| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167 |
- 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<BisInspVlgdrinkProjManage, BisInspVlgdrinkProjManageParam> 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<BisInspVlgdrinkProjManage> queryListByPage(BisInspVlgdrinkProjManageParam p) throws Exception {
- PageHelper.startPage(p.getPageNum(), p.getPageSize());
- List<BisInspVlgdrinkProjManage> list = bisInspVlgdrinkProjManageDao.findList(p);
- return new PageInfo<BisInspVlgdrinkProjManage>(list);
- }
- @Override
- public List<BisInspVlgdrinkProjManage> queryList(BisInspVlgdrinkProjManageParam p) throws Exception {
- List<BisInspVlgdrinkProjManage> list = bisInspVlgdrinkProjManageDao.findList(p);
- return list;
- }
- @Override
- public List<BisInspVlgdrinkProjManage> queryListByObjId(String objId, String name) throws Exception {
- List<BisInspVlgdrinkProjManage> list = bisInspVlgdrinkProjManageDao.queryListByObjId(objId, name);
- return list;
- }
- @Override
- public List<BisInspVlgdrinkProjManage> getListByCodeAndPerId(VillRgstrDto villRgstrDto) {
- return this.bisInspVlgdrinkProjManageDao.getListByCodeAndPerId(villRgstrDto);
- }
- @Override
- public PageInfo<BisInspVlgdrinkProjManage> getPageByCodeAndPerId(VillRgstrDto villRgstrDto) {
- PageHelper.startPage(villRgstrDto.getPageNum(), villRgstrDto.getPageSize());
- List<BisInspVlgdrinkProjManage> list = bisInspVlgdrinkProjManageDao.getListByCodeAndPerId(villRgstrDto);
- return new PageInfo<BisInspVlgdrinkProjManage>(list);
- }
- @Override
- public PageInfo<BisInspVlgdrinkProjManageDcdxDto> getPageByNodeId(GetVillPageByNodeIdParam p) throws Exception {
- PageHelper.startPage(p.getPageNum(), p.getPageSize());
- List<BisInspVlgdrinkProjManageDcdxDto> list = bisInspVlgdrinkProjManageDao.getPageByNodeId(p);
- return new PageInfo<BisInspVlgdrinkProjManageDcdxDto>(list);
- }
- }
|