Răsfoiți Sursa

销售合同添加归属部门

yzc 1 an în urmă
părinte
comite
3ecfdb164a

+ 1 - 0
hx-admin/src/main/resources/application-test.yml

@@ -45,6 +45,7 @@ mail:
 
 hx:
     httpUrl: http://36.134.91.96:10006/test-api/
+    fileServiceUrl: http://127.0.0.1:8090
 
 # token配置
 token:

+ 5 - 0
hx-sale/src/main/java/com/fjhx/sale/entity/contract/po/Contract.java

@@ -443,4 +443,9 @@ public class Contract extends BasePo {
      */
     private String templateContent;
 
+    /**
+     * 归属部门id
+     */
+    private Long deptId;
+
 }

+ 8 - 11
hx-sale/src/main/java/com/fjhx/sale/flow/ContractFlow.java

@@ -13,6 +13,7 @@ import com.fjhx.common.enums.FlowStatusEnum1;
 import com.fjhx.common.enums.InOutType;
 import com.fjhx.common.service.coding.CodingRuleService;
 import com.fjhx.common.service.file.FtpFileService;
+import com.fjhx.common.utils.Assert;
 import com.fjhx.file.utils.ObsFileUtil;
 import com.fjhx.flow.core.FlowDelegate;
 import com.fjhx.flow.enums.FlowStatusEnum;
@@ -35,6 +36,7 @@ import com.fjhx.sale.service.contract.ContractProductBomService;
 import com.fjhx.sale.service.contract.ContractProductService;
 import com.fjhx.sale.service.contract.ContractProjectService;
 import com.fjhx.sale.service.contract.ContractService;
+import com.fjhx.tenant.utils.DeptUstil;
 import com.ruoyi.common.annotation.LogicIgnore;
 import com.ruoyi.common.core.domain.BasePo;
 import com.ruoyi.common.core.domain.entity.SysDept;
@@ -42,7 +44,6 @@ import com.ruoyi.common.core.domain.entity.SysUser;
 import com.ruoyi.common.exception.ServiceException;
 import com.ruoyi.common.utils.SecurityUtils;
 import com.ruoyi.common.utils.StringUtils;
-import com.ruoyi.framework.mybatis.holder.TenantHolder;
 import com.ruoyi.system.service.ISysDeptService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
@@ -150,6 +151,12 @@ public class ContractFlow extends FlowDelegate {
     }
 
     public Long start(ContractDto contract) {
+        //赋值归属部门,归属公司信息
+        Long deptId = contract.getDeptId();
+        Assert.notEmpty(deptId, "归属部门id不能为空!");
+        Long companyId = DeptUstil.getCompanyIdByDeptId(deptId);
+        contract.setCompanyId(companyId);
+
         // 赋值城市省份信息
         CustomizeAreaUtil.setAreaId(contract);
         SysUser loginUser = SecurityUtils.getLoginUser().getUser();
@@ -159,17 +166,7 @@ public class ContractFlow extends FlowDelegate {
         contract.setBuyProvinceId(contract.getProvinceId());
         contract.setStatus(FlowStatusEnum1.UNDER_REVIEW.getKey());
 
-        //根据归属公司将数据赋值给指定公司
-        Long companyId = contract.getCompanyId();
-        TenantHolder.setIgnore(true);
-        SysDept country = deptService.getById(companyId);
-        TenantHolder.clear();
-        if (ObjectUtil.isEmpty(country)) {
-            throw new ServiceException("归属公司不存在");
-        }
-        SecurityUtils.setTenantId(country.getTenantId());
         contractService.saveOrUpdate(contract);
-        SecurityUtils.clearTenantId();
 
         // 保存合同产品
         List<ContractProductDto> contractProductListDto = contract.getContractProductList();

+ 2 - 2
hx-sale/src/main/java/com/fjhx/sale/service/contract/impl/ContractServiceImpl.java

@@ -2722,11 +2722,11 @@ public class ContractServiceImpl extends ServiceImpl<ContractMapper, Contract>
             }
         }
         String collect = arr.stream().collect(Collectors.joining(","));
-        //消息推送 给归属公司的 总经理
+        //消息推送 给归属公司的 子公司总经理
         String title = String.format("合同【%s】发生生产标签变更,变更如下:%s", contract.getCode(), collect);
         JSONObject msg = new JSONObject();
         msg.put("business_id", dto.getId());
-        List<Long> generalManagerIds = UserUtil.getUserIdsByRoleKey("general_manager", dto.getCompanyId());
+        List<Long> generalManagerIds = UserUtil.getUserIdsByRoleKey("subsidiary_gm", dto.getCompanyId());
         for (Long generalManagerId : generalManagerIds) {
             WebSocketPush.byUser(PushTypeEnum.MESSAGE, generalManagerId, title, PushBusinessTypeEnum.CONTRACT_PRODUCTION_TAG_UPDATE.getType(), msg.toString());
         }

+ 2 - 2
hx-sale/src/main/java/com/fjhx/sale/service/sale/impl/SaleQuotationServiceImpl.java

@@ -216,10 +216,10 @@ public class SaleQuotationServiceImpl extends ServiceImpl<SaleQuotationMapper, S
         saleQuotationDto.setQuotationStatus(0);//报价状态未报价
         saveOrEdit(saleQuotationDto);
 
-        //消息推送 给归属公司的 总经理
+        //消息推送 给归属公司的 子公司总经理
         JSONObject msg = new JSONObject();
         msg.put("business_id", saleQuotationDto.getId());
-        List<Long> generalManagerIds = UserUtil.getUserIdsByRoleKey("general_manager", saleQuotationDto.getCompanyId());
+        List<Long> generalManagerIds = UserUtil.getUserIdsByRoleKey("subsidiary_gm", saleQuotationDto.getCompanyId());
         for (Long generalManagerId : generalManagerIds) {
             WebSocketPush.byUser(PushTypeEnum.MESSAGE, generalManagerId,
                     "您有新的报价单待报价,请尽快处理!",