| | |
| | | package cn.gistack.sm.sjztmd.service.impl; |
| | | |
| | | import cn.gistack.common.config.MyThreadPoolConfig; |
| | | import cn.gistack.sm.feedback.service.IFeedbackService; |
| | | import cn.gistack.sm.intelligentCall.vo.CallTaskStatistic; |
| | | import cn.gistack.sm.sjztmd.entity.TbAttResBase; |
| | | import cn.gistack.sm.sjztmd.mapper.TbAttResBaseMapper; |
| | | import cn.gistack.sm.sjztmd.service.ITbAttResBaseService; |
| | |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Date; |
| | | import java.util.*; |
| | | import java.util.concurrent.CompletableFuture; |
| | | import java.util.concurrent.ExecutionException; |
| | | import java.util.concurrent.ThreadPoolExecutor; |
| | | |
| | | /** |
| | | * @ClassName AttResBaseServiceImpl |
| | |
| | | |
| | | @Autowired |
| | | private IUserClient userClient; |
| | | |
| | | @Autowired |
| | | private MyThreadPoolConfig myThreadPoolConfig; |
| | | |
| | | /** |
| | | * 查询水库填报详情信息 |
| | |
| | | */ |
| | | @Override |
| | | public boolean updateByGuid(TbAttResBase tbAttResBase) { |
| | | // 设置填报数据表的最终填报状态 |
| | | if (tbAttResBase.getCheckState()!=4) { |
| | | tbAttResBase.setFinalState(0); |
| | | } |
| | | // 查询是否存在 |
| | | TbAttResBase detail = baseMapper.getDetailByGuid(tbAttResBase.getGuid()); |
| | | // 更新审核日志 |
| | |
| | | public boolean auditByGuid(TbAttResBase tbAttResBase) { |
| | | // 查询是否存在 |
| | | TbAttResBase detail = baseMapper.getDetailByGuid(tbAttResBase.getGuid()); |
| | | // 更新审核日志 |
| | | setUpdateCheckLog(detail,tbAttResBase); |
| | | // 更新操作日志 |
| | | setUpdateLog(detail,tbAttResBase); |
| | | // 更新审核日志 |
| | | setUpdateCheckLog(detail,tbAttResBase); |
| | | if (null!=detail){ |
| | | tbAttResBase.setGuid(detail.getGuid()); |
| | | } |
| | | // 驳回情况下将状态修改回0即已填写未提交状态 |
| | | if (tbAttResBase.getCheckState()==3){ |
| | | tbAttResBase.setCheckState(0); |
| | | // 只要一个退回则设置为填写中... |
| | | tbAttResBase.setFinalState(0); |
| | | } |
| | | // 更新数据 |
| | | int i = baseMapper.updateByGuid(tbAttResBase); |
| | | int i = baseMapper.updateById(tbAttResBase); |
| | | if (i>0){ |
| | | // 如果是审核通过需要判断其他报表是否都已填报并审核通过 |
| | | if (tbAttResBase.getCheckState()==2){ |
| | | Boolean flag = baseMapper.getFinalCheckStateByGuid(tbAttResBase.getGuid()); |
| | | if (flag){ |
| | | TbAttResBase tbAttResBase1 = new TbAttResBase(); |
| | | tbAttResBase1.setFinalState(1); |
| | | tbAttResBase1.setGuid(tbAttResBase.getGuid()); |
| | | updateById(tbAttResBase1); |
| | | } |
| | | } |
| | | return true; |
| | | } |
| | | return false; |
| | |
| | | int i = 0; |
| | | if (null!=tbAttResBase.getGuid()){ |
| | | // 更新 |
| | | i = baseMapper.updateByGuid(tbAttResBase); |
| | | i = baseMapper.updateById(tbAttResBase); |
| | | }else { |
| | | tbAttResBase.setCreateTime(new Date()); |
| | | i = baseMapper.insert(tbAttResBase); |
| | | } |
| | | // 返回 |
| | |
| | | fillName = "审核"; |
| | | } |
| | | if (newTbAttResBase.getCheckState()==3){ |
| | | fillName = "退回" + (null==newTbAttResBase.getLog()?"":":" + newTbAttResBase.getLog()); |
| | | fillName = "退回" + (null==newTbAttResBase.getCheckLog()?"":":" + newTbAttResBase.getCheckLog()); |
| | | } |
| | | // 管理员编辑 |
| | | if (newTbAttResBase.getCheckState()==4){ |
| | | fillName = "编辑"; |
| | | newTbAttResBase.setCheckState(oldAbAttResBase.getCheckState()); |
| | | } |
| | | |
| | | // 拼接 |
| | |
| | | newTbAttResBase.setLog(stringBuilder.toString()); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 查询所有水库填报的状态信息 |
| | | * @param resGuid |
| | | * @return |
| | | */ |
| | | @Override |
| | | public List<Map<String, Object>> getAllWaterFillInfoByResGuid(String resGuid) { |
| | | List<Map<String, Object>> list = new ArrayList<>(); |
| | | ThreadPoolExecutor executor = myThreadPoolConfig.threadPoolExecutor(); |
| | | // 查询水库基础填报数据 |
| | | CompletableFuture<List<Map<String,Object>>> tbAttResBaseInfo = getTbAttResBaseInfo("tb_att_res_base",resGuid, executor); |
| | | // 查询水库其他填报数据 |
| | | // CompletableFuture<List<Map<String,Object>>> tbAttResBuildInfo = getTbInfo("tb_att_res_build_info",resGuid,executor); |
| | | CompletableFuture<List<Map<String,Object>>> tbAttResEngBene = getTbInfo("tb_att_res_eng_bene",resGuid,executor); |
| | | CompletableFuture<List<Map<String,Object>>> tbAttResInfomationProject = getTbInfo("tb_att_res_infomation_project",resGuid,executor); |
| | | CompletableFuture<List<Map<String,Object>>> tbAttResMgrSysB = getTbInfo("tb_att_res_mgr_sys_b",resGuid,executor); |
| | | CompletableFuture<List<Map<String,Object>>> tbAttResPowerStation = getTbInfo("tb_att_res_power_station",resGuid,executor); |
| | | CompletableFuture<List<Map<String,Object>>> tbAttResProjectUtilize = getTbInfo("tb_att_res_project_utilize",resGuid,executor); |
| | | CompletableFuture<List<Map<String,Object>>> tbAttResRsbNorspi = getTbInfo("tb_att_res_rsb_norspi",resGuid,executor); |
| | | CompletableFuture<List<Map<String,Object>>> tbAttResRsbSpillway = getTbInfo("tb_att_res_rsb_spillway",resGuid,executor); |
| | | CompletableFuture<List<Map<String,Object>>> tbAttResRsbVerspi = getTbInfo("tb_att_res_rsb_verspi",resGuid,executor); |
| | | CompletableFuture<List<Map<String,Object>>> tbAttResSafetyMonitor = getTbInfo("tb_att_res_safety_monitor",resGuid,executor); |
| | | CompletableFuture<List<Map<String,Object>>> tbAttResStagChar = getTbInfo("tb_att_res_stag_char",resGuid,executor); |
| | | CompletableFuture<List<Map<String,Object>>> tbAttResWaterBlock = getTbInfo("tb_att_res_water_block",resGuid,executor); |
| | | CompletableFuture<List<Map<String,Object>>> tbAttResWaterDelivery = getTbInfo("tb_att_res_water_delivery",resGuid,executor); |
| | | CompletableFuture<List<Map<String,Object>>> tbFileStorageLocation = getTbInfo("tb_file_storage_location",resGuid,executor); |
| | | //等待所有任务执行完成 |
| | | try { |
| | | CompletableFuture.allOf( |
| | | tbAttResBaseInfo, |
| | | tbFileStorageLocation, |
| | | tbAttResEngBene, |
| | | tbAttResInfomationProject, |
| | | tbAttResMgrSysB, |
| | | tbAttResPowerStation, |
| | | tbAttResProjectUtilize, |
| | | tbAttResRsbNorspi, |
| | | tbAttResRsbSpillway, |
| | | tbAttResRsbVerspi, |
| | | tbAttResSafetyMonitor, |
| | | tbAttResStagChar, |
| | | tbAttResWaterBlock, |
| | | tbAttResWaterDelivery).get(); |
| | | // 数据处理 |
| | | list.addAll(tbAttResBaseInfo.get()); |
| | | list.addAll(tbAttResEngBene.get()); |
| | | list.addAll(tbAttResInfomationProject.get()); |
| | | list.addAll(tbAttResMgrSysB.get()); |
| | | list.addAll(tbAttResPowerStation.get()); |
| | | list.addAll(tbAttResProjectUtilize.get()); |
| | | list.addAll(tbAttResRsbNorspi.get()); |
| | | list.addAll(tbAttResRsbSpillway.get()); |
| | | list.addAll(tbAttResRsbVerspi.get()); |
| | | list.addAll(tbAttResSafetyMonitor.get()); |
| | | list.addAll(tbAttResStagChar.get()); |
| | | list.addAll(tbAttResWaterBlock.get()); |
| | | list.addAll(tbAttResWaterDelivery.get()); |
| | | list.addAll(tbFileStorageLocation.get()); |
| | | } catch (InterruptedException e) { |
| | | e.printStackTrace(); |
| | | } catch (ExecutionException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | // 返回 |
| | | return list; |
| | | } |
| | | |
| | | /** |
| | | * 查询水库基础填报数据 |
| | | * @param tableName |
| | | * @param resGuid |
| | | * @param executor |
| | | * @return |
| | | */ |
| | | private CompletableFuture<List<Map<String,Object>>> getTbAttResBaseInfo(String tableName,String resGuid,ThreadPoolExecutor executor){ |
| | | return CompletableFuture.supplyAsync(()->{ |
| | | // 查询所有水库填报的状态信息 |
| | | return baseMapper.getTbAttResBaseInfo(resGuid,tableName); |
| | | },executor); |
| | | } |
| | | |
| | | /** |
| | | * 查询水库其他填报数据 |
| | | * @param tableName |
| | | * @param resGuid |
| | | * @param executor |
| | | * @return |
| | | */ |
| | | private CompletableFuture<List<Map<String,Object>>> getTbInfo(String tableName,String resGuid,ThreadPoolExecutor executor){ |
| | | return CompletableFuture.supplyAsync(()->{ |
| | | // 查询所有水库填报的状态信息 |
| | | List<Map<String, Object>> tbInfo = baseMapper.getTbInfo(resGuid,"\'"+tableName+"'" ,"\""+tableName+"\""); |
| | | if (tbInfo.size()==0){ |
| | | Map<String, Object> map = new HashMap<>(2); |
| | | map.put("NAME",tableName); |
| | | map.put("VALUE",-1); |
| | | tbInfo.add(map); |
| | | } |
| | | return tbInfo; |
| | | },executor); |
| | | } |
| | | |
| | | /** |
| | | * 更新水库信息填报最终状态 |
| | | * @param resGuid 水库编码 |
| | | * @param state 状态值 |
| | | */ |
| | | @Override |
| | | public Boolean updateFinalState(String resGuid, int state) { |
| | | TbAttResBase tbAttResBase = new TbAttResBase(); |
| | | tbAttResBase.setGuid(resGuid); |
| | | if (state==2){ |
| | | // 审核通过,判断是否已全部通过审核 |
| | | Boolean flag = baseMapper.getFinalCheckStateByGuid(resGuid); |
| | | if (flag){ |
| | | tbAttResBase.setFinalState(1); |
| | | }else { |
| | | // 否则判断是否审核中 |
| | | flag = baseMapper.getFinalCheckStateCheckLoadingByGuid(resGuid); |
| | | if (flag){ |
| | | // 设置为审核中 |
| | | tbAttResBase.setFinalState(2); |
| | | }else { |
| | | // 填写中 |
| | | tbAttResBase.setFinalState(0); |
| | | } |
| | | } |
| | | }else { |
| | | tbAttResBase.setFinalState(0); |
| | | } |
| | | //更新 |
| | | return updateById(tbAttResBase); |
| | | } |
| | | } |