package com.dy.pipIrrIrrigate.irrigateUnit;
|
|
import com.dy.common.webUtil.QueryResultVo;
|
import com.dy.pipIrrGlobal.daoIr.IrIrrigateUnitMapper;
|
import com.dy.pipIrrGlobal.daoIr.IrProjectMapper;
|
import com.dy.pipIrrGlobal.pojoIr.IrIrrigateUnit;
|
import com.dy.pipIrrGlobal.pojoIr.IrProject;
|
import com.dy.pipIrrGlobal.voIr.VoProject;
|
import com.dy.pipIrrGlobal.voIr.VoProjectOne;
|
import com.dy.pipIrrGlobal.voIr.VoUnit;
|
import com.dy.pipIrrGlobal.voIr.VoUnitOne;
|
import com.dy.pipIrrIrrigate.irrigateUnit.QueryVo;
|
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
|
* @Date :2024/5/16 18:11
|
* @LastEditTime :2024/5/16 18:11
|
* @Description
|
*/
|
@Slf4j
|
@Service
|
public class IrrigateUnitSv {
|
|
@Autowired
|
private IrIrrigateUnitMapper irIrrigateUnitMapper;
|
|
/**
|
* 创建灌溉单元
|
*
|
* @param po
|
* @return
|
*/
|
public Integer addIrrigateUnit(IrIrrigateUnit po) {
|
po.setOperateDt(new Date());
|
po.setDeleted((byte) 0);
|
int rows = irIrrigateUnitMapper.insertSelective(po);
|
if (rows == 0) {
|
return 0;
|
}
|
return 1;
|
}
|
|
/**
|
* 删除灌溉单元
|
*
|
* @param id
|
*/
|
public Integer deleteUnit(Long id) {
|
int rows = irIrrigateUnitMapper.deleteLogicById(id);
|
if (rows == 0) {
|
return 0;
|
}
|
return 1;
|
}
|
|
/**
|
* 修改灌溉单元
|
* @param po
|
* @return
|
*/
|
public Integer updateUnit(IrIrrigateUnit po){
|
po.setOperateDt(new Date());
|
int rows = irIrrigateUnitMapper.updateByPrimaryKeySelective(po);
|
if (rows == 0){
|
return 0;
|
}
|
return 1;
|
}
|
|
/**
|
* 获取一个灌溉单元
|
* @param id
|
* @return
|
*/
|
public VoUnitOne selectById(Long id){
|
VoUnitOne unit = irIrrigateUnitMapper.selectById(id);
|
return unit;
|
}
|
|
/**
|
* 分页查询项目
|
* @param queryVo
|
* @return
|
*/
|
public QueryResultVo<List<VoUnit>> getUnits(QueryVo queryVo){
|
Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(queryVo);
|
Long itemTotal = irIrrigateUnitMapper.getRecordCount(params);
|
|
QueryResultVo<List<VoUnit>> rsVo = new QueryResultVo<>();
|
rsVo.pageSize = queryVo.pageSize;
|
rsVo.pageCurr = queryVo.pageCurr;
|
rsVo.calculateAndSet(itemTotal, params);
|
rsVo.obj = irIrrigateUnitMapper.getUnits(params);
|
return rsVo;
|
}
|
}
|