소스 검색

add:派单信息

caozixuan 1 년 전
부모
커밋
5af2b886dd

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

@@ -78,7 +78,7 @@ public interface TBUserArchivesAllocationService extends IService<TBUserArchives
      *
      * @param crmNo crmNo
      */
-    void publishSop(String crmNo);
+    void publishSop(String crmNo) throws InterruptedException;
 
     /**
      * crm派单 sop流程撤销发布

+ 34 - 24
sop-business/src/main/java/com/qmth/sop/business/service/impl/TBDingServiceImpl.java

@@ -2,7 +2,9 @@ package com.qmth.sop.business.service.impl;
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.qmth.sop.business.activiti.service.ActivitiService;
 import com.qmth.sop.business.bean.dto.DateFormDto;
 import com.qmth.sop.business.bean.dto.SopCrmInfo;
 import com.qmth.sop.business.bean.params.DingSaveParam;
@@ -47,32 +49,36 @@ public class TBDingServiceImpl extends ServiceImpl<TBDingMapper, TBDing> impleme
     private TBUserArchivesService tbUserArchivesService;
     @Resource
     private SysDingDateService sysDingDateService;
+    @Resource
+    private ActivitiService activitiService;
 
     @Override
     public DingElementResult findDingElements(String sopNo, Long userId) {
         DingElementResult dingElementResult = this.baseMapper.findDingResultByUserId(userId);
-        Long userArchivesId = dingElementResult.getUserArchivesId();
-        String currentDayStr = DateFormatUtils.format(System.currentTimeMillis(), SystemConstant.DEFAULT_DATE_DAY_PATTERN);
-        List<TBDing> tbDingList = this.list(new QueryWrapper<TBDing>()
-                .lambda()
-                .eq(TBDing::getSopNo, sopNo)
-                .eq(TBDing::getUserArchivesId, userArchivesId)
-                .eq(TBDing::getSignDate, currentDayStr));
-        if (CollectionUtils.isNotEmpty(tbDingList)) {
-            // 有考勤记录
-            if (tbDingList.size() > 1) {
-                throw ExceptionResultEnum.ERROR.exception("考勤记录异常");
+        if (Objects.nonNull(dingElementResult)) {
+            Long userArchivesId = dingElementResult.getUserArchivesId();
+            String currentDayStr = DateFormatUtils.format(System.currentTimeMillis(), SystemConstant.DEFAULT_DATE_DAY_PATTERN);
+            List<TBDing> tbDingList = this.list(new QueryWrapper<TBDing>()
+                    .lambda()
+                    .eq(TBDing::getSopNo, sopNo)
+                    .eq(TBDing::getUserArchivesId, userArchivesId)
+                    .eq(TBDing::getSignDate, currentDayStr));
+            if (CollectionUtils.isNotEmpty(tbDingList)) {
+                // 有考勤记录
+                if (tbDingList.size() > 1) {
+                    throw ExceptionResultEnum.ERROR.exception("考勤记录异常");
+                }
+                TBDing tbDing = tbDingList.get(0);
+                Long signInTime = tbDing.getSignInTime();
+                String singInAddress = tbDing.getSignInAddress();
+                Long signOutTime = tbDing.getSignOutTime();
+                String signOutAddress = tbDing.getSignOutAddress();
+
+                dingElementResult.setSignInTime(signInTime);
+                dingElementResult.setSignInAddress(singInAddress);
+                dingElementResult.setSignOutAddress(signOutAddress);
+                dingElementResult.setSignOutTime(signOutTime);
             }
-            TBDing tbDing = tbDingList.get(0);
-            Long signInTime = tbDing.getSignInTime();
-            String singInAddress = tbDing.getSignInAddress();
-            Long signOutTime = tbDing.getSignOutTime();
-            String signOutAddress = tbDing.getSignOutAddress();
-
-            dingElementResult.setSignInTime(signInTime);
-            dingElementResult.setSignInAddress(singInAddress);
-            dingElementResult.setSignOutAddress(signOutAddress);
-            dingElementResult.setSignOutTime(signOutTime);
         }
         return dingElementResult;
     }
@@ -220,7 +226,7 @@ public class TBDingServiceImpl extends ServiceImpl<TBDingMapper, TBDing> impleme
 
         String signDate = DateFormatUtils.format(signTime, SystemConstant.DEFAULT_DATE_DAY_PATTERN);
         String currentDayStr = DateFormatUtils.format(System.currentTimeMillis(), SystemConstant.DEFAULT_DATE_DAY_PATTERN);
-        if (currentDayStr.equals(signDate)) {
+        if (!currentDayStr.equals(signDate)) {
             throw ExceptionResultEnum.ERROR.exception("打卡失败,时间异常");
         }
 
@@ -229,8 +235,12 @@ public class TBDingServiceImpl extends ServiceImpl<TBDingMapper, TBDing> impleme
                 .eq(TBDing::getUserId, userId)
                 .eq(TBDing::getSignDate, signDate));
 
-        // TODO: 2023/9/5 其他的sopNo集合 
-        List<String> otherSopNoList = new ArrayList<>();
+        IPage<WorkTaskResult> sopPage = activitiService.getFlowTaskList(new Page<>(1, 100000), userId, TFCustomTypeEnum.SOP_FLOW, serviceId, null, null, crmNo);
+        List<String> otherSopNoList = sopPage.getRecords()
+                .stream()
+                .map(WorkTaskResult::getCode)
+                .distinct()
+                .collect(Collectors.toList());
 
         if (CollectionUtils.isEmpty(tbDingList)) {
             // 没有这天的打卡记录 - 新增打卡记录

+ 64 - 7
sop-business/src/main/java/com/qmth/sop/business/service/impl/TBUserArchivesAllocationServiceImpl.java

@@ -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

+ 7 - 0
sop-business/src/main/resources/db/log/caozixuan_update_log.sql

@@ -230,3 +230,10 @@ ALTER TABLE t_b_ding
     CHANGE COLUMN face_in_error face_in_pass TINYINT NULL DEFAULT NULL COMMENT '人脸识别是否通过,0:未通过,1:通过' ,
     CHANGE COLUMN face_out_error face_out_pass TINYINT NULL DEFAULT NULL COMMENT '人脸识别是否通过,0:未通过,1:通过' ;
 
+-- 2023-09-06
+INSERT INTO sys_privilege (id, name, url, type, parent_id, sequence, property, enable, default_auth, front_display) VALUES ('2043', '查询项目派单信息', '/api/admin/tb/crm/crm_project_info', 'URL', '64', '32', 'SYS', '1', '1', '0');
+INSERT INTO sys_privilege (id, name, url, type, parent_id, sequence, property, enable, default_auth, front_display) VALUES ('2044', '考勤打卡信息', '/api/admin/tb/ding/ding_info', 'URL', '26', '1', 'SYS', '1', '1', '0');
+INSERT INTO sys_privilege (id, name, url, type, parent_id, sequence, property, enable, default_auth, front_display) VALUES ('2045', '考勤结果统计', '/api/admin/tb/ding/ding_statistic', 'URL', '26', '2', 'SYS', '1', '1', '0');
+INSERT INTO sys_privilege (id, name, url, type, parent_id, sequence, property, enable, default_auth, front_display) VALUES ('2046', '考勤打卡保存', '/api/admin/tb/ding/ding_save', 'URL', '26', '3', 'SYS', '1', '1', '0');
+UPDATE sys_privilege SET related = '3017,2044,2045,2046' WHERE (id = '26');
+

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

@@ -202,7 +202,7 @@
             tbs.id AS serviceUnitId,
             tbs.name AS serviceUnitName,
             regionManager.id AS regionManagerId,
-            regionManager.real_name AS crmUserName,
+            regionManager.real_name AS regionManagerName,
             regionCoordinator.id AS regionCoordinatorId,
             regionCoordinator.real_name AS regionCoordinatorName
         FROM
@@ -245,7 +245,7 @@
             tbs.id AS serviceUnitId,
             tbs.name AS serviceUnitName,
             regionManager.id AS regionManagerId,
-            regionManager.real_name AS crmUserName,
+            regionManager.real_name AS regionManagerName,
             regionCoordinator.id AS regionCoordinatorId,
             regionCoordinator.real_name AS regionCoordinatorName
         FROM

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

@@ -202,7 +202,7 @@ public class TBDingController {
         return ResultUtil.ok(tBDingService.findDingStatistic(sopNo, requestUser.getId()));
     }
 
-    @ApiOperation(value = "考勤打卡")
+    @ApiOperation(value = "考勤打卡保存")
     @RequestMapping(value = "/ding_save", method = RequestMethod.POST)
     @ApiResponses({@ApiResponse(code = 200, message = "更新成功", response = Result.class)})
     @OperationLog

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

@@ -108,7 +108,7 @@ public class TBUserArchivesAllocationController {
     @RequestMapping(value = "/publish", method = RequestMethod.POST)
     @ApiResponses({@ApiResponse(code = 200, message = "发布成功", response = Result.class)})
     @OperationLog
-    public Result publishCrmSop(@ApiParam(value = "派单号", required = true) @RequestParam String crmNo) {
+    public Result publishCrmSop(@ApiParam(value = "派单号", required = true) @RequestParam String crmNo) throws InterruptedException {
         tbUserArchivesAllocationService.publishSop(crmNo);
         return ResultUtil.ok();
     }