78c9fa3b8de7c6d88721e5f3808a9017fab847cd.svn-base 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  1. package cn.com.goldenwater.dcproj.service.impl.rsml;
  2. import cn.com.goldenwater.core.service.AbstractCrudService;
  3. import cn.com.goldenwater.dcproj.constValue.BisInspEnum;
  4. import cn.com.goldenwater.dcproj.constValue.RsvrEnum;
  5. import cn.com.goldenwater.dcproj.constValue.SplitValue;
  6. import cn.com.goldenwater.dcproj.constValue.StateEnum;
  7. import cn.com.goldenwater.dcproj.dao.*;
  8. import cn.com.goldenwater.dcproj.dto.BisInspRgstrDto;
  9. import cn.com.goldenwater.dcproj.dto.BisInspRsmlRgstrDto;
  10. import cn.com.goldenwater.dcproj.model.AttRsBase;
  11. import cn.com.goldenwater.dcproj.model.BisInspAllObj;
  12. import cn.com.goldenwater.dcproj.model.BisInspRsmlRgstr;
  13. import cn.com.goldenwater.dcproj.param.*;
  14. import cn.com.goldenwater.dcproj.service.BisInspObjStrategy;
  15. import cn.com.goldenwater.dcproj.service.BisInspRsmlRgstrService;
  16. import cn.com.goldenwater.dcproj.utils.AdLevelUtil;
  17. import cn.com.goldenwater.id.util.UuidUtil;
  18. import com.github.pagehelper.PageHelper;
  19. import com.github.pagehelper.PageInfo;
  20. import org.apache.commons.lang3.StringUtils;
  21. import org.springframework.beans.factory.annotation.Autowired;
  22. import org.springframework.stereotype.Service;
  23. import org.springframework.transaction.annotation.Transactional;
  24. import javax.servlet.http.HttpServletResponse;
  25. import java.util.Date;
  26. import java.util.List;
  27. import java.util.Optional;
  28. /**
  29. * @author lune
  30. * @date 2020-3-9
  31. */
  32. @Service
  33. @Transactional
  34. public class BisInspRsmlRgstrServiceImpl extends AbstractCrudService<BisInspRsmlRgstr, BisInspRsmlRgstrParam> implements BisInspRsmlRgstrService, BisInspObjStrategy {
  35. @Autowired
  36. private BisInspRsmlRgstrDao bisInspRsmlRgstrDao;
  37. @Autowired
  38. private BisInspAllObjDao bisInspAllObjDao;
  39. @Autowired
  40. private AttRsBaseDao attRsBaseDao;
  41. @Autowired
  42. private BisInspRsmlRgstrProjectDao bisInspRsmlRgstrProjectDao;
  43. @Autowired
  44. private BisInspRsmlRgstrRunManageDao bisInspRsmlRgstrRunManageDao;
  45. @Autowired
  46. private BisInspRsmlRgstrPresDao bisInspRsmlRgstrPresDao;
  47. public BisInspRsmlRgstrServiceImpl(BisInspRsmlRgstrDao bisInspRsmlRgstrDao) {
  48. super(bisInspRsmlRgstrDao);
  49. this.bisInspRsmlRgstrDao = bisInspRsmlRgstrDao;
  50. }
  51. @Override
  52. public BisInspRsmlRgstr getBy(BisInspRsmlRgstrParam param) {
  53. BisInspRsmlRgstr rgstr = super.getBy(param);
  54. Optional.ofNullable(rgstr).map(BisInspRsmlRgstr::getObjId).ifPresent(objId -> {
  55. AttRsBase base = attRsBaseDao.getObjId(objId);
  56. Optional.ofNullable(base).map(AttRsBase::getCompDateStr).ifPresent(rgstr::setCompDateStr);
  57. });
  58. return rgstr;
  59. }
  60. @Override
  61. public void insertObj(BisInspAllObj bisInspAllObj, String persId) {
  62. AttRsBaseParam baseParam = new AttRsBaseParam();
  63. baseParam.setRsCode(bisInspAllObj.getCode());
  64. AttRsBase attRsBase = attRsBaseDao.getBy(baseParam);
  65. BisInspRsmlRgstr rgstr = new BisInspRsmlRgstr();
  66. rgstr.setId(UuidUtil.uuid());
  67. rgstr.setObjId(bisInspAllObj.getObjId());
  68. rgstr.setRsCode(attRsBase.getRsCode());
  69. rgstr.setRsName(bisInspAllObj.getNm());
  70. rgstr.setAdCode(attRsBase.getAdmDiv());
  71. rgstr.setOrgId(bisInspAllObj.getOrgId());
  72. rgstr.setRsAdmCode(attRsBase.getRsAdmCode());
  73. rgstr.setRsAdmName(attRsBase.getRsAdmName());
  74. rgstr.setDamSizeHig(attRsBase.getDamSizeHig());
  75. rgstr.setEngScal(attRsBase.getEngScal());
  76. rgstr.setLocation(attRsBase.getLocation());
  77. rgstr.setDamType(attRsBase.getDamType());
  78. rgstr.setTotCap(attRsBase.getTotCap());
  79. rgstr.setDesFlStag(attRsBase.getDesFlStag());
  80. rgstr.setImpdDt(attRsBase.getImpdDt());
  81. rgstr.setRnfcImpdDt(attRsBase.getRnfcImpdDt());
  82. rgstr.setResCreateTime(attRsBase.getCompDate());
  83. rgstr.setPresState(StateEnum.NOWASTSTATE.getKey());
  84. rgstr.setProjectState(StateEnum.NOWASTSTATE.getKey());
  85. rgstr.setRunManageState(StateEnum.NOWASTSTATE.getKey());
  86. rgstr.setSafeStat(StateEnum.NOWASTSTATE.getKey());
  87. rgstr.setHasDamRegCode("1");
  88. rgstr.setDamRegCode(attRsBase.getRegCode());
  89. rgstr.setHystSite(attRsBase.getRsLoc());
  90. if (attRsBase.getCenterX() != null) {
  91. rgstr.setCenterX(Double.parseDouble(attRsBase.getCenterX()));
  92. }
  93. if (attRsBase.getCenterY() != null) {
  94. rgstr.setCenterY(Double.parseDouble(attRsBase.getCenterY()));
  95. }
  96. if (attRsBase.getCenterXGd() != null) {
  97. rgstr.setGdX(Double.parseDouble(attRsBase.getCenterXGd()));
  98. }
  99. if (attRsBase.getCenterYGd() != null) {
  100. rgstr.setGdY(Double.parseDouble(attRsBase.getCenterYGd()));
  101. }
  102. rgstr.setRsClass(attRsBase.getRsClass());
  103. rgstr.setState(StateEnum.NOWASTSTATE.getKey());
  104. Date date = new Date();
  105. rgstr.setIntm(date);
  106. rgstr.setUptm(date);
  107. bisInspRsmlRgstrDao.insert(rgstr);
  108. }
  109. @Override
  110. public String getType() {
  111. return BisInspEnum.RSML.getValue();
  112. }
  113. @Override
  114. public void cleanObjData(String objId) {
  115. BisInspRsmlRgstrParam param = new BisInspRsmlRgstrParam();
  116. param.setObjId(objId);
  117. List<BisInspRsmlRgstr> list = bisInspRsmlRgstrDao.findList(param);
  118. if (list.size() > 0) {
  119. String id = list.get(0).getId();
  120. bisInspRsmlRgstrDao.delete(id);
  121. BisInspAllObjParam bisInspAllObjParam = new BisInspAllObjParam();
  122. if (StringUtils.isNotBlank(objId)) {
  123. bisInspAllObjParam.setObjId(objId);
  124. BisInspRsmlRgstrProjectParam bisInspRsmlRgstrProjectParam = new BisInspRsmlRgstrProjectParam();
  125. bisInspRsmlRgstrProjectParam.setRgstrId(id);
  126. bisInspRsmlRgstrProjectDao.deleteBy(bisInspRsmlRgstrProjectParam);
  127. BisInspRsmlRgstrRunManageParam bisInspRsmlRgstrRunManageParam = new BisInspRsmlRgstrRunManageParam();
  128. bisInspRsmlRgstrRunManageParam.setRgstrId(id);
  129. bisInspRsmlRgstrRunManageDao.deleteBy(bisInspRsmlRgstrRunManageParam);
  130. BisInspRsmlRgstrPresParam bisInspRsmlRgstrPresParam = new BisInspRsmlRgstrPresParam();
  131. bisInspRsmlRgstrPresParam.setRgstrId(id);
  132. bisInspRsmlRgstrPresDao.deleteBy(bisInspRsmlRgstrPresParam);
  133. this.bisInspAllObjDao.deleteBy(bisInspAllObjParam);
  134. }
  135. }
  136. }
  137. @Override
  138. public PageInfo findObjPageByType(TypeParam typeParam, HttpServletResponse response) {
  139. return findRsmlPage(typeParam, response);
  140. }
  141. @Override
  142. public Object findObjListByType(TypeParam typeParam) {
  143. return findRsmlList(typeParam);
  144. }
  145. @Override
  146. public PageInfo<BisInspRsmlRgstrDto> getRsmlPage(BisInspRsmlRgstrParam bisInspRsmlRgstrParam) {
  147. PageHelper.startPage(bisInspRsmlRgstrParam);
  148. List<BisInspRsmlRgstrDto> list = bisInspRsmlRgstrDao.getRsmlList(bisInspRsmlRgstrParam);
  149. if (list.size() > 0) {
  150. for (BisInspRsmlRgstrDto b : list) {
  151. if (b.getAdFullName() != null) {
  152. if (b.getAdFullName().contains(SplitValue.HENG_SPLIT)) {
  153. String[] split = b.getAdFullName().split(SplitValue.HENG_SPLIT);
  154. if (split.length == 3) {
  155. b.setProvince(split[0]);
  156. b.setCity(split[1]);
  157. b.setCounty(split[2]);
  158. }
  159. if (split.length == 2) {
  160. b.setProvince(split[0]);
  161. b.setCity(split[1]);
  162. b.setCounty("");
  163. }
  164. } else {
  165. b.setProvince(b.getAdFullName());
  166. }
  167. }
  168. }
  169. }
  170. PageInfo<BisInspRsmlRgstrDto> pageInfo = new PageInfo<>(list);
  171. return pageInfo;
  172. }
  173. @Override
  174. public PageInfo<BisInspRgstrDto> findRsmlPage(TypeParam typeParam, HttpServletResponse response) {
  175. if (StringUtils.isNotBlank(typeParam.getAdCode())) {
  176. typeParam.setAdCode(String.valueOf(AdLevelUtil.SubAd(typeParam.getAdCode()).get(SplitValue.SUBAD)));
  177. }
  178. PageHelper.startPage(typeParam);
  179. List<BisInspRgstrDto> list = bisInspRsmlRgstrDao.findRsmlList(typeParam);
  180. list = changeList(list);
  181. return new PageInfo<BisInspRgstrDto>(list);
  182. }
  183. private List<BisInspRgstrDto> changeList(List<BisInspRgstrDto> list) {
  184. if (list.size() > 0) {
  185. for (BisInspRgstrDto rgstrDto : list) {
  186. String adFullName = rgstrDto.getAdName();
  187. if (StringUtils.isBlank(adFullName)) {
  188. continue;
  189. }
  190. if (adFullName.contains(SplitValue.HENG_SPLIT)) {
  191. String[] split = adFullName.split(SplitValue.HENG_SPLIT);
  192. if (split.length == 3) {
  193. rgstrDto.setProvince(split[0]);
  194. rgstrDto.setCity(split[1]);
  195. rgstrDto.setCountry(split[2]);
  196. }
  197. if (split.length == 2) {
  198. rgstrDto.setProvince(split[0]);
  199. rgstrDto.setCity(split[1]);
  200. rgstrDto.setCountry("");
  201. }
  202. } else {
  203. rgstrDto.setProvince(adFullName);
  204. }
  205. }
  206. }
  207. return list;
  208. }
  209. @Override
  210. public List findRsmlList(TypeParam typeParam) {
  211. if (StringUtils.isNotBlank(typeParam.getAdCode())) {
  212. typeParam.setAdCode(String.valueOf(AdLevelUtil.SubAd(typeParam.getAdCode()).get(SplitValue.SUBAD)));
  213. }
  214. List<BisInspRgstrDto> list = bisInspRsmlRgstrDao.findRsmlList(typeParam);
  215. return changeList(list);
  216. }
  217. @Override
  218. public void updateRsvr(String rgstrId, String status, String input) {
  219. if (StringUtils.isBlank(rgstrId)) {
  220. return;
  221. }
  222. BisInspRsmlRgstr rgstr = bisInspRsmlRgstrDao.get(rgstrId);
  223. if (StringUtils.isBlank(status)) {
  224. status = "2";
  225. }
  226. RsvrEnum rsvrEnum = RsvrEnum.getByValue(input);
  227. if (rsvrEnum == null) {
  228. return;
  229. }
  230. switch (rsvrEnum) {
  231. case PERSSAFE:
  232. rgstr.setSafeStat(status);
  233. break;
  234. default:
  235. }
  236. if (StringUtils.isBlank(rgstr.getState()) ||
  237. StateEnum.NOWASTSTATE.getKey().equals(rgstr.getState())) {
  238. rgstr.setState(StateEnum.EXWASTSTATE.getKey());
  239. } else {
  240. rgstr.setState(rgstr.getState());
  241. }
  242. bisInspRsmlRgstrDao.update(rgstr);
  243. }
  244. }