Commit 6d824f6e authored by wanghao's avatar wanghao

1液化气-燃气用户外部接口开发-开发中

parent a9ce7ee1
......@@ -1829,12 +1829,10 @@ public class lpgGasController {
for (JSONObject object : list) {
lpgDeliveryRecord = new TLpgDeliveryRecord();
JSONObject jsonObject = object;
// 气瓶条码不许为空
String bottleCode = jsonObject.getString("bottleCode");
String bottleCode = object.getString("bottleCode");
if (StringUtils.isBlank(bottleCode)) {
lpgThirdPartyDockingInterfaceRecord = errorRecord("createLpgDeliveryRecord", jsonObject.toJSONString(),
lpgThirdPartyDockingInterfaceRecord = errorRecord("createLpgDeliveryRecord", object.toJSONString(),
"气瓶条码不许为空!!!", encryption.getQybm());
lpgThirdPartyDockingInterfaceRecords.add(lpgThirdPartyDockingInterfaceRecord);
errorNum++;
......@@ -1842,7 +1840,7 @@ public class lpgGasController {
}
if (bottleCode.length() > 255) {
lpgThirdPartyDockingInterfaceRecord = errorRecord("createLpgDeliveryRecord", jsonObject.toJSONString(),
lpgThirdPartyDockingInterfaceRecord = errorRecord("createLpgDeliveryRecord", object.toJSONString(),
"气瓶条码不符合要求!!!", encryption.getQybm());
lpgThirdPartyDockingInterfaceRecords.add(lpgThirdPartyDockingInterfaceRecord);
errorNum++;
......@@ -1850,10 +1848,10 @@ public class lpgGasController {
}
// 用户自有编号 可以为空 为空时 就不关联 燃气用户了
String userOwnId = jsonObject.getString("userOwnId") == null ? "" : jsonObject.getString("userOwnId");
String userOwnId = object.getString("userOwnId") == null ? "" : object.getString("userOwnId");
if (userOwnId.length() > 50) {
lpgThirdPartyDockingInterfaceRecord = errorRecord("createLpgDeliveryRecord", jsonObject.toJSONString(),
lpgThirdPartyDockingInterfaceRecord = errorRecord("createLpgDeliveryRecord", object.toJSONString(),
"用户自有编号不符合要求!!!", encryption.getQybm());
lpgThirdPartyDockingInterfaceRecords.add(lpgThirdPartyDockingInterfaceRecord);
errorNum++;
......@@ -1861,11 +1859,11 @@ public class lpgGasController {
}
// 储备站 可以为空
String stationName = jsonObject.getString("stationName") == null ? "" : jsonObject.getString("stationName");
String stationName = object.getString("stationName") == null ? "" : object.getString("stationName");
if (stationName.length() > 64) {
lpgThirdPartyDockingInterfaceRecord = errorRecord("createLpgDeliveryRecord", jsonObject.toJSONString(),
lpgThirdPartyDockingInterfaceRecord = errorRecord("createLpgDeliveryRecord", object.toJSONString(),
"储备站不符合要求!!!", encryption.getQybm());
lpgThirdPartyDockingInterfaceRecords.add(lpgThirdPartyDockingInterfaceRecord);
errorNum++;
......@@ -1873,11 +1871,11 @@ public class lpgGasController {
}
// 配送人员 可以为空
String deliveryPerson = jsonObject.getString("deliveryPerson") == null ? "" : jsonObject.getString("deliveryPerson");
String deliveryPerson = object.getString("deliveryPerson") == null ? "" : object.getString("deliveryPerson");
if (deliveryPerson.length() > 20) {
lpgThirdPartyDockingInterfaceRecord = errorRecord("createLpgDeliveryRecord", jsonObject.toJSONString(),
lpgThirdPartyDockingInterfaceRecord = errorRecord("createLpgDeliveryRecord", object.toJSONString(),
"储备站不符合要求!!!", encryption.getQybm());
lpgThirdPartyDockingInterfaceRecords.add(lpgThirdPartyDockingInterfaceRecord);
errorNum++;
......@@ -1885,11 +1883,11 @@ public class lpgGasController {
}
// 车辆代码 可以为空
String vehicleCode = jsonObject.getString("vehicleCode") == null ? "" : jsonObject.getString("vehicleCode");
String vehicleCode = object.getString("vehicleCode") == null ? "" : object.getString("vehicleCode");
if (vehicleCode.length() > 50) {
lpgThirdPartyDockingInterfaceRecord = errorRecord("createLpgDeliveryRecord", jsonObject.toJSONString(),
lpgThirdPartyDockingInterfaceRecord = errorRecord("createLpgDeliveryRecord", object.toJSONString(),
"车辆代码不符合要求!!!", encryption.getQybm());
lpgThirdPartyDockingInterfaceRecords.add(lpgThirdPartyDockingInterfaceRecord);
errorNum++;
......@@ -1897,11 +1895,11 @@ public class lpgGasController {
}
// 用户类型 可以为空
String gasUserType = jsonObject.getString("gasUserType") == null ? "" : jsonObject.getString("gasUserType");
String gasUserType = object.getString("gasUserType") == null ? "" : object.getString("gasUserType");
if (gasUserType.length() > 2) {
lpgThirdPartyDockingInterfaceRecord = errorRecord("createLpgDeliveryRecord", jsonObject.toJSONString(),
lpgThirdPartyDockingInterfaceRecord = errorRecord("createLpgDeliveryRecord", object.toJSONString(),
"用户类型不符合要求!!!", encryption.getQybm());
lpgThirdPartyDockingInterfaceRecords.add(lpgThirdPartyDockingInterfaceRecord);
errorNum++;
......@@ -1910,7 +1908,7 @@ public class lpgGasController {
if (gasUserType.length() > 0 && !"0".equals(gasUserType) && !"1".equals(gasUserType)) {
lpgThirdPartyDockingInterfaceRecord = errorRecord("createLpgDeliveryRecord", jsonObject.toJSONString(),
lpgThirdPartyDockingInterfaceRecord = errorRecord("createLpgDeliveryRecord", object.toJSONString(),
"用户类型不符合要求!!!", encryption.getQybm());
lpgThirdPartyDockingInterfaceRecords.add(lpgThirdPartyDockingInterfaceRecord);
errorNum++;
......@@ -1918,10 +1916,10 @@ public class lpgGasController {
}
// 配送地址 可以为空
String deliveryAddress = jsonObject.getString("deliveryAddress") == null ? "" : jsonObject.getString("deliveryAddress");
String deliveryAddress = object.getString("deliveryAddress") == null ? "" : object.getString("deliveryAddress");
if (deliveryAddress.length() > 50) {
lpgThirdPartyDockingInterfaceRecord = errorRecord("createLpgDeliveryRecord", jsonObject.toJSONString(),
lpgThirdPartyDockingInterfaceRecord = errorRecord("createLpgDeliveryRecord", object.toJSONString(),
"配送地址不符合要求!!!", encryption.getQybm());
lpgThirdPartyDockingInterfaceRecords.add(lpgThirdPartyDockingInterfaceRecord);
errorNum++;
......@@ -1929,10 +1927,10 @@ public class lpgGasController {
}
// 配送时间 可以为空
String deliveryDate = jsonObject.getString("deliveryDate") == null ? "" : jsonObject.getString("deliveryDate");
String deliveryDate = object.getString("deliveryDate") == null ? "" : object.getString("deliveryDate");
if (deliveryDate.length() > 0 && !isValidDate(sdf, deliveryDate)) {
lpgThirdPartyDockingInterfaceRecord = errorRecord("createLpgDeliveryRecord", jsonObject.toJSONString(),
lpgThirdPartyDockingInterfaceRecord = errorRecord("createLpgDeliveryRecord", object.toJSONString(),
"配送时间不符合要求!!!", encryption.getQybm());
lpgThirdPartyDockingInterfaceRecords.add(lpgThirdPartyDockingInterfaceRecord);
errorNum++;
......@@ -2042,10 +2040,108 @@ public class lpgGasController {
return AjaxResult.success(sb.toString());
}
/**
* 封装一个 失败的接口对象
* @return r
*/
/**
* 创建 液化气用户接口
* @return r
*/
@PostMapping("/createLpgLiquefiedGasUser")
public AjaxResult createLpgLiquefiedGasUser(@RequestBody Encryption encryption) {
keyInformation selectkey = decryptService.selectkey(encryption.getQybm());
if (selectkey == null) {
return AjaxResult.error("企业编码不存在!!!");
}
DESEncoder desEncoder = new DESEncoder();
String data = encryption.getData();
String decrypt = desEncoder.decrypt(data, selectkey.getSecretKey());
TEnterpriseInfo tEnterpriseInfo = tEnterpriseInfoMapper.selectTEnterpriseInfoById(selectkey.getEnterpriseId());
if (tEnterpriseInfo == null) {
return AjaxResult.error("监管平台配置企业信息不存在!!!");
}
int successNum = 0;
int errorNum = 0;
if (StringUtils.isNotBlank(decrypt)) {
JSONArray jsonArray = JSON.parseArray(decrypt);
String js = JSONObject.toJSONString(jsonArray, SerializerFeature.WriteClassName);
List<JSONObject> list = JSONObject.parseArray(js, JSONObject.class);
if (list.size() > 500) {
return AjaxResult.error("每次最多处理500条数据");
}
List<TYehuaqiUser> yehuaqiUsers = new ArrayList<>();
TYehuaqiUser yehuaqiUser;
String dateFormat = "yyyy-MM-dd HH:mm:ss";
SimpleDateFormat sdf = new SimpleDateFormat(dateFormat);
// 接口保存记录
List<TLpgThirdPartyDockingInterfaceRecord> lpgThirdPartyDockingInterfaceRecords = new ArrayList<>();
TLpgThirdPartyDockingInterfaceRecord lpgThirdPartyDockingInterfaceRecord;
for (JSONObject object : list) {
yehuaqiUser = new TYehuaqiUser();
String userOwnId = object.getString("userOwnId");
if (StringUtils.isBlank(userOwnId)) {
lpgThirdPartyDockingInterfaceRecord = errorRecord("createLpgDeliveryRecord", object.toJSONString(),
"用户自有编号不许为空!!!", encryption.getQybm());
lpgThirdPartyDockingInterfaceRecords.add(lpgThirdPartyDockingInterfaceRecord);
errorNum++;
continue;
}
if(userOwnId.length() > 50) {
lpgThirdPartyDockingInterfaceRecord = errorRecord("createLpgDeliveryRecord", object.toJSONString(),
"用户自有编号不符合要求!!!", encryption.getQybm());
lpgThirdPartyDockingInterfaceRecords.add(lpgThirdPartyDockingInterfaceRecord);
errorNum++;
continue;
}
// 用户名称
String nickName = object.getString("nickName");
if(StringUtils.isBlank(nickName)) {
lpgThirdPartyDockingInterfaceRecord = errorRecord("createLpgDeliveryRecord", object.toJSONString(),
"用户名称不符合要求!!!", encryption.getQybm());
lpgThirdPartyDockingInterfaceRecords.add(lpgThirdPartyDockingInterfaceRecord);
errorNum++;
continue;
}
}
}
StringBuilder sb = new StringBuilder();
if (errorNum > 0) {
sb.append("成功:").append(successNum).append("条;失败:").append(errorNum).append("条");
return AjaxResult.success(sb.toString());
}
sb.append("成功:").append(successNum).append("条");
return AjaxResult.success(sb.toString());
}
/**
* 封装一个 失败的接口对象
* @return r
*/
private TLpgThirdPartyDockingInterfaceRecord errorRecord(String interfaceName,String receiveData,
String failureReason,String qybm){
......
......@@ -12,10 +12,8 @@ import cn.afterturn.easypoi.excel.ExcelExportUtil;
import cn.afterturn.easypoi.excel.entity.TemplateExportParams;
import com.zehong.common.core.domain.entity.SysUser;
import com.zehong.common.utils.SecurityUtils;
import com.zehong.system.domain.TDetectorUser;
import com.zehong.system.domain.vo.GasUserAndSafetyDeviceVo;
import com.zehong.system.domain.vo.UserManageGasUserExportVo;
import com.zehong.system.domain.vo.UserManageSafetyDeviceExportVo;
import com.zehong.system.domain.vo.YeHuaqiUserManageSafetyDeviceExportVo;
import org.apache.poi.ss.usermodel.Workbook;
import org.springframework.beans.BeanUtils;
......
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