f7c780d2a4558e37eee3435aaa5e856082106edc.svn-base 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. package cn.com.goldenwater.dcproj.service.impl.offline;
  2. import cn.com.goldenwater.dcproj.constValue.BisInspEnum;
  3. import cn.com.goldenwater.dcproj.constValue.SplitValue;
  4. import cn.com.goldenwater.dcproj.dao.*;
  5. import cn.com.goldenwater.dcproj.model.*;
  6. import cn.com.goldenwater.dcproj.param.AttRsBaseParam;
  7. import cn.com.goldenwater.dcproj.param.AttWuntBaseParam;
  8. import cn.com.goldenwater.dcproj.param.BisInspAllObjParam;
  9. import cn.com.goldenwater.dcproj.param.BisInspRsfcoqhPresParam;
  10. import cn.com.goldenwater.dcproj.service.GwComFileService;
  11. import cn.com.goldenwater.dcproj.service.SupervisionPlanService;
  12. import cn.com.goldenwater.dcproj.utils.AdLevelUtil;
  13. import cn.com.goldenwater.id.util.UuidUtil;
  14. import com.fasterxml.jackson.databind.DeserializationFeature;
  15. import com.fasterxml.jackson.databind.ObjectMapper;
  16. import org.apache.commons.lang3.StringUtils;
  17. import org.springframework.beans.factory.annotation.Autowired;
  18. import org.springframework.beans.factory.annotation.Value;
  19. import org.springframework.stereotype.Service;
  20. import org.springframework.transaction.annotation.Transactional;
  21. import java.io.IOException;
  22. import java.text.ParseException;
  23. import java.text.SimpleDateFormat;
  24. import java.util.Date;
  25. import java.util.List;
  26. import static cn.com.goldenwater.dcproj.utils.impexcel.ImpUtil.checkIsDate;
  27. /**
  28. * 青海-水库防洪调度离线填报
  29. *
  30. * @author zhangcheng
  31. * @date 2019/11/26 17:54
  32. */
  33. @Service
  34. @Transactional
  35. public class BisInspOffLineRsfcoqhProcess extends BisInspOffLineProcess {
  36. @Autowired
  37. BisInspAllObjDao bisInspAllObjDao;
  38. @Autowired
  39. BisInspPblmDao bisInspPblmDao;//督查问题
  40. @Autowired
  41. AttRsBaseDao attRsBaseDao;//水库基本信息
  42. @Autowired
  43. SupervisionPlanService supervisionPlanService;
  44. @Autowired
  45. BisInspRsfcoqhRgstrDao bisInspRsfcoqhRgstrDao;
  46. @Autowired
  47. BisInspRsfcoqhPresDao bisInspRsfcoqhPresDao;
  48. @Value("${getFile.prefix}")
  49. public String prefix;
  50. @Autowired
  51. BisInspRsvrRgstrDao bisInspRsvrRgstrDao;
  52. @Override
  53. public BisInspOffLineRet process(BisInspOffLineObj bisInspOffLineObj, String fileDir) throws IOException {
  54. BisInspOffLineRet bisInspOffLineRet = new BisInspOffLineRet();
  55. SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
  56. ObjectMapper om = new ObjectMapper();
  57. om.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
  58. //解析青海-水库防洪调度督查
  59. BisInspOffLineRsfcoqhRgeister bisInspOffLineRsfcoqhRgeister = om.readValue(bisInspOffLineObj.getRegister(), BisInspOffLineRsfcoqhRgeister.class);
  60. //解析水库基本信息对象
  61. if (bisInspOffLineObj.getBase() != null) {
  62. //添加到督查任务
  63. String objId = UuidUtil.uuid();
  64. String groupId = bisInspOffLineObj.getGroupId();
  65. String regId = objId;
  66. String persId = bisInspOffLineObj.getPersId();
  67. AttRsBase attRsBase = om.readValue(bisInspOffLineObj.getBase(), AttRsBase.class);
  68. BisInspRsfcoqhRgstr bisInspRsfcoqhRgstr = new BisInspRsfcoqhRgstr();
  69. if (StringUtils.isNotBlank(attRsBase.getRgstrId())) {
  70. regId = attRsBase.getRgstrId();
  71. objId = attRsBase.getObjId();
  72. bisInspRsfcoqhRgstr.setId(regId);
  73. bisInspRsfcoqhRgstr.setObjId(objId);
  74. bisInspRsfcoqhRgstr.setState("1");
  75. } else {
  76. //添加到督查任务
  77. insertBisInspAllObj(bisInspOffLineObj, groupId, objId, attRsBase);
  78. bisInspRsfcoqhRgstr.setRgstrId(regId);
  79. bisInspRsfcoqhRgstr.setObjId(objId);
  80. bisInspRsfcoqhRgstr.setId(regId);
  81. //插入登记表信息
  82. insertRsfcoqhRgstr(attRsBase, bisInspRsfcoqhRgstr, om);
  83. }
  84. //水库安全度汛检查表
  85. insertRsfcoqhPres(bisInspOffLineRsfcoqhRgeister, regId, persId, bisInspRsfcoqhRgstr);
  86. bisInspRsfcoqhRgstrDao.update(bisInspRsfcoqhRgstr);
  87. bisInspOffLineRet.setRegId(regId);
  88. bisInspOffLineRet.setObjId(objId);
  89. }
  90. return bisInspOffLineRet;
  91. }
  92. /**
  93. * 删除任务及登记表信息
  94. *
  95. * @param groupId
  96. * @param nm
  97. */
  98. public void delRgstrData(BisInspOffLineObj bisInspOffLineObj) {
  99. //登记表查找重复数据,然后删除
  100. BisInspAllObjParam bisInspAllObjParam = new BisInspAllObjParam();
  101. bisInspAllObjParam.setId(bisInspOffLineObj.getGroupId());
  102. bisInspAllObjParam.setNm(bisInspOffLineObj.getNm());
  103. List<BisInspAllObj> bisInspAllObjs = bisInspAllObjDao.findList(bisInspAllObjParam);
  104. for (BisInspAllObj bisInspAllObj : bisInspAllObjs) {
  105. //删除登记表
  106. //删除登记表关联的各个填报表数据
  107. supervisionPlanService.cleanObjDataByObjId(BisInspEnum.RSFCOQH.getValue(), bisInspAllObj.getObjId());
  108. }
  109. }
  110. /**
  111. * 添加到督查任务
  112. *
  113. * @param groupId
  114. * @param objId
  115. * @param attAdBase
  116. */
  117. public void insertBisInspAllObj(BisInspOffLineObj bisInspOffLineObj, String groupId, String objId, AttRsBase attRsBase) {
  118. BisInspAllObj bisInspAllObj = new BisInspAllObj();
  119. bisInspAllObj.setId(groupId);
  120. bisInspAllObj.setObjId(objId);
  121. bisInspAllObj.setNm(attRsBase.getRsName());
  122. bisInspAllObj.setCode(attRsBase.getRsCode());//非空字段
  123. bisInspAllObj.setPtype("96");
  124. bisInspAllObj.setOrgId(bisInspOffLineObj.getOrgId());
  125. bisInspAllObj.setAdCode(bisInspOffLineObj.getProvince());
  126. bisInspAllObj.setLttd(StringUtils.isNotBlank(attRsBase.getCenterXGd()) ? Double.parseDouble(attRsBase.getCenterXGd()) : 0);
  127. bisInspAllObj.setLgtd(StringUtils.isNotBlank(attRsBase.getCenterYGd()) ? Double.parseDouble(attRsBase.getCenterYGd()) : 0);
  128. bisInspAllObj.setLttdpc(StringUtils.isNotBlank(attRsBase.getCenterX()) ? Double.parseDouble(attRsBase.getCenterX()) : 0);
  129. bisInspAllObj.setLgtdpc(StringUtils.isNotBlank(attRsBase.getCenterY()) ? Double.parseDouble(attRsBase.getCenterY()) : 0);
  130. bisInspAllObj.setObjAdCode(attRsBase.getRsAdmCode());
  131. bisInspAllObjDao.insert(bisInspAllObj);
  132. }
  133. /**
  134. * 插入登记表信息
  135. *
  136. * @param bisInspOffLineObj
  137. * @param objId
  138. * @param om
  139. * @param regId
  140. * @param bisInspSvwtWuntRgstr
  141. * @throws IOException
  142. */
  143. public void insertRsfcoqhRgstr(AttRsBase attRsBase, BisInspRsfcoqhRgstr bisInspRsfcoqhRgstr, ObjectMapper om) {
  144. bisInspRsfcoqhRgstr.setRsCode(attRsBase.getRsCode());
  145. bisInspRsfcoqhRgstr.setRsName(attRsBase.getRsName());
  146. if (attRsBase.getRegCode() != null) {
  147. bisInspRsfcoqhRgstr.setHasDamRegCode("1");
  148. bisInspRsfcoqhRgstr.setDamRegCode(attRsBase.getRegCode());
  149. } else {
  150. bisInspRsfcoqhRgstr.setHasDamRegCode("2");
  151. }
  152. bisInspRsfcoqhRgstr.setAdCode(attRsBase.getAdmDiv());
  153. bisInspRsfcoqhRgstr.setLocation(attRsBase.getLocation());
  154. bisInspRsfcoqhRgstr.setHystSite(attRsBase.getLocation());
  155. bisInspRsfcoqhRgstr.setCenterX(attRsBase.getCenterX() == null ? 0 : Double.parseDouble(attRsBase.getCenterX()));
  156. bisInspRsfcoqhRgstr.setCenterY(attRsBase.getCenterY() == null ? 0 : Double.parseDouble(attRsBase.getCenterY()));
  157. bisInspRsfcoqhRgstr.setGdX(attRsBase.getCenterXGd() == null ? 0 : Double.parseDouble(attRsBase.getCenterXGd()));
  158. bisInspRsfcoqhRgstr.setGdY(attRsBase.getCenterYGd() == null ? 0 : Double.parseDouble(attRsBase.getCenterYGd()));
  159. bisInspRsfcoqhRgstr.setRsAdmCode(attRsBase.getRsAdmCode());
  160. bisInspRsfcoqhRgstr.setRsAdmName(attRsBase.getRsAdmName());
  161. bisInspRsfcoqhRgstr.setEngScal(attRsBase.getEngScal());
  162. bisInspRsfcoqhRgstr.setDamType(attRsBase.getDamType());
  163. bisInspRsfcoqhRgstr.setTotCap(attRsBase.getTotCap());
  164. bisInspRsfcoqhRgstr.setDamSizeHig(attRsBase.getDamSizeHig());
  165. bisInspRsfcoqhRgstr.setDataStat("0");
  166. if (org.apache.commons.lang3.StringUtils.isNotBlank(attRsBase.getCompDateStr())) {
  167. try {
  168. // 不是时间格式会报错,判断一下,不是时间格式就不赋给它了
  169. if (checkIsDate(attRsBase.getCompDateStr())) {
  170. bisInspRsfcoqhRgstr.setResCreateTime(new SimpleDateFormat(SplitValue.TIME_SPLIT).parse(attRsBase.getCompDateStr()));
  171. }
  172. } catch (ParseException e) {
  173. e.printStackTrace();
  174. }
  175. }
  176. bisInspRsfcoqhRgstr.setIntm(new Date());
  177. bisInspRsfcoqhRgstr.setUptm(new Date());
  178. bisInspRsfcoqhRgstr.setState("1");
  179. //添加注册登记表
  180. if (StringUtils.isNotBlank(attRsBase.getRgstrId())) {
  181. bisInspRsfcoqhRgstrDao.update(bisInspRsfcoqhRgstr);
  182. } else {
  183. bisInspRsfcoqhRgstrDao.insert(bisInspRsfcoqhRgstr);
  184. }
  185. }
  186. /**
  187. * 插入水库安全度汛检查表
  188. */
  189. public void insertRsfcoqhPres(BisInspOffLineRsfcoqhRgeister bisInspOffLineRsfcoqhRgeister, String regId, String persId, BisInspRsfcoqhRgstr bisInspRsfcoqhRgstr) {
  190. // BIS_INSP_RSFCOQH_PRES
  191. BisInspRsfcoqhPres bisInspRsfcoqhPres = bisInspOffLineRsfcoqhRgeister.getBisInspRsfcoqhPres();
  192. BisInspRsfcoqhPresParam bisInspRsfcoqhPresParam = new BisInspRsfcoqhPresParam();
  193. bisInspRsfcoqhPresParam.setRgstrId(regId);
  194. bisInspRsfcoqhPresDao.deleteBy(bisInspRsfcoqhPresParam);
  195. bisInspRsfcoqhPres.setId(UuidUtil.uuid());
  196. bisInspRsfcoqhPres.setRgstrId(regId);
  197. bisInspRsfcoqhPres.setDataStat("0");
  198. bisInspRsfcoqhPres.setPersId(persId);
  199. bisInspRsfcoqhPresDao.insert(bisInspRsfcoqhPres);
  200. bisInspRsfcoqhRgstr.setPresState("1");
  201. }
  202. @Override
  203. public BisInspOffLineRetBase getBaseInfo(BisInspOffLine bisInspOffLine) {
  204. BisInspOffLineRetBase bisInspOffLineRetBase = new BisInspOffLineRetBase();
  205. AttRsBaseParam attRsBaseParam = new AttRsBaseParam();
  206. attRsBaseParam.setRsName(bisInspOffLine.getName());
  207. attRsBaseParam.setAdmDiv(AdLevelUtil.getAddvcd(bisInspOffLine.getAddvcd()));
  208. bisInspOffLineRetBase.setBase(attRsBaseDao.findList(attRsBaseParam));
  209. //判断登记表是否有重复对象
  210. List<BisInspRsfcoqhRgstr> bisInspRsfcoqhRgstrs = bisInspRsfcoqhRgstrDao.getRsvrByIdNm(bisInspOffLine.getGroupId(), bisInspOffLine.getName());
  211. if (null != bisInspRsfcoqhRgstrs && bisInspRsfcoqhRgstrs.size() > 0) {
  212. bisInspOffLineRetBase.setRepeat(true);
  213. bisInspOffLineRetBase.setRepeatList(bisInspRsfcoqhRgstrs);
  214. } else {
  215. bisInspOffLineRetBase.setRepeat(false);
  216. }
  217. return bisInspOffLineRetBase;
  218. }
  219. }