4c08a8f3f238b7e485123ef02ed527e917cce8a1.svn-base 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279
  1. package cn.com.goldenwater.dcproj.service.impl;
  2. import cn.com.goldenwater.core.service.AbstractCrudService;
  3. import cn.com.goldenwater.dcproj.constValue.BisInspEnum;
  4. import cn.com.goldenwater.dcproj.constValue.SplitValue;
  5. import cn.com.goldenwater.dcproj.constValue.StateEnum;
  6. import cn.com.goldenwater.dcproj.dao.*;
  7. import cn.com.goldenwater.dcproj.dto.BisInspRgstrDto;
  8. import cn.com.goldenwater.dcproj.dto.BisInspWintuRgstrVo;
  9. import cn.com.goldenwater.dcproj.model.*;
  10. import cn.com.goldenwater.dcproj.param.*;
  11. import cn.com.goldenwater.dcproj.service.BisInspObjStrategy;
  12. import cn.com.goldenwater.dcproj.service.BisInspWintuRgstrService;
  13. import cn.com.goldenwater.dcproj.utils.AdLevelUtil;
  14. import cn.com.goldenwater.dcproj.utils.GeoUtil;
  15. import cn.com.goldenwater.dcproj.utils.impexcel.ExpAndImpUtil;
  16. import cn.com.goldenwater.dcproj.utils.impexcel.WintuFieldFromatExp;
  17. import cn.com.goldenwater.id.util.UuidUtil;
  18. import cn.com.goldenwater.util.common.InspPblmUtils;
  19. import com.github.pagehelper.PageHelper;
  20. import com.github.pagehelper.PageInfo;
  21. import org.apache.commons.collections.CollectionUtils;
  22. import org.apache.commons.lang3.StringUtils;
  23. import org.springframework.beans.BeanUtils;
  24. import org.springframework.beans.factory.annotation.Autowired;
  25. import org.springframework.beans.factory.annotation.Value;
  26. import org.springframework.stereotype.Service;
  27. import org.springframework.transaction.annotation.Transactional;
  28. import javax.servlet.http.HttpServletResponse;
  29. import java.io.File;
  30. import java.util.*;
  31. import static cn.com.goldenwater.dcproj.utils.impexcel.field.ExcelFieldLists.bisInspRgstrArrays;
  32. import static cn.com.goldenwater.dcproj.utils.impexcel.field.ExcelFieldLists.bisInspWintuMendLiftArrays;
  33. /**
  34. * @author lune
  35. * @date 2020-7-15
  36. */
  37. @Service
  38. @Transactional(rollbackFor = Exception.class)
  39. public class BisInspWintuRgstrServiceImpl extends AbstractCrudService<BisInspWintuRgstr, BisInspWintuRgstrParam> implements BisInspWintuRgstrService, BisInspObjStrategy {
  40. @Autowired
  41. private BisInspWintuRgstrDao bisInspWintuRgstrDao;
  42. @Autowired
  43. private AttWintBaseDao attWintBaseDao;
  44. @Autowired
  45. private BisInspPblmDao bisInspPblmDao;
  46. @Autowired
  47. private BisInspAllObjDao bisInspAllObjDao;
  48. @Autowired
  49. private BisInspWintRgstrMendLiftDao bisInspWintRgstrMendLiftDao;
  50. @Autowired
  51. private BisInspWintRgstrChkInDao bisInspWintRgstrChkInDao;
  52. @Value("${export.templatePath}")
  53. private String templatePath;
  54. public BisInspWintuRgstrServiceImpl(BisInspWintuRgstrDao bisInspWintuRgstrDao) {
  55. super(bisInspWintuRgstrDao);
  56. this.bisInspWintuRgstrDao = bisInspWintuRgstrDao;
  57. }
  58. public String getAdCode(String regid) {
  59. return null;
  60. }
  61. @Override
  62. public PageInfo<BisInspRgstrDto> findWintuPage(TypeParam param) {
  63. if (StringUtils.isNotBlank(param.getAdCode())) {
  64. param.setAdCode(String.valueOf(AdLevelUtil.SubAd(param.getAdCode()).get(SplitValue.SUBAD)));
  65. }
  66. if (StringUtils.isNotBlank(param.getAdCodes())) {
  67. param.setAdCodes(AdLevelUtil.getListAddvcd(param.getAdCodes()));
  68. }
  69. PageHelper.startPage(param);
  70. List<BisInspRgstrDto> list = bisInspWintuRgstrDao.findWintuPage(param);
  71. list = InspPblmUtils.changeList(list);
  72. return new PageInfo(list);
  73. }
  74. @Override
  75. public PageInfo findObjPageByType(TypeParam typeParam, HttpServletResponse response) {
  76. return this.findWintuPage(typeParam);
  77. }
  78. @Override
  79. public Object findObjListByType(TypeParam typeParam) {
  80. List<BisInspRgstrDto> list = bisInspWintuRgstrDao.findWintuPage(typeParam);
  81. return InspPblmUtils.changeList(list);
  82. }
  83. @Override
  84. public String getType() {
  85. return BisInspEnum.WINTU.getValue();
  86. }
  87. @Override
  88. public void insertObj(BisInspAllObj bisInspAllObj, String persId) {
  89. AttWintBase attWintBase = attWintBaseDao.get(bisInspAllObj.getCode());
  90. BisInspWintuRgstr rgstr = new BisInspWintuRgstr();
  91. BeanUtils.copyProperties(attWintBase, rgstr);
  92. rgstr.setId(UuidUtil.uuid());
  93. rgstr.setWinId(attWintBase.getId());
  94. rgstr.setWinName(attWintBase.getWintName());
  95. rgstr.setObjId(bisInspAllObj.getObjId());
  96. rgstr.setInTm(new Date());
  97. rgstr.setUpTm(new Date());
  98. rgstr.setChkInStat(StateEnum.NOWASTSTATE.getKey());
  99. rgstr.setMendLiftStat(StateEnum.NOWASTSTATE.getKey());
  100. rgstr.setWiuLoc(attWintBase.getWintPos());
  101. rgstr.setCenterX(attWintBase.getWainLong());
  102. rgstr.setCenterY(attWintBase.getWainLat());
  103. if (rgstr.getCenterX() != null && rgstr.getCenterY() != null) {
  104. Map<String, Double> map = GeoUtil.wgs84togcj02(rgstr.getCenterX(), rgstr.getCenterY());
  105. rgstr.setGdX(map.get("lon"));
  106. rgstr.setGdY(map.get("lat"));
  107. }
  108. rgstr.setPersId(persId);
  109. bisInspWintuRgstrDao.insert(rgstr);
  110. }
  111. @Override
  112. public void cleanObjData(String objId) {
  113. BisInspWintuRgstrParam wintuRgstrParam = new BisInspWintuRgstrParam();
  114. wintuRgstrParam.setObjId(objId);
  115. List<BisInspWintuRgstr> list = this.bisInspWintuRgstrDao.findList(wintuRgstrParam);
  116. if (CollectionUtils.isNotEmpty(list)) {
  117. String id = list.get(0).getId();
  118. //删除问题
  119. BisInspPblmParam bisInspPblmParam = new BisInspPblmParam();
  120. bisInspPblmParam.setObjId(objId);
  121. bisInspPblmParam.setObjType(BisInspEnum.WINTU.getValue());
  122. this.bisInspPblmDao.deleteBy(bisInspPblmParam);
  123. //删除对象名录表
  124. BisInspAllObjParam bisInspAllObjParam = new BisInspAllObjParam();
  125. bisInspAllObjParam.setObjId(objId);
  126. this.bisInspAllObjDao.deleteBy(bisInspAllObjParam);
  127. BisInspWintRgstrMendLiftParam mendLiftParam = new BisInspWintRgstrMendLiftParam();
  128. mendLiftParam.setRgstrId(id);
  129. bisInspWintRgstrMendLiftDao.deleteBy(mendLiftParam);
  130. BisInspWintRgstrChkInParam chkInParam = new BisInspWintRgstrChkInParam();
  131. chkInParam.setRgstrId(id);
  132. bisInspWintRgstrChkInDao.deleteBy(chkInParam);
  133. }
  134. }
  135. /**
  136. * 获取取水许可信息
  137. *
  138. * @param id 登记表ID
  139. * @return
  140. */
  141. @Override
  142. public Aqsxkspqk findPermissionInfo(String id) {
  143. return bisInspWintuRgstrDao.findPermissionInfo(id);
  144. }
  145. /**
  146. * 获取问题信息
  147. *
  148. * @param id 登记表ID
  149. * @return
  150. */
  151. @Override
  152. public Aqsxkspqk findIssueInfo(String id) {
  153. return bisInspWintuRgstrDao.findIssueInfo(id);
  154. }
  155. @Override
  156. public void downloadTemplate(HttpServletResponse response, TypeParam param) throws Exception {
  157. List<BisInspWintuRgstrVo> bisInspWintuRgstrVos = new ArrayList();
  158. // 模板路径
  159. String filePath = templatePath + File.separator + "pblmQysdc_tb.xls";
  160. // SHEET名称
  161. String sheetName = "取用水督查填报";
  162. // startRow
  163. int startRow = 2;
  164. if (StringUtils.isBlank(param.getPlnaId())) {
  165. List<Map<String, Object>> list = new ArrayList<>();
  166. ExpAndImpUtil.download(response, list, filePath, startRow, sheetName);
  167. }
  168. List<BisInspRgstrDto> list = bisInspWintuRgstrDao.findWintuPage(param);
  169. list = InspPblmUtils.changeList(list);
  170. for (BisInspRgstrDto bisInspRgstrDto : list) {
  171. BisInspWintuRgstrVo vo = new BisInspWintuRgstrVo();
  172. //登记表
  173. vo.setBisInspRgstrDto(bisInspRgstrDto);
  174. String rgstrId = bisInspRgstrDto.getRgstrId();
  175. //整改提升
  176. BisInspWintRgstrMendLiftParam mendLiftParam = new BisInspWintRgstrMendLiftParam();
  177. mendLiftParam.setRgstrId(rgstrId);
  178. BisInspWintRgstrMendLift mendLift = bisInspWintRgstrMendLiftDao.getBy(mendLiftParam);
  179. vo.setBisInspWintRgstrMendLift(mendLift);
  180. bisInspWintuRgstrVos.add(vo);
  181. }
  182. List<Map<String, Object>> dataList = new LinkedList<>();
  183. for (BisInspWintuRgstrVo vo : bisInspWintuRgstrVos) {
  184. Map<String, Object> map = new HashMap<>();
  185. BisInspRgstrDto bisInspRgstrDto = vo.getBisInspRgstrDto();
  186. ExpAndImpUtil.convertBeanToMap(bisInspRgstrDto, bisInspRgstrArrays, map, WintuFieldFromatExp.class);
  187. //整改提升
  188. BisInspWintRgstrMendLift bisInspWintRgstrMendLift = vo.getBisInspWintRgstrMendLift();
  189. ExpAndImpUtil.convertBeanToMap(bisInspWintRgstrMendLift, bisInspWintuMendLiftArrays, map, WintuFieldFromatExp.class);
  190. dataList.add(map);
  191. }
  192. ExpAndImpUtil.download(response, dataList, filePath, startRow, sheetName);
  193. }
  194. @Override
  195. public void insertIntoData(List<LinkedHashMap<String, Object>> showDataList, FileParam param) throws Exception {
  196. String persId = param.getPersId();
  197. for (LinkedHashMap<String, Object> map : showDataList) {
  198. String rgstrId = "";
  199. BisInspRgstrDto bisInspRgstrDto = (BisInspRgstrDto) ExpAndImpUtil.convertMapToBean(BisInspRgstrDto.class, map);
  200. if (StringUtils.isNotBlank(bisInspRgstrDto.getRgstrId())) {
  201. rgstrId = bisInspRgstrDto.getRgstrId();
  202. BisInspWintuRgstr wintuRgstr = new BisInspWintuRgstr();
  203. BeanUtils.copyProperties(bisInspRgstrDto, wintuRgstr);
  204. wintuRgstr.setPersId(persId);
  205. wintuRgstr.setUpTm(new Date());
  206. wintuRgstr.setId(rgstrId);
  207. bisInspWintuRgstrDao.update(wintuRgstr);
  208. } else {
  209. String id = UuidUtil.uuid();
  210. rgstrId = id;
  211. BisInspWintuRgstr wintuRgstr = new BisInspWintuRgstr();
  212. BeanUtils.copyProperties(bisInspRgstrDto, wintuRgstr);
  213. AttWintBaseParam attWintBaseParam = new AttWintBaseParam();
  214. attWintBaseParam.setWintName(bisInspRgstrDto.getNm());
  215. List<AttWintBase> attWintBases = attWintBaseDao.findList(attWintBaseParam);
  216. if (CollectionUtils.isEmpty(attWintBases)) {
  217. continue;
  218. }
  219. AttWintBase attWintBase = attWintBases.get(0);
  220. BeanUtils.copyProperties(attWintBase, wintuRgstr);
  221. String ObjUuid = UuidUtil.uuid();
  222. BisInspAllObj bisInspAllObj = new BisInspAllObj();
  223. bisInspAllObj.setCode(attWintBase.getId());
  224. bisInspAllObj.setId(param.getGroupId());
  225. bisInspAllObj.setNm(attWintBase.getWintName());
  226. bisInspAllObj.setLgtd(attWintBase.getWainLong());
  227. bisInspAllObj.setLttd(attWintBase.getWainLat());
  228. bisInspAllObj.setObjId(ObjUuid);
  229. bisInspAllObj.setPtype("31");
  230. bisInspAllObjDao.insert(bisInspAllObj);
  231. wintuRgstr.setId(rgstrId);
  232. wintuRgstr.setWinName(bisInspRgstrDto.getNm());
  233. wintuRgstr.setPersId(persId);
  234. wintuRgstr.setInTm(new Date());
  235. wintuRgstr.setUpTm(new Date());
  236. wintuRgstr.setObjId(ObjUuid);
  237. bisInspWintuRgstrDao.insert(wintuRgstr);
  238. }
  239. if (StringUtils.isBlank(rgstrId)) {
  240. continue;
  241. }
  242. BisInspWintRgstrMendLift mendLift = (BisInspWintRgstrMendLift) ExpAndImpUtil.convertMapToBean(BisInspWintRgstrMendLift.class, map);
  243. BisInspWintRgstrMendLiftParam mendLiftParam = new BisInspWintRgstrMendLiftParam();
  244. mendLiftParam.setRgstrId(rgstrId);
  245. List<BisInspWintRgstrMendLift> mendLiftList = bisInspWintRgstrMendLiftDao.findList(mendLiftParam);
  246. if (CollectionUtils.isNotEmpty(mendLiftList)) {
  247. mendLift.setId(mendLiftList.get(0).getId());
  248. mendLift.setUptm(new Date());
  249. mendLift.setRecPersId(persId);
  250. bisInspWintRgstrMendLiftDao.update(mendLift);
  251. } else {
  252. mendLift.setId(UuidUtil.uuid());
  253. mendLift.setUptm(new Date());
  254. mendLift.setIntm(new Date());
  255. mendLift.setRecPersId(persId);
  256. bisInspWintRgstrMendLiftDao.insert(mendLift);
  257. }
  258. }
  259. }
  260. }