Ver código fonte

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

wanghaicheng 5 anos atrás
pai
commit
12f47062a2

+ 1 - 1
lift-business-service/src/main/java/cn/com/ty/lift/business/BusinessApplication.java

@@ -15,7 +15,7 @@ import org.springframework.web.bind.annotation.CrossOrigin;
  * @create 2019/11/4
  */
 @Slf4j
-@CrossOrigin
+//@CrossOrigin
 @EnableJms
 @EnableFeignClients
 @MapperScan("cn.com.ty.**.mapper")

+ 38 - 0
lift-business-service/src/main/java/cn/com/ty/lift/business/maintenance/controller/PropertyMaintenanceController.java

@@ -0,0 +1,38 @@
+package cn.com.ty.lift.business.maintenance.controller;
+
+import cn.com.ty.lift.business.maintenance.dao.entity.model.request.PropertyMtRequest;
+import cn.com.ty.lift.business.maintenance.dao.entity.model.response.PropertyMtResponse;
+import cn.com.ty.lift.business.maintenance.dao.mapper.MaintenancePlanMapper;
+import cn.com.ty.lift.business.maintenance.dao.mapper.MaintenanceRecordMapper;
+import cn.com.ty.lift.business.maintenance.dao.mapper.PropertyMaintenanceMapper;
+import cn.com.xwy.boot.web.dto.RestResponse;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import lombok.AllArgsConstructor;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+
+@RestController
+@AllArgsConstructor
+@RequestMapping("property")
+public class PropertyMaintenanceController {
+    private final MaintenancePlanMapper maintenancePlanMapper;
+    private final MaintenanceRecordMapper maintenanceRecordMapper;
+    private final PropertyMaintenanceMapper propertyMaintenanceMapper;
+
+    @PostMapping("maintenance")
+    public RestResponse maintenance(@RequestBody PropertyMtRequest propertyMtRequest) {
+        Page<PropertyMtResponse> propertyMtResponsePage = new Page<>(propertyMtRequest.getPageNum(), propertyMtRequest.getPageSize());
+        //todo
+        return RestResponse.success("待实现");
+    }
+
+    public Page<PropertyMtResponse> propertyMtResponsePage(Page<PropertyMtResponse> propertyMtResponsePage, PropertyMtRequest propertyMtRequest) {
+        Page<PropertyMtResponse> propertyMtResponses =
+                propertyMaintenanceMapper.queryMaintenance(propertyMtResponsePage, propertyMtRequest.getUserId());
+        return propertyMtResponses;
+    }
+}

+ 25 - 0
lift-business-service/src/main/java/cn/com/ty/lift/business/maintenance/dao/entity/model/request/PropertyMtRequest.java

@@ -0,0 +1,25 @@
+package cn.com.ty.lift.business.maintenance.dao.entity.model.request;
+
+import lombok.Data;
+
+@Data
+public class PropertyMtRequest {
+
+    /**
+     * 列表数据类型
+     * 1、待保养
+     * 2、保养中
+     * 3、已完成
+     * 4、计划超期
+     * 5、法规超期
+     */
+    private Integer type;
+
+    private Long userId;
+
+    /**
+     * 分页
+     */
+    private Long pageNum = 1L;
+    private Long pageSize = 10L;
+}

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

@@ -0,0 +1,16 @@
+package cn.com.ty.lift.business.maintenance.dao.entity.model.response;
+
+import lombok.Data;
+
+import java.time.LocalDateTime;
+
+@Data
+public class PropertyMtResponse {
+    private String projectName;
+    private String registrationCode;
+    private String devicePosition;
+    private Object liftType;
+    private Object category;
+    private String workerName;
+    private LocalDateTime planDate;
+}

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

@@ -0,0 +1,13 @@
+package cn.com.ty.lift.business.maintenance.dao.mapper;
+
+import cn.com.ty.lift.business.maintenance.dao.entity.model.response.PropertyMtResponse;
+import cn.com.ty.lift.common.constants.ApiConstants;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import org.apache.ibatis.annotations.Select;
+
+import java.util.List;
+
+public interface PropertyMaintenanceMapper {
+    @Select(ApiConstants.SQL.QUERY_MAINTENANCE)
+    Page<PropertyMtResponse> queryMaintenance(Page<PropertyMtResponse> page, Long userId);
+}

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

@@ -330,4 +330,33 @@ public class ApiConstants {
         Integer IOS = 2;
         Integer PC = 3;
     }
+
+    public interface Faq {
+        Integer TITLE_TYPE = 2;
+    }
+
+    public interface Maintenance {
+        Integer STATUS_UNFINISHED = 1;
+    }
+
+    public interface SQL {
+        String QUERY_MAINTENANCE = "select p.project_name projectName," +
+                "       l.registration_code registrationCode," +
+                "       l.device_position devicePosition," +
+                "       l.lift_type liftType," +
+                "       l.category category," +
+                "       ui.name workerName," +
+                "       mp.plan_date planDate," +
+                "       from maintenance_plan mp" +
+                "         left join lift l on mp.lift_id = l.id" +
+                "         left join project_lift_relevance plr" +
+                "                   on l.id = plr.lift_id" +
+                "                       and plr.project_id in (select project_id" +
+                "                                              from project_user" +
+                "                                              where user_id = #{userId})" +
+                "         left join project p on mp.project_id = p.id" +
+                "         left join user_info ui on ui.user_id = mp.worker_id" +
+                "        where DATE_FORMAT(mp.plan_date, '%Y%m') = DATE_FORMAT(CURDATE(), '%Y%m')" +
+                "  and mp.status = '1'";
+    }
 }

+ 30 - 6
lift-common/src/main/java/cn.com.ty.lift.common/model/PushMessage.java

@@ -24,11 +24,12 @@ public class PushMessage implements Serializable {
 
     private static final long serialVersionUID = 4125096758372084309L;
 
-    private String       title;
-    private String       content;
+    private String title;
+    private String content;
+    private Hashtable<Long,Integer> users = new Hashtable<>();
     private List<String> toList = new ArrayList<>();
     //the count of try again. Increase 1 for each failure, maximum times 100
-    private int          tryCount = 0;
+    private int tryCount = 0;
 
     private PushMessage() {
     }
@@ -38,7 +39,7 @@ public class PushMessage implements Serializable {
         this.content = content;
     }
 
-    public PushMessage add(String to){
+    public PushMessage add(String to) {
         this.toList.add(to);
         return this;
     }
@@ -538,7 +539,7 @@ public class PushMessage implements Serializable {
      */
     public boolean sendTokenOnPlatform(JmsMessagingTemplate jmsMessagingTemplate, List<PushUserInfo> pushUserInfos) {
         try {
-            if(IterUtil.isEmpty(pushUserInfos)){
+            if (IterUtil.isEmpty(pushUserInfos)) {
                 return false;
             }
             Set<String> toAndroid = new HashSet<>();
@@ -552,6 +553,7 @@ public class PushMessage implements Serializable {
                     }
                 }
             }
+            resetUsers(pushUserInfos);
             if (IterUtil.isNotEmpty(toAndroid)) {
                 this.setToList(new ArrayList<>(toAndroid));
                 jmsMessagingTemplate.send(ValuePool.PUSH_QUEUE_ANDROID_TOKEN, new GenericMessage<>(this));
@@ -573,9 +575,13 @@ public class PushMessage implements Serializable {
      */
     public boolean sendTokenOnPlatform(JmsMessagingTemplate jmsMessagingTemplate, PushUserInfo pushUserInfo) {
         try {
-            if (Objects.isNull(pushUserInfo) || !pushUserInfo.available()) {
+            if (Objects.isNull(pushUserInfo)) {
                 return false;
             }
+            if (!pushUserInfo.available()) {
+                return false;
+            }
+            resetUsers(pushUserInfo);
             this.add(pushUserInfo.getDeviceFlag());
             if (pushUserInfo.isAndroid()) {
                 jmsMessagingTemplate.send(ValuePool.PUSH_QUEUE_ANDROID_TOKEN, new GenericMessage<>(this));
@@ -595,6 +601,7 @@ public class PushMessage implements Serializable {
      * 同时推送android和ios全平台
      */
     public boolean sendAllOnPlatform(JmsMessagingTemplate jmsMessagingTemplate) {
+        users.clear();
         try {
             jmsMessagingTemplate.send(ValuePool.PUSH_QUEUE_ANDROID_ALL, new GenericMessage<>(this));
             jmsMessagingTemplate.send(ValuePool.PUSH_QUEUE_IOS_ALL, new GenericMessage<>(this));
@@ -604,4 +611,21 @@ public class PushMessage implements Serializable {
             return false;
         }
     }
+
+    /**
+     * 将用户id和设备类型传到消息中间件中,方便消息中心功能来保存
+     * @param pushUserInfos 用户信息列表
+     */
+    private void resetUsers(List<PushUserInfo> pushUserInfos) {
+        users.clear();
+        pushUserInfos.forEach(pushUserInfo -> users.put(pushUserInfo.getUserId(),pushUserInfo.getDeviceModel()));
+    }
+    /**
+     * 将用户id和设备类型传到消息中间件中,方便消息中心功能来保存
+     * @param pushUserInfo 用户信息列表
+     */
+    private void resetUsers(PushUserInfo pushUserInfo) {
+        users.clear();
+        users.put(pushUserInfo.getUserId(),pushUserInfo.getDeviceModel());
+    }
 }

+ 2 - 5
lift-enterprise-service/src/main/java/cn/com/ty/lift/enterprise/custom/service/impl/PropertyCompanyServiceImpl.java

@@ -115,7 +115,7 @@ public class PropertyCompanyServiceImpl extends ServiceImpl<PropertyCompanyMappe
         rows.add(CollUtil.newArrayList("甲方公司id", "名称", "通讯地址", "状态"));
         companies.forEach(company -> {
             List<?> row = CollUtil.newArrayList(
-                    company.getId()
+                    company.getId().toString()
                     , company.getName()
                     , null != company.getMailingAddress() ? company.getMailingAddress() : "无"
                     , company.getStatus() == 1 ? "无关联项目" : "有关联项目");
@@ -124,15 +124,12 @@ public class PropertyCompanyServiceImpl extends ServiceImpl<PropertyCompanyMappe
 
         ExcelWriter writer = ExcelUtil.getWriter(true);
         //设置列宽
-        writer.setColumnWidth(0, 25);
-        writer.setColumnWidth(1, 35);
-        writer.setColumnWidth(2, 40);
-        writer.setColumnWidth(3, 25);
 
         response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet;charset=utf-8");
         response.setHeader("Content-Disposition", "attachment;filename=" + LocalDate.now().toString() + ".xlsx");
         try (ServletOutputStream out = response.getOutputStream()) {
             writer.write(rows);
+            writer.autoSizeColumnAll();
             writer.flush(out, true);
             writer.close();
         } catch (IOException e) {

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

@@ -18,6 +18,7 @@ import org.springframework.stereotype.Component;
 
 import java.time.LocalDateTime;
 import java.util.ArrayList;
+import java.util.Hashtable;
 import java.util.List;
 
 /**
@@ -136,12 +137,10 @@ public class PushConsumer {
      * @param pushMessage 要推送的消息
      */
     private void saveMessage(PushMessage pushMessage) {
-        List<String> toList = pushMessage.getToList();
-        List<UserAccount> userAccounts = userAccountService.list(Wrappers.<UserAccount>query().in(!toList.isEmpty(), "device_flag", toList));
         List<TimeMessage> timeMessages = new ArrayList<>();
-        for (UserAccount userAccount : userAccounts) {
+        pushMessage.getUsers().forEach((k, v) -> {
             TimeMessage timeMessage = new TimeMessage();
-            timeMessage.setUserId(userAccount.getUserId());
+            timeMessage.setUserId(k);
             timeMessage.setContent(pushMessage.getContent());
             switch (pushMessage.getTitle()) {
                 case "团队消息":
@@ -157,12 +156,15 @@ public class PushConsumer {
                     timeMessage.setType(4);
                     break;
             }
-            timeMessage.setDeviceModel(userAccount.getDeviceModel());
+            timeMessage.setDeviceModel(v);
             timeMessage.setCreateUserId(10000L);
             timeMessage.setCreateTime(LocalDateTime.now());
             timeMessages.add(timeMessage);
-        }
+        });
         log.info("消息记录列表:" + timeMessages.toString());
-        timeMessageService.saveBatch(timeMessages);
+        if (!timeMessages.isEmpty()) {
+            log.info("消息不为空,保存消息到消息中心");
+            timeMessageService.saveBatch(timeMessages);
+        }
     }
 }

+ 1 - 1
lift-system-service/src/main/java/cn/com/ty/lift/system/faq/controller/FaqController.java

@@ -58,7 +58,7 @@ public class FaqController {
      */
     @PostMapping("/add")
     public RestResponse add(@RequestBody Faq faq) {
-        return RestResponse.success(faqService.save(faq));
+        return RestResponse.success(faqService.addFaq(faq));
     }
 
 

+ 13 - 0
lift-system-service/src/main/java/cn/com/ty/lift/system/faq/service/impl/FaqServiceImpl.java

@@ -1,5 +1,6 @@
 package cn.com.ty.lift.system.faq.service.impl;
 
+import cn.com.ty.lift.common.constants.ApiConstants;
 import cn.com.ty.lift.system.faq.dao.entity.Faq;
 import cn.com.ty.lift.system.faq.dao.mapper.FaqMapper;
 import cn.com.ty.lift.system.faq.service.FaqService;
@@ -7,6 +8,7 @@ import cn.com.xwy.boot.web.dto.RestResponse;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
 import java.util.List;
 import java.util.stream.Collectors;
@@ -69,4 +71,15 @@ public class FaqServiceImpl extends ServiceImpl<FaqMapper, Faq> implements FaqSe
             }
         }
     }
+
+    @Transactional(rollbackFor = Exception.class)
+    public boolean addFaq(Faq faq) {
+        this.save(faq);
+        if (faq.getType().equals(ApiConstants.Faq.TITLE_TYPE)) {
+            Faq answer = new Faq();
+            answer.setParentId(faq.getId());
+            this.save(answer);
+        }
+        return true;
+    }
 }