Эх сурвалжийг харах

fix:
sop 设备出入库数据权限控制
设备可入库设备查询条件修改
考勤打卡统计页面与正在补卡交互

caozixuan 1 жил өмнө
parent
commit
2026001609

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

@@ -47,7 +47,6 @@ public class TBDeviceInOutController {
     private TBDeviceInOutService tbDeviceInOutService;
     @Resource
     private SysUserService sysUserService;
-    // TODO: 2023/11/10 设备出入库sop数据权限变更 
 
     @ApiOperation(value = "sop管理 - 设备出入库登记查询")
     @RequestMapping(value = "/sop_page", method = RequestMethod.POST)

+ 41 - 10
sop-business/src/main/java/com/qmth/sop/business/service/impl/TBDingServiceImpl.java

@@ -65,6 +65,8 @@ public class TBDingServiceImpl extends ServiceImpl<TBDingMapper, TBDing> impleme
     private SysUserService sysUserService;
     @Resource
     private SysDingObjService sysDingObjService;
+    @Resource
+    private TBDingApplyService tbDingApplyService;
 
     @Override
     public DingElementResult findDingElements(String sopNo, Long userId) {
@@ -108,6 +110,11 @@ public class TBDingServiceImpl extends ServiceImpl<TBDingMapper, TBDing> impleme
 
     @Override
     public DingStatisticResult findDingStatistic(String sopNo, Long userId) {
+        // 截取年分割截止
+        final int yearEnd = 4;
+        // 截取日分割开始
+        final int dayStart = 5;
+
         // 根据sopNo查询日期表单
         DateFormDto dateFormDto = this.buildSignDateFormBySop(sopNo);
         List<String> dateFormList = dateFormDto.getDateFormList();
@@ -178,11 +185,19 @@ public class TBDingServiceImpl extends ServiceImpl<TBDingMapper, TBDing> impleme
             }
 
             String endDate = dateFormDto.getEndDate();
-            endDate = endDate.substring(5);
+            endDate = endDate.substring(dayStart);
+
+            // 查询正在补卡中的记录
+            List<TBDingApply> resigningList = tbDingApplyService.list(new QueryWrapper<TBDingApply>()
+                    .lambda()
+                    .select(TBDingApply::getType, TBDingApply::getApplyTime)
+                    .eq(TBDingApply::getSopNo, sopNo)
+                    .eq(TBDingApply::getCreateId, userId)
+                    .isNull(TBDingApply::getApprove));
 
             for (String date : dateFormList) {
-                String year = date.substring(0, 4);
-                String signDate = date.substring(5);
+                String year = date.substring(0, yearEnd);
+                String signDate = date.substring(dayStart);
 
                 List<DingFormResult> dingFormResultList = formDingList.stream()
                         .filter(e -> signDate.equals(e.getSignDate()))
@@ -226,6 +241,29 @@ public class TBDingServiceImpl extends ServiceImpl<TBDingMapper, TBDing> impleme
                     dingFormResult.setSignOutInfo(out);
                     dingFormResult.setSignDate(signDate);
                 }
+
+
+                // 当天补卡中的记录
+                List<TBDingApply> applyRecordList = resigningList.stream().filter(e -> {
+                    Long applyTime = e.getApplyTime();
+                    String applyTimeStr = DateFormatUtils.format(applyTime, SystemConstant.DEFAULT_DATE_YMD_S_PATTERN);
+                    String applyYear = applyTimeStr.substring(0, yearEnd);
+                    String applyDay = applyTimeStr.substring(dayStart);
+                    return year.equals(applyYear) && signDate.equals(applyDay);
+                }).collect(Collectors.toList());
+
+                // 签到 补卡记录
+                List<TBDingApply> applyInRecord = applyRecordList.stream().filter(e -> InOutTypeEnum.IN.equals(e.getType())).collect(Collectors.toList());
+                if (CollectionUtils.isNotEmpty(applyInRecord)) {
+                    dingFormResult.getSignInInfo().setStatus(DingStatusEnum.RE_SIGN_ING);
+                }
+
+                // 签退 补卡记录
+                List<TBDingApply> applyOutRecord = applyRecordList.stream().filter(e -> InOutTypeEnum.OUT.equals(e.getType())).collect(Collectors.toList());
+                if (CollectionUtils.isNotEmpty(applyOutRecord)) {
+                    dingFormResult.getSignOutInfo().setStatus(DingStatusEnum.RE_SIGN_ING);
+                }
+
                 dingFormResult.setYear(year);
                 formList.add(dingFormResult);
             }
@@ -399,13 +437,6 @@ public class TBDingServiceImpl extends ServiceImpl<TBDingMapper, TBDing> impleme
         }
     }
 
-    /**
-     * 查询列表
-     *
-     * @param iPage
-     * @return
-     */
-
     @Override
     public IPage<TBDingSubmitQueryResult> query(IPage<Map> iPage, Long serviceId, String status, Long createId, String userName, Long supplierId, String custom, String sopNo, Long days) {
         SysUser requestUser = (SysUser) ServletUtil.getRequestUser();

+ 46 - 9
sop-business/src/main/resources/mapper/TBDeviceInOutMapper.xml

@@ -71,9 +71,25 @@
                 AND tbdio.serial_no LIKE CONCAT('%',#{serialNo},'%')
             </if>
             <if test="dpr != null and !dpr.hasAdmin and !dpr.hasPmo">
-                <if test="dpr.hasBusiness">
-                    AND tbs.service_lead_id = #{dpr.requestUserId}
-                </if>
+                <choose>
+                    <when test="dpr.hasBusiness">
+                        AND tbs.service_lead_id = #{dpr.requestUserId} OR tbdio.service_id IS NULL
+                    </when>
+                    <otherwise>
+                        <choose>
+                            <when test="dpr.hasRegionManager">
+                                AND EXISTS(SELECT 1 FROM t_b_crm tbc WHERE tbc.crm_no = tbdio.crm_no AND tbc.lead_id = #{dpr.requestUserId} OR tbdio.service_id IS NULL)
+                            </when>
+                            <otherwise>
+                                <choose>
+                                    <when test="dpr.hasRegionCoordinator">
+                                        AND EXISTS(SELECT 1 FROM t_b_crm tbc WHERE tbc.crm_no = tbdio.crm_no AND tbc.region_coordinator_id = #{dpr.requestUserId} OR tbdio.service_id IS NULL)
+                                    </when>
+                                </choose>
+                            </otherwise>
+                        </choose>
+                    </otherwise>
+                </choose>
             </if>
         </where>
         ORDER BY tbs.id DESC,tbdio.in_out_time
@@ -148,9 +164,25 @@
                 AND tbdio.serial_no LIKE CONCAT('%',#{serialNo},'%')
             </if>
             <if test="dpr != null and !dpr.hasAdmin and !dpr.hasPmo">
-                <if test="dpr.hasBusiness">
-                    AND tbs.service_lead_id = #{dpr.requestUserId}
-                </if>
+                <choose>
+                    <when test="dpr.hasBusiness">
+                        AND tbs.service_lead_id = #{dpr.requestUserId} OR tbdio.service_id IS NULL
+                    </when>
+                    <otherwise>
+                        <choose>
+                            <when test="dpr.hasRegionManager">
+                                AND EXISTS(SELECT 1 FROM t_b_crm tbc WHERE tbc.crm_no = tbdio.crm_no AND tbc.lead_id = #{dpr.requestUserId} OR tbdio.service_id IS NULL)
+                            </when>
+                            <otherwise>
+                                <choose>
+                                    <when test="dpr.hasRegionCoordinator">
+                                        AND EXISTS(SELECT 1 FROM t_b_crm tbc WHERE tbc.crm_no = tbdio.crm_no AND tbc.region_coordinator_id = #{dpr.requestUserId} OR tbdio.service_id IS NULL)
+                                    </when>
+                                </choose>
+                            </otherwise>
+                        </choose>
+                    </otherwise>
+                </choose>
             </if>
         </where>
         ORDER BY tbs.id DESC,tbdio.in_out_time
@@ -208,9 +240,14 @@
             <if test="inOutType != null">
                 AND sd.bound = #{inOutType}
             </if>
-            <if test="sopNo != null and sopNo != ''">
-                AND EXISTS(SELECT 1 FROM t_b_device_in_out tbdio WHERE tbdio.device_no = sd.serial_no AND tbdio.sop_no = #{sopNo})
-            </if>
+            <choose>
+                <when test="sopNo != null and sopNo != ''">
+                    AND EXISTS(SELECT 1 FROM t_b_device_in_out tbdio WHERE tbdio.device_no = sd.serial_no AND tbdio.sop_no = #{sopNo})
+                </when>
+                <otherwise>
+                    AND EXISTS(SELECT 1 FROM t_b_device_in_out tbdio WHERE tbdio.device_no = sd.serial_no AND tbdio.service_id IS NULL)
+                </otherwise>
+            </choose>
         </where>
         ORDER BY ss.id,sd.brand,sd.serial_no
     </select>

+ 4 - 6
sop-business/src/main/resources/mapper/TBDingMapper.xml

@@ -453,16 +453,14 @@
         SELECT
             COUNT(*)
         FROM
-            t_b_ding_apply tbda
-                LEFT JOIN
-            t_b_ding tbd ON tbda.ding_id = tbd.id
+            t_b_ding_apply
         <where>
-            AND (tbda.approve IS NULL OR tbda.approve = 'PASS')
+            AND (approve IS NULL OR approve = 'PASS')
             <if test="userId != null">
-                AND tbd.user_id = #{userId}
+                AND create_id = #{userId}
             </if>
             <if test="sopNo != null and sopNo != ''">
-                AND tbd.sop_no = #{sopNo}
+                AND sop_no = #{sopNo}
             </if>
         </where>
     </select>