Browse Source

Merge remote-tracking branch 'origin/dev_1.1.0' into dev_1.1.0

wangliang 1 năm trước cách đây
mục cha
commit
33b133c844
20 tập tin đã thay đổi với 212 bổ sung132 xóa
  1. 26 1
      sop-api/src/main/java/com/qmth/sop/server/api/FxxkAsyncController.java
  2. 1 1
      sop-api/src/main/java/com/qmth/sop/server/api/TBCrmController.java
  3. 1 1
      sop-api/src/main/java/com/qmth/sop/server/api/TBDingController.java
  4. BIN
      sop-api/src/main/resources/static/delivery.xlsx
  5. 2 2
      sop-business/src/main/java/com/qmth/sop/business/activiti/service/impl/ActivitiServiceImpl.java
  6. 3 1
      sop-business/src/main/java/com/qmth/sop/business/bean/dto/DeviceDeliveryImportDto.java
  7. 30 42
      sop-business/src/main/java/com/qmth/sop/business/bean/result/CrmProjectResult.java
  8. 23 0
      sop-business/src/main/java/com/qmth/sop/business/entity/TBDeviceDelivery.java
  9. 8 10
      sop-business/src/main/java/com/qmth/sop/business/service/TBCrmService.java
  10. 9 4
      sop-business/src/main/java/com/qmth/sop/business/service/impl/SysUserRoleServiceImpl.java
  11. 1 1
      sop-business/src/main/java/com/qmth/sop/business/service/impl/TBCrmDetailServiceImpl.java
  12. 77 47
      sop-business/src/main/java/com/qmth/sop/business/service/impl/TBCrmServiceImpl.java
  13. 6 3
      sop-business/src/main/java/com/qmth/sop/business/service/impl/TBDeviceDeliveryServiceImpl.java
  14. 11 5
      sop-business/src/main/java/com/qmth/sop/business/service/impl/TBDingApplyServiceImpl.java
  15. 1 1
      sop-business/src/main/java/com/qmth/sop/business/service/impl/TBProjectExchangeServiceImpl.java
  16. 4 4
      sop-business/src/main/java/com/qmth/sop/business/service/impl/TBSopInfoServiceImpl.java
  17. 3 1
      sop-business/src/main/resources/db/log/caozixuan_update_log.sql
  18. 4 3
      sop-business/src/main/resources/db/log/haoguanghui_update_log.sql
  19. 0 4
      sop-business/src/main/resources/mapper/TBCrmMapper.xml
  20. 2 1
      sop-common/src/main/java/com/qmth/sop/common/enums/SequenceEnum.java

+ 26 - 1
sop-api/src/main/java/com/qmth/sop/server/api/FxxkAsyncController.java

@@ -1,9 +1,11 @@
 package com.qmth.sop.server.api;
 
+import com.alibaba.fastjson.JSON;
 import com.qmth.boot.api.annotation.Aac;
 import com.qmth.boot.api.constant.ApiConstant;
 import com.qmth.sop.business.sync.FxxkApiUtils;
 import com.qmth.sop.business.sync.been.fxxk.FxxkAppAuthInfo;
+import com.qmth.sop.business.sync.been.fxxk.FxxkCrm;
 import com.qmth.sop.common.contant.SystemConstant;
 import com.qmth.sop.common.util.Result;
 import com.qmth.sop.common.util.ResultUtil;
@@ -14,6 +16,10 @@ import io.swagger.annotations.ApiResponses;
 import org.springframework.web.bind.annotation.*;
 
 import javax.annotation.Resource;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
 
 /**
  * @Description: 分享逍客同步控制器
@@ -65,6 +71,25 @@ public class FxxkAsyncController {
     @RequestMapping(value = "/find/custom_list", method = RequestMethod.POST)
     @Aac(auth = false)
     public Result findCustomList() {
-        return ResultUtil.ok(fxxkApiUtils.findCustomList());
+        List<FxxkCrm> fxxkCrmList = fxxkApiUtils.findCustomList();
+        Map<String,FxxkCrm> map = new HashMap<>();
+        List<String> crmNoList = new ArrayList<>();
+        for (FxxkCrm fxxkCrm : fxxkCrmList) {
+            String crmNo = fxxkCrm.getCrmNo();
+            String province = fxxkCrm.getCustomProvince();
+            String city = fxxkCrm.getCustomCity();
+            String address = fxxkCrm.getCustomAddress();
+            String customName = fxxkCrm.getCustomName();
+            if (map.containsKey(customName)){
+                FxxkCrm v = map.get(customName);
+                if (!v.getCustomProvince().equals(province) || !v.getCustomCity().equals(city) || !v.getCustomAddress().equals(address)){
+                    crmNoList.add(crmNo);
+                }
+            } else {
+                map.put(customName,fxxkCrm);
+            }
+        }
+        System.out.println(JSON.toJSONString(crmNoList));
+        return ResultUtil.ok();
     }
 }

+ 1 - 1
sop-api/src/main/java/com/qmth/sop/server/api/TBCrmController.java

@@ -128,7 +128,7 @@ public class TBCrmController {
     @ApiResponses({@ApiResponse(code = 200, message = "查询成功", response = DingElementResult.class)})
     public Result findDingInfo(@ApiParam(value = "sop单号") @RequestParam(required = false) String sopNo,
                                @ApiParam(value = "crm单号") @RequestParam(required = false) String crmNo) {
-        return ResultUtil.ok(tBCrmService.findCrmProjectBySopNoOrCrmNo(sopNo, crmNo));
+        return ResultUtil.ok(tBCrmService.findCrmProjectInfo(sopNo, null, crmNo));
     }
 
     @ApiOperation(value = "派单数据刷新(测试用)")

+ 1 - 1
sop-api/src/main/java/com/qmth/sop/server/api/TBDingController.java

@@ -260,7 +260,7 @@ public class TBDingController {
                         .distinct()
                         .collect(Collectors.toList());
                 for (TBCrm tbCrm : crmInServiceList) {
-                    CrmProjectResult crmProjectResult = tbCrmService.findCrmProjectBySopNoOrCrmNo(null, tbCrm.getCrmNo());
+                    CrmProjectResult crmProjectResult = tbCrmService.findCrmProjectInfo(null,null, tbCrm.getCrmNo());
                     List<String> sopNoList = tbSopInfoService.findFlowPassageByCrmNo(tbCrm.getCrmNo(), requestUserId);
                     if (CollectionUtils.isEmpty(sopNoList)){
                         continue;

BIN
sop-api/src/main/resources/static/delivery.xlsx


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

@@ -583,7 +583,7 @@ public class ActivitiServiceImpl implements ActivitiService {
         map.put(SystemConstant.FLOW_DEPLOYMENT_ID, tfCustomFlow.getFlowDeploymentId());
         map.put(SystemConstant.ID, tfCustomFlow.getId());
         if (Objects.nonNull(crmNo)) {
-            CrmProjectResult crmProjectResult = tbCrmService.findCrmProjectBySopNoOrCrmNo(null, crmNo);
+            CrmProjectResult crmProjectResult = tbCrmService.findCrmProjectInfo(null,null, crmNo);
             if (Objects.nonNull(crmProjectResult)) {
                 map.put(SystemConstant.CRM_INFO, crmProjectResult);
             }
@@ -1074,7 +1074,7 @@ public class ActivitiServiceImpl implements ActivitiService {
 
         CrmProjectResult crmProjectResult = null;
         if (Objects.nonNull(tfCustomFlowEntity.getCrmNo())) {
-            crmProjectResult = tbCrmService.findCrmProjectBySopNoOrCrmNo(tfCustomFlowEntity.getCode(),
+            crmProjectResult = tbCrmService.findCrmProjectInfo(tfCustomFlowEntity.getCode(),null,
                     tfCustomFlowEntity.getCrmNo());
         }
         return new FlowViewResult(flowId, tfFlowApprove.getStatus(), tfCustomFlowEntity.getCode(), taskIdList,

+ 3 - 1
sop-business/src/main/java/com/qmth/sop/business/bean/dto/DeviceDeliveryImportDto.java

@@ -19,7 +19,9 @@ import java.io.Serializable;
 @HeadStyle(fillForegroundColor = 11)
 @HeadFontStyle(color = 1)
 public class DeviceDeliveryImportDto extends BasicExcelRow implements Serializable {
-    @ExcelProperty(value = "项目单号/项目编号")
+    @ExcelProperty(value = "项目单号/项目编号*")
+    @NotNull(message = "项目单号/项目编号不能为空")
+    @NotBlank(message = "项目单号/项目编号不能为空")
     private String crmNo;
 
     @ExcelProperty(value = "供应商*")

+ 30 - 42
sop-business/src/main/java/com/qmth/sop/business/bean/result/CrmProjectResult.java

@@ -68,18 +68,14 @@ public class CrmProjectResult {
     @ApiModelProperty("大区经理名称")
     private String regionManagerName;
 
-    @ApiModelProperty("区域协调人id")
-    @JsonSerialize(using = ToStringSerializer.class)
-    private Long regionCoordinatorId;
-
-    @ApiModelProperty("区域协调人名称")
-    private String regionCoordinatorName;
+    @ApiModelProperty("区域协调人集合")
+    private List<UserArchivesDto> regionCoordinatorList;
 
-    @ApiModelProperty("实施工程师集合")
-    private List<UserArchivesDto> effectEngineerList;
+    @ApiModelProperty("项目经理集合")
+    private List<UserArchivesDto> projectManagerList;
 
-    @ApiModelProperty("助理工程师集合")
-    private List<UserArchivesDto> assistantEngineerList;
+    @ApiModelProperty("工程师集合")
+    private List<UserArchivesDto> engineerList;
 
     @ApiModelProperty(value = "标准人天")
     private Integer peoperDay;
@@ -87,22 +83,6 @@ public class CrmProjectResult {
     @ApiModelProperty(value = "过程变量")
     private String processVar;
 
-    public String getProcessVar() {
-        return processVar;
-    }
-
-    public void setProcessVar(String processVar) {
-        this.processVar = processVar;
-    }
-
-    public Integer getPeoperDay() {
-        return peoperDay;
-    }
-
-    public void setPeoperDay(Integer peoperDay) {
-        this.peoperDay = peoperDay;
-    }
-
     public String getCrmNo() {
         return crmNo;
     }
@@ -231,35 +211,43 @@ public class CrmProjectResult {
         this.regionManagerName = regionManagerName;
     }
 
-    public Long getRegionCoordinatorId() {
-        return regionCoordinatorId;
+    public List<UserArchivesDto> getRegionCoordinatorList() {
+        return regionCoordinatorList;
     }
 
-    public void setRegionCoordinatorId(Long regionCoordinatorId) {
-        this.regionCoordinatorId = regionCoordinatorId;
+    public void setRegionCoordinatorList(List<UserArchivesDto> regionCoordinatorList) {
+        this.regionCoordinatorList = regionCoordinatorList;
     }
 
-    public String getRegionCoordinatorName() {
-        return regionCoordinatorName;
+    public List<UserArchivesDto> getProjectManagerList() {
+        return projectManagerList;
     }
 
-    public void setRegionCoordinatorName(String regionCoordinatorName) {
-        this.regionCoordinatorName = regionCoordinatorName;
+    public void setProjectManagerList(List<UserArchivesDto> projectManagerList) {
+        this.projectManagerList = projectManagerList;
     }
 
-    public List<UserArchivesDto> getEffectEngineerList() {
-        return effectEngineerList;
+    public List<UserArchivesDto> getEngineerList() {
+        return engineerList;
     }
 
-    public void setEffectEngineerList(List<UserArchivesDto> effectEngineerList) {
-        this.effectEngineerList = effectEngineerList;
+    public void setEngineerList(List<UserArchivesDto> engineerList) {
+        this.engineerList = engineerList;
     }
 
-    public List<UserArchivesDto> getAssistantEngineerList() {
-        return assistantEngineerList;
+    public Integer getPeoperDay() {
+        return peoperDay;
     }
 
-    public void setAssistantEngineerList(List<UserArchivesDto> assistantEngineerList) {
-        this.assistantEngineerList = assistantEngineerList;
+    public void setPeoperDay(Integer peoperDay) {
+        this.peoperDay = peoperDay;
+    }
+
+    public String getProcessVar() {
+        return processVar;
+    }
+
+    public void setProcessVar(String processVar) {
+        this.processVar = processVar;
     }
 }

+ 23 - 0
sop-business/src/main/java/com/qmth/sop/business/entity/TBDeviceDelivery.java

@@ -4,6 +4,7 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize;
 import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
 import com.qmth.sop.common.base.BaseEntity;
 import com.qmth.sop.common.enums.DeviceDeliveryStatusEnum;
+import com.qmth.sop.common.enums.DeviceStatusEnum;
 import com.qmth.sop.common.enums.DeviceUsageTypeEnum;
 import com.qmth.sop.common.enums.InOutTypeEnum;
 import io.swagger.annotations.ApiModel;
@@ -93,6 +94,12 @@ public class TBDeviceDelivery extends BaseEntity implements Serializable {
     @ApiModelProperty(value = "有效的可操作的发货记录(当一个设备处于一个发货出入库生命周期时为有效), 0: 无效,1: 有效")
     private Boolean effect;
 
+    @ApiModelProperty(value = "设备的状态,NORMAL:正常 BREAK_DOWN: 故障")
+    private DeviceStatusEnum deviceStatus;
+
+    @ApiModelProperty(value = "设备来源ID,不为空,说明该设备由其他单号中转过来")
+    private Long sourceId;
+
     public String getExpressNo() {
         return expressNo;
     }
@@ -252,4 +259,20 @@ public class TBDeviceDelivery extends BaseEntity implements Serializable {
     public void setEffect(Boolean effect) {
         this.effect = effect;
     }
+
+    public DeviceStatusEnum getDeviceStatus() {
+        return deviceStatus;
+    }
+
+    public void setDeviceStatus(DeviceStatusEnum deviceStatus) {
+        this.deviceStatus = deviceStatus;
+    }
+
+    public Long getSourceId() {
+        return sourceId;
+    }
+
+    public void setSourceId(Long sourceId) {
+        this.sourceId = sourceId;
+    }
 }

+ 8 - 10
sop-business/src/main/java/com/qmth/sop/business/service/TBCrmService.java

@@ -76,7 +76,6 @@ public interface TBCrmService extends IService<TBCrm> {
      */
     void unbindCrmWithService(Long crmId);
 
-
     /**
      * 服务范围管理 - 查询派单小计
      *
@@ -97,16 +96,16 @@ public interface TBCrmService extends IService<TBCrm> {
      */
     TBCrm findByCrmNo(String crmNo);
 
-
     /**
      * 查询列表
      *
      * @param iPage
      * @return
      */
-    IPage<TBCrmResult> query(IPage<Map> iPage, Long serviceId,Boolean isBind, Long leadId, Long crmUserId, ProductTypeEnum type, String custom, String crmNo, Long startTime, Long endTime);
+    IPage<TBCrmResult> query(IPage<Map> iPage, Long serviceId, Boolean isBind, Long leadId, Long crmUserId,
+            ProductTypeEnum type, String custom, String crmNo, Long startTime, Long endTime);
 
-    int count(Long serviceId,Boolean isBind, Long leadId, Long crmUserId, ProductTypeEnum type, String custom, String crmNo, Long startTime, Long endTime);
+    int count(Long serviceId, Boolean isBind, Long leadId, Long crmUserId, ProductTypeEnum type, String custom, String crmNo, Long startTime, Long endTime);
 
     /**
      * 新增修改派单信息表
@@ -115,7 +114,6 @@ public interface TBCrmService extends IService<TBCrm> {
      */
     Boolean saveTBCrm(TBCrm tBCrm);
 
-
     /**
      * 删除派单信息表
      *
@@ -126,13 +124,14 @@ public interface TBCrmService extends IService<TBCrm> {
     boolean batchDisable(long[] crmIds);
 
     /**
-     * 根据sopNo或crmNo查询项目派单信息
+     * 根据sopNo或派单详情id查询项目派单信息
      *
-     * @param sopNo sopNo
-     * @param crmNo crmNo
+     * @param sopNo       sopNo
+     * @param crmDetailId 派单详情id
+     * @param crmNo       派单编号(如果传派单号怎不查询人员配置信息)
      * @return 项目派单信息
      */
-    CrmProjectResult findCrmProjectBySopNoOrCrmNo(String sopNo, String crmNo);
+    CrmProjectResult findCrmProjectInfo(String sopNo, Long crmDetailId, String crmNo);
 
     /**
      * 根据sop单号查询签到中派单信息
@@ -178,7 +177,6 @@ public interface TBCrmService extends IService<TBCrm> {
      */
     List<TBCrm> findByTBCrmListByServiceUnitIdAndAddress(Long serviceUnitId, String province, String city);
 
-
     /**
      * 派单重新划定服务单元
      *

+ 9 - 4
sop-business/src/main/java/com/qmth/sop/business/service/impl/SysUserRoleServiceImpl.java

@@ -2,6 +2,7 @@ package com.qmth.sop.business.service.impl;
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.qmth.sop.business.bean.dto.UserArchivesDto;
 import com.qmth.sop.business.bean.dto.UserDto;
 import com.qmth.sop.business.bean.result.CrmProjectResult;
 import com.qmth.sop.business.bean.result.MenuResult;
@@ -205,14 +206,18 @@ public class SysUserRoleServiceImpl extends ServiceImpl<SysUserRoleMapper, SysUs
                         userIdList.addAll(serviceLeadIdList);
                     }
                 } else if (s.getType() == RoleTypeEnum.REGION_MANAGER) {
-                    CrmProjectResult crmProjectResult = tbCrmService.findCrmProjectBySopNoOrCrmNo(sopNo, null);
+                    CrmProjectResult crmProjectResult = tbCrmService.findCrmProjectInfo(sopNo,null, null);
                     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.findCrmProjectBySopNoOrCrmNo(sopNo, null);
-                    if (Objects.nonNull(crmProjectResult) && Objects.nonNull(crmProjectResult.getRegionCoordinatorId())) {
-                        userIdList.addAll(Arrays.asList(String.valueOf(crmProjectResult.getRegionCoordinatorId())));
+                    CrmProjectResult crmProjectResult = tbCrmService.findCrmProjectInfo(sopNo, null,null);
+                    if (Objects.nonNull(crmProjectResult)) {
+                        List<UserArchivesDto> regionCoordinatorIdList = crmProjectResult.getRegionCoordinatorList();
+                        if (CollectionUtils.isNotEmpty(regionCoordinatorIdList)){
+                            userIdList.addAll(Arrays.asList(String.valueOf(regionCoordinatorIdList.get(0).getUserId())));
+                        }
+
                     }
                 } else {
                     sysRoleOtherList.add(s.getId());

+ 1 - 1
sop-business/src/main/java/com/qmth/sop/business/service/impl/TBCrmDetailServiceImpl.java

@@ -70,7 +70,7 @@ public class TBCrmDetailServiceImpl extends ServiceImpl<TBCrmDetailMapper, TBCrm
      */
     @Override
     public CrmProjectResult sopVarInfo(String crmNo) {
-        CrmProjectResult crmProjectResult = tbCrmService.findCrmProjectBySopNoOrCrmNo(null, crmNo);
+        CrmProjectResult crmProjectResult = tbCrmService.findCrmProjectInfo(null, null, crmNo);
         Objects.requireNonNull(crmProjectResult, "未找到派单信息");
 
         TBCrm tbCrm = tbCrmService.findByCrmNo(crmNo);

+ 77 - 47
sop-business/src/main/java/com/qmth/sop/business/service/impl/TBCrmServiceImpl.java

@@ -22,6 +22,8 @@ import com.qmth.sop.common.enums.*;
 import com.qmth.sop.common.util.ResultUtil;
 import com.qmth.sop.common.util.ServletUtil;
 import org.apache.commons.collections4.CollectionUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.dao.DuplicateKeyException;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -42,6 +44,8 @@ import java.util.stream.Stream;
 @Service
 public class TBCrmServiceImpl extends ServiceImpl<TBCrmMapper, TBCrm> implements TBCrmService {
 
+    private final static Logger log = LoggerFactory.getLogger(TBCrmServiceImpl.class);
+
     @Resource
     private TBServiceService tbServiceService;
 
@@ -69,6 +73,12 @@ public class TBCrmServiceImpl extends ServiceImpl<TBCrmMapper, TBCrm> implements
     @Resource
     private TBProductService tbProductService;
 
+    @Resource
+    private SequenceService sequenceService;
+
+    @Resource
+    private TBCrmDetailService tbCrmDetailService;
+
     @Override
     public IPage<CrmServiceResult> findServiceScopePage(Long serviceUnitId, String city, ProductTypeEnum productType,
             String customName, Boolean bindStatus, Integer pageNumber, Integer pageSize) {
@@ -278,54 +288,38 @@ public class TBCrmServiceImpl extends ServiceImpl<TBCrmMapper, TBCrm> implements
     }
 
     @Override
-    public CrmProjectResult findCrmProjectBySopNoOrCrmNo(String sopNo, String crmNo) {
+    public CrmProjectResult findCrmProjectInfo(String sopNo, Long crmDetailId,String crmNo) {
         CrmProjectResult result = new CrmProjectResult();
-        List<CrmProjectResult> crmProjectResults;
-        if (sopNo != null && sopNo.length() > 0) {
-            crmProjectResults = this.baseMapper.findCrmProjectBySopNo(sopNo);
+        TBCrmDetail tbCrmDetail = null;
+        if (crmDetailId != null && crmDetailId > 0) {
+            tbCrmDetail = tbCrmDetailService.getById(crmDetailId);
+        } else if (sopNo != null && sopNo.length() > 0) {
+            tbCrmDetail = tbCrmDetailService.getOne(
+                    new QueryWrapper<TBCrmDetail>().lambda().eq(TBCrmDetail::getSopNo, sopNo).last(SystemConstant.LIMIT1));
         } else if (crmNo != null && crmNo.length() > 0) {
-            crmProjectResults = this.baseMapper.findCrmProjectByCrmNo(crmNo);
-        } else {
-            throw ExceptionResultEnum.ERROR.exception("缺少sop单号和crm单号");
-        }
-        if (CollectionUtils.isNotEmpty(crmProjectResults)) {
-            if (crmProjectResults.size() > 1) {
-                throw ExceptionResultEnum.ERROR.exception("根据sop号找到多个与之对应的派单异常");
+            List<CrmProjectResult> crmProjectResultList = this.baseMapper.findCrmProjectByCrmNo(crmNo);
+            if (CollectionUtils.isNotEmpty(crmProjectResultList)) {
+                return crmProjectResultList.get(0);
             }
-            CrmProjectResult crmProjectResult = crmProjectResults.get(0);
-            String tbCrmNo = crmProjectResult.getCrmNo();
-
-            List<TBUserArchivesAllocation> archivesAllocationList = tbUserArchivesAllocationService.list(
-                    new QueryWrapper<TBUserArchivesAllocation>().lambda().eq(TBUserArchivesAllocation::getCrmNo, tbCrmNo));
-
-            RoleResult effectRole = sysRoleService.findRoleInfoByArchivesType(RoleTypeEnum.EFFECT_ENGINEER);
-            Long effectRoleId = effectRole.getRoleId();
-            // TODO: 2024/5/14 查询派单分配信息修改 -czx 
-//            List<UserArchivesDto> effectEngineerList = archivesAllocationList.stream()
-//                    .filter(e -> effectRoleId.equals(e.getRoleId())).flatMap(e -> {
-//                        UserArchivesDto dto = new UserArchivesDto();
-//                        Long userArchivesId = e.getArchivesId();
-//                        dto.setUserArchivesId(userArchivesId);
-//                        dto.setUserId(e.getUserId());
-//                        dto.setName(tbUserArchivesService.getById(userArchivesId).getName());
-//                        return Stream.of(dto);
-//                    }).collect(Collectors.toList());
-//
-//            RoleResult assistant = sysRoleService.findRoleInfoByArchivesType(RoleTypeEnum.ASSISTANT_ENGINEER);
-//            Long assistantRoleId = assistant.getRoleId();
-//            List<UserArchivesDto> assistantEngineerList = archivesAllocationList.stream()
-//                    .filter(e -> assistantRoleId.equals(e.getRoleId())).flatMap(e -> {
-//                        UserArchivesDto dto = new UserArchivesDto();
-//                        Long userArchivesId = e.getArchivesId();
-//                        dto.setUserArchivesId(userArchivesId);
-//                        dto.setUserId(e.getUserId());
-//                        dto.setName(tbUserArchivesService.getById(userArchivesId).getName());
-//                        return Stream.of(dto);
-//                    }).collect(Collectors.toList());
-//            crmProjectResult.setEffectEngineerList(effectEngineerList);
-//            crmProjectResult.setAssistantEngineerList(assistantEngineerList);
-            result = crmProjectResult;
         }
+        if (Objects.isNull(tbCrmDetail)) {
+            log.error(String.format("未找到对应的派单详情, sopNo[%s], crmDetailId[%s]", sopNo, crmDetailId));
+            throw ExceptionResultEnum.ERROR.exception("未找到对应的派单详情");
+        }
+        crmNo = tbCrmDetail.getCrmNo();
+        crmDetailId = tbCrmDetail.getId();
+        List<CrmProjectResult> crmProjectResultList = this.baseMapper.findCrmProjectByCrmNo(crmNo);
+        if (CollectionUtils.isNotEmpty(crmProjectResultList)) {
+            result = crmProjectResultList.get(0);
+        }
+        List<TBUserArchivesAllocation> datasource = tbUserArchivesAllocationService.list(
+                new QueryWrapper<TBUserArchivesAllocation>().lambda().eq(TBUserArchivesAllocation::getCrmDetailId, crmDetailId));
+        List<UserArchivesDto> regionCoordinatorList = this.buildUserArchivesDtoList(datasource, SopRoleTypeEnum.REGION_COORDINATOR);
+        List<UserArchivesDto> projectManagerList = this.buildUserArchivesDtoList(datasource, SopRoleTypeEnum.PROJECT_MANAGER);
+        List<UserArchivesDto> engineerList = this.buildUserArchivesDtoList(datasource, SopRoleTypeEnum.ENGINEER);
+        result.setRegionCoordinatorList(regionCoordinatorList);
+        result.setProjectManagerList(projectManagerList);
+        result.setEngineerList(engineerList);
         return result;
     }
 
@@ -467,6 +461,9 @@ public class TBCrmServiceImpl extends ServiceImpl<TBCrmMapper, TBCrm> implements
                 String managerMobileNumber = fxxkCrm.getManagerMobileNumber();
                 ProductTypeEnum customType = fxxkCrm.getCustomType();
                 String customName = fxxkCrm.getCustomName();
+                String customProvince = fxxkCrm.getCustomProvince();
+                String customCity = fxxkCrm.getCustomCity();
+                String customAddress = fxxkCrm.getCustomAddress();
                 Long examStartTime = fxxkCrm.getExamStartTime();
                 Long examEndTime = fxxkCrm.getExamEndTime();
 
@@ -488,6 +485,12 @@ public class TBCrmServiceImpl extends ServiceImpl<TBCrmMapper, TBCrm> implements
                 if (customName == null || customName.length() == 0) {
                     basicInfoMissingError = basicInfoMissingError + "缺少客户名称";
                 }
+                if (customProvince == null || customProvince.length() == 0) {
+                    basicInfoMissingError = basicInfoMissingError + "缺少客户所在省份";
+                }
+                if (customCity == null || customCity.length() == 0) {
+                    basicInfoMissingError = basicInfoMissingError + "缺少客户所在城市";
+                }
                 if (examStartTime == null || examStartTime == 0) {
                     basicInfoMissingError = basicInfoMissingError + "缺少考试开始时间";
                 }
@@ -523,11 +526,20 @@ public class TBCrmServiceImpl extends ServiceImpl<TBCrmMapper, TBCrm> implements
                     // 客户名称校验
                     Long customId = null;
                     List<SysCustom> sysCustomList = sysCustomService.list(
-                            new QueryWrapper<SysCustom>().lambda().eq(SysCustom::getName, customName).eq(SysCustom::getType, customType).eq(SysCustom::getEnable, true));
+                            new QueryWrapper<SysCustom>().lambda().eq(SysCustom::getName, customName).eq(SysCustom::getType, customType));
 
                     if (CollectionUtils.isEmpty(sysCustomList)) {
-                        matchInfoError = matchInfoError + String.format("纷享销客中的客户[%s(%s)]在质控平台不存在或已禁用(客户名称 + 客户类型)\n",
-                                customName, customType.getTitle());
+                        // 质控平台不存在该类型客户 -> 新增一个客户
+                        SysCustom sysCustom = new SysCustom();
+                        sysCustom.setName(customName);
+                        sysCustom.setCode(sequenceService.createSerialNo(SequenceEnum.SYS_CUSTOM_CODE));
+                        sysCustom.setType(customType);
+                        sysCustom.setProvince(customProvince);
+                        sysCustom.setCity(customCity);
+                        if (customAddress != null && customAddress.length() > 0) {
+                            sysCustom.setAddress(customAddress);
+                        }
+                        throw ExceptionResultEnum.ERROR.exception(String.format("客户[%s]不存在", sysCustom.getName()));
                     } else if (sysCustomList.size() > 1) {
                         throw ExceptionResultEnum.ERROR.exception("客户数据异常 :客户名称-客户类型 不唯一\n");
                     } else {
@@ -583,4 +595,22 @@ public class TBCrmServiceImpl extends ServiceImpl<TBCrmMapper, TBCrm> implements
             throw ExceptionResultEnum.ERROR.exception(e.getMessage());
         }
     }
+
+    /**
+     * 根据sop用户身份类型构建用户档案信息
+     * @param datasource 数据源
+     * @param sopRoleTypeEnum 身份
+     * @return 用户档案信息
+     */
+    private List<UserArchivesDto> buildUserArchivesDtoList(List<TBUserArchivesAllocation> datasource, SopRoleTypeEnum sopRoleTypeEnum){
+        return datasource.stream()
+                .filter(e -> sopRoleTypeEnum.equals(e.getSopRoleType())).flatMap(e -> {
+                    UserArchivesDto dto = new UserArchivesDto();
+                    Long userArchivesId = e.getArchivesId();
+                    dto.setUserArchivesId(userArchivesId);
+                    dto.setUserId(e.getUserId());
+                    dto.setName(tbUserArchivesService.getById(userArchivesId).getName());
+                    return Stream.of(dto);
+                }).collect(Collectors.toList());
+    }
 }

+ 6 - 3
sop-business/src/main/java/com/qmth/sop/business/service/impl/TBDeviceDeliveryServiceImpl.java

@@ -189,16 +189,18 @@ public class TBDeviceDeliveryServiceImpl extends ServiceImpl<TBDeviceDeliveryMap
                 }
 
                 TBDeviceDelivery tbDeviceDelivery = new TBDeviceDelivery();
-                if (crmNo != null && crmNo.length() > 0) {
+                if (crmNo != null && !crmNo.isEmpty()) {
                     if (!crmNoList.contains(crmNo)) {
                         throw ExceptionResultEnum.ERROR.exception("派单号不存在");
                     }
 
                     tbDeviceDelivery.setCrmNo(crmNo);
                     tbDeviceDelivery.setUsageType(DeviceUsageTypeEnum.PROJECT);
-                } else {
-                    tbDeviceDelivery.setUsageType(DeviceUsageTypeEnum.OTHER);
                 }
+                // 项目单号/项目编号修改为必填项
+                /*else {
+                    tbDeviceDelivery.setUsageType(DeviceUsageTypeEnum.OTHER);
+                }*/
                 tbDeviceDelivery.setSerialNo(serialNo);
                 tbDeviceDelivery.setSupplierId(supplierId);
                 tbDeviceDelivery.setMailingAddress(mailingAddress);
@@ -210,6 +212,7 @@ public class TBDeviceDeliveryServiceImpl extends ServiceImpl<TBDeviceDeliveryMap
                 tbDeviceDelivery.setDeliveryType(InOutTypeEnum.OUT);
                 tbDeviceDelivery.setStatus(DeviceDeliveryStatusEnum.UN_DELIVER);
                 tbDeviceDelivery.setCreateId(requestUser.getId());
+                tbDeviceDelivery.setDeviceStatus(DeviceStatusEnum.NORMAL);
                 this.save(tbDeviceDelivery);
             }
         }

+ 11 - 5
sop-business/src/main/java/com/qmth/sop/business/service/impl/TBDingApplyServiceImpl.java

@@ -9,6 +9,7 @@ import com.google.gson.reflect.TypeToken;
 import com.qmth.sop.business.activiti.service.ActivitiService;
 import com.qmth.sop.business.bean.dto.DataPermissionDto;
 import com.qmth.sop.business.bean.dto.OrgUserNameDto;
+import com.qmth.sop.business.bean.dto.UserArchivesDto;
 import com.qmth.sop.business.bean.params.FlowApproveParam;
 import com.qmth.sop.business.bean.result.*;
 import com.qmth.sop.business.entity.*;
@@ -101,7 +102,7 @@ public class TBDingApplyServiceImpl extends ServiceImpl<TBDingApplyMapper, TBDin
         if (count == 0) {
             throw ExceptionResultEnum.ERROR.exception("该用户剩余补卡次数为0");
         }
-        CrmProjectResult crmProjectResult = tbCrmService.findCrmProjectBySopNoOrCrmNo(sopNo, crmNo);
+        CrmProjectResult crmProjectResult = tbCrmService.findCrmProjectInfo(sopNo, null, crmNo);
         Optional.ofNullable(crmProjectResult).orElseThrow(ExceptionResultEnum.CRM_NO_NO_DATA::exception);
 
         List<String> sysUserRoleList = sysUserRoleService.listByServiceId(crmProjectResult.getServiceUnitId(),
@@ -420,10 +421,15 @@ public class TBDingApplyServiceImpl extends ServiceImpl<TBDingApplyMapper, TBDin
                 .eq(TBDingApply::getDingExceptionNo, tfCustomFlowEntity.getCode()));
         Optional.ofNullable(tbDingApply).orElseThrow(() -> ExceptionResultEnum.DING_APPLY_NO_DATA.exception());
 
-        CrmProjectResult crmProjectResult = tbCrmService.findCrmProjectBySopNoOrCrmNo(tfCustomFlowEntity.getCode(),
-                tfCustomFlowEntity.getCrmNo());
+        CrmProjectResult crmProjectResult = tbCrmService.findCrmProjectInfo(tfCustomFlowEntity.getCode(),
+                null,tfCustomFlowEntity.getCrmNo());
         Optional.ofNullable(crmProjectResult).orElseThrow(() -> ExceptionResultEnum.CRM_NO_NO_DATA.exception());
-        Optional.ofNullable(crmProjectResult.getRegionCoordinatorId())
+
+        List<UserArchivesDto> regionCoordinatorList = crmProjectResult.getRegionCoordinatorList();
+        if (CollectionUtils.isEmpty(regionCoordinatorList)){
+            throw ExceptionResultEnum.ERROR.exception("crm区域协调人数据为空");
+        }
+        Optional.ofNullable(regionCoordinatorList.get(0).getUserId())
                 .orElseThrow(() -> ExceptionResultEnum.ERROR.exception("crm区域协调人数据为空"));
 
         List<String> sysUserRoleList = sysUserRoleService.listByServiceId(crmProjectResult.getServiceUnitId(),
@@ -449,7 +455,7 @@ 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.findCrmProjectBySopNoOrCrmNo(tbDingApply.getSopNo(),
+        CrmProjectResult crmProjectResult = tbCrmService.findCrmProjectInfo(tbDingApply.getSopNo(),null,
                 tbDingApply.getCrmNo());
         Optional.ofNullable(crmProjectResult).orElseThrow(() -> ExceptionResultEnum.CRM_NO_NO_DATA.exception());
 

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

@@ -204,7 +204,7 @@ public class TBProjectExchangeServiceImpl extends ServiceImpl<TBProjectExchangeM
         TBProjectExchange tbProjectExchange = this.getById(id);
         Optional.ofNullable(tbProjectExchange).orElseThrow(() -> ExceptionResultEnum.PROJECT_EXCHANGE_NO_DATA.exception());
 
-        CrmProjectResult crmProjectResult = tbCrmService.findCrmProjectBySopNoOrCrmNo(tbProjectExchange.getSopNo(), tbProjectExchange.getCrmNo());
+        CrmProjectResult crmProjectResult = tbCrmService.findCrmProjectInfo(tbProjectExchange.getSopNo(),null, 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()));

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

@@ -264,7 +264,7 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
     public String sopPublish(SopPublishParam sopPublishParam) throws InterruptedException {
         Objects.requireNonNull(sopPublishParam.getCrmNo(), "crm编号不能为空");
         SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
-        CrmProjectResult crmProjectResult = tbCrmService.findCrmProjectBySopNoOrCrmNo(sopPublishParam.getSopNo(),
+        CrmProjectResult crmProjectResult = tbCrmService.findCrmProjectInfo(sopPublishParam.getSopNo(),null,
                 sopPublishParam.getCrmNo());
         Optional.ofNullable(crmProjectResult).orElseThrow(() -> ExceptionResultEnum.CRM_NO_NO_DATA.exception());
 
@@ -433,7 +433,7 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
             flowApproveParam.setFormProperties(JacksonUtil.parseJson(flowTaskResult));
         }
 
-        CrmProjectResult crmProjectResult = tbCrmService.findCrmProjectBySopNoOrCrmNo(tfCustomFlowEntity.getCode(),
+        CrmProjectResult crmProjectResult = tbCrmService.findCrmProjectInfo(tfCustomFlowEntity.getCode(),null,
                 tfCustomFlowEntity.getCrmNo());
         Optional.ofNullable(crmProjectResult).orElseThrow(() -> ExceptionResultEnum.CRM_NO_NO_DATA.exception());
 
@@ -1324,7 +1324,7 @@ public class TBSopInfoServiceImpl extends ServiceImpl<TBSopInfoMapper, TBSopInfo
         }
         flowResultNew.setSetupMap(setupMapNew);
 
-        CrmProjectResult crmProjectResult = tbCrmService.findCrmProjectBySopNoOrCrmNo(tfCustomFlowEntity.getCode(),
+        CrmProjectResult crmProjectResult = tbCrmService.findCrmProjectInfo(tfCustomFlowEntity.getCode(),null,
                 tfCustomFlowEntity.getCrmNo());
         Optional.ofNullable(crmProjectResult).orElseThrow(() -> ExceptionResultEnum.CRM_NO_NO_DATA.exception());
 
@@ -1377,7 +1377,7 @@ 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.findCrmProjectBySopNoOrCrmNo(tfCustomFlowEntity.getCode(),
+            CrmProjectResult crmProjectResult = tbCrmService.findCrmProjectInfo(tfCustomFlowEntity.getCode(),null,
                     tfCustomFlowEntity.getCrmNo());
             Optional.ofNullable(crmProjectResult).orElseThrow(() -> ExceptionResultEnum.CRM_NO_NO_DATA.exception());
 

+ 3 - 1
sop-business/src/main/resources/db/log/caozixuan_update_log.sql

@@ -43,4 +43,6 @@ ALTER TABLE sys_ding_obj
 -- 旧数据临时处理
 update t_b_ding set sop_role_type = 'ENGINEER' where sop_role_type = '';
 update t_b_user_archives_allocation set sop_role_type = 'ENGINEER' where sop_role_type = '';
-update sys_ding_obj set sop_role_type = 'ENGINEER' where sop_role_type = '';
+update sys_ding_obj set sop_role_type = 'ENGINEER' where sop_role_type = '';
+
+INSERT INTO sequence (name, current_value, increment) VALUES ('sysCustomCode', '1', '1');

+ 4 - 3
sop-business/src/main/resources/db/log/haoguanghui_update_log.sql

@@ -1,5 +1,6 @@
-ALTER TABLE t_b_device_delivery
+-- 2024-05-15
+ALTER TABLE t_b_device_delivery
     ADD COLUMN `device_status` varchar(30) NULL COMMENT '设备状态,正常:NORMAL; 故障:FAULT' AFTER `effect`;
-
 ALTER TABLE t_b_device_delivery
-    ADD COLUMN `source_id` bigint NULL COMMENT '设备来源ID,不为空,说明该设备由其他单号中转过来' AFTER `device_status`;
+    ADD COLUMN `source_id` bigint NULL COMMENT '设备来源ID,不为空,说明该设备由其他单号中转过来' AFTER `device_status`;
+

+ 0 - 4
sop-business/src/main/resources/mapper/TBCrmMapper.xml

@@ -316,8 +316,6 @@
             tbs.name AS serviceUnitName,
             regionManager.id AS regionManagerId,
             regionManager.real_name AS regionManagerName,
-            regionCoordinator.id AS regionCoordinatorId,
-            regionCoordinator.real_name AS regionCoordinatorName,
             sc.peoper_day as peoperDay,
             tbc.process_var as processVar
         FROM
@@ -331,8 +329,6 @@
                 LEFT JOIN
             sys_user regionManager ON tbc.lead_id = regionManager.id
                 LEFT JOIN
-            sys_user regionCoordinator ON tbc.region_coordinator_id = regionCoordinator.id
-                LEFT JOIN
             sys_user customManager ON tbc.crm_user_id = customManager.id
         <where>
             <if test="crmNo != null and crmNo != ''">

+ 2 - 1
sop-common/src/main/java/com/qmth/sop/common/enums/SequenceEnum.java

@@ -7,7 +7,8 @@ package com.qmth.sop.common.enums;
  */
 public enum SequenceEnum {
     USER_ARCHIVES_CODE("用户档案编号", "userArchivesCode", "ARC"),
-    DEVICE_IN_OUT_CODE("设备出入库流水号", "deviceInOutCode", "DIO");
+    DEVICE_IN_OUT_CODE("设备出入库流水号", "deviceInOutCode", "DIO"),
+    SYS_CUSTOM_CODE("客户编号", "sysCustomCode", "SCC");
     private final String title;
 
     private final String code;