Commit 2f1ffcea authored by 刘凡's avatar 刘凡

修改:修改气瓶同步消息

parent 936a68de
...@@ -2,27 +2,32 @@ package com.yeejoin.amos.api.openapi.controller; ...@@ -2,27 +2,32 @@ package com.yeejoin.amos.api.openapi.controller;
import com.yeejoin.amos.api.common.restful.utils.ResponseHelper; import com.yeejoin.amos.api.common.restful.utils.ResponseHelper;
import com.yeejoin.amos.api.common.restful.utils.ResponseModel; import com.yeejoin.amos.api.common.restful.utils.ResponseModel;
import com.yeejoin.amos.api.openapi.face.dto.CylinderFillingMessage;
import com.yeejoin.amos.api.openapi.face.model.*; import com.yeejoin.amos.api.openapi.face.model.*;
import com.yeejoin.amos.api.openapi.face.service.*; import com.yeejoin.amos.api.openapi.face.service.*;
import com.yeejoin.amos.component.feign.model.FeignClientResult;
import com.yeejoin.amos.feign.privilege.Privilege;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import net.sf.json.JSONObject; import net.sf.json.JSONObject;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import org.typroject.tyboot.component.emq.EmqKeeper;
import org.typroject.tyboot.component.event.RestEventTrigger; import org.typroject.tyboot.component.event.RestEventTrigger;
import org.typroject.tyboot.core.foundation.enumeration.UserType; import org.typroject.tyboot.core.foundation.enumeration.UserType;
import org.typroject.tyboot.core.foundation.utils.ValidationUtil; import org.typroject.tyboot.core.foundation.utils.ValidationUtil;
import org.typroject.tyboot.core.restful.doc.TycloudOperation; import org.typroject.tyboot.core.restful.doc.TycloudOperation;
import org.typroject.tyboot.core.restful.exception.instance.BadRequest; import org.typroject.tyboot.core.restful.exception.instance.BadRequest;
import java.util.HashMap; import java.text.SimpleDateFormat;
import java.util.List; import java.util.*;
import java.util.Map;
@RestController @RestController
@RequestMapping(value = "/cylinder") @RequestMapping(value = "/cylinder")
...@@ -47,6 +52,10 @@ public class CylinderController { ...@@ -47,6 +52,10 @@ public class CylinderController {
private TmCylinderTagsService cylinderTagsService; private TmCylinderTagsService cylinderTagsService;
@Autowired @Autowired
private CylinderFillingDataValidationService cylinderFillingDataValidationService; private CylinderFillingDataValidationService cylinderFillingDataValidationService;
@Autowired
private EmqKeeper emqKeeper;
private SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false) @TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@ApiOperation(value = "气瓶企业信息") @ApiOperation(value = "气瓶企业信息")
...@@ -91,9 +100,43 @@ public class CylinderController { ...@@ -91,9 +100,43 @@ 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 {
AgencyUserModel me = Privilege.agencyUserClient.getme().getResult();
JSONObject jsonobject = JSONObject.fromObject(fillingData); JSONObject jsonobject = JSONObject.fromObject(fillingData);
CylinderFillingDataValidationResultModel validateResult = null;
CylinderFillingMessage cylinderFillingMessage = new CylinderFillingMessage();
cylinderFillingMessage.setTime(simpleDateFormat.format(new Date()));
cylinderFillingMessage.setFillingCompanyName(me.getCompanys().get(0).getCompanyName());
try {
validateResult = cylinderFillingDataValidationService.validateFilling(jsonobject);
} catch (Exception e) {
logger.error("液化气体气瓶充装信息上报,数据校验失败");
cylinderFillingMessage.setMessage(e.getMessage());
}
if (!ObjectUtils.isEmpty(validateResult)) {
cylinderFillingMessage.setCylinderNumber(validateResult.getCylinderNumber());
List<String> message = new ArrayList<>();
Boolean flag = true;
if (!ObjectUtils.isEmpty(validateResult.getBeforeErrorData())) {
flag = false;
message.add("充装前检查异常数:" + validateResult.getBeforeErrorData().size());
}
if (!ObjectUtils.isEmpty(validateResult.getRecordErrorData())) {
flag = false;
message.add("充装记录异常数:" + validateResult.getRecordErrorData().size());
}
if (!ObjectUtils.isEmpty(validateResult.getAfterErrorData())) {
flag = false;
message.add("充装后复查异常数:" + validateResult.getAfterErrorData().size());
}
cylinderFillingDataValidationService.validateFilling(jsonobject); if (flag) {
message.add("液化气体气瓶充装信息上传成功");
}
cylinderFillingMessage.setMessage(String.join(",", message));
}
Map<String, Class> classMap = new HashMap<>(); Map<String, Class> classMap = new HashMap<>();
classMap.put("fillingBefore", TmCylinderFillingModel.class); classMap.put("fillingBefore", TmCylinderFillingModel.class);
...@@ -111,6 +154,8 @@ public class CylinderController { ...@@ -111,6 +154,8 @@ public class CylinderController {
cylinderFillingService.createCylinderFillingBefore(fillingBeforeList); cylinderFillingService.createCylinderFillingBefore(fillingBeforeList);
cylinderFillingRecordService.createCylinderFilling(fillingList); cylinderFillingRecordService.createCylinderFilling(fillingList);
cylinderFillingCheckService.createCylinderFillingAfter(fillingAfterList); cylinderFillingCheckService.createCylinderFillingAfter(fillingAfterList);
emqKeeper.getMqttClient().publish("openapi/cylinder/filling", JSONObject.fromObject(cylinderFillingMessage).toString().getBytes(), 2, false);
return ResponseHelper.buildResponse("OK"); return ResponseHelper.buildResponse("OK");
} }
......
package com.yeejoin.amos.api.openapi.face.dto;
import lombok.Data;
@Data
public class CylinderFillingMessage {
private String time;
private String fillingCompanyName;
private Integer cylinderNumber;
private String message;
}
...@@ -6,6 +6,7 @@ import java.util.List; ...@@ -6,6 +6,7 @@ import java.util.List;
@Data @Data
public class CylinderFillingDataValidationResultModel { public class CylinderFillingDataValidationResultModel {
private Integer cylinderNumber;
private List<String> beforeErrorData; private List<String> beforeErrorData;
private List<String> recordErrorData; private List<String> recordErrorData;
private List<String> afterErrorData; private List<String> afterErrorData;
......
...@@ -19,7 +19,7 @@ public class TmCylinderFillingModel extends AbstractBaseModel{ ...@@ -19,7 +19,7 @@ public class TmCylinderFillingModel extends AbstractBaseModel{
private String isValid; //是否在检验有效期以内,严禁充装超期未检气瓶、非法改装或翻新及报废气瓶 private String isValid; //是否在检验有效期以内,严禁充装超期未检气瓶、非法改装或翻新及报废气瓶
private int same; //警示标签上印有的瓶装气体的名称及化学分子式应与气瓶钢印标志是否一致* private int same; //警示标签上印有的瓶装气体的名称及化学分子式应与气瓶钢印标志是否一致*
private int isRegulations; //气瓶外表面的颜色标志是否符合规定* private int isRegulations; //气瓶外表面的颜色标志是否符合规定*
private int isComplianceWithGBT; //气瓶瓶阀的出气口螺纹型式是否符合GB/T15383的规定,即可燃气体用的瓶阀,出口螺纹应是内螺纹(左旋)* private int isComplianceWithgbt; //气瓶瓶阀的出气口螺纹型式是否符合GB/T15383的规定,即可燃气体用的瓶阀,出口螺纹应是内螺纹(左旋)*
private int haveStillPressure; //气瓶内有无剩余压力* private int haveStillPressure; //气瓶内有无剩余压力*
private int isComplete; //气瓶外表面有无裂纹、严重腐蚀、明显变形及其他严重外部损伤缺陷* private int isComplete; //气瓶外表面有无裂纹、严重腐蚀、明显变形及其他严重外部损伤缺陷*
private int haveSecurityDocuments; //气瓶的安全附件齐全并符合安全要求 private int haveSecurityDocuments; //气瓶的安全附件齐全并符合安全要求
......
package com.yeejoin.amos.api.openapi.face.service; package com.yeejoin.amos.api.openapi.face.service;
import cn.hutool.core.collection.ConcurrentHashSet;
import com.yeejoin.amos.api.openapi.enums.*; import com.yeejoin.amos.api.openapi.enums.*;
import com.yeejoin.amos.api.openapi.face.model.*; import com.yeejoin.amos.api.openapi.face.model.*;
import com.yeejoin.amos.api.openapi.face.orm.dao.MidEquipRegistrationInfoMapper; import com.yeejoin.amos.api.openapi.face.orm.dao.MidEquipRegistrationInfoMapper;
...@@ -184,17 +185,40 @@ public class CylinderFillingDataValidationService { ...@@ -184,17 +185,40 @@ public class CylinderFillingDataValidationService {
if (!jsonobject.containsKey("fillingAfter") || ObjectUtils.isEmpty(jsonobject.get("fillingAfter"))) { if (!jsonobject.containsKey("fillingAfter") || ObjectUtils.isEmpty(jsonobject.get("fillingAfter"))) {
throw new BadRequest("充装后复查数据不能为空!!!"); throw new BadRequest("充装后复查数据不能为空!!!");
} }
Set<String> cylinderCodeSet = new ConcurrentHashSet<>();
CompletableFuture<List<String>> beforeFuture = CompletableFuture.supplyAsync(() -> { CompletableFuture<List<String>> beforeFuture = CompletableFuture.supplyAsync(() -> {
// 异步校验检验前数据 // 异步校验检验前数据
return validateFillingBeforeData(jsonobject.getJSONArray("fillingBefore")); JSONArray fillingBefore = jsonobject.getJSONArray("fillingBefore");
if (!ObjectUtils.isEmpty(fillingBefore)) {
for (int i = 0; i < fillingBefore.size(); i++) {
JSONObject row = fillingBefore.getJSONObject(i);
cylinderCodeSet.add(row.getString("sequenceCode"));
}
}
return validateFillingBeforeData(fillingBefore);
}); });
CompletableFuture<List<String>> recordFuture = CompletableFuture.supplyAsync(() -> { CompletableFuture<List<String>> recordFuture = CompletableFuture.supplyAsync(() -> {
// 异步校验检填充数据 // 异步校验检填充数据
return validateFillingRecordData(jsonobject.getJSONArray("filling")); JSONArray filling = jsonobject.getJSONArray("filling");
if (!ObjectUtils.isEmpty(filling)) {
for (int i = 0; i < filling.size(); i++) {
JSONObject row = filling.getJSONObject(i);
cylinderCodeSet.add(row.getString("sequenceCode"));
}
}
return validateFillingRecordData(filling);
}); });
CompletableFuture<List<String>> afterFuture = CompletableFuture.supplyAsync(() -> { CompletableFuture<List<String>> afterFuture = CompletableFuture.supplyAsync(() -> {
// 异步校验检填充后数据 // 异步校验检填充后数据
JSONArray fillingAfter = jsonobject.getJSONArray("fillingAfter");
if (!ObjectUtils.isEmpty(fillingAfter)) {
for (int i = 0; i < fillingAfter.size(); i++) {
JSONObject row = fillingAfter.getJSONObject(i);
cylinderCodeSet.add(row.getString("sequenceCode"));
}
}
return validateFillinAfterData(jsonobject.getJSONArray("fillingAfter")); return validateFillinAfterData(jsonobject.getJSONArray("fillingAfter"));
}); });
...@@ -205,6 +229,7 @@ public class CylinderFillingDataValidationService { ...@@ -205,6 +229,7 @@ public class CylinderFillingDataValidationService {
result.setBeforeErrorData(beforeFuture.get()); result.setBeforeErrorData(beforeFuture.get());
result.setRecordErrorData(recordFuture.get()); result.setRecordErrorData(recordFuture.get());
result.setAfterErrorData(afterFuture.get()); result.setAfterErrorData(afterFuture.get());
result.setCylinderNumber(cylinderCodeSet.size());
return result; return result;
} }
......
...@@ -167,6 +167,7 @@ public class SyncCylinderDataService { ...@@ -167,6 +167,7 @@ public class SyncCylinderDataService {
} }
@DS("tzs")
public void createCylinderFillingRecord(List<ESCylinderFillingRecordDto> cylinderFillingRecord) { public void createCylinderFillingRecord(List<ESCylinderFillingRecordDto> cylinderFillingRecord) {
if (!ObjectUtils.isEmpty(cylinderFillingRecord)) { if (!ObjectUtils.isEmpty(cylinderFillingRecord)) {
List<String> appIds = cylinderFillingRecord.stream().map(ESCylinderFillingRecordDto::getAppId).collect(Collectors.toList()); List<String> appIds = cylinderFillingRecord.stream().map(ESCylinderFillingRecordDto::getAppId).collect(Collectors.toList());
......
...@@ -33,7 +33,6 @@ public class TmCylinderFillingCheckService extends MyBaseServiceImpl<TmCylinderF ...@@ -33,7 +33,6 @@ public class TmCylinderFillingCheckService extends MyBaseServiceImpl<TmCylinderF
private SyncCylinderDataService syncCylinderDataService; private SyncCylinderDataService syncCylinderDataService;
@DSTransactional @DSTransactional
@Transactional
public void createCylinderFillingAfter(List<TmCylinderFillingCheckModel> model) { public void createCylinderFillingAfter(List<TmCylinderFillingCheckModel> model) {
String appId = getAppId(); String appId = getAppId();
Date now = new Date(); Date now = new Date();
......
...@@ -47,7 +47,6 @@ public class TmCylinderFillingRecordService extends MyBaseServiceImpl<TmCylinder ...@@ -47,7 +47,6 @@ public class TmCylinderFillingRecordService extends MyBaseServiceImpl<TmCylinder
private SyncCylinderDataService syncCylinderDataService; private SyncCylinderDataService syncCylinderDataService;
@DSTransactional @DSTransactional
@Transactional(rollbackFor = Exception.class)
public void createCylinderFilling(List<TmCylinderFillingRecordModel> model) { public void createCylinderFilling(List<TmCylinderFillingRecordModel> model) {
Date now = new Date(); Date now = new Date();
String appId = getAppId(); String appId = getAppId();
...@@ -74,7 +73,7 @@ public class TmCylinderFillingRecordService extends MyBaseServiceImpl<TmCylinder ...@@ -74,7 +73,7 @@ public class TmCylinderFillingRecordService extends MyBaseServiceImpl<TmCylinder
} }
@DS("tzs") @DS("tzs")
private void syncCylinderFilling(List<TmCylinderFillingRecordModel> model) { public void syncCylinderFilling(List<TmCylinderFillingRecordModel> model) {
syncCylinderDataService.syncCylinderFillingRecord(model); syncCylinderDataService.syncCylinderFillingRecord(model);
ArrayList<ESCylinderFillingRecordDto> models = Bean.toModels(model, ESCylinderFillingRecordDto.class); ArrayList<ESCylinderFillingRecordDto> models = Bean.toModels(model, ESCylinderFillingRecordDto.class);
......
...@@ -33,7 +33,6 @@ public class TmCylinderFillingService extends MyBaseServiceImpl<TmCylinderFillin ...@@ -33,7 +33,6 @@ public class TmCylinderFillingService extends MyBaseServiceImpl<TmCylinderFillin
private SyncCylinderDataService syncCylinderDataService; private SyncCylinderDataService syncCylinderDataService;
@DSTransactional @DSTransactional
@Transactional(rollbackFor = {java.lang.Exception.class})
public void createCylinderFillingBefore(List<TmCylinderFillingModel> model) { public void createCylinderFillingBefore(List<TmCylinderFillingModel> model) {
Date now = new Date(); Date now = new Date();
String appId = getAppId(); String appId = getAppId();
......
...@@ -25,6 +25,9 @@ public class CylinderFillingCheck extends BaseEntity { ...@@ -25,6 +25,9 @@ public class CylinderFillingCheck extends BaseEntity {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "气瓶唯一标识码")
private String sequenceCode;
@ApiModelProperty(value = "充装后复查ID") @ApiModelProperty(value = "充装后复查ID")
private String fillingCheckId; private String fillingCheckId;
......
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