瀏覽代碼

sop编辑去掉控制,crmProjectResult全局修改

wangliang 1 年之前
父節點
當前提交
8a09251157

+ 14 - 2
sop-business/src/main/java/com/qmth/sop/business/activiti/service/impl/ActivitiServiceImpl.java

@@ -123,6 +123,9 @@ public class ActivitiServiceImpl implements ActivitiService {
     @Resource
     TBDeviceDeliveryService tbDeviceDeliveryService;
 
+    @Resource
+    TBCrmDetailService tbCrmDetailService;
+
     /**
      * 根据deploymentId查找processDefinitionId
      *
@@ -569,7 +572,15 @@ public class ActivitiServiceImpl implements ActivitiService {
             map = this.getFlowFormPropertie(map, taskList, flowResult, tfCustomFlow);
         }
         if (Objects.nonNull(crmNo)) {
-            CrmProjectResult crmProjectResult = tbCrmService.findCrmProjectInfo(null, null, crmNo);
+            TBCrmDetail tbCrmDetail = null;
+            if (Objects.nonNull(flowId)) {
+                TFCustomFlowEntity tfCustomFlowEntity = tfCustomFlowEntityService.getOne(
+                        new QueryWrapper<TFCustomFlowEntity>().lambda().eq(TFCustomFlowEntity::getFlowId, flowId));
+                tbCrmDetail = tbCrmDetailService.findBySopNo(tfCustomFlowEntity.getCode());
+            }
+            CrmProjectResult crmProjectResult = tbCrmService.findCrmProjectInfo(
+                    Objects.nonNull(tbCrmDetail) ? tbCrmDetail.getSopNo() : null,
+                    Objects.nonNull(tbCrmDetail) ? tbCrmDetail.getId() : null, crmNo);
             if (Objects.nonNull(crmProjectResult)) {
                 map.put(SystemConstant.CRM_INFO, crmProjectResult);
             }
@@ -999,7 +1010,8 @@ public class ActivitiServiceImpl implements ActivitiService {
 
         CrmProjectResult crmProjectResult = null;
         if (Objects.nonNull(tfCustomFlowEntity.getCrmNo())) {
-            crmProjectResult = tbCrmService.findCrmProjectInfo(tfCustomFlowEntity.getCode(), null,
+            TBCrmDetail tbCrmDetail = tbCrmDetailService.findBySopNo(tfCustomFlowEntity.getCode());
+            crmProjectResult = tbCrmService.findCrmProjectInfo(tfCustomFlowEntity.getCode(), tbCrmDetail.getId(),
                     tfCustomFlowEntity.getCrmNo());
         }
         return new FlowViewResult(flowId, tfFlowApprove.getStatus(), tfCustomFlowEntity.getCode(), taskIdList,

+ 30 - 12
sop-business/src/main/java/com/qmth/sop/business/service/impl/SysUserRoleServiceImpl.java

@@ -65,6 +65,9 @@ public class SysUserRoleServiceImpl extends ServiceImpl<SysUserRoleMapper, SysUs
     @Resource
     SysUserRoleService sysUserRoleService;
 
+    @Resource
+    TBCrmDetailService tbCrmDetailService;
+
     /**
      * 获取用户菜单
      *
@@ -87,7 +90,8 @@ public class SysUserRoleServiceImpl extends ServiceImpl<SysUserRoleMapper, SysUs
         List<SysRole> sysRoleList = this.listRoleByUserId(userId);
         if (CollectionUtils.isNotEmpty(sysRoleList)) {
             List<RoleTypeEnum> targetRoleTypeList = Arrays.stream(roleTypes).collect(Collectors.toList());
-            List<RoleTypeEnum> userRoleTypeList = sysRoleList.stream().map(SysRole::getType).collect(Collectors.toList());
+            List<RoleTypeEnum> userRoleTypeList = sysRoleList.stream().map(SysRole::getType)
+                    .collect(Collectors.toList());
             if (userRoleTypeList.containsAll(targetRoleTypeList)) {
                 result = true;
             }
@@ -149,23 +153,30 @@ public class SysUserRoleServiceImpl extends ServiceImpl<SysUserRoleMapper, SysUs
         if (sysUser.getSource() == UserSourceEnum.SYSTEM) {
             throw ExceptionResultEnum.ERROR.exception("非档案用户不能发起异常补卡申请");
         }
-        TBUserArchives tbUserArchives = tbUserArchivesService.getOne(new QueryWrapper<TBUserArchives>().lambda().eq(TBUserArchives::getMobileNumber, sysUser.getMobileNumber()));
+        TBUserArchives tbUserArchives = tbUserArchivesService.getOne(new QueryWrapper<TBUserArchives>().lambda()
+                .eq(TBUserArchives::getMobileNumber, sysUser.getMobileNumber()));
         Optional.ofNullable(tbUserArchives).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("档案用户不存在"));
 
-        TBUserArchivesSupplier tbUserArchivesSupplier = tbUserArchivesSupplierService.getOne(new QueryWrapper<TBUserArchivesSupplier>().lambda().eq(TBUserArchivesSupplier::getUserArchivesId, tbUserArchives.getId()));
+        TBUserArchivesSupplier tbUserArchivesSupplier = tbUserArchivesSupplierService.getOne(
+                new QueryWrapper<TBUserArchivesSupplier>().lambda()
+                        .eq(TBUserArchivesSupplier::getUserArchivesId, tbUserArchives.getId()));
         Optional.ofNullable(tbUserArchivesSupplier).orElseThrow(() -> ExceptionResultEnum.ERROR.exception("档案机构不存在"));
 
         List<SysRole> userArchivesRoleList = sysUserRoleService.listRoleByUserId(sysUser.getId());
-        Map<Long, SysRole> userArchivesRoleMap = userArchivesRoleList.stream().collect(Collectors.toMap(SysRole::getId, Function.identity(), (dto1, dto2) -> dto1));
+        Map<Long, SysRole> userArchivesRoleMap = userArchivesRoleList.stream()
+                .collect(Collectors.toMap(SysRole::getId, Function.identity(), (dto1, dto2) -> dto1));
 
-        List<SysDingGroup> sysDingGroupList = sysDingGroupService.list(new QueryWrapper<SysDingGroup>().lambda().eq(SysDingGroup::getServiceId, serviceId).eq(SysDingGroup::getSupplierId, tbUserArchivesSupplier.getSupplierId()));
+        List<SysDingGroup> sysDingGroupList = sysDingGroupService.list(
+                new QueryWrapper<SysDingGroup>().lambda().eq(SysDingGroup::getServiceId, serviceId)
+                        .eq(SysDingGroup::getSupplierId, tbUserArchivesSupplier.getSupplierId()));
         if (CollectionUtils.isEmpty(sysDingGroupList)) {
             throw ExceptionResultEnum.SERVICE_DING_GROUP_NO_DATA.exception();
         }
         List<String> userIdList = null;
         for (SysDingGroup sysDingGroup : sysDingGroupList) {
             //首选找考勤对象
-            List<SysDingObj> sysDingObjList = sysDingObjService.list(new QueryWrapper<SysDingObj>().lambda().eq(SysDingObj::getDingGroupId, sysDingGroup.getId()));
+            List<SysDingObj> sysDingObjList = sysDingObjService.list(
+                    new QueryWrapper<SysDingObj>().lambda().eq(SysDingObj::getDingGroupId, sysDingGroup.getId()));
             if (CollectionUtils.isEmpty(sysDingObjList)) {
                 throw ExceptionResultEnum.SERVICE_DING_NO_DATA.exception();
             }
@@ -206,16 +217,21 @@ public class SysUserRoleServiceImpl extends ServiceImpl<SysUserRoleMapper, SysUs
                         userIdList.addAll(serviceLeadIdList);
                     }
                 } else if (s.getType() == RoleTypeEnum.REGION_MANAGER) {
-                    CrmProjectResult crmProjectResult = tbCrmService.findCrmProjectInfo(sopNo,null, null);
+                    TBCrmDetail tbCrmDetail = tbCrmDetailService.findBySopNo(sopNo);
+                    CrmProjectResult crmProjectResult = tbCrmService.findCrmProjectInfo(sopNo, tbCrmDetail.getId(),
+                            tbCrmDetail.getCrmNo());
                     if (Objects.nonNull(crmProjectResult) && Objects.nonNull(crmProjectResult.getRegionManagerId())) {
                         userIdList.addAll(Arrays.asList(String.valueOf(crmProjectResult.getRegionManagerId())));
                     }
                 } else if (s.getType() == RoleTypeEnum.REGION_COORDINATOR) {
-                    CrmProjectResult crmProjectResult = tbCrmService.findCrmProjectInfo(sopNo, null,null);
+                    TBCrmDetail tbCrmDetail = tbCrmDetailService.findBySopNo(sopNo);
+                    CrmProjectResult crmProjectResult = tbCrmService.findCrmProjectInfo(sopNo, tbCrmDetail.getId(),
+                            tbCrmDetail.getCrmNo());
                     if (Objects.nonNull(crmProjectResult)) {
                         List<UserArchivesDto> regionCoordinatorIdList = crmProjectResult.getRegionCoordinatorList();
-                        if (CollectionUtils.isNotEmpty(regionCoordinatorIdList)){
-                            userIdList.addAll(Arrays.asList(String.valueOf(regionCoordinatorIdList.get(0).getUserId())));
+                        if (CollectionUtils.isNotEmpty(regionCoordinatorIdList)) {
+                            userIdList.addAll(
+                                    Arrays.asList(String.valueOf(regionCoordinatorIdList.get(0).getUserId())));
                         }
 
                     }
@@ -224,8 +240,10 @@ public class SysUserRoleServiceImpl extends ServiceImpl<SysUserRoleMapper, SysUs
                 }
             }
             if (!CollectionUtils.isEmpty(sysRoleOtherList)) {
-                List<SysUserRole> sysUserRoleList = this.list(new QueryWrapper<SysUserRole>().lambda().in(SysUserRole::getRoleId, sysRoleOtherList));
-                List<String> otherRoleUserList = sysUserRoleList.stream().map(i -> String.valueOf(i.getUserId())).collect(Collectors.toList());
+                List<SysUserRole> sysUserRoleList = this.list(
+                        new QueryWrapper<SysUserRole>().lambda().in(SysUserRole::getRoleId, sysRoleOtherList));
+                List<String> otherRoleUserList = sysUserRoleList.stream().map(i -> String.valueOf(i.getUserId()))
+                        .collect(Collectors.toList());
                 userIdList.addAll(otherRoleUserList);
             }
             break;

+ 14 - 4
sop-business/src/main/java/com/qmth/sop/business/service/impl/TBDingApplyServiceImpl.java

@@ -83,6 +83,9 @@ public class TBDingApplyServiceImpl extends ServiceImpl<TBDingApplyMapper, TBDin
     @Resource
     TBUserArchivesAllocationService tbUserArchivesAllocationService;
 
+    @Resource
+    TBCrmDetailService tbCrmDetailService;
+
     /**
      * 新增考勤异常补卡申请
      *
@@ -102,7 +105,12 @@ public class TBDingApplyServiceImpl extends ServiceImpl<TBDingApplyMapper, TBDin
         if (count == 0) {
             throw ExceptionResultEnum.ERROR.exception("该用户剩余补卡次数为0");
         }
-        CrmProjectResult crmProjectResult = tbCrmService.findCrmProjectInfo(sopNo, null, crmNo);
+        TBCrmDetail tbCrmDetail = null;
+        if (Objects.nonNull(sopNo)) {
+            tbCrmDetail = tbCrmDetailService.findBySopNo(sopNo);
+        }
+        CrmProjectResult crmProjectResult = tbCrmService.findCrmProjectInfo(sopNo,
+                Objects.nonNull(tbCrmDetail) ? tbCrmDetail.getId() : null, crmNo);
         Optional.ofNullable(crmProjectResult).orElseThrow(ExceptionResultEnum.CRM_NO_NO_DATA::exception);
 
         List<String> sysUserRoleList = sysUserRoleService.listByServiceId(crmProjectResult.getServiceUnitId(),
@@ -421,12 +429,13 @@ public class TBDingApplyServiceImpl extends ServiceImpl<TBDingApplyMapper, TBDin
                 .eq(TBDingApply::getDingExceptionNo, tfCustomFlowEntity.getCode()));
         Optional.ofNullable(tbDingApply).orElseThrow(() -> ExceptionResultEnum.DING_APPLY_NO_DATA.exception());
 
+        TBCrmDetail tbCrmDetail = tbCrmDetailService.findBySopNo(tfCustomFlowEntity.getCode());
         CrmProjectResult crmProjectResult = tbCrmService.findCrmProjectInfo(tfCustomFlowEntity.getCode(),
-                null,tfCustomFlowEntity.getCrmNo());
+                tbCrmDetail.getId(), tfCustomFlowEntity.getCrmNo());
         Optional.ofNullable(crmProjectResult).orElseThrow(() -> ExceptionResultEnum.CRM_NO_NO_DATA.exception());
 
         List<UserArchivesDto> regionCoordinatorList = crmProjectResult.getRegionCoordinatorList();
-        if (CollectionUtils.isEmpty(regionCoordinatorList)){
+        if (CollectionUtils.isEmpty(regionCoordinatorList)) {
             throw ExceptionResultEnum.ERROR.exception("crm区域协调人数据为空");
         }
         Optional.ofNullable(regionCoordinatorList.get(0).getUserId())
@@ -455,7 +464,8 @@ public class TBDingApplyServiceImpl extends ServiceImpl<TBDingApplyMapper, TBDin
         TBDingApply tbDingApply = this.getById(id);
         Optional.ofNullable(tbDingApply).orElseThrow(() -> ExceptionResultEnum.DING_APPLY_NO_DATA.exception());
 
-        CrmProjectResult crmProjectResult = tbCrmService.findCrmProjectInfo(tbDingApply.getSopNo(),null,
+        TBCrmDetail tbCrmDetail = tbCrmDetailService.findBySopNo(tbDingApply.getSopNo());
+        CrmProjectResult crmProjectResult = tbCrmService.findCrmProjectInfo(tbDingApply.getSopNo(), tbCrmDetail.getId(),
                 tbDingApply.getCrmNo());
         Optional.ofNullable(crmProjectResult).orElseThrow(() -> ExceptionResultEnum.CRM_NO_NO_DATA.exception());
 

+ 73 - 31
sop-business/src/main/java/com/qmth/sop/business/service/impl/TBProjectExchangeServiceImpl.java

@@ -39,7 +39,8 @@ import java.util.stream.Collectors;
  * @since 2023-08-01
  */
 @Service
-public class TBProjectExchangeServiceImpl extends ServiceImpl<TBProjectExchangeMapper, TBProjectExchange> implements TBProjectExchangeService {
+public class TBProjectExchangeServiceImpl extends ServiceImpl<TBProjectExchangeMapper, TBProjectExchange>
+        implements TBProjectExchangeService {
 
     @Resource
     ActivitiService activitiService;
@@ -71,6 +72,9 @@ public class TBProjectExchangeServiceImpl extends ServiceImpl<TBProjectExchangeM
     @Resource
     TFCustomFlowAllocationService tfCustomFlowAllocationService;
 
+    @Resource
+    TBCrmDetailService tbCrmDetailService;
+
     /**
      * 新增项目变更计划申请
      *
@@ -81,23 +85,31 @@ public class TBProjectExchangeServiceImpl extends ServiceImpl<TBProjectExchangeM
     @Override
     @Transactional
     public Boolean saveProjectExchange(TBProjectExchange tbProjectExchange) throws InterruptedException {
-        if (tbProjectExchange.getFlowApprove() != FlowApprovePassEnum.START && tbProjectExchange.getFlowApprove() != FlowApprovePassEnum.DRAFT) {
+        if (tbProjectExchange.getFlowApprove() != FlowApprovePassEnum.START
+                && tbProjectExchange.getFlowApprove() != FlowApprovePassEnum.DRAFT) {
             throw ExceptionResultEnum.PARAMS_ERROR.exception("项目计划变更申请只能为提交或草稿");
         }
         SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
 
-        TFCustomFlowAllocation tfCustomFlowAllocation = tfCustomFlowAllocationService.getOne(new QueryWrapper<TFCustomFlowAllocation>().lambda().eq(TFCustomFlowAllocation::getType, TFCustomTypeEnum.PROJECT_EXCHANGE_FLOW));
-        Optional.ofNullable(tfCustomFlowAllocation).orElseThrow(() -> ExceptionResultEnum.FLOW_ALLOCATION_NO_DATA.exception());
-        Optional.ofNullable(tfCustomFlowAllocation.getRoleAllocation()).orElseThrow(() -> ExceptionResultEnum.FLOW_ALLOCATION_NO_DATA.exception());
+        TFCustomFlowAllocation tfCustomFlowAllocation = tfCustomFlowAllocationService.getOne(
+                new QueryWrapper<TFCustomFlowAllocation>().lambda()
+                        .eq(TFCustomFlowAllocation::getType, TFCustomTypeEnum.PROJECT_EXCHANGE_FLOW));
+        Optional.ofNullable(tfCustomFlowAllocation)
+                .orElseThrow(() -> ExceptionResultEnum.FLOW_ALLOCATION_NO_DATA.exception());
+        Optional.ofNullable(tfCustomFlowAllocation.getRoleAllocation())
+                .orElseThrow(() -> ExceptionResultEnum.FLOW_ALLOCATION_NO_DATA.exception());
 
-        List<RoleTypeEnum> roleTypeEnumList = tfCustomFlowAllocationService.getRoleTypes(tfCustomFlowAllocation.getRoleAllocation(), 2);
+        List<RoleTypeEnum> roleTypeEnumList = tfCustomFlowAllocationService.getRoleTypes(
+                tfCustomFlowAllocation.getRoleAllocation(), 2);
         //查询所有审核角色
         List<UserDto> userDtoList = sysUserRoleService.userListByRoleType(roleTypeEnumList);
         if (CollectionUtils.isEmpty(userDtoList)) {
             throw ExceptionResultEnum.ERROR.exception("系统中没有" + roleTypeEnumList + "角色的用户");
         }
-        List<String> approveUserIds = userDtoList.stream().map(s -> String.valueOf(s.getId())).collect(Collectors.toList());
-        FlowApproveParam flowApproveParam = new FlowApproveParam(tbProjectExchange.getFlowDeploymentId(), tbProjectExchange.getFlowApprove(), approveUserIds, tbProjectExchange.getCrmNo());
+        List<String> approveUserIds = userDtoList.stream().map(s -> String.valueOf(s.getId()))
+                .collect(Collectors.toList());
+        FlowApproveParam flowApproveParam = new FlowApproveParam(tbProjectExchange.getFlowDeploymentId(),
+                tbProjectExchange.getFlowApprove(), approveUserIds, tbProjectExchange.getCrmNo());
         flowApproveParam.setApproveRemark(tbProjectExchange.getFlowApprove().getTitle());
         Map<String, Object> map = activitiService.taskApprove(flowApproveParam);
         TFCustomFlowEntity tfCustomFlowEntity = (TFCustomFlowEntity) map.get(SystemConstant.FLOW_ENTITY);
@@ -123,16 +135,24 @@ public class TBProjectExchangeServiceImpl extends ServiceImpl<TBProjectExchangeM
      * @return
      */
     @Override
-    public IPage<ProjectExchangeResult> list(IPage<Map> iPage, Long serviceId, Long createUserId, DelayWarnTypeEnum type, ProductTypeEnum customType, ProjectExchangeFlowStatusEnum flowStatus, String customName, String exchangeNo, Long startTime, Long endTime) {
+    public IPage<ProjectExchangeResult> list(IPage<Map> iPage, Long serviceId, Long createUserId,
+            DelayWarnTypeEnum type, ProductTypeEnum customType, ProjectExchangeFlowStatusEnum flowStatus,
+            String customName, String exchangeNo, Long startTime, Long endTime) {
         SysUser requestUser = (SysUser) ServletUtil.getRequestUser();
         DataPermissionDto dpr = sysUserService.buildUserDataPermission(requestUser.getId());
-        IPage<ProjectExchangeResult> list = this.baseMapper.list(iPage, serviceId, createUserId, Objects.nonNull(type) ? type.name() : null, Objects.nonNull(customType) ? customType.name() : null, Objects.nonNull(flowStatus) ? flowStatus.name() : null, customName, exchangeNo, startTime, endTime, dpr);
+        IPage<ProjectExchangeResult> list = this.baseMapper.list(iPage, serviceId, createUserId,
+                Objects.nonNull(type) ? type.name() : null, Objects.nonNull(customType) ? customType.name() : null,
+                Objects.nonNull(flowStatus) ? flowStatus.name() : null, customName, exchangeNo, startTime, endTime,
+                dpr);
         for (ProjectExchangeResult p : list.getRecords()) {
             TFFlowLog tfFlowLog = tfFlowLogService.findByLastFlowLog(p.getFlowId());
             if (Objects.nonNull(tfFlowLog) && Objects.nonNull(tfFlowLog.getPendApproveId())) {
-                List<String> userList = Arrays.asList(tfFlowLog.getPendApproveId().split(SystemConstant.LIST_JOIN_SPLIT));
-                List<OrgUserNameDto> orgUserNameDtoList = sysUserService.findOrgUserName(userList.stream().map(s -> Long.parseLong(s)).collect(Collectors.toList()));
-                List<String> userName = orgUserNameDtoList.stream().map(s -> s.getOrgUserName()).collect(Collectors.toList());
+                List<String> userList = Arrays.asList(
+                        tfFlowLog.getPendApproveId().split(SystemConstant.LIST_JOIN_SPLIT));
+                List<OrgUserNameDto> orgUserNameDtoList = sysUserService.findOrgUserName(
+                        userList.stream().map(s -> Long.parseLong(s)).collect(Collectors.toList()));
+                List<String> userName = orgUserNameDtoList.stream().map(s -> s.getOrgUserName())
+                        .collect(Collectors.toList());
                 p.setApproveUsersName(StringUtils.join(userName, SystemConstant.LIST_JOIN_SPLIT));
             }
             if (Objects.nonNull(p.getTaskId())) {
@@ -143,7 +163,8 @@ public class TBProjectExchangeServiceImpl extends ServiceImpl<TBProjectExchangeM
                     List<IdentityLink> identityLinkList = taskService.getIdentityLinksForTask(task.getId());
                     if (!CollectionUtils.isEmpty(identityLinkList)) {
                         for (IdentityLink i : identityLinkList) {
-                            if (Objects.nonNull(i.getUserId()) && i.getUserId().equals(requestUser.getId().toString())) {
+                            if (Objects.nonNull(i.getUserId()) && i.getUserId()
+                                    .equals(requestUser.getId().toString())) {
                                 p.setMyself(true);
                             }
                         }
@@ -167,9 +188,11 @@ public class TBProjectExchangeServiceImpl extends ServiceImpl<TBProjectExchangeM
      */
     @Override
     @Transactional
-    public Boolean flowApprove(Long taskId, FlowApprovePassEnum flowApprove, ProjectExchangeApproveEnum projectExchangeApprove, String remark, Long userId) throws InterruptedException {
+    public Boolean flowApprove(Long taskId, FlowApprovePassEnum flowApprove,
+            ProjectExchangeApproveEnum projectExchangeApprove, String remark, Long userId) throws InterruptedException {
         Optional.ofNullable(taskId).orElseThrow(() -> ExceptionResultEnum.FLOW_TASK_ID_IS_NULL.exception());
-        if (flowApprove != FlowApprovePassEnum.START && flowApprove != FlowApprovePassEnum.PASS && flowApprove != FlowApprovePassEnum.DRAFT) {
+        if (flowApprove != FlowApprovePassEnum.START && flowApprove != FlowApprovePassEnum.PASS
+                && flowApprove != FlowApprovePassEnum.DRAFT) {
             throw ExceptionResultEnum.PARAMS_ERROR.exception("项目计划变更审批只能为通过或草稿");
         }
         SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
@@ -178,15 +201,21 @@ public class TBProjectExchangeServiceImpl extends ServiceImpl<TBProjectExchangeM
         Optional.ofNullable(task).orElseThrow(() -> ExceptionResultEnum.FLOW_TASK_NO_DATA.exception());
 
         List<String> taskApproveUserList = activitiService.getTaskApprove(task);
-        if (!CollectionUtils.isEmpty(taskApproveUserList) && !taskApproveUserList.contains(sysUser.getId().toString())) {
+        if (!CollectionUtils.isEmpty(taskApproveUserList) && !taskApproveUserList.contains(
+                sysUser.getId().toString())) {
             throw ExceptionResultEnum.FLOW_DATA_NOT_ME.exception();
         }
 
-        TFCustomFlowEntity tfCustomFlowEntity = tfCustomFlowEntityService.getOne(new QueryWrapper<TFCustomFlowEntity>().lambda().eq(TFCustomFlowEntity::getFlowId, Long.parseLong(task.getProcessInstanceId())));
-        activitiService.taskApprove(new FlowApproveParam(taskId, flowApprove, Arrays.asList(String.valueOf(userId)), tfCustomFlowEntity.getCrmNo(), projectExchangeApprove.getTitle() + ";" + remark));
+        TFCustomFlowEntity tfCustomFlowEntity = tfCustomFlowEntityService.getOne(
+                new QueryWrapper<TFCustomFlowEntity>().lambda()
+                        .eq(TFCustomFlowEntity::getFlowId, Long.parseLong(task.getProcessInstanceId())));
+        activitiService.taskApprove(new FlowApproveParam(taskId, flowApprove, Arrays.asList(String.valueOf(userId)),
+                tfCustomFlowEntity.getCrmNo(), projectExchangeApprove.getTitle() + ";" + remark));
 
-        TBProjectExchange tbProjectExchange = this.getOne(new QueryWrapper<TBProjectExchange>().lambda().eq(TBProjectExchange::getExchangeNo, tfCustomFlowEntity.getCode()));
-        Optional.ofNullable(tbProjectExchange).orElseThrow(() -> ExceptionResultEnum.PROJECT_EXCHANGE_NO_DATA.exception());
+        TBProjectExchange tbProjectExchange = this.getOne(new QueryWrapper<TBProjectExchange>().lambda()
+                .eq(TBProjectExchange::getExchangeNo, tfCustomFlowEntity.getCode()));
+        Optional.ofNullable(tbProjectExchange)
+                .orElseThrow(() -> ExceptionResultEnum.PROJECT_EXCHANGE_NO_DATA.exception());
 
         tbProjectExchange.setResult(projectExchangeApprove);
         tbProjectExchange.setRemark(remark);
@@ -202,16 +231,22 @@ public class TBProjectExchangeServiceImpl extends ServiceImpl<TBProjectExchangeM
     @Override
     public TBProjectExchangeViewResult view(Long id) {
         TBProjectExchange tbProjectExchange = this.getById(id);
-        Optional.ofNullable(tbProjectExchange).orElseThrow(() -> ExceptionResultEnum.PROJECT_EXCHANGE_NO_DATA.exception());
+        Optional.ofNullable(tbProjectExchange)
+                .orElseThrow(() -> ExceptionResultEnum.PROJECT_EXCHANGE_NO_DATA.exception());
 
-        CrmProjectResult crmProjectResult = tbCrmService.findCrmProjectInfo(tbProjectExchange.getSopNo(),null, tbProjectExchange.getCrmNo());
+        TBCrmDetail tbCrmDetail = tbCrmDetailService.findBySopNo(tbProjectExchange.getSopNo());
+        CrmProjectResult crmProjectResult = tbCrmService.findCrmProjectInfo(tbProjectExchange.getSopNo(),
+                tbCrmDetail.getId(), tbProjectExchange.getCrmNo());
         Optional.ofNullable(crmProjectResult).orElseThrow(() -> ExceptionResultEnum.CRM_NO_NO_DATA.exception());
 
-        TFCustomFlowEntity tfCustomFlowEntity = tfCustomFlowEntityService.getOne(new QueryWrapper<TFCustomFlowEntity>().lambda().eq(TFCustomFlowEntity::getCode, tbProjectExchange.getExchangeNo()));
+        TFCustomFlowEntity tfCustomFlowEntity = tfCustomFlowEntityService.getOne(
+                new QueryWrapper<TFCustomFlowEntity>().lambda()
+                        .eq(TFCustomFlowEntity::getCode, tbProjectExchange.getExchangeNo()));
         Optional.ofNullable(tfCustomFlowEntity).orElseThrow(() -> ExceptionResultEnum.FLOW_ENTITY_NO_DATA.exception());
 
         //获取当前流程节点
-        TFFlowApprove tfFlowApprove = tfFlowApproveService.getOne(new QueryWrapper<TFFlowApprove>().lambda().eq(TFFlowApprove::getFlowId, tfCustomFlowEntity.getFlowId()));
+        TFFlowApprove tfFlowApprove = tfFlowApproveService.getOne(new QueryWrapper<TFFlowApprove>().lambda()
+                .eq(TFFlowApprove::getFlowId, tfCustomFlowEntity.getFlowId()));
         Optional.ofNullable(tfFlowApprove).orElseThrow(() -> ExceptionResultEnum.FLOW_APPROVE_NO_DATA.exception());
 
         FlowResult flowResult = JSONObject.parseObject(tfCustomFlowEntity.getFlowProcessVar(), FlowResult.class);
@@ -225,8 +260,10 @@ public class TBProjectExchangeServiceImpl extends ServiceImpl<TBProjectExchangeM
         Map<Integer, Integer> approveSetupMap = new HashMap<>();
         List<TFFlowLogResult> tfFlowLogResultList = tfFlowLogService.findByObjectId(tfCustomFlowEntity.getId());
         if (!CollectionUtils.isEmpty(tfFlowLogResultList)) {
-            flowApproveHistoryList = GsonUtil.fromJson(GsonUtil.toJson(tfFlowLogResultList), new TypeToken<List<TFFlowViewLogResult>>() {
-            }.getType());
+            flowApproveHistoryList = GsonUtil.fromJson(GsonUtil.toJson(tfFlowLogResultList),
+                    new TypeToken<List<TFFlowViewLogResult>>() {
+
+                    }.getType());
             for (TFFlowViewLogResult t : flowApproveHistoryList) {
                 t.setMessageType(FlowMsgTypeEnum.STANDARD);
                 approveSetupMap.put(t.getApproveSetup(), t.getApproveSetup());
@@ -239,18 +276,23 @@ public class TBProjectExchangeServiceImpl extends ServiceImpl<TBProjectExchangeM
             FlowTaskResult flowTaskResult = GsonUtil.fromJson(GsonUtil.toJson(entry.getValue()), FlowTaskResult.class);
             if (flowTaskResult.getSetup() > 0) {
                 //正在审批的表单
-                if (Objects.nonNull(tfFlowApprove.getSetup()) && flowTaskResult.getSetup().intValue() == tfFlowApprove.getSetup().intValue()) {
+                if (Objects.nonNull(tfFlowApprove.getSetup())
+                        && flowTaskResult.getSetup().intValue() == tfFlowApprove.getSetup().intValue()) {
                     currFlowTaskResult = flowTaskResult;
-                    List<Task> taskList = taskService.createTaskQuery().processInstanceId(String.valueOf(tfCustomFlowEntity.getFlowId())).list();
+                    List<Task> taskList = taskService.createTaskQuery()
+                            .processInstanceId(String.valueOf(tfCustomFlowEntity.getFlowId())).list();
                     if (!CollectionUtils.isEmpty(taskList)) {
                         taskIdList = taskList.stream().map(s -> Long.parseLong(s.getId())).collect(Collectors.toList());
                     }
                 } else if (approveSetupMap.containsKey(flowTaskResult.getSetup())) {//已经审批过的表单
-                    flowTaskHistoryList = CollectionUtils.isEmpty(flowTaskHistoryList) ? new ArrayList<>(approveSetupMap.size()) : flowTaskHistoryList;
+                    flowTaskHistoryList = CollectionUtils.isEmpty(flowTaskHistoryList) ?
+                            new ArrayList<>(approveSetupMap.size()) :
+                            flowTaskHistoryList;
                     flowTaskHistoryList.add(flowTaskResult);
                 }
             }
         }
-        return new TBProjectExchangeViewResult(crmProjectResult, tbProjectExchange, taskIdList, flowTaskHistoryList, currFlowTaskResult, flowApproveHistoryList);
+        return new TBProjectExchangeViewResult(crmProjectResult, tbProjectExchange, taskIdList, flowTaskHistoryList,
+                currFlowTaskResult, flowApproveHistoryList);
     }
 }

+ 8 - 28
sop-business/src/main/java/com/qmth/sop/business/service/impl/TBSopInfoServiceImpl.java

@@ -1027,34 +1027,13 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
         Optional.ofNullable(tfFlowApprove).orElseThrow(() -> ExceptionResultEnum.FLOW_APPROVE_NO_DATA.exception());
 
         FlowResult flowResult = JSONObject.parseObject(tfCustomFlowEntity.getFlowProcessVar(), FlowResult.class);
-        FlowResult flowResultNew = new FlowResult();
-        BeanUtils.copyProperties(flowResult, flowResultNew);
-        LinkedHashMap<String, FlowTaskResult> setupMap = flowResult.getSetupMap();
-        LinkedHashMap<String, FlowTaskResult> setupMapNew = new LinkedHashMap<>(setupMap.size());
-        for (Map.Entry<String, FlowTaskResult> entry : setupMap.entrySet()) {
-            if (entry.getValue().getSetup().intValue() > 0) {
-                if (entry.getValue().getSetup().intValue() == 1 || entry.getValue().getSetup().intValue() == 3) {
-                    for (FlowFormWidgetResult f : entry.getValue().getFormProperty()) {
-                        f.setReadable(true);
-                        f.setWritable(false);
-                    }
-                }
-                if (tfFlowApprove.getSetup().intValue() != 0 && tfFlowApprove.getSetup().intValue() < entry.getValue()
-                        .getSetup().intValue()) {
-                    break;
-                } else if (entry.getValue().getSetup().intValue() != tfFlowApprove.getSetup().intValue()) {
-                    setupMapNew.put(entry.getKey(), entry.getValue());
-                }
-            }
-        }
-        flowResultNew.setSetupMap(setupMapNew);
-
-        CrmProjectResult crmProjectResult = tbCrmService.findCrmProjectInfo(tfCustomFlowEntity.getCode(), null,
-                tfCustomFlowEntity.getCrmNo());
+        TBCrmDetail tbCrmDetail = tbCrmDetailService.findBySopNo(tfCustomFlowEntity.getCode());
+        CrmProjectResult crmProjectResult = tbCrmService.findCrmProjectInfo(tfCustomFlowEntity.getCode(),
+                tbCrmDetail.getId(), tfCustomFlowEntity.getCrmNo());
         Optional.ofNullable(crmProjectResult).orElseThrow(() -> ExceptionResultEnum.CRM_NO_NO_DATA.exception());
 
-        flowResultNew.setCrmInfo(crmProjectResult);
-        return flowResultNew;
+        flowResult.setCrmInfo(crmProjectResult);
+        return flowResult;
     }
 
     /**
@@ -1102,8 +1081,9 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
         tfCustomFlowEntity.setFlowProcessVar(JacksonUtil.parseJson(flowResult));
         if (tfFlowApprove.getStatus() != FlowStatusEnum.FINISH && tfFlowApprove.getStatus() != FlowStatusEnum.END) {
             Map<String, Object> map = new HashMap<>();
-            CrmProjectResult crmProjectResult = tbCrmService.findCrmProjectInfo(tfCustomFlowEntity.getCode(), null,
-                    tfCustomFlowEntity.getCrmNo());
+            TBCrmDetail tbCrmDetail = tbCrmDetailService.findBySopNo(tfCustomFlowEntity.getCode());
+            CrmProjectResult crmProjectResult = tbCrmService.findCrmProjectInfo(tfCustomFlowEntity.getCode(),
+                    tbCrmDetail.getId(), tfCustomFlowEntity.getCrmNo());
             Optional.ofNullable(crmProjectResult).orElseThrow(() -> ExceptionResultEnum.CRM_NO_NO_DATA.exception());
 
             TFFlowLog tfFlowLog = tfFlowLogService.getOne(