| | |
| | | package com.dy.pipIrrIrrigate.project; |
| | | |
| | | |
| | | import com.dy.common.webUtil.QueryResultVo; |
| | | import com.dy.pipIrrGlobal.daoIr.IrProjectMapper; |
| | | import com.dy.pipIrrGlobal.pojoIr.IrProject; |
| | | import com.dy.pipIrrGlobal.voIr.VoProject; |
| | | import com.dy.pipIrrGlobal.voIr.VoProjectOne; |
| | | import com.dy.pipIrrGlobal.voIr.VoProjectSimple; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.dubbo.common.utils.PojoUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * @author :WuZeYu |
| | |
| | | private IrProjectMapper irProjectMapper; |
| | | |
| | | /** |
| | | * 添加项目 |
| | | * |
| | | * 添加项目,旧版本,原则上废弃 |
| | | * @param po |
| | | * @return |
| | | */ |
| | | public Integer addProject(IrProject po) { |
| | | po.setOperateDt(new Date()); |
| | | po.setOperateTime(new Date()); |
| | | po.setDeleted((byte) 0); |
| | | if (po.getVillageId() != null) { |
| | | po.setTownId(irProjectMapper.getSupperByVillageId(po.getVillageId())); |
| | |
| | | } |
| | | |
| | | /** |
| | | * 添加项目,目前使用 |
| | | * @param po |
| | | * @return |
| | | */ |
| | | public Long addIrrigateProject(IrProject po) { |
| | | irProjectMapper.insert(po); |
| | | return po.getId(); |
| | | } |
| | | |
| | | /** |
| | | * 删除项目 |
| | | * |
| | | * @param id |
| | |
| | | } |
| | | return 1; |
| | | } |
| | | |
| | | /** |
| | | * 修改项目信息 |
| | | * @param po |
| | | * @return |
| | | */ |
| | | public Integer updateProject(IrProject po){ |
| | | po.setOperateTime(new Date()); |
| | | if (po.getVillageId() != null) { |
| | | po.setTownId(irProjectMapper.getSupperByVillageId(po.getVillageId())); |
| | | po.setCountyId(irProjectMapper.getSupperByVillageId(po.getTownId())); |
| | | po.setCityId(irProjectMapper.getSupperByVillageId(po.getCountyId())); |
| | | po.setProvinceId(irProjectMapper.getSupperByVillageId(po.getCityId())); |
| | | } |
| | | if (po.getTownId() != null) { |
| | | po.setCountyId(irProjectMapper.getSupperByVillageId(po.getTownId())); |
| | | po.setCityId(irProjectMapper.getSupperByVillageId(po.getCountyId())); |
| | | po.setProvinceId(irProjectMapper.getSupperByVillageId(po.getCityId())); |
| | | } |
| | | if (po.getCountyId() != null) { |
| | | po.setCityId(irProjectMapper.getSupperByVillageId(po.getCountyId())); |
| | | po.setProvinceId(irProjectMapper.getSupperByVillageId(po.getCityId())); |
| | | } |
| | | if (po.getCityId() != null) { |
| | | po.setProvinceId(irProjectMapper.getSupperByVillageId(po.getCityId())); |
| | | } |
| | | int rows = irProjectMapper.updateByPrimaryKeySelective(po); |
| | | if (rows == 0){ |
| | | return 0; |
| | | } |
| | | return 1; |
| | | } |
| | | |
| | | /** |
| | | * 修改项目状态 |
| | | * @param po |
| | | * @return |
| | | */ |
| | | public Integer updateProjectState(IrProject po){ |
| | | po.setOperateTime(new Date()); |
| | | int rows = irProjectMapper.updateProjectState(po); |
| | | if (rows == 0){ |
| | | return 0; |
| | | } |
| | | return 1; |
| | | } |
| | | |
| | | /** |
| | | * 获取一个项目数据 |
| | | * @param id |
| | | * @return |
| | | */ |
| | | public VoProjectOne selectById(Long id){ |
| | | VoProjectOne irProject = irProjectMapper.selectById(id); |
| | | return irProject; |
| | | } |
| | | |
| | | /** |
| | | * 分页查询项目,旧版本,原则上废弃 |
| | | * @param queryVo |
| | | * @return |
| | | */ |
| | | public QueryResultVo<List<VoProject>> getProjects(QueryVo queryVo){ |
| | | Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(queryVo); |
| | | Long itemTotal = irProjectMapper.getRecordCount(params); |
| | | |
| | | QueryResultVo<List<VoProject>> rsVo = new QueryResultVo<>(); |
| | | rsVo.pageSize = queryVo.pageSize; |
| | | rsVo.pageCurr = queryVo.pageCurr; |
| | | rsVo.calculateAndSet(itemTotal, params); |
| | | rsVo.obj = irProjectMapper.getProjects(params); |
| | | return rsVo; |
| | | } |
| | | |
| | | /** |
| | | * 分页查询项目,新版本,目前使用 |
| | | * @param queryVo |
| | | * @return |
| | | */ |
| | | public QueryResultVo<List<VoProjectSimple>> getSimpleProjects(QueryVo queryVo) { |
| | | Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(queryVo); |
| | | Long itemTotal = irProjectMapper.getSimpleProjectsCount(params); |
| | | |
| | | QueryResultVo<List<VoProjectSimple>> rsVo = new QueryResultVo<>(); |
| | | rsVo.pageSize = queryVo.pageSize; |
| | | rsVo.pageCurr = queryVo.pageCurr; |
| | | rsVo.calculateAndSet(itemTotal, params); |
| | | rsVo.obj = irProjectMapper.getSimpleProjects(params); |
| | | return rsVo; |
| | | } |
| | | } |