Commit 1554dd4f authored by Lambertliu's avatar Lambertliu

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

parents 5b7ec4a0 08de6906
......@@ -47,5 +47,5 @@ public interface JgInstallationNoticeMapper extends CustomBaseMapper<JgInstallat
List<Map<String, Object>> getDeviceListByProjectContraption(@Param("projectContraptionSeq") String projectContraptionSeq);
Map<String, Object> getPipelineEquInfoByRecord(@Param("record") String record);
List<Map<String, Object>> getPipelineEquInfoByRecords(@Param("records") List<String> records);
}
......@@ -228,7 +228,7 @@
ri."EQU_TYPE" equType,
ri."EQU_CODE_TYPE" equCodeType,
ri."WHETHER_VEHICLE_CYLINDER" whetherVehicleCylinder,
pp."DEVICE_NAME" deviceName,z
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,
......@@ -293,12 +293,16 @@
</where>
</select>
<select id="getPipelineEquInfoByRecord" resultType="java.util.Map">
<select id="getPipelineEquInfoByRecords" resultType="java.util.Map">
<include refid="page-list-pipeline"/>
<where>
<if test="record != null and record != ''">
and ui."RECORD" = #{record}
<if test="records != null and !records.isEmpty()">
and ui."RECORD" in
<foreach collection="records" item="record" open="(" close=")" separator=",">
#{record}
</foreach>
</if>
</where>
</select>
......
......@@ -1018,8 +1018,8 @@
WHERE
ri."EQU_CATEGORY" = '8300'
and ui."PROJECT_CONTRAPTION_ID" = #{projectContraptionSeq}
AND ui.IS_INTO_MANAGEMENT = false
AND ri."USE_ORG_CODE" <![CDATA[<>]]> ''
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>
......
......@@ -34,4 +34,11 @@ public class DataHandlerController extends BaseController {
return ResponseHelper.buildResponse(dataHandlerService.deviceListInFormWithInstallNotice());
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET", value = "向新增的工程装置表刷入数据", notes = "向新增的工程装置表刷入数据")
@GetMapping(value = "/projectContraption/writeData")
public ResponseModel<Boolean> writeData2ProjectContraption() {
return ResponseHelper.buildResponse(dataHandlerService.writeData2ProjectContraption());
}
}
......@@ -16,6 +16,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.typroject.tyboot.component.event.RestEventTrigger;
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;
......@@ -167,7 +168,7 @@ public class JgInstallationNoticeController extends BaseController {
notes = "查询工程装置下的所有未做安装告知、不在安装告知流程、安装告知作废的设备")
@GetMapping(value = "/getDeviceListByProjectContraptionSeq")
public ResponseModel<Object> getDeviceListByProjectContraption(@RequestParam Map<String, Object> params) {
String projectContraptionSeq = String.valueOf(params.get("sequenceNbr"));
String projectContraptionSeq = ValidationUtil.isEmpty(params.get("sequenceNbr")) ? String.valueOf(params.get("record")) : params.get("sequenceNbr").toString();
return ResponseHelper.buildResponse(iJgInstallationNoticeService.getDeviceListByProjectContraption(projectContraptionSeq));
}
}
package com.yeejoin.amos.boot.module.jg.biz.service.impl;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yeejoin.amos.boot.module.jg.api.entity.JgInstallationNotice;
import com.yeejoin.amos.boot.module.jg.api.entity.JgRegistrationHistory;
import com.yeejoin.amos.boot.biz.common.utils.SnowflakeIdUtil;
import com.yeejoin.amos.boot.module.jg.api.entity.*;
import com.yeejoin.amos.boot.module.ymt.api.entity.*;
import com.yeejoin.amos.boot.module.ymt.api.enums.FlowStatusEnum;
import com.yeejoin.amos.boot.module.ymt.api.mapper.EquipmentCategoryMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ObjectUtils;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.*;
import java.util.stream.Collectors;
/**
......@@ -28,13 +30,51 @@ public class DataHandlerServiceImpl {
@Resource
private ObjectMapper objectMapper;
@Autowired
@Resource
private JgRegistrationHistoryServiceImpl registrationHistoryService;
@Autowired
@Resource
private JgInstallationNoticeServiceImpl installationNoticeService;
@Resource
private JgUseRegistrationServiceImpl useRegistrationService;
@Resource
private JgUseRegistrationEqServiceImpl useRegistrationEqService;
@Resource
private JgInstallationNoticeEqServiceImpl installationNoticeEqService;
@Resource
private IdxBizJgUseInfoServiceImpl useInfoService;
@Resource
private SnowflakeIdUtil sequence;
@Resource
private IdxBizJgProjectContraptionServiceImpl projectContraptionService;
@Resource
private IdxBizJgTechParamsPipelineServiceImpl techParamsPipelineService;
@Resource
private EquipmentCategoryMapper equipmentCategoryMapper;
@Resource
private IdxBizJgRegisterInfoServiceImpl registerInfoService;
@Resource
private IdxBizJgSupervisionInfoServiceImpl supervisionInfoService;
@Resource
private IdxBizJgFactoryInfoServiceImpl factoryInfoService;
/**
* 安装告知压力管道历史数据修复-详情中的设备列表修改为汇总表格式
*
* @return result
*/
@Transactional(rollbackFor = Exception.class)
public Boolean deviceListInFormWithInstallNotice() {
List<JgInstallationNotice> noticeList = installationNoticeService.list(new LambdaQueryWrapper<JgInstallationNotice>()
......@@ -56,13 +96,11 @@ public class DataHandlerServiceImpl {
new TypeReference<ArrayList<Map<String, Object>>>() {
}
);
deviceList.forEach(device -> {
String record = String.valueOf(device.get("record"));
Map<String, Object> pipelineEquInfo = installationNoticeService.getBaseMapper().getPipelineEquInfoByRecord(record);
device.putAll(pipelineEquInfo);
});
// 更新处理后的数据回到 history 对象
hisData.put("deviceList", deviceList);
if (!ValidationUtil.isEmpty(deviceList)) {
List<Map<String, Object>> pipelineListInfo = installationNoticeService.getBaseMapper().getPipelineEquInfoByRecords(deviceList.stream().map(device -> String.valueOf(device.get("record"))).collect(Collectors.toList()));
// 更新处理后的数据回到 history 对象
hisData.put("deviceList", pipelineListInfo);
}
history.setChangeData(objectMapper.writeValueAsString(hisData)); // 更新 changeData 字段
} catch (Exception e) {
log.error("JSON 数据处理失败!", e);
......@@ -85,4 +123,177 @@ public class DataHandlerServiceImpl {
.eq(JgRegistrationHistory::getIsDelete, false)
);
}
/**
* 向新增的工程装置表刷入数据
*
* @return result
*/
@Transactional(rollbackFor = Exception.class)
public Boolean writeData2ProjectContraption() {
projectContraptionService.getBaseMapper().delete(null);
List<IdxBizJgUseInfo> collect = useInfoService.lambdaQuery()
.select(IdxBizJgUseInfo::getRecord, IdxBizJgUseInfo::getProjectContraption, IdxBizJgUseInfo::getUseUnitCreditCode, IdxBizJgUseInfo::getUseUnitName, IdxBizJgUseInfo::getIsIntoManagement)
.isNotNull(IdxBizJgUseInfo::getProjectContraption)
.ne(IdxBizJgUseInfo::getProjectContraption, "")
.groupBy(IdxBizJgUseInfo::getProjectContraption, IdxBizJgUseInfo::getUseUnitCreditCode)
.list().stream()
.filter(Objects::nonNull)
.collect(Collectors.toList());
log.info("查询到的工程装置集合: {}", JSON.toJSONString(collect));
List<IdxBizJgProjectContraption> projectContraptionList = new ArrayList<>();
Iterator<IdxBizJgUseInfo> iterator = collect.iterator();
while (iterator.hasNext()) {
IdxBizJgUseInfo useInfo = iterator.next();
boolean isLast = !iterator.hasNext();
String record = useInfo.getRecord();
Boolean isIntoManagement = useInfo.getIsIntoManagement();
String projectContraption = useInfo.getProjectContraption();
String useUnitCreditCode = useInfo.getUseUnitCreditCode();
Long sequenceNbr = sequence.nextId();
List<String> installNotSeqs = installationNoticeEqService.lambdaQuery()
.eq(JgInstallationNoticeEq::getEquId, record)
.list().stream()
.filter(Objects::nonNull)
.map(JgInstallationNoticeEq::getEquipTransferId)
.collect(Collectors.toList());
JgInstallationNotice installationNotice = installNotSeqs.isEmpty() ? null : installationNoticeService.lambdaQuery()
.in(JgInstallationNotice::getSequenceNbr, installNotSeqs)
.eq(JgInstallationNotice::getUseUnitCreditCode, useUnitCreditCode)
.eq(JgInstallationNotice::getNoticeStatus, FlowStatusEnum.TO_BE_FINISHED.getCode())
.list().stream()
.findFirst().orElse(null);
List<String> useRegSeqs = useRegistrationEqService.lambdaQuery()
.eq(JgUseRegistrationEq::getEquId, record)
.list().stream()
.filter(Objects::nonNull)
.map(JgUseRegistrationEq::getEquipTransferId)
.collect(Collectors.toList());
JgUseRegistration useRegistration = useRegSeqs.isEmpty() ? null : useRegistrationService.lambdaQuery()
.in(JgUseRegistration::getSequenceNbr, useRegSeqs)
.eq(JgUseRegistration::getUseUnitCreditCode, useUnitCreditCode)
.eq(JgUseRegistration::getStatus, FlowStatusEnum.TO_BE_FINISHED.getName())
.list().stream()
.findFirst().orElse(null);
List<IdxBizJgUseInfo> useInfos = useInfoService.lambdaQuery()
.eq(IdxBizJgUseInfo::getProjectContraption, projectContraption)
.eq(IdxBizJgUseInfo::getUseUnitCreditCode, useUnitCreditCode)
.list();
List<IdxBizJgTechParamsPipeline> idxBizJgTechParamsPipelines = useInfos.isEmpty() ? new ArrayList<>() : techParamsPipelineService
.lambdaQuery()
.in(IdxBizJgTechParamsPipeline::getRecord, useInfos.stream()
.map(IdxBizJgUseInfo::getRecord)
.collect(Collectors.toList()))
.list();
double pipeLengthSum = idxBizJgTechParamsPipelines.stream()
.filter(Objects::nonNull)
.filter(pip -> Objects.nonNull(pip.getPipeLength()))
.mapToDouble(pipeline -> Double.parseDouble(pipeline.getPipeLength()))
.sum();
IdxBizJgRegisterInfo registerInfo = registerInfoService.lambdaQuery()
.eq(IdxBizJgRegisterInfo::getRecord, useInfos
.stream().findFirst().orElse(new IdxBizJgUseInfo())
.getRecord())
.one();
IdxBizJgSupervisionInfo supervisionInfo = supervisionInfoService.lambdaQuery()
.eq(IdxBizJgSupervisionInfo::getRecord, useInfos
.stream()
.findFirst().orElse(new IdxBizJgUseInfo())
.getRecord())
.one();
IdxBizJgFactoryInfo factoryInfo = factoryInfoService.lambdaQuery()
.eq(IdxBizJgFactoryInfo::getRecord, useInfos
.stream()
.findFirst().orElse(new IdxBizJgUseInfo())
.getRecord())
.one();
IdxBizJgProjectContraption idxBizJgProjectContraption = IdxBizJgProjectContraption.builder()
.projectContraption(projectContraption)
.projectContraptionNo(projectContraption)
.useUnitCreditCode(isIntoManagement ? (ObjectUtils.isEmpty(installationNotice) ? null : installationNotice.getUseUnitCreditCode()) : null)
.useUnitName(isIntoManagement ? (ObjectUtils.isEmpty(installationNotice) ? null : installationNotice.getUseUnitName()) : null)
.uscUnitCreditCode(isIntoManagement ? (ObjectUtils.isEmpty(useRegistration) ? (ObjectUtils.isEmpty(installationNotice) ? null : installationNotice.getInstallUnitCreditCode()) : null) : null)
.uscUnitName(isIntoManagement ? (ObjectUtils.isEmpty(useRegistration) ? (ObjectUtils.isEmpty(installationNotice) ? null : installationNotice.getInstallUnitName()) : null) : null)
.equList(ObjectUtils.isEmpty(installationNotice) ? null : installationNotice.getEquListCode())
.equListName(ObjectUtils.isEmpty(installationNotice) ? null : installationNotice.getEquList())
.equCategory(ObjectUtils.isEmpty(installationNotice) ? null : installationNotice.getEquCategoryCode())
.equCategoryName(ObjectUtils.isEmpty(ObjectUtils.isEmpty(installationNotice) ? null : installationNotice.getEquCategoryCode()) ? null : equipmentCategoryMapper.selectOne(new LambdaQueryWrapper<EquipmentCategory>().eq(EquipmentCategory::getCode, (ObjectUtils.isEmpty(installationNotice) ? null : installationNotice.getEquCategoryCode()))).getName())
.equDefine(ObjectUtils.isEmpty(registerInfo) ? null : registerInfo.getEquDefine())
.equDefineName(ObjectUtils.isEmpty(ObjectUtils.isEmpty(registerInfo) ? null : registerInfo.getEquDefine()) ? null : equipmentCategoryMapper.selectOne(new LambdaQueryWrapper<EquipmentCategory>().eq(EquipmentCategory::getCode, (ObjectUtils.isEmpty(registerInfo) ? null : registerInfo.getEquDefine()))).getName())
.content(null)
.pipelineLength(pipeLengthSum)
.productPhoto(ObjectUtils.isEmpty(registerInfo) ? null : registerInfo.getProductPhoto())
.otherAccessories(null)
.orgCode(ObjectUtils.isEmpty(supervisionInfo) ? null : supervisionInfo.getOrgBranchCode())
.orgName(ObjectUtils.isEmpty(supervisionInfo) ? null : supervisionInfo.getOrgBranchName())
.productQualificationCertificate(ObjectUtils.isEmpty(factoryInfo) ? null : factoryInfo.getProductQualityYieldProve())
.province(ObjectUtils.isEmpty(installationNotice) ? null : installationNotice.getProvince())
.provinceName(ObjectUtils.isEmpty(installationNotice) ? null : installationNotice.getProvinceName())
.city(ObjectUtils.isEmpty(installationNotice) ? null : installationNotice.getCity())
.cityName(ObjectUtils.isEmpty(installationNotice) ? null : installationNotice.getCityName())
.county(ObjectUtils.isEmpty(installationNotice) ? null : installationNotice.getCounty())
.countyName(ObjectUtils.isEmpty(installationNotice) ? null : installationNotice.getCountyName())
.street(ObjectUtils.isEmpty(installationNotice) ? null : installationNotice.getStreet())
.streetName(ObjectUtils.isEmpty(installationNotice) ? null : installationNotice.getStreetName())
.address(ObjectUtils.isEmpty(installationNotice) ? null : installationNotice.getAddress())
.startLatitudeLongitude(ObjectUtils.isEmpty(idxBizJgTechParamsPipelines) ? null : idxBizJgTechParamsPipelines.get(0).getStartePosition())
.endLatitudeLongitude(ObjectUtils.isEmpty(idxBizJgTechParamsPipelines) ? null : idxBizJgTechParamsPipelines.get(0).getEndPosition())
.supervisoryCode(ObjectUtils.isEmpty(installationNotice) ? null : installationNotice.getSupervisoryCode())
.useRegistrationCode(ObjectUtils.isEmpty(useRegistration) ? null : useRegistration.getUseRegistrationCode())
.isIntoManagement(isIntoManagement)
.dataSource("jg")
.build();
idxBizJgProjectContraption.setSequenceNbr(sequenceNbr);
idxBizJgProjectContraption.setRecDate(new Date());
idxBizJgProjectContraption.setIsDelete(Boolean.FALSE);
projectContraptionList.add(idxBizJgProjectContraption);
if (projectContraptionList.size() % 1000 == 0 || isLast) {
projectContraptionService.saveBatch(projectContraptionList);
projectContraptionList.clear();
}
useInfoService.lambdaUpdate()
.set(IdxBizJgUseInfo::getProjectContraptionId, sequenceNbr)
.eq(IdxBizJgUseInfo::getProjectContraption, projectContraption)
.eq(IdxBizJgUseInfo::getUseUnitCreditCode, useUnitCreditCode)
.update();
if (!installNotSeqs.isEmpty()) {
installationNoticeService.lambdaUpdate()
.set(JgInstallationNotice::getProjectContraptionId, sequenceNbr)
.in(JgInstallationNotice::getSequenceNbr, installNotSeqs)
.eq(JgInstallationNotice::getProjectContraption, projectContraption)
.eq(JgInstallationNotice::getUseUnitCreditCode, useUnitCreditCode)
.update();
}
if (!useRegSeqs.isEmpty()) {
useRegistrationService.lambdaUpdate()
.set(JgUseRegistration::getProjectContraptionId, sequenceNbr)
.in(JgUseRegistration::getSequenceNbr, useRegSeqs)
.eq(JgUseRegistration::getProjectContraption, projectContraption)
.eq(JgUseRegistration::getUseUnitCreditCode, useUnitCreditCode)
.update();
}
}
return Boolean.TRUE;
}
}
......@@ -19,6 +19,7 @@ import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ObjectUtils;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.rdbms.service.BaseService;
import javax.annotation.Resource;
import java.util.*;
import java.util.stream.Collectors;
......@@ -110,7 +111,7 @@ public class IdxBizJgProjectContraptionServiceImpl extends BaseService<IdxBizJgP
.eq(!ValidationUtil.isEmpty(params.get(IS_INTO_MANAGEMENT)), IdxBizJgProjectContraption::getIsIntoManagement, isIntoManagement)
.eq(!ValidationUtil.isEmpty(useRegistrationCode), IdxBizJgProjectContraption::getUseRegistrationCode, useRegistrationCode)
.eq(!ValidationUtil.isEmpty(equCategory), IdxBizJgProjectContraption::getEquCategory, equCategory)
.eq(!ValidationUtil.isEmpty(equDefine), IdxBizJgProjectContraption::getEquCategory, equDefine)
.eq(!ValidationUtil.isEmpty(equDefine), IdxBizJgProjectContraption::getEquDefine, equDefine)
.like(!ValidationUtil.isEmpty(projectContraption), IdxBizJgProjectContraption::getProjectContraption, projectContraption)
.like(!ValidationUtil.isEmpty(projectContraptionNo), IdxBizJgProjectContraption::getProjectContraptionNo, projectContraptionNo)
.isNull(!ValidationUtil.isEmpty(regCodeIsNull) && Boolean.TRUE.equals(Boolean.valueOf(regCodeIsNull)), IdxBizJgProjectContraption::getUseRegistrationCode)
......
......@@ -10,6 +10,7 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.github.pagehelper.util.StringUtil;
import com.google.common.collect.Lists;
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.dao.mapper.DataDictionaryMapper;
......@@ -26,6 +27,7 @@ import com.yeejoin.amos.boot.module.jg.api.dto.*;
import com.yeejoin.amos.boot.module.jg.api.entity.*;
import com.yeejoin.amos.boot.module.jg.api.enums.BusinessTypeEnum;
import com.yeejoin.amos.boot.module.jg.api.enums.CompanyTypeEnum;
import com.yeejoin.amos.boot.module.jg.api.enums.PipelineEnum;
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;
......@@ -171,7 +173,8 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN
private JgRegistrationHistoryMapper jgRegistrationHistoryMapper;
@Autowired
private IdxBizJgFactoryInfoServiceImpl idxBizJgFactoryInfoService;
@Autowired
private IdxBizJgProjectContraptionServiceImpl projectContraptionService;
@Autowired
private ObjectMapper objectMapper;
......@@ -322,12 +325,21 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN
private Map<String, Object> setNewEquipData(String companyLevel, Map<String, Object> installationInfo) {
List<Map<String, Object>> equipListMaps = Lists.newArrayList();
String equCategory = (String) installationInfo.get("equCategoryCode");
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);
if (!ValidationUtil.isEmpty(jgInstallationNoticeEqs)) {
List<String> ids = jgInstallationNoticeEqs.stream().map(item -> item.getEquId()).collect(Collectors.toList());
// 压力管道从工程装置表查询设备信息
if (PipelineEnum.INDUSTRIAL_PIPELINE.getCode().equals(equCategory)) {
equipListMaps = jgInstallationNoticeMapper.getPipelineEquInfoByRecords(ids);
} else {
Iterable<ESEquipmentCategoryDto> equips = esEquipmentCategory.findAllById(ids);
equipListMaps = getEquipListMaps(equips);
}
}
// Map<String, Object> detail = equipmentInfos.get(0);
// Map<String, Object> equInfo = idxBizJgRegisterInfoService.getDetailFieldCamelCaseByRecord(detail.get("equId").toString());
......@@ -1712,8 +1724,16 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN
*/
@Override
public Object getDeviceListByProjectContraption(String projectContraptionSeq) {
IdxBizJgProjectContraption projectContraption = projectContraptionService.getById(projectContraptionSeq);
if (ValidationUtil.isEmpty(projectContraption)) {
return null;
}
List<Map<String, Object>> deviceList = this.baseMapper.getDeviceListByProjectContraption(projectContraptionSeq);
return new JSONObject().fluentPut("deviceList", deviceList);
return new JSONObject().fluentPut("deviceList", deviceList)
.fluentPut("projectContraption", projectContraption.getProjectContraption())
.fluentPut("projectContraptionNo", projectContraption.getProjectContraptionNo())
.fluentPut("pipelineLength", projectContraption.getPipelineLength())
.fluentPut("projectContraptionId", projectContraptionSeq);
}
@Override
......
......@@ -6,7 +6,6 @@ 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.annotation.TableField;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
......@@ -14,12 +13,13 @@ import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.additional.query.impl.LambdaQueryChainWrapper;
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.dao.mapper.DataDictionaryMapper;
import com.yeejoin.amos.boot.biz.common.entity.BaseEntity;
import com.yeejoin.amos.boot.biz.common.entity.DataDictionary;
import com.yeejoin.amos.boot.biz.common.entity.TzsBaseEntity;
import com.yeejoin.amos.boot.biz.common.service.IDataDictionaryService;
import com.yeejoin.amos.boot.biz.common.service.impl.DataDictionaryServiceImpl;
import com.yeejoin.amos.boot.biz.common.utils.RedisKey;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
......@@ -220,8 +220,10 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
@Autowired
IdxBizJgProjectInspectionMapper projectInspectionMapper;
@Autowired
private DataDictionaryServiceImpl dataDictionaryServiceImpl;
@Autowired
private IdxBizJgProjectContraptionMapper idxBizJgProjectContraptionMapper;
/**
......@@ -360,7 +362,7 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
// 更新使用信息
useInfoMapper.update(useInfo, lambda);
// 更新检验检测信息
this.updateOrCreateInspectionDetection(map);
this.updateOrCreateInspectionDetection(map, jgUseRegistration, registerInfo);
// 更新注册登记信息表
LambdaUpdateWrapper<IdxBizJgRegisterInfo> IdxBizJgRegLambda = new UpdateWrapper<IdxBizJgRegisterInfo>().lambda();
IdxBizJgRegLambda.eq(IdxBizJgRegisterInfo::getRecord, map.get("equipId"))
......@@ -387,21 +389,50 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
createCode(map, jgUseRegistration, registerInfo, useInfo, otherInfo);
}
private void updateOrCreateInspectionDetection(JSONObject map) {
private void updateOrCreateInspectionDetection(JSONObject map, JgUseRegistration jgUseRegistration, IdxBizJgRegisterInfo registerInfo) {
InspectionDetectionInfo inspectionDetectionInfo = new InspectionDetectionInfo();
BeanUtil.copyProperties(map, inspectionDetectionInfo);
if (map.get("jySeq") != null) {
// 更新逻辑
InspectionDetectionInfo inspectionDetectionInfoDb = inspectionDetectionInfoMapper.selectById(map.get("jySeq").toString());
Bean.copyExistPropertis(inspectionDetectionInfo, inspectionDetectionInfoDb);
inspectionDetectionInfoMapper.updateById(inspectionDetectionInfo);
String record = map.get("equipId").toString();
if("unit".equals(jgUseRegistration.getManageType()) && registerInfo.getEquList().equals(EquipmentClassifityEnum.YLGD.getCode())){
// 压力管道逻辑,根据设备record + 检验报告编号判定唯一一条检验流水,有进行更新,无则进行插入
saveEquipOfPieLineInspectData(record, inspectionDetectionInfo);
} else {
// 插入逻辑
if (inspectionDetectionInfo.getInspectType() != null && inspectionDetectionInfo.getInspectConclusion() != null) {
inspectionDetectionInfo.setRecord(map.get("equipId").toString());
inspectionDetectionInfo.setRecDate(new Date());
inspectionDetectionInfo.setSequenceNbr(sequence.nextId() + "");
inspectionDetectionInfoMapper.insert(inspectionDetectionInfo);
// 其他逻辑
if (map.get("jySeq") != null) {
// 更新逻辑
InspectionDetectionInfo inspectionDetectionInfoDb = inspectionDetectionInfoMapper.selectById(map.get("jySeq").toString());
Bean.copyExistPropertis(inspectionDetectionInfo, inspectionDetectionInfoDb);
inspectionDetectionInfoMapper.updateById(inspectionDetectionInfo);
} else {
// 插入逻辑
if (inspectionDetectionInfo.getInspectType() != null && inspectionDetectionInfo.getInspectConclusion() != null) {
inspectionDetectionInfo.setRecord(record);
inspectionDetectionInfo.setRecDate(new Date());
inspectionDetectionInfo.setSequenceNbr(sequence.nextId() + "");
inspectionDetectionInfoMapper.insert(inspectionDetectionInfo);
}
}
}
}
private void saveEquipOfPieLineInspectData(String record, InspectionDetectionInfo inspectionDetectionInfo) {
// 检验机构 + 设备+ 检验报告编号时 , 是唯一的为了防止老数据有重复的,程序健壮,故使用list进行处理
LambdaQueryWrapper<InspectionDetectionInfo> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(AbstractEquipBaseEntity::getRecord, record)
.eq(!StringUtils.isEmpty(inspectionDetectionInfo.getInspectReportNo()), InspectionDetectionInfo::getInspectReportNo, inspectionDetectionInfo.getInspectReportNo())
.eq(InspectionDetectionInfo::getInspectOrgCode, inspectionDetectionInfo.getInspectOrgCode());
List<InspectionDetectionInfo> inspectionDetectionInfos = inspectionDetectionInfoMapper.selectList(wrapper);
if(inspectionDetectionInfos.isEmpty()){
inspectionDetectionInfo.setRecord(record);
inspectionDetectionInfo.setRecDate(new Date());
inspectionDetectionInfo.setSequenceNbr(sequence.nextId() + "");
inspectionDetectionInfoMapper.insert(inspectionDetectionInfo);
} else {
for (InspectionDetectionInfo inspectionDetectionInfo1 : inspectionDetectionInfos) {
Bean.copyExistPropertis(inspectionDetectionInfo, inspectionDetectionInfo1);
inspectionDetectionInfo1.setRecDate(new Date());
inspectionDetectionInfoMapper.updateById(inspectionDetectionInfo1);
}
}
}
......@@ -984,6 +1015,7 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
}
}
List<Map<String, Object>> equipmentLists = (List<Map<String, Object>>) mapData.get("equipmentLists");
String inspectConclusionName = getInspectConclusionName(mapData);
if (!CollectionUtils.isEmpty(equipmentLists)) {
for (int i = 0; i < equipmentLists.size(); i++) {
Map<String, Object> equipment = equipmentLists.get(i);
......@@ -996,6 +1028,10 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
lambdaReg.eq(IdxBizJgRegisterInfo::getRecord, equId);
IdxBizJgRegisterInfo registerInfo = idxBizJgRegisterInfoMapper.selectOne(lambdaReg);
// 压力管道:[更新的原始引用]更新检验日期-nextInspectDate、检验结论-inspectConclusion、检验机构名称-inspectOrgName
equipment.put("nextInspectDate", mapData.getOrDefault("nextInspectDate", ""));
equipment.put("inspectOrgName", mapData.getOrDefault("inspectOrgName", ""));
equipment.put("inspectConclusion", inspectConclusionName);
// 更新设备信息 && 生成使用登记证编号 && 同步es
processMapData(sequenceNbr, mapData, jgUseRegistration, jgRegistrationHistory, registerInfo, taskV2Model, jsonObject, flag, useRegistrationCode);
// 查询设备制造信息
......@@ -1011,22 +1047,67 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
certificateChangeRecordEqService.save(changeRecordEq);
}
}
// 取第一条设备的注册消息--用来获取这一批设备的设备种类/类别/品种
LambdaQueryWrapper<IdxBizJgRegisterInfo> lambdaReg = new QueryWrapper<IdxBizJgRegisterInfo>().lambda();
lambdaReg.eq(IdxBizJgRegisterInfo::getRecord, String.valueOf(mapData.get("equipId")));
IdxBizJgRegisterInfo registerInfo = idxBizJgRegisterInfoMapper.selectOne(lambdaReg);
// 单位办理的压力管道,在完成审批时,将检验信息写入到装置检验信息表
savePieLineProjectInspectData(jgUseRegistration, registerInfo, mapData);
// 生成证书管理表
generateRegistrationManage(jgUseRegistration, registerInfo, flag, useRegistrationManageSeq);
// 生成一条tzs_jg_certificate_change_record记录
generateCertificateChangeRecord(jgUseRegistration, registerInfo, changeRecordId, taskV2Model, flag);
// 更新历史表:下次检验日期、检验机构名称、检验结论在压力管道、气瓶时更新子表单的数据
jgRegistrationHistory.setChangeData(JSON.toJSONString(mapData));
jgRegistrationHistoryService.updateById(jgRegistrationHistory);
// 装置表写入使用登记证编号、将装置名称写入到使用登记表
updateRegAndProjectContrapt(jgUseRegistration);
}
this.getBaseMapper().updateById(jgUseRegistration);
commonServiceImpl.saveExecuteFlowData2Redis(jgUseRegistration.getInstanceId(), this.buildInstanceRuntimeData(jgUseRegistration));
}
private void updateRegAndProjectContrapt(JgUseRegistration jgUseRegistration) {
if(!StringUtils.isEmpty(jgUseRegistration.getProjectContraptionId())){
IdxBizJgProjectContraption jgProjectContraption = jgProjectContraptionService.getById(jgUseRegistration.getProjectContraptionId());
jgUseRegistration.setProjectContraption(jgProjectContraption.getProjectContraption());
jgProjectContraption.setUseRegistrationCode(jgUseRegistration.getUseRegistrationCode());
jgProjectContraptionService.updateById(jgProjectContraption);
}
}
private String getInspectConclusionName(JSONObject mapData) {
if( !ObjectUtils.isEmpty(mapData.get("inspectConclusion"))) {
String code = mapData.get("inspectConclusion").toString();
DataDictionary conclusionDict = dataDictionaryServiceImpl.getByCode( code,"JYJL");
if(conclusionDict != null) {
return conclusionDict.getName();
}
}
return "";
}
private void savePieLineProjectInspectData(JgUseRegistration jgUseRegistration, IdxBizJgRegisterInfo registerInfo, JSONObject mapData) {
// 单位办理的压力管道,在完成审批时,将检验信息写入到装置检验信息表
if("unit".equals(jgUseRegistration.getManageType()) && registerInfo.getEquList().equals(EquipmentClassifityEnum.YLGD.getCode())){
IdxBizJgProjectInspection inspectionDetectionInfo = new IdxBizJgProjectInspection();
BeanUtil.copyProperties(mapData, inspectionDetectionInfo);
if (mapData.get("jySeq") != null) {
// 更新逻辑
IdxBizJgProjectInspection inspectionDetectionInfoDb = projectInspectionMapper.selectById(mapData.get("jySeq").toString());
Bean.copyExistPropertis(inspectionDetectionInfo, inspectionDetectionInfoDb);
projectInspectionMapper.updateById(inspectionDetectionInfo);
} else {
inspectionDetectionInfo.setProjectContraptionId(jgUseRegistration.getProjectContraptionId());
inspectionDetectionInfo.setRecDate(new Date());
// 使用登记创建新增的检验信息id设置为使用登记的主键id,在作废时级联作废
inspectionDetectionInfo.setSequenceNbr(jgUseRegistration.getSequenceNbr() + "");
projectInspectionMapper.insert(inspectionDetectionInfo);
}
}
}
/**
* 生成使用登记证变更记录
*
......@@ -2311,7 +2392,7 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
// 安全管理部门
exportParamsMap.put("orgBranchName", String.valueOf(jsonObject.get("orgBranchCode")).split("_")[1]);
// 安全管理员
exportParamsMap.put("safetyManager", String.valueOf(jsonObject.get("safetyManager")).split("_")[1]);
exportParamsMap.put("safetyManager", String.valueOf(jsonObject.get("safetyManager")).contains("_") ? String.valueOf(jsonObject.get("safetyManager")).split("_")[1] : String.valueOf(jsonObject.get("safetyManager")));
// 联系电话
exportParamsMap.put("phone", ValidationUtil.isEmpty(result.getMobile()) ? "" : result.getMobile());
// 经办人
......@@ -2370,7 +2451,7 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
String[] fieldNames = {"productName", "pipelineNumber", "deviceLevel", "designUnitName", "uscUnitName",
"uscDate", "useDate", "nominalDiameter", "wallThickness", "pipeLength", "pressure", "temperature",
"medium", "inspectConclusion", "inspectOrgName", "nextInspectDate", "inspectConclusion", "remarks"};
"medium", "inspectConclusion", "inspectOrgName", "nextInspectDate", "remarks"};
// 填充有效数据
for (int curr = 0; curr < equData.size(); curr++) {
JSONObject obj = (JSONObject) equData.get(curr);
......@@ -2609,6 +2690,8 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
private void clearUseInfoOfEquip(JgUseRegistration jgUseRegistration) {
List<JgUseRegistrationEq> eqList = getJgUseRegistrationEqs(jgUseRegistration);
// 0.压力管道 清空装置表的使用登记证编号、删除装置的检验信息
this.rollBackForPieLine(jgUseRegistration);
eqList.forEach(e -> {
String record = e.getEquId();
Boolean flag = Boolean.FALSE;
......@@ -2642,6 +2725,18 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
}
}
private void rollBackForPieLine(JgUseRegistration jgUseRegistration) {
if(!StringUtils.isEmpty(jgUseRegistration.getProjectContraptionId())){
// 清除使用登记证编号
LambdaUpdateWrapper<IdxBizJgProjectContraption> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.eq(BaseEntity::getSequenceNbr, jgUseRegistration.getProjectContraptionId());
updateWrapper.set(IdxBizJgProjectContraption::getUseRegistrationCode, null);
idxBizJgProjectContraptionMapper.update(null, updateWrapper);
// 删除改装置的检验信息【只有是在使用登记页面新增的才会删除,使用登记终审通过时,插入的检验信息id为使用登记的主键】
projectInspectionMapper.deleteById(jgUseRegistration.getSequenceNbr());
}
}
private void dealHisRegEquipData(JgUseRegistration jgUseRegistration, String record) {
// 历史登记时处理
if("1".equals(jgUseRegistration.getRegType())){
......@@ -3608,25 +3703,31 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
}
public IPage<IdxBizJgProjectContraption> getJgProjectContraptionPage(String useUnitCreditCode, Page<IdxBizJgProjectContraption> page) {
// 兼容个人业务
if(useUnitCreditCode.contains("_")){
useUnitCreditCode = useUnitCreditCode.split("_")[1];
}
// 查询流程中的装置
List<JgUseRegistration> flowIngPros = this.list(new LambdaQueryWrapper<JgUseRegistration>().notIn(JgUseRegistration::getStatus, NOT_FLOWING_STATE).select(BaseEntity::getSequenceNbr, JgUseRegistration::getProjectContraptionId));
Set<String> proIds = flowIngPros.stream().map(JgUseRegistration::getProjectContraptionId).collect(toSet());
proIds.remove(null);
proIds.remove("");
// 查询已纳管且使用登记证编号为空或者null且非流程中的装置
// 查询已纳管且使用登记证编号为空或者null且非流程中的装置
LambdaQueryWrapper<IdxBizJgProjectContraption> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(IdxBizJgProjectContraption::getUseUnitCreditCode,useUnitCreditCode);
wrapper.eq(IdxBizJgProjectContraption::getIsIntoManagement, true);
wrapper.notIn(!proIds.isEmpty(), BaseEntity::getSequenceNbr, proIds);
wrapper.last("and use_registration_code <> ''");
wrapper.last("and (length(use_registration_code) = 0 or use_registration_code is null)");
return jgProjectContraptionService.page(page, wrapper);
}
public Map<String, Object> getDeviceListByProjectContraption(String projectContraptionSeq) {
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","111111111");
re.put("equipmentLists", equList);
re.put("projectContraption", projectContraption.getProjectContraption());
re.put("projectContraptionId", projectContraptionSeq);
this.setPieLineInspectInfo(projectContraptionSeq, re);
this.setConstructionInfo(projectContraptionSeq, re);
return re;
......@@ -3641,12 +3742,14 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
re.put("installLeaderPhone",construction.getConstructionLeaderPhone());
re.put("installStartDate", construction.getUscDate());
re.put("installPropertyUnitName", construction.getConstructionLeaderName());
re.put("installProxyStatementAttachment", JSON.parseObject(construction.getProxyStatementAttachment()));
re.put("installContractAttachment", JSON.parseObject(construction.getConstructionContractAttachment()));
re.put("insOtherAccessories", JSON.parseObject(construction.getConstructionOtherAccessories()));
re.put("installProxyStatementAttachment", JSON.parse(construction.getProxyStatementAttachment()));
re.put("installContractAttachment", JSON.parse(construction.getConstructionContractAttachment()));
re.put("insOtherAccessories", JSON.parse(construction.getConstructionOtherAccessories()));
re.put("installStreet", construction.getStreetName());
re.put("installProvince", construction.getProvinceName());
re.put("installAddress", construction.getAddress());
re.put("installCity", construction.getCityName());
re.put("installIsXixian", construction.getIsXixian());
re.put("installCounty", construction.getCountyName());
re.put("uscUnitCreditCode", construction.getUscUnitCreditCode());
re.put("uscUnitName", construction.getUscUnitName());
......@@ -3666,7 +3769,7 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
re.put("inspectDate", inspection.getInspectDate());
re.put("inspectStaff", inspection.getInspectStaff());
re.put("nextInspectDate", inspection.getNextInspectDate());
re.put("inspectReport", JSON.parseObject(inspection.getInspectReport()));
re.put("inspectReport", JSON.parse(inspection.getInspectReport()));
re.put("inspectReportNo",inspection.getInspectReportNo());
// 返回代表是系统的数据,前端控制系统的检验信息不让编辑
re.put("jySeq",inspection.getSequenceNbr());
......
......@@ -12,7 +12,6 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.boot.biz.common.entity.DataDictionary;
import com.yeejoin.amos.boot.biz.common.excel.ExcelUtil;
import com.yeejoin.amos.boot.biz.common.service.impl.DataDictionaryServiceImpl;
import com.yeejoin.amos.boot.biz.common.utils.DateUtils;
import com.yeejoin.amos.boot.biz.common.utils.RedisKey;
......@@ -53,18 +52,14 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ObjectUtils;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.exception.BaseException;
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.exception.instance.TooManyRequests;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import java.text.ParseException;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.function.Predicate;
import java.util.stream.Collectors;
/**
......@@ -134,7 +129,7 @@ public class TzBaseEnterpriseInfoServiceImpl
// 使用单位资质
COMPANY_TYPE_CERT_TYPE_MAP.put("使用单位", "1232");
// 检验检测机构资质:细分为1233-1、1233-2
COMPANY_TYPE_CERT_TYPE_MAP.put("检验检测机构", "1233");
COMPANY_TYPE_CERT_TYPE_MAP.put("检验检测机构", "1233-1,1233-2");
// 安装改造维修单位身份资质:充装单位-1231 制造单位-1236 设计单位-1235 安装改造维修单位-1234
COMPANY_TYPE_CERT_TYPE_MAP.put("安装改造维修单位", "1231,1234,1235,1236");
}
......
......@@ -100,4 +100,6 @@ public class IdxBizJgProjectConstructionDto extends BaseDto {
@ApiModelProperty(value = "使用地点_街道")
private String streetName;
@ApiModelProperty(value = "是否西咸:0-否;1-是")
private String isXixian;
}
......@@ -169,4 +169,9 @@ public class IdxBizJgProjectConstruction extends TzsBaseEntity {
@TableField("\"STREET_NAME\"")
private String streetName;
/**
* 是否西咸:0-否;1-是
*/
@TableField("\"IS_XIXIAN\"")
private String isXixian;
}
......@@ -3,8 +3,7 @@ package com.yeejoin.amos.boot.module.ymt.api.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.yeejoin.amos.boot.biz.common.entity.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.*;
import lombok.experimental.Accessors;
/**
......@@ -16,6 +15,9 @@ import lombok.experimental.Accessors;
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@AllArgsConstructor
@NoArgsConstructor
@Builder
@TableName("idx_biz_jg_project_contraption")
public class IdxBizJgProjectContraption extends BaseEntity {
......
package com.yeejoin.amos.boot.module.ymt.api.mapper;
import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgProjectContraption;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgProjectContraption;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import 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