c21b43535e3c99a917c6ea5c12036f38392c7e40.svn-base 8.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. package cn.com.goldenwater.dcproj.service.impl.wr;
  2. import cn.com.goldenwater.dcproj.dao.WrGwsBDao;
  3. import cn.com.goldenwater.dcproj.model.WrGwsB;
  4. import cn.com.goldenwater.dcproj.param.WrGwsBParam;
  5. import cn.com.goldenwater.dcproj.service.WrGwsBService;
  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 WrGwsBServiceImpl extends AbstractCrudService<WrGwsB, WrGwsBParam> implements WrGwsBService {
  30. @Autowired
  31. private WrGwsBDao wrGwsBDao;
  32. public WrGwsBServiceImpl(WrGwsBDao wrGwsBDao) {
  33. super(wrGwsBDao);
  34. this.wrGwsBDao = wrGwsBDao;
  35. }
  36. @Override
  37. public String add(WrGwsB p) throws Exception {
  38. String uuid = "";
  39. String now = DateUtils.getTodayYMDHMS();
  40. if (StringUtils.isNotBlank(p.getAdCode())) {
  41. String maxGwsCode = wrGwsBDao.getMaxGwsCode(p.getAdCode().substring(0, 6)); //根据最大code生成cwscode
  42. if (maxGwsCode != null) {
  43. Long mCcode = 0L;
  44. if (maxGwsCode == null) {
  45. mCcode = NumberUtils.createLong(p.getAdCode());
  46. Long gwsCode = mCcode + 1;
  47. p.setGwsCd(gwsCode + "");
  48. } else {
  49. mCcode = NumberUtils.createLong(maxGwsCode);
  50. Long gwsCode = mCcode + 1;
  51. p.setGwsCd(gwsCode + "");
  52. }
  53. }
  54. } else {
  55. throw new Exception("adCode不能为空");
  56. }
  57. transferGeo(p);
  58. p.setTs(now);
  59. wrGwsBDao.insert(p);
  60. uuid = p.getGwsCd();
  61. return uuid;
  62. }
  63. @Override
  64. public int modify(WrGwsB p) throws Exception {
  65. String now = DateUtils.getTodayYMDHMS();
  66. transferGeo(p);
  67. p.setTs(now);
  68. int ret = wrGwsBDao.update(p);
  69. return ret;
  70. }
  71. public void transferGeo(WrGwsB 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<WrGwsB> queryListByPage(WrGwsBParam p) throws Exception {
  101. PageHelper.startPage(p.getPageNum(), p.getPageSize());
  102. List<WrGwsB> list = wrGwsBDao.findList(p);
  103. return new PageInfo<WrGwsB>(list);
  104. }
  105. @Override
  106. public List<WrGwsB> queryList(WrGwsBParam p) throws Exception {
  107. List<WrGwsB> list = wrGwsBDao.findList(p);
  108. return list;
  109. }
  110. @Override
  111. public void exportWrGwsB(WrGwsBParam wrGwsBParam, HttpServletResponse response) {
  112. List<WrGwsB> list=wrGwsBDao.findList(wrGwsBParam);
  113. List<Map<String,Object>> mapList = new ArrayList<>();
  114. for (WrGwsB wrGwsB : list) {
  115. String wqGoal=wrGwsB.getWqGoal();
  116. String monG=wrGwsB.getMonG();
  117. String consCond=wrGwsB.getConsCond();
  118. if ("1".equals(wqGoal)){
  119. wrGwsB.setWqGoal("Ⅰ类");
  120. }else if ("2".equals(wqGoal)){
  121. wrGwsB.setWqGoal("Ⅱ类");
  122. }else if ("3".equals(wqGoal)){
  123. wrGwsB.setWqGoal("Ⅲ类");
  124. }else if ("4".equals(wqGoal)){
  125. wrGwsB.setWqGoal("Ⅳ类");
  126. }else if ("5".equals(wqGoal)){
  127. wrGwsB.setWqGoal("Ⅴ类");
  128. }else if ("6".equals(wqGoal)){
  129. wrGwsB.setWqGoal("劣Ⅴ类");
  130. }else if ("12".equals(wqGoal)){
  131. wrGwsB.setWqGoal("I-II类");
  132. }else if ("13".equals(wqGoal)){
  133. wrGwsB.setWqGoal("I-III类");
  134. }else if ("14".equals(wqGoal)){
  135. wrGwsB.setWqGoal("I-IV类");
  136. }else if ("15".equals(wqGoal)){
  137. wrGwsB.setWqGoal("I-V类");
  138. }else if ("16".equals(wqGoal)){
  139. wrGwsB.setWqGoal("I-劣Ⅴ类");
  140. }else if ("23".equals(wqGoal)){
  141. wrGwsB.setWqGoal("II-III类");
  142. }else if ("24".equals(wqGoal)){
  143. wrGwsB.setWqGoal("II-IV类");
  144. }else if ("25".equals(wqGoal)){
  145. wrGwsB.setWqGoal("II-V类");
  146. }else if ("26".equals(wqGoal)){
  147. wrGwsB.setWqGoal("II-劣V类");
  148. }else if ("34".equals(wqGoal)){
  149. wrGwsB.setWqGoal("III-IV类");
  150. }else if ("35".equals(wqGoal)){
  151. wrGwsB.setWqGoal("III-V类");
  152. }else if ("36".equals(wqGoal)){
  153. wrGwsB.setWqGoal("III-劣Ⅴ类");
  154. }else if ("45".equals(wqGoal)){
  155. wrGwsB.setWqGoal("IV-V类");
  156. }else if ("46".equals(wqGoal)){
  157. wrGwsB.setWqGoal("IV-劣V类");
  158. }else if ("56".equals(wqGoal)){
  159. wrGwsB.setWqGoal("V-劣V类");
  160. }
  161. if ("0".equals(monG)||"9".equals(monG)){
  162. wrGwsB.setMonG("其他");
  163. }else if ("1".equals(monG)){
  164. wrGwsB.setMonG("国控级");
  165. }else if ("2".equals(monG)){
  166. wrGwsB.setMonG("省控级");
  167. }else if ("3".equals(monG)){
  168. wrGwsB.setMonG("地市级");
  169. }
  170. if ("1".equals(consCond)){
  171. wrGwsB.setConsCond("已建");
  172. }else if ("2".equals(consCond)){
  173. wrGwsB.setConsCond("在建");
  174. }else if ("3".equals(consCond)){
  175. wrGwsB.setConsCond("待建");
  176. }
  177. mapList.add(BeanUtil.transBean2Map(wrGwsB));
  178. }
  179. ExportAbstract export = new ExcelExport();
  180. export.setFileName("地下水水源地基础信息");
  181. export.setExport_ps_export(true);
  182. export.setExport_ps_type(ExportAbstract.XLS);
  183. export.setExport_bzip(false);
  184. export.setTitle("地下水水源地基础信息");
  185. ArrayList<Object> cols = new ArrayList<Object>();
  186. cols.add("gwsCd[地下水水源地代码]");
  187. cols.add("gwsNm[地下水水源地名称]");
  188. cols.add("gwsA[地下水水源地面积]");
  189. cols.add("rangDesc[范围描述]");
  190. cols.add("wqGoal[水质目标]");
  191. cols.add("consCond[建设状况]");
  192. cols.add("putProdTm[投产时间]");
  193. cols.add("avgExpYd[多年平均年可开采量]");
  194. cols.add("wsObj[供水对象]");
  195. cols.add("monG[监控级别]");
  196. cols.add("desInt[设计年取水量(万立方米)]");
  197. cols.add("permInt[年许可取水量(万立方米)]");
  198. cols.add("whsManCd[水源地管理单位代码]");
  199. cols.add("whsApprCd[水源地审批单位代码]");
  200. cols.add("ts[时间戳]");
  201. cols.add("nt[备注]");
  202. export.setCols(cols);
  203. export.setGroupable(false);
  204. // 设置视图指标
  205. export.setLevel(1);
  206. export.setLocksize(0);
  207. try {
  208. export.Export(response);
  209. export.ExportHeadForCustom(response);//导出表头
  210. export.ContinueExport(mapList);
  211. export.EndExport();
  212. } catch (Exception e) {
  213. e.printStackTrace();
  214. }
  215. }
  216. }