package cn.com.goldenwater.dcproj.service.impl.vill; import cn.com.goldenwater.dcproj.dao.AttCwsBaseDao; import cn.com.goldenwater.dcproj.dao.BisInspVillRgstrDao; import cn.com.goldenwater.dcproj.dao.BisInspVlgdrinkProjManageDao; import cn.com.goldenwater.dcproj.dto.BisInspVlgdrinkProjManageDcdxDto; import cn.com.goldenwater.dcproj.dto.VillRgstrDto; import cn.com.goldenwater.dcproj.model.AttCwsBase; import cn.com.goldenwater.dcproj.model.BisInspVillRgstr; import cn.com.goldenwater.dcproj.model.BisInspVlgdrinkProjManage; import cn.com.goldenwater.dcproj.param.AttCwsBaseParam; import cn.com.goldenwater.dcproj.param.BisInspVlgdrinkProjManageParam; import cn.com.goldenwater.dcproj.param.GetPageByNodeIdParam; import cn.com.goldenwater.dcproj.param.GetVillPageByNodeIdParam; import cn.com.goldenwater.dcproj.service.BisInspVlgdrinkProjManageService; import cn.com.goldenwater.core.service.AbstractCrudService; 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.List; import cn.com.goldenwater.id.util.UuidUtil; import java.util.Date; import cn.com.goldenwater.dcproj.utils.DateUtils; /** * @author zhengdafei * @date 2019-2-21 */ @Service @Transactional public class BisInspVlgdrinkProjManageServiceImpl extends AbstractCrudService implements BisInspVlgdrinkProjManageService { @Autowired private BisInspVlgdrinkProjManageDao bisInspVlgdrinkProjManageDao; @Autowired private AttCwsBaseDao attCwsBaseDao; @Autowired private BisInspVillRgstrDao bisInspVillRgstrDao; public BisInspVlgdrinkProjManageServiceImpl(BisInspVlgdrinkProjManageDao bisInspVlgdrinkProjManageDao) { super(bisInspVlgdrinkProjManageDao); this.bisInspVlgdrinkProjManageDao = bisInspVlgdrinkProjManageDao; } @Override public String add(BisInspVlgdrinkProjManage p) throws Exception { String uuid = UuidUtil.uuid(); String now = DateUtils.getTodayYMDHMS(); p.setCreateTime(now); p.setUpdateTime(now); p.setRunId(uuid); AttCwsBaseParam cwsp = new AttCwsBaseParam(); cwsp.setCwsCode(p.getCwsCode()); if (StringUtils.isNotBlank(p.getCwsCode())) { AttCwsBase cws = attCwsBaseDao.getBy(cwsp); if (cws != null) { if (StringUtils.isBlank(p.getPjnm())) { p.setPjnm(cws.getCwsName()); } if (StringUtils.isBlank(p.getVillageNm())) { p.setVillageNm(cws.getCwsLoc()); } if (p.getBuildYear() == null || p.getBuildYear() == 0) { if (StringUtils.isNotBlank(cws.getCompDate())) { p.setBuildYear(NumberUtils.toLong(cws.getCompDate().split("-")[0])); } } if (p.getPlanSupplyScale() == null || p.getPlanSupplyScale() == 0) { if (cws.getDesWasuScal() != null) { p.setPlanSupplyScale(cws.getDesWasuScal().doubleValue()); } } if (p.getPersonNum() == null || p.getPersonNum() == 0) { if (cws.getDesWasuPop() != null) { p.setPersonNum(NumberUtils.toLong(cws.getDesWasuPop() * 10000 + "")); } } } } bisInspVlgdrinkProjManageDao.insert(p); BisInspVillRgstr rp = new BisInspVillRgstr(); rp.setEngId(p.getEngId()); rp.setState("1"); bisInspVillRgstrDao.update(rp); return uuid; } @Override public int modify(BisInspVlgdrinkProjManage p) throws Exception { String now = DateUtils.getTodayYMDHMS(); p.setUpdateTime(now); AttCwsBase attCwsBase = attCwsBaseDao.get(p.getCwsCode()); if (attCwsBase != null) { if (StringUtils.isBlank(p.getPjnm())) { p.setPjnm(attCwsBase.getCwsName()); } if (StringUtils.isBlank(p.getVillageNm())) { p.setVillageNm(attCwsBase.getCwsLoc()); } if (p.getBuildYear() == null || p.getBuildYear() == 0) { if (StringUtils.isNotBlank(attCwsBase.getCompDate())) { p.setBuildYear(NumberUtils.toLong(attCwsBase.getCompDate().split("-")[0])); } } if (p.getPlanSupplyScale() == null || p.getPlanSupplyScale() == 0) { if (attCwsBase.getDesWasuScal() != null) { p.setPlanSupplyScale(attCwsBase.getDesWasuScal().doubleValue()); } } if (p.getPersonNum() == null || p.getPersonNum() == 0) { if (attCwsBase.getDesWasuPop() != null) { p.setPersonNum(NumberUtils.toLong(attCwsBase.getDesWasuPop() * 10000 + "")); } } } int ret = bisInspVlgdrinkProjManageDao.update(p); return ret; } @Override public PageInfo queryListByPage(BisInspVlgdrinkProjManageParam p) throws Exception { PageHelper.startPage(p.getPageNum(), p.getPageSize()); List list = bisInspVlgdrinkProjManageDao.findList(p); return new PageInfo(list); } @Override public List queryList(BisInspVlgdrinkProjManageParam p) throws Exception { List list = bisInspVlgdrinkProjManageDao.findList(p); return list; } @Override public List queryListByObjId(String objId, String name) throws Exception { List list = bisInspVlgdrinkProjManageDao.queryListByObjId(objId, name); return list; } @Override public List getListByCodeAndPerId(VillRgstrDto villRgstrDto) { return this.bisInspVlgdrinkProjManageDao.getListByCodeAndPerId(villRgstrDto); } @Override public PageInfo getPageByCodeAndPerId(VillRgstrDto villRgstrDto) { PageHelper.startPage(villRgstrDto.getPageNum(), villRgstrDto.getPageSize()); List list = bisInspVlgdrinkProjManageDao.getListByCodeAndPerId(villRgstrDto); return new PageInfo(list); } @Override public PageInfo getPageByNodeId(GetVillPageByNodeIdParam p) throws Exception { PageHelper.startPage(p.getPageNum(), p.getPageSize()); List list = bisInspVlgdrinkProjManageDao.getPageByNodeId(p); return new PageInfo(list); } }