| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359 |
- package cn.com.goldenwater.dcproj.service.impl.other;
- import cn.com.goldenwater.dcproj.dao.*;
- import cn.com.goldenwater.dcproj.dto.BisInspOtherPblmDto;
- import cn.com.goldenwater.dcproj.dto.PersAllDto;
- import cn.com.goldenwater.dcproj.model.*;
- import cn.com.goldenwater.dcproj.param.*;
- import cn.com.goldenwater.dcproj.service.BisInspOtherPblmService;
- import cn.com.goldenwater.core.service.AbstractCrudService;
- import cn.com.goldenwater.dcproj.service.GwComFileService;
- import cn.com.goldenwater.dcproj.utils.BeanUtil;
- import cn.com.goldenwater.dcproj.utils.impexcel.ExpAndImpUtil;
- import cn.com.goldenwater.id.util.UuidUtil;
- import com.github.pagehelper.PageHelper;
- import com.github.pagehelper.PageInfo;
- import org.apache.commons.lang3.StringUtils;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Service;
- import org.springframework.transaction.annotation.Transactional;
- import java.text.ParseException;
- import java.text.SimpleDateFormat;
- import java.util.*;
- /**
- * @author lune
- * @date 2019-7-19
- */
- @Service
- @Transactional
- public class BisInspOtherPblmServiceImpl extends AbstractCrudService<BisInspOtherPblm, BisInspOtherPblmParam> implements BisInspOtherPblmService {
- @Autowired
- private BisInspOtherPblmDao bisInspOtherPblmDao;
- @Autowired
- private AttAdXBaseDao attAdXBaseDao;
- @Autowired
- private BisInspAllDao bisInspAllDao;
- @Autowired
- private BisInspOtherRgstrDao rgstrDao;
- @Autowired
- private BisInspAllObjDao allObjDao;
- @Autowired
- private AttOtherBaseDao otherBaseDao;
- @Autowired
- private GwComFileService gwComFileService;
- @Autowired
- private SupervisionPlanDao supervisionPlanDao;
- public BisInspOtherPblmServiceImpl(BisInspOtherPblmDao bisInspOtherPblmDao) {
- super(bisInspOtherPblmDao);
- this.bisInspOtherPblmDao = bisInspOtherPblmDao;
- }
- @Override
- public int insertIntoData(List<LinkedHashMap<String, Object>> list) {
- Map<String, String> areaMap = new HashMap<>();
- areaMap.put("黄河流域", "001010");
- areaMap.put("长江流域", "001009");
- areaMap.put("珠江流域", "001013");
- areaMap.put("海河流域", "001012");
- areaMap.put("松花江流域", "001014");
- areaMap.put("淮河流域", "001011");
- areaMap.put("太湖流域", "001015");
- Iterator<LinkedHashMap<String, Object>> iterator = list.iterator();
- List<BisInspOtherRgstr> otherRgstrs = new ArrayList<>();
- List<BisInspOtherPblm> pblms = new ArrayList<>();
- while (iterator.hasNext()) {
- LinkedHashMap<String, Object> map = iterator.next();
- if (StringUtils.isBlank(String.valueOf(map.get("name")))) {
- continue;
- }
- BisInspOtherPblmDto otherPblmDto = null;
- try {
- otherPblmDto = (BisInspOtherPblmDto) ExpAndImpUtil.convertMapToBean(BisInspOtherPblmDto.class, map);
- } catch (Exception e) {
- throw new NullPointerException("转换失败");
- }
- String type = type(otherPblmDto.getType());
- if (StringUtils.isBlank(type)) {
- continue;
- }
- String name = otherPblmDto.getName();
- String adCode = "";
- try {
- if (StringUtils.isNotBlank(otherPblmDto.getProvince())) {
- adCode = getAdCode(otherPblmDto.getProvince(), "000000000000");
- if (StringUtils.isNotBlank(otherPblmDto.getCity())) {
- adCode = getAdCode(otherPblmDto.getCity(), adCode);
- if (StringUtils.isNotBlank(otherPblmDto.getCountry())) {
- adCode = getAdCode(otherPblmDto.getCountry(), adCode);
- }
- }
- }
- } catch (Exception e) {
- e.printStackTrace();
- }
- String orgId = "";
- if (StringUtils.isNotBlank(otherPblmDto.getOrg())) {
- orgId = getOrgId(otherPblmDto.getOrg(), areaMap);
- }
- if (StringUtils.isNotBlank(otherPblmDto.getPblmNum()) && otherPblmDto.getPblmNum().indexOf(".") > 0) {
- otherPblmDto.setPblmNum(otherPblmDto.getPblmNum().substring(0, otherPblmDto.getPblmNum().indexOf(".")));
- }
- AttOtherBaseParam baseParam = new AttOtherBaseParam();
- baseParam.setName(otherPblmDto.getName());
- baseParam.setType(type);
- AttOtherBase base = otherBaseDao.getBy(baseParam);
- if (base == null) {
- continue;
- }
- base.setAdCode(adCode);
- base.setAdmOrg(orgId);
- otherBaseDao.update(base);
- BisInspOtherRgstrParam fscRgstrParam = new BisInspOtherRgstrParam();
- fscRgstrParam.setType(type);
- fscRgstrParam.setName(name);
- List<BisInspOtherRgstr> rgstrs = rgstrDao.findList(fscRgstrParam);
- if (rgstrs != null && rgstrs.size() > 1) {
- throw new NullPointerException("当前对象有多个");
- }
- BisInspOtherRgstr rgstr = null;
- if (rgstrs == null || rgstrs.size() == 0) {
- //查询督查对象表
- BisInspAllObjParam param = new BisInspAllObjParam();
- param.setNm(otherPblmDto.getName());
- param.setPtype("9");
- BisInspAllObj obj = allObjDao.getBy(param);
- rgstr = new BisInspOtherRgstr();
- rgstr.setId(UuidUtil.uuid());
- rgstr.setObjId(obj.getObjId());
- rgstr.setState("0");
- rgstr.setCenterX(obj.getLttd());
- rgstr.setCenterY(obj.getLgtd());
- rgstr.setType(type);
- rgstr.setAdCode(adCode);
- rgstr.setInTm(new Date());
- rgstr.setUpTm(new Date());
- rgstr.setName(obj.getNm());
- rgstr.setGroupId(obj.getId());
- rgstr.setAdmOrg(orgId);
- rgstr.setDataStat("0");
- this.rgstrDao.insert(rgstr);
- } else {
- rgstr = rgstrs.get(0);
- rgstr.setAdCode(adCode);
- rgstr.setAdmOrg(orgId);
- this.rgstrDao.update(rgstr);
- }
- if (rgstr != null) {
- otherRgstrs.add(rgstr);
- if (StringUtils.isNotBlank(otherPblmDto.getFdTime())) {
- try {
- otherPblmDto.setFdTm(new SimpleDateFormat("yyyy-MM-dd").parse(otherPblmDto.getFdTime()));
- } catch (ParseException e) {
- }
- }
- if (StringUtils.isNotBlank(otherPblmDto.getRectTime())) {
- try {
- otherPblmDto.setRectTm(new SimpleDateFormat("yyyy-MM-dd").parse(otherPblmDto.getRectTime()));
- } catch (ParseException e) {
- }
- }
- if (StringUtils.isBlank(otherPblmDto.getAUnit()) || StringUtils.isBlank(otherPblmDto.getPblmNum())) {
- continue;
- }
- BisInspOtherPblm pblm = new BisInspOtherPblm(otherPblmDto);
- pblm.setPblmIsTrue(pblmIsTrue(otherPblmDto.getPblmIsTrue()));
- if (StringUtils.isBlank(pblm.getId())) {
- bisInspOtherPblmDao.update(pblm);
- } else {
- pblm.setId(UuidUtil.uuid());
- pblm.setRgstrId(rgstr.getId());
- pblm.setGroupId(rgstr.getGroupId());
- pblm.setPersId(rgstr.getPersId());
- pblm.setInTm(new Date());
- pblm.setUpTm(new Date());
- pblm.setDataStat("0");
- pblms.add(pblm);
- }
- }
- }
- if (pblms.size() == 0) {
- if (otherRgstrs.size() == 0) {
- return 1;
- }
- return otherRgstrs.size();
- }
- if (pblms.size() > 0) {
- return this.bisInspOtherPblmDao.insertList(pblms);
- }
- return 0;
- }
- private String type(String typeName) {
- if ("河湖".equals(typeName)) {
- return "0";
- }
- if ("举报调查".equals(typeName)) {
- return "1";
- }
- return "";
- }
- private String typeName(String type) {
- if ("0".equals(type)) {
- return "河湖";
- }
- if ("1".equals(type)) {
- return "举报调查";
- }
- return "";
- }
- private String pblmIsTrue(String pblmIsTrue) {
- if ("不属实".equals(pblmIsTrue)) {
- return "0";
- }
- if ("部分属实".equals(pblmIsTrue)) {
- return "1";
- }
- if ("属实".equals(pblmIsTrue)) {
- return "2";
- }
- return "0";
- }
- private String revPblmIsTrue(String pblmIsTrue) {
- if (StringUtils.isBlank(pblmIsTrue)) {
- return "";
- }
- if ("0".equals(pblmIsTrue)) {
- return "不属实";
- }
- if ("1".equals(pblmIsTrue)) {
- return "部分属实";
- }
- if ("2".equals(pblmIsTrue)) {
- return "属实";
- }
- return "不属实";
- }
- private String getAdCode(String adName, String adFcode) {
- AttAdXBaseParam param = new AttAdXBaseParam();
- param.setAdName(adName);
- param.setAdFcode(adFcode);
- AttAdXBase base = this.attAdXBaseDao.getBy(param);
- return base.getAdCode();
- }
- private String getOrgId(String orgName, Map<String, String> areaMap) {
- for (String key : areaMap.keySet()) {
- if (key.contains(orgName)) {
- return areaMap.get(key);
- }
- }
- return "";
- }
- @Override
- public int updatePblm(BisInspOtherPblm bisInspOtherPblm) {
- bisInspOtherPblm.setUpTm(new Date());
- bisInspOtherPblmDao.update(bisInspOtherPblm);
- gwComFileService.updateBiz(bisInspOtherPblm.getGwComFiles(), bisInspOtherPblm.getId());
- return 0;
- }
- @Override
- public List<Map<String, Object>> findPblmList(FileParam param) {
- Map<String, String> areaMap = new HashMap<>();
- areaMap.put("001010", "黄河流域");
- areaMap.put("001009", "长江流域");
- areaMap.put("001013", "珠江流域");
- areaMap.put("001012", "海河流域");
- areaMap.put("001012", "松花江流域");
- areaMap.put("001011", "淮河流域");
- areaMap.put("001015", "太湖流域");
- List<BisInspOtherPblmDto> list = this.bisInspOtherPblmDao.findPblmList(param);
- List<Map<String, Object>> pblmList = new ArrayList<>();
- if (list.size() > 0) {
- int i = 0;
- for (BisInspOtherPblmDto b : list) {
- b.setNum(String.valueOf(i++));
- b.setType(typeName(b.getType()));
- b.setPblmIsTrue(revPblmIsTrue(b.getPblmIsTrue()));
- if (StringUtils.isNotBlank(b.getOrg())) {
- b.setOrg(getOrgId(b.getOrg(), areaMap));
- }
- if (b.getFdTm() != null) {
- b.setFdTime(new SimpleDateFormat("yyyy-MM-dd").format(b.getFdTm()));
- }
- if (b.getRectTm() != null) {
- b.setRectTime(new SimpleDateFormat("yyyy-MM-dd").format(b.getRectTm()));
- }
- if (StringUtils.isNotBlank(b.getGroupObjId())) {
- List<PersAllDto> persAllDtoList = supervisionPlanDao.getPersAllDtoList(b.getGroupObjId(),param.getOrgId(),param.getProvince());
- if (persAllDtoList != null) {
- String checkLead = "";
- String checkMemb = "";
- for (PersAllDto per : persAllDtoList) {
- if ("1".equals(per.getPersType())) {
- checkLead = checkLead + per.getPersName() + ",";
- }
- if ("2".equals(per.getPersType())) {
- checkMemb = checkMemb + per.getPersName() + ",";
- }
- }
- if (checkLead.length() > 0) {
- b.setCheckLead(checkLead.substring(0, checkLead.length() - 1));
- }
- if (checkMemb.length() > 0) {
- b.setCheckMemb(checkMemb.substring(0, checkMemb.length() - 1));
- }
- }
- }
- if (b.getAdFullName() != null) {
- if (b.getAdFullName().contains("-")) {
- String[] split = b.getAdFullName().split("-");
- if (split.length == 3) {
- b.setProvince(split[0]);
- b.setCity(split[1]);
- b.setCountry(split[2]);
- }
- if (split.length == 2) {
- b.setProvince(split[0]);
- b.setCity(split[1]);
- b.setCountry("");
- }
- } else {
- b.setProvince(b.getAdFullName());
- }
- }
- pblmList.add(BeanUtil.transBean2Map(b));
- }
- }
- return pblmList;
- }
- @Override
- public PageInfo<BisInspOtherPblm> findPageInfo(BisInspOtherPblmParam bisInspOtherPblmParam){
- PageHelper.startPage(bisInspOtherPblmParam.getPageNum(), bisInspOtherPblmParam.getPageSize());
- List<BisInspOtherPblm> bisInspFscPblms = bisInspOtherPblmDao.findPageList(bisInspOtherPblmParam);
- PageInfo page = new PageInfo(bisInspFscPblms);
- return page;
- }
- }
|