Commit 4f845e6b authored by 刘凡's avatar 刘凡

新增:调整多数据源与气瓶企业数据校验

parent 69ceb527
...@@ -65,6 +65,7 @@ public class CylinderController { ...@@ -65,6 +65,7 @@ public class CylinderController {
@PostMapping(value = "/info") @PostMapping(value = "/info")
@RestEventTrigger(value = "openapiLogEventHandler") @RestEventTrigger(value = "openapiLogEventHandler")
public ResponseModel<String> cylinderInfo(@RequestBody List<TmCylinderInfoModel> infoData) throws Exception { public ResponseModel<String> cylinderInfo(@RequestBody List<TmCylinderInfoModel> infoData) throws Exception {
cylinderFillingDataValidationService.validateCylinderInfo(infoData);
return ResponseHelper.buildResponse(cylinderInfoService.createCylinderInfo(infoData)); return ResponseHelper.buildResponse(cylinderInfoService.createCylinderInfo(infoData));
} }
...@@ -73,6 +74,7 @@ public class CylinderController { ...@@ -73,6 +74,7 @@ public class CylinderController {
@PostMapping(value = "/tag") @PostMapping(value = "/tag")
@RestEventTrigger(value = "openapiLogEventHandler") @RestEventTrigger(value = "openapiLogEventHandler")
public ResponseModel<String> cylinderTagInfo(@RequestBody List<TmCylinderTagsModel> tagData) throws Exception { public ResponseModel<String> cylinderTagInfo(@RequestBody List<TmCylinderTagsModel> tagData) throws Exception {
cylinderFillingDataValidationService.validateCylinderTag(tagData);
return ResponseHelper.buildResponse(cylinderTagsService.createCylinderTag(tagData)); return ResponseHelper.buildResponse(cylinderTagsService.createCylinderTag(tagData));
} }
...@@ -81,6 +83,7 @@ public class CylinderController { ...@@ -81,6 +83,7 @@ public class CylinderController {
@PostMapping(value = "/inspection") @PostMapping(value = "/inspection")
@RestEventTrigger(value = "openapiLogEventHandler") @RestEventTrigger(value = "openapiLogEventHandler")
public ResponseModel<String> cylinderInspectionInfo(@RequestBody List<TmCylinderInspectionModel> inspectionData) throws Exception { public ResponseModel<String> cylinderInspectionInfo(@RequestBody List<TmCylinderInspectionModel> inspectionData) throws Exception {
cylinderFillingDataValidationService.validateCylinderInspection(inspectionData);
return ResponseHelper.buildResponse(cylinderInspectionService.createCylinderInspection(inspectionData)); return ResponseHelper.buildResponse(cylinderInspectionService.createCylinderInspection(inspectionData));
} }
...@@ -91,8 +94,11 @@ public class CylinderController { ...@@ -91,8 +94,11 @@ public class CylinderController {
@RestEventTrigger(value = "openapiLogEventHandler") @RestEventTrigger(value = "openapiLogEventHandler")
public ResponseModel<String> cylinderFillingInfo(@RequestBody String fillingData) throws Exception { public ResponseModel<String> cylinderFillingInfo(@RequestBody String fillingData) throws Exception {
logger.info("气瓶充装数据"+fillingData); // logger.info("气瓶充装数据"+fillingData);
JSONObject jsonobject = JSONObject.fromObject(fillingData); JSONObject jsonobject = JSONObject.fromObject(fillingData);
cylinderFillingDataValidationService.validateFilling(jsonobject);
Map<String, Class> classMap = new HashMap<String, Class>(); Map<String, Class> classMap = new HashMap<String, Class>();
classMap.put("fillingBefore", TmCylinderFillingModel.class); classMap.put("fillingBefore", TmCylinderFillingModel.class);
classMap.put("filling", TmCylinderFillingRecordModel.class); classMap.put("filling", TmCylinderFillingRecordModel.class);
...@@ -125,6 +131,7 @@ public class CylinderController { ...@@ -125,6 +131,7 @@ public class CylinderController {
@PostMapping(value = "/fillingAudit") @PostMapping(value = "/fillingAudit")
@RestEventTrigger(value = "openapiLogEventHandler") @RestEventTrigger(value = "openapiLogEventHandler")
public ResponseModel<String> cylinderFillingAudit(@RequestBody List<TmCylinderFillingExamineModel> fillingAuditData) throws Exception { public ResponseModel<String> cylinderFillingAudit(@RequestBody List<TmCylinderFillingExamineModel> fillingAuditData) throws Exception {
cylinderFillingDataValidationService.validateCylinderFillingExamineModel(fillingAuditData);
return ResponseHelper.buildResponse(cylinderFillingExamineService.createCylinderFillingExamine(fillingAuditData)); return ResponseHelper.buildResponse(cylinderFillingExamineService.createCylinderFillingExamine(fillingAuditData));
} }
......
...@@ -120,7 +120,7 @@ public class CylinderFillingDataValidationService { ...@@ -120,7 +120,7 @@ public class CylinderFillingDataValidationService {
* @param inspectionData * @param inspectionData
* @return * @return
*/ */
boolean validateCylinderInspection(List<TmCylinderInspectionModel> inspectionData) { public boolean validateCylinderInspection(List<TmCylinderInspectionModel> inspectionData) {
JSONArray jsonArray = JSONArray.fromObject(inspectionData); JSONArray jsonArray = JSONArray.fromObject(inspectionData);
// 1.必填校验 // 1.必填校验
List<String> errorRows = validateRequired(CylinderInspectionFieldEnum.getAllRequireKeys(), jsonArray); List<String> errorRows = validateRequired(CylinderInspectionFieldEnum.getAllRequireKeys(), jsonArray);
...@@ -148,7 +148,7 @@ public class CylinderFillingDataValidationService { ...@@ -148,7 +148,7 @@ public class CylinderFillingDataValidationService {
* @param inspectionData * @param inspectionData
* @return * @return
*/ */
boolean validateCylinderFillingExamineModel(List<TmCylinderFillingExamineModel> inspectionData) { public boolean validateCylinderFillingExamineModel(List<TmCylinderFillingExamineModel> inspectionData) {
JSONArray jsonArray = JSONArray.fromObject(inspectionData); JSONArray jsonArray = JSONArray.fromObject(inspectionData);
// 1.必填校验 // 1.必填校验
List<String> errorRows = validateRequired(CylinderFillingAuditFieldEnum.getAllRequireKeys(), jsonArray); List<String> errorRows = validateRequired(CylinderFillingAuditFieldEnum.getAllRequireKeys(), jsonArray);
...@@ -176,6 +176,18 @@ public class CylinderFillingDataValidationService { ...@@ -176,6 +176,18 @@ public class CylinderFillingDataValidationService {
*/ */
public CylinderFillingDataValidationResultModel validateFilling(JSONObject jsonobject) throws ExecutionException, InterruptedException { public CylinderFillingDataValidationResultModel validateFilling(JSONObject jsonobject) throws ExecutionException, InterruptedException {
CylinderFillingDataValidationResultModel result = new CylinderFillingDataValidationResultModel(); CylinderFillingDataValidationResultModel result = new CylinderFillingDataValidationResultModel();
if (ObjectUtils.isEmpty(jsonobject)) {
throw new BadRequest("上传数据不能为空!!!");
}
if (!jsonobject.containsKey("fillingBefore") || ObjectUtils.isEmpty(jsonobject.get("fillingBefore"))) {
throw new BadRequest("充装前检查数据不能为空!!!");
}
if (!jsonobject.containsKey("filling") || ObjectUtils.isEmpty(jsonobject.get("filling"))) {
throw new BadRequest("充装数据不能为空!!!");
}
if (!jsonobject.containsKey("fillingAfter") || ObjectUtils.isEmpty(jsonobject.get("fillingAfter"))) {
throw new BadRequest("充装后复查数据不能为空!!!");
}
CompletableFuture<List<String>> beforeFuture = CompletableFuture.supplyAsync(() -> { CompletableFuture<List<String>> beforeFuture = CompletableFuture.supplyAsync(() -> {
// 异步校验检验前数据 // 异步校验检验前数据
return validateFillingBeforeData(jsonobject.getJSONArray("fillingBefore")); return validateFillingBeforeData(jsonobject.getJSONArray("fillingBefore"));
......
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