| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262 |
- package cn.com.goldenwater.dcproj.service.impl.wr;
- import cn.com.goldenwater.dcproj.dao.WrSwsBDao;
- import cn.com.goldenwater.dcproj.model.WrSwsB;
- import cn.com.goldenwater.dcproj.param.WrSwsBParam;
- import cn.com.goldenwater.dcproj.service.WrSwsBService;
- 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 WrSwsBServiceImpl extends AbstractCrudService<WrSwsB, WrSwsBParam> implements WrSwsBService {
- @Autowired
- private WrSwsBDao wrSwsBDao;
- public WrSwsBServiceImpl(WrSwsBDao wrSwsBDao) {
- super(wrSwsBDao);
- this.wrSwsBDao = wrSwsBDao;
- }
- @Override
- public String add(WrSwsB p) throws Exception {
- String uuid = "";
- String now = DateUtils.getTodayYMDHMS();
- if (StringUtils.isNotBlank(p.getAdCode())) {
- String maxCwsCode = wrSwsBDao.getMaxCwsCode(p.getAdCode().substring(0, 6)); //根据最大code生成cwscode
- if (maxCwsCode != null) {
- Long mCcode = 0L;
- if (maxCwsCode == null) {
- mCcode = NumberUtils.createLong(p.getAdCode());
- Long gwsCode = mCcode + 1;
- p.setSwsCd(gwsCode + "");
- } else {
- mCcode = NumberUtils.createLong(maxCwsCode);
- Long gwsCode = mCcode + 1;
- p.setSwsCd(gwsCode + "");
- }
- }
- } else {
- throw new Exception("adCode不能为空");
- }
- transferGeo(p);
- p.setTs(now);
- wrSwsBDao.insert(p);
- uuid = p.getSwsCd();
- return uuid;
- }
- @Override
- public int modify(WrSwsB p) throws Exception {
- String now = DateUtils.getTodayYMDHMS();
- p.setTs(now);
- transferGeo(p);
- int ret = wrSwsBDao.update(p);
- return ret;
- }
- public void transferGeo(WrSwsB 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<WrSwsB> queryListByPage(WrSwsBParam p) throws Exception {
- PageHelper.startPage(p.getPageNum(), p.getPageSize());
- List<WrSwsB> list = wrSwsBDao.findList(p);
- return new PageInfo<WrSwsB>(list);
- }
- @Override
- public List<WrSwsB> queryList(WrSwsBParam p) throws Exception {
- List<WrSwsB> list = wrSwsBDao.findList(p);
- return list;
- }
- @Override
- public void exportWrSwsB(WrSwsBParam wrSwsBParam, HttpServletResponse response) {
- List<WrSwsB> list=new ArrayList<>();
- list=wrSwsBDao.findList(wrSwsBParam);
- List<Map<String,Object>> mapList = new ArrayList<>();
- for (WrSwsB wrSwsB : list) {
- String swsTp=wrSwsB.getSwsTp();
- String wqGoal=wrSwsB.getWqGoal();
- String consCond=wrSwsB.getConsCond();
- String wsCond=wrSwsB.getWsCond();
- String monG=wrSwsB.getMonG();
- if("1".equals(swsTp)){
- wrSwsB.setSwsTp("河道(江河)");
- }else if ("2".equals(swsTp)){
- wrSwsB.setSwsTp("水库");
- }else if ("3".equals(swsTp)){
- wrSwsB.setSwsTp("湖泊");
- }else if ("9".equals(swsTp)){
- wrSwsB.setSwsTp("其他");
- }
- if ("1".equals(wqGoal)){
- wrSwsB.setWqGoal("Ⅰ类");
- }else if ("2".equals(wqGoal)){
- wrSwsB.setWqGoal("Ⅱ类");
- }else if ("3".equals(wqGoal)){
- wrSwsB.setWqGoal("Ⅲ类");
- }else if ("4".equals(wqGoal)){
- wrSwsB.setWqGoal("Ⅳ类");
- }else if ("5".equals(wqGoal)){
- wrSwsB.setWqGoal("Ⅴ类");
- }else if ("6".equals(wqGoal)){
- wrSwsB.setWqGoal("劣Ⅴ类");
- }else if ("12".equals(wqGoal)){
- wrSwsB.setWqGoal("I-II类");
- }else if ("13".equals(wqGoal)){
- wrSwsB.setWqGoal("I-III类");
- }else if ("14".equals(wqGoal)){
- wrSwsB.setWqGoal("I-IV类");
- }else if ("15".equals(wqGoal)){
- wrSwsB.setWqGoal("I-V类");
- }else if ("16".equals(wqGoal)){
- wrSwsB.setWqGoal("I-劣Ⅴ类");
- }else if ("23".equals(wqGoal)){
- wrSwsB.setWqGoal("II-III类");
- }else if ("24".equals(wqGoal)){
- wrSwsB.setWqGoal("II-IV类");
- }else if ("25".equals(wqGoal)){
- wrSwsB.setWqGoal("II-V类");
- }else if ("26".equals(wqGoal)){
- wrSwsB.setWqGoal("II-劣V类");
- }else if ("34".equals(wqGoal)){
- wrSwsB.setWqGoal("III-IV类");
- }else if ("35".equals(wqGoal)){
- wrSwsB.setWqGoal("III-V类");
- }else if ("36".equals(wqGoal)){
- wrSwsB.setWqGoal("III-劣Ⅴ类");
- }else if ("45".equals(wqGoal)){
- wrSwsB.setWqGoal("IV-V类");
- }else if ("46".equals(wqGoal)){
- wrSwsB.setWqGoal("IV-劣V类");
- }else if ("56".equals(wqGoal)){
- wrSwsB.setWqGoal("V-劣V类");
- }
- if ("1".equals(consCond)){
- wrSwsB.setConsCond("已建");
- }else if ("2".equals(consCond)){
- wrSwsB.setConsCond("在建");
- }else if ("3".equals(consCond)){
- wrSwsB.setConsCond("待建");
- }
- if ("1".equals(wsCond)){
- wrSwsB.setWsCond("常年");
- }else if ("2".equals(wsCond)){
- wrSwsB.setWsCond("汛期");
- }else if ("3".equals(wsCond)){
- wrSwsB.setWsCond("非汛期");
- }
- if ("0".equals(monG)||"9".equals(monG)){
- wrSwsB.setMonG("其他");
- }else if ("1".equals(monG)){
- wrSwsB.setMonG("国控级");
- }else if ("2".equals(monG)){
- wrSwsB.setMonG("省控级");
- }else if ("3".equals(monG)){
- wrSwsB.setMonG("地市级");
- }
- mapList.add(BeanUtil.transBean2Map(wrSwsB));
- }
- 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("swsCd[地表水水源地代码]");
- cols.add("swsNm[地表水水源地名称]");
- cols.add("swsTp[地表水水源地类型]");
- cols.add("watA[水面面积(平方公里)]");
- cols.add("wqGoal[水质目标]");
- cols.add("consCond[建设状况]");
- cols.add("putProdTm[投产时间]");
- cols.add("runCond[运行状况]");
- cols.add("wsCond[水源供水持续状况]");
- cols.add("wsObj[供水对象]");
- cols.add("dywsPp[设计年供水人口(万人)]");
- cols.add("dywsW[设计年供水量(万立方米)]");
- cols.add("whsManCd[水源地管理单位代码]");
- cols.add("whsApprCd[水源地审批单位代码]");
- cols.add("emCd[应急管理单位代码]");
- cols.add("monG[监控级别]");
- 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();
- }
- }
- }
|