Browse Source

Merge branch 'feature-wcz' of lift-manager/lift-server into develop

wucizhong 5 years ago
parent
commit
7fc2cdefb2
23 changed files with 761 additions and 193 deletions
  1. 41 6
      lift-business-service/src/main/java/cn/com/ty/lift/business/annualinspection/controller/AnnualInspectionController.java
  2. 4 7
      lift-business-service/src/main/java/cn/com/ty/lift/business/common/CommonController.java
  3. 95 0
      lift-business-service/src/main/java/cn/com/ty/lift/business/common/MybatisSqlBuilder.java
  4. 139 0
      lift-business-service/src/main/java/cn/com/ty/lift/business/common/PushUserService.java
  5. 59 0
      lift-business-service/src/main/java/cn/com/ty/lift/business/common/mapper/PushUserMapper.java
  6. 24 1
      lift-business-service/src/main/java/cn/com/ty/lift/business/emergency/controller/EmergencyRepairController.java
  7. 61 31
      lift-business-service/src/main/java/cn/com/ty/lift/business/emergency/service/EmergencyRepairService.java
  8. 6 0
      lift-business-service/src/main/java/cn/com/ty/lift/business/framework/job/BusinessJob.java
  9. 16 20
      lift-business-service/src/main/java/cn/com/ty/lift/business/library/service/LiftService.java
  10. 39 39
      lift-business-service/src/main/java/cn/com/ty/lift/business/project/service/ProjectService.java
  11. 0 26
      lift-business-service/src/main/resources/application-dev.yml
  12. 0 27
      lift-business-service/src/main/resources/application-local.yml
  13. 15 11
      lift-push/src/main/resources/application-dev.yml
  14. 2 0
      lift-business-service/src/main/resources/application-web.yml
  15. 1 1
      lift-business-service/src/main/resources/application.yml
  16. 1 1
      lift-business-service/src/main/resources/bootstrap.yml
  17. 181 0
      lift-business-service/src/main/resources/mapper/push/PushUserMapper.xml
  18. 10 7
      lift-common/src/main/java/cn.com.ty.lift.common/model/PushMessage.java
  19. 1 1
      lift-push/src/main/java/cn/com/ty/lift/push/app/PushConsumer.java
  20. 15 14
      lift-push/src/main/java/cn/com/ty/lift/push/app/XingePush.java
  21. 50 0
      lift-push/src/main/resources/application-prod.yml
  22. 0 0
      lift-push/src/main/resources/application-test.yml
  23. 1 1
      lift-push/src/main/resources/application.yml

+ 41 - 6
lift-business-service/src/main/java/cn/com/ty/lift/business/annualinspection/controller/AnnualInspectionController.java

@@ -5,15 +5,20 @@ import cn.com.ty.lift.business.annualinspection.dto.InspectionRequest;
 import cn.com.ty.lift.business.annualinspection.dto.InspectionResponse;
 import cn.com.ty.lift.business.annualinspection.entity.AnnualInspection;
 import cn.com.ty.lift.business.annualinspection.service.AnnualInspectionService;
+import cn.com.ty.lift.business.common.PushUserService;
 import cn.com.ty.lift.business.library.dao.entity.model.response.LiftAnnualInspectionResponse;
 import cn.com.ty.lift.business.library.service.LiftService;
+import cn.com.ty.lift.business.project.dao.entity.Region;
+import cn.com.ty.lift.common.constants.CommonEnum;
 import cn.com.ty.lift.common.model.CountPage;
 import cn.com.ty.lift.common.model.PushMessage;
+import cn.com.ty.lift.common.model.PushUserInfo;
 import cn.com.ty.lift.common.utils.DateUtils;
 import cn.com.ty.lift.common.verify.Ver;
 import cn.com.ty.lift.common.verify.Verifier;
 import cn.com.ty.lift.common.verify.Verify;
 import cn.com.xwy.boot.web.dto.RestResponse;
+import cn.hutool.core.collection.IterUtil;
 import cn.hutool.core.io.FileUtil;
 import cn.hutool.core.util.StrUtil;
 import cn.hutool.core.util.ZipUtil;
@@ -38,10 +43,8 @@ import java.io.FileInputStream;
 import java.io.OutputStream;
 import java.time.LocalDate;
 import java.time.LocalDateTime;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
+import java.util.*;
+import java.util.stream.Collectors;
 
 /**
  * <p>
@@ -60,6 +63,7 @@ public class AnnualInspectionController {
     private AnnualInspectionService annualInspectionService;
     private LiftService             liftService;
     private JmsMessagingTemplate    jmsMessagingTemplate;
+    private PushUserService         pushUserService;
 
     private static final Map<String, String>     headerAlias = new HashMap<>();
     //最大年检间隔
@@ -247,8 +251,39 @@ public class AnnualInspectionController {
 
         boolean ai = annualInspectionService.saveOrUpdate(old);
         if(ai){
-            InspectionResponse ins = annualInspectionService.infoById(entity);
-            PushMessage.inspectionConfirmCheckDate(ins.getProjectName(), ins.getDevicePosition(), ins.getRegistrationCode(), ins.getCheckDate()).sendAllOnPlatform(jmsMessagingTemplate);
+            List<PushUserInfo> pushUserInfos = pushUserService.listByAnnualInspection(old.getId(), old.getMtCompanyId(), Arrays.asList(CommonEnum.DefaultRole.REGION_DIRECTOR.getCode()));
+            if (IterUtil.isNotEmpty(pushUserInfos)) {
+                InspectionResponse ins = annualInspectionService.infoById(entity);
+                Map<Integer, List<PushUserInfo>> collect = pushUserInfos.stream().collect(Collectors.groupingBy(PushUserInfo::getDeviceModel));
+                List<PushUserInfo> android = collect.get(1);
+                if (IterUtil.isNotEmpty(android)) {
+                    List<String> toAndroid = android.stream().map(PushUserInfo::getDeviceFlag).collect(Collectors.toList());
+                    PushMessage.inspectionConfirmCheckDate(ins.getProjectName(), ins.getDevicePosition(), ins.getRegistrationCode(), ins.getCheckDate()).sendTokenOnAndroid(jmsMessagingTemplate, toAndroid);
+                }
+                List<PushUserInfo> ios = collect.get(2);
+                if (IterUtil.isNotEmpty(ios)) {
+                    List<String> toIos = ios.stream().map(PushUserInfo::getDeviceFlag).collect(Collectors.toList());
+                    PushMessage.inspectionConfirmCheckDate(ins.getProjectName(), ins.getDevicePosition(), ins.getRegistrationCode(), ins.getCheckDate()).sendTokenOnIos(jmsMessagingTemplate, toIos);
+                }
+            }
+            Region region = pushUserService.findRegionByAnnualInspection(old.getId(), old.getMtCompanyId());
+            if (Objects.nonNull(region)) {
+                List<Long> userIds = new ArrayList<>();
+                userIds.add(region.getUserId());
+                String clerk = region.getClerk();
+                if (Objects.nonNull(clerk)) {
+                    if (clerk.contains(",")) {
+                        List<Long> clerks = Arrays.stream(clerk.split(",")).map(s -> Long.parseLong(s.trim())).collect(Collectors.toList());
+                        userIds.addAll(clerks);
+                    } else {
+                        userIds.add(Long.parseLong(clerk.trim()));
+                    }
+                }
+                List<PushUserInfo> regionUsers = pushUserService.listByUserIds(old.getMtCompanyId(), userIds);
+                List<PushUserInfo> director = pushUserService.listByRoleCodes(old.getMtCompanyId(), Arrays.asList(CommonEnum.DefaultRole.HIGH_DIRECTOR.getCode()));
+
+
+            }
         }
         return RestResponse.success(ai);
     }

+ 4 - 7
lift-business-service/src/main/java/cn/com/ty/lift/business/common/CommonController.java

@@ -21,10 +21,7 @@ import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 import org.springframework.web.multipart.MultipartFile;
 
-import java.util.ArrayList;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
 
 /**
  * @author bieao
@@ -80,7 +77,7 @@ public class CommonController {
      */
     @PostMapping("uploads")
     public RestResponse uploads(@RequestParam("files") MultipartFile[] files){
-        Verify.notTrue(null == files || files.length == 0,Verify.Upload.fileDataMissing);
+        Verify.notTrue(Objects.isNull(files) || files.length == 0,Verify.Upload.fileDataMissing);
         try {
             Map<String, MultipartFile> fileMap = new HashMap<>();
             //1 先解析文件格式
@@ -125,7 +122,7 @@ public class CommonController {
      */
     @PostMapping("upload")
     public RestResponse upload(@RequestParam("file") MultipartFile file){
-        Verify.notTrue(null == file || file.isEmpty(),Verify.Upload.fileDataMissing);
+        Verify.notTrue(Objects.isNull(file) || file.isEmpty(),Verify.Upload.fileDataMissing);
         try {
             String fileName = handleFile(file);
             if(StrUtil.isEmpty(fileName)){
@@ -147,7 +144,7 @@ public class CommonController {
      * @return the name string of the file.
      */
     private String handleFile(MultipartFile file){
-        Verify.notTrue(null == file || file.isEmpty(),Verify.Upload.fileDataMissing);
+        Verify.notTrue(Objects.isNull(file) || file.isEmpty(),Verify.Upload.fileDataMissing);
         // 获取文件名,带后缀
         String originalFilename = file.getOriginalFilename();
         log.info("上传文件,原文件名:{}", originalFilename);

+ 95 - 0
lift-business-service/src/main/java/cn/com/ty/lift/business/common/MybatisSqlBuilder.java

@@ -0,0 +1,95 @@
+package cn.com.ty.lift.business.common;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author huangyuan
+ * @date 2020/4/18
+ * @description mybatis @select 自定义sql 处理工具
+ */
+public class MybatisSqlBuilder {
+
+    /**
+     * @param params 查询参数
+     * @return 拼接的sql语句
+     * @description 通过给定参数拼接sql - 获取当前公司指定角色的用户信息
+     * @date 2020/4/18 6:27 下午
+     */
+    @SuppressWarnings("unchecked")
+    public String getPushUserInfoByRoleCodesSql(Map<String, Object> params) {
+
+        List<String> roleCodeList = (List<String>) params.get("roleCodeList");
+        Long companyId = (Long) params.get("companyId");
+        //获取通用语句
+        StringBuilder sql = getPushUserInfoSql();
+        if (roleCodeList != null && roleCodeList.size() > 0) {
+            sql.append("and r.code in (");
+            //拼接list语句
+            spliceList(roleCodeList, sql);
+        }
+        sql.append("and ur.company_id=").append(companyId);
+        System.out.println(sql.toString());
+        return sql.toString();
+    }
+
+    /**
+     * @param params 查询参数
+     * @return 拼接的sql语句
+     * @description 通过给定参数拼接sql - 获取当前公司指定角色的用户信息
+     * @date 2020/4/18 6:27 下午
+     */
+    @SuppressWarnings("unchecked")
+    public String getPushUserInfoByIdsSql(Map<String, Object> params) {
+        List<Long> userIdList = (List<Long>) params.get("userIdList");
+        Long companyId = (Long) params.get("companyId");
+        //获取通用语句
+        StringBuilder sql = getPushUserInfoSql();
+        if (userIdList != null && userIdList.size() > 0) {
+            sql.append("and ua.user_id in (");
+            //拼接list语句
+            spliceList(userIdList, sql);
+        }
+        sql.append("and ur.company_id=").append(companyId);
+        System.out.println(sql);
+        return sql.toString();
+    }
+
+    /**
+     * @param list 要拼接的list
+     * @description 拼接语句
+     * @date 2020/4/18 6:37 下午
+     */
+    private void spliceList(List<?> list, StringBuilder sql) {
+        for (int i = 0; i < list.size(); i++) {
+            sql.append("'").append(list.get(i));
+            if (i == list.size() - 1) {
+                sql.append("')");
+            } else {
+                sql.append("',");
+            }
+        }
+    }
+
+    /**
+     * @return 通用语句
+     * @description 获取查询通用语句
+     * @date 2020/4/18 6:51 下午
+     */
+    private StringBuilder getPushUserInfoSql() {
+        StringBuilder sql = new StringBuilder();
+        sql.append("SELECT ui.user_id AS userId, ");
+        sql.append("ui.name AS userName, ");
+        sql.append("ua.mobile AS mobile, ");
+        sql.append("ua.device_model AS deviceModel, ");
+        sql.append("ua.device_flag AS deviceFlag, ");
+        sql.append("r.name AS roleName FROM ");
+        sql.append("user_account ua ");
+        sql.append("LEFT JOIN user_info ui ON ua.user_id = ui.user_id ");
+        sql.append("LEFT JOIN user_role ur ON ua.user_id = ur.user_id ");
+        sql.append("LEFT JOIN role r ON r.id = ur.role_id ");
+        sql.append("WHERE 1 = 1 ");
+        return sql;
+    }
+}
+

+ 139 - 0
lift-business-service/src/main/java/cn/com/ty/lift/business/common/PushUserService.java

@@ -0,0 +1,139 @@
+package cn.com.ty.lift.business.common;
+
+import cn.com.ty.lift.business.common.mapper.PushUserMapper;
+import cn.com.ty.lift.business.project.dao.entity.Region;
+import cn.com.ty.lift.common.constants.ApiConstants;
+import cn.com.ty.lift.common.constants.PushMessageConstants;
+import cn.com.ty.lift.common.model.PushUserInfo;
+import cn.com.xwy.boot.service.impl.BaseServiceImpl;
+import org.springframework.stereotype.Service;
+import org.springframework.web.context.request.RequestContextHolder;
+import org.springframework.web.context.request.ServletRequestAttributes;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpSession;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Objects;
+
+/**
+ * @author huangyuan
+ * @date 2020/4/17
+ * @description
+ */
+@Service
+public class PushUserService extends BaseServiceImpl<PushUserMapper, PushUserInfo> {
+
+    /**
+     * @param pushSituation 推送情形:1 2 3 4 5
+     *                      :1 企业管理员
+     *                      :2 企业管理员 + 总经理
+     *                      :3 企业管理员 + 总经理 + 区域主管
+     *                      :4 企业管理员 + 总经理 + 区域主管 + 文员
+     *                      :5 企业管理员 + 总经理 + 区域主管 + 文员 + 维保工
+     * @return 要推送给的用户信息
+     * @description 通过推送情形获取对应用户信息
+     * @date 2020/4/17 11:14 上午
+     */
+    public List<PushUserInfo> getPushUserInfo(int pushSituation) {
+        String[] roleCodes = PushMessageConstants.PUSH_VALUE_TO_ROLE_CODE.get(pushSituation);
+        if (roleCodes != null && roleCodes.length > 0) {
+            return getPushUserInfoByRoleCodes(Arrays.asList(roleCodes));
+        }
+        return null;
+    }
+
+    /**
+     * @param roleCodes 角色编码集合
+     * @return 要推送的用户信息
+     * @description
+     * @date 2020/4/17 3:38 下午
+     */
+    public List<PushUserInfo> getPushUserInfoByRoleCodes(List<String> roleCodes) {
+        //获取当前公司id
+        Long companyId = getCurrentCompanyId();
+        return this.baseMapper.getPushUserInfoByRoleCodes(companyId, roleCodes);
+    }
+
+    /**
+     * @param userIdList 用户id集合
+     * @return 用户信息
+     * @description
+     * @date 2020/4/18 7:16 下午
+     */
+    public List<PushUserInfo> getPushUserInfoByUserIds(List<Long> userIdList) {
+        //获取当前公司id
+        Long companyId = getCurrentCompanyId();
+        return this.baseMapper.getPushUserInfoByUserIds(companyId, userIdList);
+    }
+
+    /**
+     * @return 当前用户id
+     * @description 获取当前用户id
+     * @date 2020/4/17 10:06 上午
+     */
+    private Long getCurrentUserId() {
+        return getAttributeFromSession(ApiConstants.CURRENT_USER_ID);
+    }
+
+
+    /**
+     * @return 当前公司id
+     * @description 获取当前公司id
+     * @date 2020/4/17 10:09 上午
+     */
+    private Long getCurrentCompanyId() {
+        return getAttributeFromSession(ApiConstants.CURRENT_COMPANY_ID);
+    }
+
+    /**
+     * @param attributeName 属性名
+     * @return 属性值
+     * @description 从session中获取
+     * @date 2020/4/17 10:09 上午
+     */
+    private Long getAttributeFromSession(String attributeName) {
+        HttpSession session = getHttpSession();
+        if (session != null) {
+            return (Long) session.getAttribute(attributeName);
+        }
+        return null;
+    }
+
+    /**
+     * @return session
+     * @description 获取session
+     * @date 2020/4/17 10:06 上午
+     */
+    private HttpSession getHttpSession() {
+        HttpServletRequest request = ((ServletRequestAttributes) Objects.requireNonNull(
+                RequestContextHolder.getRequestAttributes())).getRequest();
+        return request.getSession();
+    }
+
+    public List<PushUserInfo> listByUserIds(Long mtCompanyId, List<Long> userIds){
+        return baseMapper.listByUserIds(mtCompanyId, userIds);
+    }
+
+    public List<PushUserInfo> listByRoleCodes(Long mtCompanyId, List<String> roleCodes){
+        return baseMapper.listByRoleCodes(mtCompanyId, roleCodes);
+    }
+
+    public List<PushUserInfo> listByEmergencyRepair(Long repairId, Long mtCompanyId, List<String> roleCodes){
+        return baseMapper.listByEmergencyRepair(repairId, mtCompanyId, roleCodes);
+    }
+    public Region findRegionByEmergencyRepair(Long repairId, Long mtCompanyId){
+        return baseMapper.findRegionByEmergencyRepair(repairId, mtCompanyId);
+    }
+
+    public List<PushUserInfo> listByAnnualInspection(Long inspectionId, Long mtCompanyId, List<String> roleCodes){
+        return baseMapper.listByAnnualInspection(inspectionId, mtCompanyId, roleCodes);
+    }
+    public Region findRegionByAnnualInspection(Long inspectionId, Long mtCompanyId){
+        return baseMapper.findRegionByAnnualInspection(inspectionId, mtCompanyId);
+    }
+
+    public Region findRegionByProject(Long projectId, Long mtCompanyId){
+        return baseMapper.findRegionByProject(projectId, mtCompanyId);
+    }
+}

+ 59 - 0
lift-business-service/src/main/java/cn/com/ty/lift/business/common/mapper/PushUserMapper.java

@@ -0,0 +1,59 @@
+package cn.com.ty.lift.business.common.mapper;
+
+import cn.com.ty.lift.business.project.dao.entity.Region;
+import cn.com.ty.lift.common.model.PushUserInfo;
+import cn.com.ty.lift.common.utils.MybatisSqlUtils;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.SelectProvider;
+
+import java.util.List;
+
+/**
+ * <p>
+ * 专家表 Mapper 接口
+ * </p>
+ *
+ * @author huangyuan
+ * @since 2020-04-17
+ */
+public interface PushUserMapper extends BaseMapper<PushUserInfo> {
+
+    /**
+     * 获取要推送的用户信息
+     *
+     * @param companyId 当前公司id
+     * @param roleCodes 角色编码集合
+     * @return 用户信息
+     * @description 获取要推送的用户信息
+     * @date 2020/4/17 2:03 下午
+     */
+    @SelectProvider(type = MybatisSqlUtils.class, method = "getPushUserInfoByRoleCodesSql")
+    List<PushUserInfo> getPushUserInfoByRoleCodes(@Param("companyId") Long companyId,
+                                                  @Param("roleCodeList") List<String> roleCodes);
+
+    /**
+     * 获取要推送的用户信息
+     *
+     * @param companyId  当前公司id
+     * @param userIdList 用户id集合
+     * @return 用户信息
+     * @description 获取要推送的用户信息
+     * @date 2020/4/18 7:24 下午
+     */
+    @SelectProvider(type = MybatisSqlUtils.class, method = "getPushUserInfoByIdsSql")
+    List<PushUserInfo> getPushUserInfoByUserIds(@Param("companyId") Long companyId,
+                                                @Param("userIdList") List<Long> userIdList);
+
+    List<PushUserInfo> listByUserIds(@Param("mtCompanyId") Long mtCompanyId, @Param("userIds") List<Long> userIds);
+    List<PushUserInfo> listByRoleCodes(@Param("mtCompanyId") Long mtCompanyId, @Param("roleCodes") List<String> roleCodes);
+
+    Region findRegionByEmergencyRepair(@Param("id") Long repairId, @Param("mtCompanyId") Long mtCompanyId);
+    Region findRegionByAnnualInspection(@Param("id") Long inspectionId, @Param("mtCompanyId") Long mtCompanyId);
+    Region findRegionByProject(@Param("id") Long projectId, @Param("mtCompanyId") Long mtCompanyId);
+
+    List<PushUserInfo> listByEmergencyRepair(@Param("id") Long repairId, @Param("mtCompanyId") Long mtCompanyId, @Param("roleCodes") List<String> roleCodes);
+
+    List<PushUserInfo> listByAnnualInspection(@Param("id") Long inspectionId, @Param("mtCompanyId") Long mtCompanyId, @Param("roleCodes") List<String> roleCodes);
+
+}

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

@@ -1,6 +1,7 @@
 package cn.com.ty.lift.business.emergency.controller;
 
 
+import cn.com.ty.lift.business.common.PushUserService;
 import cn.com.ty.lift.business.emergency.dto.*;
 import cn.com.ty.lift.business.emergency.entity.EmergencyRepair;
 import cn.com.ty.lift.business.emergency.entity.ErRecordCost;
@@ -11,9 +12,11 @@ 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.library.dao.entity.PlatformCompanyLiftRelevance;
 import cn.com.ty.lift.business.library.service.PlatformCompanyLiftRelevanceService;
+import cn.com.ty.lift.business.project.dao.entity.Region;
 import cn.com.ty.lift.common.constants.CommonEnum;
 import cn.com.ty.lift.common.model.CountPage;
 import cn.com.ty.lift.common.model.PushMessage;
+import cn.com.ty.lift.common.model.PushUserInfo;
 import cn.com.ty.lift.common.utils.DateUtils;
 import cn.com.ty.lift.common.utils.ValuePool;
 import cn.com.ty.lift.common.utils.WordUtil;
@@ -75,6 +78,7 @@ public class EmergencyRepairController {
     private PlatformCompanyLiftRelevanceService platformCompanyLiftRelevanceService;
     private EmergencyHistoryService             emergencyHistoryService;
     private JmsMessagingTemplate                jmsMessagingTemplate;
+    private PushUserService                     pushUserService;
 
     private static final Map<String, String> headerAlias = new HashMap<>();
 
@@ -171,7 +175,7 @@ public class EmergencyRepairController {
         int repairing = emergencyRepairService.countRepairing(mtCompanyId, liftId);
         Verify.nolt0(repairing, Verify.Repair.haveUnfinisedRepair);
         PlatformCompanyLiftRelevance relevance = platformCompanyLiftRelevanceService.findByMtCompanyAndLift(entity.getMtCompanyId(), entity.getLiftId());
-        if(null != relevance){
+        if(Objects.nonNull(relevance)){
             Verify.notTrue(relevance.getLiftCompanyStatus().equals(CommonEnum.LiftStatus.ANNUAL_INSPECTION.getCode()), Verify.Repair.inspection);
         }
 
@@ -181,6 +185,24 @@ public class EmergencyRepairController {
         entity.setStatus(Verify.Repair.STATUS_TO_REPAIRED);
         boolean result = emergencyRepairService.save(entity);
         if (result) {
+            Region region = pushUserService.findRegionByEmergencyRepair(entity.getId(), mtCompanyId);
+            if (Objects.nonNull(region)) {
+                List<Long> userIds = new ArrayList<>();
+                userIds.add(region.getUserId());
+                String clerk = region.getClerk();
+                if (Objects.nonNull(clerk)) {
+                    if (clerk.contains(",")) {
+                        List<Long> clerks = Arrays.stream(clerk.split(",")).map(s -> Long.parseLong(s.trim())).collect(Collectors.toList());
+                        userIds.addAll(clerks);
+                    } else {
+                        userIds.add(Long.parseLong(clerk.trim()));
+                    }
+                }
+                List<PushUserInfo> regionUsers = pushUserService.listByUserIds(mtCompanyId, userIds);
+                List<PushUserInfo> director = pushUserService.listByRoleCodes(mtCompanyId, Arrays.asList(CommonEnum.DefaultRole.HIGH_DIRECTOR.getCode()));
+
+
+            }
             RepairResponse info = emergencyRepairService.infoById(entity.getId());
             PushMessage.emergencyAssign(info.getAreaName(), info.getProjectName(), info.getDevicePosition(), info.getRegistrationCode(), info.getCallerDate(), info.getIsTrapped(), info.getCallerFaultDescription(), info.getWorkerName()).sendAllOnPlatform(jmsMessagingTemplate);
         }
@@ -265,6 +287,7 @@ public class EmergencyRepairController {
 
         //如果已经接单,在急修中了不能被转派
         Verify.notTrue(Verify.Repair.statusRepairing(entity.getStatus()), Verify.Repair.repairHadTaked);
+        Long originWorker = entity.getWorkerId1();
         //本急修单的负责维保工
         entity.setWorkerId1(request.getWorkerId());
 

+ 61 - 31
lift-business-service/src/main/java/cn/com/ty/lift/business/emergency/service/EmergencyRepairService.java

@@ -14,6 +14,7 @@ import cn.com.ty.lift.business.library.service.PlatformCompanyLiftRelevanceServi
 import cn.com.ty.lift.common.constants.CommonEnum;
 import cn.com.ty.lift.common.verify.Verify;
 import cn.com.xwy.boot.web.dto.RestResponse;
+import cn.hutool.core.collection.IterUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
@@ -25,6 +26,7 @@ import org.springframework.transaction.interceptor.TransactionAspectSupport;
 
 import java.time.LocalDateTime;
 import java.util.*;
+import java.util.stream.Collectors;
 
 /**
  * <p>
@@ -289,7 +291,7 @@ public class EmergencyRepairService extends ServiceImpl<EmergencyRepairMapper, E
     }
 
     private String formatCostContent(ErRecordCost erRecordCost){
-        return String.format("应收:%.2f, 实收:%.2f, 开票:%.2f", erRecordCost.getCostMoney(), erRecordCost.getPayMoney(), erRecordCost.getInvoiceMoney());
+        return String.format("费用项:%s, 应收:%.2f, 实收:%.2f, 开票:%.2f", erRecordCost.getCostName(), erRecordCost.getCostMoney(), erRecordCost.getPayMoney(), erRecordCost.getInvoiceMoney());
     }
 
     /**
@@ -346,49 +348,77 @@ public class EmergencyRepairService extends ServiceImpl<EmergencyRepairMapper, E
         if (!re) {
             return RestResponse.fail("修改急修失败,请稍后重试");
         }
-        //原有的收费项就更新,新加的新增
-        boolean er = erRecordCostService.saveOrUpdateBatch(erRecordCosts,erRecordCosts.size());
-        if (er) {
-            List<EmergencyHistory> histories = new ArrayList<>();
-            for (ErRecordCost erRecordCost : erRecordCosts) {
+        List<ErRecordCost> updateList = new ArrayList<>();
+        List<ErRecordCost> deleteList = new ArrayList<>();
+        List<EmergencyHistory> histories = new ArrayList<>();
+        //新增的收费项
+        List<ErRecordCost> insertList = erRecordCosts.stream().filter(cost -> Objects.isNull(cost.getId())).collect(Collectors.toList());
+        if (IterUtil.isNotEmpty(insertList)) {
+            for (ErRecordCost erRecordCost : insertList) {
                 EmergencyHistory history = new EmergencyHistory();
                 history.setErRecordId(repair.getId());
                 history.setDescription(erRecordCost.getCostName());
+                history.setBeforeContent("--");
                 String afterContent = formatCostContent(erRecordCost);
                 history.setAfterContent(afterContent);
                 history.setOperatorId(repair.getUpdateId());
                 history.setOperateDate(LocalDateTime.now());
-                if(erRecordCost.getId() == null){
-                    history.setOperate("新增收费项");
-                    history.setBeforeContent("--");
+                history.setOperate("新增收费项");
+                histories.add(history);
+            }
+        }
+        //比较原有的收费项
+        for (ErRecordCost oldRecordCost : oldRecordCosts) {
+            EmergencyHistory history = new EmergencyHistory();
+            history.setErRecordId(repair.getId());
+            history.setDescription(oldRecordCost.getCostName());
+            String before = formatCostContent(oldRecordCost);
+            history.setBeforeContent(before);
+            history.setOperatorId(repair.getUpdateId());
+            history.setOperateDate(LocalDateTime.now());
+            Optional<ErRecordCost> original = erRecordCosts.stream().filter(cost -> oldRecordCost.getId().equals(cost.getId())).findFirst();
+            if (original.isPresent()) {
+                history.setOperate("修改收费项");
+                String after = formatCostContent(original.get());
+                if (!Objects.equals(before, after)) {
+                    history.setAfterContent(after);
                     histories.add(history);
-                }else{
-                    history.setOperate("修改收费项");
-                    Optional<ErRecordCost> first = oldRecordCosts.stream().filter(cost -> cost.getId().equals(erRecordCost.getId())).findFirst();
-                    if(first.isPresent()){
-                        ErRecordCost cost = first.get();
-                        String beforeContent = formatCostContent(cost);
-                        history.setBeforeContent(beforeContent);
-                        if(!Objects.equals(beforeContent, afterContent)){
-                            histories.add(history);
-                        }
-                    }else{
-                        history.setBeforeContent("--");
-                        histories.add(history);
-                    }
+                    updateList.add(oldRecordCost);
                 }
+            } else {
+                history.setOperate("删除收费项");
+                history.setAfterContent("--");
+                histories.add(history);
+                deleteList.add(oldRecordCost);
             }
-            boolean his = emergencyHistoryService.saveBatch(histories, histories.size());
-            if(his){
-                return RestResponse.success(true);
-            }else{
+        }
+        if(IterUtil.isNotEmpty(deleteList)){
+            boolean delete = erRecordCostService.removeByIds(deleteList.stream().map(ErRecordCost::getId).collect(Collectors.toList()));
+            if(!delete){
                 rollback();
-                return RestResponse.fail("插入急修操作记录失败,请稍后重试");
+                return RestResponse.fail("删除急修收费项失败,请稍后重试");
             }
-        } else {
-            //强制手动事务回滚
+        }
+        if(IterUtil.isNotEmpty(updateList)){
+            boolean update = erRecordCostService.updateBatchById(updateList, updateList.size());
+            if(!update){
+                rollback();
+                return RestResponse.fail("修改急修收费项失败,请稍后重试");
+            }
+        }
+        if(IterUtil.isNotEmpty(insertList)){
+            boolean save = erRecordCostService.saveBatch(insertList, insertList.size());
+            if(!save){
+                rollback();
+                return RestResponse.fail("新增急修收费项失败,请稍后重试");
+            }
+        }
+        boolean his = emergencyHistoryService.saveBatch(histories, histories.size());
+        if(his){
+            return RestResponse.success(true);
+        }else{
             rollback();
-            return RestResponse.fail("修改急修收费项失败,请稍后重试");
+            return RestResponse.fail("插入急修操作记录失败,请稍后重试");
         }
     }
 

+ 6 - 0
lift-business-service/src/main/java/cn/com/ty/lift/business/framework/job/BusinessJob.java

@@ -39,6 +39,9 @@ public class BusinessJob {
         maintenancePlanService.updateOverduePlan(1000);
     }
 
+    /**
+     * 年检到期提前45天提醒
+     */
     @Scheduled(cron = "0 0 8 * * ?")
     public void inspection45days() {
         log.trace("Starting inspection 45days");
@@ -67,6 +70,9 @@ public class BusinessJob {
         } while (pageNum <= pages);
     }
 
+    /**
+     * 年检到期提前15天提醒
+     */
     @Scheduled(cron = "0 0 8 * * ?")
     public void inspection15days() {
         log.trace("Starting inspection 15days");

+ 16 - 20
lift-business-service/src/main/java/cn/com/ty/lift/business/library/service/LiftService.java

@@ -6,12 +6,8 @@ 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.dao.entity.model.LiftImportModel;
 import cn.com.ty.lift.business.library.dao.entity.model.LiftProjectModel;
-import cn.com.ty.lift.business.library.dao.entity.model.request.LiftChooseRequest;
-import cn.com.ty.lift.business.library.dao.entity.model.request.LiftExtensionRequest;
-import cn.com.ty.lift.business.library.dao.entity.model.request.LiftRequest;
-import cn.com.ty.lift.business.library.dao.entity.model.request.ProjectLiftRequest;
-import cn.com.ty.lift.business.library.dao.entity.model.response.LiftAnnualInspectionResponse;
 import cn.com.ty.lift.business.library.dao.entity.model.request.*;
+import cn.com.ty.lift.business.library.dao.entity.model.response.LiftAnnualInspectionResponse;
 import cn.com.ty.lift.business.library.dao.entity.model.response.LiftResponse;
 import cn.com.ty.lift.business.library.dao.mapper.LiftMapper;
 import cn.com.ty.lift.business.maintenance.dao.entity.model.response.LiftPrintResponse;
@@ -22,8 +18,8 @@ import cn.com.ty.lift.common.base.ExportRequest;
 import cn.com.ty.lift.common.constants.ApiConstants;
 import cn.com.ty.lift.common.constants.CommonEnum;
 import cn.com.ty.lift.common.export.ExportUtils;
-import cn.com.ty.lift.common.verify.Verify;
 import cn.com.ty.lift.common.utils.DateUtils;
+import cn.com.ty.lift.common.verify.Verify;
 import cn.com.xwy.boot.web.dto.RestResponse;
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.date.DateUtil;
@@ -34,6 +30,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.IdWorker;
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Service;
@@ -410,29 +407,29 @@ public class LiftService extends ServiceImpl<LiftMapper, Lift> {
 
         //批量插入platform-company-lift关联数据
         if (!platformCompanyLiftRelevances.isEmpty()) {
-            boolean plat = platformService.saveOrUpdateBatch(platformCompanyLiftRelevances);
+            boolean plat = platformService.saveOrUpdateBatch(platformCompanyLiftRelevances, platformCompanyLiftRelevances.size());
             if (!plat) {
                 //强制手动事务回滚
                 rollback();
-                return RestResponse.fail();
+                return RestResponse.fail("插入平台公司电梯关联信息失败,请稍后重试");
             }
         }
         //批量插入project-lift关联数据
         if (!projectLiftRelevances.isEmpty()) {
-            boolean proj = projectRelevanceService.saveOrUpdateBatch(projectLiftRelevances);
+            boolean proj = projectRelevanceService.saveOrUpdateBatch(projectLiftRelevances, projectLiftRelevances.size());
             if (!proj) {
                 //强制手动事务回滚
                 rollback();
-                return RestResponse.fail();
+                return RestResponse.fail("插入项目电梯关联信息失败,请稍后重试");
             }
         }
         //批量插入lift数据
         if (!lifts.isEmpty()) {
-            boolean lift = saveOrUpdateBatch(lifts);
+            boolean lift = saveOrUpdateBatch(lifts, lifts.size());
             if (!lift) {
                 //强制手动事务回滚
                 rollback();
-                return RestResponse.fail();
+                return RestResponse.fail("插入电梯信息失败,请稍后重试");
             }
         }
         return RestResponse.success("导入成功");
@@ -445,8 +442,7 @@ public class LiftService extends ServiceImpl<LiftMapper, Lift> {
      * @author wcz
      */
     public List<Lift> groupByRegistrationCode() {
-        QueryWrapper<Lift> queryWrapper = new QueryWrapper<>();
-        LambdaQueryWrapper<Lift> lambdaQueryWrapper = queryWrapper.lambda();
+        LambdaQueryWrapper<Lift> lambdaQueryWrapper = Wrappers.lambdaQuery();
         lambdaQueryWrapper.groupBy(Lift::getRegistrationCode);
         lambdaQueryWrapper.having("count(*) > 1");
         return list(lambdaQueryWrapper);
@@ -497,9 +493,9 @@ public class LiftService extends ServiceImpl<LiftMapper, Lift> {
             }
         });
         //保存脚本到文件
-        String sqlname = "./sql/1.delete_lift.sql";
-        FileUtil.writeString(deleteBuffer.toString(), new File(sqlname), "utf-8");
-        log.info("生成DELETE操作sql文件:{}", sqlname);
+        String deletesql = "./sql/1.delete_lift.sql";
+        FileUtil.writeString(deleteBuffer.toString(), new File(deletesql), "utf-8");
+        log.info("生成DELETE操作sql文件:{}", deletesql);
 
         StringBuffer updateBuffer = new StringBuffer();
         //需要更新lift_id的表
@@ -523,9 +519,9 @@ public class LiftService extends ServiceImpl<LiftMapper, Lift> {
             updateIds.entrySet().forEach(entry -> {
                 updateBuffer.append(StrUtil.format("UPDATE {} SET lift_id = {} WHERE lift_id IN ({});", table, entry.getKey(), StrUtil.join(",", entry.getValue()))).append("\n");
             });
-            sqlname = StrUtil.format("./sql/{}.update_{}.sql", (i + 2), table);
-            FileUtil.writeString(updateBuffer.toString(), new File(sqlname), "utf-8");
-            log.info("生成UPDATE操作sql文件:{}", sqlname);
+            String updatesql = StrUtil.format("./sql/{}.update_{}.sql", (i + 2), table);
+            FileUtil.writeString(updateBuffer.toString(), new File(updatesql), "utf-8");
+            log.info("生成UPDATE操作sql文件:{}", updatesql);
             //清空buffer
             updateBuffer.setLength(0);
         }

+ 39 - 39
lift-business-service/src/main/java/cn/com/ty/lift/business/project/service/ProjectService.java

@@ -335,7 +335,7 @@ public class ProjectService extends ServiceImpl<ProjectMapper,Project> {
     @Transactional(rollbackFor = Exception.class)
     public RestResponse assemble(List<ProjectImportModel> projectImportModels,Long mtCompanyId){
         //检查列表有效性
-        Verify.notNull(projectImportModels,"没有数据");
+        Verify.notNull(projectImportModels, "没有数据");
         //存放新建的project
         List<Project> projects = new ArrayList<>();
         //存放新建的region
@@ -364,16 +364,16 @@ public class ProjectService extends ServiceImpl<ProjectMapper,Project> {
 
         //全部甲方联系人
         List<PropertyContact> propertyContactList = propertyContactService.list();
-        log.info("甲方联系人总条数: {}",propertyContactList.size());
+        log.info("甲方联系人总条数: {}", propertyContactList.size());
 
-        for (int i = 0; i< projectImportModels.size();i ++){
+        for (int i = 0; i < projectImportModels.size(); i++) {
             ProjectImportModel item = projectImportModels.get(i);
             //0 属性表头,1 文字表头,2 记录行
             int rowNum = i + 2;
             Project project = new Project();
             //复制解析model中的值到project中
-            BeanUtil.copyProperties(item,project);
-            log.info("复制属性后的project: {}",project);
+            BeanUtil.copyProperties(item, project);
+            log.info("复制属性后的project: {}", project);
             //查找省
             String provName = item.getProvince();
             Optional<AreaCode> provOptional = provinceList
@@ -381,9 +381,9 @@ public class ProjectService extends ServiceImpl<ProjectMapper,Project> {
                     .filter(areaCode -> (StrUtil.equals(areaCode.getName(), provName)))
                     .distinct().limit(1).findFirst();
 
-            if(!provOptional.isPresent()){
-                log.error("表格数据有误,行数:{}, {}没有匹配省",rowNum,provName);
-                return RestResponse.fail(StrUtil.format("表格数据有误,行数:{}, {}没有匹配省",rowNum,provName));
+            if (!provOptional.isPresent()) {
+                log.error("表格数据有误,行数:{}, {}没有匹配省", rowNum, provName);
+                return RestResponse.fail(StrUtil.format("表格数据有误,行数:{}, {}没有匹配省", rowNum, provName));
             }
             //项目中设置省
             AreaCode province = provOptional.get();
@@ -395,9 +395,9 @@ public class ProjectService extends ServiceImpl<ProjectMapper,Project> {
                     .stream()
                     .filter(areaCode -> (StrUtil.equals(areaCode.getName(), cityName)))
                     .distinct().limit(1).findFirst();
-            if(!cityOptional.isPresent()){
-                log.error("表格数据有误,行数:{}, {}没有匹配市",rowNum,cityName);
-                return RestResponse.fail(StrUtil.format("表格数据有误,行数:{}, {}没有匹配市",rowNum,cityName));
+            if (!cityOptional.isPresent()) {
+                log.error("表格数据有误,行数:{}, {}没有匹配市", rowNum, cityName);
+                return RestResponse.fail(StrUtil.format("表格数据有误,行数:{}, {}没有匹配市", rowNum, cityName));
             }
             //项目中设置市
             AreaCode city = cityOptional.get();
@@ -409,9 +409,9 @@ public class ProjectService extends ServiceImpl<ProjectMapper,Project> {
                     .stream()
                     .filter(areaCode -> (StrUtil.equals(areaCode.getName(), distName)))
                     .distinct().limit(1).findFirst();
-            if(!distOptional.isPresent()){
-                log.error("表格数据有误,行数:{}, {}没有匹配区",rowNum,distName);
-                return RestResponse.fail(StrUtil.format("表格数据有误,行数:{}, {}没有匹配区",rowNum,distName));
+            if (!distOptional.isPresent()) {
+                log.error("表格数据有误,行数:{}, {}没有匹配区", rowNum, distName);
+                return RestResponse.fail(StrUtil.format("表格数据有误,行数:{}, {}没有匹配区", rowNum, distName));
             }
             //项目中设置区
             AreaCode district = distOptional.get();
@@ -425,9 +425,9 @@ public class ProjectService extends ServiceImpl<ProjectMapper,Project> {
                     .filter(r -> (StrUtil.equals(r.getProvinceCode(), province.getCode()) && StrUtil.equals(r.getCityCode(), city.getCode()) && StrUtil.equals(r.getAreaName(), areaName)))
                     .distinct().limit(1).findFirst();
             //根据省市查找区域,如果区域不存在就新增
-            if(!regionOptional.isPresent()) {
-                log.error("表格数据有误,行数:{}, {}没有匹配区域",rowNum,areaName);
-                return RestResponse.fail(StrUtil.format("表格数据有误,行数:{}, {}没有匹配区域",rowNum,areaName));
+            if (!regionOptional.isPresent()) {
+                log.error("表格数据有误,行数:{}, {}没有匹配区域", rowNum, areaName);
+                return RestResponse.fail(StrUtil.format("表格数据有误,行数:{}, {}没有匹配区域", rowNum, areaName));
 
                 //fixme:待确认,如果表格中导入的区域不存在,直接返回还是新增
 //                Region region = new Region();
@@ -455,14 +455,14 @@ public class ProjectService extends ServiceImpl<ProjectMapper,Project> {
                     .stream()
                     .filter(company -> (StrUtil.equals(company.getName(), ppCompanyName)))
                     .distinct().limit(1).findFirst();
-            if(ppcOptional.isPresent()){
+            if (ppcOptional.isPresent()) {
                 //如果存在就赋值给ppCompanyId
                 ppCompanyId = ppcOptional.get().getId();
-            }else{
+            } else {
                 //如果维保公司不存在,新建,生成id
                 PropertyCompany propertyCompany = new PropertyCompany();
                 ppCompanyId = IdWorker.getId();
-                log.info("新建甲方公司. id: {}",ppCompanyId);
+                log.info("新建甲方公司. id: {}", ppCompanyId);
                 propertyCompany.setId(ppCompanyId);
                 propertyCompany.setMtCompanyId(mtCompanyId);
                 //公司名称
@@ -485,14 +485,14 @@ public class ProjectService extends ServiceImpl<ProjectMapper,Project> {
                     .stream()
                     .filter(contact -> (StrUtil.equals(contact.getName(), ppCompanyContact) && StrUtil.equals(contact.getTelephone(), ppTelephone) && ppCompanyId == contact.getPpCompanyId()))
                     .distinct().limit(1).findFirst();
-            if(pptOptional.isPresent()){
+            if (pptOptional.isPresent()) {
                 //如果存在就取id
                 ppContactId = pptOptional.get().getId();
-            }else {
+            } else {
                 //如果不存在就创建,加入到新增list中
                 PropertyContact propertyContact = new PropertyContact();
                 ppContactId = IdWorker.getId();
-                log.info("新增甲方联系人. id: {}",ppContactId);
+                log.info("新增甲方联系人. id: {}", ppContactId);
                 propertyContact.setId(ppContactId);
                 propertyContact.setName(ppCompanyContact);
                 propertyContact.setTelephone(ppTelephone);
@@ -515,38 +515,38 @@ public class ProjectService extends ServiceImpl<ProjectMapper,Project> {
             projects.add(project);
         }
         //批量插入新增区域信息
-        if(!regions.isEmpty()){
-            boolean reg = regionService.saveOrUpdateBatch(regions);
-            if(!reg){
+        if (!regions.isEmpty()) {
+            boolean reg = regionService.saveOrUpdateBatch(regions, regions.size());
+            if (!reg) {
                 //强制手动事务回滚
                 rollback();
-                return RestResponse.fail();
+                return RestResponse.fail("插入区域信息失败,请稍后重试");
             }
         }
         //批量插入新增甲方公司
-        if(!propertyCompanies.isEmpty()){
-            boolean ppc = propertyCompanyService.saveOrUpdateBatch(propertyCompanies);
-            if(!ppc){
+        if (!propertyCompanies.isEmpty()) {
+            boolean ppc = propertyCompanyService.saveOrUpdateBatch(propertyCompanies, propertyCompanies.size());
+            if (!ppc) {
                 //强制手动事务回滚
                 rollback();
-                return RestResponse.fail();
+                return RestResponse.fail("插入公司信息失败,请稍后重试");
             }
         }
         //批量插入新增甲方联系人
-        if(!propertyContacts.isEmpty()){
-            boolean ppt = propertyContactService.saveOrUpdateBatch(propertyContacts);
-            if(!ppt){
+        if (!propertyContacts.isEmpty()) {
+            boolean ppt = propertyContactService.saveOrUpdateBatch(propertyContacts, propertyContacts.size());
+            if (!ppt) {
                 //强制手动事务回滚
                 rollback();
-                return RestResponse.fail();
+                return RestResponse.fail("插入联系人信息失败,请稍后重试");
             }
         }
         //批量插入项目
-        if(!projects.isEmpty()){
-            boolean pro = saveBatch(projects);
-            if(!pro){
+        if (!projects.isEmpty()) {
+            boolean pro = saveBatch(projects, projects.size());
+            if (!pro) {
                 rollback();
-                return RestResponse.fail();
+                return RestResponse.fail("插入项目信息失败,请稍后重试");
             }
         }
         return RestResponse.success("导入成功");

+ 0 - 26
lift-business-service/src/main/resources/application-dev.yml

@@ -1,26 +0,0 @@
-spring:
-  datasource:
-    url: jdbc:mysql://192.168.1.46:3306/rdsliftmanager?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
-    username: root
-    password: Tyty-2020
-    driver-class-name: com.mysql.cj.jdbc.Driver
-
-  #redis缓存配置
-  redis:
-    database: 0 #数据库索引,默认为0
-    host: 192.168.1.46 #服务器地址
-    port: 6379 #端口
-    password: newtyty #验证密码
-    jedis:
-      pool:
-        max-active: 8 #最大连接数
-        max-idle: 8 #最大空闲链接
-        max-wait: 20000ms
-        min-idle: 0
-#aliyun OSS服务配置信息,加载到SystemConfiguration
-aliyun:
-  oss:
-    endpoint: http://oss-cn-beijing.aliyuncs.com
-    bucketName: temp15827479607
-    accessKeyId: LTAI4FkSqFZa6LH9HqAsVott
-    accessKeySecret: w7GXuh5tf1hduQuZ2AzT3a4q14BI1i

+ 0 - 27
lift-business-service/src/main/resources/application-local.yml

@@ -1,27 +0,0 @@
-spring:
-  datasource:
-    url: jdbc:mysql://132.232.206.88:3306/rdsliftmanager?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
-    username: root
-    password: ms.c88pocY/
-    driver-class-name: com.mysql.cj.jdbc.Driver
-
-  #redis缓存配置
-  redis:
-    database: 0 #数据库索引,默认为0
-    host: 132.232.206.88 #服务器地址
-    port: 6379 #端口
-    password: mdx12358 #验证密码
-    jedis:
-      pool:
-        max-active: 8 #最大连接数
-        max-idle: 8 #最大空闲链接
-        max-wait: 20000ms
-        min-idle: 0
-
-#aliyun OSS服务配置信息,加载到SystemConfiguration
-aliyun:
-  oss:
-    endpoint: http://oss-cn-beijing.aliyuncs.com
-    bucketName: temp15827479607
-    accessKeyId: LTAI4FkSqFZa6LH9HqAsVott
-    accessKeySecret: w7GXuh5tf1hduQuZ2AzT3a4q14BI1i

+ 15 - 11
lift-push/src/main/resources/application-dev.yml

@@ -1,22 +1,23 @@
 spring:
   datasource:
-    url: jdbc:mysql://192.168.1.46:3306/rdsliftmanager?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
-    username: root
-    password: Tyty-2020
+    url: jdbc:mysql://rm-bp1qkwy173koi066x.mysql.rds.aliyuncs.com:3306/rdsliftmanager?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
+    username: tykj
+    password: Tdkg-13250409
     driver-class-name: com.mysql.cj.jdbc.Driver
 
   #redis缓存配置
   redis:
     database: 0 #数据库索引,默认为0
-    host: 192.168.1.46 #服务器地址
+    host: r-bp1j7odydtfqtprdvm.redis.rds.aliyuncs.com #(内网地址)服务器地址
     port: 6379 #端口
-    password: newtyty #验证密码
+    password: Gdkc-290431 #验证密码
     jedis:
       pool:
         max-active: 8 #最大连接数
         max-idle: 8 #最大空闲链接
         max-wait: 20000ms
         min-idle: 0
+    timeout: 600000s
   activemq:
     #ActiveMQ通讯地址
     broker-url: tcp://121.40.209.47:61616
@@ -24,10 +25,10 @@ spring:
     user: admin
     #密码
     password: admin
-    #true 表示使用内置的MQ,false则连接服务器
+    #true 表示使用内置的MQ,false则连接服务器: 消息持久化就必须spring.activemq.in-memory=false选项
     in-memory: false
     packages:
-      #信任所有的包
+      #信任所有的包: 如果直接发送对象消息,那么必须设置spring.activemq.packages.trust-all为true
       trust-all: true
     pool:
       #true表示使用连接池;false时,每发送一条数据创建一个连接
@@ -40,7 +41,10 @@ spring:
     #如果是点对点(queue),那么此处默认应该是false,如果发布订阅,那么一定设置为true
     pub-sub-domain: false
 
-#xinge服务配置信息,加载到SystemConfiguration
-xinge:
-    appId: 40d4e2e854433
-    secretKey: fa99dc19157b00fc71cf8d7e840273a3
+#aliyun OSS服务配置信息,加载到SystemConfiguration
+aliyun:
+  oss:
+    endpoint: http://oss-cn-beijing.aliyuncs.com
+    bucketName: temp15827479607
+    accessKeyId: LTAI4FkSqFZa6LH9HqAsVott
+    accessKeySecret: w7GXuh5tf1hduQuZ2AzT3a4q14BI1i

+ 2 - 0
lift-business-service/src/main/resources/application-web.yml

@@ -17,6 +17,8 @@ spring:
         max-idle: 8 #最大空闲链接
         max-wait: 20000ms
         min-idle: 0
+
+  #消息队列配置
   activemq:
     #ActiveMQ通讯地址
     broker-url: tcp://121.40.209.47:61616

+ 1 - 1
lift-business-service/src/main/resources/application.yml

@@ -5,7 +5,7 @@ spring:
   application:
     name: lift-business-service
   profiles:
-    active: web
+    active: test
   datasource:
     hikari:
       max-lifetime: 1200000 # default: 1800000

+ 1 - 1
lift-business-service/src/main/resources/bootstrap.yml

@@ -20,5 +20,5 @@ eureka:
     lease-expiration-duration-in-seconds: 20
   client:
     service-url:
-      defaultZone: http://localhost:10225/eureka/
+      defaultZone: http://172.16.24.142:10225/eureka/
 

+ 181 - 0
lift-business-service/src/main/resources/mapper/push/PushUserMapper.xml

@@ -0,0 +1,181 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="cn.com.ty.lift.business.common.mapper.PushUserMapper">
+
+    <!-- 通用查询映射结果 -->
+    <resultMap id="BaseResultMap" type="cn.com.ty.lift.common.model.PushUserInfo">
+        <id column="user_id" property="userId"/>
+        <result column="username" property="userName"/>
+        <result column="mobile" property="mobile"/>
+        <result column="device_model" property="deviceModel"/>
+        <result column="device_flag" property="deviceFlag"/>
+        <result column="role_name" property="roleName"/>
+    </resultMap>
+
+    <select id="listByUserIds" resultMap="BaseResultMap">
+        SELECT
+            ui.user_id,
+            ui.NAME AS username,
+            ua.mobile,
+            ua.device_model,
+            ua.device_flag,
+            ro.NAME AS role_name
+        FROM
+            user_info ui
+            LEFT JOIN user_account ua ON ui.user_id = ua.user_id
+            LEFT JOIN user_role ur ON ui.user_id = ur.user_id
+            LEFT JOIN role ro ON ro.id = ur.role_id
+        <where>
+            <if test="mtCompanyId != null and mtCompanyId > 0">
+                AND ur.company_id = #{mtCompanyId}
+            </if>
+            <if test="userIds != null">
+                AND ui.user_id IN
+                <foreach collection="userIds" item="userId" open="(" separator="," close=")">
+                    #{userId, jdbcType=BIGINT}
+                </foreach>
+            </if>
+        </where>
+    </select>
+
+    <select id="listByRoleCodes" resultMap="BaseResultMap">
+        SELECT
+            ui.user_id,
+            ui.NAME AS username,
+            ua.mobile,
+            ua.device_model,
+            ua.device_flag,
+            ro.NAME AS role_name
+        FROM
+            user_info ui
+            LEFT JOIN user_account ua ON ui.user_id = ua.user_id
+            LEFT JOIN user_role ur ON ui.user_id = ur.user_id
+            LEFT JOIN role ro ON ro.id = ur.role_id
+        <where>
+            <if test="mtCompanyId != null and mtCompanyId > 0">
+                AND ur.company_id = #{mtCompanyId}
+            </if>
+            <if test="roleCodes != null">
+                AND ro.code IN
+                <foreach collection="roleCodes" item="roleCode" open="(" separator="," close=")">
+                    #{roleCode, jdbcType=VARCHAR}
+                </foreach>
+            </if>
+        </where>
+    </select>
+
+    <select id="findRegionByEmergencyRepair" resultType="cn.com.ty.lift.business.project.dao.entity.Region">
+        SELECT
+            re.user_id,
+            re.clerk
+        FROM emergency_repair er
+            LEFT JOIN project pr ON pr.id = er.project_id
+            LEFT JOIN region re ON re.id = pr.region_id
+        <where>
+            <if test="id != null and id > 0">
+                AND er.id = #{id}
+            </if>
+            <if test="mtCompanyId != null and mtCompanyId > 0">
+                AND er.mt_company_id = #{mtCompanyId}
+            </if>
+        </where>
+    </select>
+
+    <select id="listByEmergencyRepair" resultMap="BaseResultMap">
+        SELECT
+            ui.user_id,
+            ui.NAME AS username,
+            ua.mobile,
+            ua.device_model,
+            ua.device_flag,
+            ro.NAME AS role_name
+        FROM
+            emergency_repair er
+            LEFT JOIN project pr ON pr.id = er.project_id
+            LEFT JOIN region re ON re.id = pr.region_id
+            LEFT JOIN user_info ui ON ui.user_id = re.user_id
+            LEFT JOIN user_account ua ON ui.user_id = ua.user_id
+            LEFT JOIN user_role ur ON ui.user_id = ur.user_id
+            LEFT JOIN role ro ON ro.id = ur.role_id
+        <where>
+            <if test="id != null and id > 0">
+                AND er.id = #{id}
+            </if>
+            <if test="mtCompanyId != null and mtCompanyId > 0">
+                AND er.mt_company_id = #{mtCompanyId}
+            </if>
+            <if test="roleCodes != null">
+                AND ro.`code` IN
+                <foreach collection="roleCodes" item="roleCode" open="(" separator="," close=")">
+                    #{roleCode, jdbcType=VARCHAR}
+                </foreach>
+            </if>
+        </where>
+    </select>
+
+    <select id="listByAnnualInspection" resultMap="BaseResultMap">
+        SELECT
+            ui.user_id,
+            ui.NAME AS username,
+            ua.mobile,
+            ua.device_model,
+            ua.device_flag,
+            ro.NAME AS role_name
+        FROM
+            annual_inspection ai
+            LEFT JOIN project_lift_relevance plr ON plr.mt_company_id = ai.mt_company_id AND ai.lift_id = plr.lift_id
+            LEFT JOIN project pr ON pr.id = plr.project_id
+            LEFT JOIN region re ON re.id = pr.region_id
+            LEFT JOIN user_info ui ON ui.user_id = re.user_id
+            LEFT JOIN user_account ua ON ui.user_id = ua.user_id
+            LEFT JOIN user_role ur ON ua.user_id = ur.user_id
+            LEFT JOIN role ro ON ro.id = ur.role_id
+        <where>
+            <if test="id != null and id > 0">
+                AND ai.id = #{id}
+            </if>
+            <if test="mtCompanyId != null and mtCompanyId > 0">
+                AND ai.mt_company_id = #{mtCompanyId}
+            </if>
+            <if test="roleCodes != null">
+                AND ro.`code` IN
+                <foreach collection="roleCodes" item="roleCode" open="(" separator="," close=")">
+                    #{roleCode, jdbcType=VARCHAR}
+                </foreach>
+            </if>
+        </where>
+    </select>
+
+    <select id="findRegionByAnnualInspection" resultType="cn.com.ty.lift.business.project.dao.entity.Region">
+        SELECT
+            re.user_id,
+            re.clerk
+        FROM annual_inspection ai
+            LEFT JOIN project_lift_relevance plr ON plr.lift_id = ai.lift_id AND plr.mt_company_id = ai.mt_company_id
+            LEFT JOIN project pr ON pr.id = plr.project_id
+            LEFT JOIN region re ON re.id = pr.region_id
+        <where>
+            <if test="id != null and id > 0">
+                AND ai.id = #{id}
+            </if>
+            <if test="mtCompanyId != null and mtCompanyId > 0">
+                AND ai.mt_company_id = #{mtCompanyId}
+            </if>
+        </where>
+    </select>
+    <select id="findRegionByProject" resultType="cn.com.ty.lift.business.project.dao.entity.Region">
+        SELECT
+            re.user_id,
+            re.clerk
+        FROM project pr
+            LEFT JOIN region re ON re.id = pr.region_id
+        <where>
+            <if test="id != null and id > 0">
+                AND pr.id = #{id}
+            </if>
+            <if test="mtCompanyId != null and mtCompanyId > 0">
+                AND pr.mt_company_id = #{mtCompanyId}
+            </if>
+        </where>
+    </select>
+</mapper>

+ 10 - 7
lift-common/src/main/java/cn.com.ty.lift.common/model/PushMessage.java

@@ -22,11 +22,14 @@ import java.util.List;
 @Slf4j
 @Data
 public class PushMessage implements Serializable {
-    private String            title;
-    private String            content;
-    private ArrayList<String> toList;
+
+    private static final long serialVersionUID = 4125096758372084309L;
+
+    private String       title;
+    private String       content;
+    private List<String> toList;
     //the count of try again. Increase 1 for each failure, maximum times 100
-    private int               tryCount = 0;
+    private int          tryCount = 0;
 
     private PushMessage() {
     }
@@ -527,7 +530,7 @@ public class PushMessage implements Serializable {
      * @param toAndroid            推到安卓平台的Token列表
      * @param toIos                推到ios平台的Token列表
      */
-    public boolean sendTokenOnPlatform(JmsMessagingTemplate jmsMessagingTemplate, ArrayList<String> toAndroid, ArrayList<String> toIos) {
+    public boolean sendTokenOnPlatform(JmsMessagingTemplate jmsMessagingTemplate, List<String> toAndroid, List<String> toIos) {
         try {
             if (IterUtil.isNotEmpty(toAndroid)) {
                 this.setToList(toAndroid);
@@ -567,7 +570,7 @@ public class PushMessage implements Serializable {
      * @param jmsMessagingTemplate jms
      * @param toList               推到安卓平台的设备token
      */
-    public boolean sendTokenOnAndroid(JmsMessagingTemplate jmsMessagingTemplate, ArrayList<String> toList) {
+    public boolean sendTokenOnAndroid(JmsMessagingTemplate jmsMessagingTemplate, List<String> toList) {
         try {
             if (IterUtil.isEmpty(toList)) {
                 return false;
@@ -587,7 +590,7 @@ public class PushMessage implements Serializable {
      * @param toList ios设备token
      * @return
      */
-    public boolean sendTokenOnIos(JmsMessagingTemplate jmsMessagingTemplate, ArrayList<String> toList) {
+    public boolean sendTokenOnIos(JmsMessagingTemplate jmsMessagingTemplate, List<String> toList) {
         try {
             if (IterUtil.isEmpty(toList)) {
                 return false;

+ 1 - 1
lift-push/src/main/java/cn/com/ty/lift/push/app/PushConsumer.java

@@ -33,7 +33,7 @@ public class PushConsumer {
         private Processor perform() {
             String title = pushMessage.getTitle();
             String content = pushMessage.getContent();
-            ArrayList<String> toList = pushMessage.getToList();
+            List<String> toList = pushMessage.getToList();
             switch (this.destination) {
                 case ValuePool.QUEUE_ANDROID_TOKEN:
                     result = xingePush.pushTokenOnAndroid(title, content, toList);

+ 15 - 14
lift-push/src/main/java/cn/com/ty/lift/push/app/XingePush.java

@@ -11,6 +11,7 @@ import lombok.extern.slf4j.Slf4j;
 import org.json.JSONObject;
 
 import java.util.ArrayList;
+import java.util.List;
 import java.util.Objects;
 
 /**
@@ -37,11 +38,11 @@ public class XingePush {
         xingeApp = new XingeApp(appId, secretKey);
     }
 
-    public boolean pushTokenOnAndroid(String title, String content, ArrayList<String> toList) {
+    public boolean pushTokenOnAndroid(String title, String content, List<String> toList) {
         return pushMessage(RequestBuilder.android(title, content, AudienceType.token.getType(), toList));
     }
 
-    public boolean pushAccountOnAndroid(String title, String content, ArrayList<String> toList) {
+    public boolean pushAccountOnAndroid(String title, String content, List<String> toList) {
         return pushMessage(RequestBuilder.android(title, content, AudienceType.account.getType(), toList));
     }
 
@@ -49,11 +50,11 @@ public class XingePush {
         return pushMessage(RequestBuilder.android(title, content));
     }
 
-    public boolean pushTokenOnIos(String title, String content, ArrayList<String> toList) {
+    public boolean pushTokenOnIos(String title, String content, List<String> toList) {
         return pushMessage(RequestBuilder.ios(title, content, AudienceType.token.getType(), toList));
     }
 
-    public boolean pushAccountOnIos(String title, String content, ArrayList<String> toList) {
+    public boolean pushAccountOnIos(String title, String content, List<String> toList) {
         return pushMessage(RequestBuilder.ios(title, content, AudienceType.account.getType(), toList));
     }
 
@@ -107,24 +108,24 @@ public class XingePush {
         /**
          * 消息标题
          */
-        private String            title;
+        private String       title;
         /**
          * 消息内容
          */
-        private String            content;
+        private String       content;
         /**
          * 消息推送的平台 1:android 2:ios
          */
-        private Integer           platform;
+        private Integer      platform;
         /**
          * 多种推送目标的,比如:全量、标签、单设备、设备列表、单账号、账号列表
          * 0 all 1 tag 2 token 3 token_list 4 account 5 account_list
          */
-        private int               audienceType;
+        private int          audienceType;
         /**
          * 发送的账号列表/token_list
          */
-        private ArrayList<String> toList;
+        private List<String> toList;
 
         private RequestBuilder(String title, String content, Integer platform, int audienceType){
             this.title = title;
@@ -132,7 +133,7 @@ public class XingePush {
             this.platform = platform;
             this.audienceType = audienceType;
         }
-        private RequestBuilder(String title, String content, Integer platform, int audienceType, ArrayList<String> toList){
+        private RequestBuilder(String title, String content, Integer platform, int audienceType, List<String> toList){
             this.title = title;
             this.content = content;
             this.platform = platform;
@@ -140,7 +141,7 @@ public class XingePush {
             this.toList = toList;
         }
 
-        public static RequestBuilder android(String title, String content, int audienceType, ArrayList<String> toList) {
+        public static RequestBuilder android(String title, String content, int audienceType, List<String> toList) {
             return new RequestBuilder(title, content, Platform.android.getType(), audienceType, toList);
         }
 
@@ -148,7 +149,7 @@ public class XingePush {
             return new RequestBuilder(title, content, Platform.android.getType(), AudienceType.all.getType());
         }
 
-        public static RequestBuilder ios(String title, String content, int audienceType, ArrayList<String> toList) {
+        public static RequestBuilder ios(String title, String content, int audienceType, List<String> toList) {
             return new RequestBuilder(title, content, Platform.ios.getType(), audienceType, toList);
         }
 
@@ -269,7 +270,7 @@ public class XingePush {
                     } else {
                         pushAppRequest.setAudience_type(AudienceType.token_list);
                     }
-                    pushAppRequest.setToken_list(toList);
+                    pushAppRequest.setToken_list(new ArrayList<>(toList));
                     return pushAppRequest;
                 } else if (this.audienceType == AudienceType.account.getType()) {
                     if (toList.size() == 1) {
@@ -277,7 +278,7 @@ public class XingePush {
                     } else {
                         pushAppRequest.setAudience_type(AudienceType.account_list);
                     }
-                    pushAppRequest.setAccount_list(toList);
+                    pushAppRequest.setAccount_list(new ArrayList<>(toList));
                     return pushAppRequest;
                 } else {
                     log.error("Failed to Create PushAppRequest: 'audienceType' is not Invalid. (0:all, 2:token, 4:account)");

+ 50 - 0
lift-push/src/main/resources/application-prod.yml

@@ -0,0 +1,50 @@
+spring:
+  datasource:
+    url: jdbc:mysql://rm-bp1qkwy173koi066x.mysql.rds.aliyuncs.com:3306/rdsliftmanager?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
+    username: tykj
+    password: Tdkg-13250409
+    driver-class-name: com.mysql.cj.jdbc.Driver
+
+  #redis缓存配置
+  redis:
+    database: 0 #数据库索引,默认为0
+    host: r-bp1j7odydtfqtprdvm.redis.rds.aliyuncs.com #(内网地址)服务器地址
+    port: 6379 #端口
+    password: Gdkc-290431 #验证密码
+    jedis:
+      pool:
+        max-active: 8 #最大连接数
+        max-idle: 8 #最大空闲链接
+        max-wait: 20000ms
+        min-idle: 0
+    timeout: 600000s
+  activemq:
+    #ActiveMQ通讯地址
+    broker-url: tcp://121.40.209.47:61616
+    #用户名
+    user: admin
+    #密码
+    password: admin
+    #true 表示使用内置的MQ,false则连接服务器: 消息持久化就必须spring.activemq.in-memory=false选项
+    in-memory: false
+    packages:
+      #信任所有的包: 如果直接发送对象消息,那么必须设置spring.activemq.packages.trust-all为true
+      trust-all: true
+    pool:
+      #true表示使用连接池;false时,每发送一条数据创建一个连接
+      enabled: true
+      #连接池最大连接数
+      max-connections: 30
+      #空闲的连接过期时间,默认为30秒
+      idle-timeout: 3000s
+  jms:
+    #如果是点对点(queue),那么此处默认应该是false,如果发布订阅,那么一定设置为true
+    pub-sub-domain: false
+
+#aliyun OSS服务配置信息,加载到SystemConfiguration
+aliyun:
+  oss:
+    endpoint: http://oss-cn-beijing.aliyuncs.com
+    bucketName: temp15827479607
+    accessKeyId: LTAI4FkSqFZa6LH9HqAsVott
+    accessKeySecret: w7GXuh5tf1hduQuZ2AzT3a4q14BI1i

lift-push/src/main/resources/application-web.yml → lift-push/src/main/resources/application-test.yml


+ 1 - 1
lift-push/src/main/resources/application.yml

@@ -5,7 +5,7 @@ spring:
   application:
     name: lift-push-service
   profiles:
-    active: web
+    active: test
   datasource:
     hikari:
       max-lifetime: 1200000 # default: 1800000