|
@@ -1,21 +1,28 @@
|
|
|
package cn.ezhizao.project.business.controller;
|
|
|
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.util.List;
|
|
|
import javax.annotation.Resource;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
+import cn.ezhizao.common.utils.SecurityUtils;
|
|
|
import cn.ezhizao.framework.aspectj.lang.annotation.Log;
|
|
|
import cn.ezhizao.framework.aspectj.lang.enums.BusinessType;
|
|
|
import cn.ezhizao.framework.web.controller.BaseController;
|
|
|
import cn.ezhizao.framework.web.domain.AjaxResult;
|
|
|
import cn.ezhizao.framework.web.page.TableDataInfo;
|
|
|
import cn.ezhizao.project.business.domain.BizSupplier;
|
|
|
+import cn.ezhizao.project.business.domain.BizSupplierUser;
|
|
|
+import cn.ezhizao.project.business.domain.BizTenant;
|
|
|
import cn.ezhizao.project.business.service.IBizSupplierService;
|
|
|
+import cn.ezhizao.project.business.service.IBizSupplierUserService;
|
|
|
+import cn.ezhizao.project.business.service.IBizTenantService;
|
|
|
import io.swagger.annotations.Api;
|
|
|
import io.swagger.annotations.ApiImplicitParam;
|
|
|
import io.swagger.annotations.ApiImplicitParams;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
import org.springframework.web.bind.annotation.PostMapping;
|
|
|
import org.springframework.web.bind.annotation.PutMapping;
|
|
@@ -39,6 +46,10 @@ public class BizSupplierController extends BaseController
|
|
|
{
|
|
|
@Resource
|
|
|
private IBizSupplierService bizSupplierService;
|
|
|
+ @Resource
|
|
|
+ private IBizSupplierUserService BizSupplierUserService;
|
|
|
+ @Resource
|
|
|
+ private IBizTenantService bizTenantService;
|
|
|
|
|
|
/**
|
|
|
* 查询外协厂信息列表
|
|
@@ -59,33 +70,135 @@ public class BizSupplierController extends BaseController
|
|
|
/**
|
|
|
* 新增外协厂信息
|
|
|
*/
|
|
|
+ @ApiOperation("新增供应商")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "tenantId", value = "租户ID",dataType = "Long", paramType = "path", dataTypeClass = Long.class),
|
|
|
+ @ApiImplicitParam(name = "code", value = "供应商编码", required = true, dataType = "String", paramType = "path", dataTypeClass = String.class),
|
|
|
+ @ApiImplicitParam(name = "name", value = "供应商名称", required = true, dataType = "String", paramType = "path", dataTypeClass = String.class),
|
|
|
+ @ApiImplicitParam(name = "alias", value = "供应商别名", required = true, dataType = "String", paramType = "path", dataTypeClass = String.class),
|
|
|
+ @ApiImplicitParam(name = "mnemonicCode", value = "供应商助记码",required = true, dataType = "String", paramType = "path", dataTypeClass = String.class),
|
|
|
+ @ApiImplicitParam(name = "deliveryMethod", value = "发货方式", dataType = "String", paramType = "path", dataTypeClass = String.class),
|
|
|
+ @ApiImplicitParam(name = "settlementType", value = "结算方式", required = true, dataType = "String", paramType = "path", dataTypeClass = String.class),
|
|
|
+ @ApiImplicitParam(name = "freightPrice", value = "外协单价", dataType = "BigDecimal", paramType = "path", dataTypeClass = BigDecimal.class),
|
|
|
+ @ApiImplicitParam(name = "lossLimit", value = "损耗上限", dataType = "BigDecimal", paramType = "path", dataTypeClass = BigDecimal.class),
|
|
|
+ @ApiImplicitParam(name = "remark", value = "备注", dataType = "String", paramType = "path", dataTypeClass = String.class),
|
|
|
+ @ApiImplicitParam(name = "isInnerOutsource", value = "是否内部外协商", dataType = "Integer", paramType = "path", dataTypeClass = Integer.class),
|
|
|
+ })
|
|
|
@Log(title = "外协厂信息", businessType = BusinessType.INSERT)
|
|
|
@PostMapping
|
|
|
+ @Transactional
|
|
|
public AjaxResult add(@RequestBody BizSupplier bizSupplier) throws NoSuchFieldException, IllegalAccessException
|
|
|
{
|
|
|
if(bizSupplier.getCode() == null || bizSupplier.getCode() == ""||bizSupplier.getName() == null || bizSupplier.getName() == "" || bizSupplier.getMnemonicCode() == null
|
|
|
||bizSupplier.getMnemonicCode() == null || bizSupplier.getMnemonicCode() == "" ||bizSupplier.getSettlementType() == null || bizSupplier.getSettlementType() == ""){
|
|
|
return error("新增供应商失败,必填项:供应商编码,供应商名称,供应商助记码,结算方式不能为空");
|
|
|
}
|
|
|
+ if (bizSupplier.getTenantId() != null) {
|
|
|
+ List<BizTenant> tenantList = bizTenantService.query().eq("id", bizSupplier.getTenantId()).list();
|
|
|
+ if(tenantList.isEmpty()){
|
|
|
+ return error("新增供应商失败,租户ID不存在");
|
|
|
+ }
|
|
|
+ }
|
|
|
if(!bizSupplier.getSettlementType().equals("1") && !bizSupplier.getSettlementType().equals("2")){
|
|
|
-
|
|
|
+ return error("新增供应商失败,结算方式只能为1或2");
|
|
|
+ }
|
|
|
+ if(bizSupplier.getIsInnerOutsource() !=null && !(bizSupplier.getIsInnerOutsource() ==0 || bizSupplier.getIsInnerOutsource() ==1)){
|
|
|
+ return error("新增供应商失败,是否内部外协只能是0或1");
|
|
|
}
|
|
|
- return toAjax(bizSupplierService.save(bizSupplier));
|
|
|
+ if(bizSupplier.getDeliveryMethod()!=null &&bizSupplier.getDeliveryMethod()!="" && !(bizSupplier.getDeliveryMethod().equals("0") || bizSupplier.getDeliveryMethod().equals("1"))){
|
|
|
+ return error("新增供应商失败,送货方式只能为0或1");
|
|
|
+ }
|
|
|
+ List<BizSupplier> supplierList = bizSupplierService.query().eq("code", bizSupplier.getCode()).list();
|
|
|
+ if (!supplierList.isEmpty()) {
|
|
|
+ return AjaxResult.error("供应商编号不能重复");
|
|
|
+ }
|
|
|
+ supplierList = bizSupplierService.query().eq("mnemonic_code", bizSupplier.getMnemonicCode()).list();
|
|
|
+ if (!supplierList.isEmpty()) {
|
|
|
+ return AjaxResult.error("助记码不能重复");
|
|
|
+ }
|
|
|
+ bizSupplierService.save(bizSupplier);
|
|
|
+ BizSupplierUser user = new BizSupplierUser();
|
|
|
+ user.setTenantId(bizSupplier.getTenantId());
|
|
|
+ user.setSupplierId(bizSupplier.getId());
|
|
|
+ user.setSupplierCode(bizSupplier.getCode());
|
|
|
+ user.setSupplierName(bizSupplier.getName());
|
|
|
+ user.setUsername(bizSupplier.getCode());
|
|
|
+ user.setPassword(SecurityUtils.encryptPassword("123456"));
|
|
|
+ user.setIsAdmin("1");
|
|
|
+ boolean bool = BizSupplierUserService.save(user);
|
|
|
+ if(!bool){
|
|
|
+ return error("新增供应商失败,请重试");
|
|
|
+ }
|
|
|
+ return success();
|
|
|
+
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 修改外协厂信息
|
|
|
*/
|
|
|
+ @ApiOperation("修改供应商")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "id", value = "供应商ID", required = true, dataType = "Long", paramType = "path", dataTypeClass = Long.class),
|
|
|
+ @ApiImplicitParam(name = "tenantId", value = "租户ID",dataType = "Long", paramType = "path", dataTypeClass = Long.class),
|
|
|
+ @ApiImplicitParam(name = "code", value = "供应商编码", dataType = "String", paramType = "path", dataTypeClass = String.class),
|
|
|
+ @ApiImplicitParam(name = "name", value = "供应商名称", dataType = "String", paramType = "path", dataTypeClass = String.class),
|
|
|
+ @ApiImplicitParam(name = "alias", value = "供应商别名", dataType = "String", paramType = "path", dataTypeClass = String.class),
|
|
|
+ @ApiImplicitParam(name = "mnemonicCode", value = "供应商助记码", dataType = "String", paramType = "path", dataTypeClass = String.class),
|
|
|
+ @ApiImplicitParam(name = "deliveryMethod", value = "发货方式", dataType = "String", paramType = "path", dataTypeClass = String.class),
|
|
|
+ @ApiImplicitParam(name = "settlementType", value = "结算方式", dataType = "String", paramType = "path", dataTypeClass = String.class),
|
|
|
+ @ApiImplicitParam(name = "freightPrice", value = "外协单价", dataType = "BigDecimal", paramType = "path", dataTypeClass = BigDecimal.class),
|
|
|
+ @ApiImplicitParam(name = "lossLimit", value = "损耗上限", dataType = "BigDecimal", paramType = "path", dataTypeClass = BigDecimal.class),
|
|
|
+ @ApiImplicitParam(name = "remark", value = "备注", dataType = "String", paramType = "path", dataTypeClass = String.class),
|
|
|
+ @ApiImplicitParam(name = "isInnerOutsource", value = "是否内部外协商", dataType = "Integer", paramType = "path", dataTypeClass = Integer.class),
|
|
|
+ })
|
|
|
@Log(title = "外协厂信息", businessType = BusinessType.UPDATE)
|
|
|
@PutMapping
|
|
|
public AjaxResult edit(@RequestBody BizSupplier bizSupplier) throws NoSuchFieldException, IllegalAccessException
|
|
|
{
|
|
|
+ if(bizSupplier.getId() == null){
|
|
|
+ return error("修改供应商失败,供应商ID不能为空");
|
|
|
+ }
|
|
|
+ if(bizSupplier.getCode() == ""||bizSupplier.getName() == "" || bizSupplier.getMnemonicCode() == "" ||bizSupplier.getSettlementType() == ""){
|
|
|
+ return error("修改供应商失败,供应商编码,供应商名称,供应商助记码,结算方式不能为空");
|
|
|
+ }
|
|
|
+ if (bizSupplier.getTenantId() != null) {
|
|
|
+ List<BizTenant> tenantList = bizTenantService.query().eq("id", bizSupplier.getTenantId()).list();
|
|
|
+ if(tenantList.isEmpty()){
|
|
|
+ return error("修改供应商失败,租户ID不存在");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(bizSupplier.getSettlementType() !=null && bizSupplier.getSettlementType() != "" &&!bizSupplier.getSettlementType().equals("1") && !bizSupplier.getSettlementType().equals("2")){
|
|
|
+ return error("修改供应商失败,结算方式只能为1或2");
|
|
|
+ }
|
|
|
+ if(bizSupplier.getIsInnerOutsource() !=null && !(bizSupplier.getIsInnerOutsource() ==0 || bizSupplier.getIsInnerOutsource() ==1)){
|
|
|
+ return error("修改供应商失败,是否内部外协只能是0或1");
|
|
|
+ }
|
|
|
+ if(bizSupplier.getDeliveryMethod()!=null &&bizSupplier.getDeliveryMethod()!="" && !(bizSupplier.getDeliveryMethod().equals("0") || bizSupplier.getDeliveryMethod().equals("1"))){
|
|
|
+ return error("修改供应商失败,送货方式只能为0或1");
|
|
|
+ }
|
|
|
+
|
|
|
+ if(bizSupplier.getCode() != null) {
|
|
|
+ List<BizSupplier> supplierList = bizSupplierService.query().eq("code", bizSupplier.getCode()).ne("id", bizSupplier.getId()).list();
|
|
|
+ if (!supplierList.isEmpty()) {
|
|
|
+ return AjaxResult.error("供应商编号不能重复");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(bizSupplier.getMnemonicCode() != null) {
|
|
|
+ List<BizSupplier> supplierList = bizSupplierService.query().eq("mnemonic_code", bizSupplier.getMnemonicCode()).ne("id", bizSupplier.getId()).list();
|
|
|
+ if (!supplierList.isEmpty()) {
|
|
|
+ return AjaxResult.error("助记码不能重复");
|
|
|
+ }
|
|
|
+ }
|
|
|
return toAjax(bizSupplierService.updateById(bizSupplier));
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 删除外协厂信息
|
|
|
*/
|
|
|
+ @ApiOperation("删除外协商")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "id", value = "供应商ID", required = true, dataType = "List<Long>", paramType = "path", dataTypeClass = List.class)
|
|
|
+ })
|
|
|
@Log(title = "外协厂信息", businessType = BusinessType.DELETE)
|
|
|
@DeleteMapping("/{ids}")
|
|
|
public AjaxResult remove(@PathVariable List<Long> ids)
|