package cn.com.goldenwater.dcproj.service.impl.zhejiang; import cn.com.goldenwater.dcproj.constValue.BisInspEnum; import cn.com.goldenwater.dcproj.constValue.SplitValue; import cn.com.goldenwater.dcproj.dao.*; import cn.com.goldenwater.dcproj.dto.AttCountryDto; import cn.com.goldenwater.dcproj.dto.BisNewVillRgstrDto; import cn.com.goldenwater.dcproj.dto.SumNewVillNumDto; import cn.com.goldenwater.dcproj.model.*; import cn.com.goldenwater.dcproj.param.*; import cn.com.goldenwater.dcproj.service.BisInspObjStrategy; import cn.com.goldenwater.dcproj.service.BisZhejiangVillRgstrService; import cn.com.goldenwater.core.service.AbstractCrudService; import cn.com.goldenwater.dcproj.utils.AdLevelUtil; 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 javax.servlet.http.HttpServletResponse; import java.util.Date; import java.util.List; /** * @author lune * @date 2020-5-11 */ @Service @Transactional public class BisZhejiangVillRgstrServiceImpl extends AbstractCrudService implements BisZhejiangVillRgstrService ,BisInspObjStrategy { @Autowired private BisZhejiangVillRgstrDao bisZhejiangVillRgstrDao; @Autowired private AttAdXBaseDao attAdXBaseDao; @Autowired private BisInspPblmDao bisInspPblmDao; @Autowired private BisInspAllObjDao inspAllObjDao; public BisZhejiangVillRgstrServiceImpl(BisZhejiangVillRgstrDao bisZhejiangVillRgstrDao) { super(bisZhejiangVillRgstrDao); this.bisZhejiangVillRgstrDao = bisZhejiangVillRgstrDao; } @Override public PageInfo findNewVillListByType(TypeParam typeParam) { List list = bisZhejiangVillRgstrDao.findNewVillPageByType(typeParam); setCountType(list); PageInfo pageInfo = new PageInfo(list); return pageInfo; } @Override public void updateVillSum(BisZhejiangVillRgstr bisNewVillRgstr) { bisZhejiangVillRgstrDao.updateVillSum(bisNewVillRgstr); } @Override public PageInfo pageNotAddRegstr(CommonParam commonParam) { PageHelper.startPage(commonParam); List list = bisZhejiangVillRgstrDao.pageNotAddRegstr(commonParam); PageInfo pageInfo = new PageInfo(list); return pageInfo; } @Override public PageInfo findPageList(PlbmParam pblmParam) { PageHelper.startPage(pblmParam); if (StringUtils.isNotBlank(pblmParam.getAdCode())) { pblmParam.setAdCode(String.valueOf(AdLevelUtil.SubAd(pblmParam.getAdCode()).get(SplitValue.SUBAD))); } List list = bisZhejiangVillRgstrDao.findPageList(pblmParam); PageInfo pageInfo = new PageInfo(list); return pageInfo; } private List findObjListByTypeNew(TypeParam typeParam){ List list = bisZhejiangVillRgstrDao.findPageByType(typeParam); setCountType(list); setSsx(list); return list; } @Override public PageInfo findPageByType(TypeParam typeParam) { PageHelper.startPage(typeParam); List list = bisZhejiangVillRgstrDao.findPageByType(typeParam); setCountType(list); setSsx(list); PageInfo pageInfo = new PageInfo(list); return pageInfo; } private void setSsx(List list){ if (list.size() > 0) { for (BisNewVillRgstrDto b : list) { if (b.getAdFullName() != null) { if (b.getAdFullName().contains(SplitValue.HENG_SPLIT)) { String[] split = b.getAdFullName().split(SplitValue.HENG_SPLIT); if (split.length == 3) { b.setProvince(split[0]); b.setCity(split[1]); b.setCounty(split[2]); } if (split.length == 2) { b.setProvince(split[0]); b.setCity(split[1]); b.setCounty(""); } } else { b.setProvince(b.getAdFullName()); } } } } } private void setCountType(List list){ for (BisNewVillRgstrDto dto : list) { if(StringUtils.isBlank(dto.getCode())){ continue; } if(dto.getVillNum()!=0){ continue; } String code=dto.getCode(); if(dto.getCode().length()>6){ code=code.substring(0,6); if(code.endsWith("00")){ code=code.substring(0,4); } } if(code.length()<6){ continue; } SumNewVillNumDto villNUm = bisZhejiangVillRgstrDao.sumNewVillNumAdd(dto.getRgstrId(),code); dto.setVillNum(villNUm.getVillNum()); dto.setProNum(villNUm.getProNum()); BisZhejiangVillRgstr bisNewVillRgstr=new BisZhejiangVillRgstr(); bisNewVillRgstr.setId(dto.getRgstrId()); bisNewVillRgstr.setVillNum(villNUm.getVillNum()); bisNewVillRgstr.setProNum(villNUm.getProNum()); bisZhejiangVillRgstrDao.updateAllNum(bisNewVillRgstr); } } @Override public void updateAllNum(BisZhejiangVillRgstr bisNewVillRgstr) { bisZhejiangVillRgstrDao.updateAllNum(bisNewVillRgstr); } @Override public void updateProSum(BisZhejiangVillRgstr bisNewVillRgstr) { bisZhejiangVillRgstrDao.updateProSum(bisNewVillRgstr); } @Override public void insertObj(BisInspAllObj bisInspAllObj, String persId) { AttAdXBase attAdXBase = attAdXBaseDao.get(bisInspAllObj.getCode()); BisZhejiangVillRgstr bisNewVillRgstr=new BisZhejiangVillRgstr(); bisNewVillRgstr.setId(UuidUtil.uuid()); bisNewVillRgstr.setIsPkx(attAdXBase.getIsPoveryt()); bisNewVillRgstr.setObjId(bisInspAllObj.getObjId()); bisNewVillRgstr.setRegsNm(attAdXBase.getAdName()); bisNewVillRgstr.setState("0"); bisNewVillRgstr.setPersId(persId); bisNewVillRgstr.setLttdpc(attAdXBase.getLttdpc()); bisNewVillRgstr.setLgtdpc(attAdXBase.getLgtdpc()); bisNewVillRgstr.setLgtd(attAdXBase.getLgtd()); bisNewVillRgstr.setLttd(attAdXBase.getLttd()); bisNewVillRgstr.setAdFullName(attAdXBase.getAdFullName()); bisNewVillRgstr.setAdCode(attAdXBase.getAdCode()); bisNewVillRgstr.setUptm(new Date()); bisNewVillRgstr.setIntm(new Date()); bisZhejiangVillRgstrDao.insert(bisNewVillRgstr); } @Override public String getType() { return BisInspEnum.VILLZHEJIANG.getValue(); } @Autowired private BisZhejiangDcuserRelVillDao bisZhejiangDcuserRelVillDao; @Autowired private BisZhejiangCountryFeeDao bisZhejiangCountryFeeDao; @Override public void cleanObjData(String objId) { BisZhejiangVillRgstrParam bisInspVillRgstrParam = new BisZhejiangVillRgstrParam(); bisInspVillRgstrParam.setObjId(objId); BisInspAllObjParam inspAllObjParam=new BisInspAllObjParam(); inspAllObjParam.setObjId(objId); inspAllObjDao.deleteBy(inspAllObjParam); List list = this.bisZhejiangVillRgstrDao.findList(bisInspVillRgstrParam); if (list.size() > 0) { String id = list.get(0).getId(); BisInspPblmParam bisInspPblmParam = new BisInspPblmParam(); bisInspPblmParam.setRegid(id); bisInspPblmParam.setObjType(BisInspEnum.VILL2020.getValue()); this.bisInspPblmDao.deleteBy(bisInspPblmParam);//ɾ������ BisZhejiangVillRgstrParam villRgstrParam=new BisZhejiangVillRgstrParam(); villRgstrParam.setId(id); BisZhejiangVillRgstr villRgstr=bisZhejiangVillRgstrDao.get(id); if(villRgstr!=null) { bisZhejiangVillRgstrDao.delete(id); BisZhejiangDcuserRelVillParam newDcuserRelVillParam = new BisZhejiangDcuserRelVillParam(); newDcuserRelVillParam.setRgstrId(villRgstr.getId()); bisZhejiangDcuserRelVillDao.deleteBy(newDcuserRelVillParam); BisZhejiangCountryFeeParam newCountryFeeParam = new BisZhejiangCountryFeeParam(); newCountryFeeParam.setRgstrId(villRgstr.getId()); bisZhejiangCountryFeeDao.deleteBy(newCountryFeeParam); } } } @Override public PageInfo findObjPageByType(TypeParam typeParam, HttpServletResponse response) { return findNewVillListByType(typeParam); } @Override public Object findObjListByType(TypeParam typeParam) { return findObjListByTypeNew(typeParam); } }