Browse Source

保养单列表及保养单详情导出

wang-hai-cheng 5 years ago
parent
commit
4bf083d48c

+ 11 - 4
lift-business-service/src/main/java/cn/com/ty/lift/business/maintenance/controller/MaintenanceRecordController.java

@@ -25,11 +25,9 @@ import com.google.common.base.Splitter;
 import lombok.AllArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
-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 org.springframework.web.bind.annotation.*;
 
+import javax.servlet.http.HttpServletResponse;
 import javax.validation.Valid;
 import java.time.LocalDate;
 import java.time.LocalDateTime;
@@ -414,4 +412,13 @@ public class MaintenanceRecordController {
         IPage<MtRecordResponse> pages = maintenanceRecordService.pageByLift(request);
         return RestResponse.success(pages);
     }
+
+    @GetMapping("export")
+//    @Validation(fields = {"ids"})
+    public void export( MtRecordRequest mtRecordRequest, HttpServletResponse response) {
+//        mtRecordRequest.setRecordIds("1266227182742659073,1266227510250692610,1266227956126179329,1266228390303752194,1266228572550455297,1266228948301373442");
+//        mtRecordRequest.setRecordIds("1001109100000,1001109100001,1001109100002,1001109100003,1001109100004");
+        mtRecordRequest.setRecordIds("1001109100157,1001109101050");
+        maintenanceRecordService.export(mtRecordRequest,response );
+    }
 }

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

@@ -46,6 +46,7 @@ public class MaintenanceOption implements Serializable {
 
     /**
      * 电梯类别(1:曳引梯;2:液压梯;3:杂物梯;4:自动扶梯;5:自动人行道)
+     * 电梯类型(1乘客梯/载货电梯 2液压梯 3扶梯/人行道 4杂物梯)
      */
     private Integer liftCategory;
 

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

@@ -7,6 +7,8 @@ import cn.com.ty.lift.business.maintenance.dao.entity.MtRecordImg;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 
+import java.time.LocalDate;
+import java.time.LocalDateTime;
 import java.util.Collection;
 import java.util.List;
 
@@ -28,6 +30,11 @@ public class MtRecordResponse extends MaintenanceRecord {
      */
     private String projectCode;
 
+    /**
+     * 项目地址
+     */
+    private String projectAddress;
+
     /**
      * 维保公司名
      */
@@ -57,6 +64,11 @@ public class MtRecordResponse extends MaintenanceRecord {
      */
     private String workerName;
 
+    /**
+     * 维保工手机号
+     */
+    private String workerMobile;
+
     /**
      * 保养时长分钟数
      */
@@ -64,8 +76,23 @@ public class MtRecordResponse extends MaintenanceRecord {
 
     private String repairDuration;
 
+    /**
+     * 计划保养时间
+     */
+    private LocalDate planDate;
+
+    /**
+     * 实际保养时间
+     */
+    private LocalDateTime workDate;
+
     private Integer starLevel;
 
+    /**
+     * 保养建议
+     */
+    private String maintenanceAdvice;
+
     private Collection<MaintenanceOption> mtOptions;
 
     private List<MtRecordImg> mtRecordImgs;

+ 343 - 4
lift-business-service/src/main/java/cn/com/ty/lift/business/maintenance/service/MaintenanceRecordService.java

@@ -21,29 +21,47 @@ import cn.com.ty.lift.business.project.dao.entity.ProjectLiftRelevance;
 import cn.com.ty.lift.business.project.service.ProjectLiftRelevanceService;
 import cn.com.ty.lift.business.project.service.ProjectService;
 import cn.com.ty.lift.common.constants.CommonEnum;
+import cn.com.ty.lift.common.utils.DateUtils;
 import cn.com.ty.lift.common.utils.MapHelper;
 import cn.com.ty.lift.common.utils.ValuePool;
+import cn.com.ty.lift.common.verify.Val;
 import cn.com.ty.lift.common.verify.Validate;
 import cn.com.xwy.boot.web.dto.RestResponse;
 import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.collection.IterUtil;
+import cn.hutool.core.io.FileUtil;
 import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.core.util.StrUtil;
+import cn.hutool.core.util.ZipUtil;
+import cn.hutool.http.HttpUtil;
+import cn.hutool.poi.excel.ExcelUtil;
+import cn.hutool.poi.excel.ExcelWriter;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.google.common.base.Splitter;
 import com.google.gson.Gson;
 import com.google.gson.reflect.TypeToken;
 import lombok.AllArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.poi.hssf.usermodel.HSSFClientAnchor;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
+import org.apache.poi.ss.usermodel.ClientAnchor;
+import org.apache.poi.ss.usermodel.Drawing;
+import org.apache.poi.ss.usermodel.Workbook;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.core.env.Environment;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.transaction.interceptor.TransactionAspectSupport;
+import org.springframework.web.bind.annotation.RequestBody;
 
+import javax.servlet.http.HttpServletResponse;
+import java.io.*;
 import java.math.BigDecimal;
+import java.net.HttpURLConnection;
+import java.net.URL;
 import java.time.LocalDate;
 import java.time.LocalDateTime;
 import java.util.*;
@@ -69,6 +87,8 @@ public class MaintenanceRecordService extends ServiceImpl<MaintenanceRecordMappe
     private ProjectLiftRelevanceService projectLiftRelevanceService;
     private MaintenanceOptionMapper maintenanceOptionMapper;
     private Gson gson;
+    MaintenanceOptionService maintenanceOptionService;
+
     @Autowired
     private Environment env;
 
@@ -323,7 +343,7 @@ public class MaintenanceRecordService extends ServiceImpl<MaintenanceRecordMappe
     }
 
     /**
-     * @param params RwdId,token,account 完成维保入参
+     * @param params      RwdId,token,account 完成维保入参
      * @param mtCompanyId 公司ID
      * @description 完成维保
      * @date 2020/5/19 4:01 下午
@@ -400,7 +420,7 @@ public class MaintenanceRecordService extends ServiceImpl<MaintenanceRecordMappe
     }
 
     /**
-     * @param params RwdId,token,account 提交维保记录入参
+     * @param params      RwdId,token,account 提交维保记录入参
      * @param mtCompanyId 公司ID
      * @description 提交维保记录
      * @date 2020/5/19 2:55 下午
@@ -471,7 +491,7 @@ public class MaintenanceRecordService extends ServiceImpl<MaintenanceRecordMappe
             String registrationCode = StrUtil.EMPTY;
             Long liftId = oldRecord.getLiftId();
             Optional<Lift> optional = liftService.getOne(null, liftId);
-            if (optional.isPresent()){
+            if (optional.isPresent()) {
                 Lift lift = optional.get();
                 registrationCode = lift.getRegistrationCode();
             }
@@ -817,4 +837,323 @@ public class MaintenanceRecordService extends ServiceImpl<MaintenanceRecordMappe
     public IPage<MtRecordResponse> pageByLift(MtRecordRequest request) {
         return baseMapper.pageByLift(request.getPage(), request);
     }
-}
+
+    public void export(MtRecordRequest mtRecordRequest, HttpServletResponse response) {
+        Map<String, String> headerAlias = new LinkedHashMap<>();
+        headerAlias.put("projectName", "项目名称");
+        headerAlias.put("useCompanyCode", "梯号");
+        headerAlias.put("registrationCode", "注册代码");
+        headerAlias.put("planDate", "计划日期");
+        headerAlias.put("workDate", "执行日期");
+        headerAlias.put("type", "维保类型");
+        headerAlias.put("hasEvaluate", "评价状态");
+        headerAlias.put("maintenanceAdvice", "保养建议");
+        headerAlias.put("workerName", "维保工");
+        headerAlias.put("repairDuration", "保养时长");
+        log.info("headerAlias: {}", headerAlias);
+
+        //根据id列表查询
+        List<MtRecordResponse> mtRecordResponses = new ArrayList<>();
+        String[] recordIdArray = mtRecordRequest.getRecordIds().split(",");
+        for (String recordIdStr : recordIdArray) {
+            long recordId = Long.parseLong(recordIdStr);
+            mtRecordRequest.setId(recordId);
+            mtRecordResponses.add(getMtRecordResponse(mtRecordRequest));
+        }
+        Validate.notNull(mtRecordResponses, ValuePool.MAINTENANCE_RECORD_NOT_EXIST);
+        //压缩文件夹
+        File baseDir = null;
+        File zipFile = null;
+        try {
+            //获取根目录
+            String root = ValuePool.SYSTEM_USER_DIR + File.separator + "maintenance";
+            String generateCode = DateUtils.generateCode();
+            String dir = root + File.separator + generateCode;
+            String zip = dir + ".zip";
+            baseDir = new File(dir);
+            zipFile = new File(zip);
+            log.info("dir: {}", dir);
+            log.info("zip: {}", zip);
+
+            //生成excel文件
+            String excel = File.separator + dir + File.separator + generateCode + ".xlsx";
+            log.info("生成excel: {}", excel);
+            File excelFile = new File(excel);
+            ExcelWriter writer = ExcelUtil.getBigWriter(excelFile, "维保记录表");
+            //设置列别名
+            headerAlias.forEach(writer::addHeaderAlias);
+            //如果为true,则不设置alias的字段将不被输出,false表示原样输出
+            writer.setOnlyAlias(true);
+            writer.write(mtRecordResponses, true);
+//            writer.autoSizeColumnAll();
+            writer.close();
+            FileUtil.touch(excelFile);
+
+            //处理图片类文件
+            //windows现在已知的文件名非法字符有 \ / : * ? " < > |
+            String illegalChars = "\\/:*?\"<>|";
+            for (int i = 0; i < mtRecordResponses.size(); i++) {
+                MtRecordResponse mtRecordResponse = mtRecordResponses.get(i);
+                List<MtRecordImg> mtRecordImgs = mtRecordResponse.getMtRecordImgs();
+                log.info("repair: {}", mtRecordResponse);
+                //处理文件夹路径
+                String projectName = mtRecordResponse.getProjectName();
+                String registrationCode = mtRecordResponse.getRegistrationCode();
+                projectName = StrUtil.isNotEmpty(projectName) ? projectName.replace(illegalChars, "-") : "[项目]";
+                registrationCode = StrUtil.isNotEmpty(registrationCode) ? registrationCode.replace(illegalChars, "-") : "[电梯注册代码]";
+                //图片文件夹 dir/i.AreaName-ProjectName-RegistrationCode/
+                String imgDir = StrUtil.format("{}{}{}.{}-{}{}", dir, File.separator, (i + 1), projectName, registrationCode, File.separator);
+
+                List<MtRecordImg> imgs = mtRecordImgs.stream().filter(img -> mtRecordResponse.getId().equals(img.getMtRecordId())).collect(Collectors.toList());
+                if (IterUtil.isNotEmpty(imgs)) {
+                    for (int n = 0; n < imgs.size(); n++) {
+                        String imgUrl = imgs.get(n).getImgUrl();
+                        if (StrUtil.isNotEmpty(imgUrl)) {
+                            log.info("imgUrl: {}", imgUrl);
+                            String filename = imgDir + StrUtil.format("维保图片{}.jpg", (n + 1));
+                            log.info("生成维保图片文件: {}", filename);
+                            HttpUtil.downloadFile(imgUrl, filename);
+                        }
+                    }
+                }
+                String maintenanceExcelDir = imgDir + "1.保养单.xlsx";
+                log.info("生成保养单: {}", maintenanceExcelDir);
+                excelWriter(mtRecordResponse, maintenanceExcelDir);
+            }
+
+            //压缩文件夹
+            log.info("生成zipfile: {}", zip);
+            ZipUtil.zip(dir, zip);
+        } catch (Exception e) {
+            FileUtil.del(zipFile);
+            FileUtil.del(baseDir);
+            log.error("生成保养文件失败", e);
+            throw Validate.validateException("生成保养文件失败");
+        }
+        //下载压缩文件
+        if (FileUtil.exist(zipFile)) {
+            // 设置强制下载不打开, ZIP的application/x-zip-compressed
+            response.setContentType("application/force-download");
+            // 设置文件名
+            response.addHeader("Content-Disposition", "attachment;fileName=" + zipFile.getName());
+            byte[] buffer = new byte[1024];
+            try (FileInputStream fis = new FileInputStream(zipFile);
+                 BufferedInputStream bis = new BufferedInputStream(fis)) {
+                OutputStream os = response.getOutputStream();
+                int i;
+                while ((i = bis.read(buffer)) != -1) {
+                    os.write(buffer, 0, i);
+                }
+            } catch (Exception e) {
+                log.error("下载保养文件失败", e);
+                throw Validate.validateException("下载保养文件失败");
+            } finally {
+                //删除临时根目录和zip文件
+                FileUtil.del(zipFile);
+                FileUtil.del(baseDir);
+            }
+        }
+    }
+
+    private MtRecordResponse getMtRecordResponse(@RequestBody @Val MtRecordRequest request) {
+        MtRecordResponse entity = this.infoById(request);
+        String repairDuration = this.getRepairDuration(entity.getRepairDiff());
+        entity.setRepairDuration(repairDuration);
+        Validate.notNull(entity, ValuePool.MAINTENANCE_RECORD_NOT_EXIST);
+        /**
+         * 维保项id:0/1/2, 0:无需保养,1:已保养,2:需要更换
+         * 保养项目  用键值对的方式存储,如(1:0,2:1,3:1...)
+         */
+        String maintenanceOption = entity.getMaintenanceOption();
+        if (StrUtil.isNotEmpty(maintenanceOption)) {
+            Map<String, String> opts = Splitter.on(ValuePool.COMMA).withKeyValueSeparator(ValuePool.COLON).split(maintenanceOption);
+            Map<Long, Integer> optMap = new HashMap<>();
+            opts.forEach((key, value) -> {
+                optMap.put(Long.parseLong(key.trim()), Integer.parseInt(value.trim()));
+            });
+            Collection<MaintenanceOption> mtOptions = maintenanceOptionService.listByIds(optMap.keySet());
+            mtOptions.forEach(option -> {
+                option.setOpt(optMap.get(option.getId()));
+            });
+            entity.setMtOptions(mtOptions);
+        }
+        Long id = request.getId();
+        //查询费用项
+        entity.setMtRecordCosts(mtRecordCostService.listByRecord(id));
+        //查询图片
+        entity.setMtRecordImgs(mtRecordImgService.listByRecord(id));
+        //评价
+        entity.setEvaluation(evaluationService.findByRecord(id, ValuePool.EVALUATE_SOURCE_MAINTENANCE));
+        return entity;
+    }
+
+    private void excelWriter(MtRecordResponse mtRecordResponse, String maintenanceExcelDir) throws FileNotFoundException {
+        HSSFWorkbook wb = new HSSFWorkbook();
+        ExcelWriter writer = new ExcelWriter(wb, "保养单");
+
+        writer.setColumnWidth(1, 25);
+        writer.setColumnWidth(3, 25);
+        writer.setColumnWidth(4, 25);
+        writer.merge(0, 0, 0, 5, mtRecordResponse.getProjectName(), false);
+        writer.merge(1, 1, 0, 1, "xxx电梯保养单", false);
+        writer.merge(1, 1, 2, 3, "单号:", false);
+        writer.merge(1, 1, 4, 5, "设备编号:" + mtRecordResponse.getUseCompanyCode(), false);
+        writer.merge(2, 2, 0, 1, "注册代码:" + mtRecordResponse.getRegistrationCode(), false);
+        writer.merge(2, 2, 2, 3, "电梯位置:" + mtRecordResponse.getDevicePosition(), false);
+        writer.merge(2, 2, 4, 5, "保养类型:" + mtRecordResponse.getType(), false);
+        writer.merge(3, 3, 0, 1, "保养时间:" + mtRecordResponse.getWorkDate(), false);
+        writer.merge(3, 3, 2, 3, "项目编号:" + mtRecordResponse.getProjectCode(), false);
+        writer.merge(3, 3, 4, 5, "项目名称:" + mtRecordResponse.getProjectName(), false);
+        writer.merge(4, 4, 0, 1, "计划保养时间:" + mtRecordResponse.getPlanDate(), false);
+        writer.merge(4, 4, 2, 3, "停梯时间:" + mtRecordResponse.getStopDate(), false);
+        writer.merge(4, 4, 4, 5, "恢梯时间:" + mtRecordResponse.getRecoveryDate(), false);
+        writer.writeCellValue(0, 5, "保养时长");
+        writer.merge(5, 5, 1, 5, mtRecordResponse.getRepairDuration(), false);
+        writer.writeCellValue(0, 6, "序号");
+        writer.merge(6, 6, 1, 2, "维保项目", false);
+        writer.merge(6, 6, 3, 4, "维保基本要求", false);
+        writer.writeCellValue(5, 6, "结果");
+        Collection<MaintenanceOption> mtOptions = mtRecordResponse.getMtOptions();
+        int i = 0;
+        for (MaintenanceOption mtOption : mtOptions) {
+            i++;
+            writer.writeCellValue(0, 6 + i, i);
+            writer.merge(6 + i, 6 + i, 1, 2, mtOption.getItem(), false);
+            writer.merge(6 + i, 6 + i, 3, 4, mtOption.getContent(), false);
+            String maintenance = "√";
+            switch (mtOption.getOpt()) {
+                case 0:
+                    maintenance = "/";
+                    break;
+                case 2:
+                    maintenance = "X";
+                    break;
+            }
+            writer.writeCellValue(5, 6 + i, maintenance);
+        }
+        writer.writeCellValue(0, 7 + i, "保养建议");
+        writer.merge(7 + i, 7 + i, 1, 2, "保养建议内容", false);
+        writer.writeCellValue(3, 7 + i, "客户意见");
+        String advice = "";
+        if (mtRecordResponse.getEvaluation() != null) {
+            if (mtRecordResponse.getEvaluation().getAdvice() != null) {
+                advice = mtRecordResponse.getEvaluation().getAdvice();
+            }
+        }
+        writer.merge(7 + i, 7 + i, 4, 5, advice, false);
+        writer.writeCellValue(0, 8 + i, "工作标记");
+        writer.merge(8 + i, 8 + i, 1, 5, "√:已保养项 / :无需保养项 ×:需修理项目", false);
+        writer.writeCellValue(0, 9 + i, "配件费");
+        writer.merge(9 + i, 9 + i, 1, 2, "配件费内容", false);
+        writer.writeCellValue(3, 9 + i, "更换配件");
+        writer.merge(9 + i, 9 + i, 4, 5, "更换配件内容", false);
+        writer.writeCellValue(0, 10 + i, "维保人员");
+        writer.merge(10 + i, 10 + i, 1, 2, mtRecordResponse.getWorkerName(), false);
+        writer.writeCellValue(3, 10 + i, "工时费");
+        writer.merge(10 + i, 10 + i, 4, 5, "工时费内容", false);
+        writer.writeCellValue(0, 11 + i, "服务态度");
+        StringBuilder level = new StringBuilder();
+        if (mtRecordResponse.getEvaluation() != null) {
+            int levelInt = mtRecordResponse.getEvaluation().getServiceLevel();
+            for (int i1 = 0; i1 < levelInt; i1++) {
+                level.append("★");
+            }
+        }
+        writer.merge(11 + i, 11 + i, 1, 2, level.toString(), false);
+        level = new StringBuilder();
+        writer.writeCellValue(3, 11 + i, "维保质量");
+        int levelInt = mtRecordResponse.getStarLevel();
+        for (int i1 = 0; i1 < levelInt; i1++) {
+            level.append("★");
+        }
+        writer.merge(11 + i, 11 + i, 4, 5, level.toString(), false);
+        writer.merge(12 + i, 18 + i, 0, 0, "维保签名", false);
+        writer.merge(12 + i, 18 + i, 1, 2, "", false);
+//        writer.merge(12 + i, 12 + i, 1, 2, "维保签名图片", false);
+        writer.merge(12 + i, 18 + i, 3, 3, "客户签名", false);
+        writer.merge(12 + i, 18 + i, 4, 5, "", false);
+//        writer.merge(12 + i, 12 + i, 4, 5, "客户签名图片", false);
+        signImg(mtRecordResponse, wb, writer, 12 + i);
+        writer.flush(new FileOutputStream(new File(maintenanceExcelDir)), true).close();
+    }
+
+    private void signImg(MtRecordResponse mtRecordResponse, HSSFWorkbook wb, ExcelWriter writer, int row) {
+        Drawing<?> patriarch = writer.getSheet().createDrawingPatriarch();
+
+        byte[] worker1Sign;
+        byte[] worker2Sign;
+        byte[] propertySign;
+        String signatureImg1Url = mtRecordResponse.getSignatureImg1();
+        String signatureImg2Url = mtRecordResponse.getSignatureImg2();
+        String imgUrl = mtRecordResponse.getEvaluation() != null ? mtRecordResponse.getEvaluation().getImgUrl() : null;
+        HSSFClientAnchor worker1Anchor;
+        HSSFClientAnchor worker2Anchor;
+        HSSFClientAnchor propertyAnchor;
+        Integer workerSign1Index;
+        Integer workerSign2Index;
+        Integer propertySignIndex;
+        if (signatureImg1Url != null && !"".equals(signatureImg1Url)) {
+            worker1Sign = getImageByte(signatureImg1Url);
+            workerSign1Index = wb.addPicture(worker1Sign, Workbook.PICTURE_TYPE_JPEG);
+            worker1Anchor = new HSSFClientAnchor(100, 100, 500, 255, (short) 1, row, (short) 1, row + 3);
+            worker1Anchor.setAnchorType(ClientAnchor.AnchorType.byId(3));
+            patriarch.createPicture(worker1Anchor, workerSign1Index);
+        }
+        if (signatureImg2Url != null && !"".equals(signatureImg2Url)) {
+            worker2Sign = getImageByte(signatureImg2Url);
+            workerSign2Index = wb.addPicture(worker2Sign, Workbook.PICTURE_TYPE_JPEG);
+            worker2Anchor = new HSSFClientAnchor(800, 100, 1023, 255, (short) 1, row, (short) 2, row + 3);
+            worker2Anchor.setAnchorType(ClientAnchor.AnchorType.byId(3));
+            patriarch.createPicture(worker2Anchor, workerSign2Index);
+        }
+        if (imgUrl != null && !"".equals(imgUrl)) {
+            propertySign = getImageByte(imgUrl);
+            propertySignIndex = wb.addPicture(propertySign, Workbook.PICTURE_TYPE_JPEG);
+            propertyAnchor = new HSSFClientAnchor(300, 100, 800, 255, (short) 4, row, (short) 4, row + 3);
+            propertyAnchor.setAnchorType(ClientAnchor.AnchorType.byId(3));
+            patriarch.createPicture(propertyAnchor, propertySignIndex);
+        }
+    }
+
+    /**
+     * 获取网络图片字节数组
+     *
+     * @param strUrl
+     * @return
+     */
+    public byte[] getImageByte(String strUrl) {
+        System.out.println(strUrl);
+        try {
+            if (!strUrl.contains("http://")) {
+                strUrl = "http://" + strUrl;
+            }
+            URL url = new URL(strUrl);
+            HttpURLConnection conn = (HttpURLConnection) url.openConnection();
+            conn.setRequestMethod("GET");
+            conn.setConnectTimeout(5 * 1000);
+            InputStream inStream = conn.getInputStream();//通过输入流获取图片数据
+            return readInputStream(inStream);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return null;
+    }
+
+    /**
+     * 从输入流中获取数据
+     *
+     * @param inStream 输入流
+     * @return
+     * @throws Exception
+     */
+    public static byte[] readInputStream(InputStream inStream) throws Exception {
+        ByteArrayOutputStream outStream = new ByteArrayOutputStream();
+        byte[] buffer = new byte[1024];
+        int len;
+        while ((len = inStream.read(buffer)) != -1) {
+            outStream.write(buffer, 0, len);
+        }
+        inStream.close();
+        return outStream.toByteArray();
+    }
+}

+ 6 - 0
lift-business-service/src/main/resources/mapper/maintenance/MaintenanceRecordMapper.xml

@@ -35,11 +35,14 @@
 
         <result column="project_name" property="projectName" jdbcType="VARCHAR"/>
         <result column="project_code" property="projectCode" jdbcType="VARCHAR"/>
+        <result column="address" property="projectAddress" jdbcType="VARCHAR"/>
         <result column="use_company_code" property="useCompanyCode" jdbcType="VARCHAR"/>
         <result column="mt_company_name" property="mtCompanyName" jdbcType="VARCHAR"/>
         <result column="category" property="category" jdbcType="INTEGER"/>
         <result column="registration_code" property="registrationCode" jdbcType="VARCHAR"/>
         <result column="worker_name" property="workerName" jdbcType="VARCHAR"/>
+        <result column="worker_mobile" property="workerMobile" jdbcType="VARCHAR"/>
+        <result column="maintenance_advice" property="maintenanceAdvice" jdbcType="VARCHAR"/>
         <result column="repair_diff" property="repairDiff" jdbcType="INTEGER"/>
         <result column="star_level" property="starLevel" jdbcType="INTEGER"/>
         <result column="device_position" property="devicePosition" jdbcType="VARCHAR"/>
@@ -277,8 +280,11 @@
         li.category,
         mc.name AS mt_company_name,
         ui.`name` AS worker_name,
+        ui.mobile AS worker_mobile,
         pr.project_name,
         pr.project_code,
+        mr.maintenance_advice,
+        pr.address,
         ev.star_level,
         li.device_position,
         TimeStampDiff(MINUTE ,mr.stop_date,mr.recovery_date) AS repair_diff