Commit edb1caa3 authored by liufan's avatar liufan

添加:使用登记列表添加下载使用登记证功能

parent 0df545e6
......@@ -17,6 +17,7 @@ import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
......@@ -133,4 +134,11 @@ public class JgUseRegistrationController extends BaseController {
return ResponseHelper.buildResponse(map);
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@GetMapping(value = "/export")
@ApiOperation(httpMethod = "GET", value = "导出使用登记证", notes = "导出使用登记证")
public void exportImageZip(HttpServletResponse response, @RequestParam("sequenceNbr") String sequenceNbr){
jgUseRegistrationServiceImpl.exportUseRegistrationCertificate(sequenceNbr, response);
}
}
......@@ -20,7 +20,12 @@ import com.yeejoin.amos.boot.module.jg.api.mapper.JgUseRegistrationEqMapper;
import com.yeejoin.amos.boot.module.jg.api.mapper.JgUseRegistrationMapper;
import com.yeejoin.amos.boot.module.jg.api.service.IJgUseRegistrationService;
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.flc.api.fegin.WorkFlowFeignService;
import com.yeejoin.amos.boot.module.ymt.api.entity.EquipmentCategory;
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.entity.InspectionDetectionInfo;
import com.yeejoin.amos.boot.module.ymt.api.entity.OtherInfo;
import com.yeejoin.amos.boot.module.ymt.api.entity.UseInfo;
......@@ -35,14 +40,19 @@ 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.stereotype.Service;
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.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.*;
/**
......@@ -72,6 +82,15 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
JgRegistrationHistoryServiceImpl jgRegistrationHistoryService;
@Autowired
IdxBizJgRegisterInfoMapper idxBizJgRegisterInfoMapper;
@Autowired
private IdxBizJgRegisterInfoServiceImpl idxBizJgRegisterInfoService;
@Autowired
private IdxBizJgUseInfoServiceImpl idxBizJgUseInfoService;
@Autowired
private IdxBizJgFactoryInfoServiceImpl idxBizJgFactoryInfoService;
@Autowired
ICommonService commonService;
public Page<Map<String, Object>> getList(JgUseRegistrationDto dto, Page<Map<String, Object>> page, List<String> roleIds) {
Page<Map<String, Object>> listPage = this.baseMapper.getListPage(page, dto, roleIds);
return listPage;
......@@ -468,4 +487,118 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
}
return null;
}
public void exportUseRegistrationCertificate(String sequenceNbr, HttpServletResponse response) {
Map<String, Object> exportParamsMap = new HashMap<>();
//查询使用登记详情
JgUseRegistration useRegistration = this.getById(sequenceNbr);
LambdaQueryWrapper<JgUseRegistrationEq> useEqLambda = new QueryWrapper<JgUseRegistrationEq>().lambda();
useEqLambda.eq(JgUseRegistrationEq::getEquipTransferId, sequenceNbr);
JgUseRegistrationEq useRegistrationEq = jgRelationEquipMapper.selectOne(useEqLambda);
if (ValidationUtil.isEmpty(useRegistration) || ValidationUtil.isEmpty(useRegistrationEq)) {
throw new BadRequest("使用登记证导出失败,请稍后重试!");
}
//登记机关
if(ValidationUtil.isEmpty(useRegistration.getReceiveOrgName())){
throw new BadRequest("使用登记证导出失败,登记机关为空!");
}
exportParamsMap.put("receiveOrgName", useRegistration.getReceiveOrgName());
//使用登记证编号
if(ValidationUtil.isEmpty(useRegistration.getUseRegistrationCode())){
throw new BadRequest("使用登记证导出失败,使用登记证编号为空!");
}
exportParamsMap.put("useRegistrationCode", useRegistration.getUseRegistrationCode());
//使用单位名称
if(ValidationUtil.isEmpty(useRegistration.getUseUnitName())){
throw new BadRequest("使用登记证导出失败,使用单位名称为空!");
}
exportParamsMap.put("useUnitName", useRegistration.getUseUnitName());
//监管码
if(ValidationUtil.isEmpty(useRegistration.getSupervisoryCode())){
throw new BadRequest("使用登记证导出失败,监管码为空!");
}
exportParamsMap.put("supervisoryCode", useRegistration.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", useRegistrationEq.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(useRegistrationEq.getEquId());
if(!ValidationUtil.isEmpty(useInfo)){
if(ValidationUtil.isEmpty(useInfo.getUseInnerCode())){
throw new BadRequest("使用登记证导出失败,设备单位内部编码为空!");
}
//单位内部编码
exportParamsMap.put("useInnerCode", useInfo.getUseInnerCode());
//设备使用地址
String fullAddress="";
if (!ObjectUtils.isEmpty(useInfo.getProvinceName())) {
fullAddress += useInfo.getProvinceName();
}
if (!ObjectUtils.isEmpty(useInfo.getCityName())) {
fullAddress += useInfo.getCityName();
}
if (!ObjectUtils.isEmpty(useInfo.getCountyName())) {
fullAddress += useInfo.getCountyName();
}
if (!ObjectUtils.isEmpty(useInfo.getStreetName())) {
fullAddress += useInfo.getStreetName();
}
if (!ObjectUtils.isEmpty(useInfo.getAddress())) {
fullAddress += useInfo.getAddress();
}
if(ValidationUtil.isEmpty(fullAddress)){
throw new BadRequest("使用登记证导出失败,设备使用地址为空!");
}
exportParamsMap.put("fullAddress", fullAddress);
}
IdxBizJgFactoryInfo factoryInfo = idxBizJgFactoryInfoService.getOneData(useRegistrationEq.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