Commit 5955715d authored by 韩桐桐's avatar 韩桐桐

fix(jg):1,安装告知压力管道刷入调整后新结构的数据;

2,查询工程装置下的所有未做安装告知、不在安装告知流程、安装告知作废的设备接口
parent 7514da46
......@@ -44,4 +44,8 @@ public interface JgInstallationNoticeMapper extends CustomBaseMapper<JgInstallat
List<CompanyEquipCountDto> queryForFlowingEquipList();
List<InstallationVo> queryInstallationInIds(@Param("ids") List<String> ids);
List<Map<String, Object>> getDeviceListByProjectContraption(@Param("projectContraption") String projectContraption);
Map<String, Object> getPipelineEquInfoByRecord(@Param("record") String record);
}
......@@ -86,4 +86,6 @@ public interface IJgInstallationNoticeService extends IService<JgInstallationNot
JgInstallationNotice cancelApplication(Long sequenceNbr, String cancelReason);
Boolean historyDataRepair();
Object getDeviceListByProjectContraption(String projectContraption);
}
......@@ -200,4 +200,107 @@
isn.create_date DESC, isn.apply_no DESC
</select>
<sql id="page-list-pipeline">
SELECT ui."USE_UNIT_NAME" useUnitName,
ui."USE_UNIT_CREDIT_CODE" useUnitCreditCode,
to_char(ui."USE_DATE", 'YYYY-MM') useDate,
(SELECT DESIGN_UNIT_NAME from idx_biz_jg_design_info where "RECORD" = ui."RECORD") designUnitName,
(SELECT USC_UNIT_NAME
from idx_biz_jg_construction_info
where "RECORD" = ui."RECORD"
ORDER BY USC_DATE DESC
limit 1) uscUnitName,
to_char((SELECT USC_DATE
from idx_biz_jg_construction_info
where "RECORD" = ui."RECORD"
ORDER BY USC_DATE DESC
limit 1), 'YYYY-MM') uscDate,
ui."RECORD" record,
ri."EQU_CODE" equCode,
ri."EQU_LIST" equList,
(select name from tz_equipment_category where code = ri."EQU_LIST") equListName,
ri."EQU_CATEGORY" equCategory,
(select name from tz_equipment_category where code = ri."EQU_CATEGORY") equCategoryName,
ri."EQU_DEFINE" equDefine,
(select name from tz_equipment_category where code = ri."EQU_DEFINE") equDefineName,
ri."PRODUCT_NAME" productName,
ri."BRAND_NAME" brandName,
ri."EQU_TYPE" equType,
ri."EQU_CODE_TYPE" equCodeType,
ri."WHETHER_VEHICLE_CYLINDER" whetherVehicleCylinder,
pp."DEVICE_NAME" deviceName,
(select name from cb_data_dictionary where code = pp."DEVICE_LEVEL" and type = 'GBI') deviceLevel,
pp."PIPE_NAME" pipeName,
pp."PIPELINE_NUMBER" pipelineNumber,
pp."NOMINAL_DIAMETER" nominalDiameter,
pp."WALL_THICKNESS" wallThickness,
pp."PIPE_LENGTH" pipeLength,
pp."PRESSURE" pressure,
pp."TEMPERATURE" temperature,
pp."MEDIUM" medium,
pp."REMARKS" remarks,
(select INSPECT_ORG_NAME
from idx_biz_jg_inspection_detection_info
where "RECORD" = ui."RECORD"
ORDER BY REC_DATE DESC
limit 1) inspectOrgName,
(select name
from cb_data_dictionary
where type = 'JYJL'
and code = (select INSPECT_CONCLUSION
from idx_biz_jg_inspection_detection_info
where "RECORD" = ui."RECORD"
ORDER BY REC_DATE DESC
limit 1)) inspectConclusion,
to_char((select NEXT_INSPECT_DATE
from idx_biz_jg_inspection_detection_info
where "RECORD" = ui."RECORD"
ORDER BY REC_DATE DESC
limit 1), 'YYYY-MM-DD') nextInspectDate
FROM idx_biz_jg_use_info ui
LEFT JOIN idx_biz_jg_register_info ri on ri."RECORD" = ui."RECORD"
LEFT JOIN idx_biz_jg_tech_params_pipeline pp ON pp."RECORD" = ui."RECORD"
</sql>
<select id="getDeviceListByProjectContraption" resultType="java.util.Map">
<include refid="page-list-pipeline"/>
<where>
ri."EQU_CATEGORY" = '8300'
and ui."DATA_SOURCE" like 'jg%' and ui."DATA_SOURCE" not like 'jg_his%'
<if test="projectContraption != null and projectContraption != ''">
and ui."PROJECT_CONTRAPTION" = #{projectContraption}
</if>
-- 排除 已经做过安装告知的
AND NOT EXISTS (
SELECT 1
FROM
tzs_jg_installation_notice n,
tzs_jg_installation_notice_eq ne
WHERE
n.sequence_nbr = ne.equip_transfer_id
AND ne.equ_id = ui."RECORD"
AND (
n.notice_status = '6621'
OR n.notice_status = '6612'
OR n.notice_status = '6614'
OR n.notice_status = '6615'
OR n.notice_status = '6616'
OR n.notice_status = '6618'
)
AND n.is_delete = 0
)
</where>
</select>
<select id="getPipelineEquInfoByRecord" resultType="java.util.Map">
<include refid="page-list-pipeline"/>
<where>
<if test="record != null and record != ''">
and ui."RECORD" = #{record}
</if>
</where>
</select>
</mapper>
......@@ -169,4 +169,12 @@ public class JgInstallationNoticeController extends BaseController {
public ResponseModel<Boolean> historyDataRepair() {
return ResponseHelper.buildResponse(iJgInstallationNoticeService.historyDataRepair());
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET", value = "查询工程装置下的所有未做安装告知、不在安装告知流程、安装告知作废的设备",
notes = "查询工程装置下的所有未做安装告知、不在安装告知流程、安装告知作废的设备")
@GetMapping(value = "/getDeviceListByProjectContraption")
public ResponseModel<Object> getDeviceListByProjectContraption(@RequestParam("projectContraption") String projectContraption) {
return ResponseHelper.buildResponse(iJgInstallationNoticeService.getDeviceListByProjectContraption(projectContraption));
}
}
......@@ -7,8 +7,9 @@ import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.yeejoin.amos.boot.biz.common.utils.SnowflakeIdUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.github.pagehelper.util.StringUtil;
import com.yeejoin.amos.boot.biz.common.bo.CompanyBo;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
......@@ -19,6 +20,7 @@ import com.yeejoin.amos.boot.biz.common.entity.TzsBaseEntity;
import com.yeejoin.amos.boot.biz.common.utils.DateUtils;
import com.yeejoin.amos.boot.biz.common.utils.RedisKey;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import com.yeejoin.amos.boot.biz.common.utils.SnowflakeIdUtil;
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.jg.api.dto.*;
......@@ -28,7 +30,6 @@ import com.yeejoin.amos.boot.module.jg.api.enums.CompanyTypeEnum;
import com.yeejoin.amos.boot.module.jg.api.mapper.JgInstallationNoticeEqMapper;
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.vo.SortVo;
import com.yeejoin.amos.boot.module.jg.api.vo.tableDataExportVo.InstallationVo;
......@@ -51,7 +52,6 @@ import com.yeejoin.amos.boot.module.ymt.api.enums.EquCodeTypeEnum;
import com.yeejoin.amos.boot.module.ymt.api.enums.FlowStatusEnum;
import com.yeejoin.amos.boot.module.ymt.api.mapper.*;
import com.yeejoin.amos.component.feign.model.FeignClientResult;
import com.yeejoin.amos.component.robot.AmosRequestContext;
import com.yeejoin.amos.feign.privilege.Privilege;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import com.yeejoin.amos.feign.privilege.model.CompanyModel;
......@@ -69,7 +69,6 @@ import org.redisson.api.RedissonClient;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.Resource;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
......@@ -178,7 +177,7 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN
private JgRegistrationHistoryServiceImpl jgRegistrationHistoryService;
@Autowired
private EquipTechParamPipelineMapper equipTechParamPipelineMapper;
private ObjectMapper objectMapper;
@Autowired
EventPublisher eventPublisher;
......@@ -1708,60 +1707,72 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN
useInfoService.update(updateWrapper);
}
@Transactional
@Override
@Transactional(rollbackFor = Exception.class)
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())
.eq(JgRegistrationHistory::getIsDelete, false)
.one();
if (!ObjectUtils.isEmpty(jgRegistrationHistory) && !ObjectUtils.isEmpty(jgRegistrationHistory.getChangeData())) {
List<String> ids = equList.stream().map(JgInstallationNoticeEq::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.getEquListCode()) || 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());
}
}
List<JgInstallationNotice> noticeList = this.getBaseMapper().selectList(new LambdaQueryWrapper<JgInstallationNotice>()
.eq(JgInstallationNotice::getEquCategoryCode, "8300"));
List<JgRegistrationHistory> jgRegistrationHistories = noticeList.stream()
.map(notice -> {
JgRegistrationHistory history = getRegistrationHistory(String.valueOf(notice.getSequenceNbr()));
if (history == null) return null;
try {
Map<String, Object> hisData = objectMapper.readValue(
history.getChangeData(),
new TypeReference<Map<String, Object>>() {
}
);
// 获取设备列表并处理每个设备信息
List<Map<String, Object>> deviceList = objectMapper.readValue(
objectMapper.writeValueAsString(hisData.get("deviceList")),
new TypeReference<ArrayList<Map<String, Object>>>() {
}
);
deviceList.forEach(device -> {
String record = String.valueOf(device.get("record"));
Map<String, Object> pipelineEquInfo = this.baseMapper.getPipelineEquInfoByRecord(record);
device.putAll(pipelineEquInfo);
});
// 更新处理后的数据回到 history 对象
hisData.put("deviceList", deviceList);
history.setChangeData(objectMapper.writeValueAsString(hisData)); // 更新 changeData 字段
} catch (Exception e) {
log.error("JSON 数据处理失败!", e);
throw new RuntimeException(e.getMessage());
}
}
jgInstallationNoticeEqs.add(equ);
});
});
// 修改历史表数据
return history;
})
.filter(Objects::nonNull)
.collect(Collectors.toList());
// 批量更新历史表数据
jgRegistrationHistoryService.updateBatchById(jgRegistrationHistories);
this.updateBatchById(list);
jgInstallationNoticeEqService.updateBatchById(jgInstallationNoticeEqs);
return Boolean.TRUE;
}
// 辅助方法:根据 DocumentId 获取历史记录
private JgRegistrationHistory getRegistrationHistory(String documentId) {
return jgRegistrationHistoryService.getBaseMapper().selectOne(
new QueryWrapper<JgRegistrationHistory>().lambda()
.eq(JgRegistrationHistory::getCurrentDocumentId, documentId)
.eq(JgRegistrationHistory::getIsDelete, false)
);
}
/**
* 查询工程装置下的所有未做安装告知、不在安装告知流程、安装告知作废的设备
*
* @param projectContraption 工程装置名称
* @return 设备列表
*/
@Override
public Object getDeviceListByProjectContraption(String projectContraption) {
List<Map<String, Object>> deviceList = this.baseMapper.getDeviceListByProjectContraption(projectContraption);
return new JSONObject().fluentPut("deviceList", deviceList);
}
@Override
public boolean beforeCheck(JgInstallationNotice notice) {
return notice.getInstanceId() != null && !notice.getNoticeStatus().equals(String.valueOf(FlowStatusEnum.TO_BE_FINISHED.getCode())) &&!notice.getNoticeStatus().equals(String.valueOf(FlowStatusEnum.TO_BE_DISCARD.getCode()));
......
......@@ -34,10 +34,11 @@ public class EquipTechParamPipeline extends AbstractEquipBaseEntity {
@TableField(value = "\"STATUS\"")
private String status;
/**
* * 工程(装置)名称
* * 工程(装置)名称--废弃,以use_info表为准
*/
@Deprecated
@TableField(value = "\"DEVICE_NAME\"")
private String deviceName;
/**
......
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