diff --git a/dl-module-inspection/pom.xml b/dl-module-inspection/pom.xml
index 03b7e017..281ec10f 100644
--- a/dl-module-inspection/pom.xml
+++ b/dl-module-inspection/pom.xml
@@ -32,6 +32,16 @@
2.1.0-jdk8-snapshot
compile
+
+
+ cn.afterturn
+ easypoi-spring-boot-starter
+ 4.4.0
+
+
+ org.springframework
+ spring-test
+
8
diff --git a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/controller/InspectionInfoController.java b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/controller/InspectionInfoController.java
index b89e8e07..1810d278 100644
--- a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/controller/InspectionInfoController.java
+++ b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/controller/InspectionInfoController.java
@@ -1,16 +1,22 @@
package cn.iocoder.yudao.module.inspection.controller;
-import java.util.List;
+import java.util.*;
+import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+import cn.hutool.core.date.DateTime;
+import cn.hutool.core.date.DateUtil;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.security.core.LoginUser;
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
import cn.iocoder.yudao.module.inspection.entity.InspectionInfo;
import cn.iocoder.yudao.module.inspection.entity.InspectionWorkNode;
+import cn.iocoder.yudao.module.inspection.service.AppInspectionPartnerService;
import cn.iocoder.yudao.module.inspection.service.IInspectionInfoService;
import cn.iocoder.yudao.module.inspection.service.IInspectionWorkNodeService;
+import cn.iocoder.yudao.module.inspection.vo.InspectionInfoVo;
import cn.iocoder.yudao.util.ExcelUtil;
+//import cn.iocoder.yudao.util.WordUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.security.access.prepost.PreAuthorize;
@@ -32,6 +38,8 @@ public class InspectionInfoController extends BaseController {
@Autowired
private IInspectionWorkNodeService inspectionWorkNodeService;
+ @Autowired
+ private AppInspectionPartnerService partnerList;
/**
* 查询【请填写功能名称】列表
@@ -267,4 +275,62 @@ public class InspectionInfoController extends BaseController {
public CommonResult isExamine(){
return success(inspectionInfoService.isExamine());
}
+ /**
+ * 判断当前登陆人是否有重检、重审、退办理的权限(app)
+ * @return
+ */
+ @GetMapping("getRoleList")
+ public CommonResult getRoleList(){
+ return success(inspectionInfoService.getRoleList());
+ }
+
+ @GetMapping("getWordContent")
+ public CommonResult getWordContent(InspectionInfo inspectionInfo) {
+ //根据工单id查询工单信息
+ InspectionInfoVo inspectionInfoVo = partnerList.inspectionDetail(inspectionInfo.getId());
+ InspectionInfo inspectionInfos = inspectionInfoService.selectInspectionInfoById(inspectionInfo.getId());
+ Map map = new HashMap<>();
+ Date endTime = inspectionInfos.getEndTime();
+ // 创建 Calendar 实例并设置时间
+ Calendar calendar = Calendar.getInstance();
+ calendar.setTime(endTime);
+
+ // 获取年、月、日
+ int year = calendar.get(Calendar.YEAR);
+ int month = calendar.get(Calendar.MONTH) + 1; // 月份从0开始,所以需要加1
+ int day = calendar.get(Calendar.DAY_OF_MONTH);
+
+ map.put("vin", inspectionInfos.getCarIdNo());
+ map.put("day", day);
+ map.put("one","□");
+ map.put("two","□");
+ map.put("three","□");
+ map.put("four","√");
+ map.put("month", month);
+ map.put("year", year);
+ map.put("carNum", inspectionInfoVo.getCarNum());
+ map.put("userName", inspectionInfos.getBuyName());
+ //TODO 还差编号和检验报告编号 告知书编号规则:8位行政区划号码+2位年份号码+4位顺序号,例如:51132201240009。 暂时写死
+ StringBuilder sb = new StringBuilder();
+ sb.append("51132201");
+ //获取年份第二位
+ DateTime now = DateUtil.date();
+ String yearStr = DateUtil.format(now, "yy");
+ sb.append(yearStr);
+ sb.append("0001");//顺序号 暂时写死
+ map.put("id", "1111111111");
+ map.put("reportId", sb);
+
+ return success(map);
+ }
+
+ /**
+ * 根据模板导出word
+ */
+ @PostMapping("/exportWord")
+ public CommonResult exportWord(HttpServletRequest request, HttpServletResponse response,@RequestBody Map map){
+ String str = UUID.randomUUID().toString()+".docx";
+ String name = inspectionInfoService.easyPoiExport("template/word/四川省超标排放汽车维护修理告知书.docx", str, map, request, response);
+ return CommonResult.success(name);
+ }
}
diff --git a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/IInspectionInfoService.java b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/IInspectionInfoService.java
index c71c609d..78d0703d 100644
--- a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/IInspectionInfoService.java
+++ b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/IInspectionInfoService.java
@@ -2,11 +2,14 @@ package cn.iocoder.yudao.module.inspection.service;
import cn.iocoder.yudao.module.inspection.entity.InspectionWorkNode;
import cn.iocoder.yudao.module.inspection.vo.DlInspectionWorkNodeVo;
+import cn.iocoder.yudao.module.system.dal.dataobject.permission.RoleDO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import cn.iocoder.yudao.module.inspection.entity.InspectionInfo;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;
@@ -109,4 +112,12 @@ public interface IInspectionInfoService extends IService
* @return
*/
Boolean isExamine();
+
+ /**
+ * 获取当前登陆人的角色列表
+ * @return
+ */
+ List getRoleList();
+
+ String easyPoiExport(String templatePath, String filename, Map data, HttpServletRequest request, HttpServletResponse response);
}
diff --git a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/impl/InspectionInfoServiceImpl.java b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/impl/InspectionInfoServiceImpl.java
index 0d99bf6a..cd13f89b 100644
--- a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/impl/InspectionInfoServiceImpl.java
+++ b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/impl/InspectionInfoServiceImpl.java
@@ -1,5 +1,10 @@
package cn.iocoder.yudao.module.inspection.service.impl;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.net.URLEncoder;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
@@ -9,9 +14,12 @@ import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
+import cn.afterturn.easypoi.word.WordExportUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateUtil;
+import cn.hutool.core.io.IoUtil;
+import cn.hutool.core.lang.Assert;
import cn.hutool.core.util.ObjectUtil;
import cn.iocoder.yudao.framework.security.core.LoginUser;
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
@@ -19,6 +27,7 @@ import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore;
import cn.iocoder.yudao.module.appBase.controller.admin.InspectionSocket;
import cn.iocoder.yudao.module.custom.entity.CustomerMain;
import cn.iocoder.yudao.module.custom.service.CustomerMainService;
+import cn.iocoder.yudao.module.infra.service.file.FileService;
import cn.iocoder.yudao.module.inspection.vo.DlInspectionWorkNodeVo;
import cn.iocoder.yudao.module.partner.entity.PartnerCustomerInfo;
import cn.iocoder.yudao.module.partner.service.IPartnerCustomerInfoService;
@@ -48,13 +57,20 @@ import cn.iocoder.yudao.module.payment.entity.OrderInfo;
import cn.iocoder.yudao.module.payment.entity.OrderInfoDetail;
import cn.iocoder.yudao.module.shop.entity.ShopMallPartners;
import org.apache.commons.lang3.ObjectUtils;
+import org.apache.poi.xwpf.usermodel.XWPFDocument;
+import org.apache.poi.xwpf.usermodel.XWPFParagraph;
+import org.apache.poi.xwpf.usermodel.XWPFRun;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
+import org.springframework.mock.web.MockMultipartFile;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.multipart.MultipartFile;
import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
import static cn.iocoder.yudao.framework.common.config.CommonStr.USER_TYPE_CUS;
@@ -99,6 +115,8 @@ public class InspectionInfoServiceImpl extends ServiceImpl getRoleList() {
+ LoginUser loginUser = SecurityFrameworkUtils.getLoginUser();
+ //获取当前登陆人的所有角色
+ List userRoles = roleService.getByUserId(loginUser.getId());
+ List userRoleIds = userRoles.stream().map(UserRoleDO::getRoleId).collect(Collectors.toList());
+ return roleService.getRoleList(userRoleIds);
+ }
+
+ /**
+ * EasyPoi 替换数据 导出 word
+ * @param templatePath word模板地址
+ * @param filename 文件名称
+ * @param data 替换参数
+ * @param request
+ * @param response
+ */
+ public String easyPoiExport(String templatePath, String filename, Map data, HttpServletRequest request, HttpServletResponse response) {
+ Assert.notNull(templatePath, "模板路径不能为空");
+ Assert.notNull(filename, "文件名称不能为空");
+ Assert.isTrue(filename.endsWith(".docx"), "文件名称仅支持docx格式");
+
+ try {
+ String userAgent = request.getHeader("user-agent").toLowerCase();
+ if (userAgent.contains("msie") || userAgent.contains("like gecko")) {
+ filename = URLEncoder.encode(filename, "UTF-8");
+ } else {
+ filename = new String(filename.getBytes("utf-8"), "ISO-8859-1");
+ }
+
+ XWPFDocument document = WordExportUtil.exportWord07(templatePath, data);
+ MultipartFile files = convertXWPFDocumentToMultipartFile(document, filename);
+ filename = fileService.createFile(files.getOriginalFilename(), "", IoUtil.readBytes(files.getInputStream()));
+
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ return filename;
+ }
+ public static MultipartFile convertXWPFDocumentToMultipartFile(XWPFDocument document, String filename) throws IOException {
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ document.write(bos);
+ byte[] bytes = bos.toByteArray();
+ return new MockMultipartFile(filename, filename, "application/vnd.openxmlformats-officedocument.wordprocessingml.document", bytes);
+ }
}
diff --git a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/vo/InspectionInfoVo.java b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/vo/InspectionInfoVo.java
index d56a29b0..425d4e74 100644
--- a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/vo/InspectionInfoVo.java
+++ b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/vo/InspectionInfoVo.java
@@ -90,4 +90,6 @@ public class InspectionInfoVo {
List workNodes;
@TableField(exist = false)
private Long leadManId;
+ @TableField(exist = false)
+ private String skuName;
}
diff --git a/dl-module-inspection/src/main/resources/template/word/四川省超标排放汽车维护修理告知书.docx b/dl-module-inspection/src/main/resources/template/word/四川省超标排放汽车维护修理告知书.docx
new file mode 100644
index 00000000..acd0e5cf
Binary files /dev/null and b/dl-module-inspection/src/main/resources/template/word/四川省超标排放汽车维护修理告知书.docx differ