3c2b18d5640e0e5a4a656094e39eb3ac2a041995.svn-base 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498
  1. package cn.com.goldenwater.dcproj.service.impl.importex;
  2. import cn.com.goldenwater.core.service.AbstractCrudService;
  3. import cn.com.goldenwater.dcproj.dao.*;
  4. import cn.com.goldenwater.dcproj.dto.BisInspRgstrDto;
  5. import cn.com.goldenwater.dcproj.dto.BisInspSwhsRgstrPcDtoVo;
  6. import cn.com.goldenwater.dcproj.model.*;
  7. import cn.com.goldenwater.dcproj.param.*;
  8. import cn.com.goldenwater.dcproj.service.BisInspSwhsRgstrService;
  9. import cn.com.goldenwater.dcproj.service.ImpDcInfoService;
  10. import cn.com.goldenwater.dcproj.utils.BeanUtil;
  11. import cn.com.goldenwater.dcproj.utils.export.CreateExcelHelper;
  12. import cn.com.goldenwater.dcproj.utils.impexcel.ExpAndImpUtil;
  13. import cn.com.goldenwater.dcproj.utils.impexcel.ImportExcel;
  14. import cn.com.goldenwater.dcproj.utils.impexcel.format.DcSydFieldFormatExp;
  15. import cn.com.goldenwater.dcproj.utils.impexcel.format.DcSydFieldFormatImp;
  16. import cn.com.goldenwater.id.util.UuidUtil;
  17. import org.apache.commons.collections.MapUtils;
  18. import org.apache.commons.lang.ArrayUtils;
  19. import org.apache.commons.lang.StringUtils;
  20. import org.springframework.beans.factory.annotation.Autowired;
  21. import org.springframework.beans.factory.annotation.Value;
  22. import org.springframework.data.redis.core.RedisTemplate;
  23. import org.springframework.stereotype.Service;
  24. import org.springframework.transaction.annotation.Transactional;
  25. import javax.servlet.http.HttpServletResponse;
  26. import java.io.File;
  27. import java.io.IOException;
  28. import java.util.*;
  29. import java.util.stream.Collectors;
  30. import static cn.com.goldenwater.dcproj.utils.export.FieldFormat.formatCheckNull;
  31. import static cn.com.goldenwater.dcproj.utils.export.FieldFormat.formatState;
  32. import static cn.com.goldenwater.dcproj.utils.impexcel.field.ExcelFieldLists.*;
  33. /**
  34. * <p>
  35. * 批量填报
  36. * </p>
  37. *
  38. * @author liyz
  39. * @date 2019/8/14 13:34
  40. **/
  41. @Service
  42. @Transactional(rollbackFor = Exception.class)
  43. public class ImpDcInfoServiceImpl extends AbstractCrudService implements ImpDcInfoService {
  44. @Value("${export.templatePath}")
  45. private String templatePath;
  46. @Autowired
  47. private ImpDcInfoDao impDcInfoDao;
  48. @Autowired
  49. private BisInspAllDao bisInspAllDao;
  50. @Autowired
  51. private CreateExcelHelper createExcelHelper;
  52. @Autowired
  53. private BisInspSwhsRgstrDao bisInspSwhsRgstrDao;
  54. @Autowired
  55. private BisInspSwhsRgstrService bisInspSwhsRgstrService;
  56. @Autowired
  57. private AttSwhsBaseCrrctDao attSwhsBaseCrrctDao;
  58. @Autowired
  59. private BisInspSwhsRgstrSafetyDao bisInspSwhsRgstrSafetyDao;
  60. @Autowired
  61. private BisInspSwhsRgstrMeasuresDao bisInspSwhsRgstrMeasuresDao;
  62. @Autowired
  63. private AttSwhsBaseDao attSwhsBaseDao;
  64. @Autowired
  65. private RedisTemplate redisTemplate;
  66. public ImpDcInfoServiceImpl(ImpDcInfoDao impDcInfoDao) {
  67. super(impDcInfoDao);
  68. this.impDcInfoDao = impDcInfoDao;
  69. }
  70. @Override
  71. public void downloadTemplate(HttpServletResponse response, String userId, String orgType, String orgIds) throws Exception {
  72. // 模板路径
  73. String filePath = templatePath + File.separator + "tbSyd.xls";
  74. // SHEET名称
  75. String sheetName = "水源地填报表";
  76. // 文件名称带后缀
  77. String fileName = sheetName + ".xls";
  78. // startRow
  79. int startRow = 4;
  80. List<BisInspRgstrDto> rgstrList = this.getRgstrList(userId,orgIds);
  81. List<BisInspSwhsRgstrPcDtoVo> dtoVoList = this.getBisDtoVo(rgstrList,userId);
  82. List<Map<String,Object>> dataList = this.getExpDataList(dtoVoList);
  83. ExpAndImpUtil.download(response,dataList,filePath,startRow,sheetName);
  84. }
  85. public List<BisInspSwhsRgstrPcDtoVo> getBisDtoVo(List<BisInspRgstrDto> dataList, String userId) {
  86. List<BisInspSwhsRgstrPcDtoVo> dataListVo = new ArrayList<>();
  87. dataList.forEach(rgstrDto -> {
  88. BisInspSwhsRgstrPcDtoVo bisVo = new BisInspSwhsRgstrPcDtoVo();
  89. // 放入登记表
  90. bisVo.setBisInspSwhsRgstr(this.getBisInspSwhsRgstr(rgstrDto));
  91. // 放入通用登记表
  92. bisVo.setBisInspRgstrDto(rgstrDto);
  93. // 1.基本信息纠错表
  94. // 2.安全保障达标落实情况
  95. bisVo.setBisInspSwhsRgstrSafety(this.getBisInspSwhsRgstrSafety(rgstrDto));
  96. // 3.保护措施监管情况
  97. bisVo.setBisInspSwhsRgstrMeasures(this.getBisInspSwhsRgstrMeasures(rgstrDto));
  98. dataListVo.add(bisVo);
  99. });
  100. return dataListVo;
  101. }
  102. private BisInspSwhsRgstr getBisInspSwhsRgstr(BisInspRgstrDto rgstrDto){
  103. return bisInspSwhsRgstrDao.get(rgstrDto.getRgstrId());
  104. }
  105. private AttSwhsBaseCrrct getAttSwhsBaseCrrct(BisInspRgstrDto rgstrDto,String userId){
  106. CrrctParam crrctParam = new CrrctParam();
  107. crrctParam.setPersId(userId);
  108. crrctParam.setCode(rgstrDto.getCode());
  109. // 根据人员id 和 水源地编码
  110. AttSwhsBaseCrrctParam attSwhsBaseCrrctParam = new AttSwhsBaseCrrctParam();
  111. attSwhsBaseCrrctParam.setSwhsCode(rgstrDto.getCode());
  112. attSwhsBaseCrrctParam.setPersId(userId);
  113. if(StringUtils.isBlank(attSwhsBaseCrrctParam.getSwhsCode())){
  114. return new AttSwhsBaseCrrct();
  115. }else {
  116. AttSwhsBaseCrrct crrct = attSwhsBaseCrrctDao.getBy(attSwhsBaseCrrctParam);
  117. if (crrct == null) {
  118. AttSwhsBase base = attSwhsBaseDao.get(crrctParam.getCode());
  119. crrct = new AttSwhsBaseCrrct();
  120. BeanUtil.copyObject1(base,crrct);
  121. crrct.setId("");
  122. crrct.setSwhsCode(base.getId());
  123. }
  124. return crrct;
  125. }
  126. }
  127. private BisInspSwhsRgstrSafety getBisInspSwhsRgstrSafety(BisInspRgstrDto rgstrDto){
  128. BisInspSwhsRgstrSafetyParam bisInspSwhsRgstrSafetyParam = new BisInspSwhsRgstrSafetyParam();
  129. bisInspSwhsRgstrSafetyParam.setRgstrId(rgstrDto.getId());
  130. if(StringUtils.isBlank(bisInspSwhsRgstrSafetyParam.getRgstrId())){
  131. return new BisInspSwhsRgstrSafety();
  132. }else {
  133. return bisInspSwhsRgstrSafetyDao.getBy(bisInspSwhsRgstrSafetyParam);
  134. }
  135. }
  136. private BisInspSwhsRgstrMeasures getBisInspSwhsRgstrMeasures(BisInspRgstrDto rgstrDto){
  137. BisInspSwhsRgstrMeasuresParam bisInspSwhsRgstrMeasuresParam = new BisInspSwhsRgstrMeasuresParam();
  138. bisInspSwhsRgstrMeasuresParam.setRgstrId(rgstrDto.getId());
  139. if(StringUtils.isBlank(bisInspSwhsRgstrMeasuresParam.getRgstrId())){
  140. return new BisInspSwhsRgstrMeasures();
  141. }else {
  142. return bisInspSwhsRgstrMeasuresDao.getBy(bisInspSwhsRgstrMeasuresParam);
  143. }
  144. }
  145. private List<Map<String,Object>> getExpDataList(List<BisInspSwhsRgstrPcDtoVo> list){
  146. // 把实体类的数据放入到List里去
  147. List<Map<String, Object>> dataList = new LinkedList<>();
  148. for (BisInspSwhsRgstrPcDtoVo bis : list) {
  149. HashMap<String, Object> map = new HashMap<>();
  150. //通用登记表
  151. BisInspRgstrDto bisInspRgstrDto = bis.getBisInspRgstrDto();
  152. // 放入登记表主键
  153. map.put("rgstrId", bisInspRgstrDto.getId());
  154. // 督查组
  155. map.put("groupName", formatCheckNull(bisInspRgstrDto.getUpGroupName()));
  156. // 督查状态
  157. map.put("state", formatState(bisInspRgstrDto.getState()));
  158. // 改成放入登记表
  159. BisInspSwhsRgstr bisInspSwhsRgstr = bis.getBisInspSwhsRgstr();
  160. ExpAndImpUtil.convertBeanToMap(bisInspSwhsRgstr, attSwhsBaseCrrctArrays, map, DcSydFieldFormatExp.class);
  161. // 2.安全保障达标落实情况
  162. BisInspSwhsRgstrSafety bisInspSwhsRgstrSafety = bis.getBisInspSwhsRgstrSafety();
  163. ExpAndImpUtil.convertBeanToMap(bisInspSwhsRgstrSafety, bisInspSwhsRgstrSafetyArrays, map, DcSydFieldFormatExp.class);
  164. // 3.保护措施监管情况
  165. BisInspSwhsRgstrMeasures bisInspSwhsRgstrMeasures = bis.getBisInspSwhsRgstrMeasures();
  166. ExpAndImpUtil.convertBeanToMap(bisInspSwhsRgstrMeasures, bisInspSwhsRgstrMeasuresArrays, map, DcSydFieldFormatExp.class);
  167. dataList.add(map);
  168. }
  169. return dataList;
  170. }
  171. @Override
  172. public Map<String, Object> parseTemplate(String filePath, String userId, String orgType) {
  173. Map<String,Object> map = new HashMap<>();
  174. List<LinkedHashMap<String,Object>> listParse = null;
  175. int startRow = 4;
  176. int endRow = 0;
  177. List<LinkedHashMap<String, Object>> listShow = new ArrayList<>();
  178. try {
  179. // 获取到从Excel里提取到的数据,并已格式化
  180. listParse = ImportExcel.getParseData(filePath,startRow,endRow, DcSydFieldFormatImp.class);
  181. if(listParse.size() > 0){
  182. String cacheId = UuidUtil.uuid();
  183. redisTemplate.opsForList().rightPushAll(cacheId,listParse);
  184. map.put("cacheId",cacheId);
  185. }else{
  186. map.put("cacheId","");
  187. }
  188. listShow = ImportExcel.getShowData(listParse, DcSydFieldFormatExp.class);
  189. // 过滤掉不是此用户的节点
  190. listShow = this.filterNotTreeIdData(listShow, userId, null);
  191. map.put("listParse",listShow);
  192. } catch (IOException e) {
  193. e.printStackTrace();
  194. }
  195. return map;
  196. }
  197. @Override
  198. public String insertTemplateInfo(String cacheId, String userId, String orgType) {
  199. // 从redis里获取到数据
  200. List<LinkedHashMap<String, Object>> listParse = this.getParseDataByRedis(cacheId);
  201. // 过滤掉不是此用户的节点
  202. listParse = this.filterNotTreeIdData(listParse,userId,null);
  203. switch (orgType){
  204. case "013":
  205. return this.insertTemplateInfoSyd(listParse,userId);
  206. default:
  207. return null;
  208. }
  209. }
  210. /**
  211. * 添加入库从模板里获取到的水源地督查信息
  212. */
  213. private String insertTemplateInfoSyd(List<LinkedHashMap<String,Object>> listParse, String userId) {
  214. int successCount = 0;
  215. for (LinkedHashMap<String,Object> lhp : listParse) {
  216. /*
  217. 只对未督查过和督查中的水库进行批量填报
  218. */
  219. try {
  220. String rgstrId = MapUtils.getString(lhp,"rgstrId");
  221. if (StringUtils.isBlank(rgstrId) || rgstrId.length() != 32) {
  222. continue;
  223. }
  224. // 1.修改基础信息表和基础信息纠错表
  225. // 改成修改登记表
  226. this.insertOrUpdateSwhsRgstr(lhp,userId);
  227. // 2.安全保障达标落实情况
  228. this.insertOrUpdateSwhsRgstrSafety(lhp, userId);
  229. // 3.保护措施监管情况
  230. this.insertOrUpdateSwhsRgstrMeasures(lhp, userId);
  231. successCount ++;
  232. } catch (Exception e) {
  233. e.printStackTrace();
  234. }
  235. }
  236. int sumCount = listParse.size();
  237. return " 此次填报共:<b>" + sumCount + "</b>条," +
  238. " 成功<b>" + successCount + "</b>条,失败<b>"+ (sumCount - successCount) + "</b>条";
  239. }
  240. /**
  241. * 只入库一次,只取一次,取完及时删除
  242. */
  243. private List<LinkedHashMap<String,Object>> getParseDataByRedis(String cacheId){
  244. // 取出
  245. List<LinkedHashMap<String,Object>> listParse = redisTemplate.opsForList().range(cacheId, 0, -1);
  246. // 删除
  247. redisTemplate.delete(cacheId);
  248. return listParse;
  249. }
  250. /**
  251. * @see cn.com.goldenwater.dcproj.controller.BisInspSwhsRgstrController#insert(BisInspSwhsRgstr)
  252. */
  253. private void insertOrUpdateSwhsRgstr(LinkedHashMap<String,Object> lhp,String userId) throws InstantiationException, IllegalAccessException {
  254. BisInspSwhsRgstr bisInspSwhsRgstr = (BisInspSwhsRgstr) ExpAndImpUtil.convertMapToBean(BisInspSwhsRgstr.class, lhp);
  255. // 先用登记表id查一下
  256. BisInspSwhsRgstr rgstr = bisInspSwhsRgstrDao.get(MapUtils.getString(lhp,RGSTRID));
  257. bisInspSwhsRgstr.setId(rgstr.getId());
  258. bisInspSwhsRgstr.setObjId(rgstr.getObjId());
  259. bisInspSwhsRgstr.setSwhsId(rgstr.getSwhsId());
  260. bisInspSwhsRgstr.setUpTm(new Date());
  261. bisInspSwhsRgstr.setPersId(userId);
  262. bisInspSwhsRgstr.setGdX(rgstr.getGdX());
  263. bisInspSwhsRgstr.setGdY(rgstr.getGdY());
  264. bisInspSwhsRgstr.setGroupId(rgstr.getGroupId());
  265. if(StringUtils.isNotBlank(bisInspSwhsRgstr.getId())){
  266. bisInspSwhsRgstrService.updateRgstr(bisInspSwhsRgstr);
  267. }
  268. }
  269. /**
  270. * @see cn.com.goldenwater.dcproj.controller.AttSwhsBaseCrrctController#insert(AttSwhsBaseCrrct)
  271. */
  272. private void insertOrUpdateSwhsBaseCrrct(LinkedHashMap<String,Object> lhp,String userId){
  273. try{
  274. // 从导入的Excel里的字段赋值给实体类
  275. AttSwhsBaseCrrct attSwhsBaseCrrct = (AttSwhsBaseCrrct) ExpAndImpUtil.convertMapToBean(AttSwhsBaseCrrct.class, lhp);
  276. // 先用登记表id查一下
  277. BisInspSwhsRgstr rgstr = bisInspSwhsRgstrDao.get(MapUtils.getString(lhp,"rgstrId"));
  278. // 有没有纠错信息
  279. AttSwhsBaseCrrctParam param = new AttSwhsBaseCrrctParam();
  280. param.setSwhsCode(rgstr.getSwhsId());
  281. param.setPersId(userId);
  282. List<AttSwhsBaseCrrct> list = attSwhsBaseCrrctDao.findList(param);
  283. // 总是添加一条纠错到纠错表
  284. attSwhsBaseCrrct.setId(UuidUtil.uuid());
  285. attSwhsBaseCrrct.setPersId(userId);
  286. attSwhsBaseCrrct.setInTm(new Date());
  287. attSwhsBaseCrrct.setUpTm(new Date());
  288. attSwhsBaseCrrctDao.insert(attSwhsBaseCrrct);
  289. // 更新登记表
  290. BeanUtil.copyObject1(attSwhsBaseCrrct, rgstr);
  291. rgstr.setId(rgstr.getId());
  292. if(list.size() > 0){
  293. rgstr.setGdX(list.get(0).getSwhsLongGd());
  294. rgstr.setGdY(list.get(0).getSwhsLatGd());
  295. }
  296. rgstr.setCenterX(attSwhsBaseCrrct.getSwhsLong());
  297. rgstr.setCenterY(attSwhsBaseCrrct.getSwhsLat());
  298. rgstr.setPersId(userId);
  299. bisInspSwhsRgstrDao.update(rgstr);
  300. }catch (Exception e){
  301. e.printStackTrace();
  302. }
  303. }
  304. /**
  305. * @see cn.com.goldenwater.dcproj.controller.BisInspSwhsRgstrSafetyController#insert(BisInspSwhsRgstrSafety)
  306. */
  307. private void insertOrUpdateSwhsRgstrSafety(LinkedHashMap<String,Object> lhp,String userId) throws InstantiationException, IllegalAccessException {
  308. BisInspSwhsRgstrSafety bisInspSwhsRgstrSafety = (BisInspSwhsRgstrSafety) ExpAndImpUtil.convertMapToBean(BisInspSwhsRgstrSafety.class, lhp);
  309. // 新增或更新本表
  310. BisInspSwhsRgstrSafetyParam param = new BisInspSwhsRgstrSafetyParam();
  311. param.setRgstrId(bisInspSwhsRgstrSafety.getRgstrId());
  312. List<BisInspSwhsRgstrSafety> list = bisInspSwhsRgstrSafetyDao.findList(param);
  313. if (list.size() > 0 ){
  314. bisInspSwhsRgstrSafety.setId(list.get(0).getId());
  315. bisInspSwhsRgstrSafety.setUpTm(new Date());
  316. bisInspSwhsRgstrSafety.setRecPersId(userId);
  317. bisInspSwhsRgstrSafetyDao.update(bisInspSwhsRgstrSafety);
  318. }else {
  319. bisInspSwhsRgstrSafety.setInTm(new Date());
  320. bisInspSwhsRgstrSafety.setUpTm(new Date());
  321. bisInspSwhsRgstrSafety.setId(UuidUtil.uuid());
  322. bisInspSwhsRgstrSafety.setRecPersId(userId);
  323. bisInspSwhsRgstrSafetyDao.insert(bisInspSwhsRgstrSafety);
  324. }
  325. // 更新登记表
  326. if (org.apache.commons.lang3.StringUtils.isNotBlank(bisInspSwhsRgstrSafety.getRgstrId())) {
  327. BisInspSwhsRgstr rgstr = bisInspSwhsRgstrDao.get(bisInspSwhsRgstrSafety.getRgstrId());
  328. if (rgstr != null) {
  329. // 判断督查状态
  330. if(StringUtils.isNotBlank(bisInspSwhsRgstrSafety.getIsCoaeattsr().replace("0",""))
  331. && StringUtils.isNotBlank(bisInspSwhsRgstrSafety.getIsFrmsaisasdsam().replace("0",""))
  332. && StringUtils.isNotBlank(bisInspSwhsRgstrSafety.getIsWiqistcs().replace("0",""))
  333. && StringUtils.isNotBlank(bisInspSwhsRgstrSafety.getIsMcpacdar().replace("0",""))
  334. && StringUtils.isNotBlank(bisInspSwhsRgstrSafety.getIsWtpfilyeafrai().replace("0",""))
  335. ){
  336. // 已完成
  337. rgstr.setSafetyStat("2");
  338. }else{
  339. // 未完成
  340. rgstr.setSafetyStat("1");
  341. }
  342. rgstr.setState("2".equals(rgstr.getState()) ? "2" : "1");
  343. bisInspSwhsRgstrDao.update(rgstr);
  344. }
  345. }
  346. }
  347. /**
  348. * @see cn.com.goldenwater.dcproj.controller.BisInspSwhsRgstrMeasuresController#insert(BisInspSwhsRgstrMeasures)
  349. */
  350. private void insertOrUpdateSwhsRgstrMeasures(LinkedHashMap<String,Object> lhp,String userId) throws InstantiationException, IllegalAccessException {
  351. BisInspSwhsRgstrMeasures bisInspSwhsRgstrMeasures = (BisInspSwhsRgstrMeasures) ExpAndImpUtil.convertMapToBean(BisInspSwhsRgstrMeasures.class, lhp);
  352. // 更新本表
  353. BisInspSwhsRgstrMeasuresParam param = new BisInspSwhsRgstrMeasuresParam();
  354. param.setRgstrId(bisInspSwhsRgstrMeasures.getRgstrId());
  355. List<BisInspSwhsRgstrMeasures> list = bisInspSwhsRgstrMeasuresDao.findList(param);
  356. if (list.size() > 0 ){
  357. bisInspSwhsRgstrMeasures.setUpTm(new Date());
  358. bisInspSwhsRgstrMeasures.setId(list.get(0).getId());
  359. bisInspSwhsRgstrMeasures.setRecPersId(userId);
  360. bisInspSwhsRgstrMeasuresDao.update(bisInspSwhsRgstrMeasures);
  361. }else {
  362. bisInspSwhsRgstrMeasures.setInTm(new Date());
  363. bisInspSwhsRgstrMeasures.setUpTm(new Date());
  364. String uuid = UuidUtil.uuid();
  365. bisInspSwhsRgstrMeasures.setId(uuid);
  366. bisInspSwhsRgstrMeasures.setRecPersId(userId);
  367. bisInspSwhsRgstrMeasuresDao.insert(bisInspSwhsRgstrMeasures);
  368. }
  369. // 更新 登记表
  370. if (org.apache.commons.lang3.StringUtils.isNotBlank(bisInspSwhsRgstrMeasures.getRgstrId())) {
  371. BisInspSwhsRgstr rgstr = bisInspSwhsRgstrDao.get(bisInspSwhsRgstrMeasures.getRgstrId());
  372. if (rgstr != null) {
  373. // 判断督查状态
  374. if(StringUtils.isNotBlank(bisInspSwhsRgstrMeasures.getIsTcowqmWtmiafmtr().replace("0",""))
  375. && StringUtils.isNotBlank(bisInspSwhsRgstrMeasures.getIsEowqoms().replace("0",""))
  376. && StringUtils.isNotBlank(bisInspSwhsRgstrMeasures.getIsSwqiowstswrmisar().replace("0",""))
  377. && StringUtils.isNotBlank(bisInspSwhsRgstrMeasures.getIsAmwqiadtfad().replace("0",""))
  378. && StringUtils.isNotBlank(bisInspSwhsRgstrMeasures.getIsPzfdwsad().replace("0",""))
  379. && StringUtils.isNotBlank(bisInspSwhsRgstrMeasures.getIsEcgbacws().replace("0",""))
  380. && StringUtils.isNotBlank(bisInspSwhsRgstrMeasures.getIsHasProject().replace("0",""))
  381. && StringUtils.isNotBlank(bisInspSwhsRgstrMeasures.getIsHasIwba().replace("0",""))
  382. ){
  383. // 已完成
  384. rgstr.setMeasuresStat("2");
  385. }else{
  386. // 未完成
  387. rgstr.setMeasuresStat("1");
  388. }
  389. rgstr.setState("2".equals(rgstr.getState()) ? "2" : "1");
  390. bisInspSwhsRgstrDao.update(rgstr);
  391. }
  392. }
  393. }
  394. /**
  395. * 过滤掉findList不是此用户下的此节点的数据
  396. */
  397. private List<LinkedHashMap<String,Object>> filterNotTreeIdData(List<LinkedHashMap<String,Object>> listParse, String userId, String orgIds) {
  398. List<BisInspRgstrDto> rgstrList = this.getRgstrList(userId,orgIds);
  399. Object[] rgstrIds = rgstrList.stream().map(BisInspRgstrDto::getRgstrId).toArray();
  400. if (listParse == null) {
  401. return new ArrayList<>();
  402. } else {
  403. listParse = listParse.stream().filter(x -> ArrayUtils.contains(rgstrIds,MapUtils.getString(x,"rgstrId"))).collect(Collectors.toList());
  404. }
  405. return listParse;
  406. }
  407. private List<BisInspRgstrDto> getRgstrList(String userId,String orgIds){
  408. // 导出参数
  409. TypeParam typeParam = new TypeParam();
  410. typeParam.setpType("13");
  411. typeParam.setPresId(userId);
  412. // 0未督查 1督查中 2已督查
  413. typeParam.setState("1,0");
  414. typeParam.setGroupId(orgIds);
  415. return bisInspSwhsRgstrDao.findSwhsPage(typeParam);
  416. }
  417. }