package cn.com.goldenwater.dcproj.service.impl.vill2020; import cn.com.goldenwater.core.service.AbstractCrudService; import cn.com.goldenwater.dcproj.constValue.BisInspEnum; import cn.com.goldenwater.dcproj.constValue.SplitValue; import cn.com.goldenwater.dcproj.constValue.StateEnum; 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.*; import cn.com.goldenwater.dcproj.utils.InspUtils; 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.ArrayList; import java.util.Date; import java.util.List; /** * @author lune * @date 2020-3-27 */ @Service @Transactional public class BisNewVillRgstrServiceImpl extends AbstractCrudService implements BisNewVillRgstrService, BisInspObjStrategy { @Autowired private BisNewVillRgstrDao bisNewVillRgstrDao; @Autowired private AttAdXBaseDao attAdXBaseDao; @Autowired private BisInspPblmDao bisInspPblmDao; @Autowired private BisNewCountryFeeService bisNewCountryFeeService; @Autowired private BisNewDcuserRelVillService bisNewDcuserRelVillService; @Autowired private BisNewWateruserInfoService bisNewWateruserInfoService; @Autowired private BisNewVillRgstrService bisNewVillRgstrService; @Autowired private BisNewCountryFeeDao bisNewCountryFeeDao; @Autowired private BisInspAllObjDao inspAllObjDao; @Autowired private BisNewWateruserInfoDao bisNewWateruserInfoDao; public BisNewVillRgstrServiceImpl(BisNewVillRgstrDao bisNewVillRgstrDao) { super(bisNewVillRgstrDao); this.bisNewVillRgstrDao = bisNewVillRgstrDao; } @Override public void insertObj(BisInspAllObj bisInspAllObj, String persId) { BisNewVillRgstr bisNewVillRgstr = new BisNewVillRgstr(); bisNewVillRgstr.setId(UuidUtil.uuid()); AttAdXBase attAdXBase = attAdXBaseDao.get(bisInspAllObj.getCode()); if (attAdXBase != null) { bisNewVillRgstr.setIsPkx(attAdXBase.getIsPoveryt()); bisNewVillRgstr.setRegsNm(attAdXBase.getAdName()); 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.setPersId(persId); bisNewVillRgstr.setObjId(bisInspAllObj.getObjId()); bisNewVillRgstr.setState("0"); bisNewVillRgstr.setUptm(new Date()); bisNewVillRgstr.setIntm(new Date()); bisNewVillRgstr.setWaterPriceIsMade("0"); bisNewVillRgstrDao.insert(bisNewVillRgstr); } @Override public void cleanObjData(String objId) { BisNewVillRgstrParam bisInspVillRgstrParam = new BisNewVillRgstrParam(); bisInspVillRgstrParam.setObjId(objId); BisInspAllObjParam inspAllObjParam = new BisInspAllObjParam(); inspAllObjParam.setObjId(objId); inspAllObjDao.deleteBy(inspAllObjParam); List list = this.bisNewVillRgstrDao.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);//ɾ������ BisNewVillRgstrParam villRgstrParam = new BisNewVillRgstrParam(); villRgstrParam.setId(id); BisNewVillRgstr villRgstr = bisNewVillRgstrService.get(id); if (villRgstr != null) { bisNewVillRgstrService.delete(id); BisNewDcuserRelVillParam newDcuserRelVillParam = new BisNewDcuserRelVillParam(); newDcuserRelVillParam.setRegstrId(villRgstr.getId()); bisNewDcuserRelVillService.deleteBy(newDcuserRelVillParam); BisNewWateruserInfoParam newWateruserInfoParam = new BisNewWateruserInfoParam(); newWateruserInfoParam.setRegstrId(villRgstr.getId()); bisNewWateruserInfoService.deleteBy(newWateruserInfoParam); BisNewCountryFeeParam newCountryFeeParam = new BisNewCountryFeeParam(); newCountryFeeParam.setRegstrId(villRgstr.getId()); bisNewCountryFeeService.deleteBy(newCountryFeeParam); } } } @Override public PageInfo findObjPageByType(TypeParam typeParam, HttpServletResponse response) { return this.findPageByType(typeParam); } @Override public Object findObjListByType(TypeParam typeParam) { return this.findNewVillListByType(typeParam); } @Override public String getType() { return BisInspEnum.VILL2020.getValue(); } @Override public PageInfo findNewVillPageByType(TypeParam typeParam) { PageHelper.startPage(typeParam); List list = bisNewVillRgstrDao.findNewVillPageByType(typeParam); setCountType(list); return new PageInfo<>(list); } private void setCountType(List list) { for (BisNewVillRgstrDto dto : list) { if (StringUtils.isBlank(dto.getCode())) { continue; } if (dto.getVillNum() != 0) { continue; } String code = dto.getCode().replace("00", ""); if (code.length() < 6) { continue; } SumNewVillNumDto villNUm = bisNewVillRgstrDao.sumNewVillNumAdd(dto.getRegstrId(), code); dto.setVillNum(villNUm.getVillNum()); dto.setProNum(villNUm.getProNum()); dto.setWaterNum(villNUm.getWaterNum()); BisNewVillRgstr bisNewVillRgstr = new BisNewVillRgstr(); bisNewVillRgstr.setId(dto.getRegstrId()); bisNewVillRgstr.setWaterNum(villNUm.getWaterNum()); bisNewVillRgstr.setVillNum(villNUm.getVillNum()); bisNewVillRgstr.setProNum(villNUm.getProNum()); bisNewVillRgstrDao.updateAllNum(bisNewVillRgstr); } } @Override public List findNewVillListByType(TypeParam typeParam) { List list = bisNewVillRgstrDao.findNewVillPageByType(typeParam); if (list == null) { return new ArrayList<>(); } return list; } @Override public PageInfo pageNotAddRegstr(CommonParam commonParam) { PageHelper.startPage(commonParam); List list = bisNewVillRgstrDao.pageNotAddRegstr(commonParam); return new PageInfo<>(list); } @Override public PageInfo findPageList(PlbmParam pblmParam) { PageHelper.startPage(pblmParam); String orgIds = InspUtils.setOrgIds(pblmParam.getOrgIds()); pblmParam.setOrgIds(orgIds); pblmParam.setCodes(InspUtils.setOrgIds(pblmParam.getCodes())); List list = bisNewVillRgstrDao.findPageList(pblmParam); if (list.size() > 0) { for (BisInspPblm 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.setCountry(split[2]); } if (split.length == 2) { b.setProvince(split[0]); b.setCity(split[1]); b.setCountry(""); } } else { b.setProvince(b.getAdFullName()); } } } } return new PageInfo<>(list); } @Override public PageInfo findPageByType(TypeParam typeParam) { PageHelper.startPage(typeParam); List list = bisNewVillRgstrDao.findPageByType(typeParam); setCountType(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()); } } } } return new PageInfo<>(list); } @Override public void updateWaterOrPay(String regstrId) { if (StringUtils.isBlank(regstrId)) { return; } BisNewCountryFeeParam countryFeeParam = new BisNewCountryFeeParam(); countryFeeParam.setRegstrId(regstrId); countryFeeParam.setStatus(StateEnum.COMASTSTATE.getKey()); BisNewVillRgstr bisNewVillRgstr = new BisNewVillRgstr(); List countryFeeList = bisNewCountryFeeDao.findList(countryFeeParam); BisNewWateruserInfoParam newWateruserInfoParam = new BisNewWateruserInfoParam(); newWateruserInfoParam.setRegstrId(regstrId); newWateruserInfoParam.setStatus(StateEnum.COMASTSTATE.getKey()); List wateruserInfoList = bisNewWateruserInfoDao.findList(newWateruserInfoParam); if (!countryFeeList.isEmpty() && !wateruserInfoList.isEmpty()) { bisNewVillRgstr.setId(regstrId); bisNewVillRgstr.setWaterSafeOrPay(StateEnum.COMASTSTATE.getKey()); bisNewVillRgstrDao.update(bisNewVillRgstr); } } @Override public void updateVillSum(BisNewVillRgstr bisNewVillRgstr) { bisNewVillRgstrDao.updateVillSum(bisNewVillRgstr); } @Override public void updateProSum(BisNewVillRgstr bisNewVillRgstr) { bisNewVillRgstrDao.updateProSum(bisNewVillRgstr); } @Override public void updateWaterSum(BisNewVillRgstr bisNewVillRgstr) { bisNewVillRgstrDao.updateWaterSum(bisNewVillRgstr); } @Override public void updateAllNum(BisNewVillRgstr bisNewVillRgstr) { bisNewVillRgstrDao.updateAllNum(bisNewVillRgstr); } }