fb67ca80ac5bba45c1f26db9f53f0804a9c14db9.svn-base 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. package cn.com.goldenwater.dcproj.service.impl.wr;
  2. import cn.com.goldenwater.dcproj.dao.WrSwsBDao;
  3. import cn.com.goldenwater.dcproj.model.WrSwsB;
  4. import cn.com.goldenwater.dcproj.param.WrSwsBParam;
  5. import cn.com.goldenwater.dcproj.service.WrSwsBService;
  6. import cn.com.goldenwater.core.service.AbstractCrudService;
  7. import cn.com.goldenwater.dcproj.utils.BeanUtil;
  8. import cn.com.goldenwater.dcproj.utils.GeoUtil;
  9. import cn.com.goldenwater.dcproj.utils.expExcel.ExcelExport;
  10. import cn.com.goldenwater.dcproj.utils.expExcel.ExportAbstract;
  11. import com.github.pagehelper.PageHelper;
  12. import org.apache.commons.lang3.StringUtils;
  13. import org.apache.commons.lang3.math.NumberUtils;
  14. import org.springframework.beans.factory.annotation.Autowired;
  15. import org.springframework.stereotype.Service;
  16. import org.springframework.transaction.annotation.Transactional;
  17. import com.github.pagehelper.PageInfo;
  18. import java.util.ArrayList;
  19. import java.util.List;
  20. import java.util.Map;
  21. import cn.com.goldenwater.dcproj.utils.DateUtils;
  22. import javax.servlet.http.HttpServletResponse;
  23. /**
  24. * @author zhengdafei
  25. * @date 2019-3-3
  26. */
  27. @Service
  28. @Transactional
  29. public class WrSwsBServiceImpl extends AbstractCrudService<WrSwsB, WrSwsBParam> implements WrSwsBService {
  30. @Autowired
  31. private WrSwsBDao wrSwsBDao;
  32. public WrSwsBServiceImpl(WrSwsBDao wrSwsBDao) {
  33. super(wrSwsBDao);
  34. this.wrSwsBDao = wrSwsBDao;
  35. }
  36. @Override
  37. public String add(WrSwsB p) throws Exception {
  38. String uuid = "";
  39. String now = DateUtils.getTodayYMDHMS();
  40. if (StringUtils.isNotBlank(p.getAdCode())) {
  41. String maxCwsCode = wrSwsBDao.getMaxCwsCode(p.getAdCode().substring(0, 6)); //根据最大code生成cwscode
  42. if (maxCwsCode != null) {
  43. Long mCcode = 0L;
  44. if (maxCwsCode == null) {
  45. mCcode = NumberUtils.createLong(p.getAdCode());
  46. Long gwsCode = mCcode + 1;
  47. p.setSwsCd(gwsCode + "");
  48. } else {
  49. mCcode = NumberUtils.createLong(maxCwsCode);
  50. Long gwsCode = mCcode + 1;
  51. p.setSwsCd(gwsCode + "");
  52. }
  53. }
  54. } else {
  55. throw new Exception("adCode不能为空");
  56. }
  57. transferGeo(p);
  58. p.setTs(now);
  59. wrSwsBDao.insert(p);
  60. uuid = p.getSwsCd();
  61. return uuid;
  62. }
  63. @Override
  64. public int modify(WrSwsB p) throws Exception {
  65. String now = DateUtils.getTodayYMDHMS();
  66. p.setTs(now);
  67. transferGeo(p);
  68. int ret = wrSwsBDao.update(p);
  69. return ret;
  70. }
  71. public void transferGeo(WrSwsB p) {
  72. String src = p.getSrc();
  73. if (StringUtils.isNotBlank(src)) {
  74. if ("PC".equalsIgnoreCase(src)) {
  75. if (p.getLgtdpc() != null && p.getLttdpc() != null) {
  76. Map<String, Double> map = GeoUtil.wgs84togcj02(p.getLgtdpc(), p.getLttdpc());
  77. p.setLgtd(map.get("lon"));
  78. p.setLttd(map.get("lat"));
  79. }
  80. } else if ("MOBILE".equalsIgnoreCase(src)) {
  81. if (p.getLgtd() != null && p.getLttd() != null) {
  82. Map<String, Double> map = GeoUtil.gcj02towgs84(p.getLgtd(), p.getLttd());
  83. p.setLgtdpc(map.get("lon"));
  84. p.setLttdpc(map.get("lat"));
  85. }
  86. }
  87. } else {
  88. if (p.getLgtdpc() != null && p.getLttdpc() != null) {
  89. Map<String, Double> map = GeoUtil.wgs84togcj02(p.getLgtdpc(), p.getLttdpc());
  90. p.setLgtd(map.get("lon"));
  91. p.setLttd(map.get("lat"));
  92. } else if (p.getLgtd() != null && p.getLttd() != null) {
  93. Map<String, Double> map = GeoUtil.gcj02towgs84(p.getLgtd(), p.getLttd());
  94. p.setLgtdpc(map.get("lon"));
  95. p.setLttdpc(map.get("lat"));
  96. }
  97. }
  98. }
  99. @Override
  100. public PageInfo<WrSwsB> queryListByPage(WrSwsBParam p) throws Exception {
  101. PageHelper.startPage(p.getPageNum(), p.getPageSize());
  102. List<WrSwsB> list = wrSwsBDao.findList(p);
  103. return new PageInfo<WrSwsB>(list);
  104. }
  105. @Override
  106. public List<WrSwsB> queryList(WrSwsBParam p) throws Exception {
  107. List<WrSwsB> list = wrSwsBDao.findList(p);
  108. return list;
  109. }
  110. @Override
  111. public void exportWrSwsB(WrSwsBParam wrSwsBParam, HttpServletResponse response) {
  112. List<WrSwsB> list=new ArrayList<>();
  113. list=wrSwsBDao.findList(wrSwsBParam);
  114. List<Map<String,Object>> mapList = new ArrayList<>();
  115. for (WrSwsB wrSwsB : list) {
  116. String swsTp=wrSwsB.getSwsTp();
  117. String wqGoal=wrSwsB.getWqGoal();
  118. String consCond=wrSwsB.getConsCond();
  119. String wsCond=wrSwsB.getWsCond();
  120. String monG=wrSwsB.getMonG();
  121. if("1".equals(swsTp)){
  122. wrSwsB.setSwsTp("河道(江河)");
  123. }else if ("2".equals(swsTp)){
  124. wrSwsB.setSwsTp("水库");
  125. }else if ("3".equals(swsTp)){
  126. wrSwsB.setSwsTp("湖泊");
  127. }else if ("9".equals(swsTp)){
  128. wrSwsB.setSwsTp("其他");
  129. }
  130. if ("1".equals(wqGoal)){
  131. wrSwsB.setWqGoal("Ⅰ类");
  132. }else if ("2".equals(wqGoal)){
  133. wrSwsB.setWqGoal("Ⅱ类");
  134. }else if ("3".equals(wqGoal)){
  135. wrSwsB.setWqGoal("Ⅲ类");
  136. }else if ("4".equals(wqGoal)){
  137. wrSwsB.setWqGoal("Ⅳ类");
  138. }else if ("5".equals(wqGoal)){
  139. wrSwsB.setWqGoal("Ⅴ类");
  140. }else if ("6".equals(wqGoal)){
  141. wrSwsB.setWqGoal("劣Ⅴ类");
  142. }else if ("12".equals(wqGoal)){
  143. wrSwsB.setWqGoal("I-II类");
  144. }else if ("13".equals(wqGoal)){
  145. wrSwsB.setWqGoal("I-III类");
  146. }else if ("14".equals(wqGoal)){
  147. wrSwsB.setWqGoal("I-IV类");
  148. }else if ("15".equals(wqGoal)){
  149. wrSwsB.setWqGoal("I-V类");
  150. }else if ("16".equals(wqGoal)){
  151. wrSwsB.setWqGoal("I-劣Ⅴ类");
  152. }else if ("23".equals(wqGoal)){
  153. wrSwsB.setWqGoal("II-III类");
  154. }else if ("24".equals(wqGoal)){
  155. wrSwsB.setWqGoal("II-IV类");
  156. }else if ("25".equals(wqGoal)){
  157. wrSwsB.setWqGoal("II-V类");
  158. }else if ("26".equals(wqGoal)){
  159. wrSwsB.setWqGoal("II-劣V类");
  160. }else if ("34".equals(wqGoal)){
  161. wrSwsB.setWqGoal("III-IV类");
  162. }else if ("35".equals(wqGoal)){
  163. wrSwsB.setWqGoal("III-V类");
  164. }else if ("36".equals(wqGoal)){
  165. wrSwsB.setWqGoal("III-劣Ⅴ类");
  166. }else if ("45".equals(wqGoal)){
  167. wrSwsB.setWqGoal("IV-V类");
  168. }else if ("46".equals(wqGoal)){
  169. wrSwsB.setWqGoal("IV-劣V类");
  170. }else if ("56".equals(wqGoal)){
  171. wrSwsB.setWqGoal("V-劣V类");
  172. }
  173. if ("1".equals(consCond)){
  174. wrSwsB.setConsCond("已建");
  175. }else if ("2".equals(consCond)){
  176. wrSwsB.setConsCond("在建");
  177. }else if ("3".equals(consCond)){
  178. wrSwsB.setConsCond("待建");
  179. }
  180. if ("1".equals(wsCond)){
  181. wrSwsB.setWsCond("常年");
  182. }else if ("2".equals(wsCond)){
  183. wrSwsB.setWsCond("汛期");
  184. }else if ("3".equals(wsCond)){
  185. wrSwsB.setWsCond("非汛期");
  186. }
  187. if ("0".equals(monG)||"9".equals(monG)){
  188. wrSwsB.setMonG("其他");
  189. }else if ("1".equals(monG)){
  190. wrSwsB.setMonG("国控级");
  191. }else if ("2".equals(monG)){
  192. wrSwsB.setMonG("省控级");
  193. }else if ("3".equals(monG)){
  194. wrSwsB.setMonG("地市级");
  195. }
  196. mapList.add(BeanUtil.transBean2Map(wrSwsB));
  197. }
  198. ExportAbstract export = new ExcelExport();
  199. export.setFileName("地表水水源地基础信息");
  200. export.setExport_ps_export(true);
  201. export.setExport_ps_type(ExportAbstract.XLS);
  202. export.setExport_bzip(false);
  203. export.setTitle("地表水水源地基础信息");
  204. ArrayList<Object> cols = new ArrayList<Object>();
  205. cols.add("swsCd[地表水水源地代码]");
  206. cols.add("swsNm[地表水水源地名称]");
  207. cols.add("swsTp[地表水水源地类型]");
  208. cols.add("watA[水面面积(平方公里)]");
  209. cols.add("wqGoal[水质目标]");
  210. cols.add("consCond[建设状况]");
  211. cols.add("putProdTm[投产时间]");
  212. cols.add("runCond[运行状况]");
  213. cols.add("wsCond[水源供水持续状况]");
  214. cols.add("wsObj[供水对象]");
  215. cols.add("dywsPp[设计年供水人口(万人)]");
  216. cols.add("dywsW[设计年供水量(万立方米)]");
  217. cols.add("whsManCd[水源地管理单位代码]");
  218. cols.add("whsApprCd[水源地审批单位代码]");
  219. cols.add("emCd[应急管理单位代码]");
  220. cols.add("monG[监控级别]");
  221. cols.add("ts[时间戳]");
  222. cols.add("nt[备注]");
  223. export.setCols(cols);
  224. export.setGroupable(false);
  225. // 设置视图指标
  226. export.setLevel(1);
  227. export.setLocksize(0);
  228. try {
  229. export.Export(response);
  230. export.ExportHeadForCustom(response);//导出表头
  231. export.ContinueExport(mapList);
  232. export.EndExport();
  233. } catch (Exception e) {
  234. e.printStackTrace();
  235. }
  236. }
  237. }