feat:报告编制-数据保存
This commit is contained in:
@@ -103,6 +103,16 @@ public class ReportDocumentMainController extends AbstractFileUploadController i
|
||||
return reportDocumentMainService.execRemoveData(vo);
|
||||
}
|
||||
|
||||
@PutMapping("/doSave")
|
||||
@Operation(summary = "更新检测报告业务")
|
||||
//@PreAuthorize("@ss.hasPermission('qms:report-document-main:update')")
|
||||
public CommonResult<Boolean> doSave(@Valid @RequestBody ReportDocumentMainSaveReqVO updateReqVO) {
|
||||
updateReqVO.setCancelFlag("0");
|
||||
reportDocumentMainService.updateReportDocumentMain(updateReqVO);
|
||||
return success(true);
|
||||
}
|
||||
|
||||
|
||||
@PutMapping("/update")
|
||||
@Operation(summary = "更新检测报告业务")
|
||||
//@PreAuthorize("@ss.hasPermission('qms:report-document-main:update')")
|
||||
|
||||
@@ -6,6 +6,7 @@ import jakarta.validation.constraints.NotEmpty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Schema(description = "管理后台 - 检测报告业务新增/修改 Request VO")
|
||||
@Data
|
||||
@@ -94,5 +95,7 @@ public class ReportDocumentMainSaveReqVO {
|
||||
@Schema(description = "委托id,支持多值")
|
||||
private String businessSampleEntrustRegistrationIds;
|
||||
|
||||
@Schema(description = "报表数据明细,用于保存【备注】等数据")
|
||||
private List<ReportDocumentDataSaveReqVO> reportDocumentDataList;
|
||||
|
||||
}
|
||||
@@ -60,7 +60,7 @@ public class ReportDocumentDataDO extends BusinessBaseDO {
|
||||
/**
|
||||
* 附加内容
|
||||
*/
|
||||
@TableField("DOC_CNTT")
|
||||
@TableField("EXT_CNTT")
|
||||
private String externalContent;
|
||||
|
||||
//样品编号
|
||||
|
||||
@@ -44,6 +44,8 @@ public interface ReportDocumentDataService {
|
||||
*/
|
||||
void updateReportDocumentData(@Valid ReportDocumentDataSaveReqVO updateReqVO);
|
||||
|
||||
void updateBatch(List<ReportDocumentDataSaveReqVO> list);
|
||||
|
||||
/**
|
||||
* 删除检测报告明细
|
||||
*
|
||||
|
||||
@@ -60,7 +60,6 @@ public class ReportDocumentDataServiceImpl implements ReportDocumentDataService
|
||||
if(typeDO == null || typeDO.getConfigReportTypeId() == null)
|
||||
return CommonResult.error(REPORT_DOCUMENT_TYPE_NOT_EXISTS, "报告配置为空,或未配置报表类型,请联系管理员处理!");
|
||||
String customConfig = typeDO.getCustomConfig();
|
||||
|
||||
//查询报表字段配置
|
||||
ConfigReportFieldPageReqVO fieldParam = new ConfigReportFieldPageReqVO();
|
||||
fieldParam.setConfigReportTypeId(typeDO.getConfigReportTypeId());
|
||||
@@ -117,6 +116,7 @@ public class ReportDocumentDataServiceImpl implements ReportDocumentDataService
|
||||
String fixedColCountStr = jsonObject.getString("fixedColCount");
|
||||
String maxRowCountStr = jsonObject.getString("maxRowCount");
|
||||
String nameCodeType = jsonObject.getString("nameCodeType");
|
||||
String hasRemark = jsonObject.getString("hasRemark");
|
||||
if(!ObjectUtils.isEmpty(dynamicColCountStr)) dynamicColCount = Integer.parseInt(dynamicColCountStr);
|
||||
if(!ObjectUtils.isEmpty(fixedColCountStr)) fixedColCount = Integer.parseInt(fixedColCountStr);
|
||||
|
||||
@@ -143,6 +143,10 @@ public class ReportDocumentDataServiceImpl implements ReportDocumentDataService
|
||||
int rowAssist = 1;
|
||||
int colIndex = 1;
|
||||
boolean lastObjFlag = true;
|
||||
if("1".equals(hasRemark)){
|
||||
//在最后一列增加备注
|
||||
t.put(colPrefix + parseNumToString(colCountOneSample + 1, 2), "备注");
|
||||
}
|
||||
for(ConfigReportFieldDO fieldDO : fieldList){
|
||||
String fieldType = fieldDO.getFieldType();
|
||||
if(FIELD_FIXED.equals(fieldType)){ //这里只处理动态列。固定列在 addTitleToRowList 处理
|
||||
@@ -155,6 +159,10 @@ public class ReportDocumentDataServiceImpl implements ReportDocumentDataService
|
||||
if(colIndex % colCountOneSample == 0){
|
||||
addTitleToRowList(nameCodeType, rowAssist, t, dataLength, emptyRowCount, rowList, fieldList);
|
||||
t = new JSONObject();
|
||||
if("1".equals(hasRemark)){
|
||||
//在最后一列增加备注
|
||||
t.put(colPrefix + parseNumToString(colCountOneSample + 1, 2), "备注");
|
||||
}
|
||||
rowAssist++;
|
||||
colIndex = fixedColCount; //第二组以后,从固定列数开始
|
||||
lastObjFlag = false;
|
||||
@@ -168,10 +176,19 @@ public class ReportDocumentDataServiceImpl implements ReportDocumentDataService
|
||||
int dataIndex = 1;
|
||||
for(ReportDocumentDataDO dataDO : dataList){
|
||||
String documentContent = dataDO.getDocumentContent();
|
||||
String externalContent = dataDO.getExternalContent();
|
||||
JSONObject s = JSONObject.parseObject(documentContent);
|
||||
JSONObject e = new JSONObject();
|
||||
if(!ObjectUtils.isEmpty(externalContent)){
|
||||
e = JSONObject.parseObject(externalContent);
|
||||
}
|
||||
String remark = e.getString("remark");
|
||||
colIndex = fixedColCount + 1;
|
||||
rowAssist = 1;
|
||||
t = new JSONObject();
|
||||
if("1".equals(hasRemark)){
|
||||
t.put(colPrefix + parseNumToString(colCountOneSample + 1, 2), remark);
|
||||
}
|
||||
for(ConfigReportFieldDO fieldDO : fieldList){
|
||||
String fieldType = fieldDO.getFieldType();
|
||||
if(FIELD_FIXED.equals(fieldType)){ //这里只处理动态列。固定列在 addDataToRowList 处理
|
||||
@@ -188,6 +205,9 @@ public class ReportDocumentDataServiceImpl implements ReportDocumentDataService
|
||||
if(colIndex % colCountOneSample == 0){
|
||||
addDataToRowList(nameCodeType, dataDO, rowAssist, t, dataLength, emptyRowCount, dataIndex, rowList, fieldList);
|
||||
t = new JSONObject();
|
||||
if("1".equals(hasRemark)){
|
||||
t.put(colPrefix + parseNumToString(colCountOneSample + 1, 2), remark);
|
||||
}
|
||||
rowAssist++;
|
||||
colIndex = fixedColCount + 1; //第二组以后,从固定列数开始
|
||||
lastObjFlag = false;
|
||||
@@ -206,7 +226,8 @@ public class ReportDocumentDataServiceImpl implements ReportDocumentDataService
|
||||
* @param nameCodeType: merge-合并, name-只显示名称, code-只显示编号, split-2列分开显示
|
||||
*
|
||||
* */
|
||||
private void addTitleToRowList(String nameCodeType, Integer rowAssist, JSONObject t, Integer dataLength, Integer emptyRowCount, List<JSONObject> rowList, List<ConfigReportFieldDO> fieldList){
|
||||
private void addTitleToRowList(String nameCodeType, Integer rowAssist, JSONObject t, Integer dataLength, Integer emptyRowCount,
|
||||
List<JSONObject> rowList, List<ConfigReportFieldDO> fieldList){
|
||||
int rowIndex = (1 + dataLength + emptyRowCount) * (rowAssist - 1) + 1; //(标题 + 数据行 + 空行)
|
||||
//处理固定列
|
||||
int index = 1;
|
||||
@@ -239,6 +260,7 @@ public class ReportDocumentDataServiceImpl implements ReportDocumentDataService
|
||||
}
|
||||
private void addDataToRowList(String nameCodeType, ReportDocumentDataDO dataDO, Integer rowAssist, JSONObject t, Integer dataLength, Integer emptyRowCount, Integer dataIndex, List<JSONObject> rowList, List<ConfigReportFieldDO> fieldList){
|
||||
int rowIndex = (1 + dataLength + emptyRowCount) * (rowAssist - 1) + dataIndex + 1; //(标题 + 数据行 + 空行)
|
||||
t.put("id", dataDO.getId());
|
||||
//处理固定列
|
||||
int index = 1;
|
||||
//处理固定列
|
||||
@@ -326,6 +348,16 @@ public class ReportDocumentDataServiceImpl implements ReportDocumentDataService
|
||||
reportDocumentDataMapper.updateById(updateObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateBatch(List<ReportDocumentDataSaveReqVO> list) {
|
||||
List<ReportDocumentDataDO> updateList = new ArrayList<>();
|
||||
for (ReportDocumentDataSaveReqVO updateReqVO : list) {
|
||||
ReportDocumentDataDO updateObj = BeanUtils.toBean(updateReqVO, ReportDocumentDataDO.class);
|
||||
updateList.add(updateObj);
|
||||
}
|
||||
reportDocumentDataMapper.updateBatch(updateList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteReportDocumentData(Long id) {
|
||||
// 校验存在
|
||||
|
||||
@@ -30,6 +30,9 @@ public interface ReportDocumentMainService {
|
||||
|
||||
void updateCommonField(ReportDocumentMainDO reportDocumentMainDO);
|
||||
|
||||
//保存报告
|
||||
void doSave(@Valid ReportDocumentMainSaveReqVO updateReqVO);
|
||||
|
||||
/**
|
||||
* 创建检测报告业务
|
||||
*
|
||||
@@ -45,6 +48,7 @@ public interface ReportDocumentMainService {
|
||||
*/
|
||||
void updateReportDocumentMain(@Valid ReportDocumentMainSaveReqVO updateReqVO);
|
||||
|
||||
|
||||
/**
|
||||
* 删除检测报告业务
|
||||
*
|
||||
|
||||
@@ -176,6 +176,18 @@ public class ReportDocumentMainServiceImpl implements ReportDocumentMainService,
|
||||
return reportDocumentDataService.removeByMainIdAndDetailIds(id, reportDocumentDataIdsList);
|
||||
}
|
||||
|
||||
//保存报告
|
||||
@Override
|
||||
public void doSave(ReportDocumentMainSaveReqVO updateReqVO) {
|
||||
// 校验存在
|
||||
validateReportDocumentMainExists(updateReqVO.getId());
|
||||
// 更新
|
||||
ReportDocumentMainDO updateObj = BeanUtils.toBean(updateReqVO, ReportDocumentMainDO.class);
|
||||
reportDocumentMainMapper.updateById(updateObj);
|
||||
List<ReportDocumentDataSaveReqVO> reportDocumentDataList = updateReqVO.getReportDocumentDataList();
|
||||
reportDocumentDataService.updateBatch(reportDocumentDataList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ReportDocumentMainRespVO createReportDocumentMain(ReportDocumentMainSaveReqVO createReqVO) {
|
||||
// 插入
|
||||
|
||||
Reference in New Issue
Block a user