Commit 7b9ba3d9 authored by suhuiguang's avatar suhuiguang

Merge branch 'develop_tzs_register' into develop_tzs_register_jyjc

parents a87647f1 06d54e81
...@@ -112,4 +112,14 @@ public class JgScrapCancelDto extends BaseDto { ...@@ -112,4 +112,14 @@ public class JgScrapCancelDto extends BaseDto {
@ApiModelProperty(value = "设备代号") @ApiModelProperty(value = "设备代号")
private String equList; private String equList;
@ApiModelProperty(value = "设备类别")
private String equCategoryDesc;
@ApiModelProperty(value = "设备名称")
private String productName;
@ApiModelProperty(value = "设备地址")
private String fullAddress;
} }
...@@ -30,6 +30,12 @@ public class JgScrapCancel extends BaseEntity { ...@@ -30,6 +30,12 @@ public class JgScrapCancel extends BaseEntity {
private String cancelType; private String cancelType;
/** /**
* 注销类型(1报废注销,2移装注销)
*/
@TableField(exist = false)
private String cancelTypeDesc;
/**
* 申请编号 * 申请编号
*/ */
@TableField("apply_no") @TableField("apply_no")
...@@ -157,4 +163,16 @@ public class JgScrapCancel extends BaseEntity { ...@@ -157,4 +163,16 @@ public class JgScrapCancel extends BaseEntity {
@TableField(exist = false) @TableField(exist = false)
private String equList; private String equList;
@TableField(exist = false)
private String equListDesc;
@TableField(exist = false)
private String equCategoryDesc;
@TableField(exist = false)
private String productName;
@TableField(exist = false)
private String fullAddress;
} }
...@@ -78,5 +78,5 @@ public interface IJgChangeRegistrationReformService { ...@@ -78,5 +78,5 @@ public interface IJgChangeRegistrationReformService {
* @param sequenceNbr * @param sequenceNbr
* @param response * @param response
*/ */
void exportUseRegistrationCertificate(String sequenceNbr, HttpServletResponse response); void exportUseRegistrationCertificate(String sequenceNbr, HttpServletResponse response, String printType);
} }
...@@ -35,5 +35,7 @@ public interface IJgChangeRegistrationTransferService extends IService<JgChangeR ...@@ -35,5 +35,7 @@ public interface IJgChangeRegistrationTransferService extends IService<JgChangeR
void revocation(String instanceId); void revocation(String instanceId);
void exportUseRegistrationCertificate(String sequenceNbr, HttpServletResponse response); void exportUseRegistrationCertificate(String sequenceNbr, HttpServletResponse response, String printType);
Map<String, Object> getDetailFieldCamelCase(String record);
} }
...@@ -121,10 +121,17 @@ public class JgChangeRegistrationReformController extends BaseController { ...@@ -121,10 +121,17 @@ public class JgChangeRegistrationReformController extends BaseController {
return ResponseHelper.buildResponse(map); return ResponseHelper.buildResponse(map);
} }
/**
* 改造登记-导出使用登记证
* @param response 返回
* @param sequenceNbr 主键
* @param printType 打印类型,0-正常打印,1-套打(默认0)
*/
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/export") @GetMapping(value = "/export")
@ApiOperation(httpMethod = "GET", value = "改造登记-导出使用登记证", notes = "改造登记-导出使用登记证") @ApiOperation(httpMethod = "GET", value = "改造登记-导出使用登记证", notes = "改造登记-导出使用登记证")
public void exportImageZip(HttpServletResponse response, @RequestParam("sequenceNbr") String sequenceNbr){ public void exportImageZip(HttpServletResponse response, @RequestParam("sequenceNbr") String sequenceNbr,
jgChangeRegistrationReformServiceImpl.exportUseRegistrationCertificate(sequenceNbr, response); @RequestParam(value = "printType", defaultValue = "0") String printType){
jgChangeRegistrationReformServiceImpl.exportUseRegistrationCertificate(sequenceNbr, response, printType);
} }
} }
...@@ -5,6 +5,7 @@ import com.netflix.ribbon.proxy.annotation.Http; ...@@ -5,6 +5,7 @@ import com.netflix.ribbon.proxy.annotation.Http;
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.service.IJgChangeRegistrationTransferService; import com.yeejoin.amos.boot.module.jg.api.service.IJgChangeRegistrationTransferService;
import com.yeejoin.amos.boot.module.jg.api.service.IJgInstallationNoticeService; import com.yeejoin.amos.boot.module.jg.api.service.IJgInstallationNoticeService;
import com.yeejoin.amos.boot.module.jg.biz.service.impl.IdxBizJgRegisterInfoServiceImpl;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
...@@ -156,11 +157,23 @@ public class JgChangeRegistrationTransferController extends BaseController { ...@@ -156,11 +157,23 @@ public class JgChangeRegistrationTransferController extends BaseController {
return ResponseHelper.buildResponse(jgChangeRegistrationTransferService.queryListForPage(page,params, type)); return ResponseHelper.buildResponse(jgChangeRegistrationTransferService.queryListForPage(page,params, type));
} }
/**
* 导出使用登记证
* @param response 返回
* @param sequenceNbr 主键
* @param printType 打印类型,0-正常打印,1-套打(默认0)
*/
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/export") @GetMapping(value = "/export")
@ApiOperation(httpMethod = "GET", value = "导出使用登记证", notes = "导出使用登记证") @ApiOperation(httpMethod = "GET", value = "导出使用登记证", notes = "导出使用登记证")
public void exportImageZip(HttpServletResponse response, @RequestParam("sequenceNbr") String sequenceNbr){ public void exportImageZip(HttpServletResponse response, @RequestParam("sequenceNbr") String sequenceNbr,
jgChangeRegistrationTransferService.exportUseRegistrationCertificate(sequenceNbr, response); @RequestParam(value = "printType", defaultValue = "0") String printType){
jgChangeRegistrationTransferService.exportUseRegistrationCertificate(sequenceNbr, response, printType);
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping (value = "/detailFieldCamelCase")
@ApiOperation(httpMethod = "GET", value = "根据record查询设备注册信息详情,返回字段驼峰命名", notes = "根据record查询设备注册信息详情,返回字段驼峰命名")
public ResponseModel<Map<String, Object>> getDetailFieldCamelCase(@RequestParam String record) {
return ResponseHelper.buildResponse(jgChangeRegistrationTransferService.getDetailFieldCamelCase(record));
} }
} }
...@@ -199,11 +199,18 @@ public class JgChangeRegistrationUnitController extends BaseController { ...@@ -199,11 +199,18 @@ public class JgChangeRegistrationUnitController extends BaseController {
} }
/**
* 导出使用登记证
* @param response 返回
* @param sequenceNbr 主键
* @param printType 打印类型,0-正常打印,1-套打(默认0)
*/
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/export") @GetMapping(value = "/export")
@ApiOperation(httpMethod = "GET", value = "导出使用登记证", notes = "导出使用登记证") @ApiOperation(httpMethod = "GET", value = "导出使用登记证", notes = "导出使用登记证")
public void exportImageZip(HttpServletResponse response, @RequestParam("sequenceNbr") String sequenceNbr) throws IOException { public void exportImageZip(HttpServletResponse response, @RequestParam("sequenceNbr") String sequenceNbr,
jgChangeRegistrationUnitServiceImpl.exportUseRegistrationCertificate(sequenceNbr, response); @RequestParam(value = "printType", defaultValue = "0") String printType) {
jgChangeRegistrationUnitServiceImpl.exportUseRegistrationCertificate(sequenceNbr, response, printType);
} }
} }
...@@ -22,11 +22,8 @@ import org.typroject.tyboot.core.foundation.enumeration.UserType; ...@@ -22,11 +22,8 @@ import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation; import org.typroject.tyboot.core.restful.doc.TycloudOperation;
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 javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpServletResponseWrapper;
import java.io.File;
import java.util.*; import java.util.*;
/** /**
...@@ -195,4 +192,25 @@ public class JgTransferNoticeController extends BaseController { ...@@ -195,4 +192,25 @@ public class JgTransferNoticeController extends BaseController {
map.put("supervisoryCode", "YZGZ20231225001"); // 监管二维码 map.put("supervisoryCode", "YZGZ20231225001"); // 监管二维码
commonService.generateCertificateReport(map, response); commonService.generateCertificateReport(map, response);
} }
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET", value = "(测试使用)特种设备登记证套打", notes = "(测试使用)特种设备登记证套打")
@GetMapping(value = "/generate/pdf/print")
public void printing(HttpServletResponse response) {
Map<String, Object> map = new HashMap<>();
map.put("useRegistrationCode", "梯10 陕B00005(24)");
map.put("useUnitName", "西安市高科物业服务有限公司");
map.put("fullAddress", "西安市曲江新区春临东街南湖意境1单元2号楼");
map.put("equList", "场(厂)内专用机动车辆");
map.put("equDefine", "特种气瓶(内装填料气瓶、纤维缠绕气瓶、低温绝热气瓶)");
map.put("equCode", "31006102002024010001");
map.put("equCategory", "非公路用旅游观光车辆");
map.put("useInnerCode", "NBBH-1231231231");
map.put("factoryNum", "CCBH-2312312312");
map.put("giveOutYear", "2024");
map.put("giveOutMonth", "12");
map.put("giveOutDay", "26");
map.put("supervisoryCode", "YZGZ20231225001");
commonService.generatePdfPrint(map, response);
}
} }
...@@ -145,8 +145,9 @@ public class JgUseRegistrationController extends BaseController { ...@@ -145,8 +145,9 @@ public class JgUseRegistrationController extends BaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/export") @GetMapping(value = "/export")
@ApiOperation(httpMethod = "GET", value = "导出使用登记证", notes = "导出使用登记证") @ApiOperation(httpMethod = "GET", value = "导出使用登记证", notes = "导出使用登记证")
public void exportImageZip(HttpServletResponse response, @RequestParam("sequenceNbr") String sequenceNbr) { public void exportImageZip(HttpServletResponse response, @RequestParam("sequenceNbr") String sequenceNbr,
jgUseRegistrationServiceImpl.exportUseRegistrationCertificate(sequenceNbr, response); @RequestParam(value = "printType", defaultValue = "0") String printType) {
jgUseRegistrationServiceImpl.exportUseRegistrationCertificate(sequenceNbr, response, printType);
} }
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
......
...@@ -38,6 +38,8 @@ public interface ICommonService { ...@@ -38,6 +38,8 @@ public interface ICommonService {
void generateCertificateReport(Map<String, Object> map, HttpServletResponse response); void generateCertificateReport(Map<String, Object> map, HttpServletResponse response);
void generatePdfPrint(Map<String, Object> map, HttpServletResponse response);
List<LinkedHashMap> creatApproveTree(); List<LinkedHashMap> creatApproveTree();
List<Map<String, Object>> superviseBusinessCategory(String type); List<Map<String, Object>> superviseBusinessCategory(String type);
......
...@@ -2,10 +2,16 @@ package com.yeejoin.amos.boot.module.jg.biz.service.impl; ...@@ -2,10 +2,16 @@ package com.yeejoin.amos.boot.module.jg.biz.service.impl;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.io.IoUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
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.itextpdf.text.DocumentException;
import com.itextpdf.text.pdf.AcroFields;
import com.itextpdf.text.pdf.BaseFont;
import com.itextpdf.text.pdf.PdfReader;
import com.itextpdf.text.pdf.PdfStamper;
import com.yeejoin.amos.boot.biz.common.bo.CompanyBo; 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.bo.ReginParams;
import com.yeejoin.amos.boot.biz.common.controller.BaseController; import com.yeejoin.amos.boot.biz.common.controller.BaseController;
...@@ -42,7 +48,9 @@ import lombok.extern.slf4j.Slf4j; ...@@ -42,7 +48,9 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource; import org.springframework.core.io.Resource;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
...@@ -51,11 +59,8 @@ import org.springframework.web.multipart.MultipartFile; ...@@ -51,11 +59,8 @@ import org.springframework.web.multipart.MultipartFile;
import org.typroject.tyboot.core.foundation.context.RequestContext; import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil; import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest; import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.File; import java.io.*;
import java.io.FileInputStream;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.lang.reflect.Modifier; import java.lang.reflect.Modifier;
import java.net.URLEncoder; import java.net.URLEncoder;
...@@ -556,6 +561,89 @@ public class CommonServiceImpl implements ICommonService { ...@@ -556,6 +561,89 @@ public class CommonServiceImpl implements ICommonService {
} }
} }
/**
* 返回附件
* @param map 参数
* @param response 响应
*/
@Override
public void generatePdfPrint(Map<String, Object> map, HttpServletResponse response) {
String[] DEFAULT_KEYS = {
"useRegistrationCode", "useUnitName", "fullAddress", "equList", "equipDefine",
"equipCode", "equipCategory", "useInnerCode", "factoryNum", "giveOutYear",
"giveOutMonth", "giveOutDay"
};
if (CollectionUtils.isEmpty(map)) {
throw new IllegalArgumentException("参数不能为空");
}
// 设置默认值
Arrays.stream(DEFAULT_KEYS)
.forEach(key -> map.computeIfAbsent(key, k -> ""));
// 生成二维码
String qrCode = ImageUtils.generateQRCode((String) map.getOrDefault("supervisoryCode", ""), 100, 100);
map.put("supervisoryCode", qrCode); // 监管二维码 代码优化
// 读取资源文件夹下的模板
ClassPathResource resource = new ClassPathResource("templates/use-registration-model.pdf");
PdfReader reader = null;
ByteArrayOutputStream bos = null;
try {
InputStream inputStream = resource.getInputStream();
reader = new PdfReader(inputStream);
bos = new ByteArrayOutputStream();
PdfStamper pdfStamper = new PdfStamper(reader, bos);
AcroFields acroFields = pdfStamper.getAcroFields();
// 中文字体
BaseFont font = BaseFont.createFont("STSong-Light", "UniGB-UCS2-H", BaseFont.NOT_EMBEDDED);
for (Map.Entry<String, Object> param : map.entrySet()) {
// 设置文本域的字体为中文字体
acroFields.setFieldProperty(param.getKey(), "textfont", font,null);
// 设置字体大小
acroFields.setFieldProperty(param.getKey(), "textsize", 12.0f, null);
// 将 map 中的值写到 pdf 模板对应的文本域中
acroFields.setField(param.getKey(), param.getValue()+"");
}
// 如果为false那么生成的PDF文件还能编辑,所以一定要设为true
pdfStamper.setFormFlattening(true);
pdfStamper.close();
// 返回文件
//FileExporter.exportFile(FileExporter.FileType.valueOf("pdf"), "套打使用登记证", bos.toByteArray(), response);
this.writeAttachment(response, bos.toByteArray());
} catch (IOException | DocumentException e) {
e.printStackTrace();
} finally {
try {
assert bos != null;
bos.close();
reader.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
/**
* 返回附件
*
* @param response 响应
* @param content 附件内容
*/
private void writeAttachment(HttpServletResponse response, byte[] content) throws IOException {
// 设置 header 和 contentType
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode("套打使用登记证.pdf", "UTF-8"));
response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
// 输出附件
IoUtil.write(response.getOutputStream(), false, content);
}
/** /**
* word 转 pdf * word 转 pdf
......
...@@ -675,7 +675,7 @@ public class JgChangeRegistrationReformServiceImpl extends BaseService<JgChangeR ...@@ -675,7 +675,7 @@ public class JgChangeRegistrationReformServiceImpl extends BaseService<JgChangeR
} }
@Override @Override
public void exportUseRegistrationCertificate(String sequenceNbr, HttpServletResponse response) { public void exportUseRegistrationCertificate(String sequenceNbr, HttpServletResponse response, String printType) {
Map<String, Object> exportParamsMap = new HashMap<>(); Map<String, Object> exportParamsMap = new HashMap<>();
//查询移装变更详情 //查询移装变更详情
JgChangeRegistrationReform jgChangeRegistrationReform = this.getById(sequenceNbr); JgChangeRegistrationReform jgChangeRegistrationReform = this.getById(sequenceNbr);
...@@ -787,8 +787,13 @@ public class JgChangeRegistrationReformServiceImpl extends BaseService<JgChangeR ...@@ -787,8 +787,13 @@ public class JgChangeRegistrationReformServiceImpl extends BaseService<JgChangeR
} }
exportParamsMap.put("factoryNum", factoryInfo.getFactoryNum()); exportParamsMap.put("factoryNum", factoryInfo.getFactoryNum());
} }
//调用生成使用登记证 if ("0".equals(printType)) {
commonServiceImpl.generateCertificateReport(exportParamsMap, response); //调用生成使用登记证
commonServiceImpl.generateCertificateReport(exportParamsMap, response);
}else{
//套打
commonServiceImpl.generatePdfPrint(exportParamsMap, response);
}
} }
/** /**
......
...@@ -31,14 +31,12 @@ import com.yeejoin.amos.boot.module.jg.biz.service.ICmWorkflowService; ...@@ -31,14 +31,12 @@ import com.yeejoin.amos.boot.module.jg.biz.service.ICmWorkflowService;
import com.yeejoin.amos.boot.module.jg.biz.service.ICommonService; import com.yeejoin.amos.boot.module.jg.biz.service.ICommonService;
import com.yeejoin.amos.boot.module.jg.biz.service.IIdxBizJgUseInfoService; 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.jg.flc.api.fegin.WorkFlowFeignService;
import com.yeejoin.amos.boot.module.ymt.api.entity.EquipmentCategory; import com.yeejoin.amos.boot.module.ymt.api.entity.*;
import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgFactoryInfo;
import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgRegisterInfo;
import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgUseInfo;
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.enums.FlowStatusEnum; import com.yeejoin.amos.boot.module.ymt.api.enums.FlowStatusEnum;
import com.yeejoin.amos.boot.module.ymt.api.mapper.IdxBizJgOtherInfoMapper; import com.yeejoin.amos.boot.module.ymt.api.mapper.IdxBizJgOtherInfoMapper;
import com.yeejoin.amos.boot.module.ymt.api.mapper.IdxBizJgRegisterInfoMapper; import com.yeejoin.amos.boot.module.ymt.api.mapper.IdxBizJgRegisterInfoMapper;
import com.yeejoin.amos.boot.module.ymt.api.mapper.IdxBizJgSupervisionInfoMapper;
import com.yeejoin.amos.feign.systemctl.model.TaskV2Model; import com.yeejoin.amos.feign.systemctl.model.TaskV2Model;
import com.yeejoin.amos.feign.workflow.model.*; import com.yeejoin.amos.feign.workflow.model.*;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
...@@ -52,6 +50,7 @@ import org.elasticsearch.search.builder.SearchSourceBuilder; ...@@ -52,6 +50,7 @@ import org.elasticsearch.search.builder.SearchSourceBuilder;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.RequestParam;
import org.typroject.tyboot.core.foundation.context.RequestContext; import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.utils.Bean; import org.typroject.tyboot.core.foundation.utils.Bean;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil; import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
...@@ -77,10 +76,22 @@ import java.util.stream.Collectors; ...@@ -77,10 +76,22 @@ import java.util.stream.Collectors;
public class JgChangeRegistrationTransferServiceImpl extends BaseService<JgChangeRegistrationTransferDto, JgChangeRegistrationTransfer, JgChangeRegistrationTransferMapper> implements IJgChangeRegistrationTransferService { public class JgChangeRegistrationTransferServiceImpl extends BaseService<JgChangeRegistrationTransferDto, JgChangeRegistrationTransfer, JgChangeRegistrationTransferMapper> implements IJgChangeRegistrationTransferService {
private static final String PROCESS_DEFINITION_KEY = "changeRegistrationTransfer"; private static final String PROCESS_DEFINITION_KEY = "changeRegistrationTransfer";
private static final String TABLE_PAGE_ID = "changeRegistrationTransfer"; private static final String TABLE_PAGE_ID = "changeRegistrationTransfer";
@Autowired
RestHighLevelClient restHighLevelClient;
@Autowired
WorkFlowFeignService workFlowFeginService;
@Autowired
RedisUtils redisUtils;
@Autowired
ICommonService iCommonService;
@Autowired
TzsServiceFeignClient tzsServiceFeignClient;
@Autowired
ICmWorkflowService icmWorkflowService;
@Autowired
CommonServiceImpl commonService;
@Autowired @Autowired
private IJgChangeRegistrationTransferEqService jgChangeRegistrationTransferEqService; private IJgChangeRegistrationTransferEqService jgChangeRegistrationTransferEqService;
@Autowired @Autowired
private IJgRegistrationHistoryService jgRegistrationHistoryService; private IJgRegistrationHistoryService jgRegistrationHistoryService;
@Autowired @Autowired
...@@ -91,17 +102,6 @@ public class JgChangeRegistrationTransferServiceImpl extends BaseService<JgChang ...@@ -91,17 +102,6 @@ public class JgChangeRegistrationTransferServiceImpl extends BaseService<JgChang
private IdxBizJgRegisterInfoServiceImpl idxBizJgRegisterInfoService; private IdxBizJgRegisterInfoServiceImpl idxBizJgRegisterInfoService;
@Autowired @Autowired
private IdxBizJgFactoryInfoServiceImpl idxBizJgFactoryInfoService; private IdxBizJgFactoryInfoServiceImpl idxBizJgFactoryInfoService;
@Autowired
RestHighLevelClient restHighLevelClient;
@Autowired
WorkFlowFeignService workFlowFeginService;
@Autowired
RedisUtils redisUtils;
//改造登记关系表mapper //改造登记关系表mapper
@Autowired @Autowired
private JgChangeRegistrationReformEqMapper jgChangeRegistrationReformEqMapper; private JgChangeRegistrationReformEqMapper jgChangeRegistrationReformEqMapper;
...@@ -117,22 +117,13 @@ public class JgChangeRegistrationTransferServiceImpl extends BaseService<JgChang ...@@ -117,22 +117,13 @@ public class JgChangeRegistrationTransferServiceImpl extends BaseService<JgChang
//更名变更登记关系表mapper //更名变更登记关系表mapper
@Autowired @Autowired
private JgChangeRegistrationNameEqMapper jgChangeRegistrationNameEqMapper; private JgChangeRegistrationNameEqMapper jgChangeRegistrationNameEqMapper;
@Autowired @Autowired
private IdxBizJgOtherInfoMapper idxBizJgOtherInfoMapper; private IdxBizJgOtherInfoMapper idxBizJgOtherInfoMapper;
@Autowired @Autowired
private IdxBizJgRegisterInfoMapper idxBizJgRegisterInfoMapper; private IdxBizJgRegisterInfoMapper idxBizJgRegisterInfoMapper;
@Autowired @Autowired
ICommonService iCommonService; IdxBizJgSupervisionInfoMapper idxBizJgSupervisionInfoMapper;
@Autowired
TzsServiceFeignClient tzsServiceFeignClient;
@Autowired
ICmWorkflowService icmWorkflowService;
@Autowired
CommonServiceImpl commonService;
/** /**
* 新增移装变更登记 * 新增移装变更登记
...@@ -236,29 +227,29 @@ public class JgChangeRegistrationTransferServiceImpl extends BaseService<JgChang ...@@ -236,29 +227,29 @@ public class JgChangeRegistrationTransferServiceImpl extends BaseService<JgChang
if (!ObjectUtils.isEmpty(province)) { if (!ObjectUtils.isEmpty(province)) {
String[] provinceList = province.split("_"); String[] provinceList = province.split("_");
if (provinceList.length > 1) { if (provinceList.length > 1) {
fullAddress+=provinceList[1]; fullAddress += provinceList[1];
} }
} }
if (!ObjectUtils.isEmpty(city)) { if (!ObjectUtils.isEmpty(city)) {
String[] cityList = city.split("_"); String[] cityList = city.split("_");
if (cityList.length > 1) { if (cityList.length > 1) {
fullAddress+=cityList[1]; fullAddress += cityList[1];
} }
} }
if (!ObjectUtils.isEmpty(county)) { if (!ObjectUtils.isEmpty(county)) {
String[] countyList = county.split("_"); String[] countyList = county.split("_");
if (countyList.length > 1) { if (countyList.length > 1) {
fullAddress+=countyList[1]; fullAddress += countyList[1];
} }
} }
if (!ObjectUtils.isEmpty(street)) { if (!ObjectUtils.isEmpty(street)) {
String[] streetList = street.split("_"); String[] streetList = street.split("_");
if (streetList.length > 1) { if (streetList.length > 1) {
fullAddress+=streetList[1]; fullAddress += streetList[1];
} }
} }
if (!ObjectUtils.isEmpty(address)) { if (!ObjectUtils.isEmpty(address)) {
fullAddress+=address; fullAddress += address;
} }
//设备移装详细地址 //设备移装详细地址
oldTransfer.setFullAddress(fullAddress); oldTransfer.setFullAddress(fullAddress);
...@@ -353,7 +344,7 @@ public class JgChangeRegistrationTransferServiceImpl extends BaseService<JgChang ...@@ -353,7 +344,7 @@ public class JgChangeRegistrationTransferServiceImpl extends BaseService<JgChang
//生成代办 //生成代办
this.createToDoTask(Arrays.asList(workflowResult), oldTransfer, submitType); this.createToDoTask(Arrays.asList(workflowResult), oldTransfer, submitType);
} }
}else { } else {
List<TaskModelDto> modelDtos = new ArrayList<>(); List<TaskModelDto> modelDtos = new ArrayList<>();
TaskModelDto dto = new TaskModelDto(); TaskModelDto dto = new TaskModelDto();
dto.setModel(oldTransfer); dto.setModel(oldTransfer);
...@@ -366,14 +357,14 @@ public class JgChangeRegistrationTransferServiceImpl extends BaseService<JgChang ...@@ -366,14 +357,14 @@ public class JgChangeRegistrationTransferServiceImpl extends BaseService<JgChang
} }
JgChangeRegistrationTransferDto resultDto = new JgChangeRegistrationTransferDto(); JgChangeRegistrationTransferDto resultDto = new JgChangeRegistrationTransferDto();
Bean.copyExistPropertis(oldTransfer,resultDto); Bean.copyExistPropertis(oldTransfer, resultDto);
//组装返回信息,添加设备信息的展示 //组装返回信息,添加设备信息的展示
resultDto.setEquCategory((String) tableData.get("equCategoryDesc")); resultDto.setEquCategory((String) tableData.get("equCategoryDesc"));
resultDto.setProductName((String) tableData.get("productName")); resultDto.setProductName((String) tableData.get("productName"));
resultDto.setAllAddress(oldTransfer.getFullAddress()); resultDto.setAllAddress(oldTransfer.getFullAddress());
resultDto.setEquCode((String) tableData.get("equCode")); resultDto.setEquCode((String) tableData.get("equCode"));
resultDto.setInnerCode((String) tableData.get("useInnerCode")); resultDto.setInnerCode((String) tableData.get("useInnerCode"));
return Collections.singletonList(resultDto); return Collections.singletonList(resultDto);
} }
/** /**
...@@ -458,7 +449,7 @@ public class JgChangeRegistrationTransferServiceImpl extends BaseService<JgChang ...@@ -458,7 +449,7 @@ public class JgChangeRegistrationTransferServiceImpl extends BaseService<JgChang
jsonObject.put("nextExecuteUser", jgTransfer.getNextExecutorIds()); jsonObject.put("nextExecuteUser", jgTransfer.getNextExecutorIds());
jsonObject.put("taskType", BusinessTypeEnum.JG_CHANGE_REGISTRATION.getCode()); jsonObject.put("taskType", BusinessTypeEnum.JG_CHANGE_REGISTRATION.getCode());
// 判断撤回后当前的节点,如果当前节点为提交节点则页面可编辑 // 判断撤回后当前的节点,如果当前节点为提交节点则页面可编辑
jsonObject.put("pageType",this.getPageTypeByCurrentNode(jgTransfer.getAuditStatus())); jsonObject.put("pageType", this.getPageTypeByCurrentNode(jgTransfer.getAuditStatus()));
commonService.rollbackTask(instanceId, jsonObject); commonService.rollbackTask(instanceId, jsonObject);
} }
...@@ -510,7 +501,7 @@ public class JgChangeRegistrationTransferServiceImpl extends BaseService<JgChang ...@@ -510,7 +501,7 @@ public class JgChangeRegistrationTransferServiceImpl extends BaseService<JgChang
// 删除待办 // 删除待办
private void deleteTaskBatch(List<Long> ids) { private void deleteTaskBatch(List<Long> ids) {
ids.forEach(id-> commonService.deleteTaskModel(id + "")); ids.forEach(id -> commonService.deleteTaskModel(id + ""));
} }
/** /**
...@@ -543,47 +534,52 @@ public class JgChangeRegistrationTransferServiceImpl extends BaseService<JgChang ...@@ -543,47 +534,52 @@ public class JgChangeRegistrationTransferServiceImpl extends BaseService<JgChang
if (!ValidationUtil.equals(FlowStatusEnum.TO_BE_FINISHED.getName(), transferById.getStatus())) { if (!ValidationUtil.equals(FlowStatusEnum.TO_BE_FINISHED.getName(), transferById.getStatus())) {
JgRegistrationHistory historyData = jgRegistrationHistoryService.getDteailByRecord(equipId, transferById.getApplyNo()); JgRegistrationHistory historyData = jgRegistrationHistoryService.getDteailByRecord(equipId, transferById.getApplyNo());
if (!ValidationUtil.isEmpty(historyData)) { if (!ValidationUtil.isEmpty(historyData)) {
JSONObject newPosition = JSON.parseObject(historyData.getChangeData()); Map<String,Object> newPosition = JSON.parseObject(historyData.getChangeData(),Map.class);
String record = newPosition.getString("record"); resultDataMap.putAll(newPosition);
String receiveOrgCode = newPosition.getString("receiveOrgCode");
String equCode = newPosition.getString("equCode"); // String record = newPosition.getString("record");
String province = newPosition.getString("province"); // String receiveOrgCode = newPosition.getString("receiveOrgCode");
String city = newPosition.getString("city"); // String equCode = newPosition.getString("equCode");
String county = newPosition.getString("county"); // String province = newPosition.getString("province");
String street = newPosition.getString("street"); // String city = newPosition.getString("city");
String address = newPosition.getString("address"); // String county = newPosition.getString("county");
String longitudeLatitude = newPosition.getString("longitudeLatitude"); // String street = newPosition.getString("street");
if (!ObjectUtils.isEmpty(record)) { // String address = newPosition.getString("address");
resultDataMap.put("record", record); // String longitudeLatitude = newPosition.getString("longitudeLatitude");
} // if (!ObjectUtils.isEmpty(record)) {
if (!ObjectUtils.isEmpty(equCode)) { // resultDataMap.put("record", record);
resultDataMap.put("equCode", equCode); // }
} // if (!ObjectUtils.isEmpty(equCode)) {
if (!ObjectUtils.isEmpty(receiveOrgCode)) { // resultDataMap.put("equCode", equCode);
resultDataMap.put("receiveOrgCode", receiveOrgCode); // }
} // if (!ObjectUtils.isEmpty(receiveOrgCode)) {
// resultDataMap.put("receiveOrgCode", receiveOrgCode);
// 分割省市区街道字段 // }
if (!ObjectUtils.isEmpty(province)) { //
resultDataMap.put("province", province); // // 分割省市区街道字段
} // if (!ObjectUtils.isEmpty(province)) {
if (!ObjectUtils.isEmpty(city)) { // resultDataMap.put("province", province);
resultDataMap.put("city", city); // }
} // if (!ObjectUtils.isEmpty(city)) {
if (!ObjectUtils.isEmpty(county)) { // resultDataMap.put("city", city);
resultDataMap.put("county", county); // }
} // if (!ObjectUtils.isEmpty(county)) {
if (!ObjectUtils.isEmpty(street)) { // resultDataMap.put("county", county);
resultDataMap.put("street", street); // }
} // if (!ObjectUtils.isEmpty(street)) {
if (!ObjectUtils.isEmpty(address)) { // resultDataMap.put("street", street);
resultDataMap.put("address", address); // }
} // if (!ObjectUtils.isEmpty(address)) {
if (!ObjectUtils.isEmpty(longitudeLatitude)) { // resultDataMap.put("address", address);
resultDataMap.put("longitudeLatitude", JSON.parseObject(longitudeLatitude)); // }
} // if (!ObjectUtils.isEmpty(longitudeLatitude)) {
// resultDataMap.put("longitudeLatitude", JSON.parseObject(longitudeLatitude));
// }
} }
} else { } else {
JgRegistrationHistory historyData = jgRegistrationHistoryService.getDteailByRecord(equipId, transferById.getApplyNo());
Map<String,Object> newPosition = JSON.parseObject(historyData.getChangeData(),Map.class);
resultDataMap.putAll(newPosition);
//设备注册信息 //设备注册信息
IdxBizJgRegisterInfo registerInfo = idxBizJgRegisterInfoService.getOne(new QueryWrapper<IdxBizJgRegisterInfo>().eq("RECORD", equipId)); IdxBizJgRegisterInfo registerInfo = idxBizJgRegisterInfoService.getOne(new QueryWrapper<IdxBizJgRegisterInfo>().eq("RECORD", equipId));
//使用信息详情 //使用信息详情
...@@ -609,7 +605,13 @@ public class JgChangeRegistrationTransferServiceImpl extends BaseService<JgChang ...@@ -609,7 +605,13 @@ public class JgChangeRegistrationTransferServiceImpl extends BaseService<JgChang
} }
resultDataMap.put("receiveOrgCode", transferById.getReceiveOrgCode() + "_" + transferById.getReceiveOrgName()); resultDataMap.put("receiveOrgCode", transferById.getReceiveOrgCode() + "_" + transferById.getReceiveOrgName());
} }
String transferSafetyManager = Optional.ofNullable(resultDataMap.get("transferSafetyManager")).orElse("").toString();
if(!transferSafetyManager.equals("")){
String[] transferSafetyManagerList = transferSafetyManager.split("_");
if(transferSafetyManagerList.length>1){
resultDataMap.put("transferSafetyManagerName",transferSafetyManagerList[1]);
}
}
if (!resultDataMap.isEmpty()) { if (!resultDataMap.isEmpty()) {
pageDataMap.put(TABLE_PAGE_ID, resultDataMap); pageDataMap.put(TABLE_PAGE_ID, resultDataMap);
} }
...@@ -792,12 +794,31 @@ public class JgChangeRegistrationTransferServiceImpl extends BaseService<JgChang ...@@ -792,12 +794,31 @@ public class JgChangeRegistrationTransferServiceImpl extends BaseService<JgChang
// 更新设备移装位置使用信息 // 更新设备移装位置使用信息
if (!ValidationUtil.isEmpty(newData)) { if (!ValidationUtil.isEmpty(newData)) {
JSONObject newPosition = JSON.parseObject(newData.getChangeData()); JSONObject newPosition = JSON.parseObject(newData.getChangeData());
String province = newPosition.getString("province"); //省
String city = newPosition.getString("city"); String province = newPosition.getString("tansferProvince");
String county = newPosition.getString("county"); //市
String street = newPosition.getString("street"); String city = newPosition.getString("transferCity");
String address = newPosition.getString("address"); //区县
String longitudeLatitude = newPosition.getString("longitudeLatitude"); String county = newPosition.getString("transferCounty");
//街道
String street = newPosition.getString("transferStreet");
//地址
String address = newPosition.getString("transferAddress");
//经纬度
String longitudeLatitude = newPosition.getString("transferLongitudeLatitude");
//使用场所
String usePlace = newPosition.getString("transferUsePlace");
//所属监管单位
String supervisionUnit = newPosition.getString("transferSupervisionUnit");
//是否西咸
String isXixian = newPosition.getString("transferIsXixian");
//安全管理员
String safetyManager = newPosition.getString("transferSafetyManager");
//产权单位
String transferUseInfo = newPosition.getString("transferUseInfo");
//安全管理员电话
String phone = newPosition.getString("transferPhone");
// 分割省市区街道字段 // 分割省市区街道字段
if (!ObjectUtils.isEmpty(province)) { if (!ObjectUtils.isEmpty(province)) {
String[] provinceList = province.split("_"); String[] provinceList = province.split("_");
...@@ -833,6 +854,41 @@ public class JgChangeRegistrationTransferServiceImpl extends BaseService<JgChang ...@@ -833,6 +854,41 @@ public class JgChangeRegistrationTransferServiceImpl extends BaseService<JgChang
if (!ObjectUtils.isEmpty(longitudeLatitude)) { if (!ObjectUtils.isEmpty(longitudeLatitude)) {
useInfo.setLongitudeLatitude(longitudeLatitude); useInfo.setLongitudeLatitude(longitudeLatitude);
} }
if(!ObjectUtils.isEmpty(usePlace)){
useInfo.setUsePlace(usePlace);
}
if(!ObjectUtils.isEmpty(isXixian)){
useInfo.setIsNotXiXian(isXixian);
}
if(!ObjectUtils.isEmpty(safetyManager)){
String[] safetyManagerList = safetyManager.split("_");
if (safetyManagerList.length>1){
useInfo.setSafetyManagerId(safetyManagerList[0]);
useInfo.setSafetyManager(safetyManagerList[1]);
}
}
if(!ObjectUtils.isEmpty(phone)){
useInfo.setPhone(phone);
}
if(!ObjectUtils.isEmpty(transferUseInfo)){
String[] useInfoList = transferUseInfo.split("_");
if(useInfoList.length>1){
useInfo.setEstateUnitCreditCode(useInfoList[0]);
useInfo.setEstateUnitName(useInfoList[1]);
}
}
IdxBizJgSupervisionInfo idxBizJgSupervisionInfo = new IdxBizJgSupervisionInfo();
if(!ObjectUtils.isEmpty(supervisionUnit)){
String[] supervisionUnitList = supervisionUnit.split("_");
if(supervisionUnitList.length>1){
idxBizJgSupervisionInfo.setOrgBranchCode(supervisionUnitList[0]);
idxBizJgSupervisionInfo.setOrgBranchName(supervisionUnitList[1]);
LambdaQueryWrapper<IdxBizJgSupervisionInfo> eq = new QueryWrapper<IdxBizJgSupervisionInfo>().lambda().eq(IdxBizJgSupervisionInfo::getRecord,record);
idxBizJgSupervisionInfoMapper.update(idxBizJgSupervisionInfo, eq);
}
}
useInfoService.saveOrUpdateData(useInfo); useInfoService.saveOrUpdateData(useInfo);
} }
} }
...@@ -873,27 +929,34 @@ public class JgChangeRegistrationTransferServiceImpl extends BaseService<JgChang ...@@ -873,27 +929,34 @@ public class JgChangeRegistrationTransferServiceImpl extends BaseService<JgChang
String newLongitudeLatitude = ""; String newLongitudeLatitude = "";
if (!ValidationUtil.isEmpty(newData)) { if (!ValidationUtil.isEmpty(newData)) {
JSONObject newPosition = JSON.parseObject(newData.getChangeData()); JSONObject newPosition = JSON.parseObject(newData.getChangeData());
String province = newPosition.getString("province"); String province = newPosition.getString("transferProvince");
String city = newPosition.getString("city"); String city = newPosition.getString("transferCity");
String county = newPosition.getString("county"); String county = newPosition.getString("transferCounty");
String address = newPosition.getString("address"); String street = newPosition.getString("transferStreet");
String address = newPosition.getString("transferAddress");
String longitudeLatitude = newPosition.getString("longitudeLatitude"); String longitudeLatitude = newPosition.getString("longitudeLatitude");
// 分割省市区街道字段 // 分割省市区街道字段
if (!ObjectUtils.isEmpty(province)) { if (!ObjectUtils.isEmpty(province)) {
String[] provinceList = province.split("_"); String[] provinceList = province.split("_");
if (provinceList.length > 1) { if (provinceList.length > 1) {
newUsePlace += provinceList[1]+"/"; newUsePlace += provinceList[1] + "/";
} }
} }
if (!ObjectUtils.isEmpty(city)) { if (!ObjectUtils.isEmpty(city)) {
String[] cityList = city.split("_"); String[] cityList = city.split("_");
if (cityList.length > 1) { if (cityList.length > 1) {
newUsePlace += cityList[1]+"/"; newUsePlace += cityList[1] + "/";
} }
} }
if (!ObjectUtils.isEmpty(county)) { if (!ObjectUtils.isEmpty(county)) {
String[] countyList = county.split("_"); String[] countyList = county.split("_");
if (countyList.length > 1) { if (countyList.length > 1) {
newUsePlace += countyList[1]+ "/";
}
}
if (!ObjectUtils.isEmpty(street)) {
String[] countyList = street.split("_");
if (countyList.length > 1) {
newUsePlace += countyList[1]; newUsePlace += countyList[1];
} }
} }
...@@ -944,7 +1007,7 @@ public class JgChangeRegistrationTransferServiceImpl extends BaseService<JgChang ...@@ -944,7 +1007,7 @@ public class JgChangeRegistrationTransferServiceImpl extends BaseService<JgChang
* *
* @param sequenceNbr * @param sequenceNbr
*/ */
public void exportUseRegistrationCertificate(String sequenceNbr, HttpServletResponse response) { public void exportUseRegistrationCertificate(String sequenceNbr, HttpServletResponse response, String printType) {
Map<String, Object> exportParamsMap = new HashMap<>(); Map<String, Object> exportParamsMap = new HashMap<>();
//查询移装变更详情 //查询移装变更详情
JgChangeRegistrationTransfer transfer = this.getById(sequenceNbr); JgChangeRegistrationTransfer transfer = this.getById(sequenceNbr);
...@@ -984,11 +1047,11 @@ public class JgChangeRegistrationTransferServiceImpl extends BaseService<JgChang ...@@ -984,11 +1047,11 @@ public class JgChangeRegistrationTransferServiceImpl extends BaseService<JgChang
if (!ValidationUtil.isEmpty(transferHistory)) { if (!ValidationUtil.isEmpty(transferHistory)) {
String fullAddress = ""; String fullAddress = "";
JSONObject newPosition = JSON.parseObject(transferHistory.getChangeData()); JSONObject newPosition = JSON.parseObject(transferHistory.getChangeData());
String province = newPosition.getString("province"); String province = newPosition.getString("transferProvince");
String city = newPosition.getString("city"); String city = newPosition.getString("transferCity");
String county = newPosition.getString("county"); String county = newPosition.getString("transferCounty");
String street = newPosition.getString("street"); String street = newPosition.getString("transferStreet");
String address = newPosition.getString("address"); String address = newPosition.getString("transferAddress");
// 分割省市区街道字段 // 分割省市区街道字段
if (!ObjectUtils.isEmpty(province)) { if (!ObjectUtils.isEmpty(province)) {
...@@ -1075,8 +1138,12 @@ public class JgChangeRegistrationTransferServiceImpl extends BaseService<JgChang ...@@ -1075,8 +1138,12 @@ public class JgChangeRegistrationTransferServiceImpl extends BaseService<JgChang
} }
exportParamsMap.put("factoryNum", factoryInfo.getFactoryNum()); exportParamsMap.put("factoryNum", factoryInfo.getFactoryNum());
} }
//调用生成使用登记证 if ("0".equals(printType)) {
iCommonService.generateCertificateReport(exportParamsMap, response); //调用生成使用登记证
commonService.generateCertificateReport(exportParamsMap, response);
}else{
commonService.generatePdfPrint(exportParamsMap, response);
}
} }
...@@ -1169,10 +1236,10 @@ public class JgChangeRegistrationTransferServiceImpl extends BaseService<JgChang ...@@ -1169,10 +1236,10 @@ public class JgChangeRegistrationTransferServiceImpl extends BaseService<JgChang
} }
private String getPageTypeByCurrentNode(String auditStatus) { private String getPageTypeByCurrentNode(String auditStatus) {
if(WorkFlowStatusEnum.TRANSFER_SUBMIT.getPass().equals(auditStatus) || if (WorkFlowStatusEnum.TRANSFER_SUBMIT.getPass().equals(auditStatus) ||
WorkFlowStatusEnum.TRANSFER_SUBMIT.getReject().equals(auditStatus) || WorkFlowStatusEnum.TRANSFER_SUBMIT.getReject().equals(auditStatus) ||
WorkFlowStatusEnum.TRANSFER_SUBMIT.getRollBack().equals(auditStatus) WorkFlowStatusEnum.TRANSFER_SUBMIT.getRollBack().equals(auditStatus)
){ ) {
// urlInfo.json 文件的 pageType // urlInfo.json 文件的 pageType
return "edit"; return "edit";
} else { } else {
...@@ -1180,4 +1247,36 @@ public class JgChangeRegistrationTransferServiceImpl extends BaseService<JgChang ...@@ -1180,4 +1247,36 @@ public class JgChangeRegistrationTransferServiceImpl extends BaseService<JgChang
return "look"; return "look";
} }
} }
public Map<String, Object> getDetailFieldCamelCase( String record) {
Map<String, Object> result = new HashMap<>();
result = idxBizJgRegisterInfoService.getDetailFieldCamelCaseByRecord(record);
//移装变更-省份回显
result.put("transferProvince",result.get("province"));
//移装变更-市回显
result.put("transferCity",result.get("city"));
//移装变更-区回显
result.put("transferCounty",result.get("county"));
//移装变更-街道回显
result.put("transferStreet",result.get("factoryUseSiteStreet")+"_"+result.get("streetName"));
//移装变更-移装场所
result.put("transferUsePlace",result.get("usePlace"));
//移装变更-详细地址
result.put("transferAddress",result.get("useAddress"));
//移装变更-经纬度
result.put("transferLongitudeLatitude",result.get("longitudeLatitude"));
//移装变更-所属监管单位
result.put("transferSupervisionUnit",result.get("orgBranchCode")+"_"+result.get("orgBranchName"));
//移装变更-所属经营单位
result.put("transferIsXixian",result.get("isNotXiXian"));
//移装变更-安全管理员
result.put("transferSafetyManager",result.get("safetyManagerId")+"_"+result.get("safetyManager"));
//移装变更-安全管理员姓名
result.put("transferSafetyManagerName",result.get("safetyManager"));
//移装变更-电话
result.put("transferPhone",result.get("phone"));
//移装变更-产权单位
result.put("transferUseInfo",result.get("estateUnitCreditCode")+"_"+result.get("estateUnitName"));
return result;
}
} }
\ No newline at end of file
...@@ -897,7 +897,7 @@ public class JgChangeRegistrationUnitServiceImpl extends BaseService<JgChangeReg ...@@ -897,7 +897,7 @@ public class JgChangeRegistrationUnitServiceImpl extends BaseService<JgChangeReg
* *
* @param sequenceNbr * @param sequenceNbr
*/ */
public void exportUseRegistrationCertificate(String sequenceNbr, HttpServletResponse response) { public void exportUseRegistrationCertificate(String sequenceNbr, HttpServletResponse response, String printType) {
Map<String, Object> exportParamsMap = new HashMap<>(); Map<String, Object> exportParamsMap = new HashMap<>();
//查询移装变更详情 //查询移装变更详情
JgChangeRegistrationUnit transfer = this.getById(sequenceNbr); JgChangeRegistrationUnit transfer = this.getById(sequenceNbr);
...@@ -975,7 +975,13 @@ public class JgChangeRegistrationUnitServiceImpl extends BaseService<JgChangeReg ...@@ -975,7 +975,13 @@ public class JgChangeRegistrationUnitServiceImpl extends BaseService<JgChangeReg
//调用生成使用登记证 //调用生成使用登记证
exportParamsMap.put("excelType","变更登记"); exportParamsMap.put("excelType","变更登记");
exportParamsMap.put("tableName","特种设备单位变更登记"); exportParamsMap.put("tableName","特种设备单位变更登记");
commonService.generateCertificateReport(exportParamsMap, response);
if ("0".equals(printType)) {
//调用生成使用登记证
commonService.generateCertificateReport(exportParamsMap, response);
}else{
commonService.generatePdfPrint(exportParamsMap, response);
}
} }
......
...@@ -137,6 +137,7 @@ public class JgReformNoticeServiceImpl extends BaseService<JgReformNoticeDto, Jg ...@@ -137,6 +137,7 @@ public class JgReformNoticeServiceImpl extends BaseService<JgReformNoticeDto, Jg
equipMap = idxBizJgRegisterInfoService.getDetailFieldCamelCaseByRecord(equId); equipMap = idxBizJgRegisterInfoService.getDetailFieldCamelCaseByRecord(equId);
equipMap.put("useUnitCreditCodeUse", equipMap.getOrDefault("useUnitCreditCode", "")); equipMap.put("useUnitCreditCodeUse", equipMap.getOrDefault("useUnitCreditCode", ""));
equipMap.put("useUnitNameUse", equipMap.getOrDefault("useUnitName", "")); equipMap.put("useUnitNameUse", equipMap.getOrDefault("useUnitName", ""));
equipMap.put("equRegisterCode", equipMap.getOrDefault("equCode", ""));
for (String s : fields) { for (String s : fields) {
if (installationInfo.containsKey(s)) { if (installationInfo.containsKey(s)) {
installationInfo.put(s, JSON.parseArray(installationInfo.get(s).toString())); installationInfo.put(s, JSON.parseArray(installationInfo.get(s).toString()));
......
...@@ -244,6 +244,9 @@ public class JgScrapCancelServiceImpl extends BaseService<JgScrapCancelDto, JgSc ...@@ -244,6 +244,9 @@ public class JgScrapCancelServiceImpl extends BaseService<JgScrapCancelDto, JgSc
this.createTaskModel(jgScrapCancel, taskName[0], submitType, nextUserIds); this.createTaskModel(jgScrapCancel, taskName[0], submitType, nextUserIds);
jgRelationEquip.setEquipTransferId(String.valueOf(jgScrapCancel.getSequenceNbr())); jgRelationEquip.setEquipTransferId(String.valueOf(jgScrapCancel.getSequenceNbr()));
jgScrapCancelEqService.save(jgRelationEquip); jgScrapCancelEqService.save(jgRelationEquip);
String equListName = EquipmentClassifityEnum.getNameByCode(jgScrapCancel.getEquList());
jgScrapCancel.setEquListDesc(equListName);
jgScrapCancel.setCancelTypeDesc("1".equals(jgScrapCancel.getCancelType()) ? "报废注销" : "移装注销");
return jgScrapCancel; return jgScrapCancel;
} }
......
...@@ -47,7 +47,6 @@ import org.typroject.tyboot.core.foundation.utils.ValidationUtil; ...@@ -47,7 +47,6 @@ 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.typroject.tyboot.core.restful.exception.instance.BadRequest; 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 javax.servlet.http.HttpServletResponse;
import java.text.ParseException; import java.text.ParseException;
import java.time.LocalDate; import java.time.LocalDate;
...@@ -122,9 +121,14 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD ...@@ -122,9 +121,14 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
// 安全管理员 // 安全管理员
if (map.containsKey("safetyManagerName")) { if (map.containsKey("safetyManagerName")) {
map.put("safetyManager", map.get("safetyManagerName")); map.put("safetyManager", map.get("safetyManagerName"));
map.put("safetyManagerId", map.get("safetyManagerId"));
} }
IdxBizJgUseInfo useInfo = new IdxBizJgUseInfo(); IdxBizJgUseInfo useInfo = new IdxBizJgUseInfo();
BeanUtil.copyProperties(map, useInfo); BeanUtil.copyProperties(map, useInfo);
if(map.containsKey("isXixian")){
useInfo.setIsNotXiXian(map.get("isXixian").toString());
}
// 城市 // 城市
if (!ObjectUtils.isEmpty(map.get("city")) && !ObjectUtils.isEmpty(city)) { if (!ObjectUtils.isEmpty(map.get("city")) && !ObjectUtils.isEmpty(city)) {
city.forEach(item -> { city.forEach(item -> {
...@@ -231,6 +235,7 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD ...@@ -231,6 +235,7 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
// 安全管理员 // 安全管理员
if (map.containsKey("safetyManager")) { if (map.containsKey("safetyManager")) {
String[] data = String.valueOf(map.getString("safetyManager")).split("_"); String[] data = String.valueOf(map.getString("safetyManager")).split("_");
map.put("safetyManagerId",data[0]);
map.put("safetyManagerName", data[1]); map.put("safetyManagerName", data[1]);
} }
// 使用单位提交 // 使用单位提交
...@@ -644,7 +649,7 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD ...@@ -644,7 +649,7 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
return null; return null;
} }
public void exportUseRegistrationCertificate(String sequenceNbr, HttpServletResponse response) { public void exportUseRegistrationCertificate(String sequenceNbr, HttpServletResponse response, String printType) {
Map<String, Object> exportParamsMap = new HashMap<>(); Map<String, Object> exportParamsMap = new HashMap<>();
//查询使用登记详情 //查询使用登记详情
JgUseRegistration useRegistration = this.getById(sequenceNbr); JgUseRegistration useRegistration = this.getById(sequenceNbr);
...@@ -754,8 +759,13 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD ...@@ -754,8 +759,13 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
} }
exportParamsMap.put("factoryNum", factoryInfo.getFactoryNum()); exportParamsMap.put("factoryNum", factoryInfo.getFactoryNum());
} }
//调用生成使用登记证 if ("0".equals(printType)) {
commonService.generateCertificateReport(exportParamsMap, response); //调用生成使用登记证
commonService.generateCertificateReport(exportParamsMap, response);
}else{
//套打
commonService.generatePdfPrint(exportParamsMap, response);
}
} }
/** /**
......
...@@ -17,6 +17,11 @@ public interface BizCommonConstant { ...@@ -17,6 +17,11 @@ public interface BizCommonConstant {
*/ */
String REGION_TREE_REDIS_KEY = "REGION_TREE_TCM"; String REGION_TREE_REDIS_KEY = "REGION_TREE_TCM";
/**
* 全国所有区划企业数据redisKey
*/
String NATIONAL_REGION_TREE_REDIS_KEY = "NATIONAL_REGION_TREE_TCM";
/** /**
* 企业类型数据redisKey * 企业类型数据redisKey
......
...@@ -142,4 +142,7 @@ public class RegUnitInfoDto extends BaseDto { ...@@ -142,4 +142,7 @@ public class RegUnitInfoDto extends BaseDto {
@ApiModelProperty(value = "注册类型") @ApiModelProperty(value = "注册类型")
private String registerType; private String registerType;
@ApiModelProperty(value = "单位所在地是否为全国")
private String isNationwide;
} }
package com.yeejoin.amos.boot.module.tcm.flc.api.enums;
import lombok.Getter;
/**
* 企业数据来源
* @author Administrator
*/
@Getter
public enum UnitDataSourceEnum {
/**
* 单位审核状态
*/
NATIONAL("省外企业","1"),
SHAANXI("陕西省内企业","0");
private String name;
private String code;
UnitDataSourceEnum(String name, String code){
this.name = name;
this.code = code;
}
}
...@@ -47,7 +47,9 @@ public interface IUnitInfoService { ...@@ -47,7 +47,9 @@ public interface IUnitInfoService {
/** /**
* 单位树 * 单位树
* @param parentId 上级行政区划ID
* @param isNationwide 是否全国范围行政区划 null默认陕西省内,1全国
* @return Collection<RegionModel> * @return Collection<RegionModel>
*/ */
Collection<RegionModel> getRegionTree(Long parentId); Collection<RegionModel> getRegionTree(Long parentId, String isNationwide);
} }
...@@ -140,8 +140,10 @@ public class AmosTcmApplication { ...@@ -140,8 +140,10 @@ public class AmosTcmApplication {
//4.区域放redis缓存(依赖1) //4.区域放redis缓存(依赖1)
//4.1先删除缓存 //4.1先删除缓存
redisUtil.del(BizCommonConstant.REGION_TREE_REDIS_KEY); redisUtil.del(BizCommonConstant.REGION_TREE_REDIS_KEY);
redisUtil.del(BizCommonConstant.NATIONAL_REGION_TREE_REDIS_KEY);
//4.2再初始化 //4.2再初始化
unitInfoService.getAllRegionTree(); unitInfoService.getAllRegionTree(null); // 陕西省
unitInfoService.getAllRegionTree("1"); // 全国
//5.企业类型放redis缓存(依赖1) //5.企业类型放redis缓存(依赖1)
//5.1先删除缓存 //5.1先删除缓存
redisUtil.del(BizCommonConstant.UNIT_TYPE_LIST_REDIS_KEY); redisUtil.del(BizCommonConstant.UNIT_TYPE_LIST_REDIS_KEY);
......
...@@ -97,15 +97,23 @@ public class UnitInfoController extends BaseController { ...@@ -97,15 +97,23 @@ public class UnitInfoController extends BaseController {
* *
* @return * @return
*/ */
//@TycloudOperation(needAuth = false, ApiLevel = UserType.AGENCY)
@TycloudOperation(ApiLevel = UserType.ANONYMOUS, needAuth = false) @TycloudOperation(ApiLevel = UserType.ANONYMOUS, needAuth = false)
@GetMapping(value = "/region/tree") @GetMapping(value = "/region/tree")
@ApiOperation(httpMethod = "GET", value = "获取组织机构树", notes = "获取组织机构树") @ApiOperation(httpMethod = "GET", value = "获取组织机构树", notes = "获取组织机构树")
public ResponseModel<Collection<RegionModel>> getRegionTree(@RequestParam(value = "parentId",required = false) Long parentId) { public ResponseModel<Collection<RegionModel>> getRegionTree(@RequestParam(value = "parentId",required = false) Long parentId) {
return ResponseHelper.buildResponse(unitInfoServiceImpl.getRegionTree(parentId)); return ResponseHelper.buildResponse(unitInfoServiceImpl.getRegionTree(parentId, null));
} }
/**
* 获取全国行政区划树
*
*/
@TycloudOperation(ApiLevel = UserType.ANONYMOUS, needAuth = false)
@GetMapping(value = "/national/region/tree")
@ApiOperation(httpMethod = "GET", value = "获取全国行政区划树", notes = "获取全国行政区划树")
public ResponseModel<Collection<RegionModel>> getNationalRegionTree(@RequestParam(value = "parentId",required = false) Long parentId, @RequestParam(value = "isNationwide",required = false) String isNationwide) {
return ResponseHelper.buildResponse(unitInfoServiceImpl.getRegionTree(parentId, isNationwide));
}
/** /**
* 获取管辖单位树 * 获取管辖单位树
......
...@@ -33,6 +33,7 @@ import com.yeejoin.amos.boot.module.tcm.flc.api.dto.RegUnitIcDto; ...@@ -33,6 +33,7 @@ import com.yeejoin.amos.boot.module.tcm.flc.api.dto.RegUnitIcDto;
import com.yeejoin.amos.boot.module.tcm.flc.api.dto.RegUnitInfoDto; import com.yeejoin.amos.boot.module.tcm.flc.api.dto.RegUnitInfoDto;
import com.yeejoin.amos.boot.module.tcm.flc.api.entity.RegUnitIc; import com.yeejoin.amos.boot.module.tcm.flc.api.entity.RegUnitIc;
import com.yeejoin.amos.boot.module.tcm.flc.api.entity.RegUnitInfo; import com.yeejoin.amos.boot.module.tcm.flc.api.entity.RegUnitInfo;
import com.yeejoin.amos.boot.module.tcm.flc.api.enums.UnitDataSourceEnum;
import com.yeejoin.amos.boot.module.tcm.flc.api.feign.AccessFeignService; import com.yeejoin.amos.boot.module.tcm.flc.api.feign.AccessFeignService;
import com.yeejoin.amos.boot.module.tcm.flc.api.feign.IdxFeignService; import com.yeejoin.amos.boot.module.tcm.flc.api.feign.IdxFeignService;
import com.yeejoin.amos.boot.module.tcm.flc.api.feign.UgpServiceFeignClient; import com.yeejoin.amos.boot.module.tcm.flc.api.feign.UgpServiceFeignClient;
...@@ -353,7 +354,12 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI ...@@ -353,7 +354,12 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI
// 这个表有两个字段所以赋值两字段 // 这个表有两个字段所以赋值两字段
baseEnterpriseInfo.setSuperviseOrgName(regUnitInfo.getManagementUnit()); baseEnterpriseInfo.setSuperviseOrgName(regUnitInfo.getManagementUnit());
baseEnterpriseInfo.setGoverningBody(regUnitInfo.getManagementUnit()); baseEnterpriseInfo.setGoverningBody(regUnitInfo.getManagementUnit());
baseEnterpriseInfo.setDataSources("企业注册"); if (UnitDataSourceEnum.NATIONAL.getCode().equals(regUnitInfo.getIsNationwide())) {
baseEnterpriseInfo.setDataSources(UnitDataSourceEnum.NATIONAL.getName());
} else {
baseEnterpriseInfo.setDataSources(UnitDataSourceEnum.SHAANXI.getName());
}
baseEnterpriseInfo.setRegisterType(Objects.requireNonNull(EnterpriseEnums.getEnumByType(type).getTypeName())); baseEnterpriseInfo.setRegisterType(Objects.requireNonNull(EnterpriseEnums.getEnumByType(type).getTypeName()));
if (type.equals(EnterpriseEnums.QY_DW.getType())){ if (type.equals(EnterpriseEnums.QY_DW.getType())){
baseEnterpriseInfo.setIndustry(regUnitInfo.getRegUnitIc().getIndustryName()); baseEnterpriseInfo.setIndustry(regUnitInfo.getRegUnitIc().getIndustryName());
......
...@@ -101,6 +101,8 @@ public class UnitInfoServiceImpl extends BaseService<UnitInfoDto, UnitInfo, Unit ...@@ -101,6 +101,8 @@ public class UnitInfoServiceImpl extends BaseService<UnitInfoDto, UnitInfo, Unit
@Autowired @Autowired
private RedisUtil redisUtil; private RedisUtil redisUtil;
@Value("${shaanxi.region.seq:1402458558599125040}")
private Long shaanxiRegionSeq;
@Transactional @Transactional
...@@ -639,11 +641,11 @@ public class UnitInfoServiceImpl extends BaseService<UnitInfoDto, UnitInfo, Unit ...@@ -639,11 +641,11 @@ public class UnitInfoServiceImpl extends BaseService<UnitInfoDto, UnitInfo, Unit
} }
@Override @Override
public Collection<RegionModel> getRegionTree(Long parentId) { public Collection<RegionModel> getRegionTree(Long parentId, String isNationwide) {
tzsAuthServiceImpl.setRequestContext(); tzsAuthServiceImpl.setRequestContext();
Collection<RegionModel> result = null; Collection<RegionModel> result = null;
if(parentId == null) { if(parentId == null) {
result = this.getAllRegionTree(); result = this.getAllRegionTree(isNationwide);
} else { } else {
result = Systemctl.regionClient.querySubAgencyTree(parentId).getResult(); result = Systemctl.regionClient.querySubAgencyTree(parentId).getResult();
} }
...@@ -651,20 +653,26 @@ public class UnitInfoServiceImpl extends BaseService<UnitInfoDto, UnitInfo, Unit ...@@ -651,20 +653,26 @@ public class UnitInfoServiceImpl extends BaseService<UnitInfoDto, UnitInfo, Unit
return result; return result;
} }
public Collection<RegionModel> getAllRegionTree() { public Collection<RegionModel> getAllRegionTree(String isNationwide) {
Collection<RegionModel> result; Collection<RegionModel> result;
// isNationwide = null 获取陕西省行政区划,其他获取全国行政区划
String regionTreeRedisKey = ValidationUtil.isEmpty(isNationwide) ? BizCommonConstant.REGION_TREE_REDIS_KEY : BizCommonConstant.NATIONAL_REGION_TREE_REDIS_KEY;
// 先从Redis缓存中获取值 // 先从Redis缓存中获取值
if (redisUtil.hasKey(BizCommonConstant.REGION_TREE_REDIS_KEY)) { if (redisUtil.hasKey(regionTreeRedisKey)) {
result = JSONObject.parseArray(redisUtil.get(BizCommonConstant.REGION_TREE_REDIS_KEY).toString(), RegionModel.class); result = JSONObject.parseArray(redisUtil.get(regionTreeRedisKey).toString(), RegionModel.class);
return result; return result;
} }
// 在同步块内再次检查缓存,以避免多个线程同时查不到缓存时重复查询数据库 // 在同步块内再次检查缓存,以避免多个线程同时查不到缓存时重复查询数据库
synchronized (this) { synchronized (this) {
if (redisUtil.hasKey(BizCommonConstant.REGION_TREE_REDIS_KEY)) { if (redisUtil.hasKey(regionTreeRedisKey)) {
result = JSONObject.parseArray(redisUtil.get(BizCommonConstant.REGION_TREE_REDIS_KEY).toString(), RegionModel.class); result = JSONObject.parseArray(redisUtil.get(regionTreeRedisKey).toString(), RegionModel.class);
} else { } else {
result = Systemctl.regionClient.queryForTree(null).getResult(); if (ValidationUtil.isEmpty(isNationwide)) {
redisUtil.set(BizCommonConstant.REGION_TREE_REDIS_KEY, JSONObject.toJSONString(result)); result = Systemctl.regionClient.querySubAgencyTree(shaanxiRegionSeq).getResult();
} else {
result = Systemctl.regionClient.queryForTree(null).getResult();
}
redisUtil.set(regionTreeRedisKey, JSONObject.toJSONString(result));
} }
} }
...@@ -681,7 +689,7 @@ public class UnitInfoServiceImpl extends BaseService<UnitInfoDto, UnitInfo, Unit ...@@ -681,7 +689,7 @@ public class UnitInfoServiceImpl extends BaseService<UnitInfoDto, UnitInfo, Unit
while(iterator.hasNext()) { while(iterator.hasNext()) {
RegionModel regionModel = iterator.next(); RegionModel regionModel = iterator.next();
regionModel.setLevel(regionModel.getLevel().trim()); regionModel.setLevel(regionModel.getLevel().trim());
regionModel.setLevelName(regionModel.getLevelName().trim()); regionModel.setLevelName(ValidationUtil.isEmpty(regionModel.getLevelName()) ? "" : regionModel.getLevelName().trim());
if(!ValidationUtil.isEmpty(regionModel.getChildren())) { if(!ValidationUtil.isEmpty(regionModel.getChildren())) {
despace(regionModel.getChildren()); despace(regionModel.getChildren());
} }
......
...@@ -221,6 +221,14 @@ public class IdxBizJgUseInfo extends TzsBaseEntity { ...@@ -221,6 +221,14 @@ public class IdxBizJgUseInfo extends TzsBaseEntity {
@TableField("\"IS_NOT_XIXIAN\"") @TableField("\"IS_NOT_XIXIAN\"")
private String isNotXiXian; private String isNotXiXian;
@TableField("\"STREET_NAME\"") @TableField("\"STREET_NAME\"")
private String streetName; private String streetName;
/**
*
*/
@TableField("\"SAFETY_MANAGER_ID\"")
private String safetyManagerId;
} }
...@@ -6,6 +6,8 @@ import com.yeejoin.amos.boot.module.ymt.api.enums.EquipmentCategoryEnum; ...@@ -6,6 +6,8 @@ import com.yeejoin.amos.boot.module.ymt.api.enums.EquipmentCategoryEnum;
import com.yeejoin.amos.boot.module.ymt.api.mapper.CategoryOtherInfoMapper; import com.yeejoin.amos.boot.module.ymt.api.mapper.CategoryOtherInfoMapper;
import com.yeejoin.amos.boot.module.ymt.api.service.IGenerateCodeService; import com.yeejoin.amos.boot.module.ymt.api.service.IGenerateCodeService;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.redisson.api.RLock;
import org.redisson.api.RedissonClient;
import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.core.StringRedisTemplate; import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.core.ValueOperations; import org.springframework.data.redis.core.ValueOperations;
...@@ -33,17 +35,19 @@ public class GenerateCodeServiceImpl implements IGenerateCodeService { ...@@ -33,17 +35,19 @@ public class GenerateCodeServiceImpl implements IGenerateCodeService {
private static final String LOCK_KEY_SUPERVISORY = "sequence_lock_supervisory"; private static final String LOCK_KEY_SUPERVISORY = "sequence_lock_supervisory";
private static final String SEQUENCE_TYPE_UR = "%05d"; private static final String SEQUENCE_TYPE_UR = "%05d";
private static final String SEQUENCE_TYPE = "%07d"; private static final String SEQUENCE_TYPE = "%07d";
private static final long LOCK_EXPIRATION_SECONDS = 60;
private final RedisTemplate<String, String> redisTemplate; private final RedisTemplate<String, String> redisTemplate;
private final StringRedisTemplate stringRedisTemplate; private final StringRedisTemplate stringRedisTemplate;
private final CategoryOtherInfoMapper categoryOtherInfoMapper; private final CategoryOtherInfoMapper categoryOtherInfoMapper;
private final RedissonClient redissonClient;
private String rulePrefix = ""; private String rulePrefix = "";
public GenerateCodeServiceImpl(RedisTemplate<String, String> redisTemplate, StringRedisTemplate stringRedisTemplate, CategoryOtherInfoMapper categoryOtherInfoMapper) { public GenerateCodeServiceImpl(RedisTemplate<String, String> redisTemplate, StringRedisTemplate stringRedisTemplate, CategoryOtherInfoMapper categoryOtherInfoMapper, RedissonClient redissonClient) {
this.redisTemplate = redisTemplate; this.redisTemplate = redisTemplate;
this.redissonClient = redissonClient;
this.stringRedisTemplate = stringRedisTemplate; this.stringRedisTemplate = stringRedisTemplate;
this.categoryOtherInfoMapper = categoryOtherInfoMapper; this.categoryOtherInfoMapper = categoryOtherInfoMapper;
} }
/** /**
* 生成申请单编号(13位,GZ20231214000) * 生成申请单编号(13位,GZ20231214000)
* *
...@@ -109,9 +113,11 @@ public class GenerateCodeServiceImpl implements IGenerateCodeService { ...@@ -109,9 +113,11 @@ public class GenerateCodeServiceImpl implements IGenerateCodeService {
private String generateSupervisorySequence(String sequenceKey) { private String generateSupervisorySequence(String sequenceKey) {
// 使用分布式锁,确保在并发情况下只有一个线程能够生成顺序码 // 使用分布式锁,确保在并发情况下只有一个线程能够生成顺序码
Boolean lockAcquired = obtainLock(GenerateCodeServiceImpl.LOCK_KEY_SUPERVISORY); RLock lock = redissonClient.getLock(LOCK_KEY_SUPERVISORY);
if (Boolean.TRUE.equals(lockAcquired)) { try {
try { log.info("尝试获取锁: {}", lock.tryLock(10, TimeUnit.SECONDS));
if (lock.isLocked()) {
// 获取当前顺序码 // 获取当前顺序码
ValueOperations<String, String> valueOps = redisTemplate.opsForValue(); ValueOperations<String, String> valueOps = redisTemplate.opsForValue();
String currentSequenceStr = valueOps.get(sequenceKey); String currentSequenceStr = valueOps.get(sequenceKey);
...@@ -126,16 +132,21 @@ public class GenerateCodeServiceImpl implements IGenerateCodeService { ...@@ -126,16 +132,21 @@ public class GenerateCodeServiceImpl implements IGenerateCodeService {
// 更新顺序码 // 更新顺序码
valueOps.set(sequenceKey, formattedSequence); valueOps.set(sequenceKey, formattedSequence);
return sequenceKey + "-" + formattedSequence; return sequenceKey + "-" + formattedSequence;
} finally { } else {
releaseLock(GenerateCodeServiceImpl.LOCK_KEY_SUPERVISORY); throw new RuntimeException("Failed to acquire lock for sequence generation");
} }
} else { } catch (InterruptedException e) {
throw new RuntimeException("Failed to acquire lock for sequence generation"); Thread.currentThread().interrupt(); // 保持中断状态
throw new RuntimeException("Thread interrupted while acquiring lock", e);
} finally {
lock.unlock(); // 释放锁
log.info("释放锁");
} }
} }
/** /**
* 监管码为空的话,初始化Redis * 监管码为空的话,初始化Redis
*
* @param sequenceKey key * @param sequenceKey key
* @return 顺序码 * @return 顺序码
*/ */
...@@ -165,11 +176,13 @@ public class GenerateCodeServiceImpl implements IGenerateCodeService { ...@@ -165,11 +176,13 @@ public class GenerateCodeServiceImpl implements IGenerateCodeService {
* @param batchSize 批量生成个数 * @param batchSize 批量生成个数
* @return List * @return List
*/ */
public synchronized List<String> generateBatchSequence(String sequenceKey, int batchSize) { public List<String> generateBatchSequence(String sequenceKey, int batchSize) {
// 使用分布式锁,确保在并发情况下只有一个线程能够生成顺序码 RLock lock = redissonClient.getLock(LOCK_KEY_AF);
Boolean lockAcquired = obtainLock(LOCK_KEY_AF);
if (Boolean.TRUE.equals(lockAcquired)) { try {
try { log.info("尝试获取锁: {}", lock.tryLock(10, TimeUnit.SECONDS));
if (lock.isLocked()) {
// 获取当前顺序码 // 获取当前顺序码
ValueOperations<String, String> valueOps = redisTemplate.opsForValue(); ValueOperations<String, String> valueOps = redisTemplate.opsForValue();
String currentSequenceStr = valueOps.get(sequenceKey); String currentSequenceStr = valueOps.get(sequenceKey);
...@@ -192,12 +205,16 @@ public class GenerateCodeServiceImpl implements IGenerateCodeService { ...@@ -192,12 +205,16 @@ public class GenerateCodeServiceImpl implements IGenerateCodeService {
} }
return sequenceList; return sequenceList;
} finally { } else {
releaseLock(LOCK_KEY_AF); // 获取锁失败,可以选择重试或采取其他策略
throw new RuntimeException("Failed to acquire lock for sequence generation");
} }
} else { } catch (InterruptedException e) {
// 获取锁失败,可以选择重试或采取其他策略 Thread.currentThread().interrupt(); // 保持中断状态
throw new RuntimeException("Failed to acquire lock for sequence generation"); throw new RuntimeException("Thread interrupted while acquiring lock", e);
} finally {
lock.unlock(); // 释放锁
log.info("释放锁");
} }
} }
...@@ -211,9 +228,13 @@ public class GenerateCodeServiceImpl implements IGenerateCodeService { ...@@ -211,9 +228,13 @@ public class GenerateCodeServiceImpl implements IGenerateCodeService {
*/ */
public String generateSequence(String sequenceKey, String sequenceType, String lockKey) { public String generateSequence(String sequenceKey, String sequenceType, String lockKey) {
// 使用分布式锁,确保在并发情况下只有一个线程能够生成顺序码 // 使用分布式锁,确保在并发情况下只有一个线程能够生成顺序码
Boolean lockAcquired = obtainLock(lockKey); RLock lock = redissonClient.getLock(lockKey);
if (Boolean.TRUE.equals(lockAcquired)) {
try { try {
log.info("尝试获取锁: {}", lock.tryLock(10, TimeUnit.SECONDS));
if (lock.isLocked()) {
// 获取当前顺序码 // 获取当前顺序码
ValueOperations<String, String> valueOps = redisTemplate.opsForValue(); ValueOperations<String, String> valueOps = redisTemplate.opsForValue();
String currentSequenceStr = valueOps.get(sequenceKey); String currentSequenceStr = valueOps.get(sequenceKey);
...@@ -236,40 +257,47 @@ public class GenerateCodeServiceImpl implements IGenerateCodeService { ...@@ -236,40 +257,47 @@ public class GenerateCodeServiceImpl implements IGenerateCodeService {
log.info("===================>返回《{}》顺序码:{}<===================", sequenceKey, result); log.info("===================>返回《{}》顺序码:{}<===================", sequenceKey, result);
return result; return result;
} else {
} finally { throw new RuntimeException("Failed to acquire lock for sequence generation");
releaseLock(lockKey);
} }
} else { } catch (InterruptedException e) {
throw new RuntimeException("Failed to acquire lock for sequence generation"); Thread.currentThread().interrupt(); // 保持中断状态
throw new RuntimeException("Thread interrupted while acquiring lock", e);
} finally {
lock.unlock(); // 释放锁
log.info("释放锁");
} }
} }
/** /**
* 生成顺序码 * 生成顺序码
* *
* @param sequenceKey redisKey * @param sequenceKey Redis Key
* @param sequenceType 生成码类型 * @param sequenceType 生成码类型
* @param lockKey redis锁 * @param lockKey Redis锁Key
* @return s * @return 生成的顺序码
*/ */
public String generateElevatorSequence(String sequenceKey, String sequenceType, String lockKey) { public String generateElevatorSequence(String sequenceKey, String sequenceType, String lockKey) {
// 使用分布式锁,确保在并发情况下只有一个线程能够生成顺序码 // 使用分布式锁,确保在并发情况下只有一个线程能够生成顺序码
Boolean lockAcquired = obtainLock(lockKey); RLock lock = redissonClient.getLock(lockKey);
if (Boolean.TRUE.equals(lockAcquired)) {
try { try {
log.info("尝试获取锁: {}", lock.tryLock(10, TimeUnit.SECONDS));
if (lock.isLocked()) {
// 获取当前顺序码 // 获取当前顺序码
ValueOperations<String, String> valueOps = redisTemplate.opsForValue(); ValueOperations<String, String> valueOps = redisTemplate.opsForValue();
String currentSequenceStr = valueOps.get(sequenceKey); String currentSequenceStr = valueOps.get(sequenceKey);
// 如果为空,则初始化为0 // 如果为空,则初始化为0
if (currentSequenceStr == null) { if (currentSequenceStr == null) {
currentSequenceStr = EquipmentCategoryEnum.getCodeByValue(sequenceKey); String initialCode = EquipmentCategoryEnum.getCodeByValue(sequenceKey);
log.info("===================>获取《{}》初始码:{}<===================", sequenceKey, currentSequenceStr); log.info("===================>获取《{}》初始码:{}<===================", sequenceKey, initialCode);
return currentSequenceStr; return initialCode;
} }
Long currentSequence = Long.parseLong(currentSequenceStr);
Long currentSequence = Long.parseLong(currentSequenceStr);
log.info("===================>获取《{}》当前顺序码:{}<===================", sequenceKey, currentSequenceStr); log.info("===================>获取《{}》当前顺序码:{}<===================", sequenceKey, currentSequenceStr);
currentSequence++; currentSequence++;
// 生成顺序码 // 生成顺序码
String formattedSequence = String.format(sequenceType, currentSequence); String formattedSequence = String.format(sequenceType, currentSequence);
...@@ -277,12 +305,15 @@ public class GenerateCodeServiceImpl implements IGenerateCodeService { ...@@ -277,12 +305,15 @@ public class GenerateCodeServiceImpl implements IGenerateCodeService {
// 更新顺序码 // 更新顺序码
valueOps.set(sequenceKey, formattedSequence); valueOps.set(sequenceKey, formattedSequence);
return formattedSequence; return formattedSequence;
} else {
} finally { throw new RuntimeException("Failed to acquire lock for sequence generation");
releaseLock(lockKey);
} }
} else { } catch (InterruptedException e) {
throw new RuntimeException("Failed to acquire lock for sequence generation"); Thread.currentThread().interrupt(); // 保持中断状态
throw new RuntimeException("Thread interrupted while acquiring lock", e);
} finally {
lock.unlock(); // 释放锁
log.info("释放锁");
} }
} }
...@@ -296,9 +327,11 @@ public class GenerateCodeServiceImpl implements IGenerateCodeService { ...@@ -296,9 +327,11 @@ public class GenerateCodeServiceImpl implements IGenerateCodeService {
*/ */
public boolean reduceSequence(String sequenceKey, String sequenceType, String lockKey) { public boolean reduceSequence(String sequenceKey, String sequenceType, String lockKey) {
// 使用分布式锁,确保在并发情况下只有一个线程能够生成顺序码 // 使用分布式锁,确保在并发情况下只有一个线程能够生成顺序码
Boolean lockAcquired = obtainLock(lockKey); RLock lock = redissonClient.getLock(lockKey);
if (Boolean.TRUE.equals(lockAcquired)) { try {
try { lock.lock(); // 获取锁
log.info("尝试获取锁: {}", lock.tryLock(10, TimeUnit.SECONDS));
if (lock.isLocked()) {
// 获取当前顺序码 // 获取当前顺序码
ValueOperations<String, String> valueOps = redisTemplate.opsForValue(); ValueOperations<String, String> valueOps = redisTemplate.opsForValue();
String currentSequenceStr = valueOps.get(sequenceKey); String currentSequenceStr = valueOps.get(sequenceKey);
...@@ -321,36 +354,16 @@ public class GenerateCodeServiceImpl implements IGenerateCodeService { ...@@ -321,36 +354,16 @@ public class GenerateCodeServiceImpl implements IGenerateCodeService {
log.warn("===================>无法回退《{}》顺序码,当前顺序码已为0<===================", sequenceKey); log.warn("===================>无法回退《{}》顺序码,当前顺序码已为0<===================", sequenceKey);
return false; // 无法回退,当前顺序码已为0 return false; // 无法回退,当前顺序码已为0
} }
} finally { } else {
releaseLock(lockKey); throw new RuntimeException("Failed to acquire lock for sequence generation");
} }
} else { } catch (InterruptedException e) {
throw new RuntimeException("Failed to acquire lock for sequence generation"); Thread.currentThread().interrupt(); // 保持中断状态
} throw new RuntimeException("Thread interrupted while acquiring lock", e);
} } finally {
lock.unlock(); // 释放锁
/** log.info("释放锁");
* 分布式锁
*
* @param lockKey lockKey
* @return bool
*/
private Boolean obtainLock(String lockKey) {
Boolean lockAcquired = redisTemplate.opsForValue().setIfAbsent(lockKey, LOCK_VALUE);
if (lockAcquired != null && lockAcquired) {
redisTemplate.expire(lockKey, LOCK_EXPIRATION_SECONDS, TimeUnit.SECONDS);
} }
return lockAcquired;
}
/**
* 释放锁
*
* @param lockKey lockKey
*/
private void releaseLock(String lockKey) {
redisTemplate.delete(lockKey);
} }
/** /**
......
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