Commit 30c33ca9 authored by suhuiguang's avatar suhuiguang

1.新增使用标志生成方法,标志3待写

parent 946c650d
package com.yeejoin.amos.boot.module.jg.api.dto;
import lombok.Data;
import java.util.Date;
/**
* @author Administrator
* 使用标志参数
*/
@Data
public class UseFlagParamDto {
/**
* 设备种类名称
*/
private String equList;
/**
* 设备种类编码
*/
private String equListCode;
/**
* 设备代码
*/
private String equipCode;
/**
* 设备品种名称
*/
private String equipDefine;
/**
* 使用单位名称
*/
private String useUnitName;
/**
* 设备类别名称
*/
private String equipCategory;
/**
* 单位内编号
*/
private String useInnerCode;
/**
* 登记机关
*/
private String receiveOrgName;
/**
* 检验机构名称
*/
private String inspectionUnitName;
/**
* 登记证编号
*/
private String useRegistrationCode;
/**
* 下次检验日期
*/
private Date nextInspectionDate;
/**
* 维保单位名称--电梯专用
*/
private String maintenanceUnitName;
/**
* 应急救援电话--电梯专用
*/
private String emergencyTel;
/**
* 车牌号--车用气瓶专用
*/
private String carNumber;
/**
* 产品编号--车用气瓶专用
*
*/
private String factoryNumber;
/**
* 气瓶数量或者容积--车用气瓶专用
*/
private String cylinderNumOrVolume;
/**
* 申请编号
*/
private String applyNo;
}
......@@ -3,6 +3,7 @@ package com.yeejoin.amos.boot.module.jg.biz.service;
import com.yeejoin.amos.boot.biz.common.bo.CompanyBo;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.boot.module.jg.api.dto.UseFlagParamDto;
import com.yeejoin.amos.boot.module.ymt.api.entity.EquipmentCategory;
import javax.servlet.http.HttpServletResponse;
......@@ -68,4 +69,11 @@ public interface ICommonService {
Map<String, Object> getPermissionTreeWithCompany(String menuAgent, String permissionType, String path, CompanyBo company);
/**
* 使用标志生成
* @param useFlagParamDto 参数
* @param response 文件信息
*/
void useFlagGenerate(UseFlagParamDto useFlagParamDto, HttpServletResponse response);
}
......@@ -2,6 +2,7 @@ package com.yeejoin.amos.boot.module.jg.biz.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.io.IoUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
......@@ -67,6 +68,7 @@ import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;
import org.springframework.web.multipart.MultipartFile;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.utils.Bean;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
......@@ -347,6 +349,7 @@ public class CommonServiceImpl implements ICommonService {
/**
* 验EQUCODE的唯一性
*
* @param equCode
* @return
*/
......@@ -361,13 +364,75 @@ public class CommonServiceImpl implements ICommonService {
@Override
public Map<String, Object> getPermissionTreeWithCompany(String menuAgent, String permissionType, String path, CompanyBo company) {
Map<String, Object> result = new HashMap<>();
Collection<PermissionModel> permissionModels = FeignUtil.remoteCall(()->Privilege.permissionClient.currentPermissionTree(menuAgent, permissionType, null, path));
Collection<PermissionModel> permissionModels = FeignUtil.remoteCall(() -> Privilege.permissionClient.currentPermissionTree(menuAgent, permissionType, null, path));
result.put("permission", permissionModels);
result.put("company", company);
return result;
}
@Override
public void useFlagGenerate(UseFlagParamDto useFlagParamDto, HttpServletResponse response) {
if (useFlagParamDto == null) {
throw new IllegalArgumentException("参数不能为空");
}
Map<String, Object> paramMap;
paramMap = Bean.BeantoMap(useFlagParamDto);
// 设置二维码
setQrCode(useFlagParamDto, paramMap);
setNextDate(useFlagParamDto, paramMap);
String ftlPath = this.getFtlPathByBiz(useFlagParamDto);
if (StringUtils.isEmpty(ftlPath)) {
throw new BadRequest("无法找到使用标志");
}
File pdfFile = null;
try {
pdfFile = this.wordToPdf("特种设备使用标志_", ftlPath, paramMap);
byte[] bytes = file2byte(pdfFile);
String docTitle = pdfFile.getName();
FileExporter.exportFile(FileExporter.FileType.valueOf("pdf"), docTitle, bytes, response);
} catch (Exception e) {
log.error("特种设备使用标志生成失败", e);
throw new RuntimeException(e);
} finally {
if (pdfFile != null) {
pdfFile.deleteOnExit();
}
}
}
private void setNextDate(UseFlagParamDto useFlagParamDto, Map<String, Object> paramMap) {
if (useFlagParamDto.getNextInspectionDate() != null) {
paramMap.put("year", DateUtil.year(useFlagParamDto.getNextInspectionDate()));
paramMap.put("month", DateUtil.month(useFlagParamDto.getNextInspectionDate()) + 1);
}
}
private void setQrCode(UseFlagParamDto useFlagParamDto, Map<String, Object> paramMap) {
String qrCode = ImageUtils.generateQRCode(Optional.ofNullable(useFlagParamDto.getApplyNo()).orElse(""), 180, 180);
paramMap.put("qrCode", qrCode);
}
private String getFtlPathByBiz(UseFlagParamDto useFlagParamDto) {
String ftlPath = "";
// 锅炉、压力容器(气瓶除外)、起重机械、客运索道、大型游乐设施、场(厂)内专用机动车辆 使用式样一
String[] flag1EquipList = {"1000", "2000", "4000", "9000", "6000"};
if (Arrays.asList(flag1EquipList).contains(useFlagParamDto.getEquListCode())) {
ftlPath = "flag1-use-equip.ftl";
}
// 电梯使用式样二
String[] flag2EquipList = {"3000"};
if (Arrays.asList(flag2EquipList).contains(useFlagParamDto.getEquListCode())) {
ftlPath = "flag2-use-equip.ftl";
}
// 车用气瓶使用式样三, 约定 车用气瓶为 0000
String[] flag3EquipList = {"0000"};
if (Arrays.asList(flag3EquipList).contains(useFlagParamDto.getEquListCode())) {
ftlPath = "flag3-use-equip.ftl";
}
return ftlPath;
}
@Override
public List<LinkedHashMap> getTree(ReginParams reginParams) {
// 企业逻辑
if (reginParams.getCompany().getLevel().equals(BaseController.COMPANY_TYPE_COMPANY)) {
......@@ -470,7 +535,7 @@ public class CommonServiceImpl implements ICommonService {
// disabled的节点设置下不可编辑属性
if (e.get("description") != null && e.get("description").toString().contains(type + "-disabled")) {
// 过滤非全部(all)公共及指定类型外的
e.put("disabled",true);
e.put("disabled", true);
}
if (!ObjectUtils.isEmpty(e.get("children"))) {
filterTreeDataByType((List<LinkedHashMap>) e.get("children"), type);
......@@ -628,7 +693,7 @@ public class CommonServiceImpl implements ICommonService {
// word转pdf
File pdfFile;
try {
pdfFile = this.wordToPdf("equipment-registration-certificate-report.ftl", map);
pdfFile = this.wordToPdf("特种设备使用登记证_", "equipment-registration-certificate-report.ftl", map);
} catch (Exception e) {
throw new RuntimeException(e);
}
......@@ -748,10 +813,10 @@ public class CommonServiceImpl implements ICommonService {
*
* @param wordPath word文件路径
*/
private File wordToPdf(String wordPath, Map<String, Object> placeholders) throws Exception {
private File wordToPdf(String filePrefix, String wordPath, Map<String, Object> placeholders) throws Exception {
Assert.hasText(wordPath, "word文件路径不能为空");
String tempFileName = "特种设备使用登记证_" + System.currentTimeMillis() + "_temp.pdf";
String tempFileName = filePrefix + System.currentTimeMillis() + "_temp.pdf";
WordTemplateUtils instance = WordTemplateUtils.getInstance();
......@@ -1336,7 +1401,7 @@ public class CommonServiceImpl implements ICommonService {
/**
* 生成使用登记编号
*
* @param supervisoryCode 监管码
* @param supervisoryCode 监管码
* @param supervisoryCompanyCode 接收机构单位代码
* @return 使用登记编号
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment