Commit dbe0081b authored by 麻笑宇's avatar 麻笑宇

Merge remote-tracking branch 'origin/develop_tzs_register_to_0715' into…

Merge remote-tracking branch 'origin/develop_tzs_register_to_0715' into develop_tzs_register_to_0715
parents 023cb216 4b4afe68
......@@ -307,5 +307,16 @@ public class JgInstallationNoticeDto extends BaseDto {
@ApiModelProperty(value = "作废日期")
private Date cancelDate;
/**
* 冗余设备类别
*/
private String equCategoryCode;
/**
* 工程装置
*/
private String projectContraption;
/**
* 冗余设备种类
*/
private String equListCode;
}
......@@ -471,4 +471,20 @@ public class JgInstallationNotice extends BaseEntity {
*/
@TableField("cancel_user_id")
private String cancelUserId;
/**
* 冗余设备类别
*/
@TableField("equ_category_code")
private String equCategoryCode;
/**
* 工程装置
*/
@TableField("project_contraption")
private String projectContraption;
/**
* 冗余设备种类
*/
@TableField("equ_list_code")
private String equListCode;
}
......@@ -34,4 +34,21 @@ public class JgInstallationNoticeEq extends BaseEntity {
@TableField("equ_id")
private String equId;
/**
* 告知单编号
*/
@TableField("inform_number")
private String informNumber;
/**
* 设备类别
*/
@TableField("equ_category_code")
private String equCategoryCode;
/**
* 设备种类
*/
@TableField("equ_list_code")
private String equListCode;
}
......@@ -84,4 +84,6 @@ public interface IJgInstallationNoticeService extends IService<JgInstallationNot
* @return JgInstallationNoticeDto
*/
JgInstallationNotice cancelApplication(Long sequenceNbr, String cancelReason);
Boolean historyDataRepair();
}
......@@ -24,23 +24,14 @@
isn.next_execute_ids AS nextExecuteIds,
isn.instance_status AS instanceStatus,
DATE_FORMAT(isn.handle_date,'%Y-%m-%d') AS handleDate,
other.CODE96333 AS code96333,
(select name from tz_equipment_category ec WHERE ec.code = ri.equ_category) AS equList,
isn.notice_report_url AS noticeReportUrl,
isn.create_user_id as createUserId,
isn.next_task_id AS nextTaskId,
isn.next_execute_user_ids as nextExecuteUserIds,
ri.EQU_CODE AS equCode,
(select name from tz_equipment_category ec WHERE ec.code = ri.EQU_DEFINE) AS equDefine,
(SELECT name from tz_equipment_category where code = ri.EQU_LIST) AS equListName,
concat(ibjui."PROVINCE_NAME", '', ibjui."CITY_NAME", '', ibjui."COUNTY_NAME", '', ibjui."STREET_NAME") as equAddress,
ibjui."ADDRESS" as detailedAddress,
(SELECT name from tz_equipment_category where code = isn.equ_list_code) AS equListName,
(SELECT name from tz_equipment_category where code = isn.equ_category_code) AS equList,
isn.cancel_reason as cancelReason
FROM tzs_jg_installation_notice isn
LEFT JOIN tzs_jg_installation_notice_eq insEq on insEq.equip_transfer_id = isn.sequence_nbr
LEFT JOIN idx_biz_jg_use_info ibjui on insEq.equ_id = ibjui.RECORD
LEFT JOIN idx_biz_jg_register_info ri ON ri.record = insEq.equ_id
LEFT JOIN idx_biz_jg_other_info other on other.RECORD = insEq.equ_id
<where>
isn.is_delete = false
<if test="param != null ">
......@@ -65,28 +56,11 @@
<if test="param.supervisoryCode != null and param.supervisoryCode != ''">
AND isn."supervisory_code" LIKE concat('%',#{param.supervisoryCode},'%')
</if>
<if test="param.code96333 != null and param.code96333 != ''">
AND other."CODE96333" LIKE concat('%',#{param.code96333},'%')
</if>
<if test="param.equCode != null and param.equCode != ''">
AND ri."EQU_CODE" LIKE concat('%',#{param.equCode},'%')
</if>
<if test="param.equList != null and param.equList != ''">
AND ri."EQU_LIST" = #{param.equList}
AND isn."equ_list_code" = #{param.equList}
</if>
<if test="param.equipCategory != null and param.equipCategory != ''">
AND ri."equ_category" = #{param.equipCategory}
</if>
<if test="param.equDefine != null and param.equDefine != ''">
AND ri."EQU_DEFINE" = #{param.equDefine}
</if>
<if test="param.equAddress != null and param.equAddress != ''">
AND (
ibjui."PROVINCE_NAME" LIKE CONCAT('%', #{param.equAddress}, '%')
OR ibjui."CITY_NAME" LIKE CONCAT('%', #{param.equAddress}, '%')
OR ibjui."COUNTY_NAME" LIKE CONCAT('%', #{param.equAddress}, '%')
OR ibjui."STREET_NAME" LIKE CONCAT('%', #{param.equAddress}, '%')
)
AND isn."equ_category_code" = #{param.equipCategory}
</if>
<if test="param.useUnitCreditCode != null and param.useUnitCreditCode != ''">
AND isn.use_unit_credit_code = #{param.useUnitCreditCode}
......@@ -129,7 +103,7 @@
isn.install_leader_name AS installLeaderName,
isn.install_leader_phone AS installLeaderPhone,
isn.use_unit_name AS useUnitName,
isn.inform_number AS informNumber,
isn.other_accessories AS otherAccessories,
tec2.name AS equCategory,
tec1.name AS equList,
......@@ -168,6 +142,7 @@
useUnit.address as useUnitLeaderAddress,
re.equ_id as equId,
installUnit.address installUnitAddress,
re.inform_number informNumber,
(select idi.INSPECT_REPORT from idx_biz_jg_inspection_detection_info idi Where idi.record = re.equ_id ORDER BY idi.INSPECT_DATE desc LIMIT 1) as inspectReport
FROM
tzs_jg_installation_notice isn
......@@ -181,7 +156,7 @@
LEFT JOIN amos_tzs_biz.tz_equipment_category tec1 ON ri."EQU_LIST"::text = tec1.code::text
LEFT JOIN amos_tzs_biz.tz_equipment_category tec2 ON ri."EQU_DEFINE"::text = tec2.code::text
WHERE
isn.sequence_nbr = #{sequenceNbr}
re.sequence_nbr = #{sequenceNbr}
LIMIT 1
</select>
<select id="queryForFlowingEquipList" resultType="com.yeejoin.amos.boot.module.jg.api.dto.CompanyEquipCountDto">
......
......@@ -17,6 +17,7 @@ import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
......@@ -66,7 +67,7 @@ public class JgInstallationNoticeController extends BaseController {
@ApiOperation(httpMethod = "PUT", value = "根据sequenceNbr更新安装告知", notes = "根据sequenceNbr更新安装告知")
public ResponseModel<JgInstallationNoticeDto> updateBySequenceNbrJgInstallationNotice(@RequestParam String submitType, @RequestBody Map<String, Object> model, @RequestParam(value = "op", required = false) String op) {
JgInstallationNoticeDto installationInfo = BeanUtil.mapToBean(((LinkedHashMap) model.get("installationInfo")), JgInstallationNoticeDto.class, true);
installationInfo.setEquList(((LinkedHashMap<?, ?>) model.get("installationInfo")).get("equListDesc").toString());
// installationInfo.setEquList(((LinkedHashMap<?, ?>) model.get("installationInfo")).get("equListDesc").toString());
if (Objects.isNull(installationInfo)) {
throw new IllegalArgumentException("参数installationInfo不能为空");
}
......@@ -169,4 +170,12 @@ public class JgInstallationNoticeController extends BaseController {
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET", value = "安装告知历史数据修复", notes = "安装告知历史数据修复")
@GetMapping(value = "/historyDataRepair")
public ResponseModel<Boolean> historyDataRepair() {
return ResponseHelper.buildResponse(iJgInstallationNoticeService.historyDataRepair());
}
}
package com.yeejoin.amos.boot.module.jg.biz.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.text.CharSequenceUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
......@@ -28,6 +29,7 @@ import com.yeejoin.amos.boot.module.jg.api.mapper.JgInstallationNoticeMapper;
import com.yeejoin.amos.boot.module.jg.api.mapper.JgRegistrationHistoryMapper;
import com.yeejoin.amos.boot.module.jg.api.mapper.JgUseRegistrationMapper;
import com.yeejoin.amos.boot.module.jg.api.service.IJgInstallationNoticeService;
import com.yeejoin.amos.boot.module.jg.api.service.IJgRegistrationHistoryService;
import com.yeejoin.amos.boot.module.jg.api.vo.SortVo;
import com.yeejoin.amos.boot.module.jg.biz.config.LocalBadRequest;
import com.yeejoin.amos.boot.module.jg.biz.context.EquipUsedCheckStrategyContext;
......@@ -75,6 +77,7 @@ import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import javax.servlet.http.HttpServletResponse;
import java.lang.reflect.Field;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
......@@ -115,6 +118,8 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN
@Autowired
JgInstallationNoticeEqMapper jgInstallationNoticeEqMapper;
@Autowired
JgInstallationNoticeEqServiceImpl jgInstallationNoticeEqService;
@Autowired
JgUseRegistrationMapper jgUseRegistrationMapper;
@Autowired
IdxBizJgUseInfoServiceImpl idxBizJgUseInfoService;
......@@ -183,6 +188,11 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN
@Autowired
private IdxBizJgFactoryInfoServiceImpl idxBizJgFactoryInfoService;
@Autowired
private JgRegistrationHistoryServiceImpl jgRegistrationHistoryService;
@Autowired
private EquipTechParamPipelineMapper equipTechParamPipelineMapper;
/**
* 根据sequenceNbr查询
*
......@@ -201,7 +211,27 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN
installationInfo.put("province", notice.getProvince() + "_" + notice.getProvinceName());
installationInfo.put("city", notice.getCity() + "_" + notice.getCityName());
installationInfo.put("county", notice.getCounty() + "_" + notice.getCountyName());
// 处理安装负责人-详情
if (!ObjectUtils.isEmpty(installationInfo.get("installLeaderName"))){
installationInfo.put("installLeaderName", installationInfo.get("installLeaderName"));
}
// 处理设备类型
if (!ObjectUtils.isEmpty(installationInfo.get("equCategoryCode"))){
installationInfo.put("EQU_CATEGORY_CODE", installationInfo.get("equCategoryCode"));
}
// 处理设备筛选默认值
installationInfo.put("QUERY_TYPE", "AZ");
installationInfo.put("IS_INTO_MANAGEMENT", "false");
// 处理图片
if (!ValidationUtil.isEmpty(installationInfo.get("proxyStatementAttachment"))) {
installationInfo.put("proxyStatementAttachmentList", JSONObject.parseArray(installationInfo.get("proxyStatementAttachment").toString()));
}
if (!ValidationUtil.isEmpty(installationInfo.get("installContractAttachment"))) {
installationInfo.put("installContractAttachmentList", JSONObject.parseArray(installationInfo.get("installContractAttachment").toString()));
}
if (!ValidationUtil.isEmpty(installationInfo.get("otherAccessories"))) {
installationInfo.put("otherAccessoriesList", JSONObject.parseArray(installationInfo.get("otherAccessories").toString()));
}
TzBaseEnterpriseInfo useCodeResult = tzBaseEnterpriseInfoMapper.selectOne(
new QueryWrapper<TzBaseEnterpriseInfo>()
.eq("use_unit_code", notice.getUseUnitCreditCode())
......@@ -246,7 +276,7 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN
"productQualityYieldProve", "insUseMaintainExplain", "inspectReport",
"proxyStatementAttachment", "installContractAttachment", "otherAccessories"};
// 设备信息
List<Map<String, Object>> equipmentInfos = jgInstallationNoticeMapper.queryEquipInformation(sequenceNbr);
// List<Map<String, Object>> equipmentInfos = jgInstallationNoticeMapper.queryEquipInformation(sequenceNbr);
for (String s : fields) {
if (installationInfo.containsKey(s)) {
installationInfo.put(s, ObjectUtils.isEmpty(installationInfo.get(s)) ? new JSONArray() : parseArray(installationInfo.get(s).toString()));
......@@ -257,7 +287,7 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN
JSONObject hisData = commonService.queryHistoryData(notice.getSequenceNbr());
// 兼容老数据
if (hisData == null) {
Map<String, Object> detail = setNewEquipData(companyLevel, installationInfo, equipmentInfos);
Map<String, Object> detail = setNewEquipData(companyLevel, installationInfo);
return new HashMap<String, Map<String, Object>>() {{
this.put("installationInfo", detail);
}};
......@@ -270,30 +300,69 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN
}
} else {
// 显示最新的设备信息
Map<String, Object> detail = setNewEquipData(companyLevel, installationInfo, equipmentInfos);
Map<String, Object> detail = setNewEquipData(companyLevel, installationInfo);
return new HashMap<String, Map<String, Object>>() {{
this.put("installationInfo", detail);
}};
}
}
private Map<String, Object> setNewEquipData(String companyLevel, Map<String, Object> installationInfo, List<Map<String, Object>> equipmentInfos) {
Map<String, Object> detail = equipmentInfos.get(0);
Map<String, Object> equInfo = idxBizJgRegisterInfoService.getDetailFieldCamelCaseByRecord(detail.get("equId").toString());
equInfo.put("useUnitCreditCodeUse", equInfo.getOrDefault("useUnitCreditCode", ""));
equInfo.put("useUnitNameUse", equInfo.getOrDefault("useUnitName", ""));
equInfo.put("productPhoto", JSON.parse(String.valueOf(detail.get("productPhoto"))));
equInfo.put("factoryStandard", JSON.parse(String.valueOf(detail.get("factoryStandard"))));
equInfo.put("productQualityYieldProve", JSON.parse(String.valueOf(detail.get("productQualityYieldProve"))));
equInfo.put("insUseMaintainExplain", JSON.parse(String.valueOf(detail.get("insUseMaintainExplain"))));
equInfo.put("inspectReport", JSON.parse(String.valueOf(detail.get("inspectReport"))));
equInfo.put("designStandard", JSON.parse(String.valueOf(detail.get("designStandard"))));
equInfo.put("designDoc", JSON.parse(String.valueOf(detail.get("designDoc"))));
equInfo.put("otherAccessoriesList", JSON.parse(String.valueOf(detail.get("otherAccessories"))));
BeanUtil.copyProperties(equInfo, detail);
BeanUtil.copyProperties(installationInfo, detail, "equList", "supervisoryCode", "factoryNum", "equRegisterCode");
detail.put("companyLevel", companyLevel);
return detail;
private List<Map<String, Object>> getEquipListMaps(Iterable<ESEquipmentCategoryDto> equips) {
List<Map<String, Object>> arrayList = new ArrayList<>();
equips.forEach(equip -> {
Map<String, Object> objectHashMap = new HashMap<>();
BeanUtil.beanToMap(equip, objectHashMap, false, false);
objectHashMap.put("record", equip.getSEQUENCE_NBR());
objectHashMap.put("ADDRESS", concatDetailAddress(equip));
arrayList.add(objectHashMap);
});
return arrayList;
}
private String concatDetailAddress(ESEquipmentCategoryDto esEquipmentCategoryDto) {
// 省、市、区
String usePlace = esEquipmentCategoryDto.getUSE_PLACE();
// 详细地址
String address = esEquipmentCategoryDto.getADDRESS();
return String.format("%s%s", usePlace, address);
}
private Map<String, Object> setNewEquipData(String companyLevel, Map<String, Object> installationInfo) {
LambdaQueryWrapper<JgInstallationNoticeEq> lambda = new QueryWrapper<JgInstallationNoticeEq>().lambda();
lambda.eq(JgInstallationNoticeEq::getEquipTransferId,installationInfo.get("sequenceNbr"));
List<JgInstallationNoticeEq> jgInstallationNoticeEqs = jgInstallationNoticeEqMapper.selectList(lambda);
List<String> ids = jgInstallationNoticeEqs.stream().map(item -> item.getEquId()).collect(Collectors.toList());
Iterable<ESEquipmentCategoryDto> equips = esEquipmentCategory.findAllById(ids);
List<Map<String, Object>> equipListMaps = getEquipListMaps(equips);
// Map<String, Object> detail = equipmentInfos.get(0);
// Map<String, Object> equInfo = idxBizJgRegisterInfoService.getDetailFieldCamelCaseByRecord(detail.get("equId").toString());
// equInfo.put("useUnitCreditCodeUse", equInfo.getOrDefault("useUnitCreditCode", ""));
// equInfo.put("useUnitNameUse", equInfo.getOrDefault("useUnitName", ""));
// equInfo.put("productPhoto", JSON.parse(String.valueOf(detail.get("productPhoto"))));
// equInfo.put("factoryStandard", JSON.parse(String.valueOf(detail.get("factoryStandard"))));
// equInfo.put("productQualityYieldProve", JSON.parse(String.valueOf(detail.get("productQualityYieldProve"))));
// equInfo.put("insUseMaintainExplain", JSON.parse(String.valueOf(detail.get("insUseMaintainExplain"))));
// equInfo.put("inspectReport", JSON.parse(String.valueOf(detail.get("inspectReport"))));
// equInfo.put("designStandard", JSON.parse(String.valueOf(detail.get("designStandard"))));
// equInfo.put("designDoc", JSON.parse(String.valueOf(detail.get("designDoc"))));
// equInfo.put("otherAccessoriesList", JSON.parse(String.valueOf(detail.get("otherAccessories"))));
// BeanUtil.copyProperties(equInfo, detail);
// BeanUtil.copyProperties(installationInfo, detail, "equList", "supervisoryCode", "factoryNum", "equRegisterCode");
installationInfo.put("companyLevel", companyLevel);
installationInfo.put("deviceList", equipListMaps);
// // 处理图片
// if (!ValidationUtil.isEmpty(installationInfo.get("proxyStatementAttachment"))) {
// installationInfo.put("proxyStatementAttachmentList", installationInfo.get("proxyStatementAttachment"));
// }
// if (!ValidationUtil.isEmpty(installationInfo.get("installContractAttachment"))) {
// installationInfo.put("installContractAttachmentList", installationInfo.get("installContractAttachment"));
// }
// if (!ValidationUtil.isEmpty(installationInfo.get("otherAccessories"))) {
// installationInfo.put("otherAccessoriesList", installationInfo.get("otherAccessories"));
// }
return installationInfo;
}
/**
......@@ -413,6 +482,20 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN
BeanUtils.copyProperties(noticeDto, bean);
this.updateById(bean);
}
// 更新关联设备信息
LambdaQueryWrapper<JgInstallationNoticeEq> lambda = new QueryWrapper<JgInstallationNoticeEq>().lambda();
lambda.eq(JgInstallationNoticeEq::getEquipTransferId, noticeDto.getSequenceNbr());
jgInstallationNoticeEqMapper.delete(lambda);
ArrayList<JgInstallationNoticeEq> jgInstallationNoticeEqs = new ArrayList<>();
noticeDto.getDeviceList().forEach(item->{
JgInstallationNoticeEq jgInstallationNoticeEq = new JgInstallationNoticeEq();
jgInstallationNoticeEq.setEquId(String.valueOf(item.get("SEQUENCE_NBR")));
jgInstallationNoticeEq.setEquCategoryCode(String.valueOf(item.get("EQU_CATEGORY_CODE")));
jgInstallationNoticeEq.setEquListCode(String.valueOf(item.get("EQU_LIST_CODE")));
jgInstallationNoticeEq.setEquipTransferId(noticeDto.getSequenceNbr().toString());
jgInstallationNoticeEqs.add(jgInstallationNoticeEq);
});
jgInstallationNoticeEqMapper.insertBatchSomeColumn(jgInstallationNoticeEqs);
return noticeDto;
} catch (BadRequest | LocalBadRequest e) {
log.error(e.getMessage(), e);
......@@ -432,8 +515,10 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN
// 流程中校验
LambdaQueryWrapper<JgInstallationNoticeEq> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(JgInstallationNoticeEq::getEquipTransferId, jgInstallationNotice.getSequenceNbr());
JgInstallationNoticeEq jgRelationEquip = jgInstallationNoticeEqMapper.selectOne(queryWrapper);
EquipUsedCheckStrategyContext.getUsedStrategy(PROCESS_INSTALL_NOTICE_KEY).equipRepeatUsedCheck(jgRelationEquip.getEquId(), jgInstallationNotice.getInstallUnitCreditCode());
List<JgInstallationNoticeEq> jgInstallationNoticeEqs = jgInstallationNoticeEqMapper.selectList(queryWrapper);
for (JgInstallationNoticeEq jgInstallationNoticeEq : jgInstallationNoticeEqs) {
EquipUsedCheckStrategyContext.getUsedStrategy(PROCESS_INSTALL_NOTICE_KEY).equipRepeatUsedCheck(jgInstallationNoticeEq.getEquId(), jgInstallationNotice.getInstallUnitCreditCode());
}
}
}
......@@ -508,13 +593,18 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN
if (Objects.isNull(sequenceNbr)) {
throw new IllegalArgumentException("参数不能为空");
}
JgInstallationNotice jgInstallationNotice = this.getById(sequenceNbr);
List<Map<String, Object>> informationList = jgInstallationNoticeMapper.queryEquipInformation(sequenceNbr);
List<JgInstallationNoticeEq> equList = jgInstallationNoticeEqService.lambdaQuery().eq(JgInstallationNoticeEq::getEquipTransferId, jgInstallationNotice.getSequenceNbr()).list();
HashMap<String, Object> map = new HashMap<>();
ArrayList<Map<String, Object>> maps = new ArrayList<>();
equList.forEach(equ ->{
List<Map<String, Object>> informationList = jgInstallationNoticeMapper.queryEquipInformation(equ.getSequenceNbr());
if (Objects.isNull(jgInstallationNotice) || CollectionUtils.isEmpty(informationList)) {
throw new IllegalArgumentException("安装告知单不存在");
}
Map<String, Object> placeholders = fullFillTemplateObj(informationList, BusinessTypeEnum.JG_INSTALLATION_NOTIFICATION.getName().substring(0, 2));
maps.add(placeholders);
});
String tempFileName = "安装告知单_" + System.currentTimeMillis() + "_temp";
// String url = WordTemplateUtils.templateToPdf(tempFileName, "installation-notification-report.ftl", placeholders);
......@@ -522,8 +612,8 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN
// // 更新到数据库
// jgInstallationNotice.setNoticeReportUrl(url);
// this.updateById(jgInstallationNotice);
WordTemplateUtils.templateToPdfDownload(tempFileName, "installation-notification-report.ftl", placeholders, response);
map.put("equipBasicInfoList", maps);
WordTemplateUtils.templateToPdfDownload(tempFileName, "installation-notification-report.ftl", map, response);
}
public Map<String, Object> fullFillTemplateObj(List<Map<String, Object>> informationList, String businessType) {
......@@ -600,7 +690,7 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN
this.repeatUsedEquipCheck(deviceList, reginParams.getCompany().getCompanyCode());
}
// 获取告知单号
ResponseModel<List<String>> listResponseModel = tzsServiceFeignClient.applicationFormCode(ApplicationFormTypeEnum.AZGZ.getCode(), deviceList.size());
ResponseModel<List<String>> listResponseModel = tzsServiceFeignClient.applicationFormCode(ApplicationFormTypeEnum.AZGZ.getCode(), 1);
if (!ObjectUtils.isEmpty(listResponseModel) && listResponseModel.getStatus() != HttpStatus.OK.value()) {
log.error("告知单获取失败: {}", listResponseModel.getMessage());
throw new BadRequest("告知单生成失败!");
......@@ -726,46 +816,50 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN
private void businessData(String submitType, ReginParams reginParams, JgInstallationNoticeDto model, List<Map<String, Object>> deviceList, List<String> applyNoList, List<JgInstallationNotice> list, List<JgInstallationNoticeEq> equipList, List<WorkflowResultDto> workflowResultList) {
CompanyBo companyBo = commonService.getOneCompany(model.getReceiveOrgCreditCode());
deviceList.forEach(obj -> {
JgInstallationNoticeEq jgRelationEquip = new JgInstallationNoticeEq();
JgInstallationNotice dto = new JgInstallationNotice();
BeanUtils.copyProperties(model, dto);
int i = deviceList.indexOf(obj);
String applyNo = applyNoList.get(i);
// int i = deviceList.indexOf(obj);
String applyNo = applyNoList.get(0);
dto.setApplyNo(applyNo);
dto.setNoticeDate(new Date());
// 统计使用
dto.setReceiveCompanyOrgCode(companyBo.getOrgCode());
if (SUBMIT_TYPE_FLOW.equals(submitType)) {
dto.setNextExecuteIds(workflowResultList.get(i).getNextExecutorRoleIds());
dto.setNextExecuteUserIds(workflowResultList.get(i).getNextExecutorUserIds());
dto.setInstanceStatus(workflowResultList.get(i).getNextExecutorRoleIds() + "," + workflowResultList.get(i).getExecutorRoleIds());
dto.setNextExecuteIds(workflowResultList.get(0).getNextExecutorRoleIds());
dto.setNextExecuteUserIds(workflowResultList.get(0).getNextExecutorUserIds());
dto.setInstanceStatus(workflowResultList.get(0).getNextExecutorRoleIds() + "," + workflowResultList.get(0).getExecutorRoleIds());
dto.setPromoter(reginParams.getUserModel().getUserId());
dto.setNextTaskId(workflowResultList.get(i).getNextTaskId());
dto.setNextTaskId(workflowResultList.get(0).getNextTaskId());
} else {
dto.setNextExecuteUserIds(reginParams.getUserModel().getUserId());
}
dto.setInstallUnitName(reginParams.getCompany().getCompanyName());
dto.setInstallUnitCreditCode(reginParams.getCompany().getCompanyCode());
dto.setEquList((String.valueOf(obj.get("EQU_LIST"))));
// dto.setEquList((String.valueOf(obj.get("EQU_LIST"))));
dto.setEntrustingUnitName(dto.getUseUnitName());
dto.setCreateUserCompanyName(reginParams.getCompany().getCompanyName());
dto.setEquRegisterCode(String.valueOf(obj.get("EQU_CODE")));
dto.setFactoryNum(String.valueOf(obj.get("FACTORY_NUM")));
jgRelationEquip.setEquId(String.valueOf(obj.get("SEQUENCE_NBR")));
jgRelationEquip.setEquipTransferId(applyNo);
// dto.setEquRegisterCode(String.valueOf(obj.get("EQU_CODE")));
// dto.setFactoryNum(String.valueOf(obj.get("FACTORY_NUM")));
if (!CollectionUtils.isEmpty(workflowResultList)) {
dto.setInstanceId(workflowResultList.get(i).getInstanceId());
dto.setInstanceId(workflowResultList.get(0).getInstanceId());
dto.setNoticeStatus(String.valueOf(FlowStatusEnum.TO_BE_PROCESSED.getCode()));
} else {
dto.setNoticeStatus(String.valueOf(FlowStatusEnum.TO_BE_SUBMITTED.getCode()));
}
dto.setCreateUserName(reginParams.getUserModel().getRealName());
dto.setCreateUserId(reginParams.getUserModel().getUserId());
dto.setEquAddress(obj.getOrDefault("ADDRESS", "").toString());
// dto.setEquAddress(obj.getOrDefault("ADDRESS", "").toString());
list.add(dto);
deviceList.forEach(obj -> {
JgInstallationNoticeEq jgRelationEquip = new JgInstallationNoticeEq();
jgRelationEquip.setEquId(String.valueOf(obj.get("SEQUENCE_NBR")));
jgRelationEquip.setEquCategoryCode(String.valueOf(obj.get("EQU_CATEGORY_CODE")));
jgRelationEquip.setEquListCode(String.valueOf(obj.get("EQU_LIST_CODE")));
jgRelationEquip.setEquipTransferId(applyNo);
equipList.add(jgRelationEquip);
});
}
/**
......@@ -779,14 +873,14 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN
if (SUBMIT_TYPE_FLOW.equals(submitType)) {
ActWorkflowBatchDTO actWorkflowBatchDTO = new ActWorkflowBatchDTO();
List<ActWorkflowStartDTO> list = new ArrayList<>();
deviceList.forEach(item -> {
// deviceList.forEach(item -> {
ActWorkflowStartDTO dto = new ActWorkflowStartDTO();
dto.setProcessDefinitionKey(PROCESS_DEFINITION_KEY);
dto.setBusinessKey(item.get("SEQUENCE_NBR").toString());
// dto.setBusinessKey(item.get("SEQUENCE_NBR").toString());
dto.setCompleteFirstTask(Boolean.TRUE);
dto.setNextExecuteUserCompanyCode(receiveOrgCreditCode);
list.add(dto);
});
// });
actWorkflowBatchDTO.setProcess(list);
List<ProcessTaskDTO> processTaskDTOS = iCmWorkflowService.startBatch(actWorkflowBatchDTO);
// 组装工作流返回的数据
......@@ -956,8 +1050,9 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN
private void delRepeatUseEquipData(JgInstallationNotice jgInstallationNotice) {
LambdaQueryWrapper<JgInstallationNoticeEq> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(JgInstallationNoticeEq::getEquipTransferId, jgInstallationNotice.getSequenceNbr());
JgInstallationNoticeEq jgRelationEquip = jgInstallationNoticeEqMapper.selectOne(queryWrapper);
EquipUsedCheckStrategyContext.getUsedStrategy(PROCESS_INSTALL_NOTICE_KEY).delDataForCheckEquipRepeatUsed(Collections.singletonList(jgRelationEquip.getEquId()), jgInstallationNotice.getInstallUnitCreditCode());
List<JgInstallationNoticeEq> jgInstallationNoticeEqs = jgInstallationNoticeEqMapper.selectList(queryWrapper);
List<String> ids = jgInstallationNoticeEqs.stream().map(item -> item.getEquId()).collect(Collectors.toList());
EquipUsedCheckStrategyContext.getUsedStrategy(PROCESS_INSTALL_NOTICE_KEY).delDataForCheckEquipRepeatUsed(ids, jgInstallationNotice.getInstallUnitCreditCode());
}
@GlobalTransactional(rollbackFor = Exception.class)
......@@ -997,8 +1092,23 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN
if (StringUtils.isEmpty(workflowResultDto.getNextExecutorRoleIds())) {
LambdaQueryWrapper<JgInstallationNoticeEq> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(JgInstallationNoticeEq::getEquipTransferId, dto.getSequenceNbr());
JgInstallationNoticeEq jgRelationEquip = jgInstallationNoticeEqMapper.selectOne(queryWrapper);
this.saveHisDataBeforeUpdate(jgInstallationNotice, jgRelationEquip.getEquId());
List<JgInstallationNoticeEq> jgRelationEquips = jgInstallationNoticeEqMapper.selectList(queryWrapper);
this.saveHisDataBeforeUpdate(jgInstallationNotice);
jgInstallationNotice.setNoticeStatus(String.valueOf(FlowStatusEnum.TO_BE_FINISHED.getCode()));
// 上个代办改为已办
HashMap<String, Object> taskMap = new HashMap<>();
taskMap.put("taskStatus", FlowStatusEnum.TO_BE_FINISHED.getCode());
taskMap.put("taskStatusLabel", FlowStatusEnum.TO_BE_FINISHED.getName());
taskMap.put("relationId", jgInstallationNotice.getInstanceId());
taskMap.put("flowStatus", FlowStatusEnum.TO_BE_FINISHED.getCode());
taskMap.put("flowStatusLabel", FlowStatusEnum.TO_BE_FINISHED.getName());
TaskMessageDto taskMessageDto = new TaskMessageDto();
BeanUtils.copyProperties(jgInstallationNotice, taskMessageDto);
taskMap.put("model", taskMessageDto);
TaskV2Model taskV2Model1 = commonService.updateTaskModel(taskMap);
String finalYm = ym;
jgRelationEquips.forEach(jgRelationEquip ->{
LambdaQueryWrapper<OtherInfo> queryWrapper1 = new LambdaQueryWrapper<>();
queryWrapper1.eq(OtherInfo::getRecord, jgRelationEquip.getEquId());
OtherInfo tzsJgOtherInfo = tzsJgOtherInfoMapper.selectOne(queryWrapper1);
......@@ -1007,7 +1117,7 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN
IdxBizJgRegisterInfo idxBizJgRegisterInfo = tzsJgRegistrationInfoMapper.selectOne(queryWrapper2);
String equCode = Optional.ofNullable(idxBizJgRegisterInfo.getEquDefine())
.orElse(idxBizJgRegisterInfo.getEquCategory());
String registrationCode = equCode + jgInstallationNotice.getReceiveOrgCreditCode() + ym;
String registrationCode = equCode + jgInstallationNotice.getReceiveOrgCreditCode() + finalYm;
ResponseModel<String> responseModel = tzsServiceFeignClient.deviceRegistrationCode(registrationCode);
String deviceRegistrationCode = responseModel.getResult();
Map<String, Object> map = new HashMap<>();
......@@ -1021,9 +1131,9 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN
ResponseModel<Map<String, Object>> code = tzsServiceFeignClient.createCode(map);
mapCode = code.getResult();
supervisoryCodeInfoMapper.updateStatusBySuperviseCode(mapCode.get("superviseCode").toString());
jgInstallationNotice.setNoticeStatus(String.valueOf(FlowStatusEnum.TO_BE_FINISHED.getCode()));
jgInstallationNotice.setHandleDate(new Date());
jgInstallationNotice.setInformNumber(deviceRegistrationCode);
// jgInstallationNotice.setInformNumber(deviceRegistrationCode);
jgRelationEquip.setInformNumber(deviceRegistrationCode);
jgInstallationNotice.setSupervisoryCode(mapCode.get("superviseCode").toString());
jgInstallationNotice.setPromoter("");
......@@ -1060,19 +1170,6 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN
// 更新使用信息
updateJgUseInfo(jgInstallationNotice, jgRelationEquip);
// 上个代办改为已办
HashMap<String, Object> taskMap = new HashMap<>();
taskMap.put("taskStatus", FlowStatusEnum.TO_BE_FINISHED.getCode());
taskMap.put("taskStatusLabel", FlowStatusEnum.TO_BE_FINISHED.getName());
taskMap.put("relationId", jgInstallationNotice.getInstanceId());
taskMap.put("flowStatus", FlowStatusEnum.TO_BE_FINISHED.getCode());
taskMap.put("flowStatusLabel", FlowStatusEnum.TO_BE_FINISHED.getName());
TaskMessageDto taskMessageDto = new TaskMessageDto();
BeanUtils.copyProperties(jgInstallationNotice, taskMessageDto);
taskMap.put("model", taskMessageDto);
TaskV2Model taskV2Model1 = commonService.updateTaskModel(taskMap);
// 生成证记录表主键
long certChangeSeq = sequence.nextId();
// 生成jg证书变更记录
......@@ -1099,7 +1196,9 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN
.status("正常")
.routePath(taskV2Model1.getRoutePath())
.build());
});
// 更新关联设备表
jgInstallationNoticeEqService.updateBatchById(jgRelationEquips);
} else {
jgInstallationNotice.setNextExecuteIds(workflowResultDto.getNextExecutorRoleIds());
jgInstallationNotice.setNextExecuteUserIds(workflowResultDto.getNextExecutorUserIds());
......@@ -1298,9 +1397,14 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN
private void saveHisDataBeforeUpdate(JgInstallationNotice jgInstallationNotice) {
LambdaQueryWrapper<JgInstallationNoticeEq> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(JgInstallationNoticeEq::getEquipTransferId, jgInstallationNotice.getSequenceNbr());
JgInstallationNoticeEq jgRelationEquip = jgInstallationNoticeEqMapper.selectOne(queryWrapper);
Map<String, Object> map = idxBizJgRegisterInfoService.getDetailFieldCamelCaseByRecord(jgRelationEquip.getEquId());
commonService.saveOrUpdateHistory(BusinessTypeEnum.JG_INSTALLATION_NOTIFICATION.getName(), new JSONObject(map), jgRelationEquip.getEquId(), jgInstallationNotice.getSequenceNbr().toString());
List<JgInstallationNoticeEq> jgInstallationNoticeEqs = jgInstallationNoticeEqMapper.selectList(queryWrapper);
List<String> ids = jgInstallationNoticeEqs.stream().map(item -> item.getEquId()).collect(Collectors.toList());
// Map<String, Object> map = idxBizJgRegisterInfoService.getDetailFieldCamelCaseByRecord(jgRelationEquip.getEquId());
Iterable<ESEquipmentCategoryDto> equips = esEquipmentCategory.findAllById(ids);
List<Map<String, Object>> equipListMaps = getEquipListMaps(equips);
Map<String, Object> installationInfo = BeanUtil.beanToMap(jgInstallationNotice, false, true);
installationInfo.put("deviceList", equipListMaps);
commonService.saveOrUpdateHistory(BusinessTypeEnum.JG_INSTALLATION_NOTIFICATION.getName(), new JSONObject(installationInfo), null, jgInstallationNotice.getSequenceNbr().toString());
}
private void saveHisDataBeforeUpdate(JgInstallationNotice jgInstallationNotice, String equId) {
......@@ -1475,7 +1579,8 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN
// 2.1 数据库的的USE_UNIT_CREDIT_CODE赋空
LambdaQueryWrapper<JgInstallationNoticeEq> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(JgInstallationNoticeEq::getEquipTransferId, installationNotice.getSequenceNbr());
JgInstallationNoticeEq jgRelationEquip = jgInstallationNoticeEqMapper.selectOne(queryWrapper);
List<JgInstallationNoticeEq> jgInstallationNoticeEqs = jgInstallationNoticeEqMapper.selectList(queryWrapper);
jgInstallationNoticeEqs.forEach(jgRelationEquip ->{
// 强制更新字段为 NULL
LambdaUpdateWrapper<IdxBizJgUseInfo> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.eq(IdxBizJgUseInfo::getRecord, jgRelationEquip.getEquId()); // 设置更新条件
......@@ -1490,5 +1595,57 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN
esEquipmentCategoryDto.setUSE_UNIT_NAME(null);
esEquipmentCategory.save(esEquipmentCategoryDto);
}
});
}
@Transactional
@Override
public Boolean historyDataRepair() {
List<JgInstallationNotice> list = this.lambdaQuery().list();
ArrayList<JgInstallationNoticeEq> jgInstallationNoticeEqs = new ArrayList<>();
ArrayList<JgRegistrationHistory> jgRegistrationHistories = new ArrayList<>();
list.forEach(item ->{
// 设备信息
List<JgInstallationNoticeEq> equList = jgInstallationNoticeEqService.lambdaQuery().eq(JgInstallationNoticeEq::getEquipTransferId, item.getSequenceNbr()).list();
JgRegistrationHistory jgRegistrationHistory = jgRegistrationHistoryService.lambdaQuery().eq(JgRegistrationHistory::getCurrentDocumentId, item.getSequenceNbr()).one();
if (!ObjectUtils.isEmpty(jgRegistrationHistory) && !ObjectUtils.isEmpty(jgRegistrationHistory.getChangeData())){
List<String> ids = equList.stream().map(a -> a.getEquId()).collect(Collectors.toList());
Iterable<ESEquipmentCategoryDto> equips = esEquipmentCategory.findAllById(ids);
List<Map<String, Object>> equipListMaps = getEquipListMaps(equips);
JSONObject object = JSONObject.parseObject(jgRegistrationHistory.getChangeData());
object.put("deviceList", equipListMaps);
jgRegistrationHistory.setChangeData(JSONObject.toJSONString(object));
jgRegistrationHistories.add(jgRegistrationHistory);
}
equList.forEach(equ->{
if (!ObjectUtils.isEmpty(item.getInformNumber())){
equ.setInformNumber(item.getInformNumber());
}
IdxBizJgRegisterInfo registerInfo = idxBizJgRegisterInfoService.lambdaQuery().eq(IdxBizJgRegisterInfo::getRecord, equ.getEquId()).one();
if (!ObjectUtils.isEmpty(registerInfo) && !ObjectUtils.isEmpty(registerInfo.getEquList()) && !ObjectUtils.isEmpty(registerInfo.getEquCategory())){
equ.setEquListCode(registerInfo.getEquList());
equ.setEquCategoryCode(registerInfo.getEquCategory());
if (ObjectUtils.isEmpty(item.getEquList()) || ObjectUtils.isEmpty(item.getEquCategoryCode())){
item.setEquListCode(registerInfo.getEquList());
item.setEquCategoryCode(registerInfo.getEquCategory());
if ("8300".equals(item.getEquCategoryCode())){
LambdaQueryWrapper<EquipTechParamPipeline> lambda = new QueryWrapper<EquipTechParamPipeline>().lambda();
lambda.eq(EquipTechParamPipeline::getRecord, equ.getEquId());
EquipTechParamPipeline equipTechParamPipeline = equipTechParamPipelineMapper.selectOne(lambda);
if (!ObjectUtils.isEmpty(equipTechParamPipeline) && !ObjectUtils.isEmpty(equipTechParamPipeline.getDeviceName())){
item.setProjectContraption(equipTechParamPipeline.getDeviceName());
}
}
}
}
jgInstallationNoticeEqs.add(equ);
});
});
// 修改历史表数据
jgRegistrationHistoryService.updateBatchById(jgRegistrationHistories);
this.updateBatchById(list);
jgInstallationNoticeEqService.updateBatchById(jgInstallationNoticeEqs);
return Boolean.TRUE;
}
}
\ No newline at end of file
......@@ -1886,7 +1886,7 @@
</w:r>
</w:p>
</w:tc>
<#if installLicenseNoList?size == 0>
<#if equipList.installLicenseNoList?size == 0>
<w:tc>
<w:tcPr>
<w:tcW w:w="809" w:type="pct"/>
......@@ -1931,7 +1931,7 @@
</w:p>
</w:tc>
</#if>
<#if installLicenseNoList?size == 1>
<#if equipList.installLicenseNoList?size == 1>
<w:tc>
<w:tcPr>
<w:tcW w:w="809" w:type="pct"/>
......@@ -1978,7 +1978,7 @@
</w:p>
</w:tc>
</#if>
<#if installLicenseNoList?size == 2>
<#if equipList.installLicenseNoList?size == 2>
<w:tc>
<w:tcPr>
<w:tcW w:w="809" w:type="pct"/>
......@@ -2095,7 +2095,7 @@
</w:tc>
</#if>
<#if installLicenseNoList?size == 3>
<#if equipList.installLicenseNoList?size == 3>
<w:tc>
<w:tcPr>
<w:tcW w:w="809" w:type="pct"/>
......@@ -2128,7 +2128,7 @@
<w:gridCol w:w="1645"/>
</w:tblGrid>
<#list installLicenseNoList as item>
<#list equipList.installLicenseNoList as item>
<w:tr>
<w:tblPrEx>
<w:tblBorders>
......@@ -2257,7 +2257,7 @@
</w:r>
</w:p>
</w:tc>
<#if installLicenseExpirationDateList?size == 0>
<#if equipList.installLicenseExpirationDateList?size == 0>
<w:tc>
<w:tcPr>
<w:tcW w:w="1119" w:type="pct"/>
......@@ -2305,7 +2305,7 @@
</#if>
<#if installLicenseExpirationDateList?size == 1>
<#if equipList.installLicenseExpirationDateList?size == 1>
<w:tc>
<w:tcPr>
<w:tcW w:w="1119" w:type="pct"/>
......@@ -2355,7 +2355,7 @@
</#if>
<#if installLicenseExpirationDateList?size == 2>
<#if equipList.installLicenseExpirationDateList?size == 2>
<w:tc>
<w:tcPr>
<w:tcW w:w="1119" w:type="pct"/>
......@@ -2388,7 +2388,7 @@
<w:gridCol w:w="1340"/>
</w:tblGrid>
<#list installLicenseExpirationDateList as item1>
<#list equipList.installLicenseExpirationDateList as item1>
<w:tr>
<w:tblPrEx>
<w:tblBorders>
......@@ -2478,7 +2478,7 @@
</#if>
<#if installLicenseExpirationDateList?size == 3>
<#if equipList.installLicenseExpirationDateList?size == 3>
<w:tc>
<w:tcPr>
<w:tcW w:w="1119" w:type="pct"/>
......@@ -2510,7 +2510,7 @@
<w:tblGrid>
<w:gridCol w:w="1349"/>
</w:tblGrid>
<#list installLicenseExpirationDateList as item1>
<#list equipList.installLicenseExpirationDateList as item1>
<w:tr>
<w:tblPrEx>
<w:tblBorders>
......
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