Commit dd3515bf authored by 韩桐桐's avatar 韩桐桐

feat(jg):用于业务变更过程中历史数据处理的控制层提交

parent b9adc76b
......@@ -85,7 +85,5 @@ public interface IJgInstallationNoticeService extends IService<JgInstallationNot
*/
JgInstallationNotice cancelApplication(Long sequenceNbr, String cancelReason);
Boolean historyDataRepair();
Object getDeviceListByProjectContraption(String projectContraptionSeq);
}
package com.yeejoin.amos.boot.module.jg.biz.controller;
import com.yeejoin.amos.boot.biz.common.controller.BaseController;
import com.yeejoin.amos.boot.module.jg.biz.service.impl.DataHandlerServiceImpl;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.utils.ResponseHelper;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import javax.annotation.Resource;
/**
* 用于业务变更过程中历史数据处理的控制层
*/
@Api(tags = "用于业务变更过程中历史数据处理的控制层")
@RestController
@RequestMapping(value = "/dataHandler")
public class DataHandlerController extends BaseController {
@Resource
private DataHandlerServiceImpl dataHandlerService;
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET", value = "安装告知压力管道历史数据修复-详情中的设备列表修改为汇总表格式", notes = "安装告知压力管道历史数据修复-详情中的设备列表修改为汇总表格式")
@GetMapping(value = "/installNotice/deviceListInForm")
public ResponseModel<Boolean> deviceListInFormWithInstallNotice() {
return ResponseHelper.buildResponse(dataHandlerService.deviceListInFormWithInstallNotice());
}
}
......@@ -162,19 +162,12 @@ public class JgInstallationNoticeController extends BaseController {
return ResponseHelper.buildResponse(result);
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET", value = "安装告知历史数据修复", notes = "安装告知历史数据修复")
@GetMapping(value = "/historyDataRepair")
public ResponseModel<Boolean> historyDataRepair() {
return ResponseHelper.buildResponse(iJgInstallationNoticeService.historyDataRepair());
}
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET", value = "查询工程装置下的所有未做安装告知、不在安装告知流程、安装告知作废的设备",
notes = "查询工程装置下的所有未做安装告知、不在安装告知流程、安装告知作废的设备")
@GetMapping(value = "/getDeviceListByProjectContraptionSeq")
public ResponseModel<Object> getDeviceListByProjectContraption(@RequestParam("projectContraptionSeq") String projectContraptionSeq) {
public ResponseModel<Object> getDeviceListByProjectContraption(@RequestParam Map<String, Object> params) {
String projectContraptionSeq = String.valueOf(params.get("sequenceNbr"));
return ResponseHelper.buildResponse(iJgInstallationNoticeService.getDeviceListByProjectContraption(projectContraptionSeq));
}
}
package com.yeejoin.amos.boot.module.jg.biz.service.impl;
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 lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
/**
* 用于业务变更过程中的历史数据处理的service层
*/
@Slf4j
@Service
public class DataHandlerServiceImpl {
@Resource
private ObjectMapper objectMapper;
@Autowired
private JgRegistrationHistoryServiceImpl registrationHistoryService;
@Autowired
private JgInstallationNoticeServiceImpl installationNoticeService;
@Transactional(rollbackFor = Exception.class)
public Boolean deviceListInFormWithInstallNotice() {
List<JgInstallationNotice> noticeList = installationNoticeService.list(new LambdaQueryWrapper<JgInstallationNotice>()
.eq(JgInstallationNotice::getEquCategoryCode, "8300"));
List<JgRegistrationHistory> jgRegistrationHistories = noticeList.stream()
.map(notice -> {
JgRegistrationHistory history = getRegistrationHistory(String.valueOf(notice.getSequenceNbr()));
if (history == null) return null;
try {
Map<String, Object> hisData = objectMapper.readValue(
history.getChangeData(),
new TypeReference<Map<String, Object>>() {
}
);
// 获取设备列表并处理每个设备信息
List<Map<String, Object>> deviceList = objectMapper.readValue(
objectMapper.writeValueAsString(hisData.get("deviceList")),
new TypeReference<ArrayList<Map<String, Object>>>() {
}
);
deviceList.forEach(device -> {
String record = String.valueOf(device.get("record"));
Map<String, Object> pipelineEquInfo = installationNoticeService.getBaseMapper().getPipelineEquInfoByRecord(record);
device.putAll(pipelineEquInfo);
});
// 更新处理后的数据回到 history 对象
hisData.put("deviceList", deviceList);
history.setChangeData(objectMapper.writeValueAsString(hisData)); // 更新 changeData 字段
} catch (Exception e) {
log.error("JSON 数据处理失败!", e);
throw new RuntimeException(e.getMessage());
}
return history;
})
.filter(Objects::nonNull)
.collect(Collectors.toList());
// 批量更新历史表数据
registrationHistoryService.updateBatchById(jgRegistrationHistories);
return Boolean.TRUE;
}
// 辅助方法:根据 DocumentId 获取历史记录
private JgRegistrationHistory getRegistrationHistory(String documentId) {
return registrationHistoryService.getBaseMapper().selectOne(
new QueryWrapper<JgRegistrationHistory>().lambda()
.eq(JgRegistrationHistory::getCurrentDocumentId, documentId)
.eq(JgRegistrationHistory::getIsDelete, false)
);
}
}
......@@ -8,7 +8,6 @@ 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.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.github.pagehelper.util.StringUtil;
import com.yeejoin.amos.boot.biz.common.bo.CompanyBo;
......@@ -174,9 +173,6 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN
private IdxBizJgFactoryInfoServiceImpl idxBizJgFactoryInfoService;
@Autowired
private JgRegistrationHistoryServiceImpl jgRegistrationHistoryService;
@Autowired
private ObjectMapper objectMapper;
@Autowired
......@@ -1708,59 +1704,6 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN
}
@Override
@Transactional(rollbackFor = Exception.class)
public Boolean historyDataRepair() {
List<JgInstallationNotice> noticeList = this.getBaseMapper().selectList(new LambdaQueryWrapper<JgInstallationNotice>()
.eq(JgInstallationNotice::getEquCategoryCode, "8300"));
List<JgRegistrationHistory> jgRegistrationHistories = noticeList.stream()
.map(notice -> {
JgRegistrationHistory history = getRegistrationHistory(String.valueOf(notice.getSequenceNbr()));
if (history == null) return null;
try {
Map<String, Object> hisData = objectMapper.readValue(
history.getChangeData(),
new TypeReference<Map<String, Object>>() {
}
);
// 获取设备列表并处理每个设备信息
List<Map<String, Object>> deviceList = objectMapper.readValue(
objectMapper.writeValueAsString(hisData.get("deviceList")),
new TypeReference<ArrayList<Map<String, Object>>>() {
}
);
deviceList.forEach(device -> {
String record = String.valueOf(device.get("record"));
Map<String, Object> pipelineEquInfo = this.baseMapper.getPipelineEquInfoByRecord(record);
device.putAll(pipelineEquInfo);
});
// 更新处理后的数据回到 history 对象
hisData.put("deviceList", deviceList);
history.setChangeData(objectMapper.writeValueAsString(hisData)); // 更新 changeData 字段
} catch (Exception e) {
log.error("JSON 数据处理失败!", e);
throw new RuntimeException(e.getMessage());
}
return history;
})
.filter(Objects::nonNull)
.collect(Collectors.toList());
// 批量更新历史表数据
jgRegistrationHistoryService.updateBatchById(jgRegistrationHistories);
return Boolean.TRUE;
}
// 辅助方法:根据 DocumentId 获取历史记录
private JgRegistrationHistory getRegistrationHistory(String documentId) {
return jgRegistrationHistoryService.getBaseMapper().selectOne(
new QueryWrapper<JgRegistrationHistory>().lambda()
.eq(JgRegistrationHistory::getCurrentDocumentId, documentId)
.eq(JgRegistrationHistory::getIsDelete, false)
);
}
/**
* 查询工程装置下的所有未做安装告知、不在安装告知流程、安装告知作废的设备
*
......
......@@ -21,8 +21,6 @@ public class IdxBizJgProjectConstructionDto extends BaseDto {
private static final long serialVersionUID = 1L;
private String sequenceNbr;
private String record;
private Date recDate;
......
......@@ -16,13 +16,11 @@ import java.util.Date;
*/
@Data
@EqualsAndHashCode(callSuper = true)
@ApiModel(value="IdxBizJgProjectInspectionDto", description="工程装置-检验检测信息表")
public class IdxBizJgProjectInspectionDto extends BaseDto {
private static final long serialVersionUID = 1L;
private String sequenceNbr;
@ApiModel(value = "IdxBizJgProjectInspectionDto", description = "工程装置-检验检测信息表")
public class IdxBizJgProjectInspectionDto extends BaseDto {
private static final long serialVersionUID = 1L;
private String record;
private Date recDate;
......
......@@ -23,11 +23,6 @@ public class IdxBizJgProjectConstruction extends TzsBaseEntity {
private static final long serialVersionUID = 1L;
/**
*
*/
@TableField("\"SEQUENCE_NBR\"")
private String sequenceNbr;
/**
*
......@@ -38,18 +33,6 @@ public class IdxBizJgProjectConstruction extends TzsBaseEntity {
/**
*
*/
@TableField("\"REC_DATE\"")
private Date recDate;
/**
*
*/
@TableField("\"REC_USER_ID\"")
private String recUserId;
/**
*
*/
@TableField("\"INSTANCE_ID\"")
private String instanceId;
......
......@@ -26,26 +26,9 @@ public class IdxBizJgProjectInspection extends TzsBaseEntity {
/**
*
*/
@TableField("\"SEQUENCE_NBR\"")
private String sequenceNbr;
/**
*
*/
@TableField("\"RECORD\"")
private String record;
/**
*
*/
@TableField("\"REC_DATE\"")
private Date recDate;
/**
*
*/
@TableField("\"REC_USER_ID\"")
private String recUserId;
/**
*
......
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