Explorar el Código

Merge remote-tracking branch 'origin/dev_v1.0.1' into dev_v1.0.1

wangliang hace 1 año
padre
commit
b167a4873b

+ 69 - 2
sop-api/src/main/java/com/qmth/sop/server/api/TBUserArchivesController.java

@@ -1,5 +1,7 @@
 package com.qmth.sop.server.api;
 
+import cn.hutool.core.io.FileUtil;
+import com.qmth.boot.api.annotation.Aac;
 import com.qmth.boot.api.constant.ApiConstant;
 import com.qmth.sop.business.bean.params.UserArchivesParam;
 import com.qmth.sop.business.bean.query.UserArchivesQuery;
@@ -7,6 +9,7 @@ import com.qmth.sop.business.bean.result.UserArchivesResult;
 import com.qmth.sop.business.bean.result.UserArchivesSubTotalResult;
 import com.qmth.sop.business.entity.SysUser;
 import com.qmth.sop.business.entity.TBTask;
+import com.qmth.sop.business.entity.TBUserArchives;
 import com.qmth.sop.business.service.SequenceService;
 import com.qmth.sop.business.service.TBTaskService;
 import com.qmth.sop.business.service.TBUserArchivesService;
@@ -28,8 +31,8 @@ import javax.annotation.Resource;
 import javax.validation.Valid;
 import javax.validation.constraints.Max;
 import javax.validation.constraints.Min;
-import java.util.List;
-import java.util.Map;
+import java.io.File;
+import java.util.*;
 import java.util.stream.Collectors;
 
 /**
@@ -162,4 +165,68 @@ public class TBUserArchivesController {
         }
         return ResultUtil.ok();
     }
+
+
+    @ApiOperation(value = "生成底照(测试用批量上传照片)")
+    @ApiResponses({ @ApiResponse(code = 200, message = "生成底照", response = Object.class) })
+    @RequestMapping(value = "/pic/upload", method = RequestMethod.POST, produces = "application/json;charset=UTF-8")
+    @Aac(auth = false)
+    public Result buildNewPicture() {
+        String directPath = "E:\\sop\\加密照片";
+        Map<String, Object> result = new HashMap<>();
+        List<String> errorMsgList = new ArrayList<>();
+        List<String> sqlList = new ArrayList<>();
+
+        List<TBUserArchives> tbUserArchivesList = tbUserArchivesService.list();
+        File path = new File("E:\\sop\\照片编号汇总");
+        File[] files = path.listFiles();
+        if (Objects.isNull(files) || files.length == 0) {
+            throw ExceptionResultEnum.ERROR.exception("异常");
+        }
+
+        List<Map<String, Object>> mapList = tbUserArchivesService.findTempEmp();
+        for (Map<String, Object> map : mapList) {
+            String exIndex = String.valueOf(map.get("index"));
+            String exName = String.valueOf(map.get("name"));
+            String exPhone = String.valueOf(map.get("phone"));
+
+            List<TBUserArchives> aList = tbUserArchivesList.stream().filter(e -> e.getMobileNumber().equals(exPhone) && e.getName().equals(exName))
+                    .collect(Collectors.toList());
+            if (CollectionUtils.isEmpty(aList)) {
+                errorMsgList.add(String.format("序列号为[%s],名称为[%s],电话为[%s]的人员未找到对应档案", exIndex, exName, exPhone));
+                continue;
+            } else if (aList.size() > 1) {
+                errorMsgList.add(String.format("序列号为[%s],名称为[%s],电话为[%s]的人员对应到多个档案", exIndex, exName, exPhone));
+                continue;
+            }
+            TBUserArchives tbUserArchives = aList.get(0);
+            String dbPath = tbUserArchives.getBasePhotoPath();
+            if (dbPath != null && dbPath.length() > 0) {
+                // 已有图片的不处理
+                continue;
+            }
+
+            List<File> fList = Arrays.stream(files).filter(e -> e.getName().substring(0, e.getName().indexOf(".")).equals(exIndex))
+                    .collect(Collectors.toList());
+            if (CollectionUtils.isEmpty(fList)) {
+                errorMsgList.add(String.format("序列号为[%s],名称为[%s],电话为[%s]的人员未找到对应图片", exIndex, exName, exPhone));
+                continue;
+            } else if (fList.size() > 1) {
+                errorMsgList.add(String.format("序列号为[%s],名称为[%s],电话为[%s]的人员未找到多张图片", exIndex, exName, exPhone));
+                continue;
+            }
+            File file = fList.get(0);
+            String key = SystemConstant.getNanoId();
+            FileUtil.copy(file, new File(directPath + "\\" + key + file.getName().substring(file.getName().indexOf("."))),
+                    false);
+            String id = String.valueOf(tbUserArchives.getId());
+            String newDbPath = String.format("file/2023/12/26/pic/%s", key + file.getName().substring(file.getName().indexOf(".")));
+            String sql = String.format("update t_b_user_archives set base_photo_path = '%s' where id = '%s';", newDbPath,
+                    id);
+            sqlList.add(sql);
+        }
+        result.put("errorMsgList", errorMsgList);
+        result.put("sqlList", sqlList);
+        return ResultUtil.ok(result);
+    }
 }

+ 3 - 0
sop-business/src/main/java/com/qmth/sop/business/mapper/TBUserArchivesMapper.java

@@ -11,6 +11,7 @@ import com.qmth.sop.common.enums.RoleTypeEnum;
 import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
+import java.util.Map;
 
 /**
  * <p>
@@ -86,4 +87,6 @@ public interface TBUserArchivesMapper extends BaseMapper<TBUserArchives> {
      * @return 档案详细信息
      */
     List<UserArchivesResult> findSubTotal();
+
+    List<Map<String,Object>> findTempEmp();
 }

+ 3 - 0
sop-business/src/main/java/com/qmth/sop/business/service/TBUserArchivesService.java

@@ -12,6 +12,7 @@ import com.qmth.sop.business.entity.TBUserArchives;
 import com.qmth.sop.common.enums.RoleTypeEnum;
 
 import java.util.List;
+import java.util.Map;
 
 /**
  * <p>
@@ -118,4 +119,6 @@ public interface TBUserArchivesService extends IService<TBUserArchives> {
      * @return 区域负责人
      */
     List<ArchivesSourceResult> findFreeCoordinatorByServiceId(Long serviceUnitId, String crmNo, boolean verifyRate);
+
+    List<Map<String,Object>> findTempEmp();
 }

+ 5 - 0
sop-business/src/main/java/com/qmth/sop/business/service/impl/TBUserArchivesServiceImpl.java

@@ -536,4 +536,9 @@ public class TBUserArchivesServiceImpl extends ServiceImpl<TBUserArchivesMapper,
         }
         return result;
     }
+
+    @Override
+    public List<Map<String, Object>> findTempEmp() {
+        return this.baseMapper.findTempEmp();
+    }
 }

+ 18 - 26
sop-business/src/main/resources/mapper/TBDingSubmitMapper.xml

@@ -41,10 +41,7 @@
                  tbc.region_coordinator_id AS coordinatorId,
                  tbs.update_time AS serviceUpdateTime,
                  tbc.update_time AS crmUpdateTime,
-                 IF(tffa.status IN ('CANCEL','END','FINISH'),
-                     TIMESTAMPDIFF(DAY, FROM_UNIXTIME(SUBSTRING(tffa.create_time, 1, 10), '%Y-%m-%d'), FROM_UNIXTIME(SUBSTRING(tffa.update_time, 1, 10), '%Y-%m-%d')),
-                     TIMESTAMPDIFF(DAY, FROM_UNIXTIME(SUBSTRING(tffa.create_time, 1, 10), '%Y-%m-%d'), NOW()))
-                     - normal_days + 1 AS dingExceptionCount
+                 tbd.sign_in_exception_count + tbd.sign_out_exception_count AS dingExceptionCount
              FROM
                  (SELECT
                       service_id,
@@ -55,15 +52,14 @@
                       MAX(role_type) AS role_type,
                       MIN(sign_in_time) AS approach_time,
                       MAX(sign_out_time) AS departure_time,
-                      COUNT(1) AS actual_days,
-                      SUM(IF(date_type = 'WEEKDAY', 1, 0)) AS weekdays,
-                      SUM(IF(date_type = 'WEEKEND', 1, 0)) AS weekends,
-                      SUM(IF(date_type = 'LEGAL_HOLIDAYS', 1, 0)) AS legal_holidays,
-                      ROUND(SUM(IF(sign_out_time IS NOT NULL
-                                       AND sign_in_time IS NOT NULL, TIMESTAMPDIFF(MINUTE, FROM_UNIXTIME(SUBSTRING(sign_in_time, 1, 10), '%Y-%m-%d %H:%i:%s'), FROM_UNIXTIME(SUBSTRING(sign_out_time, 1, 10), '%Y-%m-%d %H:%i:%s')), 0)) / 60, 1) AS work_hours,
-                      SUM(IF((sign_in_time IS NULL
-                          OR sign_out_time IS NULL), 1, 0)) AS violation_days,
-                      SUM(IF((sign_in_time IS NOT NULL AND sign_out_time IS NOT NULL), 1, 0)) AS normal_days
+                      SUM(IF((sign_in_time IS NOT NULL AND sign_out_time IS NOT NULL), 1, 0)) AS actual_days,
+                      SUM(IF(date_type = 'WEEKDAY' AND (sign_in_time IS NOT NULL AND sign_out_time IS NOT NULL), 1, 0)) AS weekdays,
+                      SUM(IF(date_type = 'WEEKEND' AND (sign_in_time IS NOT NULL AND sign_out_time IS NOT NULL), 1, 0)) AS weekends,
+                      SUM(IF(date_type = 'LEGAL_HOLIDAYS' AND (sign_in_time IS NOT NULL AND sign_out_time IS NOT NULL), 1, 0)) AS legal_holidays,
+                      ROUND(SUM(IF(sign_out_time IS NOT NULL AND sign_in_time IS NOT NULL, TIMESTAMPDIFF(MINUTE, FROM_UNIXTIME(SUBSTRING(sign_in_time, 1, 10), '%Y-%m-%d %H:%i:%s'), FROM_UNIXTIME(SUBSTRING(sign_out_time, 1, 10), '%Y-%m-%d %H:%i:%s')), 0)) / 60, 1) AS work_hours,
+                      SUM(IF((sign_in_time IS NULL OR sign_out_time IS NULL) AND (sign_in_time IS NOT NULL OR sign_out_time IS NOT NULL), 1, 0)) AS violation_days,
+                      SUM(IF(sign_in_time IS NULL, 1, 0)) AS sign_in_exception_count,
+                      SUM(IF(sign_out_time IS NULL, 1, 0)) AS sign_out_exception_count
                   FROM
                       t_b_ding
                   GROUP BY service_id , sop_no , crm_no , user_archives_id) tbd
@@ -195,10 +191,7 @@
                  tbc.region_coordinator_id AS coordinatorId,
                  tbs.update_time AS serviceUpdateTime,
                  tbc.update_time AS crmUpdateTime,
-                 IF(tffa.status IN ('CANCEL','END','FINISH'),
-                 TIMESTAMPDIFF(DAY, FROM_UNIXTIME(SUBSTRING(tffa.create_time, 1, 10), '%Y-%m-%d'), FROM_UNIXTIME(SUBSTRING(tffa.update_time, 1, 10), '%Y-%m-%d')),
-                 TIMESTAMPDIFF(DAY, FROM_UNIXTIME(SUBSTRING(tffa.create_time, 1, 10), '%Y-%m-%d'), NOW()))
-                 - normal_days + 1 AS dingExceptionCount
+                 tbd.sign_in_exception_count + tbd.sign_out_exception_count AS dingExceptionCount
              FROM
                  (SELECT
                       service_id,
@@ -209,15 +202,14 @@
                       MAX(role_type) AS role_type,
                       MIN(sign_in_time) AS approach_time,
                       MAX(sign_out_time) AS departure_time,
-                      COUNT(1) AS actual_days,
-                      SUM(IF(date_type = 'WEEKDAY', 1, 0)) AS weekdays,
-                      SUM(IF(date_type = 'WEEKEND', 1, 0)) AS weekends,
-                      SUM(IF(date_type = 'LEGAL_HOLIDAYS', 1, 0)) AS legal_holidays,
-                      ROUND(SUM(IF(sign_out_time IS NOT NULL
-                                       AND sign_in_time IS NOT NULL, TIMESTAMPDIFF(MINUTE, FROM_UNIXTIME(SUBSTRING(sign_in_time, 1, 10), '%Y-%m-%d %H:%i:%s'), FROM_UNIXTIME(SUBSTRING(sign_out_time, 1, 10), '%Y-%m-%d %H:%i:%s')), 0)) / 60, 1) AS work_hours,
-                      SUM(IF((sign_in_time IS NULL
-                          OR sign_out_time IS NULL), 1, 0)) AS violation_days,
-                      SUM(IF((sign_in_time IS NOT NULL AND sign_out_time IS NOT NULL), 1, 0)) AS normal_days
+                      SUM(IF((sign_in_time IS NOT NULL AND sign_out_time IS NOT NULL), 1, 0)) AS actual_days,
+                      SUM(IF(date_type = 'WEEKDAY' AND (sign_in_time IS NOT NULL AND sign_out_time IS NOT NULL), 1, 0)) AS weekdays,
+                      SUM(IF(date_type = 'WEEKEND' AND (sign_in_time IS NOT NULL AND sign_out_time IS NOT NULL), 1, 0)) AS weekends,
+                      SUM(IF(date_type = 'LEGAL_HOLIDAYS' AND (sign_in_time IS NOT NULL AND sign_out_time IS NOT NULL), 1, 0)) AS legal_holidays,
+                      ROUND(SUM(IF(sign_out_time IS NOT NULL AND sign_in_time IS NOT NULL, TIMESTAMPDIFF(MINUTE, FROM_UNIXTIME(SUBSTRING(sign_in_time, 1, 10), '%Y-%m-%d %H:%i:%s'), FROM_UNIXTIME(SUBSTRING(sign_out_time, 1, 10), '%Y-%m-%d %H:%i:%s')), 0)) / 60, 1) AS work_hours,
+                      SUM(IF((sign_in_time IS NULL OR sign_out_time IS NULL) AND (sign_in_time IS NOT NULL OR sign_out_time IS NOT NULL), 1, 0)) AS violation_days,
+                      SUM(IF(sign_in_time IS NULL, 1, 0)) AS sign_in_exception_count,
+                      SUM(IF(sign_out_time IS NULL, 1, 0)) AS sign_out_exception_count
                   FROM
                       t_b_ding
                   GROUP BY service_id , sop_no , crm_no , user_archives_id) tbd

+ 3 - 0
sop-business/src/main/resources/mapper/TBUserArchivesMapper.xml

@@ -348,5 +348,8 @@
             </if>
         </where>
     </select>
+    <select id="findTempEmp" resultType="java.util.Map">
+        SELECT * FROM temp_emp
+    </select>
 
 </mapper>