6b764d825a081a657cb753e7566e956e91d4ebeb.svn-base 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359
  1. package cn.com.goldenwater.dcproj.service.impl.other;
  2. import cn.com.goldenwater.dcproj.dao.*;
  3. import cn.com.goldenwater.dcproj.dto.BisInspOtherPblmDto;
  4. import cn.com.goldenwater.dcproj.dto.PersAllDto;
  5. import cn.com.goldenwater.dcproj.model.*;
  6. import cn.com.goldenwater.dcproj.param.*;
  7. import cn.com.goldenwater.dcproj.service.BisInspOtherPblmService;
  8. import cn.com.goldenwater.core.service.AbstractCrudService;
  9. import cn.com.goldenwater.dcproj.service.GwComFileService;
  10. import cn.com.goldenwater.dcproj.utils.BeanUtil;
  11. import cn.com.goldenwater.dcproj.utils.impexcel.ExpAndImpUtil;
  12. import cn.com.goldenwater.id.util.UuidUtil;
  13. import com.github.pagehelper.PageHelper;
  14. import com.github.pagehelper.PageInfo;
  15. import org.apache.commons.lang3.StringUtils;
  16. import org.springframework.beans.factory.annotation.Autowired;
  17. import org.springframework.stereotype.Service;
  18. import org.springframework.transaction.annotation.Transactional;
  19. import java.text.ParseException;
  20. import java.text.SimpleDateFormat;
  21. import java.util.*;
  22. /**
  23. * @author lune
  24. * @date 2019-7-19
  25. */
  26. @Service
  27. @Transactional
  28. public class BisInspOtherPblmServiceImpl extends AbstractCrudService<BisInspOtherPblm, BisInspOtherPblmParam> implements BisInspOtherPblmService {
  29. @Autowired
  30. private BisInspOtherPblmDao bisInspOtherPblmDao;
  31. @Autowired
  32. private AttAdXBaseDao attAdXBaseDao;
  33. @Autowired
  34. private BisInspAllDao bisInspAllDao;
  35. @Autowired
  36. private BisInspOtherRgstrDao rgstrDao;
  37. @Autowired
  38. private BisInspAllObjDao allObjDao;
  39. @Autowired
  40. private AttOtherBaseDao otherBaseDao;
  41. @Autowired
  42. private GwComFileService gwComFileService;
  43. @Autowired
  44. private SupervisionPlanDao supervisionPlanDao;
  45. public BisInspOtherPblmServiceImpl(BisInspOtherPblmDao bisInspOtherPblmDao) {
  46. super(bisInspOtherPblmDao);
  47. this.bisInspOtherPblmDao = bisInspOtherPblmDao;
  48. }
  49. @Override
  50. public int insertIntoData(List<LinkedHashMap<String, Object>> list) {
  51. Map<String, String> areaMap = new HashMap<>();
  52. areaMap.put("黄河流域", "001010");
  53. areaMap.put("长江流域", "001009");
  54. areaMap.put("珠江流域", "001013");
  55. areaMap.put("海河流域", "001012");
  56. areaMap.put("松花江流域", "001014");
  57. areaMap.put("淮河流域", "001011");
  58. areaMap.put("太湖流域", "001015");
  59. Iterator<LinkedHashMap<String, Object>> iterator = list.iterator();
  60. List<BisInspOtherRgstr> otherRgstrs = new ArrayList<>();
  61. List<BisInspOtherPblm> pblms = new ArrayList<>();
  62. while (iterator.hasNext()) {
  63. LinkedHashMap<String, Object> map = iterator.next();
  64. if (StringUtils.isBlank(String.valueOf(map.get("name")))) {
  65. continue;
  66. }
  67. BisInspOtherPblmDto otherPblmDto = null;
  68. try {
  69. otherPblmDto = (BisInspOtherPblmDto) ExpAndImpUtil.convertMapToBean(BisInspOtherPblmDto.class, map);
  70. } catch (Exception e) {
  71. throw new NullPointerException("转换失败");
  72. }
  73. String type = type(otherPblmDto.getType());
  74. if (StringUtils.isBlank(type)) {
  75. continue;
  76. }
  77. String name = otherPblmDto.getName();
  78. String adCode = "";
  79. try {
  80. if (StringUtils.isNotBlank(otherPblmDto.getProvince())) {
  81. adCode = getAdCode(otherPblmDto.getProvince(), "000000000000");
  82. if (StringUtils.isNotBlank(otherPblmDto.getCity())) {
  83. adCode = getAdCode(otherPblmDto.getCity(), adCode);
  84. if (StringUtils.isNotBlank(otherPblmDto.getCountry())) {
  85. adCode = getAdCode(otherPblmDto.getCountry(), adCode);
  86. }
  87. }
  88. }
  89. } catch (Exception e) {
  90. e.printStackTrace();
  91. }
  92. String orgId = "";
  93. if (StringUtils.isNotBlank(otherPblmDto.getOrg())) {
  94. orgId = getOrgId(otherPblmDto.getOrg(), areaMap);
  95. }
  96. if (StringUtils.isNotBlank(otherPblmDto.getPblmNum()) && otherPblmDto.getPblmNum().indexOf(".") > 0) {
  97. otherPblmDto.setPblmNum(otherPblmDto.getPblmNum().substring(0, otherPblmDto.getPblmNum().indexOf(".")));
  98. }
  99. AttOtherBaseParam baseParam = new AttOtherBaseParam();
  100. baseParam.setName(otherPblmDto.getName());
  101. baseParam.setType(type);
  102. AttOtherBase base = otherBaseDao.getBy(baseParam);
  103. if (base == null) {
  104. continue;
  105. }
  106. base.setAdCode(adCode);
  107. base.setAdmOrg(orgId);
  108. otherBaseDao.update(base);
  109. BisInspOtherRgstrParam fscRgstrParam = new BisInspOtherRgstrParam();
  110. fscRgstrParam.setType(type);
  111. fscRgstrParam.setName(name);
  112. List<BisInspOtherRgstr> rgstrs = rgstrDao.findList(fscRgstrParam);
  113. if (rgstrs != null && rgstrs.size() > 1) {
  114. throw new NullPointerException("当前对象有多个");
  115. }
  116. BisInspOtherRgstr rgstr = null;
  117. if (rgstrs == null || rgstrs.size() == 0) {
  118. //查询督查对象表
  119. BisInspAllObjParam param = new BisInspAllObjParam();
  120. param.setNm(otherPblmDto.getName());
  121. param.setPtype("9");
  122. BisInspAllObj obj = allObjDao.getBy(param);
  123. rgstr = new BisInspOtherRgstr();
  124. rgstr.setId(UuidUtil.uuid());
  125. rgstr.setObjId(obj.getObjId());
  126. rgstr.setState("0");
  127. rgstr.setCenterX(obj.getLttd());
  128. rgstr.setCenterY(obj.getLgtd());
  129. rgstr.setType(type);
  130. rgstr.setAdCode(adCode);
  131. rgstr.setInTm(new Date());
  132. rgstr.setUpTm(new Date());
  133. rgstr.setName(obj.getNm());
  134. rgstr.setGroupId(obj.getId());
  135. rgstr.setAdmOrg(orgId);
  136. rgstr.setDataStat("0");
  137. this.rgstrDao.insert(rgstr);
  138. } else {
  139. rgstr = rgstrs.get(0);
  140. rgstr.setAdCode(adCode);
  141. rgstr.setAdmOrg(orgId);
  142. this.rgstrDao.update(rgstr);
  143. }
  144. if (rgstr != null) {
  145. otherRgstrs.add(rgstr);
  146. if (StringUtils.isNotBlank(otherPblmDto.getFdTime())) {
  147. try {
  148. otherPblmDto.setFdTm(new SimpleDateFormat("yyyy-MM-dd").parse(otherPblmDto.getFdTime()));
  149. } catch (ParseException e) {
  150. }
  151. }
  152. if (StringUtils.isNotBlank(otherPblmDto.getRectTime())) {
  153. try {
  154. otherPblmDto.setRectTm(new SimpleDateFormat("yyyy-MM-dd").parse(otherPblmDto.getRectTime()));
  155. } catch (ParseException e) {
  156. }
  157. }
  158. if (StringUtils.isBlank(otherPblmDto.getAUnit()) || StringUtils.isBlank(otherPblmDto.getPblmNum())) {
  159. continue;
  160. }
  161. BisInspOtherPblm pblm = new BisInspOtherPblm(otherPblmDto);
  162. pblm.setPblmIsTrue(pblmIsTrue(otherPblmDto.getPblmIsTrue()));
  163. if (StringUtils.isBlank(pblm.getId())) {
  164. bisInspOtherPblmDao.update(pblm);
  165. } else {
  166. pblm.setId(UuidUtil.uuid());
  167. pblm.setRgstrId(rgstr.getId());
  168. pblm.setGroupId(rgstr.getGroupId());
  169. pblm.setPersId(rgstr.getPersId());
  170. pblm.setInTm(new Date());
  171. pblm.setUpTm(new Date());
  172. pblm.setDataStat("0");
  173. pblms.add(pblm);
  174. }
  175. }
  176. }
  177. if (pblms.size() == 0) {
  178. if (otherRgstrs.size() == 0) {
  179. return 1;
  180. }
  181. return otherRgstrs.size();
  182. }
  183. if (pblms.size() > 0) {
  184. return this.bisInspOtherPblmDao.insertList(pblms);
  185. }
  186. return 0;
  187. }
  188. private String type(String typeName) {
  189. if ("河湖".equals(typeName)) {
  190. return "0";
  191. }
  192. if ("举报调查".equals(typeName)) {
  193. return "1";
  194. }
  195. return "";
  196. }
  197. private String typeName(String type) {
  198. if ("0".equals(type)) {
  199. return "河湖";
  200. }
  201. if ("1".equals(type)) {
  202. return "举报调查";
  203. }
  204. return "";
  205. }
  206. private String pblmIsTrue(String pblmIsTrue) {
  207. if ("不属实".equals(pblmIsTrue)) {
  208. return "0";
  209. }
  210. if ("部分属实".equals(pblmIsTrue)) {
  211. return "1";
  212. }
  213. if ("属实".equals(pblmIsTrue)) {
  214. return "2";
  215. }
  216. return "0";
  217. }
  218. private String revPblmIsTrue(String pblmIsTrue) {
  219. if (StringUtils.isBlank(pblmIsTrue)) {
  220. return "";
  221. }
  222. if ("0".equals(pblmIsTrue)) {
  223. return "不属实";
  224. }
  225. if ("1".equals(pblmIsTrue)) {
  226. return "部分属实";
  227. }
  228. if ("2".equals(pblmIsTrue)) {
  229. return "属实";
  230. }
  231. return "不属实";
  232. }
  233. private String getAdCode(String adName, String adFcode) {
  234. AttAdXBaseParam param = new AttAdXBaseParam();
  235. param.setAdName(adName);
  236. param.setAdFcode(adFcode);
  237. AttAdXBase base = this.attAdXBaseDao.getBy(param);
  238. return base.getAdCode();
  239. }
  240. private String getOrgId(String orgName, Map<String, String> areaMap) {
  241. for (String key : areaMap.keySet()) {
  242. if (key.contains(orgName)) {
  243. return areaMap.get(key);
  244. }
  245. }
  246. return "";
  247. }
  248. @Override
  249. public int updatePblm(BisInspOtherPblm bisInspOtherPblm) {
  250. bisInspOtherPblm.setUpTm(new Date());
  251. bisInspOtherPblmDao.update(bisInspOtherPblm);
  252. gwComFileService.updateBiz(bisInspOtherPblm.getGwComFiles(), bisInspOtherPblm.getId());
  253. return 0;
  254. }
  255. @Override
  256. public List<Map<String, Object>> findPblmList(FileParam param) {
  257. Map<String, String> areaMap = new HashMap<>();
  258. areaMap.put("001010", "黄河流域");
  259. areaMap.put("001009", "长江流域");
  260. areaMap.put("001013", "珠江流域");
  261. areaMap.put("001012", "海河流域");
  262. areaMap.put("001012", "松花江流域");
  263. areaMap.put("001011", "淮河流域");
  264. areaMap.put("001015", "太湖流域");
  265. List<BisInspOtherPblmDto> list = this.bisInspOtherPblmDao.findPblmList(param);
  266. List<Map<String, Object>> pblmList = new ArrayList<>();
  267. if (list.size() > 0) {
  268. int i = 0;
  269. for (BisInspOtherPblmDto b : list) {
  270. b.setNum(String.valueOf(i++));
  271. b.setType(typeName(b.getType()));
  272. b.setPblmIsTrue(revPblmIsTrue(b.getPblmIsTrue()));
  273. if (StringUtils.isNotBlank(b.getOrg())) {
  274. b.setOrg(getOrgId(b.getOrg(), areaMap));
  275. }
  276. if (b.getFdTm() != null) {
  277. b.setFdTime(new SimpleDateFormat("yyyy-MM-dd").format(b.getFdTm()));
  278. }
  279. if (b.getRectTm() != null) {
  280. b.setRectTime(new SimpleDateFormat("yyyy-MM-dd").format(b.getRectTm()));
  281. }
  282. if (StringUtils.isNotBlank(b.getGroupObjId())) {
  283. List<PersAllDto> persAllDtoList = supervisionPlanDao.getPersAllDtoList(b.getGroupObjId(),param.getOrgId(),param.getProvince());
  284. if (persAllDtoList != null) {
  285. String checkLead = "";
  286. String checkMemb = "";
  287. for (PersAllDto per : persAllDtoList) {
  288. if ("1".equals(per.getPersType())) {
  289. checkLead = checkLead + per.getPersName() + ",";
  290. }
  291. if ("2".equals(per.getPersType())) {
  292. checkMemb = checkMemb + per.getPersName() + ",";
  293. }
  294. }
  295. if (checkLead.length() > 0) {
  296. b.setCheckLead(checkLead.substring(0, checkLead.length() - 1));
  297. }
  298. if (checkMemb.length() > 0) {
  299. b.setCheckMemb(checkMemb.substring(0, checkMemb.length() - 1));
  300. }
  301. }
  302. }
  303. if (b.getAdFullName() != null) {
  304. if (b.getAdFullName().contains("-")) {
  305. String[] split = b.getAdFullName().split("-");
  306. if (split.length == 3) {
  307. b.setProvince(split[0]);
  308. b.setCity(split[1]);
  309. b.setCountry(split[2]);
  310. }
  311. if (split.length == 2) {
  312. b.setProvince(split[0]);
  313. b.setCity(split[1]);
  314. b.setCountry("");
  315. }
  316. } else {
  317. b.setProvince(b.getAdFullName());
  318. }
  319. }
  320. pblmList.add(BeanUtil.transBean2Map(b));
  321. }
  322. }
  323. return pblmList;
  324. }
  325. @Override
  326. public PageInfo<BisInspOtherPblm> findPageInfo(BisInspOtherPblmParam bisInspOtherPblmParam){
  327. PageHelper.startPage(bisInspOtherPblmParam.getPageNum(), bisInspOtherPblmParam.getPageSize());
  328. List<BisInspOtherPblm> bisInspFscPblms = bisInspOtherPblmDao.findPageList(bisInspOtherPblmParam);
  329. PageInfo page = new PageInfo(bisInspFscPblms);
  330. return page;
  331. }
  332. }