Преглед на файлове

Merge branch 'wanghaicheng' of lift-manager/lift-server into develop

wanghaicheng преди 4 години
родител
ревизия
3f562ea6fd

+ 8 - 1
lift-business-service/src/main/java/cn/com/ty/lift/business/emergency/controller/EmergencyRepairController.java

@@ -36,6 +36,7 @@ import cn.hutool.http.HttpUtil;
 import cn.hutool.poi.excel.ExcelUtil;
 import cn.hutool.poi.excel.ExcelWriter;
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import lombok.AllArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.jms.core.JmsMessagingTemplate;
@@ -744,9 +745,15 @@ public class EmergencyRepairController {
         entity.setFaultNature(request.getFaultNature());
         entity.setFaultDuty(request.getFaultDuty());
         entity.setRecoveryDate(recoveryDate);
-        //修改状态已完成
+        log.debug("修改急修状态到已完成");
         entity.setStatus(ValuePool.EMERGENCY_STATE_COMPLETE);
         RestResponse result = emergencyRepairService.repairOrder(entity, erRecordImgs);
+        log.debug("急修完成后,修改platform_company_lift_relevance,电梯状态到正常(状态值2)");
+        platformCompanyLiftRelevanceService.update(Wrappers.<PlatformCompanyLiftRelevance>update().
+                eq("mt_company_id", request.getMtCompanyId()).
+                eq("lift_id", request.getLiftId()).
+                set("lift_company_status", CommonEnum.LiftStatus.NORMAL.getCode()));
+
         if (Objects.equals("1", result.getStatusCode())) {
             Long mtCompanyId = entity.getMtCompanyId();
             Region region = pushUserService.findRegionByEmergencyRepair(id, mtCompanyId);

+ 5 - 0
lift-business-service/src/main/java/cn/com/ty/lift/business/library/dao/entity/model/response/LiftExtendResponse.java

@@ -32,4 +32,9 @@ public class LiftExtendResponse extends Lift {
      * 电梯品牌name
      */
     private String liftBrandName;
+
+    /**
+     * 电梯是否锁定
+     */
+    private Integer liftLocked;
 }

+ 4 - 0
lift-business-service/src/main/java/cn/com/ty/lift/business/maintenance/dao/entity/model/response/MaintenanceAppResponse.java

@@ -71,6 +71,10 @@ public class MaintenanceAppResponse {
      * 维保工
      */
     private String workerName;
+    /**
+     * 维保执行人名字
+     */
+    private String workerName1;
     /**
      * 计划保养时间
      */

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

@@ -58,4 +58,7 @@ public interface MaintenancePlanMapper extends BaseMapper<MaintenancePlan> {
     @Select("SELECT count FROM maintenance_plan WHERE id = #{planId}")
     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')")
+    boolean selectLiftMaintainableBy(Long workerId1, Long mtCompanyId);
 }

+ 4 - 0
lift-business-service/src/main/java/cn/com/ty/lift/business/maintenance/dao/mapper/MaintenanceRecordMapper.java

@@ -14,6 +14,7 @@ import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Select;
 
 import java.util.List;
+import java.util.Map;
 
 /**
  * MyBatis Mapper 接口 - 表:maintenance_record
@@ -81,4 +82,7 @@ public interface MaintenanceRecordMapper extends BaseMapper<MaintenanceRecord> {
 
     @Select("SELECT value FROM global_set WHERE code = 'workLift' AND company_id = #{mtCompanyId}")
     String getGlobalSet(Long mtCompanyId);
+
+    @Select("SELECT user_id,name FROM user_info WHERE user_id in (${userIds})")
+    List<Map<String, Object>> selectUserBy(@Param("userIds") String userIds);
 }

+ 17 - 0
lift-business-service/src/main/java/cn/com/ty/lift/business/maintenance/service/MaintenanceRecordService.java

@@ -6,7 +6,9 @@ import cn.com.ty.lift.business.evaluation.dao.entity.Evaluation;
 import cn.com.ty.lift.business.evaluation.service.EvaluationService;
 import cn.com.ty.lift.business.framework.util.MessageUtils;
 import cn.com.ty.lift.business.library.dao.entity.Lift;
+import cn.com.ty.lift.business.library.dao.entity.PlatformCompanyLiftRelevance;
 import cn.com.ty.lift.business.library.service.LiftService;
+import cn.com.ty.lift.business.library.service.PlatformCompanyLiftRelevanceService;
 import cn.com.ty.lift.business.maintenance.dao.entity.*;
 import cn.com.ty.lift.business.maintenance.dao.entity.model.request.MaintenanceRecordRequest;
 import cn.com.ty.lift.business.maintenance.dao.entity.model.request.MtRecordRequest;
@@ -89,6 +91,7 @@ public class MaintenanceRecordService extends ServiceImpl<MaintenanceRecordMappe
     private MaintenanceOptionMapper maintenanceOptionMapper;
     private MaintenancePlanMapper maintenancePlanMapper;
     MaintenanceOptionService maintenanceOptionService;
+    private PlatformCompanyLiftRelevanceService platformCompanyLiftRelevanceService;
 
     @Autowired
     private Environment env;
@@ -231,6 +234,11 @@ public class MaintenanceRecordService extends ServiceImpl<MaintenanceRecordMappe
         boolean result = calc(liftCoordinate, coordinate);
         if (result)
             return RestResponse.fail(MessageUtils.get("msg.error.person.scope"));
+        log.debug("根据全局设置判断当前维保工是否可以继续维保电梯");
+        boolean maintainable = maintenancePlanService.getBaseMapper().selectLiftMaintainableBy(request.getUserId(), request.getMtCompanyId());
+        if (!maintainable) {
+            return RestResponse.fail("超出公司设置的维保工可维保电梯上限数量");
+        }
         MaintenancePlan plan = maintenancePlanService.getOne(record.getMtPlanId());
         if (ObjectUtil.isEmpty(plan)) return RestResponse.fail(MessageUtils.get("msg.maintenance.plan.not.exist"));
 
@@ -291,6 +299,15 @@ public class MaintenanceRecordService extends ServiceImpl<MaintenanceRecordMappe
         } else {
             return RestResponse.fail(MessageUtils.get("msg.add.fail"));
         }
+        log.debug("根据公司和电梯id设置电梯状态为维保中");
+        boolean update = platformCompanyLiftRelevanceService.update(Wrappers.<PlatformCompanyLiftRelevance>update().
+                eq("mt_company_id", request.getMtCompanyId()).
+                eq("lift_id", request.getRecord().getLiftId()).
+                set("lift_company_status", CommonEnum.LiftStatus.MAINTENANCE.getCode()));
+        if (!update) {
+            rollback();
+            return RestResponse.fail("无法转换电梯状态到维保中");
+        }
         return RestResponse.success(record.getId(), MessageUtils.get("msg.add.success"));
     }
 

+ 21 - 0
lift-business-service/src/main/java/cn/com/ty/lift/business/project/service/ProjectAppService.java

@@ -356,6 +356,27 @@ public class ProjectAppService extends ServiceImpl<ProjectMapper, Project> {
             for (Map.Entry<Long, List<MaintenanceAppResponse>> entry : taskMap.entrySet()) {
                 taskList.addAll(entry.getValue());
             }
+            log.debug("将维保执行人设置进返回数据中");
+            List<Long> workerId1s = records.stream().
+                    filter(r -> r.getWorkerId1() != null).
+                    map(MaintenanceAppResponse::getWorkerId1).
+                    collect(Collectors.toList());
+            Map<Long, String> userInfoMap = new HashMap<>();
+            if (!workerId1s.isEmpty()) {
+                log.debug("workerId1s不为空,获取用户名列表");
+                List<Map<String, Object>> userMap = maintenanceRecordMapper.selectUserBy(workerId1s.toString().
+                        replace("]", "").
+                        replace("[", ""));
+                if (!userMap.isEmpty()) {
+                    userInfoMap = userMap.stream().
+                            filter(u -> u.get("user_id") != null).
+                            collect(Collectors.toMap(k -> Long.valueOf(k.get("user_id").toString()), v -> String.valueOf(v.get("name")), (k1, k2) -> k1));
+                }
+            }
+            Map<Long, String> finalUserInfoMap = userInfoMap;
+            taskList.forEach(t -> t.setWorkerName1(finalUserInfoMap.get(t.getWorkerId1())));
+            log.debug("设置完毕");
+
             LinkedList<MaintenanceAppResponse> userTaskList = taskList.stream()
                     .sorted(Comparator.comparing(MaintenanceAppResponse::getPlanDate)).collect(Collectors.toCollection(LinkedList::new));
             currentUserTaskList.addAll(userTaskList);

+ 1 - 0
lift-business-service/src/main/resources/mapper/lift/LiftMapper.xml

@@ -207,6 +207,7 @@
                lb.name AS liftBrandName,
                plr.id  AS relevanceId,
                plr.worker_id AS workerId,
+               plr.lift_locked AS liftLocked,
                ui.name AS workerName
         FROM lift l
                  LEFT JOIN project_lift_relevance plr ON l.id = plr.lift_id

+ 5 - 0
lift-common/src/main/java/cn.com.ty.lift.common/constants/ApiConstants.java

@@ -353,4 +353,9 @@ public class ApiConstants {
         int QUERY_REPAIR_EVALUATE_AUTH = 1;//查询急修评价权限
         int QUERY_MAINTENANCE_EVALUATE_AUTH = 2;//查询维保评价权限
     }
+
+    public interface LiftCertificate {
+        Integer NULL = 0;
+        Integer AUDIT = 1;
+    }
 }

+ 28 - 7
lift-enterprise-service/src/main/java/cn/com/ty/lift/enterprise/oa/controller/LiftCertificateController.java

@@ -1,16 +1,18 @@
 package cn.com.ty.lift.enterprise.oa.controller;
 
+import cn.com.ty.lift.common.constants.ApiConstants;
 import cn.com.ty.lift.common.model.CountPage;
 import cn.com.ty.lift.common.utils.ValuePool;
 import cn.com.ty.lift.common.verify.Val;
-import cn.com.ty.lift.common.verify.Validation;
 import cn.com.ty.lift.common.verify.Validate;
+import cn.com.ty.lift.common.verify.Validation;
 import cn.com.ty.lift.enterprise.oa.dto.LiftCertificateRequest;
 import cn.com.ty.lift.enterprise.oa.dto.LiftCertificateResponse;
 import cn.com.ty.lift.enterprise.oa.entity.LiftCertificate;
 import cn.com.ty.lift.enterprise.oa.service.LiftCertificateService;
 import cn.com.xwy.boot.web.dto.RestResponse;
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import lombok.AllArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.web.bind.annotation.PostMapping;
@@ -19,6 +21,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
 import javax.validation.Valid;
+import java.util.List;
 
 
 /**
@@ -117,14 +120,32 @@ public class LiftCertificateController {
     public RestResponse add(@Valid @RequestBody LiftCertificate entity) {
         Long ownerId = entity.getOwnerId();
         Long mtCompanyId = entity.getMtCompanyId();
-
-        int count = liftCertificateService.countByUserAndMtCompany(ownerId, mtCompanyId);
-        Validate.notTrue(count > 0, ValuePool.LIFT_CERT_HAD_EXIST);
-        entity.setStatus(1);
-
-        boolean result = liftCertificateService.saveOrUpdate(entity);
+//        int count = liftCertificateService.countByUserAndMtCompany(ownerId, mtCompanyId);
+        List<LiftCertificate> list = liftCertificateService.list(Wrappers.<LiftCertificate>lambdaQuery().
+                eq(LiftCertificate::getOwnerId, ownerId).
+                eq(LiftCertificate::getMtCompanyId, mtCompanyId));
+        boolean result;
+        if (list.size() > 0) {
+            log.debug("操作证数量大于0,设置操作证状态为待审核,批量更新操作证信息");
+            list.forEach(l -> {
+                l.setCode(entity.getCode());
+                l.setIssuanceAgency(entity.getIssuanceAgency());
+                l.setExpirationDate(entity.getExpirationDate());
+                l.setCertificateType(entity.getCertificateType());
+                l.setFirstImgUrl(entity.getFirstImgUrl());
+                l.setSecondImgUrl(entity.getSecondImgUrl());
+                l.setStatus(ApiConstants.LiftCertificate.AUDIT);
+            });
+            result = liftCertificateService.updateBatchById(list);
+        } else {
+            log.debug("没有操作证,设置操作证状态为待审核,保存操作证");
+            entity.setStatus(ApiConstants.LiftCertificate.AUDIT);
+            result = liftCertificateService.saveOrUpdate(entity);
+        }
+//        Validate.notTrue(list.size() > 0, ValuePool.LIFT_CERT_HAD_EXIST);
         return RestResponse.success(result);
 
+
     }
     @PostMapping("findByUser")
     @Validation(fields = {"ownerId","mtCompanyId"})