Commit cda5ab1d authored by suhuiguang's avatar suhuiguang

1.修改设备停用启用为修改业务数据(设备状态)bug

parent b576a7fa
......@@ -21,8 +21,11 @@ import com.yeejoin.amos.boot.module.jg.biz.feign.TzsServiceFeignClient;
import com.yeejoin.amos.boot.module.jg.biz.service.ICmWorkflowService;
import com.yeejoin.amos.boot.module.jg.biz.service.IIdxBizJgRegisterInfoService;
import com.yeejoin.amos.boot.module.jg.flc.api.fegin.WorkFlowFeignService;
import com.yeejoin.amos.boot.module.ymt.api.entity.IdxBizJgUseInfo;
import com.yeejoin.amos.boot.module.ymt.api.enums.ApplicationFormTypeEnum;
import com.yeejoin.amos.boot.module.ymt.api.enums.EquimentEnum;
import com.yeejoin.amos.boot.module.ymt.api.enums.FlowStatusEnum;
import com.yeejoin.amos.boot.module.ymt.api.mapper.IdxBizJgUseInfoMapper;
import com.yeejoin.amos.boot.module.ymt.api.mapper.RegistrationInfoMapper;
import com.yeejoin.amos.component.feign.model.FeignClientResult;
import com.yeejoin.amos.feign.systemctl.model.TaskV2Model;
......@@ -90,6 +93,19 @@ public class JgEnableDisableServiceImpl extends BaseService<JgEnableDisableDto,
@Autowired
private RedissonClient redissonClient;
@Autowired
private IdxBizJgUseInfoMapper idxBizJgUseInfoMapper;
/**
* 设备状态:启用
*/
public static final String APPLY_TYPE_QY = "SB_QY";
/**
* 设备状态:启用
*/
public static final String APPLY_TYPE_TY = "SB_TY";
@Transactional(rollbackFor = Exception.class)
public List<JgEnableDisable> saveOrUpdate(JSONObject map, ReginParams reginParams) {
JgEnableDisable jgEnableDisable = new JgEnableDisable();
......@@ -230,8 +246,8 @@ public class JgEnableDisableServiceImpl extends BaseService<JgEnableDisableDto,
}
private String getRegistrationClass(JgEnableDisable jgEnableDisable){
// 1启用,0停用
if("1".equals(jgEnableDisable.getApplyType())){
// SB_QY启用,SB_TY停用
if(APPLY_TYPE_QY.equals(jgEnableDisable.getApplyType())){
return BusinessTypeEnum.JG_EQUIPMENT_START.getName();
} else {
return BusinessTypeEnum.JG_EQUIPMENT_STOP.getName();
......@@ -441,6 +457,8 @@ public class JgEnableDisableServiceImpl extends BaseService<JgEnableDisableDto,
TaskMessageDto taskMessageDto = new TaskMessageDto();
BeanUtils.copyProperties(jgEnableDisable, taskMessageDto);
taskMap.put("model", jgEnableDisable);
// 更新业务数据
updateInfoOther(jgEnableDisable);
commonService.updateTaskModel(taskMap);
} else {
jgEnableDisable.setNextExecutorIds(workflowResultDto.getNextExecutorRoleIds());
......@@ -515,7 +533,37 @@ public class JgEnableDisableServiceImpl extends BaseService<JgEnableDisableDto,
}
}
private void updateInfoOther(JgEnableDisable jgEnableDisable) {
// 1.更新设备的使用信息:启用->停用,停用->启用
LambdaQueryWrapper<JgEnableDisableEq> lambdaEq = new QueryWrapper<JgEnableDisableEq>().lambda();
lambdaEq.eq(JgEnableDisableEq::getEnableDisableApplyId, jgEnableDisable.getSequenceNbr());
JgEnableDisableEq jgScrapCancelEq = jgEnableDisableEqMapper.selectOne(lambdaEq);
IdxBizJgUseInfo idxBizJgUseInfo = new IdxBizJgUseInfo();
if(APPLY_TYPE_QY.equals(jgEnableDisable.getApplyType())){
// 1启用
idxBizJgUseInfo.setEquState(String.valueOf(EquimentEnum.ZAIYONG.getCode()));
} else {
// 0停用
idxBizJgUseInfo.setEquState(String.valueOf(EquimentEnum.TINGYONG.getCode()));
}
LambdaQueryWrapper<IdxBizJgUseInfo> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(IdxBizJgUseInfo::getRecord, jgScrapCancelEq.getEquId());
idxBizJgUseInfoMapper.update(idxBizJgUseInfo, wrapper);
// 2.更新设备的es数据的状态:启用->停用,停用->启用
updateEquipEsData(jgScrapCancelEq, idxBizJgUseInfo);
}
private void updateEquipEsData(JgEnableDisableEq jgScrapCancelEq, IdxBizJgUseInfo idxBizJgUseInfo) {
Map<String, Map<String, Object>> resultMap = new HashMap<>();
Map<String, Object> map1 = new HashMap<>();
map1.put("EQU_STATE", idxBizJgUseInfo.getEquState());
resultMap.put(jgScrapCancelEq.getEquId(), map1);
try {
tzsServiceFeignClient.commonUpdateEsDataByIds(resultMap);
} catch (Exception e) {
log.error("更新es失败", e.getCause());
}
}
/**
......
......@@ -263,7 +263,7 @@ public class ReportAnalysisServiceImpl implements IReportAnalysisService {
sourceBuilder.query(boolMust);
sourceBuilder.size(0);
// 由于java api查询的数据为镶套,非便扁平化数据,故将 设备状态 + 监管机构 + 设备种类 + 设备类别+ 设备品种 ,作为分组条件中间用 | 分割,注意顺序 解析时按照此字段顺序解析
Script script = new Script(Script.DEFAULT_SCRIPT_TYPE, Script.DEFAULT_SCRIPT_LANG, "if(doc['EQU_DEFINE_CODE.keyword'].size() != 0){ return doc['EQU_STATE'].value + '|' + doc['ORG_BRANCH_CODE.keyword'].value + '|' + doc['EQU_LIST_CODE'].value + '|' + doc['EQU_CATEGORY_CODE'].value + '|' + doc['EQU_DEFINE_CODE.keyword'].value} else { return doc['EQU_STATE'].value + '|' + doc['ORG_BRANCH_CODE.keyword'].value + '|' + doc['EQU_LIST_CODE'].value + '|' + doc['EQU_CATEGORY_CODE'].value + '|'}", new HashMap<>());
Script script = new Script(Script.DEFAULT_SCRIPT_TYPE, Script.DEFAULT_SCRIPT_LANG, "if(doc['EQU_DEFINE_CODE.keyword'].size() != 0){ return doc['EQU_STATE'].value + '|' + doc['ORG_BRANCH_CODE.keyword'].value + '|' + doc['EQU_LIST_CODE'].value + '|' + doc['EQU_CATEGORY_CODE'].value + '|' + doc['EQU_DEFINE_CODE.keyword'].value} else { return doc['EQU_STATE'].value + '|' + doc['ORG_BRANCH_CODE.keyword'].value + '|' + doc['EQU_LIST_CODE'].value + '|' + doc['EQU_CATEGORY_CODE'].value + '|' + 'no'}", new HashMap<>());
TermsAggregationBuilder aggregation = AggregationBuilders.terms("result").script(script);
sourceBuilder.aggregation(aggregation);
searchRequest.source(sourceBuilder);
......
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