Browse Source

update->修复 开启维保时,维保工可同时保养电梯数量的日期匹配处理错误

wang-hai-cheng 5 years ago
parent
commit
f302bde36d

+ 2 - 2
lift-business-service/src/main/java/cn/com/ty/lift/business/maintenance/dao/mapper/MaintenancePlanMapper.java

@@ -60,6 +60,6 @@ public interface MaintenancePlanMapper extends BaseMapper<MaintenancePlan> {
     Long getCountByPlanId(Long planId);
 
     @Select("select (select value from global_set where company_id = #{mtCompanyId}  and code = 'sameUnits') >" +
-            "       (select count(*) from maintenance_record where mt_company_id=#{mtCompanyId} and worker_id1 = #{workerId1} and status = '1' and work_date = #{today})")
-    boolean selectLiftMaintainableBy(Long workerId1, Long mtCompanyId, LocalDate today);
+            "       (select count(*) from maintenance_record where mt_company_id=#{mtCompanyId} and (worker_id1 = #{workerId1} or worker_id = #{workerId1}) and status = '1' and DATE_FORMAT(work_date, '%Y-%m-%d') = #{today})")
+    boolean selectLiftMaintainableBy(Long workerId1, Long mtCompanyId, String today);
 }

+ 2 - 1
lift-business-service/src/main/java/cn/com/ty/lift/business/maintenance/service/MaintenanceRecordService.java

@@ -67,6 +67,7 @@ import java.net.HttpURLConnection;
 import java.net.URL;
 import java.time.LocalDate;
 import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
 import java.util.*;
 import java.util.stream.Collectors;
 
@@ -235,7 +236,7 @@ public class MaintenanceRecordService extends ServiceImpl<MaintenanceRecordMappe
         if (result)
             return RestResponse.fail(MessageUtils.get("msg.error.person.scope"));
         log.debug("根据全局设置判断当前维保工是否可以继续维保电梯");
-        boolean maintainable = maintenancePlanService.getBaseMapper().selectLiftMaintainableBy(request.getUserId(), request.getMtCompanyId(),LocalDate.now());
+        boolean maintainable = maintenancePlanService.getBaseMapper().selectLiftMaintainableBy(request.getUserId(), request.getMtCompanyId(),DateTimeFormatter.ofPattern("yyyy-MM-dd").format(LocalDate.now()));
         if (!maintainable) {
             return RestResponse.fail("超出公司设置的维保工可维保电梯上限数量");
         }