Procházet zdrojové kódy

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

黄远 před 5 roky
rodič
revize
9c5804fbe2
16 změnil soubory, kde provedl 398 přidání a 25 odebrání
  1. 14 0
      lift-business-service/pom.xml
  2. 244 0
      lift-business-service/src/main/java/cn/com/ty/lift/business/ImageUtil.java
  3. 25 2
      lift-business-service/src/main/java/cn/com/ty/lift/business/common/CommonController.java
  4. 17 6
      lift-business-service/src/main/java/cn/com/ty/lift/business/maintenance/controller/PropertyMaintenanceController.java
  5. 11 0
      lift-business-service/src/main/java/cn/com/ty/lift/business/maintenance/dao/entity/model/request/PropertyVo.java
  6. 9 0
      lift-business-service/src/main/java/cn/com/ty/lift/business/maintenance/dao/entity/model/response/PropertyEvaluateAuthResponse.java
  7. 1 0
      lift-business-service/src/main/java/cn/com/ty/lift/business/maintenance/dao/entity/model/response/PropertyMtResponse.java
  8. 10 0
      lift-business-service/src/main/java/cn/com/ty/lift/business/maintenance/dao/entity/model/response/PropertyProjectListResponse.java
  9. 10 2
      lift-business-service/src/main/java/cn/com/ty/lift/business/maintenance/dao/mapper/PropertyMaintenanceMapper.java
  10. 27 1
      lift-business-service/src/main/java/cn/com/ty/lift/business/maintenance/service/PropertyMaintenanceService.java
  11. 2 2
      lift-business-service/src/main/resources/mapper/contract/PaymentHistoryMapper.xml
  12. 5 0
      lift-common/src/main/java/cn.com.ty.lift.common/constants/ApiConstants.java
  13. 17 1
      lift-common/src/main/java/cn.com.ty.lift.common/constants/SqlConstants.java
  14. 1 1
      lift-enterprise-service/src/main/java/cn/com/ty/lift/enterprise/option/controller/MaintenanceOptionController.java
  15. 1 1
      lift-enterprise-service/src/main/java/cn/com/ty/lift/enterprise/option/dao/entity/MaintenanceOption.java
  16. 4 9
      lift-enterprise-service/src/main/java/cn/com/ty/lift/enterprise/region/service/impl/RegionServiceImpl.java

+ 14 - 0
lift-business-service/pom.xml

@@ -24,6 +24,20 @@
             <artifactId>lift-common</artifactId>
             <version>1.0-SNAPSHOT</version>
         </dependency>
+        <dependency>
+            <groupId>com.ning</groupId>
+            <artifactId>async-http-client</artifactId>
+            <version>1.9.32</version>
+        </dependency>
+        <dependency>
+            <groupId>commons-lang</groupId>
+            <artifactId>commons-lang</artifactId>
+            <version>2.6</version>
+        </dependency>
+        <dependency>
+            <groupId>commons-fileupload</groupId>
+            <artifactId>commons-fileupload</artifactId>
+        </dependency>
         <!--<dependency>
             <groupId>cn.com.xwy</groupId>
             <artifactId>xwy-cloud-dependencies</artifactId>

+ 244 - 0
lift-business-service/src/main/java/cn/com/ty/lift/business/ImageUtil.java

@@ -0,0 +1,244 @@
+package cn.com.ty.lift.business;
+
+import org.apache.commons.fileupload.FileItem;
+import org.apache.commons.fileupload.FileItemFactory;
+import org.apache.commons.fileupload.disk.DiskFileItemFactory;
+import org.apache.commons.lang.StringUtils;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.imageio.ImageIO;
+import java.awt.*;
+import java.awt.image.BufferedImage;
+import java.io.*;
+import java.net.URL;
+import java.net.URLConnection;
+
+/**
+ * @author 张凡
+ * @create 2020-05-20 22:06
+ **/
+public class ImageUtil {
+    /**
+     * 给图片+图片水印
+     *
+     * @param sourceUrl --sourceUrl 源图片网络地址
+     * @param sourceFile   --sourceFile 源图片文件
+     * @param pressImg  -- 水印图片地址
+     * @param targetImg -- 目标图片地址
+     * @param location  水印位置:left-top:左上角,right-top:右上角,left-bottom:左下角,right-bottom:右下角
+     * @param degree    水印旋转角度
+     */
+
+    public static void pressImage(String sourceUrl, MultipartFile sourceFile, String pressImg, String targetImg, String location, Integer degree) {
+        try {
+            // 目标文件
+            File _file = toFile(sourceUrl, null, sourceFile, new File(targetImg));
+            Image src = ImageIO.read(_file);
+            int width = src.getWidth(null);
+            int height = src.getHeight(null);
+            BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
+            Graphics2D g = image.createGraphics();
+            g.drawImage(src, 0, 0, width, height, null);
+            // 水印文件
+            File _filebiao = new File(pressImg);
+            Image src_biao = ImageIO.read(_filebiao);
+            int width_biao = src_biao.getWidth(null);
+            int height_biao = src_biao.getHeight(null);
+            // 水印坐标
+            int x = 0, y = 0;
+            if (StringUtils.equals(location, "left-top")) {
+                x += 30;
+                y += 30;
+            } else if (StringUtils.equals(location, "right-top")) {
+                x = width - width_biao - 30;
+                y += 30;
+            } else if (StringUtils.equals(location, "left-bottom")) {
+                y = height - height_biao - 30;
+                x += 30;
+            } else if (StringUtils.equals(location, "right-bottom")) {
+                x = width - width_biao - 30;
+                y = height - height_biao - 30;
+            } else {
+                x = (width - width_biao) / 2;
+                y = (height - height_biao) / 2;
+            }
+            if (null != degree) {
+                // 设置水印旋转
+                g.rotate(Math.toRadians(degree), x, y);
+            }
+            g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
+            g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
+            g.drawImage(src_biao, x, y, width_biao, height_biao, null);
+            // 水印文件结束
+            g.dispose();
+            //直接修改源文件
+            FileOutputStream out = new FileOutputStream(targetImg);
+            // JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
+            // encoder.encode(image);
+
+            ImageIO.write(image, "jpg", out);
+            out.flush();
+            out.close();
+            //生成新的文件
+            //File sf = new File("D:/imgout/" + "test" + "." + "jpg");
+            //ImageIO.write(image, "jpg", sf); // 保存图片
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    /**
+     * 给图片加文字水印
+     *
+     * @param sourceUrl 图片的网络地址
+     * @param pressText s水印文字
+     * @param targetImg 目标文件
+     * @param fontName  字体名称
+     * @param fontStyle 字体风格
+     * @param fontSize  字体大小
+     * @param location  字体位置:left-top:左上角,right-top:右上角,left-bottom:左下角,right-bottom:右下角
+     */
+    public static void pressText(String sourceUrl, String pressText, String targetImg, String fontName, int fontStyle,
+                                 int fontSize, String location, Color color) {
+        try {
+
+            int textWidth = getFontWidth(fontName, fontStyle, fontSize, pressText);
+            File _file = toFile(null, sourceUrl, null, new File(targetImg));
+            Image src = ImageIO.read(_file);
+            int width = src.getWidth(null);
+            int height = src.getHeight(null);
+            BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
+            Graphics2D g = image.createGraphics();
+            g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
+            g.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
+            g.drawImage(src.getScaledInstance(width, height, Image.SCALE_SMOOTH), 0, 0, null);
+            g.setColor(color);
+            g.setFont(new Font(fontName, fontStyle, fontSize));
+            g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_ATOP,
+                    0.45f));
+            int x = 0, y = 0;
+            if (StringUtils.equals(location, "left-top")) {
+                x = 30;
+                y = 30;
+            } else if (StringUtils.equals(location, "right-top")) {
+                x = width - textWidth - 30;
+                y = 30;
+            } else if (StringUtils.equals(location, "left-bottom")) {
+                x += 30;
+                y = height - 30;
+            } else if (StringUtils.equals(location, "right-bottom")) {
+                x = width - textWidth - 30;
+                y = height - 30;
+            } else {
+                x = (width - textWidth) / 2;
+                y = (height) / 2;
+            }
+            g.drawString(pressText, x, y);
+            g.dispose();
+            FileOutputStream out = new FileOutputStream(targetImg);
+            //JPEGImageEncoder encoder = JPEGCodec.createJPEGEncoder(out);
+            //encoder.encode(image);
+            ImageIO.write(image, "jpg", out);
+            out.flush();
+            out.close();
+
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+
+
+    }
+
+
+    /**
+     * 文件保存
+     *
+     * @param link 图片链接
+     * @param img  图片临时地址
+     * @param file 存入的文件地址
+     * @return 下载的文件
+     */
+    public static File toFile(String link, String img, MultipartFile imgFile, File file) {
+        try {
+            InputStream ins = null;
+            if (StringUtils.isNotEmpty(link)) {
+                URL url = new URL(link);
+                URLConnection uri = url.openConnection();
+                ins = uri.getInputStream();
+            }
+            if (StringUtils.isNotEmpty(img)) {
+                File nl = new File(img);
+                ins = new FileInputStream(nl);
+            }
+            if (img != null) {
+                ins = imgFile.getInputStream();
+            }
+            //获取数据流
+            OutputStream os = new FileOutputStream(file);
+            int bytesRead = 0;
+            byte[] buffer = new byte[8192];
+            while ((bytesRead = ins.read(buffer, 0, 8192)) != -1) {
+                os.write(buffer, 0, bytesRead);
+            }
+            os.close();
+            ins.close();
+            return file;
+        } catch (Exception e) {
+            return null;
+        }
+
+    }
+
+    /**
+     * 计算文本占用的width
+     *
+     * @param fontName  字体名称
+     * @param fontStyle 字体风格
+     * @param fontSize  字体大小
+     * @param pressText 输入文本
+     * @return 文字所占用的宽带
+     */
+    public static int getFontWidth(String fontName, int fontStyle, int fontSize, String pressText) {
+        Font f = new Font(fontName, fontStyle, fontSize);
+        FontMetrics fm = sun.font.FontDesignMetrics.getMetrics(f);
+        return fm.stringWidth(pressText);
+    }
+
+    /*
+        创建FileItem
+         */
+    public static FileItem createFileItem(File file, String fieldName) {
+        FileItemFactory factory = new DiskFileItemFactory(16, null);
+        FileItem item = factory.createItem(fieldName, "text/plain", true, file.getName());
+        int bytesRead = 0;
+        byte[] buffer = new byte[8192];
+        try {
+            FileInputStream fis = new FileInputStream(file);
+            OutputStream os = item.getOutputStream();
+            while ((bytesRead = fis.read(buffer, 0, 8192)) != -1) {
+                os.write(buffer, 0, bytesRead);
+            }
+            os.close();
+            fis.close();
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        return item;
+    }
+
+
+    public static void main(String[] args) {
+        pressImage("https://ty-oss-file.oss-cn-hangzhou.aliyuncs.com/banner/banner3.png",null, "D:/项目中心/电梯/水印.png", "D:/项目中心/电梯/微信图片_20200520211441.png", "right-bottom", null);//
+        //pressImage("D:/imgin/20181017110944.png", "D:/imgout/1.png", "right-top", null);
+        //        //pressImage("D:/imgin/20181017110944.png", "D:/imgout/1.png", "center", null);
+        //        //pressImage("D:/imgin/20181017110944.png", "D:/imgout/1.png", "left-bottom", null);
+        //        //pressImage("D:/imgin/20181017110944.png", "D:/imgout/1.png", "right-bottom", null);
+        pressText("D:/项目中心/电梯/微信图片_20200520211441.png", "2020-05-20", "D:/项目中心/电梯/微信图片_20200520211442.png", "黑体", Font.BOLD + Font.ITALIC, 30, "left-bottom", Color.GRAY);
+        //        //getFontWidth("黑体", Font.BOLD + Font.ITALIC, 30, "miraclesgrocery");
+        //        //System.out.println(Color.RED);
+        //        //System.out.println(Color.WHITE);
+        //        //System.out.println(Color.GRAY);
+    }
+
+
+}

+ 25 - 2
lift-business-service/src/main/java/cn/com/ty/lift/business/common/CommonController.java

@@ -1,5 +1,6 @@
 package cn.com.ty.lift.business.common;
 
+import cn.com.ty.lift.business.ImageUtil;
 import cn.com.ty.lift.business.annualinspection.service.AnnualInspectionService;
 import cn.com.ty.lift.business.capital.service.CapitalRepairLiftRelevanceService;
 import cn.com.ty.lift.business.emergency.service.EmergencyRepairService;
@@ -15,19 +16,25 @@ import cn.com.ty.lift.common.verify.Validate;
 import cn.com.ty.lift.common.verify.Validation;
 import cn.com.ty.lift.common.verify.Val;
 import cn.com.xwy.boot.web.dto.RestResponse;
+import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.util.ArrayUtil;
 import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.core.util.StrUtil;
 import com.baomidou.mybatisplus.core.toolkit.IdWorker;
 import lombok.AllArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.fileupload.FileItem;
 import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
+import org.springframework.web.multipart.commons.CommonsMultipartFile;
 
+import java.awt.*;
+import java.io.File;
 import java.time.LocalDate;
 import java.time.format.DateTimeFormatter;
 import java.util.*;
+import java.util.List;
 
 /**
  * @author bieao
@@ -89,7 +96,15 @@ public class CommonController {
         Map<String, MultipartFile> fileMap = new LinkedHashMap<>();
         //1 先解析文件格式
         for (MultipartFile file : files) {
-            String fileName = handleFile(file);
+            String currentTime = DateUtil.formatDateTime(new Date());
+            //上传图片加图片水印
+            ImageUtil.pressImage(null, file, "/home/ying/server/lift-business/tmp/watermark.png", "/home/ying/server/lift-business/tmp/imgBack.png", "right-bottom", null);
+            //上传图片加文字水印
+            ImageUtil.pressText("/home/ying/server/lift-business/tmp/imgBack.png", currentTime, "/home/ying/server/lift-business/tmp/imgBack.png", "黑体", Font.BOLD + Font.ITALIC, 30, "left-bottom", Color.GRAY);
+            File downloadFile = new File("/home/ying/server/lift-business/tmp/imgBack.png");
+            FileItem fileItem = ImageUtil.createFileItem(downloadFile, downloadFile.getName());
+            MultipartFile mfile = new CommonsMultipartFile(fileItem);
+            String fileName = handleFile(mfile);
             fileMap.put(fileName, file);
         }
         //2 批量上传
@@ -117,7 +132,15 @@ public class CommonController {
     @PostMapping("upload")
     public RestResponse upload(@RequestParam("file") MultipartFile file) {
         Validate.notTrue(Objects.isNull(file) || file.isEmpty(), ValuePool.UPLOAD_DATA_MISSING);
-        String fileName = handleFile(file);
+        String currentTime = DateUtil.formatDateTime(new Date());
+        //上传图片加图片水印
+        ImageUtil.pressImage(null, file, "/home/ying/server/lift-business/tmp/watermark.png", "/home/ying/server/lift-business/tmp/imgBack.png", "right-bottom", null);
+        //上传图片加文字水印
+        ImageUtil.pressText("/home/ying/server/lift-business/tmp/imgBack.png", currentTime, "/home/ying/server/lift-business/tmp/imgBack.png", "黑体", Font.BOLD + Font.ITALIC, 30, "left-bottom", Color.GRAY);
+        File downloadFile = new File("/home/ying/server/lift-business/tmp/imgBack.png");
+        FileItem fileItem = ImageUtil.createFileItem(downloadFile, downloadFile.getName());
+        MultipartFile mfile = new CommonsMultipartFile(fileItem);
+        String fileName = handleFile(mfile);
         try {
             String url = systemConfiguration.build().putObject(fileName, file.getBytes());
             log.info("upload file complete, file URL: {}", url);

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

@@ -1,9 +1,10 @@
 package cn.com.ty.lift.business.maintenance.controller;
 
 import cn.com.ty.lift.business.maintenance.dao.entity.model.request.PropertyMaintenanceVO;
+import cn.com.ty.lift.business.maintenance.dao.entity.model.request.PropertyVo;
 import cn.com.ty.lift.business.maintenance.dao.entity.model.response.DynamicMessageResponse;
 import cn.com.ty.lift.business.maintenance.dao.entity.model.response.PropertyMtResponse;
-import cn.com.ty.lift.business.maintenance.service.PropertyMaintenanceService;
+import cn.com.ty.lift.business.maintenance.service.PropertyService;
 import cn.com.xwy.boot.web.dto.RestResponse;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -17,28 +18,38 @@ import org.springframework.web.bind.annotation.RestController;
 @AllArgsConstructor
 @RequestMapping("property")
 public class PropertyMaintenanceController {
-    private final PropertyMaintenanceService propertyMaintenanceService;
+    private final PropertyService propertyService;
 
     @PostMapping("maintenance")
     public RestResponse<?> maintenance(@RequestBody PropertyMaintenanceVO propertyMaintenanceVO) {
         IPage<PropertyMtResponse> propertyMtResponsePage = new Page<>(propertyMaintenanceVO.getPageNum(), propertyMaintenanceVO.getPageSize());
-        return RestResponse.success(propertyMaintenanceService.propertyMtResponsePage(propertyMtResponsePage, propertyMaintenanceVO));
+        return RestResponse.success(propertyService.propertyMtResponsePage(propertyMtResponsePage, propertyMaintenanceVO));
     }
 
     @PostMapping("maintenance/num/month")
     public RestResponse<?> maintenanceNumForMonth(@RequestBody PropertyMaintenanceVO propertyMaintenanceVO) {
-        return propertyMaintenanceService.queryMaintenancePlanMonth(propertyMaintenanceVO);
+        return propertyService.queryMaintenancePlanMonth(propertyMaintenanceVO);
     }
 
     @PostMapping("repair/message")
     public RestResponse<?> repairMessage(@RequestBody PropertyMaintenanceVO propertyMaintenanceVO) {
         IPage<DynamicMessageResponse> dynamicMessageResponsePage = new Page<>(propertyMaintenanceVO.getPageNum(), propertyMaintenanceVO.getPageSize());
-        return propertyMaintenanceService.queryEmergencyRepairDynamicMessage(dynamicMessageResponsePage, propertyMaintenanceVO);
+        return propertyService.queryEmergencyRepairDynamicMessage(dynamicMessageResponsePage, propertyMaintenanceVO);
     }
 
     @PostMapping("maintenance/message")
     public RestResponse<?> maintenanceMessage(@RequestBody PropertyMaintenanceVO propertyMaintenanceVO) {
         IPage<DynamicMessageResponse> dynamicMessageResponsePage = new Page<>(propertyMaintenanceVO.getPageNum(), propertyMaintenanceVO.getPageSize());
-        return propertyMaintenanceService.queryMaintenanceSuccessDynamicMessage(dynamicMessageResponsePage, propertyMaintenanceVO);
+        return propertyService.queryMaintenanceSuccessDynamicMessage(dynamicMessageResponsePage, propertyMaintenanceVO);
+    }
+
+    @PostMapping("evaluate")
+    public RestResponse<?> evaluate(@RequestBody PropertyVo propertyVo) {
+        return propertyService.queryEvaluateAuth(propertyVo);
+    }
+
+    @PostMapping("project")
+    public RestResponse<?> project(@RequestBody PropertyVo propertyVo) {
+        return propertyService.queryJoinProjectList(propertyVo);
     }
 }

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

@@ -0,0 +1,11 @@
+package cn.com.ty.lift.business.maintenance.dao.entity.model.request;
+
+import lombok.Data;
+
+@Data
+public class PropertyVo {
+    private Long userId;
+    private Long id;
+
+    private Integer type;
+}

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

@@ -0,0 +1,9 @@
+package cn.com.ty.lift.business.maintenance.dao.entity.model.response;
+
+import lombok.Data;
+
+@Data
+public class PropertyEvaluateAuthResponse {
+    private Long id;
+    private Integer userRole;
+}

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

@@ -13,4 +13,5 @@ public class PropertyMtResponse {
     private Object category;
     private String workerName;
     private LocalDate planDate;
+    private Integer hasEvaluate;
 }

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

@@ -0,0 +1,10 @@
+package cn.com.ty.lift.business.maintenance.dao.entity.model.response;
+
+import lombok.Data;
+
+@Data
+public class PropertyProjectListResponse {
+    private Long projectId;
+    private String projectName;
+    private Long mtCompanyId;
+}

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

@@ -2,7 +2,9 @@ package cn.com.ty.lift.business.maintenance.dao.mapper;
 
 import cn.com.ty.lift.business.maintenance.dao.entity.model.dto.MaintenancePlanMonthTaskNum;
 import cn.com.ty.lift.business.maintenance.dao.entity.model.response.DynamicMessageResponse;
+import cn.com.ty.lift.business.maintenance.dao.entity.model.response.PropertyEvaluateAuthResponse;
 import cn.com.ty.lift.business.maintenance.dao.entity.model.response.PropertyMtResponse;
+import cn.com.ty.lift.business.maintenance.dao.entity.model.response.PropertyProjectListResponse;
 import cn.com.ty.lift.common.constants.SqlConstants;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import org.apache.ibatis.annotations.Select;
@@ -21,8 +23,14 @@ public interface PropertyMaintenanceMapper {
     List<MaintenancePlanMonthTaskNum> queryMaintenancePlanMonth(Long userId, String yearMonth);
 
     @Select(SqlConstants.QUERY_EMERGENCY_REPAIR_DYNAMIC_MESSAGE)
-    List<DynamicMessageResponse> queryEmergencyRepairDynamicMessage(IPage<DynamicMessageResponse> page, Long userId);
+    IPage<DynamicMessageResponse> queryEmergencyRepairDynamicMessage(IPage<DynamicMessageResponse> page, Long userId);
 
     @Select(SqlConstants.QUERY_MAINTENANCE_SUCCESS_DYNAMIC_MESSAGE)
-    List<DynamicMessageResponse> queryMaintenanceSuccessDynamicMessage(IPage<DynamicMessageResponse> page, Long userId);
+    IPage<DynamicMessageResponse> queryMaintenanceSuccessDynamicMessage(IPage<DynamicMessageResponse> page, Long userId);
+
+    @Select(SqlConstants.QUERY_JOIN_PROJECT_LIST)
+    List<PropertyProjectListResponse> queryJoinProjectList(Long userId);
+
+    @Select(SqlConstants.QUERY_EVALUATE_AUTH)
+    List<PropertyEvaluateAuthResponse> queryEvaluateAuth(String table,Long userId);
 }

+ 27 - 1
lift-business-service/src/main/java/cn/com/ty/lift/business/maintenance/service/PropertyMaintenanceService.java

@@ -2,6 +2,7 @@ package cn.com.ty.lift.business.maintenance.service;
 
 import cn.com.ty.lift.business.maintenance.dao.entity.model.dto.MaintenancePlanMonthTaskNum;
 import cn.com.ty.lift.business.maintenance.dao.entity.model.request.PropertyMaintenanceVO;
+import cn.com.ty.lift.business.maintenance.dao.entity.model.request.PropertyVo;
 import cn.com.ty.lift.business.maintenance.dao.entity.model.response.DynamicMessageResponse;
 import cn.com.ty.lift.business.maintenance.dao.entity.model.response.PropertyCalendarResponse;
 import cn.com.ty.lift.business.maintenance.dao.entity.model.response.PropertyMtResponse;
@@ -19,7 +20,7 @@ import java.util.List;
 @Service
 @AllArgsConstructor
 @Slf4j
-public class PropertyMaintenanceService {
+public class PropertyService {
     private final PropertyMaintenanceMapper propertyMaintenanceMapper;
 
     /**
@@ -149,4 +150,29 @@ public class PropertyMaintenanceService {
     public RestResponse<?> queryMaintenanceSuccessDynamicMessage(IPage<DynamicMessageResponse> dynamicMessageResponseIPage, PropertyMaintenanceVO propertyMaintenanceVO) {
         return RestResponse.success(propertyMaintenanceMapper.queryMaintenanceSuccessDynamicMessage(dynamicMessageResponseIPage, propertyMaintenanceVO.getUserId()));
     }
+
+    public RestResponse<?> queryJoinProjectList(PropertyVo propertyVo) {
+        return RestResponse.success(propertyMaintenanceMapper.queryJoinProjectList(propertyVo.getUserId()));
+    }
+
+    /**
+     * 查询用户是否拥有急修或维保评价的权限
+     *
+     * @param propertyVo type 1查询急修评价权限2查询维保评价权限,userId
+     * @return List<PropertyEvaluateAuthResponse>
+     */
+    public RestResponse<?> queryEvaluateAuth(PropertyVo propertyVo) {
+        String table;
+        switch (propertyVo.getType()) {
+            case ApiConstants.Property.QUERY_REPAIR_EVALUATE_AUTH:
+                table = "emergency_repair";
+                break;
+            case ApiConstants.Property.QUERY_MAINTENANCE_EVALUATE_AUTH:
+                table = "maintenance_plan";
+                break;
+            default:
+                throw new IllegalStateException("Unexpected value: " + propertyVo.getType());
+        }
+        return RestResponse.success(propertyMaintenanceMapper.queryEvaluateAuth(table, propertyVo.getUserId()));
+    }
 }

+ 2 - 2
lift-business-service/src/main/resources/mapper/contract/PaymentHistoryMapper.xml

@@ -19,7 +19,7 @@
     <select id="queryPaymentHistory" parameterType="java.lang.Long"
             resultType="cn.com.ty.lift.business.contract.dao.entity.model.response.PaymentHistoryResponse">
         SELECT ph.id,
-               ph.contract_id,
+               ph.contracts_id,
                ph.description,
                ph.before_content,
                ph.after_content,
@@ -28,7 +28,7 @@
                ui.name AS operatorName
         FROM payment_history ph
                  LEFT JOIN user_info ui ON ph.operator_id = ui.user_id
-        WHERE contract_id = #{contractId}
+        WHERE contracts_id = #{contractId}
     </select>
 
 </mapper>

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

@@ -348,4 +348,9 @@ public class ApiConstants {
         Integer OVERDUE = -1;//超期
         Integer LAWS_STIPULATION_OVERDUE = 10;//自定义的法规超期,非数据库状态
     }
+
+    public interface Property {
+        int QUERY_REPAIR_EVALUATE_AUTH = 1;//查询急修评价权限
+        int QUERY_MAINTENANCE_EVALUATE_AUTH = 2;//查询维保评价权限
+    }
 }

+ 17 - 1
lift-common/src/main/java/cn.com.ty.lift.common/constants/SqlConstants.java

@@ -9,11 +9,13 @@ public interface SqlConstants {
                     "       l.lift_type liftType," +
                     "       l.category category," +
                     "       ui.name workerName," +
-                    "       mp.plan_date planDate" +
+                    "       mp.plan_date planDate," +
+                    "       mr.has_evaluate hasEvaluate" +
                     "          from maintenance_plan mp" +
                     "           left join lift l on mp.lift_id = l.id" +
                     "           left join user_info ui on mp.worker_id = ui.user_id" +
                     "           left join project p on mp.project_id = p.id" +
+                    "           left join maintenance_record mr on mr.mt_plan_id = mp.id" +
                     "       where mp.plan_date = #{planDate}" +
                     "             and mp.status = #{status}" +
                     "             and mp.project_id in (select project_id from project_user where user_id = #{userId})";
@@ -96,4 +98,18 @@ public interface SqlConstants {
                     "        left join lift l on mr.lift_id = l.id" +
                     "    where DATE_FORMAT(mr.recovery_date, '%Y%m%d')  = DATE_FORMAT(CURDATE(), '%Y%m%d')" +
                     "      and project_id in (select project_id from project_user where user_id = #{userId})";
+
+    //根据用户Id查询加入的项目列表
+    String QUERY_JOIN_PROJECT_LIST =
+            "select     id projectId, project_name projectName, mt_company_id mtCompanyId" +
+                    "    from project" +
+                    "   where id in (select project_id from project_user where user_id = #{userId})";
+
+    //查询急修/维保id是否有评价权限
+    String QUERY_EVALUATE_AUTH =
+            "select     temp.id id, pu.user_role userRole" +
+                    "   from ${table} temp" +
+                    "         left join project_user pu on pu.project_id = temp.project_id" +
+                    "   where user_role in (21, 22)" +
+                    "  and user_id =#{userId}";
 }

+ 1 - 1
lift-enterprise-service/src/main/java/cn/com/ty/lift/enterprise/option/controller/MaintenanceOptionController.java

@@ -46,7 +46,7 @@ public class MaintenanceOptionController {
                         .in(req.getType() != null, "type", type(req))
                         .eq(req.getLiftCategory() != null, "lift_category", req.getLiftCategory())
                         .eq(req.getStatus() != null, "status", req.getStatus())
-                        .orderByDesc("id"));
+                        .orderByAsc("id"));
         if (page.getRecords().isEmpty()) {
             return RestResponse.success();
         }

+ 1 - 1
lift-enterprise-service/src/main/java/cn/com/ty/lift/enterprise/option/dao/entity/MaintenanceOption.java

@@ -27,7 +27,7 @@ public class MaintenanceOption implements Serializable {
     /**
      * 保养项目ID
      */
-    @TableId(value = "id", type = IdType.ID_WORKER)
+    @TableId(value = "id", type = IdType.AUTO)
     private Long id;
 
     /**

+ 4 - 9
lift-enterprise-service/src/main/java/cn/com/ty/lift/enterprise/region/service/impl/RegionServiceImpl.java

@@ -47,20 +47,15 @@ public class RegionServiceImpl extends ServiceImpl<RegionMapper, Region> impleme
                                 , "user_id userId", "id")
                         .eq("mt_company_id", req.getMtCompanyId())
                         .orderByDesc("create_time"));
-        //如果没有区域
-        if (page.getRecords().isEmpty()) {
-            return RestResponse.success();
-        }
 
         List<Map<String, Object>> records = regions.getRecords();
+        //如果没有区域
+        if (records.isEmpty()) {
+            return RestResponse.success(page);
+        }
         List<Map<String, Object>> projects = baseMapper.selectProjects();
         List<Map<String, Object>> areaCodes = baseMapper.selectAreaCodes();
         List<Map<String, Object>> userInfos = baseMapper.selectUserInfo();
-
-        if (records.isEmpty()) {
-            return RestResponse.success();
-        }
-
         //遍历区域列表
         for (Map<String, Object> region : records) {
             //遍历用户列表,将user_id替换为name