Commit 55ec1018 authored by tianbo's avatar tianbo

设备复制功能

parent 41a8cf52
......@@ -72,7 +72,6 @@ public enum CompanyTypeEnum {
if (ValidationUtil.isEmpty(str)) {
return null;
}
String companyType = null;
List<CompanyTypeEnum> typeList = Lists.newArrayList();
for (CompanyTypeEnum enumOne : CompanyTypeEnum.values()) {
if (str.contains(enumOne.getName())) {
......
......@@ -43,7 +43,6 @@ import org.elasticsearch.search.builder.SearchSourceBuilder;
import org.elasticsearch.search.sort.SortOrder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ObjectUtils;
......@@ -93,12 +92,16 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
private static final String OPERATESAVE = "save";
private static final String OPERATEEDIT = "edit";
// 单位办理类型
private static final String MANAGE_TYPE_UNIT = "unit";
private static final String RECORD = "record";
private static final String RECORD = "RECORD";
private static final String MANAGE_TYPE = "manageType";
private static final String EQU_CODE = "EQU_CODE";
private static final String SEQUENCE_NBR = "SEQUENCE_NBR";
// 新增设备是否复制而来
private static final String IS_COPY = "isCopy";
@Autowired
RestHighLevelClient restHighLevelClient;
......@@ -192,7 +195,7 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
try {
checkEquCodeUniqueness(equipmentInfoForm);
} catch (Exception e) {
return handleError(e, null);
handleError(e, null);
}
// 使用登记按照单位办理除外,其余进行编辑校验
......@@ -205,7 +208,7 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
//操作类型
try {
//保存数据
record = batchSubmitOrUpdate(equipmentClassForm,equipmentInfoForm,equipmentParamsForm);
record = batchSubmitOrUpdate(equipmentClassForm, equipmentInfoForm, equipmentParamsForm);
//保存Es数据
if (!ObjectUtils.isEmpty(record)) {
checkEsData(record);
......@@ -213,7 +216,7 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
} catch (Exception e) {
log.error("操作失败,数据异常: " + e.getMessage(), e);
return handleError(e, record);
handleError(e, record);
}
return ResponseHelper.buildResponse(record);
}
......@@ -233,11 +236,11 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
wrapper.ne(!ObjectUtils.isEmpty(equipmentInfoForm.get(SEQUENCE_NBR)), RegistrationInfo::getSequenceNbr, equipmentInfoForm.get(SEQUENCE_NBR));
Integer count = tzsJgRegistrationInfoMapper.selectCount(wrapper);
if (count > 0) {
throw new RuntimeException("设备代码已存在,请重新输入!");
throw new BadRequest("设备代码已存在,请重新输入!");
}
}
private ResponseModel handleError(Exception e, String record) {
private void handleError(Exception e, String record) {
log.error("处理异常: " + e.getMessage(), e);
//删除数据库数据和ES数据
if (!ObjectUtils.isEmpty(record)) {
......@@ -246,12 +249,7 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
superviseInfoMapper.deleteDataAll(records);
esEquipmentCategory.deleteById(record);
}
ResponseModel<Object> response = new ResponseModel<>();
response.setDevMessage(e.getMessage());
response.setResult(null);
response.setMessage("操作失败,请检查数据输入后重新提交");
response.setStatus(HttpStatus.BAD_REQUEST.value());
return response;
throw new BadRequest(e.getMessage());
}
private void checkForEquipEdit(Object record) {
......@@ -1425,52 +1423,83 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
return "";
}
private String batchSubmitOrUpdate(LinkedHashMap equipmentClassForm,LinkedHashMap equipmentInfoForm,LinkedHashMap equipmentParamsForm) {
private String batchSubmitOrUpdate(LinkedHashMap equipmentClassForm, LinkedHashMap equipmentInfoForm, LinkedHashMap equipmentParamsForm) {
Date date = new Date();
String record = null;
//操作类型
String operateType = ValidationUtil.isEmpty(equipmentInfoForm.get(SEQUENCE_NBR)) ? OPERATESAVE : OPERATEEDIT;
// 设备是否复制而来,复制来的设备走新增
boolean isCopy = !ValidationUtil.isEmpty(equipmentInfoForm.get(IS_COPY));
operateType = isCopy ? OPERATESAVE : operateType;
record = OPERATESAVE.equals(operateType) ? UUID.randomUUID().toString() : equipmentInfoForm.get(RECORD).toString();
// 单位类型
Map<String, Object> companyType = jgInstallationNoticeService.getCompanyType();
String companyTypeStr = companyType.get("companyType").toString();
Map<String, Object> companyInfoMap = jgInstallationNoticeService.getCompanyType();
String companyTypeStr = companyInfoMap.get("companyType").toString();
//使用信息
IdxBizJgUseInfo useInfo = JSON.parseObject(JSON.toJSONString(equipmentInfoForm), IdxBizJgUseInfo.class);
//设计信息
IdxBizJgDesignInfo designInfo = JSON.parseObject(JSON.toJSONString(equipmentInfoForm), IdxBizJgDesignInfo.class);
//制造信息
IdxBizJgFactoryInfo factoryInfo = JSON.parseObject(JSON.toJSONString(equipmentInfoForm), IdxBizJgFactoryInfo.class);
//施工信息
IdxBizJgConstructionInfo constructionInfo = JSON.parseObject(JSON.toJSONString(equipmentInfoForm), IdxBizJgConstructionInfo.class);
//注册登记信息
IdxBizJgRegisterInfo registerInfo = JSON.parseObject(JSON.toJSONString(equipmentInfoForm), IdxBizJgRegisterInfo.class);
//维保备案
IdxBizJgMaintenanceRecordInfo maintenanceRecordInfo = JSON.parseObject(JSON.toJSONString(equipmentInfoForm), IdxBizJgMaintenanceRecordInfo.class);
//监督管理
IdxBizJgSupervisionInfo supervisionInfo = JSON.parseObject(JSON.toJSONString(equipmentInfoForm), IdxBizJgSupervisionInfo.class);
//其他信息
IdxBizJgOtherInfo otherInfo = JSON.parseObject(JSON.toJSONString(equipmentInfoForm), IdxBizJgOtherInfo.class);
//使用信息
useInfo.setRecord(record);
useInfo.setRecDate(date);
useInfo.setDataSource("jg");
useInfo.setSequenceNbr(OPERATESAVE.equals(operateType) ? null : String.valueOf(equipmentInfoForm.get("USEINFO_SEQ")));
if(companyTypeStr.contains(CompanyTypeEnum.USE.getCode()) || companyTypeStr.contains(CompanyTypeEnum.INDIVIDUAL.getCode())) {
useInfo.setUseUnitCreditCode(companyType.get("creditCode").toString());
useInfo.setUseUnitName(companyType.get("companyTypeName").toString());
useInfo.setUseUnitCreditCode(companyInfoMap.get("creditCode").toString());
useInfo.setUseUnitName(companyInfoMap.get("companyTypeName").toString());
}
if (isCopy) {
// 设备状态置空
useInfo.setEquState(null);
// 如果为安改维单位复制设备,则将使用单位信息置空
if (companyTypeStr.equals(CompanyTypeEnum.CONSTRUCTION.getCode())) {
useInfo.setUseUnitCreditCode(null);
useInfo.setUseUnitName(null);
}
// 如果既为安改维单位又是使用单位,则将厂车、起重机械-流动式起重机、压力容器-气瓶安改维单位信息置空
if (companyTypeStr.contains(CompanyTypeEnum.CONSTRUCTION.getCode()) && companyTypeStr.contains(CompanyTypeEnum.USE.getCode())) {
if (!registerInfo.getEquList().equals("5000") && !registerInfo.getEquCategory().equals("4400") && !registerInfo.getEquCategory().equals("2300")){
constructionInfo.setUscUnitCreditCode(null);
constructionInfo.setUscUnitName(null);
}
}
}
idxBizJgUseInfoService.saveOrUpdateData(useInfo);
//设计制造
IdxBizJgDesignInfo designInfo = JSON.parseObject(JSON.toJSONString(equipmentInfoForm), IdxBizJgDesignInfo.class);
//设计信息
designInfo.setRecord(record);
designInfo.setRecDate(date);
designInfo.setSequenceNbr(OPERATESAVE.equals(operateType) ? null : String.valueOf(equipmentInfoForm.get("DESIGNINFO_SEQ")));
iIdxBizJgDesignInfoService.saveOrUpdateData(designInfo);
//制造信息
IdxBizJgFactoryInfo factoryInfo = JSON.parseObject(JSON.toJSONString(equipmentInfoForm), IdxBizJgFactoryInfo.class);
factoryInfo.setRecord(record);
factoryInfo.setRecDate(date);
factoryInfo.setSequenceNbr(OPERATESAVE.equals(operateType) ? null : String.valueOf(equipmentInfoForm.get("FACTORYINFO_SEQ")));
iIdxBizJgFactoryInfoService.saveOrUpdateData(factoryInfo);
//施工信息
JSONObject company = getCompanyType();
String companyName = company.getString("companyName");
String companyCode = company.getString("companyCode").contains("_") ?
company.getString("companyCode").split("_")[1] : company.getString("companyCode");
IdxBizJgConstructionInfo constructionInfo = JSON.parseObject(JSON.toJSONString(equipmentInfoForm), IdxBizJgConstructionInfo.class);
String companyName = companyInfoMap.get("companyName").toString();
String companyCode = companyInfoMap.get("creditCode").toString();
constructionInfo.setRecord(record);
constructionInfo.setRecDate(date);
......@@ -1479,38 +1508,55 @@ public class IdxBizJgRegisterInfoServiceImpl extends BaseService<IdxBizJgRegiste
constructionInfo.setUscUnitName(companyName);
}
if (isCopy) {
if (companyTypeStr.equals(CompanyTypeEnum.USE.getCode()) || companyTypeStr.equals(CompanyTypeEnum.INDIVIDUAL.getCode())) {
constructionInfo.setUscUnitCreditCode(null);
constructionInfo.setUscUnitName(null);
}
// 如果既为安改维单位又是使用单位,则将厂车、起重机械-流动式起重机、压力容器-气瓶安改维单位信息置空
if (companyTypeStr.contains(CompanyTypeEnum.CONSTRUCTION.getCode()) && companyTypeStr.contains(CompanyTypeEnum.USE.getCode())) {
if (registerInfo.getEquList().equals("5000") || registerInfo.getEquCategory().equals("4400") || registerInfo.getEquCategory().equals("2300")){
constructionInfo.setUscUnitCreditCode(null);
constructionInfo.setUscUnitName(null);
}
}
}
constructionInfo.setSequenceNbr(OPERATESAVE.equals(operateType) ? null : String.valueOf(equipmentInfoForm.get("CONSTRUCTIONINFO_SEQ")));
iIdxBizJgConstructionInfoService.saveOrUpdateData(constructionInfo);
//注册登记
// IdxBizJgRegisterInfo equipmentClassRegisterInfo = JSON.parseObject(JSON.toJSONString(equipmentClassForm), IdxBizJgRegisterInfo.class);
IdxBizJgRegisterInfo registerInfo = JSON.parseObject(JSON.toJSONString(equipmentInfoForm), IdxBizJgRegisterInfo.class);
// Bean.copyExistPropertis(equipmentClassRegisterInfo, registerInfo);
registerInfo.setRecord(record);
registerInfo.setRecDate(date);
registerInfo.setRegisterState(this.getRegCode());
registerInfo.setSequenceNbr(OPERATESAVE.equals(operateType) ? null : String.valueOf(equipmentInfoForm.get("REGISTERINFO_SEQ")));
if (isCopy) {
// 使用登记证号置空
registerInfo.setUseOrgCode(null);
}
this.saveOrUpdate(registerInfo);
//维保备案
IdxBizJgMaintenanceRecordInfo maintenanceRecordInfo = JSON.parseObject(JSON.toJSONString(equipmentInfoForm), IdxBizJgMaintenanceRecordInfo.class);
maintenanceRecordInfo.setRecord(record);
maintenanceRecordInfo.setRecDate(date);
maintenanceRecordInfo.setSequenceNbr(OPERATESAVE.equals(operateType) ? null : String.valueOf(equipmentInfoForm.get("MAINTENANCERECORDINFO_SEQ")));
iIdxBizJgMaintenanceRecordInfoService.saveOrUpdateData(maintenanceRecordInfo);
//监督管理
IdxBizJgSupervisionInfo supervisionInfo = JSON.parseObject(JSON.toJSONString(equipmentInfoForm), IdxBizJgSupervisionInfo.class);
supervisionInfo.setRecord(record);
supervisionInfo.setRecDate(date);
supervisionInfo.setSequenceNbr(OPERATESAVE.equals(operateType) ? null : String.valueOf(equipmentInfoForm.get("SUPERVISIONINFO_SEQ")));
iIdxBizJgSupervisionInfoService.saveOrUpdateData(supervisionInfo);
//其他信息
IdxBizJgOtherInfo otherInfo = JSON.parseObject(JSON.toJSONString(equipmentInfoForm), IdxBizJgOtherInfo.class);
otherInfo.setRecord(record);
otherInfo.setRecDate(date);
otherInfo.setSequenceNbr(OPERATESAVE.equals(operateType) ? null : String.valueOf(equipmentInfoForm.get("OTHERINFO_SEQ")));
if (isCopy) {
// 96333码和监管码置空
otherInfo.setCode96333(null);
otherInfo.setSupervisoryCode(null);
}
iIdxBizJgOtherInfoService.saveOrUpdateData(otherInfo);
//检验检测
......
......@@ -6,7 +6,6 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.pagehelper.util.StringUtil;
import com.yeejoin.amos.boot.biz.common.bo.CompanyBo;
......@@ -21,7 +20,6 @@ import com.yeejoin.amos.boot.module.jg.api.entity.JgInstallationNotice;
import com.yeejoin.amos.boot.module.jg.api.entity.JgInstallationNoticeEq;
import com.yeejoin.amos.boot.module.jg.api.enums.BusinessTypeEnum;
import com.yeejoin.amos.boot.module.jg.api.enums.CompanyTypeEnum;
import com.yeejoin.amos.boot.module.jg.api.mapper.CommonMapper;
import com.yeejoin.amos.boot.module.jg.api.mapper.JgInstallationNoticeEqMapper;
import com.yeejoin.amos.boot.module.jg.api.mapper.JgInstallationNoticeMapper;
import com.yeejoin.amos.boot.module.jg.api.mapper.JgUseRegistrationMapper;
......@@ -38,10 +36,7 @@ import com.yeejoin.amos.boot.module.ymt.api.enums.ApplicationFormTypeEnum;
import com.yeejoin.amos.boot.module.ymt.api.enums.EquCodeTypeEnum;
import com.yeejoin.amos.boot.module.ymt.api.enums.FlowStatusEnum;
import com.yeejoin.amos.boot.module.ymt.api.mapper.*;
import com.yeejoin.amos.component.feign.utils.FeignUtil;
import com.yeejoin.amos.component.robot.AmosRequestContext;
import com.yeejoin.amos.feign.privilege.Privilege;
import com.yeejoin.amos.feign.privilege.model.CompanyModel;
import com.yeejoin.amos.feign.systemctl.model.TaskV2Model;
import com.yeejoin.amos.feign.workflow.model.ActWorkflowBatchDTO;
import com.yeejoin.amos.feign.workflow.model.ActWorkflowStartDTO;
......@@ -1157,8 +1152,12 @@ public class JgInstallationNoticeServiceImpl extends BaseService<JgInstallationN
return null;
}
CompanyBo currentCompany = reginParams.getCompany();
result.put("companyName", currentCompany.getCompanyName());
result.put("orgCode", currentCompany.getOrgCode());
result.put("creditCode", currentCompany.getCompanyCode().contains("_") ? currentCompany.getCompanyCode().split("_")[1] : currentCompany.getCompanyCode());
// 单位级别
String companyLevel = CompanyTypeEnum.decideCompanyLevel(currentCompany.getCompanyType());
// 单位类型
String companyType = CompanyTypeEnum.decideCompanyCode(currentCompany.getCompanyType());
String companyTypeName = CompanyTypeEnum.decideCompanyType(currentCompany.getCompanyType());
if (!ValidationUtil.isEmpty(companyLevel)) {
......
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