refactor(steady): 重构数据校验功能并新增PQDIF解析预留模块
- 将数据校验中的缺失率相关字段替换为数据完整性字段 - 新增数据校验任务删除功能及相应测试 - 在tools模块中添加parse-pqdif子模块作为PQDIF文件解析预留 - 更新README文档以反映新的模块结构和依赖关系 - 优化数据校验统计汇总逻辑和测试覆盖 - 在entrance模块中集成parse-pqdif依赖 - 重构数据校验服务层实现和数据对象映射
This commit is contained in:
@@ -10,9 +10,10 @@
|
||||
- `add-data`
|
||||
- `add-ledger`
|
||||
- `mms-mapping`
|
||||
- `parse-pqdif`
|
||||
- `wave-tool`
|
||||
|
||||
因此,`tools` 现阶段仍然是聚合模块,但当前已实际承载激活工具、电能质量数据补录工具、数据台账工具空模块、ICD/MMS 映射工具和波形查看工具五个子模块。
|
||||
因此,`tools` 现阶段仍然是聚合模块,但当前已实际承载激活工具、电能质量数据补录工具、数据台账工具空模块、ICD/MMS 映射工具、PQDIF 解析预留工具和波形查看工具六个子模块。
|
||||
|
||||
## 当前结构
|
||||
|
||||
@@ -22,6 +23,7 @@ tools/
|
||||
├── add-data/
|
||||
├── add-ledger/
|
||||
├── mms-mapping/
|
||||
├── parse-pqdif/
|
||||
└── wave-tool/
|
||||
```
|
||||
|
||||
@@ -78,6 +80,16 @@ tools/
|
||||
|
||||
从接口层看,当前主要围绕 `/api/mms-mapping` 路径提供能力。
|
||||
|
||||
## parse-pqdif 的职责
|
||||
|
||||
`parse-pqdif` 当前仅作为 PQDIF 文件解析工具的预留骨架,参照 `mms-mapping` 的 Controller、Service、ServiceImpl 和 VO 分层组织。
|
||||
|
||||
- 预留 PQDIF 文件上传解析入口
|
||||
- 预留解析服务接口与实现
|
||||
- 当前不包含真实 PQDIF 解析、持久化或数据转换逻辑
|
||||
|
||||
从接口层看,当前预留路径为 `/api/parse-pqdif/parse`。
|
||||
|
||||
## mms-mapping 配置
|
||||
|
||||
`mms-mapping` 当前支持以下配置项:
|
||||
@@ -98,7 +110,7 @@ tools/
|
||||
|
||||
## 依赖关系
|
||||
|
||||
`tools/activate-tool`、`tools/add-data`、`tools/add-ledger`、`tools/mms-mapping` 与 `tools/wave-tool` 当前主要依赖:
|
||||
`tools/activate-tool`、`tools/add-data`、`tools/add-ledger`、`tools/mms-mapping`、`tools/parse-pqdif` 与 `tools/wave-tool` 当前主要依赖:
|
||||
|
||||
- `com.njcn:njcn-common`
|
||||
- `com.njcn:spingboot2.3.12`
|
||||
|
||||
@@ -20,6 +20,12 @@
|
||||
<version>0.0.1</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.njcn</groupId>
|
||||
<artifactId>mybatis-plus</artifactId>
|
||||
<version>0.0.1</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.njcn</groupId>
|
||||
<artifactId>spingboot2.3.12</artifactId>
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
package com.njcn.gather.icd.mapping.controller;
|
||||
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.LogUtil;
|
||||
import com.njcn.gather.icd.mapping.pojo.param.IcdCheckResultSaveParam;
|
||||
import com.njcn.gather.icd.mapping.pojo.vo.MmsDeviceTypeVO;
|
||||
import com.njcn.gather.icd.mapping.pojo.vo.PqdifCheckPlaceholderVO;
|
||||
import com.njcn.gather.icd.mapping.service.MmsDeviceTypeService;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import com.njcn.web.utils.HttpResultUtil;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PathVariable;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 设备类型校验入口。
|
||||
*/
|
||||
@Slf4j
|
||||
@Api(tags = "设备类型ICD校验")
|
||||
@RestController
|
||||
@RequestMapping("/api/mms-mapping/dev-types")
|
||||
@RequiredArgsConstructor
|
||||
public class MmsDeviceTypeController extends BaseController {
|
||||
|
||||
private final MmsDeviceTypeService mmsDeviceTypeService;
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@ApiOperation("查询设备类型校验列表")
|
||||
@GetMapping
|
||||
public HttpResult<List<MmsDeviceTypeVO>> listDeviceTypes() {
|
||||
String methodDescribe = getMethodDescribe("listDeviceTypes");
|
||||
LogUtil.njcnDebug(log, "{},开始查询设备类型校验列表", methodDescribe);
|
||||
List<MmsDeviceTypeVO> result = mmsDeviceTypeService.listDeviceTypes();
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@ApiOperation("保存设备类型ICD唯一性校验结果")
|
||||
@ApiImplicitParam(name = "id", value = "设备类型ID", required = true)
|
||||
@PostMapping("/{id}/icd-check-result")
|
||||
public HttpResult<Boolean> saveIcdCheckResult(@PathVariable("id") String id,
|
||||
@RequestBody IcdCheckResultSaveParam param) {
|
||||
String methodDescribe = getMethodDescribe("saveIcdCheckResult");
|
||||
LogUtil.njcnDebug(log, "{},开始保存设备类型ICD校验结果,devTypeId={}", methodDescribe, id);
|
||||
boolean result = mmsDeviceTypeService.saveIcdCheckResult(id, param);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@ApiOperation("设备类型PQDIF校验")
|
||||
@ApiImplicitParam(name = "id", value = "设备类型ID", required = true)
|
||||
@PostMapping("/{id}/pqdif-check")
|
||||
public HttpResult<PqdifCheckPlaceholderVO> pqdifCheck(@PathVariable("id") String id) {
|
||||
String methodDescribe = getMethodDescribe("pqdifCheck");
|
||||
LogUtil.njcnDebug(log, "{},设备类型PQDIF校验预留入口,devTypeId={}", methodDescribe, id);
|
||||
PqdifCheckPlaceholderVO result = mmsDeviceTypeService.pqdifCheck(id);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.njcn.gather.icd.mapping.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.njcn.gather.icd.mapping.pojo.po.CsDevTypePO;
|
||||
import com.njcn.gather.icd.mapping.pojo.vo.MmsDeviceTypeVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 设备类型 Mapper。
|
||||
*/
|
||||
public interface CsDevTypeMapper extends BaseMapper<CsDevTypePO> {
|
||||
|
||||
List<MmsDeviceTypeVO> selectDeviceTypeCheckList();
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.njcn.gather.icd.mapping.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.njcn.gather.icd.mapping.pojo.po.CsIcdPathPO;
|
||||
|
||||
/**
|
||||
* ICD 路径 Mapper。
|
||||
*/
|
||||
public interface CsIcdPathMapper extends BaseMapper<CsIcdPathPO> {
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
<?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.njcn.gather.icd.mapping.mapper.CsDevTypeMapper">
|
||||
|
||||
<select id="selectDeviceTypeCheckList"
|
||||
resultType="com.njcn.gather.icd.mapping.pojo.vo.MmsDeviceTypeVO">
|
||||
SELECT
|
||||
d.id AS id,
|
||||
d.name AS name,
|
||||
d.icd AS icdId,
|
||||
p.Name AS icdName,
|
||||
p.Path AS icdPath,
|
||||
p.Result AS icdResult,
|
||||
p.Msg AS icdMsg,
|
||||
d.report_name AS reportName,
|
||||
CASE WHEN d.icd IS NOT NULL AND d.icd != '' AND p.ID IS NOT NULL THEN 1 ELSE 0 END AS canCheckIcd,
|
||||
0 AS canCheckPqdif
|
||||
FROM cs_dev_type d
|
||||
LEFT JOIN cs_icd_path p ON d.icd = p.ID
|
||||
WHERE d.State = 1
|
||||
ORDER BY d.Update_Time DESC, d.Create_Time DESC
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.njcn.gather.icd.mapping.pojo.param;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* ICD 校验结果保存参数。
|
||||
*/
|
||||
@Data
|
||||
@ApiModel("ICD校验结果保存参数")
|
||||
public class IcdCheckResultSaveParam {
|
||||
|
||||
@ApiModelProperty("MMS映射JSON")
|
||||
private String mappingJson;
|
||||
|
||||
@ApiModelProperty("MMS映射XML")
|
||||
private String xml;
|
||||
|
||||
@ApiModelProperty("校验结论:0-否,1-是")
|
||||
private Integer result;
|
||||
|
||||
@ApiModelProperty("校验结论描述")
|
||||
private String msg;
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package com.njcn.gather.icd.mapping.pojo.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 设备类型表。
|
||||
*/
|
||||
@Data
|
||||
@TableName("cs_dev_type")
|
||||
public class CsDevTypePO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId("id")
|
||||
private String id;
|
||||
|
||||
@TableField("name")
|
||||
private String name;
|
||||
|
||||
@TableField("icd")
|
||||
private String icd;
|
||||
|
||||
@TableField("power")
|
||||
private String power;
|
||||
|
||||
@TableField("Dev_Volt")
|
||||
private Float devVolt;
|
||||
|
||||
@TableField("Dev_Curr")
|
||||
private Float devCurr;
|
||||
|
||||
@TableField("Dev_Chns")
|
||||
private Integer devChns;
|
||||
|
||||
@TableField("Wave_Cmd")
|
||||
private String waveCmd;
|
||||
|
||||
@TableField("State")
|
||||
private Integer state;
|
||||
|
||||
@TableField("Create_By")
|
||||
private String createBy;
|
||||
|
||||
@TableField("Create_Time")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@TableField("Update_By")
|
||||
private String updateBy;
|
||||
|
||||
@TableField("Update_Time")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
@TableField("report_name")
|
||||
private String reportName;
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package com.njcn.gather.icd.mapping.pojo.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* ICD 存储记录。
|
||||
*/
|
||||
@Data
|
||||
@TableName("cs_icd_path")
|
||||
public class CsIcdPathPO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId("ID")
|
||||
private String id;
|
||||
|
||||
@TableField("Name")
|
||||
private String name;
|
||||
|
||||
@TableField("Path")
|
||||
private String path;
|
||||
|
||||
@TableField("Angle")
|
||||
private Integer angle;
|
||||
|
||||
@TableField("Use_Phase_Index")
|
||||
private Integer usePhaseIndex;
|
||||
|
||||
@TableField("State")
|
||||
private Integer state;
|
||||
|
||||
@TableField("Create_By")
|
||||
private String createBy;
|
||||
|
||||
@TableField("Create_Time")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@TableField("Update_By")
|
||||
private String updateBy;
|
||||
|
||||
@TableField("Update_Time")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
@TableField("Json_Str")
|
||||
private String jsonStr;
|
||||
|
||||
@TableField("Xml_Str")
|
||||
private String xmlStr;
|
||||
|
||||
@TableField("Result")
|
||||
private Integer result;
|
||||
|
||||
@TableField("Msg")
|
||||
private String msg;
|
||||
|
||||
@TableField("Type")
|
||||
private Integer type;
|
||||
|
||||
@TableField("Reference_Icd_Id")
|
||||
private String referenceIcdId;
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.njcn.gather.icd.mapping.pojo.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 设备类型校验列表项。
|
||||
*/
|
||||
@Data
|
||||
@ApiModel("设备类型校验列表项")
|
||||
public class MmsDeviceTypeVO {
|
||||
|
||||
@ApiModelProperty("设备类型ID")
|
||||
private String id;
|
||||
|
||||
@ApiModelProperty("设备类型名称")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty("关联ICD ID")
|
||||
private String icdId;
|
||||
|
||||
@ApiModelProperty("ICD名称")
|
||||
private String icdName;
|
||||
|
||||
@ApiModelProperty("ICD路径")
|
||||
private String icdPath;
|
||||
|
||||
@ApiModelProperty("ICD校验结论:0-否,1-是")
|
||||
private Integer icdResult;
|
||||
|
||||
@ApiModelProperty("ICD校验结论描述")
|
||||
private String icdMsg;
|
||||
|
||||
@ApiModelProperty("报告模板名称")
|
||||
private String reportName;
|
||||
|
||||
@ApiModelProperty("是否可执行ICD唯一性校验")
|
||||
private Boolean canCheckIcd;
|
||||
|
||||
@ApiModelProperty("是否可执行PQDIF校验")
|
||||
private Boolean canCheckPqdif;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.njcn.gather.icd.mapping.pojo.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* PQDIF 校验预留响应。
|
||||
*/
|
||||
@Data
|
||||
@ApiModel("PQDIF校验预留响应")
|
||||
public class PqdifCheckPlaceholderVO {
|
||||
|
||||
@ApiModelProperty("状态")
|
||||
private String status;
|
||||
|
||||
@ApiModelProperty("提示信息")
|
||||
private String message;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.njcn.gather.icd.mapping.service;
|
||||
|
||||
import com.njcn.gather.icd.mapping.pojo.param.IcdCheckResultSaveParam;
|
||||
import com.njcn.gather.icd.mapping.pojo.vo.MmsDeviceTypeVO;
|
||||
import com.njcn.gather.icd.mapping.pojo.vo.PqdifCheckPlaceholderVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 设备类型校验服务。
|
||||
*/
|
||||
public interface MmsDeviceTypeService {
|
||||
|
||||
List<MmsDeviceTypeVO> listDeviceTypes();
|
||||
|
||||
boolean saveIcdCheckResult(String devTypeId, IcdCheckResultSaveParam param);
|
||||
|
||||
PqdifCheckPlaceholderVO pqdifCheck(String devTypeId);
|
||||
}
|
||||
@@ -0,0 +1,141 @@
|
||||
package com.njcn.gather.icd.mapping.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.njcn.gather.icd.mapping.mapper.CsDevTypeMapper;
|
||||
import com.njcn.gather.icd.mapping.mapper.CsIcdPathMapper;
|
||||
import com.njcn.gather.icd.mapping.pojo.param.IcdCheckResultSaveParam;
|
||||
import com.njcn.gather.icd.mapping.pojo.po.CsDevTypePO;
|
||||
import com.njcn.gather.icd.mapping.pojo.po.CsIcdPathPO;
|
||||
import com.njcn.gather.icd.mapping.pojo.vo.MmsDeviceTypeVO;
|
||||
import com.njcn.gather.icd.mapping.pojo.vo.PqdifCheckPlaceholderVO;
|
||||
import com.njcn.gather.icd.mapping.service.MmsDeviceTypeService;
|
||||
import com.njcn.web.utils.RequestUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 设备类型校验服务实现。
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class MmsDeviceTypeServiceImpl implements MmsDeviceTypeService {
|
||||
|
||||
private static final int STATE_NORMAL = 1;
|
||||
|
||||
private static final int ICD_TYPE_STANDARD = 1;
|
||||
|
||||
private static final String PQDIF_NOT_SUPPORTED = "NOT_SUPPORTED";
|
||||
|
||||
private final CsDevTypeMapper csDevTypeMapper;
|
||||
|
||||
private final CsIcdPathMapper csIcdPathMapper;
|
||||
|
||||
@Override
|
||||
public List<MmsDeviceTypeVO> listDeviceTypes() {
|
||||
return csDevTypeMapper.selectDeviceTypeCheckList();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public boolean saveIcdCheckResult(String devTypeId, IcdCheckResultSaveParam param) {
|
||||
if (param == null) {
|
||||
throw new IllegalArgumentException("ICD校验结果不能为空");
|
||||
}
|
||||
CsDevTypePO devType = requireDevType(devTypeId);
|
||||
if (isBlank(devType.getIcd())) {
|
||||
throw new IllegalArgumentException("设备类型未关联ICD,不能保存校验结果");
|
||||
}
|
||||
|
||||
CsIcdPathPO referenceIcd = requireUniqueReferenceIcd();
|
||||
CsIcdPathPO icdPath = csIcdPathMapper.selectById(devType.getIcd());
|
||||
if (icdPath == null || !Integer.valueOf(STATE_NORMAL).equals(icdPath.getState())) {
|
||||
throw new IllegalArgumentException("设备类型关联的ICD不存在或已删除");
|
||||
}
|
||||
|
||||
icdPath.setJsonStr(trimToNull(param.getMappingJson()));
|
||||
icdPath.setXmlStr(trimToNull(param.getXml()));
|
||||
icdPath.setResult(normalizeResult(param.getResult()));
|
||||
icdPath.setMsg(trimToNull(param.getMsg()));
|
||||
icdPath.setReferenceIcdId(referenceIcd.getId());
|
||||
icdPath.setUpdateBy(currentUserId());
|
||||
icdPath.setUpdateTime(LocalDateTime.now());
|
||||
return csIcdPathMapper.updateById(icdPath) > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PqdifCheckPlaceholderVO pqdifCheck(String devTypeId) {
|
||||
requireDevType(devTypeId);
|
||||
PqdifCheckPlaceholderVO result = new PqdifCheckPlaceholderVO();
|
||||
result.setStatus(PQDIF_NOT_SUPPORTED);
|
||||
result.setMessage("PQDIF校验功能待实现");
|
||||
return result;
|
||||
}
|
||||
|
||||
private CsDevTypePO requireDevType(String devTypeId) {
|
||||
String id = requireText(devTypeId, "设备类型ID不能为空");
|
||||
CsDevTypePO devType = csDevTypeMapper.selectById(id);
|
||||
if (devType == null || !Integer.valueOf(STATE_NORMAL).equals(devType.getState())) {
|
||||
throw new IllegalArgumentException("设备类型不存在或已删除");
|
||||
}
|
||||
return devType;
|
||||
}
|
||||
|
||||
/**
|
||||
* 全系统只允许一个正常状态的标准 ICD 作为唯一参照。
|
||||
*/
|
||||
private CsIcdPathPO requireUniqueReferenceIcd() {
|
||||
List<CsIcdPathPO> referenceIcdList = csIcdPathMapper.selectList(new LambdaQueryWrapper<CsIcdPathPO>()
|
||||
.eq(CsIcdPathPO::getState, STATE_NORMAL)
|
||||
.eq(CsIcdPathPO::getType, ICD_TYPE_STANDARD));
|
||||
if (referenceIcdList == null || referenceIcdList.isEmpty()) {
|
||||
throw new IllegalArgumentException("未配置标准ICD,无法执行唯一性校验");
|
||||
}
|
||||
if (referenceIcdList.size() > 1) {
|
||||
throw new IllegalArgumentException("存在多个标准ICD,无法确定唯一参照");
|
||||
}
|
||||
return referenceIcdList.get(0);
|
||||
}
|
||||
|
||||
private Integer normalizeResult(Integer result) {
|
||||
if (result == null) {
|
||||
throw new IllegalArgumentException("校验结论不能为空");
|
||||
}
|
||||
if (result != 0 && result != 1) {
|
||||
throw new IllegalArgumentException("校验结论只能是0或1");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private String requireText(String value, String message) {
|
||||
String text = trimToNull(value);
|
||||
if (text == null) {
|
||||
throw new IllegalArgumentException(message);
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
||||
private String trimToNull(String value) {
|
||||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
String text = value.trim();
|
||||
return text.isEmpty() ? null : text;
|
||||
}
|
||||
|
||||
private boolean isBlank(String value) {
|
||||
return trimToNull(value) == null;
|
||||
}
|
||||
|
||||
private String currentUserId() {
|
||||
try {
|
||||
String userId = RequestUtil.getUserId();
|
||||
return isBlank(userId) ? "未知用户" : userId;
|
||||
} catch (Exception ex) {
|
||||
return "未知用户";
|
||||
}
|
||||
}
|
||||
}
|
||||
55
tools/parse-pqdif/pom.xml
Normal file
55
tools/parse-pqdif/pom.xml
Normal file
@@ -0,0 +1,55 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<parent>
|
||||
<groupId>com.njcn.gather</groupId>
|
||||
<artifactId>tools</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>parse-pqdif</artifactId>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.njcn</groupId>
|
||||
<artifactId>njcn-common</artifactId>
|
||||
<version>0.0.1</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.njcn</groupId>
|
||||
<artifactId>spingboot2.3.12</artifactId>
|
||||
<version>2.3.12</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-validation</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<finalName>parse-pqdif</finalName>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.8.1</version>
|
||||
<configuration>
|
||||
<source>1.8</source>
|
||||
<target>1.8</target>
|
||||
<encoding>UTF-8</encoding>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.njcn.gather.tool.parsepqdif.controller;
|
||||
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.LogUtil;
|
||||
import com.njcn.gather.tool.parsepqdif.pojo.vo.PqdifParseResponse;
|
||||
import com.njcn.gather.tool.parsepqdif.service.ParsePqdifService;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import com.njcn.web.utils.HttpResultUtil;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestPart;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
/**
|
||||
* PQDIF 解析接口入口。
|
||||
*/
|
||||
@Slf4j
|
||||
@Api(tags = "PQDIF解析")
|
||||
@RestController
|
||||
@RequestMapping("/api/parse-pqdif")
|
||||
@RequiredArgsConstructor
|
||||
public class ParsePqdifController extends BaseController {
|
||||
|
||||
private final ParsePqdifService parsePqdifService;
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@ApiOperation("上传 PQDIF 文件并解析")
|
||||
@ApiImplicitParam(name = "pqdifFile", value = "PQDIF文件", required = true, dataType = "__file", paramType = "form")
|
||||
@PostMapping(value = "/parse", consumes = {"multipart/form-data"})
|
||||
public HttpResult<PqdifParseResponse> parse(@RequestPart("pqdifFile") MultipartFile pqdifFile) {
|
||||
String methodDescribe = getMethodDescribe("parse");
|
||||
LogUtil.njcnDebug(log, "{},PQDIF解析预留入口,fileName={}",
|
||||
methodDescribe, pqdifFile == null ? null : pqdifFile.getOriginalFilename());
|
||||
PqdifParseResponse result = parsePqdifService.parse(pqdifFile);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.njcn.gather.tool.parsepqdif.pojo.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* PQDIF 解析占位响应。
|
||||
*/
|
||||
@Data
|
||||
@ApiModel("PQDIF解析响应")
|
||||
public class PqdifParseResponse {
|
||||
|
||||
@ApiModelProperty("状态")
|
||||
private String status;
|
||||
|
||||
@ApiModelProperty("提示信息")
|
||||
private String message;
|
||||
|
||||
@ApiModelProperty("文件名")
|
||||
private String fileName;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.njcn.gather.tool.parsepqdif.service;
|
||||
|
||||
import com.njcn.gather.tool.parsepqdif.pojo.vo.PqdifParseResponse;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
/**
|
||||
* PQDIF 解析服务。
|
||||
*/
|
||||
public interface ParsePqdifService {
|
||||
|
||||
PqdifParseResponse parse(MultipartFile pqdifFile);
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.njcn.gather.tool.parsepqdif.service.impl;
|
||||
|
||||
import com.njcn.gather.tool.parsepqdif.pojo.vo.PqdifParseResponse;
|
||||
import com.njcn.gather.tool.parsepqdif.service.ParsePqdifService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
/**
|
||||
* PQDIF 解析服务实现。
|
||||
*/
|
||||
@Service
|
||||
public class ParsePqdifServiceImpl implements ParsePqdifService {
|
||||
|
||||
private static final String STATUS_NOT_SUPPORTED = "NOT_SUPPORTED";
|
||||
|
||||
@Override
|
||||
public PqdifParseResponse parse(MultipartFile pqdifFile) {
|
||||
PqdifParseResponse response = new PqdifParseResponse();
|
||||
response.setStatus(STATUS_NOT_SUPPORTED);
|
||||
response.setMessage("PQDIF解析功能待实现");
|
||||
response.setFileName(pqdifFile == null ? null : pqdifFile.getOriginalFilename());
|
||||
return response;
|
||||
}
|
||||
}
|
||||
1
tools/parse-pqdif/src/main/resources/.gitkeep
Normal file
1
tools/parse-pqdif/src/main/resources/.gitkeep
Normal file
@@ -0,0 +1 @@
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
<module>wave-tool</module>
|
||||
<module>add-data</module>
|
||||
<module>add-ledger</module>
|
||||
<module>parse-pqdif</module>
|
||||
</modules>
|
||||
|
||||
</project>
|
||||
|
||||
Reference in New Issue
Block a user