Browse Source

Merge branch 'develop' of http://132.232.206.88:3000/lift-manager/lift-server into wanghaicheng

wanghaicheng 5 years ago
parent
commit
91e5536b0f

+ 1 - 2
lift-business-service/src/main/java/cn/com/ty/lift/business/annualinspection/service/AnnualInspectionService.java

@@ -16,7 +16,6 @@ import cn.com.ty.lift.business.maintenance.service.MaintenancePlanService;
 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.util.StrUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.IdWorker;
@@ -201,7 +200,7 @@ public class AnnualInspectionService extends ServiceImpl<AnnualInspectionMapper,
         liftHistory.setLiftId(liftId);
         liftHistory.setCode(lift.getLiftCode());
         liftHistory.setDescription("修改电梯年检日期");
-        liftHistory.setContent(StrUtil.format("电梯年检日期由:{}修改成{}", oldInspectionDate, nextInspectionTime));
+        liftHistory.setContent(String.format("电梯年检日期由:%tF %tT修改成%tF %tT", oldInspectionDate, oldInspectionDate, nextInspectionTime, nextInspectionTime));
         //fixme:获取当前登录用户
         liftHistory.setOperatorId(entity.getUpdateId());
         liftHistory.setOperateDate(LocalDateTime.now());

+ 3 - 3
lift-business-service/src/main/java/cn/com/ty/lift/business/emergency/dto/RepairRequest.java

@@ -108,9 +108,9 @@ public class RepairRequest extends PageRequest {
     private LocalDateTime stopDate;
 
     /**
-     * 签到位置
+     * 位置信息
      */
-    @NotBlank(message = "缺少签到位置")
+    @NotBlank(message = "缺少位置信息")
     private String position;
 
     /**
@@ -166,7 +166,7 @@ public class RepairRequest extends PageRequest {
     /**
      * 故障性质
      */
-    @NotEmpty(message = "缺少故障性质")
+    @NotBlank(message = "缺少故障性质")
     private String faultNature;
     /**
      * 故障责任

+ 14 - 9
lift-business-service/src/main/java/cn/com/ty/lift/business/project/dao/entity/Region.java

@@ -1,5 +1,6 @@
 package cn.com.ty.lift.business.project.dao.entity;
 
+import cn.hutool.core.util.StrUtil;
 import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableId;
 import lombok.Data;
@@ -71,22 +72,26 @@ public class Region implements Serializable {
     /**
      * 拆分解析文员的id
      */
-    public List<Long> splitClerk(){
-        if(Objects.isNull(clerk)){
-            return Collections.emptyList();
+    public Set<Long> splitClerk(){
+        if(StrUtil.isBlank(clerk)){
+            return Collections.emptySet();
         }
-        if(clerk.contains(",")){
-            return Arrays.stream(clerk.split(",")).map(c -> Long.parseLong(c.trim())).collect(Collectors.toList());
-        }else{
-            return Arrays.asList(Long.parseLong(clerk.trim()));
+        try {
+            if(clerk.contains(",")){
+                return Arrays.stream(clerk.split(",")).map(c -> Long.parseLong(c.trim())).collect(Collectors.toSet());
+            }else{
+                return new HashSet<>(Arrays.asList(Long.parseLong(clerk.trim())));
+            }
+        }catch (Exception e){
+            return Collections.emptySet();
         }
     }
 
     /**
      * 返回区域主管和文员的id列表
      */
-    public List<Long> members(){
-        List<Long> members = new ArrayList<>();
+    public Set<Long> members(){
+        Set<Long> members = new HashSet<>();
         members.add(userId);
         members.addAll(splitClerk());
         return members;

+ 9 - 13
lift-business-service/src/main/java/cn/com/ty/lift/business/push/PushUserService.java

@@ -84,35 +84,31 @@ public class PushUserService extends BaseServiceImpl<PushUserMapper, PushUserInf
     }
     /**
      * 查询公司下总经理
-     * @param mtCompanyId
-     * @return
      */
     public List<PushUserInfo> listHighDirector(Long mtCompanyId){
         return baseMapper.listByRoleCode(mtCompanyId, CommonEnum.DefaultRole.HIGH_DIRECTOR.getCode());
     }
     /**
      * 查询公司下管理员
-     * @param mtCompanyId
-     * @return
      */
     public List<PushUserInfo> listEnterpriseAdmin(Long mtCompanyId){
         return baseMapper.listByRoleCode(mtCompanyId, CommonEnum.DefaultRole.ENTERPRISE_ADMIN.getCode());
     }
-
-    public List<PushUserInfo> listByEmergencyRepair(Long repairId, Long mtCompanyId, List<String> roleCodes){
-        return baseMapper.listByEmergencyRepair(repairId, mtCompanyId, roleCodes);
-    }
+    /**
+     * 根据急修id和维保公司id查询region
+     */
     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);
-    }
+    /**
+     * 根据年检id和维保公司id查询region
+     */
     public Region findRegionByAnnualInspection(Long inspectionId, Long mtCompanyId){
         return baseMapper.findRegionByAnnualInspection(inspectionId, mtCompanyId);
     }
-
+    /**
+     * 根据项目id和维保公司id查询region
+     */
     public Region findRegionByProject(Long projectId, Long mtCompanyId){
         return baseMapper.findRegionByProject(projectId, mtCompanyId);
     }

+ 4 - 4
lift-business-service/src/main/resources/mapper/project/ProjectUserMapper.xml

@@ -42,11 +42,11 @@
 		FROM project_user pu
 			 LEFT JOIN user_info ui ON pu.user_id = ui.user_id
 		WHERE 1=1
-		<if test="id!=null and id!=''">
-			AND project_id = #{id,jdbcType=BIGINT}
+		<if test="request.id!=null and request.id!=''">
+			AND project_id = #{request.id,jdbcType=BIGINT}
 		</if>
-		<if test="mtCompanyId!=null and mtCompanyId!=''">
-			AND mt_company_id = #{mtCompanyId,jdbcType=BIGINT}
+		<if test="request.mtCompanyId!=null and request.mtCompanyId!=''">
+			AND mt_company_id = #{request.mtCompanyId,jdbcType=BIGINT}
 		</if>
 	</select>
 

+ 11 - 75
lift-business-service/src/main/resources/mapper/push/PushUserMapper.xml

@@ -89,17 +89,17 @@
 
     <select id="listByRoleCode" resultMap="BaseResultMap">
         SELECT
-        ui.user_id,
-        ui.NAME AS username,
-        ua.mobile,
-        ua.device_model,
-        ua.device_flag,
-        ro.NAME AS role_name
+            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
+            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}
@@ -127,71 +127,6 @@
         </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,
@@ -209,6 +144,7 @@
             </if>
         </where>
     </select>
+
     <select id="findRegionByProject" resultType="cn.com.ty.lift.business.project.dao.entity.Region">
         SELECT
             re.user_id,

+ 20 - 59
lift-common/src/main/java/cn.com.ty.lift.common/model/PushMessage.java

@@ -2,6 +2,7 @@ package cn.com.ty.lift.common.model;
 
 import cn.com.ty.lift.common.utils.ValuePool;
 import cn.hutool.core.collection.IterUtil;
+import cn.hutool.core.util.StrUtil;
 import lombok.Data;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.jms.core.JmsMessagingTemplate;
@@ -10,11 +11,7 @@ import org.springframework.messaging.support.GenericMessage;
 import java.io.Serializable;
 import java.time.LocalDate;
 import java.time.LocalDateTime;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.stream.Collectors;
+import java.util.*;
 
 /**
  * 推送消息
@@ -537,21 +534,25 @@ public class PushMessage implements Serializable {
             if(IterUtil.isEmpty(pushUserInfos)){
                 return false;
             }
-            Map<Integer, List<PushUserInfo>> collect = pushUserInfos.stream().collect(Collectors.groupingBy(PushUserInfo::getDeviceModel));
-            List<PushUserInfo> pushAndroids = collect.get(1);
-            List<PushUserInfo> pushIos = collect.get(2);
-            if(IterUtil.isNotEmpty(pushAndroids)){
-                List<String> toAndroid = pushAndroids.stream().map(PushUserInfo::getDeviceFlag).filter(Objects::nonNull).distinct().collect(Collectors.toList());
-                if (IterUtil.isNotEmpty(toAndroid)) {
-                    this.setToList(toAndroid);
-                    jmsMessagingTemplate.send(ValuePool.QUEUE_ANDROID_TOKEN, new GenericMessage<>(this));
-                }
-            }else if (IterUtil.isNotEmpty(pushIos)) {
-                List<String> toIos = pushIos.stream().map(PushUserInfo::getDeviceFlag).filter(Objects::nonNull).distinct().collect(Collectors.toList());
-                if(IterUtil.isNotEmpty(toIos)){
-                    this.setToList(toIos);
-                    jmsMessagingTemplate.send(ValuePool.QUEUE_IOS_TOKEN, new GenericMessage<>(this));
+            Set<String> toAndroid = new HashSet<>();
+            Set<String> toIos = new HashSet<>();
+            for (PushUserInfo pushUserInfo : pushUserInfos) {
+                Integer deviceModel = pushUserInfo.getDeviceModel();
+                String deviceFlag = pushUserInfo.getDeviceFlag();
+                if (Objects.nonNull(deviceModel) && StrUtil.isNotBlank(deviceFlag)) {
+                    if (1 == deviceModel) {
+                        toAndroid.add(deviceFlag);
+                    } else if (2 == deviceModel) {
+                        toIos.add(deviceFlag);
+                    }
                 }
+            }
+            if (IterUtil.isNotEmpty(toAndroid)) {
+                this.setToList(new ArrayList<>(toAndroid));
+                jmsMessagingTemplate.send(ValuePool.QUEUE_ANDROID_TOKEN, new GenericMessage<>(this));
+            } else if (IterUtil.isNotEmpty(toIos)) {
+                this.setToList(new ArrayList<>(toIos));
+                jmsMessagingTemplate.send(ValuePool.QUEUE_IOS_TOKEN, new GenericMessage<>(this));
             } else {
                 return false;
             }
@@ -577,44 +578,4 @@ public class PushMessage implements Serializable {
             return false;
         }
     }
-
-    /**
-     * 只推送到android平台的指定设备token
-     *
-     * @param jmsMessagingTemplate jms
-     * @param toList               推到安卓平台的设备token
-     */
-    public boolean sendTokenOnAndroid(JmsMessagingTemplate jmsMessagingTemplate, List<String> toList) {
-        try {
-            if (IterUtil.isEmpty(toList)) {
-                return false;
-            }
-            this.setToList(toList.stream().filter(Objects::nonNull).distinct().collect(Collectors.toList()));
-            jmsMessagingTemplate.send(ValuePool.QUEUE_ANDROID_TOKEN, new GenericMessage<>(this));
-            return true;
-        } catch (Exception e) {
-            log.error("Failed to Send pushMessage to ANDROID_TOKEN Message Queue: ", e);
-            return false;
-        }
-    }
-
-    /**
-     * 只推送到ios的指定设备token
-     * @param jmsMessagingTemplate
-     * @param toList ios设备token
-     * @return
-     */
-    public boolean sendTokenOnIos(JmsMessagingTemplate jmsMessagingTemplate, List<String> toList) {
-        try {
-            if (IterUtil.isEmpty(toList)) {
-                return false;
-            }
-            this.setToList(toList.stream().filter(Objects::nonNull).distinct().collect(Collectors.toList()));
-            jmsMessagingTemplate.send(ValuePool.QUEUE_IOS_TOKEN, new GenericMessage<>(this));
-            return true;
-        } catch (Exception e) {
-            log.error("Failed to Send pushMessage to IOS_TOKEN Message Queue: ", e);
-            return false;
-        }
-    }
 }

+ 21 - 60
lift-common/src/main/java/cn.com.ty.lift.common/verify/VerifyProcessor.java

@@ -181,45 +181,6 @@ public class VerifyProcessor {
     private static boolean notBlank(String value) {
         return null != value && !value.trim().isEmpty();
     }
-    /**
-     * verify the int value is greater than zero.
-     *
-     * @param value any int value.
-     * @return if return {@code true}, the value is greater than zero, otherwise no.
-     */
-    private static boolean gt0(int value) {
-        return value > 0;
-    }
-
-    /**
-     * verify the int value is less than zero.
-     *
-     * @param value any int value.
-     * @return if return {@code true}, the value is less than zero, otherwise no
-     */
-    private static boolean lt0(int value) {
-        return value < 0;
-    }
-
-    /**
-     * verify the int value is greater than zero or equal to zero.
-     *
-     * @param value any int value.
-     * @return if return {@code true}, the value is greater than zero or equal to zero, otherwise no
-     */
-    private static boolean gte0(int value) {
-        return value >= 0;
-    }
-
-    /**
-     * verify the int value is less than zero or equal to zero.
-     *
-     * @param value any int value.
-     * @return if return {@code true}, the value is less than zero or equal to zero, otherwise no
-     */
-    private static boolean lte0(int value) {
-        return value <= 0;
-    }
 
     /**
      * verify the value is instance of the Number.
@@ -733,9 +694,9 @@ public class VerifyProcessor {
             final boolean inclusive = annotation.inclusive();
             //inclusive ? comparisonResult <= 0 : comparisonResult < 0;
             if (inclusive) {
-                return lte0(compare);
+                return compare <= 0;
             } else {
-                return lt0(compare);
+                return compare < 0;
             }
         }
 
@@ -782,9 +743,9 @@ public class VerifyProcessor {
             final boolean inclusive = annotation.inclusive();
             //inclusive ? comparisonResult >= 0 : comparisonResult > 0;
             if (inclusive) {
-                return gte0(compare);
+                return compare >= 0;
             } else {
-                return gt0(compare);
+                return compare > 0;
             }
         }
 
@@ -809,7 +770,7 @@ public class VerifyProcessor {
                 return false;
             }
             // length > 0
-            return gt0(length);
+            return length > 0;
         }
 
         /**
@@ -838,11 +799,11 @@ public class VerifyProcessor {
             if (Objects.isNull(value)) {
                 return false;
             }
-            if (lt0(min)) {
+            if (min < 0) {
                 setIllegalArgMessage("The min (%s) parameter of @Size cannot be negative.", min);
                 return false;
             }
-            if (lt0(max)) {
+            if (max < 0) {
                 setIllegalArgMessage("The max (%s) parameter of @Size cannot be negative.", max);
                 return false;
             }
@@ -891,11 +852,11 @@ public class VerifyProcessor {
                 setIllegalArgMessage("The @Digits only supports Number & CharSequence.");
                 return false;
             }
-            if (lt0(maxInteger)) {
+            if (maxInteger < 0) {
                 setIllegalArgMessage("The length of the integer '%s' part of @Digits cannot be negative.", maxInteger);
                 return false;
             }
-            if (lt0(maxFraction)) {
+            if (maxFraction < 0) {
                 setIllegalArgMessage("The length of the fraction '%s' part of @Digits cannot be negative.", maxFraction);
                 return false;
             }
@@ -941,7 +902,7 @@ public class VerifyProcessor {
                 setIllegalArgMessage("The @NotBlank only supports CharSequence.");
                 return false;
             }
-            return ((CharSequence) value).toString().trim().isEmpty();
+            return ((CharSequence) value).toString().trim().length() > 0;
         }
 
         /**
@@ -972,7 +933,7 @@ public class VerifyProcessor {
             // cannot split email string at @ as it can be a part of quoted local part of email.
             // so we need to split at a position of last @ present in the string:
             int splitPosition = val.lastIndexOf('@');
-            if (lt0(splitPosition)) {
+            if (splitPosition < 0) {
                 return false;
             }
             String localPart = val.substring(0, splitPosition);
@@ -1110,7 +1071,7 @@ public class VerifyProcessor {
                 compare = val.compareTo(BigDecimal.valueOf(max));
             }
             //compare <= 0
-            return lte0(compare);
+            return compare <= 0;
         }
 
         /**
@@ -1150,7 +1111,7 @@ public class VerifyProcessor {
                 compare = val.compareTo(BigDecimal.valueOf(min));
             }
             //compare >= 0
-            return gte0(compare);
+            return compare >= 0;
         }
 
         /**
@@ -1173,7 +1134,7 @@ public class VerifyProcessor {
                 return false;
             }
 
-            return lt0(signum((Number) value, GREATER_THAN));
+            return signum((Number) value, GREATER_THAN) < 0;
         }
 
         /**
@@ -1194,7 +1155,7 @@ public class VerifyProcessor {
                 return false;
             }
 
-            return lte0(signum((Number) value, GREATER_THAN));
+            return signum((Number) value, GREATER_THAN) <= 0;
         }
 
         /**
@@ -1215,7 +1176,7 @@ public class VerifyProcessor {
                 return false;
             }
 
-            return gt0(signum((Number) value, LESS_THAN));
+            return signum((Number) value, LESS_THAN) > 0;
         }
 
         /**
@@ -1236,7 +1197,7 @@ public class VerifyProcessor {
                 return false;
             }
 
-            return gte0(signum((Number) value, LESS_THAN));
+            return signum((Number) value, LESS_THAN) >= 0;
         }
 
         /**
@@ -1320,7 +1281,7 @@ public class VerifyProcessor {
                 return false;
             }
             //compare > 0
-            return gt0(compare);
+            return compare > 0;
         }
 
         /**
@@ -1350,7 +1311,7 @@ public class VerifyProcessor {
                 return false;
             }
             //compare >= 0
-            return gte0(compare);
+            return compare >= 0;
         }
 
         /**
@@ -1380,7 +1341,7 @@ public class VerifyProcessor {
                 return false;
             }
             //compare < 0
-            return lt0(compare);
+            return compare < 0;
         }
 
         /**
@@ -1410,7 +1371,7 @@ public class VerifyProcessor {
                 return false;
             }
             //compare <= 0
-            return lte0(compare);
+            return compare <= 0;
         }
 
         /**