Commit 18c8b218 authored by tianyiming's avatar tianyiming

一码通监管码不生成优化修改

parent 27383f62
......@@ -29,4 +29,8 @@ public class SupervisoryCodeInfo extends BaseEntity {
@ApiModelProperty(value = "使用状态(0-初始,1-已使用,2-未使用)")
@TableField("status")
private String status;
@ApiModelProperty(value = "一码通码生成状态(0-手动生成,1-自动生成)")
@TableField("create_status")
private String createStatus;
}
......@@ -4,6 +4,7 @@ package com.yeejoin.amos.boot.module.tzs.api.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.module.tzs.api.entity.CategoryOtherInfo;
import com.yeejoin.amos.boot.module.tzs.api.entity.EquipmentCategoryData;
import org.typroject.tyboot.core.restful.utils.ResponseModel;
import java.util.LinkedHashMap;
import java.util.List;
......@@ -43,4 +44,6 @@ public interface IEquipmentCategoryService {
EquipmentCategoryData updateEquipmentCategoryData(String id);
List<String> deleteBatch(Map<String, Object> map);
ResponseModel submit(Map<String, Object> map);
}
......@@ -2,7 +2,6 @@ package com.yeejoin.amos.boot.module.tzs.flc.api.feign;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yeejoin.amos.boot.biz.common.feign.FeignConfiguration;
import com.yeejoin.amos.component.feign.model.FeignClientResult;
import org.springframework.cloud.openfeign.FeignClient;
......@@ -40,6 +39,24 @@ public interface IdxFeignService {
/**
* 多表单页提交 数据填报
*/
@RequestMapping(value = "/table/batch/submit", method = RequestMethod.POST)
ResponseModel batchSubmit(@RequestParam(required = false) String taskId,
@RequestParam(required = false) String planInstanceId,
@RequestParam(required = false) String topic,
@RequestParam(required = false) String tableName,
@RequestBody Map<String, Object> kv) throws Exception;
/**
* 多表单页修改数据修改
*/
@RequestMapping(value = "/table/batch/update", method = RequestMethod.POST)
ResponseModel batchUpdate(@RequestParam(required = false) String topic,
@RequestParam(required = false) String tableName,
@RequestBody Map<String, Object> kv) throws Exception;
/**
*更新任务
*/
@RequestMapping(value = "/report/form/updateAmosTask/{taskId}", method = RequestMethod.POST)
......
......@@ -241,6 +241,20 @@ public class EquipmentCategoryController extends BaseController {
}
/**
* 一码通八大类设备数据操作接口
*
* @return
*/
@TycloudOperation(ApiLevel = UserType.AGENCY)
@RequestMapping(value = "/submit", method = RequestMethod.POST)
@ApiOperation(httpMethod = "POST", value = "一码通八大类设备数据操作接口", notes = "一码通八大类设备数据操作接口")
public ResponseModel<Object> submit(@RequestBody Map<String, Object> map) {
return ResponseHelper.buildResponse(equipmentCategoryService.submit(map));
}
@TycloudOperation(ApiLevel = UserType.AGENCY,needAuth = false)
@RequestMapping(value = "/createEquipmentCategoryData", method = RequestMethod.GET)
......
......@@ -27,7 +27,7 @@ public class AmosMqttListener extends EmqxListener {
String msg = JSON.parse(str).toString();
JSONObject jsonObject = JSONObject.parseObject(msg);
String id = jsonObject.get("id").toString();
equipmentCategoryService.createSupervisorCode(null, id);
// equipmentCategoryService.createSupervisorCode(null, id);
// 更新ES
equipmentCategoryService.checkEsData(id);
// 更新一码通总览数据统计表
......
......@@ -45,6 +45,7 @@ import org.elasticsearch.search.sort.SortOrder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.Resource;
import org.springframework.http.HttpStatus;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
......@@ -130,6 +131,15 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
//一码通监督管理表单id
private static final String SUPERVISION_FROM_ID = "1627903532906602497";
//一码通使用信息表单id
private static final String USE_INFO_FROM_ID = "1627903393253056514";
//一码通码自动生成
final static String CREATE = "1";
//一码通码手动输入
final static String NOT_CREATE = "0";
//一码通复制功能url参数key
private static final String COPY_KEY = "stashType";
......@@ -245,7 +255,7 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
//生成码
Map<String, String> codeMap;
synchronized (EquipmentCategoryServiceImpl.class) {
codeMap = creatCode(city, county, equipCategory, record);
codeMap = creatCode(city, county, equipCategory, null,null);
}
if (ObjectUtils.isEmpty(codeMap)) {
return new HashMap<>();
......@@ -463,49 +473,70 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
/**
* 具体生成监管码和电梯96333识别码逻辑
*/
private Map<String, String> creatCode(String city, String county, String equipCategory, String record) {
private synchronized Map<String, String> creatCode(String city, String county, String equipCategory, String code96333,String supervisionCode) {
Map<String, String> resultMap = new HashMap<>();
StringBuilder supervisorCode = new StringBuilder();
StringBuilder elevatorCode = new StringBuilder();
CategoryOtherInfo otherInfo;
// CategoryOtherInfo otherInfo;
CategoryOtherInfo categoryOtherInfo = new CategoryOtherInfo();
String prefix;
//判断是否需要生成96333电梯码
if (equipCategory.startsWith("3") && !XIAN.equals(city)) {
//判断数据是否携带96333电梯码,携带则使用,不携带则生成
if("null".equals(code96333)){
prefix = getPrefix(EquipmentCategoryEnum.XZQHDT.getCode(), city);
//查询未使用的电梯码
categoryOtherInfo = categoryOtherInfoMapper.selectElevatorCode(prefix, EquipmentCategoryEnum.WSY.getCode());
}
if (!ObjectUtils.isEmpty(record)) {
//查询对应record对应数据
otherInfo = categoryOtherInfoMapper.selectOne(new QueryWrapper<CategoryOtherInfo>().eq("RECORD", record));
if (!ObjectUtils.isEmpty(otherInfo)) {
//判断原数据是否存在监管码,存在则用原监管码即可,不存在则生成
if (!ObjectUtils.isEmpty(otherInfo.getSupervisoryCode())) {
supervisorCode = new StringBuilder(otherInfo.getSupervisoryCode());
} else {
String supervisor = createSupervisorCode(city, county, equipCategory);
supervisorCode.append(supervisor);
}
//判断是否是否需要生成96333电梯码、这个record对应的otherInfo不为空
if (equipCategory.startsWith("3") && !XIAN.equals(city)) {
if (!ObjectUtils.isEmpty(otherInfo.getCode())) {
elevatorCode.append(new StringBuilder(otherInfo.getCode()));
} else {
//如果存在未使用的电梯码则启用未使用的否则创建
String elevator = ObjectUtils.isEmpty(categoryOtherInfo) ? createElevatorCode(city, county) : categoryOtherInfo.getCode();
elevatorCode.append(elevator);
resultMap.put("creatStatus",CREATE);
} else {
elevatorCode.append(code96333);
resultMap.put("creatStatus",NOT_CREATE);
}
}
}
} else { // 监管系统申请监管码
//判断原数据是否存在监管码,存在则用原监管码即可,不存在则生成
if("null".equals(supervisionCode)){
String supervisor = createSupervisorCode(city, county, equipCategory);
supervisorCode.append(supervisor);
if (equipCategory.startsWith("3") && !XIAN.equals(city)) {
//如果存在未使用的电梯码则启用未使用的否则创建
String elevator = ObjectUtils.isEmpty(categoryOtherInfo) ? createElevatorCode(city, county) : categoryOtherInfo.getCode();
elevatorCode.append(elevator);
}
} else {
supervisorCode = new StringBuilder(supervisionCode);
}
//
// if (!ObjectUtils.isEmpty(record)) {
// //查询对应record对应数据
// otherInfo = categoryOtherInfoMapper.selectOne(new QueryWrapper<CategoryOtherInfo>().eq("RECORD", record));
// if (!ObjectUtils.isEmpty(otherInfo)) {
// //判断原数据是否存在监管码,存在则用原监管码即可,不存在则生成
// if (!ObjectUtils.isEmpty(otherInfo.getSupervisoryCode())) {
// supervisorCode = new StringBuilder(otherInfo.getSupervisoryCode());
// } else {
// String supervisor = createSupervisorCode(city, county, equipCategory);
// supervisorCode.append(supervisor);
// }
// //判断是否是否需要生成96333电梯码、这个record对应的otherInfo不为空
// if (equipCategory.startsWith("3") && !XIAN.equals(city)) {
// if (!ObjectUtils.isEmpty(otherInfo.getCode())) {
// elevatorCode.append(new StringBuilder(otherInfo.getCode()));
// } else {
// //如果存在未使用的电梯码则启用未使用的否则创建
// String elevator = ObjectUtils.isEmpty(categoryOtherInfo) ? createElevatorCode(city, county) : categoryOtherInfo.getCode();
// elevatorCode.append(elevator);
// }
// }
// }
// } else { // 监管系统申请监管码
// String supervisor = createSupervisorCode(city, county, equipCategory);
// supervisorCode.append(supervisor);
// if (equipCategory.startsWith("3") && !XIAN.equals(city)) {
// //如果存在未使用的电梯码则启用未使用的否则创建
// String elevator = ObjectUtils.isEmpty(categoryOtherInfo) ? createElevatorCode(city, county) : categoryOtherInfo.getCode();
// elevatorCode.append(elevator);
// }
// }
if (ObjectUtils.isEmpty(supervisorCode) && ObjectUtils.isEmpty(elevatorCode)) {
return new HashMap<>();
}
......@@ -912,6 +943,83 @@ public class EquipmentCategoryServiceImpl extends BaseService<EquipmentCategoryD
return records;
}
@Override
public ResponseModel submit(Map<String, Object> map) {
SupervisoryCodeInfo supervisoryCodeInfo = new SupervisoryCodeInfo();
ResponseModel responseModel = new ResponseModel();
try {
LinkedHashMap superviseMap = (LinkedHashMap) map.get("data");
String claimStatus = String.valueOf(superviseMap.get("claimStatus"));
String code96333 = String.valueOf(superviseMap.get("code96333"));
String operateType = String.valueOf(superviseMap.get("operateType"));
//生成码
Map<String, String> codeMap;
if (EquipmentCategoryEnum.YRL.getName().equals(claimStatus)) {
log.info("准备生成监管码或96333电梯识别码");
String city = String.valueOf(superviseMap.get("city"));
String county = String.valueOf(superviseMap.get("county"));
String equCategory = String.valueOf(superviseMap.get("equCategory"));
String supervisionCode = String.valueOf(superviseMap.get("supervisionCode"));
//生成码
codeMap = creatCode(city, county, equCategory, code96333, supervisionCode);
log.info("已生成对应监管码或96333电梯识别码");
SupervisoryCodeInfo selectOne = supervisoryCodeInfoMapper.selectOne(new QueryWrapper<SupervisoryCodeInfo>().eq("supervisory_code", supervisionCode));
//将生成的码添加到码表中,码的使用状态为初始状态
String equState = EquipmentCategoryEnum.CSZT.getCode();
supervisoryCodeInfo.setCode96333(codeMap.get("code96333"));
supervisoryCodeInfo.setCreateStatus(codeMap.get("creatStatus"));
supervisoryCodeInfo.setSupervisoryCode(codeMap.get("superviseCode"));
supervisoryCodeInfo.setStatus(ObjectUtils.isEmpty(selectOne) ? equState : selectOne.getStatus());
if(ObjectUtils.isEmpty(selectOne)){
supervisoryCodeInfoMapper.insert(supervisoryCodeInfo);
} else {
selectOne.setCode96333(codeMap.get("code96333"));
supervisoryCodeInfoMapper.update(selectOne,
new QueryWrapper<SupervisoryCodeInfo>().eq("supervisory_code",selectOne.getSupervisoryCode()));
}
//删除map中的冗余数据,添加对应监管码和96333码调用idx多表单页提交接口吧保存数据
map.remove("data");
LinkedHashMap supervisionMap = (LinkedHashMap) map.get(SUPERVISION_FROM_ID);
supervisionMap.put("CODE96333", codeMap.get("code96333"));
supervisionMap.put("SUPERVISORY_CODE", codeMap.get("superviseCode"));
map.put(SUPERVISION_FROM_ID, supervisionMap);
//根据操作状态判断是调用新增还是修改接口
responseModel = "save".equals(operateType) ? idxFeignService.batchSubmit(null, null, null, null, map) :
idxFeignService.batchUpdate(null, null, map);
if (!ObjectUtils.isEmpty(responseModel) && "200".equals(String.valueOf(responseModel.getStatus()))) {
supervisoryCodeInfo.setStatus(EquipmentCategoryEnum.YSY.getCode());
//todo 更新总览数据
// LinkedHashMap useInfoFrom = (LinkedHashMap) map.get("USE_INFO_FROM_ID");
} else {
supervisoryCodeInfo.setStatus(EquipmentCategoryEnum.BF.getCode());
}
} else if (EquipmentCategoryEnum.DRL.getName().equals(claimStatus)) {
map.remove("data");
LinkedHashMap supervisionMap = (LinkedHashMap) map.get(SUPERVISION_FROM_ID);
supervisionMap.put("CODE96333", code96333);
map.put(SUPERVISION_FROM_ID, supervisionMap);
//根据操作状态判断是调用新增还是修改接口
responseModel = "save".equals(operateType) ? idxFeignService.batchSubmit(null, null, null, null, map) :
idxFeignService.batchUpdate(null, null, map);
} else {
map.remove("data");
responseModel = idxFeignService.batchUpdate(null, null, map);
}
} catch (Exception e) {
supervisoryCodeInfo.setStatus(EquipmentCategoryEnum.BF.getCode());
e.printStackTrace();
ResponseModel<Object> response = new ResponseModel();
response.setResult(null);
response.setMessage("操作失败,请检查数据输入后重新提交");
response.setStatus(HttpStatus.BAD_REQUEST.value());
return response;
} finally {
supervisoryCodeInfoMapper.update(supervisoryCodeInfo,new QueryWrapper<SupervisoryCodeInfo>().eq("supervisory_code",supervisoryCodeInfo.getSupervisoryCode()));
}
return responseModel;
}
//分页查询所有数据
public Page<Map<String, Object>> getAll(Map<String, Object> map) {
......
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