package com.dy.pipIrrIrrigate.irrigateGroup;
|
|
import com.dy.common.webUtil.QueryResultVo;
|
import com.dy.pipIrrGlobal.daoIr.IrGroupUnitMapper;
|
import com.dy.pipIrrGlobal.daoIr.IrIrrigateGroupMapper;
|
import com.dy.pipIrrGlobal.pojoIr.IrGroupUnit;
|
import com.dy.pipIrrGlobal.pojoIr.IrIrrigateGroup;
|
import com.dy.pipIrrGlobal.voIr.VoGroup;
|
import com.dy.pipIrrGlobal.voIr.VoGroupOne;
|
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/21 15:57
|
* @LastEditTime :2024/5/21 15:57
|
* @Description
|
*/
|
@Slf4j
|
@Service
|
public class IrrigateGroupSv {
|
|
@Autowired
|
private IrIrrigateGroupMapper irIrrigateGroupMapper;
|
@Autowired
|
private IrGroupUnitMapper irGroupUnitMapper;
|
|
/**
|
* 创建轮灌组
|
*
|
* @param po
|
* @return
|
*/
|
public Integer addIrrigateGroup(IrIrrigateGroup po) {
|
po.setOperateDt(new Date());
|
po.setDeleted((byte) 0);
|
int rows = irIrrigateGroupMapper.insertSelective(po);
|
if (rows == 0) {
|
return 0;
|
}
|
return 1;
|
}
|
|
/**
|
* 删除轮灌组
|
*
|
* @param id
|
*/
|
public Integer deleteIrrigateGroup(Long id) {
|
int rows = irIrrigateGroupMapper.deleteLogicById(id);
|
int rows1 = irGroupUnitMapper.deleteByGroupId(id);
|
if (rows == 0) {
|
return 0;
|
}
|
return 1;
|
}
|
|
/**
|
* 修改轮灌组
|
* @param po
|
* @return
|
*/
|
public Integer updateIrrigateGroup(IrIrrigateGroup po){
|
po.setOperateDt(new Date());
|
int rows = irIrrigateGroupMapper.updateByPrimaryKeySelective(po);
|
if (rows == 0){
|
return 0;
|
}
|
return 1;
|
}
|
|
/**
|
* 获取一个轮灌组
|
* @param id
|
* @return
|
*/
|
public VoGroupOne selectById(Long id){
|
VoGroupOne unit = irIrrigateGroupMapper.selectById(id);
|
return unit;
|
}
|
|
/**
|
* 分页查询轮灌组
|
* @param queryVo
|
* @return
|
*/
|
public QueryResultVo<List<VoGroup>> getIrrigateGroups(QueryVo queryVo){
|
Map<String, Object> params = (Map<String, Object>) PojoUtils.generalize(queryVo);
|
Long itemTotal = irIrrigateGroupMapper.getRecordCount(params);
|
|
QueryResultVo<List<VoGroup>> rsVo = new QueryResultVo<>();
|
rsVo.pageSize = queryVo.pageSize;
|
rsVo.pageCurr = queryVo.pageCurr;
|
rsVo.calculateAndSet(itemTotal, params);
|
rsVo.obj = irIrrigateGroupMapper.getIrrigateGroups(params);
|
return rsVo;
|
}
|
|
/**
|
* 轮灌组添加灌溉单元
|
*
|
* @param po
|
* @return
|
*/
|
public Integer addGroupUnit(IrGroupUnit po) {
|
po.setOperateDt(new Date());
|
int rows = irGroupUnitMapper.insertSelective(po);
|
if (rows == 0) {
|
return 0;
|
}
|
return 1;
|
}
|
|
/**
|
* 轮灌组移除灌溉单元
|
*
|
* @param po
|
* @return
|
*/
|
public Integer deleteGroupUnit(IrGroupUnit po) {
|
int rows = irGroupUnitMapper.deleteByUnitIdGroupId(po);
|
if (rows == 0) {
|
return 0;
|
}
|
return 1;
|
}
|
|
/**
|
* 查一个轮灌组绑定的灌溉单元id
|
* @param groupId
|
* @return
|
*/
|
public List<Long> getGroupBindUnits(Long groupId) {
|
List<Long> groupBindUnits = irGroupUnitMapper.getGroupBindUnits(groupId);
|
return groupBindUnits;
|
}
|
|
/**
|
* //查未绑定轮灌组的灌溉单元id
|
* @return
|
*/
|
public List<Long> getNotBindUnits() {
|
List<Long> notBindUnits = irGroupUnitMapper.getNotBindUnits();
|
return notBindUnits;
|
}
|
}
|