Commit deb25b37 authored by caotao's avatar caotao

改造登记新增导出使用登记证接口。

parent cb3dc02d
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);
}
......@@ -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);
}
}
......@@ -15,13 +15,13 @@ 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.service.IJgChangeRegistrationReformService;
import com.yeejoin.amos.boot.module.jg.api.dto.JgChangeRegistrationReformDto;
import com.yeejoin.amos.boot.module.jg.api.service.IJgRegistrationHistoryService;
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.service.IIdxBizJgRegisterInfoService;
import com.yeejoin.amos.boot.module.jg.biz.service.IIdxBizJgUseInfoService;
import com.yeejoin.amos.boot.module.jg.flc.api.fegin.WorkFlowFeignService;
import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgTechParamsElevator;
import com.yeejoin.amos.boot.module.ymt.api.entity.InspectionDetectionInfo;
import com.yeejoin.amos.boot.module.ymt.api.entity.OtherInfo;
import com.yeejoin.amos.boot.module.ymt.api.entity.UseInfo;
import com.yeejoin.amos.boot.module.ymt.api.entity.*;
import com.yeejoin.amos.boot.module.ymt.api.enums.ApplicationFormTypeEnum;
import com.yeejoin.amos.boot.module.ymt.api.enums.FlowStatusEnum;
import com.yeejoin.amos.boot.module.ymt.api.mapper.*;
......@@ -30,15 +30,20 @@ import com.yeejoin.amos.feign.workflow.Workflow;
import com.yeejoin.amos.feign.workflow.model.ActWorkflowStartDTO;
import com.yeejoin.amos.feign.workflow.model.AjaxResult;
import com.yeejoin.amos.feign.workflow.model.TaskResultDTO;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ObjectUtils;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.rdbms.service.BaseService;
import org.springframework.stereotype.Service;
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 javax.servlet.http.HttpServletResponse;
import java.time.LocalDate;
import java.util.*;
import java.util.stream.Collectors;
......@@ -51,15 +56,22 @@ import java.util.stream.Collectors;
@Service
public class JgChangeRegistrationReformServiceImpl extends BaseService<JgChangeRegistrationReformDto, JgChangeRegistrationReform, JgChangeRegistrationReformMapper> implements IJgChangeRegistrationReformService {
@Autowired
IIdxBizJgRegisterInfoService idxBizJgRegisterInfoService;
@Autowired
WorkFlowFeignService workFlowFeginService;
@Autowired
TzsServiceFeignClient tzsServiceFeignClient;
@Autowired
RedisUtils redisUtils;
@Autowired
ICommonService commonService;
@Autowired
private IIdxBizJgUseInfoService useInfoService;
@Autowired
private IdxBizJgUseInfoServiceImpl idxBizJgUseInfoService;
@Autowired
private IdxBizJgRegisterInfoServiceImpl idxBizJgRegisterInfoService;
@Autowired
private IdxBizJgFactoryInfoServiceImpl idxBizJgFactoryInfoService;
@Autowired
private UseInfoMapper useInfoMapper;
@Autowired
private InspectionDetectionInfoMapper inspectionDetectionInfoMapper;
......@@ -88,6 +100,8 @@ public class JgChangeRegistrationReformServiceImpl extends BaseService<JgChangeR
//更名变更登记关系表mapper
@Autowired
private JgChangeRegistrationNameEqMapper jgChangeRegistrationNameEqMapper;
@Autowired
private IJgRegistrationHistoryService jgRegistrationHistoryService;
/**
* 分页查询
......@@ -108,7 +122,7 @@ public class JgChangeRegistrationReformServiceImpl extends BaseService<JgChangeR
BeanUtil.copyProperties(map, useInfo);
String equipId = map.get("record").toString();
LambdaQueryWrapper<UseInfo> lambda = new QueryWrapper<UseInfo>().lambda();
lambda.eq(UseInfo::getRecord,equipId);
lambda.eq(UseInfo::getRecord, equipId);
// 更新使用信息
useInfoMapper.update(useInfo, lambda);
InspectionDetectionInfo inspectionDetectionInfo = new InspectionDetectionInfo();
......@@ -126,10 +140,10 @@ public class JgChangeRegistrationReformServiceImpl extends BaseService<JgChangeR
jgChangeRegistrationReform.setSupervisoryCode(supervisoryCode);
jgChangeRegistrationReform.setUseUnitName(useInfo.getUseUnitName());
jgChangeRegistrationReform.setUseUnitCreditCode(useInfo.getUseUnitCreditCode());
if(!ObjectUtils.isEmpty(map.get("transformationQualityCertificate"))){
if (!ObjectUtils.isEmpty(map.get("transformationQualityCertificate"))) {
jgChangeRegistrationReform.setTransformationQualityCertificate(JSONObject.toJSONString(map.get("transformationQualityCertificate")));
}
if(!ObjectUtils.isEmpty(map.get("renovationSupervisioninspectionCertificate"))) {
if (!ObjectUtils.isEmpty(map.get("renovationSupervisioninspectionCertificate"))) {
jgChangeRegistrationReform.setRenovationSupervisioninspectionCertificate(JSONObject.toJSONString(map.get("renovationSupervisioninspectionCertificate")));
}
// 使用单位提交
......@@ -181,10 +195,10 @@ public class JgChangeRegistrationReformServiceImpl extends BaseService<JgChangeR
// 业务管理设备信息保存
JgChangeRegistrationReformEq jgChangeRegistrationReformEq = new JgChangeRegistrationReformEq();
jgChangeRegistrationReformEq.setEquId(equipId);
ResponseModel<List<String>> result =tzsServiceFeignClient.applicationFormCode(ApplicationFormTypeEnum.GZBG.getCode(), 1);
if(!result.getResult().isEmpty()){
ResponseModel<List<String>> result = tzsServiceFeignClient.applicationFormCode(ApplicationFormTypeEnum.GZBG.getCode(), 1);
if (!result.getResult().isEmpty()) {
jgChangeRegistrationReform.setApplyNo(result.getResult().get(0));
}else {
} else {
throw new BadRequest("申请单编号生成失败,请稍后重试!");
}
jgChangeRegistrationReform.setAuditStatus(WorkFlowStatusEnum.CHANGE_SUBMIT.getPass());
......@@ -287,7 +301,7 @@ public class JgChangeRegistrationReformServiceImpl extends BaseService<JgChangeR
JgChangeRegistrationReformEq jgChangeRegistrationReformEq = jgChangeRegistrationReformEqMapper.selectOne(new QueryWrapper<JgChangeRegistrationReformEq>().eq("equip_transfer_id", jgChangeRegistrationReform.getSequenceNbr()));
String newUseRegistrationCertificateNumber = getCode(jgChangeRegistrationReform.getSupervisoryCode());
jgChangeRegistrationReform.setUseRegistrationCode(newUseRegistrationCertificateNumber);
updateTechparamsByEquIdAndCurrentDoucumentId(jgChangeRegistrationReformEq.getEquId(), jgChangeRegistrationReform.getSequenceNbr().toString(),newUseRegistrationCertificateNumber,jgChangeRegistrationReform.getApplyNo() );
updateTechparamsByEquIdAndCurrentDoucumentId(jgChangeRegistrationReformEq.getEquId(), jgChangeRegistrationReform.getSequenceNbr().toString(), newUseRegistrationCertificateNumber, jgChangeRegistrationReform.getApplyNo());
}
this.getBaseMapper().updateById(jgChangeRegistrationReform);
}
......@@ -429,7 +443,7 @@ public class JgChangeRegistrationReformServiceImpl extends BaseService<JgChangeR
public void deleteBatch(List<Long> ids) {
List<JgChangeRegistrationReform> jgChangeRegistrationReformList = this.getBaseMapper().selectList(new QueryWrapper<JgChangeRegistrationReform>().in("sequence_nbr", ids));
List<String> applyNos =jgChangeRegistrationReformList.stream().map(JgChangeRegistrationReform::getApplyNo).collect(Collectors.toList());
List<String> applyNos = jgChangeRegistrationReformList.stream().map(JgChangeRegistrationReform::getApplyNo).collect(Collectors.toList());
JgChangeRegistrationReform jgChangeRegistrationReform = new JgChangeRegistrationReform();
jgChangeRegistrationReform.setIsDelete(true);
LambdaQueryWrapper<JgChangeRegistrationReform> lambda = new QueryWrapper<JgChangeRegistrationReform>().lambda();
......@@ -445,7 +459,7 @@ public class JgChangeRegistrationReformServiceImpl extends BaseService<JgChangeR
public Map<String, Object> getDetail(String currentDocumentId, String equipId) {
JgChangeRegistrationReform jgChangeRegistrationReform = this.getBaseMapper().selectById(currentDocumentId);
if(ObjectUtils.isEmpty(equipId)){
if (ObjectUtils.isEmpty(equipId)) {
equipId = jgChangeRegistrationReformEqMapper.selectEquipId(currentDocumentId);
}
Map<String, Object> detail = JSONObject.parseObject(JSONObject.toJSONString(jgChangeRegistrationReform), Map.class);
......@@ -454,10 +468,10 @@ public class JgChangeRegistrationReformServiceImpl extends BaseService<JgChangeR
if ((detail.get("status").equals("已完成") || detail.get("status").equals("流程结束"))) {
originalData = idxBizJgRegisterInfoService.getDetailFieldCamelCaseByRecord(equipId);
originalData.remove("sequenceNbr");
if(!ObjectUtils.isEmpty(detail.get("transformationQualityCertificate"))){
if (!ObjectUtils.isEmpty(detail.get("transformationQualityCertificate"))) {
detail.put("transformationQualityCertificate", JSONObject.parse(detail.get("transformationQualityCertificate").toString()));
}
if(!ObjectUtils.isEmpty(detail.get("renovationSupervisioninspectionCertificate"))){
if (!ObjectUtils.isEmpty(detail.get("renovationSupervisioninspectionCertificate"))) {
detail.put("renovationSupervisioninspectionCertificate", JSONObject.parse(detail.get("renovationSupervisioninspectionCertificate").toString()));
}
} else {
......@@ -495,7 +509,7 @@ public class JgChangeRegistrationReformServiceImpl extends BaseService<JgChangeR
* @param equipId
* @param currentDocumentId
*/
public void updateTechparamsByEquIdAndCurrentDoucumentId(String equipId, String currentDocumentId, String newUseRegistrationCertificateNumber,String applyNo) {
public void updateTechparamsByEquIdAndCurrentDoucumentId(String equipId, String currentDocumentId, String newUseRegistrationCertificateNumber, String applyNo) {
IdxBizJgTechParamsElevator idxBizJgTechParamsElevator = idxBizJgTechParamsElevatorMapper.selectOne(new QueryWrapper<IdxBizJgTechParamsElevator>().eq("RECORD", equipId));
JgRegistrationHistory jgRegistrationHistory = jgRegistrationHistoryMapper.selectOne(new QueryWrapper<JgRegistrationHistory>()
......@@ -559,4 +573,122 @@ public class JgChangeRegistrationReformServiceImpl extends BaseService<JgChangeR
}
return null;
}
@Override
public void exportUseRegistrationCertificate(String sequenceNbr, HttpServletResponse response) {
Map<String, Object> exportParamsMap = new HashMap<>();
//查询移装变更详情
JgChangeRegistrationReform jgChangeRegistrationReform = this.getById(sequenceNbr);
JgChangeRegistrationReformEq jgChangeRegistrationReformEq = jgChangeRegistrationReformEqMapper.selectOne(new QueryWrapper<JgChangeRegistrationReformEq>().eq("equip_transfer_id", sequenceNbr));
if (ValidationUtil.isEmpty(jgChangeRegistrationReform) || ValidationUtil.isEmpty(jgChangeRegistrationReformEq)) {
throw new BadRequest("使用登记证导出失败,请稍后重试!");
}
//是否废弃
exportParamsMap.put("isInvalid", jgChangeRegistrationReformEq.getIsInvalid());
if (ValidationUtil.isEmpty(jgChangeRegistrationReform.getReceiveOrgName())) {
throw new BadRequest("使用登记证导出失败,登记机关为空!");
}
exportParamsMap.put("receiveOrgName", jgChangeRegistrationReform.getReceiveOrgName());
//使用登记证编号
if (ValidationUtil.isEmpty(jgChangeRegistrationReform.getUseRegistrationCode())) {
throw new BadRequest("使用登记证导出失败,使用登记证编号为空!");
}
exportParamsMap.put("useRegistrationCode", jgChangeRegistrationReform.getUseRegistrationCode());
//使用单位名称
if (ValidationUtil.isEmpty(jgChangeRegistrationReform.getUseUnitName())) {
throw new BadRequest("使用登记证导出失败,使用单位名称为空!");
}
exportParamsMap.put("useUnitName", jgChangeRegistrationReform.getUseUnitName());
//监管码
if (ValidationUtil.isEmpty(jgChangeRegistrationReform.getSupervisoryCode())) {
throw new BadRequest("使用登记证导出失败,监管码为空!");
}
exportParamsMap.put("supervisoryCode", jgChangeRegistrationReform.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", jgChangeRegistrationReformEq.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 (CollectionUtils.isNotEmpty(categoryList0)) {
if (ValidationUtil.isEmpty(categoryList0.get(0).getName())) {
throw new BadRequest("使用登记证导出失败,设备种类为空!");
}
exportParamsMap.put("equList", categoryList0.get(0).getName());
}
if (CollectionUtils.isNotEmpty(categoryList1)) {
if (ValidationUtil.isEmpty(categoryList1.get(0).getName())) {
throw new BadRequest("使用登记证导出失败,设备类别为空!");
}
exportParamsMap.put("equCategory", categoryList1.get(0).getName());
}
if (CollectionUtils.isNotEmpty(categoryList2)) {
if (ValidationUtil.isEmpty(categoryList2.get(0).getName())) {
throw new BadRequest("使用登记证导出失败,设备品种为空!");
}
exportParamsMap.put("equDefine", categoryList2.get(0).getName());
}
//设备代码
if (ValidationUtil.isEmpty(registerInfo.getEquCode())) {
throw new BadRequest("使用登记证导出失败,设备代码为空!");
}
exportParamsMap.put("equCode", registerInfo.getEquCode());
}
//单位内部编码
IdxBizJgUseInfo useInfo = idxBizJgUseInfoService.getOneData(jgChangeRegistrationReformEq.getEquId());
if (!ValidationUtil.isEmpty(useInfo)) {
if (ValidationUtil.isEmpty(useInfo.getUseInnerCode())) {
throw new BadRequest("使用登记证导出失败,设备单位内部编码为空!");
}
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();
if (!ObjectUtils.isEmpty(province)) {
fullAddress += province;
}
if (!ObjectUtils.isEmpty(city)) {
fullAddress += city;
}
if (!ObjectUtils.isEmpty(county)) {
fullAddress += county;
}
if (!ObjectUtils.isEmpty(street)) {
fullAddress += street;
}
if (!ObjectUtils.isEmpty(address)) {
fullAddress += address;
}
if (ValidationUtil.isEmpty(fullAddress)) {
throw new BadRequest("使用登记证导出失败,设备使用地址为空!");
}
exportParamsMap.put("fullAddress", fullAddress);
}
IdxBizJgFactoryInfo factoryInfo = idxBizJgFactoryInfoService.getOneData(jgChangeRegistrationReformEq.getEquId());
//产品编号(出厂编号)
if (!ValidationUtil.isEmpty(factoryInfo)) {
if (ValidationUtil.isEmpty(factoryInfo.getFactoryNum())) {
throw new BadRequest("使用登记证导出失败,产品编号为空!");
}
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