Commit e18ff21b authored by liufan's avatar liufan

Merge remote-tracking branch 'origin/develop_tzs_register' into develop_tzs_register

parents c3896f75 a9c5733e
...@@ -145,23 +145,17 @@ public class ControllerAop { ...@@ -145,23 +145,17 @@ public class ControllerAop {
// 验证token有效性,防止token失效 // 验证token有效性,防止token失效
AgencyUserModel userModel; AgencyUserModel userModel;
try { try {
// StopWatch stopWatch = new StopWatch();
// stopWatch.start("1");
String authToken = RedisKey.buildReginKey(RequestContext.getExeUserId(), token); String authToken = RedisKey.buildReginKey(RequestContext.getExeUserId(), token);
if (redisUtils.hasKey(authToken)) { if (redisUtils.hasKey(authToken)) {
logger.info("登录命中缓存 ,直接返回!!===========>"); logger.info("登录命中缓存 ,直接返回!!===========>");
return; return;
} }
// stopWatch.stop(); FeignClientResult<AgencyUserModel> agencyUserModel = Privilege.agencyUserClient.getme();
// logger.info("get auth token count time===========> {}", stopWatch.getTotalTimeSeconds()); userModel = agencyUserModel.getResult();
// stopWatch.start("2"); if (userModel == null) {
// FeignClientResult<AgencyUserModel> agencyUserModel = Privilege.agencyUserClient.getme(); throw new Exception("无法获取用户信息");
// userModel = agencyUserModel.getResult(); }
// if (userModel == null) { RequestContext.setExeUserId(userModel.getUserId());
// throw new Exception("无法获取用户信息");
// }
// RequestContext.setExeUserId(userModel.getUserId());
// logger.info("get me count time===========> {}", stopWatch.getTotalTimeSeconds());
} catch (Exception e) { } catch (Exception e) {
// 删除失效token缓存 // 删除失效token缓存
logger.info("catch pattern before==========>" + pattern); logger.info("catch pattern before==========>" + pattern);
...@@ -169,8 +163,8 @@ public class ControllerAop { ...@@ -169,8 +163,8 @@ public class ControllerAop {
logger.info("catch pattern after==========>" + pattern); logger.info("catch pattern after==========>" + pattern);
throw new RuntimeException(e.getMessage()); throw new RuntimeException(e.getMessage());
} }
// saveUserRedis(userModel, token); saveUserRedis(userModel, token);
saveUserRedis(); // saveUserRedis();
} else { } else {
throw new AuthException("请求未包含认证信息."); throw new AuthException("请求未包含认证信息.");
} }
......
...@@ -15,16 +15,22 @@ import io.swagger.annotations.Api; ...@@ -15,16 +15,22 @@ import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import com.yeejoin.amos.boot.biz.common.controller.BaseController; import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import java.io.*;
import java.net.URLEncoder;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Objects; import java.util.Objects;
import com.yeejoin.amos.boot.module.jg.biz.service.impl.JgChangeRegistrationUnitServiceImpl; import com.yeejoin.amos.boot.module.jg.biz.service.impl.JgChangeRegistrationUnitServiceImpl;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import org.typroject.tyboot.core.restful.utils.ResponseHelper; import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel; import org.typroject.tyboot.core.restful.utils.ResponseModel;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.module.jg.api.dto.JgChangeRegistrationUnitDto; import com.yeejoin.amos.boot.module.jg.api.dto.JgChangeRegistrationUnitDto;
...@@ -177,4 +183,13 @@ public class JgChangeRegistrationUnitController extends BaseController { ...@@ -177,4 +183,13 @@ public class JgChangeRegistrationUnitController extends BaseController {
jgChangeRegistrationUnitServiceImpl.accept(jgInstallationNoticeDto,op); jgChangeRegistrationUnitServiceImpl.accept(jgInstallationNoticeDto,op);
return ResponseHelper.buildResponse(null); return ResponseHelper.buildResponse(null);
} }
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/export")
@ApiOperation(httpMethod = "GET", value = "导出使用登记证", notes = "导出使用登记证")
public void exportImageZip(HttpServletResponse response, @RequestParam("sequenceNbr") String sequenceNbr) throws IOException {
jgChangeRegistrationUnitServiceImpl.exportUseRegistrationCertificate(sequenceNbr, response);
}
} }
...@@ -165,7 +165,7 @@ public class JgTransferNoticeController extends BaseController { ...@@ -165,7 +165,7 @@ public class JgTransferNoticeController extends BaseController {
public void generateCertificateReport(HttpServletResponse response) { public void generateCertificateReport(HttpServletResponse response) {
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
// 组装模板变量 // 组装模板变量
map.put("useRegistrationCode", "202311056"); // 编号 map.put("useRegistrationCode", "202301256456"); // 编号
map.put("useUnitName", "西安市高科物业服务有限公司"); // 使用单位名称 map.put("useUnitName", "西安市高科物业服务有限公司"); // 使用单位名称
map.put("fullAddress", "西安市曲江新区春临东街南湖意境1单元2号楼"); // 设备使用地点 map.put("fullAddress", "西安市曲江新区春临东街南湖意境1单元2号楼"); // 设备使用地点
map.put("equList", "电梯"); // 设备种类 map.put("equList", "电梯"); // 设备种类
......
...@@ -289,21 +289,21 @@ public class CommonServiceImpl implements ICommonService { ...@@ -289,21 +289,21 @@ public class CommonServiceImpl implements ICommonService {
throw new IllegalArgumentException("参数不能为空"); throw new IllegalArgumentException("参数不能为空");
} }
// 组装模板变量 // 组装模板变量
map.put("useRegistrationCode", map.getOrDefault("useRegistrationCode", "").toString()); // 编号 map.put("useRegistrationCode", Optional.ofNullable(map.get("useRegistrationCode")).orElse("").toString()); // 编号
map.put("useUnitName", map.getOrDefault("useUnitName", "").toString()); // 使用单位名称 map.put("useUnitName", Optional.ofNullable(map.get("useUnitName")).orElse("").toString()); // 使用单位名称
map.put("fullAddress", map.getOrDefault("fullAddress", "").toString()); // 设备使用地点 map.put("fullAddress", Optional.ofNullable(map.get("fullAddress")).orElse("").toString()); // 设备使用地点
map.put("equList", map.getOrDefault("equList", "").toString()); // 设备种类 map.put("equList", Optional.ofNullable(map.get("equList")).orElse("").toString()); // 设备种类
map.put("equipDefine", map.getOrDefault("equipDefine", "").toString()); // 设备品种 map.put("equipDefine", Optional.ofNullable(map.get("equipDefine")).orElse("").toString()); // 设备品种
map.put("equipCode", map.getOrDefault("equipCode", "").toString()); // 设备代码 map.put("equipCode", Optional.ofNullable(map.get("equipCode")).orElse("").toString()); // 设备代码
map.put("equipCategory", map.getOrDefault("equipCategory", "").toString()); // 设备类别 map.put("equipCategory", Optional.ofNullable(map.get("equipCategory")).orElse("").toString()); // 设备类别
map.put("useInnerCode", map.getOrDefault("useInnerCode", "").toString()); // 单位内编号 map.put("useInnerCode", Optional.ofNullable(map.get("useInnerCode")).orElse("").toString()); // 单位内编号
map.put("factoryNum", map.getOrDefault("factoryNum", "").toString()); // 产品编号 map.put("factoryNum", Optional.ofNullable(map.get("factoryNum")).orElse("").toString()); // 产品编号
map.put("receiveOrgName", map.getOrDefault("receiveOrgName", "").toString()); // 登记机关 map.put("receiveOrgName", Optional.ofNullable(map.get("receiveOrgName")).orElse("").toString()); // 登记机关
map.put("giveOutYear", map.getOrDefault("giveOutYear", "").toString()); // 发证日期-年 map.put("giveOutYear", Optional.ofNullable(map.get("giveOutYear")).orElse("").toString()); // 发证日期-年
map.put("giveOutMonth", map.getOrDefault("giveOutMonth", "").toString()); // 发证日期-月 map.put("giveOutMonth", Optional.ofNullable(map.get("giveOutMonth")).orElse("").toString()); // 发证日期-月
map.put("giveOutDay", map.getOrDefault("giveOutDay", "").toString()); // 发证日期-日 map.put("giveOutDay", Optional.ofNullable(map.get("giveOutDay")).orElse("").toString()); // 发证日期-日
// 生成二维码 // 生成二维码
String qrCode = ImageUtils.generateQRCode(map.getOrDefault("supervisoryCode", "").toString(), 70, 65); String qrCode = ImageUtils.generateQRCode(Optional.ofNullable(map.get("supervisoryCode")).orElse("").toString(), 70, 65);
map.put("supervisoryCode", qrCode); // 监管二维码 map.put("supervisoryCode", qrCode); // 监管二维码
// word转pdf // word转pdf
...@@ -330,6 +330,12 @@ public class CommonServiceImpl implements ICommonService { ...@@ -330,6 +330,12 @@ public class CommonServiceImpl implements ICommonService {
FileExporter.exportFile(FileExporter.FileType.valueOf("pdf"), docTitle, bytes, response); FileExporter.exportFile(FileExporter.FileType.valueOf("pdf"), docTitle, bytes, response);
} catch (Exception e) { } catch (Exception e) {
log.error("pdf文件转换失败:{}", e); log.error("pdf文件转换失败:{}", e);
} finally {
try {
Files.deleteIfExists(pdfFile.toPath());
} catch (Exception e) {
log.error("文件找不到,删除失败:{}", e);
}
} }
} }
......
...@@ -6,6 +6,7 @@ import com.alibaba.fastjson.JSONArray; ...@@ -6,6 +6,7 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.aspose.words.SaveFormat; import com.aspose.words.SaveFormat;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams; import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.boot.module.jg.api.dto.ByteArrayMultipartFile; import com.yeejoin.amos.boot.module.jg.api.dto.ByteArrayMultipartFile;
import com.yeejoin.amos.boot.module.jg.api.dto.JgChangeRegistrationUnitDto; import com.yeejoin.amos.boot.module.jg.api.dto.JgChangeRegistrationUnitDto;
...@@ -15,11 +16,11 @@ import com.yeejoin.amos.boot.module.jg.api.enums.WorkFlowStatusEnum; ...@@ -15,11 +16,11 @@ import com.yeejoin.amos.boot.module.jg.api.enums.WorkFlowStatusEnum;
import com.yeejoin.amos.boot.module.jg.api.mapper.*; import com.yeejoin.amos.boot.module.jg.api.mapper.*;
import com.yeejoin.amos.boot.module.jg.api.service.IJgChangeRegistrationUnitService; import com.yeejoin.amos.boot.module.jg.api.service.IJgChangeRegistrationUnitService;
import com.yeejoin.amos.boot.module.jg.biz.feign.TzsServiceFeignClient; import com.yeejoin.amos.boot.module.jg.biz.feign.TzsServiceFeignClient;
import com.yeejoin.amos.boot.module.jg.biz.service.ICommonService;
import com.yeejoin.amos.boot.module.jg.biz.utils.ImageUtils; import com.yeejoin.amos.boot.module.jg.biz.utils.ImageUtils;
import com.yeejoin.amos.boot.module.jg.biz.utils.WordTemplateUtils; import com.yeejoin.amos.boot.module.jg.biz.utils.WordTemplateUtils;
import com.yeejoin.amos.boot.module.jg.flc.api.fegin.WorkFlowFeignService; import com.yeejoin.amos.boot.module.jg.flc.api.fegin.WorkFlowFeignService;
import com.yeejoin.amos.boot.module.ymt.api.entity.OtherInfo; import com.yeejoin.amos.boot.module.ymt.api.entity.*;
import com.yeejoin.amos.boot.module.ymt.api.entity.UseInfo;
import com.yeejoin.amos.boot.module.ymt.api.enums.ApplicationFormTypeEnum; import com.yeejoin.amos.boot.module.ymt.api.enums.ApplicationFormTypeEnum;
import com.yeejoin.amos.boot.module.ymt.api.mapper.*; import com.yeejoin.amos.boot.module.ymt.api.mapper.*;
import com.yeejoin.amos.component.feign.model.FeignClientResult; import com.yeejoin.amos.component.feign.model.FeignClientResult;
...@@ -42,12 +43,15 @@ import org.typroject.tyboot.core.foundation.utils.ValidationUtil; ...@@ -42,12 +43,15 @@ import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.rdbms.service.BaseService; import org.typroject.tyboot.core.rdbms.service.BaseService;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import org.typroject.tyboot.core.restful.utils.ResponseModel; import org.typroject.tyboot.core.restful.utils.ResponseModel;
import javax.servlet.http.HttpServletResponse;
import java.io.File; import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.IOException; import java.io.IOException;
import java.nio.file.Files; import java.nio.file.Files;
import java.time.LocalDate;
import java.util.*; import java.util.*;
import java.util.function.Function; import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -112,6 +116,16 @@ public class JgChangeRegistrationUnitServiceImpl extends BaseService<JgChangeReg ...@@ -112,6 +116,16 @@ public class JgChangeRegistrationUnitServiceImpl extends BaseService<JgChangeReg
@Autowired @Autowired
private JgChangeRegistrationNameEqMapper jgChangeRegistrationNameEqMapper; private JgChangeRegistrationNameEqMapper jgChangeRegistrationNameEqMapper;
@Autowired
private IdxBizJgUseInfoServiceImpl idxBizJgUseInfoService;
@Autowired
private IdxBizJgRegisterInfoServiceImpl idxBizJgRegisterInfoService;
@Autowired
private IdxBizJgFactoryInfoServiceImpl idxBizJgFactoryInfoService;
@Autowired
ICommonService commonService;
...@@ -672,4 +686,88 @@ public class JgChangeRegistrationUnitServiceImpl extends BaseService<JgChangeReg ...@@ -672,4 +686,88 @@ public class JgChangeRegistrationUnitServiceImpl extends BaseService<JgChangeReg
} }
return null; return null;
} }
/**
* 导出使用登记证
*
* @param sequenceNbr
*/
public void exportUseRegistrationCertificate(String sequenceNbr , HttpServletResponse response) {
Map<String, Object> exportParamsMap = new HashMap<>();
//查询移装变更详情
JgChangeRegistrationUnit transfer = this.getById(sequenceNbr);
LambdaQueryWrapper<JgChangeRegistrationUnitEq> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(JgChangeRegistrationUnitEq::getUnitChangeRegistrationId,transfer.getSequenceNbr());
JgChangeRegistrationUnitEq jgChangeRegistrationUnitEq = JgChangeRegistrationUnitEqMapper.selectOne(queryWrapper);
if (ValidationUtil.isEmpty(transfer) || ValidationUtil.isEmpty(jgChangeRegistrationUnitEq)) {
throw new BadRequest("使用登记证导出失败,请稍后重试!");
}
//是否废弃
exportParamsMap.put("isInvalid", jgChangeRegistrationUnitEq.getIsInvalid());
//登记机关
exportParamsMap.put("receiveOrgName", transfer.getReceiveOrgName());
//使用登记证编号
exportParamsMap.put("useRegistrationCode", transfer.getUseRegistCode());
//使用单位名称
exportParamsMap.put("useUnitName", transfer.getUseUnitName());
//监管码
LambdaQueryWrapper<OtherInfo> queryWrapper1 = new LambdaQueryWrapper<>();
queryWrapper1.eq(OtherInfo::getRecord,jgChangeRegistrationUnitEq.getEquId());
OtherInfo tzsJgOtherInfo = tzsJgOtherInfoMapper.selectOne(queryWrapper1);
exportParamsMap.put("supervisoryCode", tzsJgOtherInfo.getSupervisoryCode());
//发证日期(当前时间)
LocalDate today = LocalDate.now();
exportParamsMap.put("giveOutYear", today.getYear());
exportParamsMap.put("giveOutMonth", today.getMonthValue());
exportParamsMap.put("giveOutDay", today.getDayOfMonth());
//设备使用地址
//查询设备注册信息
IdxBizJgRegisterInfo registerInfo = idxBizJgRegisterInfoService.getOne(new QueryWrapper<IdxBizJgRegisterInfo>().eq("RECORD", jgChangeRegistrationUnitEq.getEquId()));
if(!ValidationUtil.isEmpty(registerInfo)){
//设备种类、类别、品种
String equList = registerInfo.getEquList();//设备种类
String equCategory = registerInfo.getEquCategory();//设备类别
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());
}
//设备代码
exportParamsMap.put("equCode", registerInfo.getEquCode());
}
//单位内部编码
IdxBizJgUseInfo useInfo = idxBizJgUseInfoService.getOneData(jgChangeRegistrationUnitEq.getEquId());
if(!ValidationUtil.isEmpty(useInfo)){
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();
fullAddress = province + city + county + street + address;
exportParamsMap.put("fullAddress", fullAddress);
}
IdxBizJgFactoryInfo factoryInfo = idxBizJgFactoryInfoService.getOneData(jgChangeRegistrationUnitEq.getEquId());
//产品编号(出厂编号)
if(!ValidationUtil.isEmpty(factoryInfo)){
exportParamsMap.put("factoryNum", factoryInfo.getFactoryNum());
}
//调用生成使用登记证
commonService.generateCertificateReport(exportParamsMap, response);
}
} }
\ No newline at end of file
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