| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236 |
- package cn.com.goldenwater.dcproj.service.impl.wr;
- import cn.com.goldenwater.dcproj.dao.WrGwsBDao;
- import cn.com.goldenwater.dcproj.model.WrGwsB;
- import cn.com.goldenwater.dcproj.param.WrGwsBParam;
- import cn.com.goldenwater.dcproj.service.WrGwsBService;
- import cn.com.goldenwater.core.service.AbstractCrudService;
- import cn.com.goldenwater.dcproj.utils.BeanUtil;
- import cn.com.goldenwater.dcproj.utils.GeoUtil;
- import cn.com.goldenwater.dcproj.utils.expExcel.ExcelExport;
- import cn.com.goldenwater.dcproj.utils.expExcel.ExportAbstract;
- import com.github.pagehelper.PageHelper;
- import org.apache.commons.lang3.StringUtils;
- import org.apache.commons.lang3.math.NumberUtils;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Service;
- import org.springframework.transaction.annotation.Transactional;
- import com.github.pagehelper.PageInfo;
- import java.util.ArrayList;
- import java.util.List;
- import java.util.Map;
- import cn.com.goldenwater.dcproj.utils.DateUtils;
- import javax.servlet.http.HttpServletResponse;
- /**
- * @author zhengdafei
- * @date 2019-3-3
- */
- @Service
- @Transactional
- public class WrGwsBServiceImpl extends AbstractCrudService<WrGwsB, WrGwsBParam> implements WrGwsBService {
- @Autowired
- private WrGwsBDao wrGwsBDao;
- public WrGwsBServiceImpl(WrGwsBDao wrGwsBDao) {
- super(wrGwsBDao);
- this.wrGwsBDao = wrGwsBDao;
- }
- @Override
- public String add(WrGwsB p) throws Exception {
- String uuid = "";
- String now = DateUtils.getTodayYMDHMS();
- if (StringUtils.isNotBlank(p.getAdCode())) {
- String maxGwsCode = wrGwsBDao.getMaxGwsCode(p.getAdCode().substring(0, 6)); //根据最大code生成cwscode
- if (maxGwsCode != null) {
- Long mCcode = 0L;
- if (maxGwsCode == null) {
- mCcode = NumberUtils.createLong(p.getAdCode());
- Long gwsCode = mCcode + 1;
- p.setGwsCd(gwsCode + "");
- } else {
- mCcode = NumberUtils.createLong(maxGwsCode);
- Long gwsCode = mCcode + 1;
- p.setGwsCd(gwsCode + "");
- }
- }
- } else {
- throw new Exception("adCode不能为空");
- }
- transferGeo(p);
- p.setTs(now);
- wrGwsBDao.insert(p);
- uuid = p.getGwsCd();
- return uuid;
- }
- @Override
- public int modify(WrGwsB p) throws Exception {
- String now = DateUtils.getTodayYMDHMS();
- transferGeo(p);
- p.setTs(now);
- int ret = wrGwsBDao.update(p);
- return ret;
- }
- public void transferGeo(WrGwsB p) {
- String src = p.getSrc();
- if (StringUtils.isNotBlank(src)) {
- if ("PC".equalsIgnoreCase(src)) {
- if (p.getLgtdpc() != null && p.getLttdpc() != null) {
- Map<String, Double> map = GeoUtil.wgs84togcj02(p.getLgtdpc(), p.getLttdpc());
- p.setLgtd(map.get("lon"));
- p.setLttd(map.get("lat"));
- }
- } else if ("MOBILE".equalsIgnoreCase(src)) {
- if (p.getLgtd() != null && p.getLttd() != null) {
- Map<String, Double> map = GeoUtil.gcj02towgs84(p.getLgtd(), p.getLttd());
- p.setLgtdpc(map.get("lon"));
- p.setLttdpc(map.get("lat"));
- }
- }
- } else {
- if (p.getLgtdpc() != null && p.getLttdpc() != null) {
- Map<String, Double> map = GeoUtil.wgs84togcj02(p.getLgtdpc(), p.getLttdpc());
- p.setLgtd(map.get("lon"));
- p.setLttd(map.get("lat"));
- } else if (p.getLgtd() != null && p.getLttd() != null) {
- Map<String, Double> map = GeoUtil.gcj02towgs84(p.getLgtd(), p.getLttd());
- p.setLgtdpc(map.get("lon"));
- p.setLttdpc(map.get("lat"));
- }
- }
- }
- @Override
- public PageInfo<WrGwsB> queryListByPage(WrGwsBParam p) throws Exception {
- PageHelper.startPage(p.getPageNum(), p.getPageSize());
- List<WrGwsB> list = wrGwsBDao.findList(p);
- return new PageInfo<WrGwsB>(list);
- }
- @Override
- public List<WrGwsB> queryList(WrGwsBParam p) throws Exception {
- List<WrGwsB> list = wrGwsBDao.findList(p);
- return list;
- }
- @Override
- public void exportWrGwsB(WrGwsBParam wrGwsBParam, HttpServletResponse response) {
- List<WrGwsB> list=wrGwsBDao.findList(wrGwsBParam);
- List<Map<String,Object>> mapList = new ArrayList<>();
- for (WrGwsB wrGwsB : list) {
- String wqGoal=wrGwsB.getWqGoal();
- String monG=wrGwsB.getMonG();
- String consCond=wrGwsB.getConsCond();
-
- if ("1".equals(wqGoal)){
- wrGwsB.setWqGoal("Ⅰ类");
- }else if ("2".equals(wqGoal)){
- wrGwsB.setWqGoal("Ⅱ类");
- }else if ("3".equals(wqGoal)){
- wrGwsB.setWqGoal("Ⅲ类");
- }else if ("4".equals(wqGoal)){
- wrGwsB.setWqGoal("Ⅳ类");
- }else if ("5".equals(wqGoal)){
- wrGwsB.setWqGoal("Ⅴ类");
- }else if ("6".equals(wqGoal)){
- wrGwsB.setWqGoal("劣Ⅴ类");
- }else if ("12".equals(wqGoal)){
- wrGwsB.setWqGoal("I-II类");
- }else if ("13".equals(wqGoal)){
- wrGwsB.setWqGoal("I-III类");
- }else if ("14".equals(wqGoal)){
- wrGwsB.setWqGoal("I-IV类");
- }else if ("15".equals(wqGoal)){
- wrGwsB.setWqGoal("I-V类");
- }else if ("16".equals(wqGoal)){
- wrGwsB.setWqGoal("I-劣Ⅴ类");
- }else if ("23".equals(wqGoal)){
- wrGwsB.setWqGoal("II-III类");
- }else if ("24".equals(wqGoal)){
- wrGwsB.setWqGoal("II-IV类");
- }else if ("25".equals(wqGoal)){
- wrGwsB.setWqGoal("II-V类");
- }else if ("26".equals(wqGoal)){
- wrGwsB.setWqGoal("II-劣V类");
- }else if ("34".equals(wqGoal)){
- wrGwsB.setWqGoal("III-IV类");
- }else if ("35".equals(wqGoal)){
- wrGwsB.setWqGoal("III-V类");
- }else if ("36".equals(wqGoal)){
- wrGwsB.setWqGoal("III-劣Ⅴ类");
- }else if ("45".equals(wqGoal)){
- wrGwsB.setWqGoal("IV-V类");
- }else if ("46".equals(wqGoal)){
- wrGwsB.setWqGoal("IV-劣V类");
- }else if ("56".equals(wqGoal)){
- wrGwsB.setWqGoal("V-劣V类");
- }
- if ("0".equals(monG)||"9".equals(monG)){
- wrGwsB.setMonG("其他");
- }else if ("1".equals(monG)){
- wrGwsB.setMonG("国控级");
- }else if ("2".equals(monG)){
- wrGwsB.setMonG("省控级");
- }else if ("3".equals(monG)){
- wrGwsB.setMonG("地市级");
- }
- if ("1".equals(consCond)){
- wrGwsB.setConsCond("已建");
- }else if ("2".equals(consCond)){
- wrGwsB.setConsCond("在建");
- }else if ("3".equals(consCond)){
- wrGwsB.setConsCond("待建");
- }
-
- mapList.add(BeanUtil.transBean2Map(wrGwsB));
- }
- ExportAbstract export = new ExcelExport();
- export.setFileName("地下水水源地基础信息");
- export.setExport_ps_export(true);
- export.setExport_ps_type(ExportAbstract.XLS);
- export.setExport_bzip(false);
- export.setTitle("地下水水源地基础信息");
- ArrayList<Object> cols = new ArrayList<Object>();
- cols.add("gwsCd[地下水水源地代码]");
- cols.add("gwsNm[地下水水源地名称]");
- cols.add("gwsA[地下水水源地面积]");
- cols.add("rangDesc[范围描述]");
- cols.add("wqGoal[水质目标]");
- cols.add("consCond[建设状况]");
- cols.add("putProdTm[投产时间]");
- cols.add("avgExpYd[多年平均年可开采量]");
- cols.add("wsObj[供水对象]");
- cols.add("monG[监控级别]");
- cols.add("desInt[设计年取水量(万立方米)]");
- cols.add("permInt[年许可取水量(万立方米)]");
- cols.add("whsManCd[水源地管理单位代码]");
- cols.add("whsApprCd[水源地审批单位代码]");
- cols.add("ts[时间戳]");
- cols.add("nt[备注]");
- export.setCols(cols);
- export.setGroupable(false);
- // 设置视图指标
- export.setLevel(1);
- export.setLocksize(0);
- try {
- export.Export(response);
- export.ExportHeadForCustom(response);//导出表头
- export.ContinueExport(mapList);
- export.EndExport();
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- }
|