|
@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.qmth.sop.business.bean.params.AllocationParam;
|
|
|
import com.qmth.sop.business.bean.params.AutoAllocationParam;
|
|
|
+import com.qmth.sop.business.bean.params.SopPublishParam;
|
|
|
import com.qmth.sop.business.bean.params.UserArchivesAllocationParam;
|
|
|
import com.qmth.sop.business.bean.result.*;
|
|
|
import com.qmth.sop.business.entity.*;
|
|
@@ -13,9 +14,7 @@ import com.qmth.sop.business.mapper.TBUserArchivesAllocationMapper;
|
|
|
import com.qmth.sop.business.service.*;
|
|
|
import com.qmth.sop.common.base.BaseEntity;
|
|
|
import com.qmth.sop.common.contant.SystemConstant;
|
|
|
-import com.qmth.sop.common.enums.ExceptionResultEnum;
|
|
|
-import com.qmth.sop.common.enums.RoleTypeEnum;
|
|
|
-import com.qmth.sop.common.enums.UserArchivesStatusEnum;
|
|
|
+import com.qmth.sop.common.enums.*;
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
@@ -45,6 +44,10 @@ public class TBUserArchivesAllocationServiceImpl extends ServiceImpl<TBUserArchi
|
|
|
private SysUserRoleService sysUserRoleService;
|
|
|
@Resource
|
|
|
private TBUserArchivesService tbUserArchivesService;
|
|
|
+ @Resource
|
|
|
+ private TBSopInfoService tbSopInfoService;
|
|
|
+ @Resource
|
|
|
+ private TFCustomFlowService tfCustomFlowService;
|
|
|
|
|
|
@Override
|
|
|
public IPage<UserArchivesAllocationResult> findCrmAllocationPage(Long serviceUnitId, String province, String city, String area, String customName, Integer gap, Integer pageNumber, Integer pageSize) {
|
|
@@ -61,7 +64,7 @@ public class TBUserArchivesAllocationServiceImpl extends ServiceImpl<TBUserArchi
|
|
|
city = SystemConstant.translateSpecificSign(city);
|
|
|
area = SystemConstant.translateSpecificSign(area);
|
|
|
customName = SystemConstant.translateSpecificSign(customName);
|
|
|
- List<UserArchivesAllocationResult> list = this.baseMapper.findCrmAllocationSubTotal(serviceUnitId, province, city, area, customName, gap,null);
|
|
|
+ List<UserArchivesAllocationResult> list = this.baseMapper.findCrmAllocationSubTotal(serviceUnitId, province, city, area, customName, gap, null);
|
|
|
Integer publishedCrmCount = Math.toIntExact(list.stream().filter(UserArchivesAllocationResult::getPublish).count());
|
|
|
Integer totalCrmCount = list.size();
|
|
|
|
|
@@ -206,7 +209,7 @@ public class TBUserArchivesAllocationServiceImpl extends ServiceImpl<TBUserArchi
|
|
|
public void autoEditCrmAllocationBatch(AutoAllocationParam autoAllocationParam) {
|
|
|
Long serviceUnitId = autoAllocationParam.getServiceUnitId();
|
|
|
List<Long> crmIdList = autoAllocationParam.getCrmIdList();
|
|
|
- List<UserArchivesAllocationResult> crmSourceList = this.baseMapper.findCrmAllocationSubTotal(serviceUnitId, null, null, null, null, null,crmIdList);
|
|
|
+ List<UserArchivesAllocationResult> crmSourceList = this.baseMapper.findCrmAllocationSubTotal(serviceUnitId, null, null, null, null, null, crmIdList);
|
|
|
// crm按照差额倒序
|
|
|
crmSourceList = crmSourceList.stream().filter(e -> e.getUnDistributed() > 0)
|
|
|
.sorted(Comparator.comparing(UserArchivesAllocationResult::getUnDistributed).reversed())
|
|
@@ -373,8 +376,62 @@ public class TBUserArchivesAllocationServiceImpl extends ServiceImpl<TBUserArchi
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void publishSop(String crmNo) {
|
|
|
- // TODO: 2023/8/21 crm流程发布
|
|
|
+ public void publishSop(String crmNo) throws InterruptedException {
|
|
|
+ TBCrm tbCrm = tbCrmService.findByCrmNo(crmNo);
|
|
|
+ Long serviceUnitId = tbCrm.getServiceId();
|
|
|
+ if (serviceUnitId == null || serviceUnitId == 0) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("该派单还未绑定服务单元,不能发布");
|
|
|
+ }
|
|
|
+ Long crmId = tbCrm.getId();
|
|
|
+ List<Long> crmIdList = new ArrayList<>();
|
|
|
+ crmIdList.add(crmId);
|
|
|
+ List<UserArchivesAllocationResult> crmSourceList = this.baseMapper.findCrmAllocationSubTotal(serviceUnitId, null, null, null, null, null, crmIdList);
|
|
|
+ if (CollectionUtils.isEmpty(crmSourceList)) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("未找到派单信息");
|
|
|
+ } else if (crmSourceList.size() > 1) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("派单信息异常");
|
|
|
+ }
|
|
|
+ UserArchivesAllocationResult crmSource = crmSourceList.get(0);
|
|
|
+ ProductTypeEnum productType = crmSource.getCustomType();
|
|
|
+
|
|
|
+ // 发布校验
|
|
|
+ // TODO: 2023/9/6 发布校验
|
|
|
+ List<TFCustomFlow> tfCustomFlowList = tfCustomFlowService.findFlowDeploymentList();
|
|
|
+ String flowDeploymentId = null;
|
|
|
+ switch (productType) {
|
|
|
+ case OFFICE:
|
|
|
+ List<String> ofl = tfCustomFlowList.stream()
|
|
|
+ .filter(e -> e.getType().equals(TFCustomTypeEnum.OFFICE_SOP_FLOW))
|
|
|
+ .map(TFCustomFlow::getFlowDeploymentId)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ if (CollectionUtils.isEmpty(ofl)) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("发布失败,未找到教务处SOP部署信息");
|
|
|
+ } else if (ofl.size() > 1) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("发布失败,教务处SOP部署信息异常");
|
|
|
+ }
|
|
|
+ flowDeploymentId = ofl.get(0);
|
|
|
+ break;
|
|
|
+ case CLOUD_MARK:
|
|
|
+ List<String> cfl = tfCustomFlowList.stream()
|
|
|
+ .filter(e -> e.getType().equals(TFCustomTypeEnum.CLOUD_MARK_SOP_FLOW))
|
|
|
+ .map(TFCustomFlow::getFlowDeploymentId)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ if (CollectionUtils.isEmpty(cfl)) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("发布失败,未找到研究生SOP部署信息");
|
|
|
+ } else if (cfl.size() > 1) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("发布失败,研究生SOP部署信息异常");
|
|
|
+ }
|
|
|
+ flowDeploymentId = cfl.get(0);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ SopPublishParam sopPublishParam = new SopPublishParam();
|
|
|
+ sopPublishParam.setCrmNo(crmNo);
|
|
|
+ sopPublishParam.setApprove(FlowApprovePassEnum.DRAFT);
|
|
|
+ if (Objects.isNull(flowDeploymentId)) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("发布失败,未找到SOP部署信息");
|
|
|
+ }
|
|
|
+ sopPublishParam.setFlowDeploymentId(flowDeploymentId);
|
|
|
+ tbSopInfoService.sopPublish(sopPublishParam);
|
|
|
}
|
|
|
|
|
|
@Override
|