Commit 08f53a52 authored by suhuiguang's avatar suhuiguang

feat(jg): 压力管道后续业务

1.启用停用代码提交
parent 31c27ea7
......@@ -43,4 +43,8 @@ public interface JgEnableDisableMapper extends BaseMapper<JgEnableDisable> {
IPage<IdxBizJgProjectContraption> queryJgProjectContraptionPage(@Param("page") Page<IdxBizJgProjectContraption> page, @Param("useUnitCreditCode") String useUnitCreditCode, @Param("proIds") Set<String> proIds);
IPage<Map<String, Object>> selectPipeLinePage(@Param("page") Page<Map<String, Object>> page, @Param("projectContraptionId") String projectContraptionId, @Param("applyType") String applyType);
List<Map<String, Object>> selectPipeLineByRecords(@Param("records") List<String> records);
}
......@@ -252,4 +252,15 @@
)
ORDER BY REC_DATE DESC
</select>
<select id="selectPipeLineByRecords" resultType="java.util.Map">
select * from (
<include refid="page-list-pipeline"/>
WHERE
ui."RECORD" = ANY(ARRAY[
<foreach collection="records" item="record" separator=",">
#{record}
</foreach>
]) )
ORDER BY REC_DATE DESC
</select>
</mapper>
\ No newline at end of file
......@@ -2,6 +2,7 @@ package com.yeejoin.amos.boot.module.jg.biz.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
......@@ -15,6 +16,8 @@ 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.utils.RedisKey;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import com.yeejoin.amos.boot.module.common.api.dao.ESEquipmentCategory;
import com.yeejoin.amos.boot.module.common.api.dto.ESEquipmentCategoryDto;
import com.yeejoin.amos.boot.module.common.biz.refresh.DataRefreshEvent;
import com.yeejoin.amos.boot.module.jg.api.dto.*;
import com.yeejoin.amos.boot.module.jg.api.entity.*;
......@@ -28,6 +31,7 @@ import com.yeejoin.amos.boot.module.jg.biz.config.LocalBadRequest;
import com.yeejoin.amos.boot.module.jg.biz.context.EquipUsedCheckStrategyContext;
import com.yeejoin.amos.boot.module.jg.biz.context.FlowingEquipRedisContext;
import com.yeejoin.amos.boot.module.jg.biz.edit.permission.FillingEditPermForCurrentUser;
import com.yeejoin.amos.boot.module.jg.biz.edit.utils.JsonDiffUtil;
import com.yeejoin.amos.boot.module.jg.biz.event.publisher.EventPublisher;
import com.yeejoin.amos.boot.module.jg.biz.feign.TzsServiceFeignClient;
import com.yeejoin.amos.boot.module.jg.biz.service.ICmWorkflowService;
......@@ -56,6 +60,7 @@ import org.springframework.util.CollectionUtils;
import org.springframework.util.ObjectUtils;
import org.springframework.util.StringUtils;
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;
......@@ -125,6 +130,9 @@ public class JgEnableDisableServiceImpl extends BaseService<JgEnableDisableDto,
@Autowired
private IdxBizJgProjectContraptionMapper jgProjectContraptionMapper;
@Autowired
private ESEquipmentCategory esEquipmentCategory;
/**
* 设备状态:启用
*/
......@@ -251,11 +259,6 @@ public class JgEnableDisableServiceImpl extends BaseService<JgEnableDisableDto,
throw new BadRequest("启用的设备中存在超过定期检验有效期的设备");
}
});
} else {
// 管道校验检验有效期逻辑 nextInspectDate
equipments.forEach(equ ->{
});
}
}
......@@ -309,6 +312,8 @@ public class JgEnableDisableServiceImpl extends BaseService<JgEnableDisableDto,
}
// 保存历史表
commonService.saveOrUpdateHistory(this.getRegistrationClass(jgEnableDisable), map, null, jgEnableDisable.getSequenceNbr().toString());
// 前端显示需要将code转name
jgEnableDisable.setApplyType(getRegistrationClass(jgEnableDisable));
return Collections.singletonList(jgEnableDisable);
} catch (BadRequest | LocalBadRequest e) {
log.error(e.getMessage(), e);
......@@ -864,14 +869,55 @@ public class JgEnableDisableServiceImpl extends BaseService<JgEnableDisableDto,
JgRegistrationHistory jgRegistrationHistory = jgRegistrationHistoryMapper.selectOne(new LambdaQueryWrapper<JgRegistrationHistory>()
.eq(JgRegistrationHistory::getCurrentDocumentId, sequenceNbr)
.eq(JgRegistrationHistory::getIsDelete, false));
if (jgRegistrationHistory != null) {
JSONObject jsonObject = JSONObject.parseObject(jgRegistrationHistory.getChangeData());
resultMap.putAll(jsonObject);
// 已完成或者已作废查询json
if (enableDisable.getAuditStatus().equals(FlowStatusEnum.TO_BE_FINISHED.getName()) || enableDisable.getAuditStatus().equals(FlowStatusEnum.TO_BE_DISCARD.getName())) {
if (jgRegistrationHistory != null) {
JSONObject jsonObject = JSONObject.parseObject(jgRegistrationHistory.getChangeData());
resultMap.putAll(jsonObject);
}
} else {
// 基本信息使用json里面的,其他字段按照如下覆盖
if (jgRegistrationHistory != null) {
JSONObject jsonObject = JSONObject.parseObject(jgRegistrationHistory.getChangeData());
resultMap.putAll(jsonObject);
}
// 流程中实时显示设备信息
LambdaQueryWrapper<JgEnableDisableEq> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(JgEnableDisableEq::getEnableDisableApplyId, enableDisable.getSequenceNbr());
queryWrapper.select(BaseEntity::getSequenceNbr, JgEnableDisableEq::getEquId);
List<JgEnableDisableEq> enableDisableEqs = jgEnableDisableEqService.list(queryWrapper).stream().filter(e-> org.apache.commons.lang3.StringUtils.isNotEmpty(e.getEquId())).collect(Collectors.toList());
if(!enableDisableEqs.isEmpty()) {
List<Map<String,Object>> equipments;
if(!enableDisable.getEquListCode().equals(EquipmentClassifityEnum.YLGD.getCode())){
equipments = new ArrayList<>();
Iterable<ESEquipmentCategoryDto> equipmentCategoryDtos = esEquipmentCategory.findAllById(enableDisableEqs.stream().map(JgEnableDisableEq::getEquId).collect(Collectors.toList()));
equipmentCategoryDtos.forEach(dto->{
Map<String,Object> item = new HashMap<>();
BeanUtils.copyProperties(dto,item);
BeanUtil.beanToMap(dto,item, true, false);
item.replaceAll((k, v) -> v == null ? "" : v);
item.put("record", dto.getSEQUENCE_NBR());
item.put("equipAddress", concatWithSplit(trimNull2Empty(dto.getUSE_PLACE()), trimNull2Empty(dto.getADDRESS())));
item.put("EQU_STATE_NAME", !ValidationUtil.isEmpty(dto.getEQU_STATE()) ? EquimentEnum.getName.get(dto.getEQU_STATE()) : null);
item.put("NEXT_INSPECT_DATE", this.castDate2TimeStr(dto.getNEXT_INSPECT_DATE()));
equipments.add(item);
});
} else {
equipments = this.getBaseMapper().selectPipeLineByRecords(enableDisableEqs.stream().map(JgEnableDisableEq::getEquId).collect(Collectors.toList()));
// 检验报告数据格式化 转json
equipments.stream().filter(e-> e.get("inspectReport") != null).forEach(item->{
item.put("inspectReport", JSON.parse(item.get("inspectReport").toString()));
});
}
resultMap.put("equipments", equipments);
}
}
resultMap.put("receiveOrgCode", enableDisable.getReceiveCompanyCode() + '_' + enableDisable.getReceiveOrgName());
resultMap.put("receiveCompanyCode", enableDisable.getReceiveCompanyCode());
resultMap.put("sequenceNbr", enableDisable.getSequenceNbr());
resultMap.put("applyNo", enableDisable.getApplyNo());
resultMap.put("applyType", enableDisable.getApplyType());
resultMap.put("remark", enableDisable.getRemark());
resultMap.put("auditStatus", enableDisable.getAuditStatus());
resultMap.put("useUnitCreditCode", enableDisable.getUseUnitCreditCode());
commonService.convertStringToJsonobject(resultMap, new String[]{"otherAccessories"});
......@@ -879,6 +925,25 @@ public class JgEnableDisableServiceImpl extends BaseService<JgEnableDisableDto,
return resultMap;
}
private String concatWithSplit(String ... strs){
return Arrays.stream(strs).filter(org.apache.commons.lang3.StringUtils::isNotEmpty).collect(Collectors.joining("/"));
}
private String trimNull2Empty(String str) {
return JsonDiffUtil.nullToEmpty(str);
}
private Date castDate2TimeStr(Long timestamp) {
if (timestamp != null) {
try {
return DateUtil.date(timestamp);
} catch (NumberFormatException e) {
return null;
}
}
return null;
}
@Override
public boolean beforeCheck(JgEnableDisable jgEnableDisable) {
return jgEnableDisable.getInstanceId() != null && !jgEnableDisable.getAuditStatus().equals(FlowStatusEnum.TO_BE_FINISHED.getName()) &&!jgEnableDisable.getAuditStatus().equals(FlowStatusEnum.TO_BE_DISCARD.getName());
......
......@@ -36,7 +36,7 @@ public enum ApplicationFormTypeEnum {
GMBG("GMBG", "DJ_GM", "更名变更"),//更名变更
SBQY("SBQY", "SB_QY", "设备启用"),//设备启用
CSJ("CSJ", "DJ_CSJ", "超设计年限"),//超设计年限
SBTY("SBTY", "SB_TY", "设备启用");//设备启
SBTY("SBTY", "SB_TY", "设备停用");//设备停
/**
* 编号
......@@ -70,7 +70,4 @@ public enum ApplicationFormTypeEnum {
return null;
}
}
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