Commit a79b4b6f authored by chenzhao's avatar chenzhao

Merge branch 'develop_tzs_register' of…

Merge branch 'develop_tzs_register' of http://36.40.66.175:5000/moa/amos-boot-biz into develop_tzs_register
parents 7b8184b4 3fa7bfb3
......@@ -43,7 +43,7 @@
(SELECT min(dispatch_time) from tz_dispatch_task where alert_id = t1.sequence_nbr and dispatch_time is not null ) as dis
from tz_alert_called t1 where t1.biz_org_code like concat('50', '%') and t1.alarm_type_code = '960' and t1.call_time BETWEEN #{startDate} and #{endDate} and t1.father_alert is null
from tz_alert_called t1 where t1.biz_org_code like concat(#{orgCode}, '%') and t1.alarm_type_code = '960' and t1.call_time BETWEEN #{startDate} and #{endDate} and t1.father_alert is null
) ) as avgNum
</select>
......
package com.yeejoin.amos.boot.module.jg.api.service;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.module.jg.api.dto.JgChangeRegistrationReformDto;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
import java.util.Map;
/**
* 改造变更登记接口类
*
......@@ -8,5 +16,12 @@ package com.yeejoin.amos.boot.module.jg.api.service;
* @date 2023-12-20
*/
public interface IJgChangeRegistrationReformService {
Page<Map<String, Object>> getList(JgChangeRegistrationReformDto dto, Page<Map<String, Object>> page, List<String> roleIds);
void save(JSONObject map);
void updateExecuteIds(String instanceId, Long sequenceNbr, String operate);
void flowExecute(Long id, String instanceId, String operate, String comment);
void withdraw(String instanceId);
void deleteBatch(List<Long> ids);
Map<String, Object> getDetail(String currentDocumentId, String equipId);
void exportUseRegistrationCertificate(String sequenceNbr, HttpServletResponse response);
}
......@@ -7,6 +7,7 @@ import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.boot.module.jg.api.dto.JgInstallationNoticeDto;
import com.yeejoin.amos.boot.module.jg.api.entity.JgInstallationNotice;
import javax.servlet.http.HttpServletResponse;
import java.util.Map;
/**
......@@ -65,5 +66,5 @@ public interface IJgInstallationNoticeService extends IService<JgInstallationNot
* @param sequenceNbr 主键
* @return pdf文件路径
*/
String generateInstallationNoticeReport(Long sequenceNbr);
void generateInstallationNoticeReport(Long sequenceNbr, HttpServletResponse response);
}
......@@ -107,7 +107,8 @@
ei.legal_person AS safetyManager,
ei.legal_phone AS safetyManagerPhone,
ei.address AS address,
ei.use_code AS useCode
ei.use_code AS useCode,
isn.install_unit_credit_code AS installUnitCreditCode
FROM
tzs_jg_installation_notice isn
LEFT JOIN tzs_jg_installation_notice_eq re ON re.equip_transfer_id = isn.sequence_nbr
......
......@@ -147,6 +147,9 @@
instance_status like concat('%',#{role},'%')
</foreach>
</if>
<if test="contractDto.status != '' and contractDto.status != null">
and status = #{contractDto.status}
</if>
</where>
order by apply_no desc
</select>
......
......@@ -25,6 +25,8 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import javax.servlet.http.HttpServletResponse;
/**
* 改造变更登记
*
......@@ -130,10 +132,9 @@ public class JgChangeRegistrationReformController extends BaseController {
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET", value = "打印历史数据", notes = "打印历史数据")
@GetMapping(value = "/printHistoryData")
public ResponseModel<Map<String, Object>> printHistoryData(@RequestParam("currentDocumentId") String currentDocumentId,@RequestParam(value = "equipId",required = false) String equipId) {
return ResponseHelper.buildResponse(jgChangeRegistrationReformServiceImpl.getDetail(currentDocumentId,equipId));
@GetMapping(value = "/export")
@ApiOperation(httpMethod = "GET", value = "改造登记-导出使用登记证", notes = "改造登记-导出使用登记证")
public void exportImageZip(HttpServletResponse response, @RequestParam("sequenceNbr") String sequenceNbr){
jgChangeRegistrationReformServiceImpl.exportUseRegistrationCertificate(sequenceNbr, response);
}
}
......@@ -18,6 +18,7 @@ import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import javax.servlet.http.HttpServletResponse;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
......@@ -141,7 +142,7 @@ public class JgInstallationNoticeController extends BaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET", value = "安装告知列表全部数据查询", notes = "安装告知列表全部数据查询")
@GetMapping(value = "/generate-report")
public ResponseModel<String> generateReport(@RequestParam("sequenceNbr") Long sequenceNbr) {
return ResponseHelper.buildResponse(iJgInstallationNoticeService.generateInstallationNoticeReport(sequenceNbr));
public void generateReport(HttpServletResponse response, @RequestParam("sequenceNbr") Long sequenceNbr) {
iJgInstallationNoticeService.generateInstallationNoticeReport(sequenceNbr, response);
}
}
......@@ -27,13 +27,11 @@ 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.restful.utils.ResponseModel;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import javax.servlet.http.HttpServletResponse;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.nio.file.Files;
import java.util.*;
import java.util.stream.Collectors;
......@@ -99,16 +97,20 @@ public class CommonServiceImpl implements ICommonService {
public List<EquipmentCategory> getEquipmentCategoryList(String code, String type) {
List<EquipmentCategory> result = new ArrayList<>();
LambdaQueryWrapper<EquipmentCategory> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(EquipmentCategory::getCode, code);
EquipmentCategory equipmentCategory = equipmentCategoryMapper.selectOne(wrapper);
if (ObjectUtils.isEmpty(type)) {
result.add(equipmentCategory);
if(!ValidationUtil.isEmpty(equipmentCategory)){
result.add(equipmentCategory);
}
} else {
LambdaQueryWrapper<EquipmentCategory> wrapper2 = new LambdaQueryWrapper<>();
wrapper2.eq(EquipmentCategory::getParentId, equipmentCategory.getId());
result = equipmentCategoryMapper.selectList(wrapper2);
List<EquipmentCategory> equipmentCategories = equipmentCategoryMapper.selectList(wrapper2);
if(!ValidationUtil.isEmpty(equipmentCategories)){
result = equipmentCategories;
}
}
return result;
}
......
......@@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.bo.CompanyBo;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.boot.biz.common.utils.RedisKey;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
......@@ -12,17 +13,13 @@ import com.yeejoin.amos.boot.module.jg.api.enums.ConstructionEnum;
import com.yeejoin.amos.boot.module.jg.biz.dao.ESEquipmentCategory;
import com.yeejoin.amos.boot.module.jg.biz.service.*;
import com.yeejoin.amos.boot.module.ymt.api.dto.ESEquipmentCategoryDto;
import com.yeejoin.amos.boot.module.ymt.api.dto.IdxBizJgConstructionInfoDto;
import com.yeejoin.amos.boot.module.ymt.api.dto.IdxBizJgInspectionDetectionInfoDto;
import com.yeejoin.amos.boot.module.ymt.api.dto.IdxBizJgMainPartsDto;
import com.yeejoin.amos.boot.module.ymt.api.dto.IdxBizJgMaintenanceRecordInfoDto;
import com.yeejoin.amos.boot.module.ymt.api.dto.IdxBizJgProtectionDevicesDto;
import com.yeejoin.amos.boot.module.ymt.api.dto.IdxBizJgRegisterInfoDto;
import com.yeejoin.amos.boot.module.ymt.api.entity.*;
import com.yeejoin.amos.boot.module.ymt.api.enums.EquimentEnum;
import com.yeejoin.amos.boot.module.ymt.api.mapper.CategoryOtherInfoMapper;
import com.yeejoin.amos.boot.module.ymt.api.mapper.IdxBizJgRegisterInfoMapper;
import com.yeejoin.amos.boot.module.ymt.api.mapper.SuperviseInfoMapper;
import com.yeejoin.amos.feign.privilege.Privilege;
import com.yeejoin.amos.feign.privilege.model.CompanyModel;
import org.apache.commons.collections.CollectionUtils;
import org.apache.lucene.queryparser.classic.QueryParser;
......@@ -30,7 +27,6 @@ import org.elasticsearch.action.search.SearchRequest;
import org.elasticsearch.action.search.SearchResponse;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.common.recycler.Recycler;
import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.search.builder.SearchSourceBuilder;
......@@ -69,13 +65,6 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
private static final String EQUDEFINE = "EQU_DEFINE";
private static final String EQUDEFINECODE = "EQU_DEFINE_CODE";
/**
* levlel=company,是企业,如果不是都是监管单位,
* * 在接口中查询当前登录人所属单位是监管单位还是企业。
* * 如果为监管单位添加监管机构查询参数(ORG_BRANCH_CODE);
* * 如果为企业添加使用单位查询参数(USE_UNIT_CREDIT_CODE)
*/
private static final String LEVEL = "company";
// 新增修改标识
private static final String OPERATESAVE = "save";
private static final String OPERATEEDIT = "edit";
......@@ -123,6 +112,7 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
@Autowired
private SuperviseInfoMapper superviseInfoMapper;
/**
* 设备注册信息
*
......@@ -541,53 +531,32 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
builder.trackTotalHits(true);
BoolQueryBuilder boolMust = QueryBuilders.boolQuery();
//获取当前登录人单位类型
JSONObject company = getCompanyType();
if (ValidationUtil.isEmpty(company)) {
result.setRecords(new ArrayList<>());
result.setTotal(0);
return result;
}
String companyCode = company.getString("companyCode").contains("_") ?
company.getString("companyCode").split("_")[1] : company.getString("companyCode");
String type = company.getString("companyType");
if (ValidationUtil.isEmpty(type) || ValidationUtil.isEmpty(companyCode)) {
result.setRecords(new ArrayList<>());
result.setTotal(0);
return result;
}
//根据当前登录人查询
if (!ValidationUtil.isEmpty(map.get(EQUSTATE))) {
map.put(EQUSTATE, EquimentEnum.getCode.get(map.get(EQUSTATE).toString()).toString());
}
//获取当前登录人单位类型
List<JSONObject> companyType = getCompanyType();
if (!ValidationUtil.isEmpty(companyType)) {
JSONObject object = getCompanyType().get(0);
String level = object.getString("level");
String code = object.getString("orgCode");
String companyCode = object.getString("companyCode").contains("_") ?
object.getString("companyCode").split("_")[1] : object.getString("companyCode");
String type = object.getString("companyType");
// 根据当前登录用户类型及管辖机构筛选条件添加对应参数
if (!ValidationUtil.isEmpty(level)) {
if (LEVEL.equals(level)) {
//企业
if (!ValidationUtil.isEmpty(type) && ValidationUtil.equals(type, "使用单位")) {
map.put("USE_UNIT_CREDIT_CODE", companyCode);
} else if (!ValidationUtil.isEmpty(type) && ValidationUtil.equals(type, "安装改造维修单位")) {
map.put("USC_UNIT_CREDIT_CODE", companyCode);
}
if (!ObjectUtils.isEmpty(map.getString("ORG_BRANCH_CODE"))) {
BoolQueryBuilder query = QueryBuilders.boolQuery();
String test = QueryParser.escape(map.getString("ORG_BRANCH_CODE"));
query.must(QueryBuilders.matchPhrasePrefixQuery("ORG_BRANCH_CODE", test));
boolMust.must(query);
}
} else {
if (!ObjectUtils.isEmpty(map.getString("ORG_BRANCH_CODE"))) {
String paramCode = map.getString("ORG_BRANCH_CODE");
if (paramCode.contains(code)) {
BoolQueryBuilder query = QueryBuilders.boolQuery();
String test = QueryParser.escape(map.getString("ORG_BRANCH_CODE"));
query.must(QueryBuilders.matchPhrasePrefixQuery("ORG_BRANCH_CODE", test));
boolMust.must(query);
} else {
return result;
}
} else {
//监管单位
map.put("ORG_BRANCH_CODE", code);
}
}
}
// 根据当前登录用户类型及管辖机构筛选条件添加对应参数
if (!ValidationUtil.isEmpty(type) && ValidationUtil.equals(type, "使用单位")) {
map.put("USE_UNIT_CREDIT_CODE", companyCode);
} else if (!ValidationUtil.isEmpty(type) && ValidationUtil.equals(type, "安装改造维修单位")) {
map.put("USC_UNIT_CREDIT_CODE", companyCode);
}
// 默认条件【STATUS==="" || null】
......@@ -732,23 +701,22 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
*
* @return
*/
public List<JSONObject> getCompanyType() {
public JSONObject getCompanyType() {
ReginParams reginParams = JSON.parseObject(redisUtils.get(RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken())).toString(), ReginParams.class);
List<CompanyModel> companys = reginParams.getUserModel().getCompanys();
ReginParams reginParams = JSONObject.parseObject(redisUtils.get(RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken())).toString(), ReginParams.class);
CompanyBo company = reginParams.getCompany();
List<JSONObject> objectList = new ArrayList<>();
if (!ValidationUtil.isEmpty(companys)) {
for (CompanyModel company : companys) {
JSONObject object = new JSONObject();
object.put("level", company.getLevel());
object.put("orgCode", company.getOrgCode());
object.put("companyCode", company.getCompanyCode());
object.put("companyType", company.getCompanyType());
objectList.add(object);
JSONObject object = new JSONObject();
if (!ValidationUtil.isEmpty(company)) {
object.put("level", company.getLevel());
object.put("orgCode", company.getOrgCode());
object.put("companyCode", company.getCompanyCode());
CompanyModel result = Privilege.companyClient.queryByCompanyCode(company.getCompanyCode()).getResult();
if(!ValidationUtil.isEmpty(result)){
object.put("companyType", result.getCompanyType());
}
}
return objectList;
return object;
}
private String batchSubmitOrUpdate(Map<String, Object> map) {
......
......@@ -704,11 +704,11 @@ public class JgChangeRegistrationUnitServiceImpl extends BaseService<JgChangeReg
throw new BadRequest("使用登记证导出失败,请稍后重试!");
}
//是否废弃
exportParamsMap.put("isInvalid", jgChangeRegistrationUnitEq.getIsInvalid());
exportParamsMap.put("isInvalid", ValidationUtil.isEmpty(jgChangeRegistrationUnitEq.getIsInvalid()) ? "0" : jgChangeRegistrationUnitEq.getIsInvalid());
//登记机关
exportParamsMap.put("receiveOrgName", transfer.getReceiveOrgName());
//使用登记证编号
exportParamsMap.put("useRegistrationCode", transfer.getUseRegistCode());
exportParamsMap.put("useRegistrationCode", ValidationUtil.isEmpty(transfer.getUseRegistCode()) ? "" : transfer.getUseRegistCode());
//使用单位名称
exportParamsMap.put("useUnitName", transfer.getUseUnitName());
//监管码
......@@ -733,15 +733,17 @@ public class JgChangeRegistrationUnitServiceImpl extends BaseService<JgChangeReg
String equDefine = registerInfo.getEquDefine();//设备品种
List<EquipmentCategory> categoryList0 = commonService.getEquipmentCategoryList(equList, null);
List<EquipmentCategory> categoryList1 = commonService.getEquipmentCategoryList(equCategory, null);
List<EquipmentCategory> categoryList2 = commonService.getEquipmentCategoryList(equDefine, null);
if (org.apache.commons.collections.CollectionUtils.isNotEmpty(categoryList1)) {
exportParamsMap.put("equList", categoryList0.get(0).getName());
}
if (org.apache.commons.collections.CollectionUtils.isNotEmpty(categoryList1)) {
exportParamsMap.put("equCategory", categoryList1.get(0).getName());
}
if (org.apache.commons.collections.CollectionUtils.isNotEmpty(categoryList2)) {
exportParamsMap.put("equDefine", categoryList2.get(0).getName());
if(!ValidationUtil.isEmpty(equDefine)) {
List<EquipmentCategory> categoryList2 = commonService.getEquipmentCategoryList(equDefine, null);
if (org.apache.commons.collections.CollectionUtils.isNotEmpty(categoryList2)) {
exportParamsMap.put("equDefine", categoryList2.get(0).getName());
}
}
//设备代码
exportParamsMap.put("equCode", registerInfo.getEquCode());
......@@ -753,11 +755,11 @@ public class JgChangeRegistrationUnitServiceImpl extends BaseService<JgChangeReg
exportParamsMap.put("useInnerCode", useInfo.getUseInnerCode());
String fullAddress="";
String province = useInfo.getProvinceName();
String city = useInfo.getCityName();
String county = useInfo.getCountyName();
String street = useInfo.getStreetName();
String address = useInfo.getAddress();
String province = ValidationUtil.isEmpty(useInfo.getProvinceName()) ? "" : useInfo.getProvinceName();
String city = ValidationUtil.isEmpty(useInfo.getCityName()) ? "" : useInfo.getCityName();
String county = ValidationUtil.isEmpty(useInfo.getCountyName()) ? "" : useInfo.getCountyName();
String street = ValidationUtil.isEmpty(useInfo.getStreetName()) ? "" : useInfo.getStreetName();
String address = ValidationUtil.isEmpty(useInfo.getAddress()) ? "" : useInfo.getAddress();
fullAddress = province + city + county + street + address;
exportParamsMap.put("fullAddress", fullAddress);
}
......
......@@ -65,6 +65,7 @@ import java.nio.file.Files;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import javax.servlet.http.HttpServletResponse;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
......@@ -310,7 +311,7 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN
* @return pdf文件路径
*/
@Override
public String generateInstallationNoticeReport(Long sequenceNbr) {
public void generateInstallationNoticeReport(Long sequenceNbr, HttpServletResponse response) {
if (Objects.isNull(sequenceNbr)) {
throw new IllegalArgumentException("参数不能为空");
}
......@@ -322,7 +323,7 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN
}
Map<String, Object> installation = informationList.get(0);
String useCode = String.valueOf(installation.get("useCode"));
String useCode = String.valueOf(installation.get("installUnitCreditCode"));
LambdaQueryWrapper<TzBaseUnitLicence> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(TzBaseUnitLicence::getUnitCode, useCode);
List<TzBaseUnitLicence> list = baseUnitLicenceMapper.selectList(wrapper);
......@@ -372,13 +373,15 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN
String qrCode = ImageUtils.generateQRCode(getValue.apply("applyNo"), 300, 300);
placeholders.put("qrCode", qrCode);
String url = WordTemplateUtils.templateToPdf("installation-notification-report.ftl", placeholders);
// String url = WordTemplateUtils.templateToPdf("installation-notification-report.ftl", placeholders);
// 更新到数据库
jgInstallationNotice.setNoticeReportUrl(url);
this.updateById(jgInstallationNotice);
return url;
// jgInstallationNotice.setNoticeReportUrl(url);
// this.updateById(jgInstallationNotice);
//
// return url;
String tempFileName = "安装告知单_" + System.currentTimeMillis() + "_temp";
WordTemplateUtils.templateToPdfDownload(tempFileName, "installation-notification-report.ftl", placeholders, response);
}
@Override
......@@ -776,12 +779,12 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN
useInfoService.saveOrUpdateData(useInfo);
}
TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() {
@Override
public void afterCommit() {
generateInstallationNoticeReport(jgInstallationNotice.getSequenceNbr());
}
});
// TransactionSynchronizationManager.registerSynchronization(new TransactionSynchronization() {
// @Override
// public void afterCommit() {
// generateInstallationNoticeReport(jgInstallationNotice.getSequenceNbr());
// }
// });
} else {
jgInstallationNotice.setNextExecuteIds(String.join(",", roleList));
if (!ObjectUtils.isEmpty(jgInstallationNotice.getInstanceStatus())) {
......
......@@ -318,7 +318,8 @@ public class JgMaintainNoticeServiceImpl extends BaseService<JgMaintainNoticeDto
placeholders.put("qrCode", qrCode);
placeholders.put("installLicenseNoList", installLicenseNoList);//许可证编号
placeholders.put("installLicenseExpirationDateList", installLicenseExpirationDateList);//许可证有效期
String url = WordTemplateUtils.templateToPdf("installation-notification-report.ftl", placeholders);
String tempFileName = "安装告知单_" + System.currentTimeMillis() + "_temp";
String url = WordTemplateUtils.templateToPdf(tempFileName, "installation-notification-report.ftl", placeholders);
// 更新到数据库
JgMaintainNotice.setNoticeReportUrl(url);
this.updateById(JgMaintainNotice);
......
......@@ -344,7 +344,8 @@ public class JgReformNoticeServiceImpl extends BaseService<JgReformNoticeDto, Jg
placeholders.put("installLicenseNoList", installLicenseNoList);
placeholders.put("installLicenseExpirationDateList", installLicenseExpirationDateList);
log.info("改造告知单 => {}", JSON.toJSONString(placeholders));
String url = WordTemplateUtils.templateToPdf("installation-notification-report.ftl", placeholders);
String tempFileName = "安装告知单_" + System.currentTimeMillis() + "_temp";
String url = WordTemplateUtils.templateToPdf(tempFileName, "installation-notification-report.ftl", placeholders);
// 更新到数据库
JgReformNotice.setNoticeReportUrl(url);
......
......@@ -175,7 +175,7 @@ public class JgTransferNoticeServiceImpl extends BaseService<JgTransferNoticeDto
}
Map<String, Object> maintain = informationList.get(0);
String useCode = String.valueOf(maintain.get("useCode"));
String useCode = String.valueOf(maintain.get("installUnitCreditCode"));
LambdaQueryWrapper<TzBaseUnitLicence> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(TzBaseUnitLicence::getUnitCode, useCode);
List<TzBaseUnitLicence> list = baseUnitLicenceMapper.selectList(wrapper);
......@@ -223,8 +223,8 @@ public class JgTransferNoticeServiceImpl extends BaseService<JgTransferNoticeDto
placeholders.put("installLicenseNoList", installLicenseNoList);
placeholders.put("installLicenseExpirationDateList", installLicenseExpirationDateList);
String url = WordTemplateUtils.templateToPdf("installation-notification-report.ftl", placeholders);
String tempFileName = "安装告知单_" + System.currentTimeMillis() + "_temp";
String url = WordTemplateUtils.templateToPdf(tempFileName, "installation-notification-report.ftl", placeholders);
// 更新到数据库
jgTransferNotice.setNoticeReportUrl(url);
......
......@@ -13,7 +13,9 @@ import lombok.extern.slf4j.Slf4j;
import org.springframework.util.Assert;
import org.springframework.util.StringUtils;
import org.springframework.web.multipart.MultipartFile;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
......@@ -131,11 +133,11 @@ public class WordTemplateUtils {
return result;
}
public static String templateToPdf(String wordPath, Map<String, Object> placeholders) {
public static String templateToPdf(String pdfName, String wordPath, Map<String, Object> placeholders) {
// word转pdf
File pdfFile;
try {
pdfFile = wordToPdf(wordPath, placeholders);
pdfFile = wordToPdf(pdfName, wordPath, placeholders);
} catch (Exception e) {
throw new RuntimeException(e);
}
......@@ -152,7 +154,33 @@ public class WordTemplateUtils {
return url;
}
public static byte[] file2byte(File file) {
public static void templateToPdfDownload(String pdfName, String wordPath, Map<String, Object> placeholders, HttpServletResponse response) {
// word转pdf
File pdfFile;
try {
pdfFile = wordToPdf(pdfName, wordPath, placeholders);
} catch (Exception e) {
log.error("模板转pdf失败:", e);
throw new BadRequest("模板转pdf失败");
}
try {
byte[] bytes = file2byte(pdfFile);
String docTitle = pdfFile.getName();
FileExporter.exportFile(FileExporter.FileType.valueOf("pdf"), docTitle, bytes, response);
} catch (Exception e) {
log.error("文档导出失败:", e);
} finally {
try {
Files.deleteIfExists(pdfFile.toPath());
} catch (Exception e) {
log.error("文件找不到,删除失败:", e);
}
}
}
private static byte[] file2byte(File file) {
try {
FileInputStream in = new FileInputStream(file);
//当文件没有结束时,每次读取一个字节显示
......@@ -191,13 +219,11 @@ public class WordTemplateUtils {
*
* @param wordPath word文件路径
*/
private static File wordToPdf(String wordPath, Map<String, Object> placeholders) throws Exception {
private static File wordToPdf(String pdfName, String wordPath, Map<String, Object> placeholders) throws Exception {
Assert.hasText(wordPath, "word文件路径不能为空");
String tempFileName = "安装告知单_" + System.currentTimeMillis() + "_temp.pdf";
WordTemplateUtils instance = WordTemplateUtils.getInstance();
return instance.fillAndConvertDocFile(wordPath, tempFileName, placeholders, SaveFormat.PDF);
return instance.fillAndConvertDocFile(wordPath, pdfName, placeholders, SaveFormat.PDF);
}
}
package com.yeejoin.amos.boot.module.ymt.biz.config;
import org.apache.http.HttpHost;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.CredentialsProvider;
import org.apache.http.impl.client.BasicCredentialsProvider;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestClientBuilder;
import org.elasticsearch.client.RestHighLevelClient;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import java.util.Arrays;
@Configuration
public class ElasticSearchClientConfig {
@Value("${spring.elasticsearch.rest.uris}")
private String uris;
@Value("${elasticsearch.username}")
private String username;
@Value("${elasticsearch.password}")
private String password;
@Bean(destroyMethod = "close")
public RestHighLevelClient restHighLevelClient() {
final CredentialsProvider credentialsProvider = new BasicCredentialsProvider();
credentialsProvider.setCredentials(AuthScope.ANY,
new UsernamePasswordCredentials(username, password));
try {
HttpHost[] httpHosts = Arrays.stream(uris.split(",")).map(HttpHost::create).toArray(HttpHost[]::new);
RestClientBuilder builder = RestClient.builder(httpHosts);
builder.setHttpClientConfigCallback(httpClientBuilder -> {
httpClientBuilder.disableAuthCaching();
return httpClientBuilder.setDefaultCredentialsProvider(credentialsProvider);
});
// 该方法接收一个RequestConfig.Builder对象,对该对象进行修改后然后返回。
builder.setRequestConfigCallback(requestConfigBuilder -> {
// 连接超时(默认为1秒)
return requestConfigBuilder.setConnectTimeout(5000 * 1000)
// 套接字超时(默认为30秒)//更改客户端的超时限制默认30秒现在改为100*1000分钟
.setSocketTimeout(6000 * 1000);
});
return new RestHighLevelClient(builder);
} catch (Exception e) {
throw new IllegalStateException("Invalid ES nodes " + "property '" + uris + "'", e);
}
}
}
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