Commit ee90f7b0 authored by hezhuozhi's avatar hezhuozhi

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

parents b14a7162 7727d145
......@@ -104,87 +104,6 @@ public class CylinderController {
@RestEventTrigger(value = "openapiLogEventHandler")
public ResponseModel<String> cylinderFillingInfo(@RequestBody String fillingData) throws Exception {
cylinderService.cylinderFillingHandler(fillingData);
// String token = RequestContext.getToken();
// AgencyUserModel me = Privilege.agencyUserClient.getme().getResult();
// String tokenKey = Redis.genKey(Constant.TOKEN_PREFIX, token);
// BizTokenModel bizTokenModel = (BizTokenModel)this.redisTemplate.opsForValue().get(tokenKey);
//
// JSONObject jsonobject = JSONObject.fromObject(fillingData);
// CylinderFillingDataValidationResultModel validateResult = null;
// CylinderFillingMessage cylinderFillingMessage = new CylinderFillingMessage();
// cylinderFillingMessage.setTime(simpleDateFormat.format(new Date()));
// cylinderFillingMessage.setFillingCompanyName(me.getCompanys().get(0).getCompanyName());
// cylinderFillingMessage.setAppId(bizTokenModel.getAppId());
// try {
// validateResult = cylinderFillingDataValidationService.validateFilling(jsonobject);
// } catch (Exception e) {
// e.printStackTrace();
// logger.error("液化气体气瓶充装信息上报,数据校验失败");
// cylinderFillingMessage.setMessage(e.getMessage());
// }
//
// if (!ObjectUtils.isEmpty(validateResult)) {
// cylinderFillingMessage.setCylinderNumber(validateResult.getCylinderNumber());
// List<String> message = new ArrayList<>();
// Integer errorNumber = 0;
// JSONObject error = new JSONObject();
// if (!ObjectUtils.isEmpty(validateResult.getBeforeErrorData())) {
// errorNumber += validateResult.getBeforeErrorData().size();
// error.put("充装前检查错误数据:", validateResult.getBeforeErrorData());
// message.add("充装前检查数据异常气瓶数:" + validateResult.getBeforeErrorCylinderNumber());
// }
//
// if (!ObjectUtils.isEmpty(validateResult.getRecordErrorData())) {
// errorNumber += validateResult.getRecordErrorData().size();
// error.put("填充错误数据:", validateResult.getRecordErrorData());
// message.add("充装记录数据异常气瓶数:" + validateResult.getRecordErrorCylinderNumber());
// }
//
// if (!ObjectUtils.isEmpty(validateResult.getAfterErrorData())) {
// errorNumber += validateResult.getAfterErrorData().size();
// error.put("充装后错误数据:", validateResult.getAfterErrorData());
// message.add("充装后复查数据异常气瓶数:" + validateResult.getAfterErrorCylinderNumber());
// }
//
// if (!org.springframework.util.ObjectUtils.isEmpty(validateResult.getSeqCodeErrorData())) {
// errorNumber += validateResult.getSeqCodeErrorData().size();
// error.put("气瓶信息不存在:", validateResult.getSeqCodeErrorData());
// message.add("气瓶信息不存在数量:" + validateResult.getSeqCodeErrorData().size());
// }
//
// if (errorNumber <= 0) {
// message.add("液化气体气瓶充装信息成功数:" + validateResult.getSuccessCylinderNumber() + "条");
// } else {
// cylinderFillingMessage.setMessage(String.join("条; ", message) + "个");
// CylinderFillingMessageModel cylinderFillingMessageModel = new CylinderFillingMessageModel();
// BeanUtils.copyProperties(cylinderFillingMessage, cylinderFillingMessageModel);
// cylinderFillingMessageService.createWithModel(cylinderFillingMessageModel);
// emqKeeper.getMqttClient().publish("openapi/cylinder/filling", JSONObject.fromObject(cylinderFillingMessage).toString().getBytes(), 2, false);
//
// throw new BadRequest(error.toString());
// }
// } else {
// throw new BadRequest("数据校验失败!!!");
// }
//
// TmCylinderFillingModelList cylinderFillingModelList = com.alibaba.fastjson.JSONObject.parseObject(fillingData, TmCylinderFillingModelList.class);
//
// List<TmCylinderFillingModel> fillingBeforeList = cylinderFillingModelList.getFillingBefore();
// List<TmCylinderFillingRecordModel> fillingList = cylinderFillingModelList.getFilling();
// List<TmCylinderFillingCheckModel> fillingAfterList = cylinderFillingModelList.getFillingAfter();
// if (ValidationUtil.isEmpty(fillingBeforeList) && ValidationUtil.isEmpty(fillingList) && ValidationUtil.isEmpty(fillingAfterList)) {
// throw new BadRequest("液化气体气瓶充装信息-充装前检查信息、液化气体气瓶充装信息-充装记录信息、液化气体气瓶充装信息-充装后复查信息为空.");
// }
// cylinderFillingService.createCylinderFillingBefore(fillingBeforeList);
// cylinderFillingRecordService.createCylinderFilling(fillingList);
// cylinderFillingCheckService.createCylinderFillingAfter(fillingAfterList);
//
// CylinderFillingMessageModel cylinderFillingMessageModel = new CylinderFillingMessageModel();
// BeanUtils.copyProperties(cylinderFillingMessage, cylinderFillingMessageModel);
// cylinderFillingMessageModel.setAppId(bizTokenModel.getAppId());
// cylinderFillingMessageService.createWithModel(cylinderFillingMessageModel);
// emqKeeper.getMqttClient().publish("openapi/cylinder/filling", JSONObject.fromObject(cylinderFillingMessage).toString().getBytes(), 2, false);
// Double a = (double) (1/0);
return ResponseHelper.buildResponse("OK");
}
......
......@@ -10,10 +10,8 @@ import com.yeejoin.amos.boot.module.jg.api.dto.JgUseRegistrationDto;
import com.yeejoin.amos.boot.module.jg.api.entity.JgUseRegistration;
import com.yeejoin.amos.boot.module.jg.api.vo.SortVo;
import com.yeejoin.amos.boot.module.jg.api.vo.tableDataExportVo.RegistrationVo;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List;
import java.util.Map;
import java.util.Set;
......@@ -71,17 +69,14 @@ public interface JgUseRegistrationMapper extends BaseMapper<JgUseRegistration> {
Page<JSONObject> queryForEquipUsedByVehiclePageHistory(@Param("page") Page<JSONObject> page, @Param("jsonObject") JSONObject jsonObject);
@MapKey("records")
List<Map<String, Object>> queryForUnitVesselEquipment(@Param("records") List<String> records);
Page<JSONObject> queryForUnitPipelineEquipmentPage(@Param("page") Page<JSONObject> page, @Param("jsonObject") JSONObject jsonObject, @Param("records") Set<String> records);
@MapKey("records")
List<Map<String, Object>> queryForUnitPipelineEquipment(@Param("records") List<String> records);
List<Map<String, Object>> queryForUnitPipelineEquipmentForEdit(@Param("records") List<String> records);
@MapKey("id")
List<Map<String, Object>> selectEquipList(@Param("id") Long id);
List<CompanyEquipCountDto> queryForFlowingEquipList();
......@@ -117,9 +112,8 @@ public interface JgUseRegistrationMapper extends BaseMapper<JgUseRegistration> {
/**
* 查询指定装置下可做使用登记的的管道,样式为汇总表样式
* @param projectContraptionSeq 装置id
* @param projectContraptionSeqList 原始装置idList
* @return List<Map<String, Object>>
*/
List<Map<String, Object>> selectPieLineListByOfCanReg(@Param("projectContraptionSeq") String projectContraptionSeq);
List<Map<String, Object>> selectPieLineListByOfCanReg(@Param("projectContraptionSeqList") List<String> projectContraptionSeqList);
}
......@@ -1067,11 +1067,14 @@
select * from (
<include refid="page-list-pipeline"/>
WHERE
ri."EQU_CATEGORY" = '8300'
and ui."PROJECT_CONTRAPTION_ID" = #{projectContraptionSeq}
AND ui.IS_INTO_MANAGEMENT = true
and (length(ri.USE_ORG_CODE) = 0 or ri.USE_ORG_CODE is null)
ORDER BY ui.REC_DATE DESC
ri."EQU_CATEGORY" = '8300'
AND ui."PROJECT_CONTRAPTION_ID" IN
<foreach collection="projectContraptionSeqList" item="item" open="(" separator="," close=")">
#{item}
</foreach>
AND ui.IS_INTO_MANAGEMENT = true
AND (length(ri.USE_ORG_CODE) = 0 OR ri.USE_ORG_CODE IS NULL)
ORDER BY ui.REC_DATE DESC
)
</select>
......
......@@ -127,5 +127,13 @@ public class DataHandlerController extends BaseController {
return ResponseHelper.buildResponse(true);
}
/**
* 管道使用登记主表刷入原始工程装置ID集合和Eq表刷入工程装置ID
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET", value = "管道使用登记主表刷入原始工程装置ID集合和Eq表刷入工程装置ID", notes = "管道使用登记主表刷入原始工程装置ID集合和Eq表刷入工程装置ID")
@GetMapping(value = "/useRegistration/writeProjectContraptionIdInJgUseRegistration")
public ResponseModel<Boolean> writeProjectContraptionIdInJgUseRegistration() {
return ResponseHelper.buildResponse(dataHandlerService.writeProjectContraptionIdInJgUseRegistration());
}
}
......@@ -389,7 +389,8 @@ public class JgUseRegistrationController extends BaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET", value = "查询工程装置下的所有做过安装告知但是为做使用登记的管道", notes = "查询工程装置下的所有做过安装告知但是为做使用登记的管道")
@GetMapping(value = "/getDeviceListByProjectContraptionSeq")
public ResponseModel<Object> getDeviceListByProjectContraption(@RequestParam("record") String projectContraptionSeq) {
return ResponseHelper.buildResponse(jgUseRegistrationServiceImpl.getDeviceListByProjectContraption(projectContraptionSeq));
public ResponseModel<Object> getDeviceListByProjectContraption(@RequestParam("record") String projectContraptionSeq,
@RequestParam("originProjectContraptionIds") String[] originProjectContraptionIds) {
return ResponseHelper.buildResponse(jgUseRegistrationServiceImpl.getDeviceListByProjectContraption(projectContraptionSeq, originProjectContraptionIds));
}
}
......@@ -959,4 +959,35 @@ public class DataHandlerServiceImpl {
useInfoService.update(updateWrapper);
});
}
public Boolean writeProjectContraptionIdInJgUseRegistration() {
List<JgUseRegistration> useRegistrations = useRegistrationService.list(
new LambdaQueryWrapper<JgUseRegistration>()
.isNotNull(JgUseRegistration::getProjectContraptionId)
.select(BaseEntity::getSequenceNbr, JgUseRegistration::getProjectContraptionId)
);
for (JgUseRegistration u : useRegistrations) {
// 更新 JgUseRegistration 表
useRegistrationService.lambdaUpdate()
.set(JgUseRegistration::getOriginProjectContraptionIds, u.getProjectContraptionId())
.eq(JgUseRegistration::getSequenceNbr, u.getSequenceNbr())
.update();
// 更新 JgUseRegistrationEq 表
LambdaQueryWrapper<JgUseRegistrationEq> lambda = new QueryWrapper<JgUseRegistrationEq>().lambda();
lambda.eq(JgUseRegistrationEq::getEquipTransferId, u.getSequenceNbr());
List<JgUseRegistrationEq> jgUseRegistrationEqList = useRegistrationEqService.getBaseMapper().selectList(lambda);
if (jgUseRegistrationEqList != null) {
for (JgUseRegistrationEq eq : jgUseRegistrationEqList) {
useRegistrationEqService.lambdaUpdate()
.set(JgUseRegistrationEq::getOriginProjectContraptionId, u.getProjectContraptionId())
.eq(JgUseRegistrationEq::getSequenceNbr, eq.getSequenceNbr())
.update();
}
}
}
return true;
}
}
......@@ -138,6 +138,7 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
public static final String DATA_SOURCE_NAME = "DATA_SOURCE_NAME";
public static final String USE_PLACE_CODE = "USE_PLACE_CODE";
public static final String EQU_CATEGORY_CODE = "EQU_CATEGORY_CODE";
public static final String EQU_LIST_CODE = "EQU_LIST_CODE";
public static final String PROJECT_CONTRAPTION = "PROJECT_CONTRAPTION";// 工程装置名称
/**
* 业务类型 0:单个新增 1:批量导入
......@@ -393,9 +394,9 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
}
LinkedHashMap equipmentInfoForm = (LinkedHashMap) checkAndCast(paramMap.get(EQUIP_INFO_FORM_ID));
String dataSource = (String) equipmentInfoForm.get(DATA_SOURCE);
String equCategory = (String) equipmentInfoForm.get(EQU_CATEGORY);
String equListCode = (String) equipmentInfoForm.get(EQU_LIST);
//管道添加设备
if (PipelineEnum.INDUSTRIAL_PIPELINE.getCode().equals(equCategory)) {
if (PipelineEnum.PRESSURE_PIPELINE.getCode().equals(equListCode)) {
return this.pipelineEquipCreateOrUpdate(paramMap);
}
if(dataSource.contains("black")){
......@@ -2479,13 +2480,19 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
boolMust.must(scBuilder);
}
// 设备种类编码
if (!ObjectUtils.isEmpty(map.getString("EQU_LIST_CODE"))) {
if (!ObjectUtils.isEmpty(map.getString(EQU_LIST_CODE))) {
BoolQueryBuilder elcBuilder = QueryBuilders.boolQuery();
String test = QueryParser.escape(map.getString("EQU_LIST_CODE"));
elcBuilder.must(QueryBuilders.matchPhraseQuery("EQU_LIST_CODE", test));
String test = QueryParser.escape(map.getString(EQU_LIST_CODE));
elcBuilder.must(QueryBuilders.matchPhraseQuery(EQU_LIST_CODE, test));
boolMust.must(elcBuilder);
} else {
BoolQueryBuilder pBuilder = QueryBuilders.boolQuery();
String test = QueryParser.escape("8000");//不查管道,管道新菜单查询
pBuilder.mustNot(QueryBuilders.termQuery(EQU_LIST_CODE, test));
boolMust.must(pBuilder);
}
// 设备类别编码
// 设备品种编码
if (!ObjectUtils.isEmpty(map.getString("EQU_DEFINE_CODE"))) {
BoolQueryBuilder elcBuilder = QueryBuilders.boolQuery();
String test = QueryParser.escape(map.getString("EQU_DEFINE_CODE"));
......@@ -2506,11 +2513,6 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
String test = QueryParser.escape(map.getString(EQU_CATEGORY_CODE));
pBuilder.must(QueryBuilders.termQuery(EQU_CATEGORY_CODE, test));
boolMust.must(pBuilder);
} else {
BoolQueryBuilder pBuilder = QueryBuilders.boolQuery();
String test = QueryParser.escape("8300");// 不查管道,管道新菜单查询
pBuilder.mustNot(QueryBuilders.termQuery(EQU_CATEGORY_CODE, test));
boolMust.must(pBuilder);
}
// 是否车用气瓶
if (!ObjectUtils.isEmpty(map.getString(WHETHER_VEHICLE_CYLINDER))) {
......
......@@ -100,6 +100,7 @@ import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
import java.util.stream.Stream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipOutputStream;
......@@ -835,6 +836,7 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
// 具体地址
useRegistration.setUseAddress("陕西省" + fullAddress + map.get("address"));
useRegistration.setOriginProjectContraptionIds((String) map.get("originProjectContraptionIds"));
// 新增或编辑保存
if (StringUtils.isEmpty(useRegistration.getSequenceNbr())) {
......@@ -3907,6 +3909,7 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
LambdaQueryWrapper<IdxBizJgProjectContraption> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(IdxBizJgProjectContraption::getUseUnitCreditCode, useUnitCreditCode)
.eq(IdxBizJgProjectContraption::getIsIntoManagement, true)
.notIn(!proIds.isEmpty(), BaseEntity::getSequenceNbr, proIds)
.and(w -> w.isNull(IdxBizJgProjectContraption::getUseRegistrationCode)
.or().eq(IdxBizJgProjectContraption::getUseRegistrationCode, "")
......@@ -3914,19 +3917,31 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
return jgProjectContraptionService.page(page, wrapper);
}
public Map<String, Object> getDeviceListByProjectContraption(String projectContraptionSeq) {
public Map<String, Object> getDeviceListByProjectContraption(String projectContraptionSeq, String[] originProjectContraptionIds) {
// 获取工程信息
IdxBizJgProjectContraption projectContraption = jgProjectContraptionService.getById(projectContraptionSeq);
Map<String, Object> re = new HashMap<>();
List<Map<String, Object>> equList = this.getBaseMapper().selectPieLineListByOfCanReg(projectContraptionSeq);
re.put("equipmentLists", equList);
re.put("projectContraption", projectContraption.getProjectContraption());
re.put("projectContraptionId", projectContraptionSeq);
re.put("projectContraptionNo", projectContraption.getProjectContraptionNo());
re.put("pipelineLength", projectContraption.getPipelineLength());
this.setPieLineInspectInfo(projectContraptionSeq, re);
this.setConstructionInfo(projectContraptionSeq, re);
return re;
// 查询设备列表
List<String> uniqueContraptionList = Stream.concat(Arrays.stream(originProjectContraptionIds), Stream.of(projectContraptionSeq))
.distinct()
.collect(Collectors.toList());
List<Map<String, Object>> equList = this.getBaseMapper()
.selectPieLineListByOfCanReg(uniqueContraptionList);
// 计算管道长度总和
double totalPipelineLength = equList.stream()
.map(map -> map.get("pipeLength"))
.filter(Objects::nonNull)
.mapToDouble(value -> (Double) value)
.sum();
return MapBuilder.<String, Object>create()
.put("equipmentLists", equList)
.put("projectContraption", projectContraption.getProjectContraption())
.put("projectContraptionId", projectContraptionSeq)
.put("projectContraptionNo", projectContraption.getProjectContraptionNo())
.put("pipelineLength", totalPipelineLength)
.build();
}
private void setConstructionInfo(String projectContraptionSeq, Map<String, Object> re) {
LambdaQueryWrapper<IdxBizJgProjectConstruction> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(IdxBizJgProjectConstruction::getProjectContraptionId, projectContraptionSeq)
......
package com.yeejoin.amos.boot.module.jyjc.api.entity;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import org.typroject.tyboot.core.rdbms.orm.entity.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.util.Date;
/**
* 检验检测历史数据表
*
* @author system_generator
* @date 2025-01-14
*/
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName(value = "tz_jyjc_inspection_history", autoResultMap = true)
public class JyjcInspectionHistory extends BaseEntity {
private static final long serialVersionUID = 1L;
/**
* 来源seq
*/
@TableField("s_seq")
private Long sSeq;
/**
* 推送数据
*/
@TableField(value = "history_data", typeHandler = JacksonTypeHandler.class)
private JSONObject historyData;
/**
* 备注
*/
@TableField("remark")
private String remark;
/**
* 来源类型
*/
@TableField("s_type")
private String sType;
}
......@@ -124,6 +124,13 @@ public interface JyjcInspectionApplicationMapper extends BaseMapper<JyjcInspecti
* @return List<Map<String, Object>>
*/
List<Map<String, Object>> selectPieLineListOfInspect(@Param("records") List<String> records);
/**
* 查询指定管道的信息,样式为汇总表样式-无检验信息
* @param records 管道ids
* @return List<Map<String, Object>>
*/
List<Map<String, Object>> selectPieLineListOfNoInspectInfo(@Param("records") List<String> records);
}
package com.yeejoin.amos.boot.module.jyjc.api.mapper;
import com.yeejoin.amos.boot.module.jyjc.api.entity.JyjcInspectionHistory;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* 检验检测历史数据表 Mapper 接口
*
* @author system_generator
* @date 2025-01-14
*/
public interface JyjcInspectionHistoryMapper extends BaseMapper<JyjcInspectionHistory> {
}
package com.yeejoin.amos.boot.module.jyjc.api.model;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import org.typroject.tyboot.core.rdbms.model.BaseModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* 检验检测历史数据表
*
* @author system_generator
* @date 2025-01-14
*/
@Data
@EqualsAndHashCode(callSuper = true)
@ApiModel(value="JyjcInspectionHistoryModel", description="检验检测历史数据表")
public class JyjcInspectionHistoryModel extends BaseModel {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "来源seq")
private Long sSeq;
@ApiModelProperty(value = "推送数据")
private String historyData;
@ApiModelProperty(value = "备注")
private String remark;
@ApiModelProperty(value = "来源类型")
private String sType;
}
package com.yeejoin.amos.boot.module.jyjc.api.service;
/**
* 检验检测历史数据表接口类
*
* @author system_generator
* @date 2025-01-14
*/
public interface IJyjcInspectionHistoryService {}
......@@ -25,4 +25,11 @@ public interface IJyjcInspectionResultParamService {
* @return 字段列表
*/
List<Map<String,Object>> getParamByEquipTypeCode(String equipTypeCode);
/**
* 根据
* @param sequenceNbr
* @return
*/
JyjcInspectionResultParam getOneParamByResultSeq(Long sequenceNbr);
}
......@@ -682,6 +682,50 @@
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>
<sql id="page-list-pipeline-no-inspect">
SELECT
ui."USE_UNIT_NAME" useUnitName,
ui."USE_UNIT_CREDIT_CODE" useUnitCreditCode,
ui."PROJECT_CONTRAPTION_ID" as projectContraptionId,
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,
ui.IS_INTO_MANAGEMENT as isIntoManagement,
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,
-- 历史遗留问题 故 as
pp."PIPE_NAME" as productName,
ri."BRAND_NAME" brandName,
ri."EQU_TYPE" equType,
ri."EQU_CODE_TYPE" equCodeType,
ri."WHETHER_VEHICLE_CYLINDER" whetherVehicleCylinder,
ri."USE_ORG_CODE" useOrgCode,
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,
pp."WORK_PRESSURE" AS workPressure,
pp."WORK_TEMPERATURE" AS workTemperature,
pp."WORK_MEDIUM" AS workMedium
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="selectPieLineListByProjectId" resultType="java.util.Map">
select * from (
<include refid="page-list-pipeline"/>
......@@ -700,4 +744,13 @@
</foreach>
ORDER BY ui.REC_DATE DESC
</select>
<select id="selectPieLineListOfNoInspectInfo" resultType="java.util.Map">
<include refid="page-list-pipeline-no-inspect"/>
WHERE
ui.record in
<foreach collection="records" item="record" open="(" close=")" separator=",">
#{record}
</foreach>
ORDER BY ui.REC_DATE DESC
</select>
</mapper>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.yeejoin.amos.boot.module.jyjc.api.mapper.JyjcInspectionHistoryMapper">
</mapper>
......@@ -71,7 +71,6 @@ import org.redisson.api.RLock;
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.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
......@@ -172,6 +171,9 @@ public class JyjcInspectionApplicationServiceImpl extends BaseService<JyjcInspec
@Resource
private SnowflakeIdUtil sequence;
@Resource
private JyjcInspectionHistoryServiceImpl inspectionHistoryService;
@NotNull
public static List<DictionarieModel> getDictionarieModels(String bizType) {
......@@ -431,7 +433,7 @@ public class JyjcInspectionApplicationServiceImpl extends BaseService<JyjcInspec
}
private void setEquipCategoryIfPieLine(JyjcInspectionApplicationModel model, JyjcInspectionApplicationEquip equipInfo, JyjcInspectionApplicationEquipDto equipDto) {
if(model.getEquipClassify().equals(EquipmentClassifityEnum.YLGD.getCode())){
if (model.getEquipClassify().equals(EquipmentClassifityEnum.YLGD.getCode())) {
equipInfo.setEquipUnicode(model.getProjectContraptionId());
equipInfo.setEquList(equipDto.getEquList());
equipInfo.setEquCategory(equipDto.getEquCategory());
......@@ -443,7 +445,7 @@ public class JyjcInspectionApplicationServiceImpl extends BaseService<JyjcInspec
}
private String buildTaskContent(JyjcInspectionApplicationModel model){
private String buildTaskContent(JyjcInspectionApplicationModel model) {
return String.format("来自%s%s的业务办理,【申请单号:%s】", model.getEquList(), StringUtils.isNotBlank(model.getSupervisoryCode()) ? "【" + model.getSupervisoryCode() + "】" : "", model.getApplicationNo());
}
......@@ -603,13 +605,33 @@ public class JyjcInspectionApplicationServiceImpl extends BaseService<JyjcInspec
Map<String, Object> map = BeanUtil.beanToMap(model);
// 附件
Map<String, Object> attMap = getAttachmentMap(sequenceNbr);
if(model.getEquipClassify().equals(EquipmentClassifityEnum.YLGD.getCode())){
// 压力管道
map.putAll(getDeviceListByProjectContraption2(model));
// 已完成的显示json数据 需兼容老数据
if (model.getStatus().equals(String.valueOf(FlowStatusEnum.TO_BE_FINISHED.getCode()))) {
JyjcInspectionHistory inspectionHistory = inspectionHistoryService.getBySSeq(sequenceNbr);
if (inspectionHistory != null) {
// 新报检单记录历史数据的逻辑
map.putAll(inspectionHistory.getHistoryData());
} else {
// 历史单位之前未记录历史数据的逻辑
if (model.getEquipClassify().equals(EquipmentClassifityEnum.YLGD.getCode())) {
// 压力管道
map.putAll(getDeviceListByProjectContraption2(model));
} else {
// 其他设备
List<Map<String, Object>> arrayList = getEquipInfoList(sequenceNbr, model);
map.put("equip", arrayList);
}
}
} else {
// 其他设备
List<Map<String, Object>> arrayList = getEquipInfoList(sequenceNbr, model);
map.put("equip", arrayList);
// 未审批完成的显示实时数据
if (model.getEquipClassify().equals(EquipmentClassifityEnum.YLGD.getCode())) {
// 压力管道
map.putAll(getDeviceListByProjectContraption2(model));
} else {
// 其他设备
List<Map<String, Object>> arrayList = getEquipInfoList(sequenceNbr, model);
map.put("equip", arrayList);
}
}
map.putAll(attMap);
map.put("companyType", companyType);
......@@ -722,7 +744,7 @@ public class JyjcInspectionApplicationServiceImpl extends BaseService<JyjcInspec
List<JyjcInspectionResult> resultModels = new ArrayList<>();
List<JgResumeInfoDto> jgResumeInfoDtoList = new ArrayList<>();
Date now = DateUtil.date();
if(model.getEquipClassify().equals(EquipmentClassifityEnum.YLGD.getCode())){
if (model.getEquipClassify().equals(EquipmentClassifityEnum.YLGD.getCode())) {
List<String> codes = tzsServiceFeignClient.applicationFormCode(ApplicationFormTypeEnum.JG.getCode(), 1).getResult();
JyjcInspectionResult resultModel = new JyjcInspectionResult();
resultModel.setInspectionUnitCode(model.getInspectionUnitCode());
......@@ -741,21 +763,21 @@ public class JyjcInspectionApplicationServiceImpl extends BaseService<JyjcInspec
// 装置信息查询
resultModel.setEquipUnicode(model.getProjectContraptionId());
IdxBizJgProjectContraption projectContraption = idxBizJgProjectContraptionMapper.selectById(model.getProjectContraptionId());
if(projectContraption != null){
if (projectContraption != null) {
resultModel.setEquipUnicode(projectContraption.getSequenceNbr() + "");
resultModel.setSupervisoryCode(projectContraption.getSupervisoryCode());
resultModel.setEquCategory(projectContraption.getEquCategory());
resultModel.setEquList(projectContraption.getEquList());
resultModel.setEquDefine(projectContraption.getEquDefine());
}
Long resultSeq = sequence.nextId();
Long resultSeq = sequence.nextId();
resultModel.setSequenceNbr(resultSeq);
resultModel.setIsExistNc(false);
resultModel.setManageType("batch");
this.setResultTypeByBizType(resultModel, model.getBizType());
resultModels.add(resultModel);
// TODO 以管道汇总样式表暂存json,在结果录入后,将数据更新技术参数,考虑老数据
Map<String, Object> paramDetail = getDeviceListByProjectContraption2(model);
Map<String, Object> paramDetail = getDeviceListByProjectContraption3(model);
JyjcInspectionResultParam resultParam = new JyjcInspectionResultParam();
resultParam.setResultSeq(resultModel.getSequenceNbr());
resultParam.setParamJson(JSON.toJSONString(paramDetail));
......@@ -787,7 +809,7 @@ public class JyjcInspectionApplicationServiceImpl extends BaseService<JyjcInspec
resultModel.setEquList(applicationEquipModels.get(i).getEquList());
resultModel.setIsExistNc(false);
this.setResultTypeByBizType(resultModel, model.getBizType());
Long resultSeq = sequence.nextId();
Long resultSeq = sequence.nextId();
resultModel.setSequenceNbr(resultSeq);
resultModels.add(resultModel);
// TODO 暂存json,在结果录入后,将数据更新技术参数-检验详情使用 考虑兼容老数据
......@@ -799,6 +821,7 @@ public class JyjcInspectionApplicationServiceImpl extends BaseService<JyjcInspec
// 报检信息推送 TODO
// this.pushInspectionApplication(model);
this.saveBatchResume(jgResumeInfoDtoList);
this.createHisAfterReceive(model);
// 更新流程中的流程数据
commonService.saveExecuteFlowData2Redis(model.getProcessInstanceId(), this.buildInstanceRuntimeData(entity));
} catch (InterruptedException e) {
......@@ -810,6 +833,19 @@ public class JyjcInspectionApplicationServiceImpl extends BaseService<JyjcInspec
}
}
public void createHisAfterReceive(JyjcInspectionApplicationModel model) {
if (model.getEquipClassify().equals(EquipmentClassifityEnum.YLGD.getCode())) {
JSONObject hisData = getDeviceListByProjectContraption2(model);
inspectionHistoryService.saveBySeq(model.getSequenceNbr(), hisData, model.getInspectionType());
} else {
List<Map<String, Object>> arrayList = getEquipInfoList(model.getSequenceNbr(), model);
JSONObject hisData = new JSONObject();
hisData.put("equip", arrayList);
inspectionHistoryService.saveBySeq(model.getSequenceNbr(), hisData, model.getInspectionType());
}
}
private void saveBatchResume(List<JgResumeInfoDto> jgResumeInfoDtoList) {
try {
jgFeignClient.saveBatchResume(jgResumeInfoDtoList);
......@@ -1391,7 +1427,7 @@ public class JyjcInspectionApplicationServiceImpl extends BaseService<JyjcInspec
public IPage<IdxBizJgProjectContraption> getJgProjectContraptionPage(String inspectionType, Page<IdxBizJgProjectContraption> page, String companyCode, String equCategory) {
// 兼容个人业务
if(companyCode.contains("_")){
if (companyCode.contains("_")) {
companyCode = companyCode.split("_")[1];
}
// 定期检验,查询当前使用单位,工业管道: 查询当前使用单位下已纳管且有使用登记证的装置,且非流程中的 ;公用管道、长输管道:已纳管且做过检验的,且非流程中的
......@@ -1400,7 +1436,8 @@ public class JyjcInspectionApplicationServiceImpl extends BaseService<JyjcInspec
/**
* 查询指定装置下的装置基本信息、施工信息、管道信息(前缀装置列表已进行过滤,故不进行状态的过滤)
* 查询指定装置下的装置基本信息、施工/使用信息、管道信息(前缀装置列表已进行过滤,故不进行状态的过滤)--报检发起使用
*
* @param projectContraptionSeq 装置id
* @return 装置的详情
*/
......@@ -1413,55 +1450,98 @@ public class JyjcInspectionApplicationServiceImpl extends BaseService<JyjcInspec
re.put("projectContraptionId", projectContraptionSeq);
re.put("projectContraptionNo", projectContraption.getProjectContraptionNo());
re.put("pipelineLength", projectContraption.getPipelineLength());
this.setConstructionInfo(projectContraptionSeq, re);
re.put("useRegistrationCode ", projectContraption.getUseRegistrationCode());
this.setInstallAddress(projectContraption, re);
this.setUseAddress(projectContraption, re);
return re;
}
/**
* 查询指定报检单据下的装置管道信息
* 使用地点-使用登记完成后回把使用登记的地点信息写到装置表。定期检验时显示
* @param projectContraption 装置
* @param re 返回结果:增加使用地点(工业管道是使用登记时的地址);公用、长输管道是安装地址(无使用登记证)
*/
private void setUseAddress(IdxBizJgProjectContraption projectContraption, Map<String, Object> re) {
re.put("useAddress", getDetailAddress(projectContraption));
}
/**
* 查询指定报检单据下的装置管道信息-----报检详情使用与getDeviceListByProjectContraption区别,指定了管道
*
* @param applicationModel 报检单据信息
* @return 装置的详情
*/
public Map<String, Object> getDeviceListByProjectContraption2(JyjcInspectionApplicationModel applicationModel) {
public JSONObject getDeviceListByProjectContraption2(JyjcInspectionApplicationModel applicationModel) {
IdxBizJgProjectContraption projectContraption = idxBizJgProjectContraptionMapper.selectById(applicationModel.getProjectContraptionId());
List<JyjcInspectionApplicationEquipModel> applicationEquipModels = applicationEquipService.listApplicationEquipByApplicationSeq(applicationModel.getSequenceNbr());
List<String> records = applicationEquipModels.stream().map(JyjcInspectionApplicationEquipModel::getEquipUnicode).collect(Collectors.toList());
Map<String, Object> re = new HashMap<>();
JSONObject jsonObject = new JSONObject();
List<Map<String, Object>> equList = this.getBaseMapper().selectPieLineListOfInspect(records);
re.put("equip", equList);
re.put("projectContraption", projectContraption.getProjectContraption());
re.put("projectContraptionId", applicationModel.getProjectContraptionId());
re.put("projectContraptionNo", projectContraption.getProjectContraptionNo());
re.put("pipelineLength", calTotalLength(equList));
this.setConstructionInfo(applicationModel.getProjectContraptionId(), re);
return re;
jsonObject.put("equip", equList);
jsonObject.put("projectContraption", projectContraption.getProjectContraption());
jsonObject.put("projectContraptionId", applicationModel.getProjectContraptionId());
jsonObject.put("projectContraptionNo", projectContraption.getProjectContraptionNo());
jsonObject.put("pipelineLength", calTotalLength(equList));
jsonObject.put("useRegistrationCode ", projectContraption.getUseRegistrationCode());
this.setInstallAddress(projectContraption, jsonObject);
this.setUseAddress(projectContraption, jsonObject);
return jsonObject;
}
private String calTotalLength(List<Map<String, Object>> equList){
double pipeLengthSum = equList.stream().map(r->r.get("pipeLength")).filter(Objects::nonNull).mapToDouble(l->Double.parseDouble(String.valueOf(l))).sum();
BigDecimal pipeLengthSumBig = new BigDecimal(String.valueOf(pipeLengthSum)).setScale(3, RoundingMode.HALF_UP);
return pipeLengthSumBig.toPlainString();
private void setInstallAddress(IdxBizJgProjectContraption projectContraption, Map<String, Object> re) {
re.put("installAddress", getDetailAddress(projectContraption));
}
/**
* 安装地址:安装告知完成后,此字段为安装地址
* @param projectContraption 装置
* @param jsonObject 增加安装地址
*/
private void setInstallAddress(IdxBizJgProjectContraption projectContraption, JSONObject jsonObject) {
jsonObject.put("installAddress", getDetailAddress(projectContraption));
}
private void setConstructionInfo(String projectContraptionSeq, Map<String, Object> re) {
LambdaQueryWrapper<IdxBizJgProjectConstruction> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(IdxBizJgProjectConstruction::getProjectContraptionId, projectContraptionSeq)
.orderByDesc(IdxBizJgProjectConstruction::getUscDate).last("limit 1");
IdxBizJgProjectConstruction construction = idxBizJgProjectConstructionMapper.selectOne(queryWrapper);
if(construction != null){
re.put("installAddress", getDetailAddress(construction));
}
/**
* 管道报检结果-管道详情页签-数据缓存---与getDeviceListByProjectContraption2区别,汇总表内不包含检验信息
* @param applicationModel 申请单
* @return 无检验信息的汇总管道-检验结果页面专用
*/
public JSONObject getDeviceListByProjectContraption3(JyjcInspectionApplicationModel applicationModel) {
JSONObject jsonObject = new JSONObject();
IdxBizJgProjectContraption projectContraption = idxBizJgProjectContraptionMapper.selectById(applicationModel.getProjectContraptionId());
List<JyjcInspectionApplicationEquipModel> applicationEquipModels = applicationEquipService.listApplicationEquipByApplicationSeq(applicationModel.getSequenceNbr());
List<String> records = applicationEquipModels.stream().map(JyjcInspectionApplicationEquipModel::getEquipUnicode).collect(Collectors.toList());
List<Map<String, Object>> equList = this.getBaseMapper().selectPieLineListOfNoInspectInfo(records);
jsonObject.put("equip", equList);
jsonObject.put("projectContraption", projectContraption.getProjectContraption());
jsonObject.put("projectContraptionId", applicationModel.getProjectContraptionId());
jsonObject.put("projectContraptionNo", projectContraption.getProjectContraptionNo());
jsonObject.put("pipelineLength", calTotalLength(equList));
jsonObject.put("useRegistrationCode ", projectContraption.getUseRegistrationCode());
this.setInstallAddress(projectContraption, jsonObject);
this.setUseAddress(projectContraption, jsonObject);
return jsonObject;
}
private String calTotalLength(List<Map<String, Object>> equList) {
double pipeLengthSum = equList.stream().map(r -> r.get("pipeLength")).filter(Objects::nonNull).mapToDouble(l -> Double.parseDouble(String.valueOf(l))).sum();
BigDecimal pipeLengthSumBig = new BigDecimal(String.valueOf(pipeLengthSum)).setScale(3, RoundingMode.HALF_UP);
return pipeLengthSumBig.toPlainString();
}
private String trimIfNull(String str){
if(StringUtils.isBlank(str)){
private String trimIfNull(String str) {
if (StringUtils.isBlank(str)) {
return "";
}
return str.trim();
}
private String getDetailAddress(IdxBizJgProjectConstruction construction){
return trimIfNull(construction.getProvinceName()) + trimIfNull(construction.getCityName()) + trimIfNull(construction.getCountyName()) + trimIfNull(construction.getStreetName());
private String getDetailAddress(IdxBizJgProjectConstruction construction) {
return trimIfNull(construction.getProvinceName()) + trimIfNull(construction.getCityName()) + trimIfNull(construction.getCountyName()) + trimIfNull(construction.getStreetName() + trimIfNull(construction.getAddress()));
}
private String getDetailAddress(IdxBizJgProjectContraption projectContraption) {
return trimIfNull(projectContraption.getProvinceName()) + trimIfNull(projectContraption.getCityName()) + trimIfNull(projectContraption.getCountyName()) + trimIfNull(projectContraption.getStreetName() + trimIfNull(projectContraption.getAddress()));
}
}
\ No newline at end of file
package com.yeejoin.amos.boot.module.jyjc.biz.service.impl;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.yeejoin.amos.boot.module.jyjc.api.entity.JyjcInspectionHistory;
import com.yeejoin.amos.boot.module.jyjc.api.mapper.JyjcInspectionHistoryMapper;
import com.yeejoin.amos.boot.module.jyjc.api.model.JyjcInspectionHistoryModel;
import com.yeejoin.amos.boot.module.jyjc.api.service.IJyjcInspectionHistoryService;
import org.springframework.stereotype.Service;
import org.typroject.tyboot.core.rdbms.service.BaseService;
import java.util.Date;
/**
* 检验检测历史数据表服务实现类
*
* @author system_generator
* @date 2025-01-14
*/
@Service
public class JyjcInspectionHistoryServiceImpl extends BaseService<JyjcInspectionHistoryModel, JyjcInspectionHistory, JyjcInspectionHistoryMapper> implements IJyjcInspectionHistoryService {
public JyjcInspectionHistory getBySSeq(Long sSeq) {
return this.getOne(new LambdaQueryWrapper<JyjcInspectionHistory>().eq(JyjcInspectionHistory::getSSeq, sSeq));
}
public void saveBySeq(Long sSeq, JSONObject hisData, String sType) {
JyjcInspectionHistory history = this.getBySSeq(sSeq);
if (history != null) {
history.setHistoryData(hisData);
this.updateById(history);
} else {
history = new JyjcInspectionHistory();
history.setHistoryData(hisData);
history.setSSeq(sSeq);
history.setRecDate(new Date());
history.setSType(sType);
super.saveOrUpdate(history);
}
}
}
\ No newline at end of file
......@@ -60,4 +60,11 @@ public class JyjcInspectionResultParamServiceImpl extends BaseService<JyjcInspec
}
return paramList;
}
@Override
public JyjcInspectionResultParam getOneParamByResultSeq(Long sequenceNbr) {
LambdaQueryWrapper<JyjcInspectionResultParam> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(JyjcInspectionResultParam::getResultSeq, sequenceNbr);
return this.baseMapper.selectOne(wrapper);
}
}
\ No newline at end of file
......@@ -8,6 +8,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.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yeejoin.amos.boot.biz.common.excel.ExcelUtil;
import com.yeejoin.amos.boot.biz.common.utils.SnowflakeIdUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
......@@ -16,15 +19,18 @@ 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.jg.api.dto.DynamicColumnDto;
import com.yeejoin.amos.boot.module.jg.api.mapper.CommonMapper;
import com.yeejoin.amos.boot.module.jyjc.api.common.StringUtil;
import com.yeejoin.amos.boot.module.jyjc.api.entity.JyjcInspectionApplication;
import com.yeejoin.amos.boot.module.jyjc.api.entity.JyjcInspectionResult;
import com.yeejoin.amos.boot.module.jyjc.api.entity.JyjcInspectionResultAttachment;
import com.yeejoin.amos.boot.module.jyjc.api.entity.JyjcInspectionResultParam;
import com.yeejoin.amos.boot.module.jyjc.api.enums.BizTypeEnum;
import com.yeejoin.amos.boot.module.jyjc.api.enums.EquipCategoryEnum;
import com.yeejoin.amos.boot.module.jyjc.api.enums.ResultStatusEnum;
import com.yeejoin.amos.boot.module.jyjc.api.mapper.JyjcInspectionApplicationMapper;
import com.yeejoin.amos.boot.module.jyjc.api.mapper.JyjcInspectionResultMapper;
import com.yeejoin.amos.boot.module.jyjc.api.model.JyjcInspectionApplicationModel;
import com.yeejoin.amos.boot.module.jyjc.api.model.JyjcInspectionResultDataModel;
import com.yeejoin.amos.boot.module.jyjc.api.model.JyjcInspectionResultModel;
import com.yeejoin.amos.boot.module.jyjc.api.service.IJyjcInspectionResultAttachmentService;
......@@ -36,7 +42,8 @@ import com.yeejoin.amos.boot.module.jyjc.biz.event.UseInfoSaveToDbEvent;
import com.yeejoin.amos.boot.module.jyjc.biz.event.publisher.BizEmqPublisher;
import com.yeejoin.amos.boot.module.jyjc.biz.event.publisher.EventPublisher;
import com.yeejoin.amos.boot.module.jyjc.biz.util.JsonUtils;
import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgProjectContraption;
import com.yeejoin.amos.boot.module.ymt.api.entity.AbstractEquipBaseEntity;
import com.yeejoin.amos.boot.module.ymt.api.entity.EquipTechParamPipeline;
import com.yeejoin.amos.boot.module.ymt.api.entity.InspectionDetectionInfo;
import com.yeejoin.amos.boot.module.ymt.api.entity.TzsUserInfo;
import com.yeejoin.amos.boot.module.ymt.api.enums.EquipmentClassifityEnum;
......@@ -77,7 +84,6 @@ public class JyjcInspectionResultServiceImpl extends BaseService<JyjcInspectionR
private static final String JYJC_SUBMIT_FILE_JYBG = "JYBG";
private static final String JYJC_SUBMIT_KEY = "inspectResult";
private static final String JYJC_PIELINE = "pieLine";
private static final String JYJC_RESULT_STATUS = "2";
@Autowired
......@@ -123,10 +129,16 @@ public class JyjcInspectionResultServiceImpl extends BaseService<JyjcInspectionR
private ESEquipmentCategory esEquipmentCategory;
@Autowired
JyjcInspectionApplicationMapper inspectionApplicationMapper;
JyjcInspectionApplicationServiceImpl inspectionApplicationService;
@Autowired
private IdxBizJgProjectContraptionMapper idxBizJgProjectContraptionMapper;
private CommonMapper jgCommonMapper;
@Autowired
private ObjectMapper objectMapper;
@Autowired
private EquipTechParamPipelineMapper techParamPipelineMapper;
/**
* 检验检测单位分页查询
......@@ -284,34 +296,131 @@ public class JyjcInspectionResultServiceImpl extends BaseService<JyjcInspectionR
if (!CollectionUtils.isEmpty(paramList)) {
resultParamService.saveOrUpdateBatch(paramList);
}
JyjcInspectionResultModel dbResultModel = this.queryBySeq(model.getSequenceNbr());
// 更新使用信息、检验信息、技术参数
this.updateTechParamAndInspectInfo(dbResultModel, jybgFile);
// 更新单据信息的json(公共)
this.updateHisDataAfterResultUpdate(dbResultModel);
return dbResultModel;
}
//插入操作历史记录
InspectionDetectionInfo info = new InspectionDetectionInfo();
QueryWrapper<InspectionDetectionInfo> wrapper = new QueryWrapper<>();
wrapper.lambda().eq(InspectionDetectionInfo::getInspectReportNo, model.getResultNo());
List<InspectionDetectionInfo> list = inspectionDetectionInfoMapper.selectList(wrapper);
if (CollectionUtils.isEmpty(list)) {
extracted(model, info, jybgFile);
info.setSequenceNbr(sequence.nextId() + "");
inspectionDetectionInfoMapper.insert(info);
// 对方不查询库 所以无事务操作
bizEmqPublisher.sendInspectionMsgAfterSave(info, "insert");
private void updateTechParamAndInspectInfo(JyjcInspectionResultModel model, JyjcInspectionResultAttachment jybgFile){
if(model.getEquList().equals(EquipmentClassifityEnum.YLGD.getCode())){
// 管道逻辑: 循环更新技术参数、检验信息更新或者插入、使用信息更新(数据库及es)
JyjcInspectionResultParam param = iJyjcInspectionResultParamService.getOneParamByResultSeq(model.getSequenceNbr());
if (!ObjectUtils.isEmpty(param.getParamJson())) {
JSONObject paramObj = JSON.parseObject(param.getParamJson());
try {
List<Map<String, Object>> equips = objectMapper.readValue(
objectMapper.writeValueAsString(paramObj.get("equip")),
new TypeReference<ArrayList<Map<String, Object>>>() {
}
);
equips.forEach(e->{
String record = String.valueOf(e.get("record"));
// 1.更新管道的技术参数
EquipTechParamPipeline techParamPipeline = new EquipTechParamPipeline();
BeanUtil.copyProperties(e, techParamPipeline,true);
LambdaUpdateWrapper<EquipTechParamPipeline> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.eq(AbstractEquipBaseEntity::getRecord, record);
updateWrapper.set(EquipTechParamPipeline::getNominalDiameter, techParamPipeline.getNominalDiameter());
updateWrapper.set(EquipTechParamPipeline::getWallThickness, techParamPipeline.getWallThickness());
updateWrapper.set(EquipTechParamPipeline::getPipeLength, techParamPipeline.getPipeLength());
updateWrapper.set(EquipTechParamPipeline::getPressure, techParamPipeline.getPressure());
updateWrapper.set(EquipTechParamPipeline::getTemperature, techParamPipeline.getTemperature());
updateWrapper.set(EquipTechParamPipeline::getMedium, techParamPipeline.getMedium());
updateWrapper.set(EquipTechParamPipeline::getWorkMedium, techParamPipeline.getWorkMedium());
updateWrapper.set(EquipTechParamPipeline::getWorkPressure, techParamPipeline.getWorkPressure());
updateWrapper.set(EquipTechParamPipeline::getWorkTemperature, techParamPipeline.getWorkTemperature());
updateWrapper.set(EquipTechParamPipeline::getRemarks, techParamPipeline.getRemarks());
techParamPipelineMapper.update(null,updateWrapper);
// 2.检验信息更新或者插入
InspectionDetectionInfo info = new InspectionDetectionInfo();
LambdaQueryWrapper<InspectionDetectionInfo> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(InspectionDetectionInfo::getInspectReportNo, model.getResultNo());
wrapper.eq(InspectionDetectionInfo::getRecord, record);
wrapper.eq(InspectionDetectionInfo::getInspectOrgCode, model.getInspectionUnitCode());
List<InspectionDetectionInfo> list = inspectionDetectionInfoMapper.selectList(wrapper);
if (CollectionUtils.isEmpty(list)) {
// 无则插入
extracted(model, info, jybgFile, record);
info.setSequenceNbr(sequence.nextId() + "");
inspectionDetectionInfoMapper.insert(info);
// 对方不查询库 所以无事务操作
bizEmqPublisher.sendInspectionMsgAfterSave(info, "insert");
} else {
// 已经维护过则更新
info = list.get(0);
extracted(model, info, jybgFile, record);
inspectionDetectionInfoMapper.updateById(info);
// 对方不查询库 所以无事务操作
bizEmqPublisher.sendInspectionMsgAfterSave(info, "update");
}
// 3.更新使用信息表,最新检验信息
useInfoMapper.updateByRecord(record, model.getNextInspectionDate(), model.getInspectionType(), model.getApplicationNo());
// 4.更新es下次检验日期
this.updateEquipNextInspectDate(model, record);
});
} catch (JsonProcessingException e) {
throw new RuntimeException(e);
}
}
} else {
info = list.get(0);
extracted(model, info, jybgFile);
inspectionDetectionInfoMapper.updateById(info);
// 对方不查询库 所以无事务操作
bizEmqPublisher.sendInspectionMsgAfterSave(info, "update");
// 台套逻辑: 单条更新技术参数、检验信息更新或者插入、使用信息更新(数据库及es)
// 1.动态更新技术参数
List<DynamicColumnDto> columns = new ArrayList<>();
JyjcInspectionResultParam param = iJyjcInspectionResultParamService.getOneParamByResultSeq(model.getSequenceNbr());
if (param != null) {
if (!ObjectUtils.isEmpty(param.getParamJson())) {
JSONObject paramObj = JSON.parseObject(param.getParamJson());
paramObj.forEach((k,v)->{
DynamicColumnDto columnDto = new DynamicColumnDto();
columnDto.setColumnName(String.format("\"%s\"", StrUtil.toUnderlineCase(k).toUpperCase()));
columnDto.setColumnValue(v == null ? null : String.valueOf(v));
columns.add(columnDto);
});
String tableName = this.getTableName(param.getParamType());
jgCommonMapper.updateTechParamDynamic(tableName, model.getEquipUnicode(), columns);
}
}
// 2.检验信息更新或者插入
InspectionDetectionInfo info = new InspectionDetectionInfo();
QueryWrapper<InspectionDetectionInfo> wrapper = new QueryWrapper<>();
wrapper.lambda().eq(InspectionDetectionInfo::getInspectReportNo, model.getResultNo());
List<InspectionDetectionInfo> list = inspectionDetectionInfoMapper.selectList(wrapper);
if (CollectionUtils.isEmpty(list)) {
extracted(model, info, jybgFile, model.getEquipUnicode());
info.setSequenceNbr(sequence.nextId() + "");
inspectionDetectionInfoMapper.insert(info);
// 对方不查询库 所以无事务操作
bizEmqPublisher.sendInspectionMsgAfterSave(info, "insert");
} else {
info = list.get(0);
extracted(model, info, jybgFile, model.getEquipUnicode());
inspectionDetectionInfoMapper.updateById(info);
// 对方不查询库 所以无事务操作
bizEmqPublisher.sendInspectionMsgAfterSave(info, "update");
}
// 3.更新使用信息表最新的检验信息
useInfoMapper.updateByRecord(model.getEquipUnicode(), model.getNextInspectionDate(), model.getInspectionType(), model.getApplicationNo());
// 4.es更新下次检验日期
this.updateEquipNextInspectDate(model, model.getEquipUnicode());
}
//更新使用信息表
useInfoMapper.updateByRecord(model.getEquipUnicode(), model.getNextInspectionDate(), model.getInspectionType(), model.getApplicationNo());
this.updateEquipNextInspectDate(model);
return model;
}
private void updateEquipNextInspectDate(JyjcInspectionResultModel model) {
private String getTableName(String paramType) {
return String.format("\"%s\"", StrUtil.toUnderlineCase(paramType));
}
private void updateHisDataAfterResultUpdate(JyjcInspectionResultModel model) {
JyjcInspectionApplication application = inspectionApplicationService.getOne(new LambdaQueryWrapper<JyjcInspectionApplication>().eq(JyjcInspectionApplication::getApplicationNo, model.getApplicationNo()));
inspectionApplicationService.createHisAfterReceive(BeanUtil.copyProperties(application, JyjcInspectionApplicationModel.class));
}
private void updateEquipNextInspectDate(JyjcInspectionResultModel model, String record) {
if (model.getNextInspectionDate() != null) {
Optional<ESEquipmentCategoryDto> optional = esEquipmentCategory.findById(model.getEquipUnicode());
Optional<ESEquipmentCategoryDto> optional = esEquipmentCategory.findById(record);
if (optional.isPresent()) {
ESEquipmentCategoryDto esEquipmentCategoryDto = optional.get();
esEquipmentCategoryDto.setNEXT_INSPECT_DATE(model.getNextInspectionDate().getTime());
......@@ -320,10 +429,10 @@ public class JyjcInspectionResultServiceImpl extends BaseService<JyjcInspectionR
}
}
private void extracted(JyjcInspectionResultModel model, InspectionDetectionInfo info, JyjcInspectionResultAttachment jybgFile) {
private void extracted(JyjcInspectionResultModel model, InspectionDetectionInfo info, JyjcInspectionResultAttachment jybgFile, String record) {
info.setInspectOrgName(model.getInspectionUnitName());
info.setInspectType(model.getInspectionType());
info.setRecord(model.getEquipUnicode());
info.setRecord(record);
info.setInspectDate(model.getInspectionDate());
info.setInspectStaff(getInspectUserName(model));
info.setInspectStaffCode(model.getInspector());
......@@ -332,7 +441,7 @@ public class JyjcInspectionResultServiceImpl extends BaseService<JyjcInspectionR
// json字段暂时注释
// info.setProblemRemark(model.getNonConformance());
info.setNextInspectDate(model.getNextInspectionDate());
info.setSequenceCode(model.getEquipUnicode());
info.setSequenceCode(record);
info.setInspectOrgCode(model.getInspectionUnitCode());
info.setInspectReportNo(model.getResultNo());
info.setRecDate(new Date());
......
......@@ -126,4 +126,10 @@ public class IdxBizJgProjectContraptionDto extends BaseDto {
@ApiModelProperty("投入日期")
private String useDate;
@ApiModelProperty("工程装置父级ID(合并用)")
private String projectContraptionParentId;
@ApiModelProperty("是否首次合并新增")
private Boolean isFirstMerge;
}
......@@ -212,6 +212,7 @@
</otherwise>
</choose>
and not EXISTS (SELECt 1 FROM tz_jyjc_inspection_application a where a.status='6611' and a.application_unit_code=#{companyCode} and a.project_contraption_id = pc.sequence_nbr)
and (pc.project_contraption_parent_id is null or pc.project_contraption_parent_id = '')
</select>
<select id="selectEquipListByExport" resultType="java.util.Map">
......
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