Commit 428b2733 authored by hezhuozhi's avatar hezhuozhi

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

parents 03a467be 49b2bd99
......@@ -181,6 +181,9 @@ public class JgReformNoticeDto extends BaseDto {
@ApiModelProperty (value = "告知设备列表")
private List<Map<String, Object>> deviceList;
@ApiModelProperty(value = "管道列表")
private List<Map<String, Object>> pipelineList;
@ApiModelProperty (value = "区名字")
private String countyName;
......
......@@ -33,7 +33,7 @@ public interface IJgReformNoticeService extends IService<JgReformNotice> {
* @param noticeDto 改造告知
* @param op 操作类型
*/
JgReformNoticeDto updateInstallationNotice(String submitType, JgReformNoticeDto noticeDto, String op);
JgReformNoticeDto updateNotice(String submitType, Map<String, Object> noticeMap, String op);
/**
* 分页查询
......
......@@ -65,13 +65,9 @@ public class JgReformNoticeController extends BaseController {
@PutMapping(value = "/update")
@ApiOperation(httpMethod = "PUT", value = "根据sequenceNbr更新改造告知", notes = "根据sequenceNbr更新改造告知")
public ResponseModel<JgReformNoticeDto> updateBySequenceNbrJgReformNotice(@RequestParam String submitType,
@RequestBody JgReformNoticeDto installationInfo,
@RequestBody Map<String, Object> noticeMap,
@RequestParam(value = "op", required = false) String op) {
if (Objects.isNull(installationInfo)) {
throw new IllegalArgumentException("参数installationInfo不能为空");
}
return ResponseHelper.buildResponse(jgReformNoticeService.updateInstallationNotice(submitType, installationInfo, op));
return ResponseHelper.buildResponse(jgReformNoticeService.updateNotice(submitType, noticeMap, op));
}
/**
......
......@@ -3,6 +3,7 @@ package com.yeejoin.amos.boot.module.jg.biz.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.map.MapBuilder;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
......@@ -40,11 +41,9 @@ import com.yeejoin.amos.boot.module.jg.biz.utils.WordTemplateUtils;
import com.yeejoin.amos.boot.module.ymt.api.entity.EquipmentCategory;
import com.yeejoin.amos.boot.module.ymt.api.entity.RegistrationInfo;
import com.yeejoin.amos.boot.module.ymt.api.enums.ApplicationFormTypeEnum;
import com.yeejoin.amos.boot.module.ymt.api.enums.EquipmentClassifityEnum;
import com.yeejoin.amos.boot.module.ymt.api.enums.FlowStatusEnum;
import com.yeejoin.amos.boot.module.ymt.api.mapper.EquipmentCategoryMapper;
import com.yeejoin.amos.boot.module.ymt.api.mapper.OtherInfoMapper;
import com.yeejoin.amos.boot.module.ymt.api.mapper.RegistrationInfoMapper;
import com.yeejoin.amos.boot.module.ymt.api.mapper.SupervisoryCodeInfoMapper;
import com.yeejoin.amos.boot.module.ymt.api.mapper.*;
import com.yeejoin.amos.feign.systemctl.model.TaskV2Model;
import com.yeejoin.amos.feign.workflow.model.ActWorkflowBatchDTO;
import com.yeejoin.amos.feign.workflow.model.ActWorkflowStartDTO;
......@@ -88,6 +87,15 @@ public class JgReformNoticeServiceImpl extends BaseService<JgReformNoticeDto, Jg
private static final String SUBMIT_TYPE_FLOW = "1";
private static final String PROCESS_DEFINITION_KEY = "renovationNoticeNew";
private static final String TABLE_PAGE_ID = "reformNoticeAdd";
public static final String PIPELINE_LIST = "pipelineList";
public static final String PIPE_LENGTH = "pipeLength";
public static final String RECORD = "record";
public static final String SEQUENCE_NBR = "SEQUENCE_NBR";
public static final String PROJECT_CONTRAPTION = "projectContraption";
public static final String EQU_LIST_CODE = "EQU_LIST_CODE";
public static final String EQU_CATEGORY_CODE = "EQU_CATEGORY_CODE";
public static final String EQUIP_INFO = "equipInfo";
public static final String PROJECT_CONTRAPTION_ID = "projectContraptionId";
private final List<String> NOT_FLOWING_STATE = Arrays.asList("6610", "6614", "6615", "6617", "6616");
// 西安行政区划code
......@@ -108,13 +116,13 @@ public class JgReformNoticeServiceImpl extends BaseService<JgReformNoticeDto, Jg
@Autowired
TzsServiceFeignClient tzsServiceFeignClient;
@Autowired
SupervisoryCodeInfoMapper supervisoryCodeInfoMapper;
IdxBizJgProjectContraptionMapper idxBizJgProjectContraptionMapper;
@Autowired
RedisUtils redisUtils;
@Autowired
private SnowflakeIdUtil sequence;
@Autowired
IIdxBizJgRegisterInfoService idxBizJgRegisterInfoService;
JgRegistrationHistoryServiceImpl jgRegistrationHistoryService;
@Autowired
JgInstallationNoticeServiceImpl jgInstallationNoticeService;
@Autowired
......@@ -156,8 +164,10 @@ public class JgReformNoticeServiceImpl extends BaseService<JgReformNoticeDto, Jg
reformNoticeMap.put("street", notice.getStreet() + "_" + notice.getStreetName());
}
reformNoticeMap.put("constructionManagerId", notice.getConstructionManagerId() + "_" + notice.getConstructionManager());
if ((Integer.parseInt(notice.getNoticeStatus()) == FlowStatusEnum.TO_BE_FINISHED.getCode()) || (Integer.parseInt(notice.getNoticeStatus()) == FlowStatusEnum.TO_BE_DISCARD.getCode())) {
// 完成 或 作废时显示历史数据
if ((Integer.parseInt(notice.getNoticeStatus()) == FlowStatusEnum.TO_BE_FINISHED.getCode())
|| (Integer.parseInt(notice.getNoticeStatus()) == FlowStatusEnum.TO_BE_DISCARD.getCode())
|| EquipmentClassifityEnum.YLGD.getCode().equals(notice.getEquListCode())) {
// 完成 或 作废时显示历史数据(压力管道也显示历史数据)
JSONObject hisData = commonService.queryHistoryData(notice.getSequenceNbr());
if (!ValidationUtil.isEmpty(hisData)) {
// 格式化基本通用信息的时间类型字段
......@@ -204,19 +214,22 @@ public class JgReformNoticeServiceImpl extends BaseService<JgReformNoticeDto, Jg
/**
* 更新改造告知
*
* @param noticeDto 改造告知
*/
@SuppressWarnings({"rawtypes", "Duplicates"})
public JgReformNoticeDto updateInstallationNotice(String submitType, JgReformNoticeDto noticeDto, String op) {
public JgReformNoticeDto updateNotice(String submitType, Map<String, Object> noticeMap, String op) {
try {
String noticeJsonStr = JSON.toJSONString(noticeMap);
JgReformNoticeDto noticeDto = JSON.parseObject(noticeJsonStr, JgReformNoticeDto.class);
if (Objects.isNull(noticeDto) || StringUtils.isEmpty(submitType)) {
throw new IllegalArgumentException("参数不能为空");
}
// 压力管道使用
JSONObject oldPipJsonData = new JSONObject();
// 字段转换
this.convertField(noticeDto);
JgReformNotice notice = this.getById(noticeDto.getSequenceNbr());
List<Map<String, Object>> deviceList = noticeDto.getDeviceList();
List<String> records = deviceList.stream().map(equ -> String.valueOf(equ.get("SEQUENCE_NBR"))).collect(Collectors.toList());
List<Map<String, Object>> deviceList = EquipmentClassifityEnum.YLGD.getCode().equals(notice.getEquListCode()) ? noticeDto.getDeviceList() : noticeDto.getPipelineList();
List<String> records = deviceList.stream().map(equ -> String.valueOf(equ.get(RECORD))).collect(Collectors.toList());
this.checkRepeatUsed(submitType, records, notice);
if (SUBMIT_TYPE_FLOW.equals(submitType)) {
// 发起流程
......@@ -245,7 +258,12 @@ public class JgReformNoticeServiceImpl extends BaseService<JgReformNoticeDto, Jg
notice.setInstanceId(workflowResultDto.getInstanceId());
notice.setNextTaskId(workflowResultDto.getNextTaskId());
notice.setNextExecuteUserIds(workflowResultDto.getNextExecutorUserIds());
// 压力管道情况处理
if (EquipmentClassifityEnum.YLGD.getCode().equals(notice.getEquListCode())) {
oldPipJsonData = this.getNowPipJsonData(noticeDto.getProjectContraptionId());
notice.setPipeLengthChanged(this.calculatePipeLengthChange(JSONArray.parseArray(JSON.toJSONString(oldPipJsonData.get(PIPELINE_LIST))),
JSONArray.parseArray(JSON.toJSONString(noticeDto.getPipelineList()))));
}
jgReformNoticeMapper.updateById(notice);
// 删除暂存
commonService.deleteTasksByRelationId(notice.getSequenceNbr() + "");
......@@ -291,7 +309,7 @@ public class JgReformNoticeServiceImpl extends BaseService<JgReformNoticeDto, Jg
BeanUtils.copyProperties(noticeDto, bean);
jgReformNoticeMapper.updateById(bean);
}
this.saveOrUpdateHisData(String.valueOf(noticeDto.getSequenceNbr()), JSONObject.parseObject(noticeJsonStr), oldPipJsonData);
jgReformNoticeEqMapper.delete(new LambdaQueryWrapper<JgReformNoticeEq>()
.eq(JgReformNoticeEq::getEquipTransferId, notice.getSequenceNbr()));
// eq关系表
......@@ -299,7 +317,7 @@ public class JgReformNoticeServiceImpl extends BaseService<JgReformNoticeDto, Jg
// 更新设备关系表
deviceList.forEach(obj -> {
JgReformNoticeEq jgRelationEquip = new JgReformNoticeEq();
jgRelationEquip.setEquId(String.valueOf(obj.get("SEQUENCE_NBR")));
jgRelationEquip.setEquId(String.valueOf(obj.get(SEQUENCE_NBR)));
jgRelationEquip.setEquipTransferId(String.valueOf(notice.getSequenceNbr()));
noticeEqs.add(jgRelationEquip);
});
......@@ -425,8 +443,13 @@ public class JgReformNoticeServiceImpl extends BaseService<JgReformNoticeDto, Jg
JSONObject jsonObject = JSONObject.parseObject(jsonString);
JgReformNoticeDto model = JSON.parseObject(jsonString, JgReformNoticeDto.class);
convertField(model);
String equListCode = String.valueOf(jsonObject.get(EQU_LIST_CODE));
String equCategoryCode = String.valueOf(jsonObject.get(EQU_CATEGORY_CODE));
// 压力管道使用
JSONObject oldPipJsonData = new JSONObject();
List<JgReformNoticeEq> noticeEqs = new ArrayList<>();
// 获取告知设备列表
List<Map<String, Object>> deviceList = model.getDeviceList();
List<Map<String, Object>> deviceList = EquipmentClassifityEnum.YLGD.getCode().equals(equListCode) ? model.getDeviceList() : model.getPipelineList();
if (CollectionUtils.isEmpty(deviceList)) {
throw new BadRequest("请选择设备!");
}
......@@ -458,9 +481,7 @@ public class JgReformNoticeServiceImpl extends BaseService<JgReformNoticeDto, Jg
notice.setCreateUserName(reginParams.getUserModel().getRealName());
notice.setCreateUserId(reginParams.getUserModel().getUserId());
notice.setCreateUserCompanyName(reginParams.getCompany().getCompanyName());
notice.setProjectContraption(ValidationUtil.isEmpty(jsonObject.get("projectContraption")) ? "" : String.valueOf(jsonObject.get("projectContraption")));
String equListCode = String.valueOf(jsonObject.get("EQU_LIST_CODE"));
String equCategoryCode = String.valueOf(jsonObject.get("EQU_CATEGORY_CODE"));
notice.setProjectContraption(ValidationUtil.isEmpty(jsonObject.get(PROJECT_CONTRAPTION)) ? "" : String.valueOf(jsonObject.get(PROJECT_CONTRAPTION)));
notice.setEquListCode(equListCode);
EquipmentCategory equipmentCategory1 = equipmentCategoryMapper.selectOne(new LambdaQueryWrapper<EquipmentCategory>().eq(EquipmentCategory::getCode, equListCode));
notice.setEquListName(ValidationUtil.isEmpty(equipmentCategory1) ? null : equipmentCategory1.getName());
......@@ -491,27 +512,26 @@ public class JgReformNoticeServiceImpl extends BaseService<JgReformNoticeDto, Jg
} else {
notice.setNoticeStatus(String.valueOf(FlowStatusEnum.TO_BE_SUBMITTED.getCode()));
}
// notice.setCreateUserId(reginParams.getUserModel().getUserId());
// 插入业务单
jgReformNoticeMapper.insert(notice);
List<JgReformNoticeEq> noticeEqs = new ArrayList<>();
// 更新设备关系表
deviceList.forEach(obj -> {
JgReformNoticeEq jgRelationEquip = new JgReformNoticeEq();
jgRelationEquip.setEquId(String.valueOf(obj.get("SEQUENCE_NBR")));
jgRelationEquip.setEquipTransferId(String.valueOf(sequenceNbr));
noticeEqs.add(jgRelationEquip);
});
jgReformNoticeEqMapper.insertBatchSomeColumn(noticeEqs);
// 压力管道情况处理
if (EquipmentClassifityEnum.YLGD.getCode().equals(equListCode)) {
oldPipJsonData = this.getNowPipJsonData(String.valueOf(jsonObject.get(PROJECT_CONTRAPTION_ID)));
notice.setPipeLengthChanged(this.calculatePipeLengthChange(JSONArray.parseArray(JSON.toJSONString(oldPipJsonData.get(PIPELINE_LIST))), JSONArray.parseArray(JSON.toJSONString(jsonObject.get(PIPELINE_LIST)))));
}
this.saveOrUpdateHisData(String.valueOf(sequenceNbr), jsonObject, oldPipJsonData);
if (SUBMIT_TYPE_FLOW.equals(submitType)) {
this.buildTask(notice, workflowResultList);
} else {
this.saveTempReformNotice(notice);
}
// 插入业务单
jgReformNoticeMapper.insert(notice);
// 更新设备关系表
deviceList.stream().filter(obj -> Objects.isNull(obj.get(RECORD)))
.map(obj -> new JgReformNoticeEq()
.setEquId(obj.get(RECORD).toString())
.setEquipTransferId(String.valueOf(sequenceNbr)))
.forEach(noticeEqs::add);
jgReformNoticeEqMapper.insertBatchSomeColumn(noticeEqs);
this.updateRedisBatch(Collections.singletonList(notice));
return Collections.singletonList(notice);
} catch (BadRequest | LocalBadRequest e) {
......@@ -527,8 +547,34 @@ public class JgReformNoticeServiceImpl extends BaseService<JgReformNoticeDto, Jg
}
}
/**
* 计算管道长度变化 正值为增长,负值为减少
*
* @param oldPipData 旧管道数据
* @param newPipData 新管道数据
* @return 管道长度变化,正值为增长,负值为减少
*/
private String calculatePipeLengthChange(JSONArray oldPipData, JSONArray newPipData) {
double oldPipLen = oldPipData.stream().mapToDouble(item -> JSONObject.parseObject(item.toString()).getDoubleValue(PIPE_LENGTH)).sum();
double newPipLen = newPipData.stream().mapToDouble(item -> JSONObject.parseObject(item.toString()).getDoubleValue(PIPE_LENGTH)).sum();
double change = newPipLen - oldPipLen;
return change == 0 ? "0" : String.format("%+.2f", change);
}
private JSONObject getNowPipJsonData(String projectContraptionId) {
return new JSONObject(Optional.ofNullable(idxBizJgProjectContraptionMapper.getDetail(projectContraptionId))
.map(map -> {
commonService.convertStringToJsonobject(map, IdxBizJgProjectContraptionServiceImpl.jsonFields);
map.put(PIPELINE_LIST, idxBizJgProjectContraptionMapper.selectEquipList((String) map.get(SEQUENCE_NBR)));
return map;
})
.orElse(Collections.emptyMap()));
}
private void repeatUsedEquipCheck(List<Map<String, Object>> equipList, String companyCode) {
equipList.forEach(equipMap -> EquipUsedCheckStrategyContext.getUsedStrategy(PROCESS_DEFINITION_KEY).equipRepeatUsedCheck(String.valueOf(equipMap.get("SEQUENCE_NBR")), companyCode));
equipList.forEach(equipMap ->
EquipUsedCheckStrategyContext.getUsedStrategy(PROCESS_DEFINITION_KEY)
.equipRepeatUsedCheck(String.valueOf(equipMap.get(RECORD)), companyCode));
}
private void checkRepeatUsed(String submitType, List<String> records, JgReformNotice jgReformNotice) {
......@@ -850,8 +896,8 @@ public class JgReformNoticeServiceImpl extends BaseService<JgReformNoticeDto, Jg
noticeEq.setInformNumber(deviceRegistrationCode);
jgReformNoticeEqMapper.updateById(noticeEq);
});
// 通过时记录历史数据
this.saveHisDataBeforeUpdate(String.valueOf(jgReformNotice.getSequenceNbr()), jsonObject);
// 通过时记录或更新历史数据
this.saveOrUpdateHisData(String.valueOf(jgReformNotice.getSequenceNbr()), jsonObject, null);
jgReformNotice.setAcceptDate(new Date());
jgReformNotice.setNoticeStatus(String.valueOf(FlowStatusEnum.TO_BE_FINISHED.getCode()));
jgReformNotice.setPromoter("");
......@@ -896,8 +942,29 @@ public class JgReformNoticeServiceImpl extends BaseService<JgReformNoticeDto, Jg
}
private void saveHisDataBeforeUpdate(String sequenceNbr, JSONObject jsonObject) {
commonService.saveOrUpdateHistory(BusinessTypeEnum.JG_MODIFICATION_NOTIFICATION.getName(), new JSONObject(jsonObject), null, sequenceNbr);
private void saveOrUpdateHisData(String sequenceNbr, JSONObject changeData, JSONObject oldData) {
this.saveOrUpdateHistory(BusinessTypeEnum.JG_MODIFICATION_NOTIFICATION.getName(), new JSONObject(changeData), new JSONObject(oldData), sequenceNbr);
}
public void saveOrUpdateHistory(String registrationClass, JSON changeData, JSON oldData, String currentDocumentId) {
JgRegistrationHistory jgRegistrationHistory = new JgRegistrationHistory();
LambdaQueryWrapper<JgRegistrationHistory> lambda = new QueryWrapper<JgRegistrationHistory>().lambda();
lambda.eq(JgRegistrationHistory::getCurrentDocumentId, currentDocumentId);
lambda.eq(JgRegistrationHistory::getIsDelete, false);
Integer integer = jgRegistrationHistoryService.getBaseMapper().selectCount(lambda);
if (integer > 0) {
jgRegistrationHistory.setChangeData(JSON.toJSONString(changeData));
jgRegistrationHistory.setOldData(JSON.toJSONString(oldData));
jgRegistrationHistoryService.update(jgRegistrationHistory, lambda);
} else {
jgRegistrationHistory.setChangeData(JSON.toJSONString(changeData));
jgRegistrationHistory.setOldData(JSON.toJSONString(oldData));
jgRegistrationHistory.setStatus("new");
jgRegistrationHistory.setRegistrationClass(registrationClass);
jgRegistrationHistory.setEquId(null);
jgRegistrationHistory.setCurrentDocumentId(currentDocumentId);
jgRegistrationHistoryService.save(jgRegistrationHistory);
}
}
public InstanceRuntimeData buildInstanceRuntimeData(JgReformNotice jgReformNotice) {
......@@ -1008,7 +1075,7 @@ public class JgReformNoticeServiceImpl extends BaseService<JgReformNoticeDto, Jg
Iterable<ESEquipmentCategoryDto> esEquipmentCategoryDtos = esEquipmentCategory.findAllById(equList);
List<Map<String, Object>> deviceList = getEquipListMaps(esEquipmentCategoryDtos);
jsonObject.put("deviceList", deviceList);
this.saveHisDataBeforeUpdate(String.valueOf(reformNotice.getSequenceNbr()), jsonObject);
this.saveOrUpdateHisData(String.valueOf(reformNotice.getSequenceNbr()), jsonObject, null);
}
@Override
......
......@@ -5,6 +5,7 @@
<select id="getDetail" resultType="java.util.Map">
SELECT
SEQUENCE_NBR,
SEQUENCE_NBR as projectContraptionId,
USE_UNIT_CREDIT_CODE,
EQU_LIST,
EQU_CATEGORY,
......
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