|
@@ -8,11 +8,11 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.huimv.guowei.admin.common.utils.Result;
|
|
import com.huimv.guowei.admin.common.utils.Result;
|
|
import com.huimv.guowei.admin.common.utils.ResultCode;
|
|
import com.huimv.guowei.admin.common.utils.ResultCode;
|
|
import com.huimv.guowei.admin.common.utils.ResultUtil;
|
|
import com.huimv.guowei.admin.common.utils.ResultUtil;
|
|
-import com.huimv.guowei.admin.entity.BasePigpen;
|
|
|
|
|
|
+import com.huimv.guowei.admin.entity.BaseBuilding;
|
|
import com.huimv.guowei.admin.entity.dto.BasePigpenDto;
|
|
import com.huimv.guowei.admin.entity.dto.BasePigpenDto;
|
|
import com.huimv.guowei.admin.entity.vo.TreeBasePigpen;
|
|
import com.huimv.guowei.admin.entity.vo.TreeBasePigpen;
|
|
-import com.huimv.guowei.admin.mapper.BasePigpenMapper;
|
|
|
|
-import com.huimv.guowei.admin.service.IBasePigpenService;
|
|
|
|
|
|
+import com.huimv.guowei.admin.mapper.BaseBuildingMapper;
|
|
|
|
+import com.huimv.guowei.admin.service.IBaseBuildingService;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
@@ -31,54 +31,54 @@ import java.util.stream.Collectors;
|
|
* @since 2023-02-13
|
|
* @since 2023-02-13
|
|
*/
|
|
*/
|
|
@Service
|
|
@Service
|
|
-public class BasePigpenServiceImpl extends ServiceImpl<BasePigpenMapper, BasePigpen> implements IBasePigpenService {
|
|
|
|
|
|
+public class BaseBuildingServiceImpl extends ServiceImpl<BaseBuildingMapper, BaseBuilding> implements IBaseBuildingService {
|
|
@Autowired
|
|
@Autowired
|
|
- private BasePigpenMapper basePigpenMapper;
|
|
|
|
|
|
+ private BaseBuildingMapper baseBuildingMapper;
|
|
// @Autowired
|
|
// @Autowired
|
|
// private EnvDeviceMapper envDeviceMapper;
|
|
// private EnvDeviceMapper envDeviceMapper;
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@Transactional
|
|
@Transactional
|
|
public Result addPigpen(BasePigpenDto basePigpenDto) {
|
|
public Result addPigpen(BasePigpenDto basePigpenDto) {
|
|
- Integer num = basePigpenMapper.selectCount(new QueryWrapper<BasePigpen>().eq("build_name", basePigpenDto.getBuildName()));
|
|
|
|
|
|
+ Integer num = baseBuildingMapper.selectCount(new QueryWrapper<BaseBuilding>().eq("build_name", basePigpenDto.getBuildName()));
|
|
if (num > 0){
|
|
if (num > 0){
|
|
return ResultUtil.exist();
|
|
return ResultUtil.exist();
|
|
}
|
|
}
|
|
- BasePigpen basePigpen = new BasePigpen();
|
|
|
|
- BeanUtil.copyProperties(basePigpenDto,basePigpen);
|
|
|
|
- basePigpen.setParentId(0);
|
|
|
|
- basePigpen.setFType(1);
|
|
|
|
- basePigpen.setOther2("0");
|
|
|
|
- int insert = basePigpenMapper.insert(basePigpen);
|
|
|
|
- Integer id = basePigpen.getId();
|
|
|
|
- String buildName = basePigpen.getBuildName();
|
|
|
|
|
|
+ BaseBuilding baseBuilding = new BaseBuilding();
|
|
|
|
+ BeanUtil.copyProperties(basePigpenDto, baseBuilding);
|
|
|
|
+ baseBuilding.setParentId(0);
|
|
|
|
+ baseBuilding.setFType(1);
|
|
|
|
+ baseBuilding.setOther2("0");
|
|
|
|
+ int insert = baseBuildingMapper.insert(baseBuilding);
|
|
|
|
+ Integer id = baseBuilding.getId();
|
|
|
|
+ String buildName = baseBuilding.getBuildName();
|
|
Integer floorNum = basePigpenDto.getFloorNum();
|
|
Integer floorNum = basePigpenDto.getFloorNum();
|
|
for (Integer integer = 1; integer <= floorNum; integer++) {
|
|
for (Integer integer = 1; integer <= floorNum; integer++) {
|
|
- BasePigpen basePigpen1 = new BasePigpen();
|
|
|
|
- basePigpen1.setFType(2);
|
|
|
|
- basePigpen1.setParentId(id);
|
|
|
|
- basePigpen1.setBuildName(buildName+Convert.numberToChinese(integer,false) +"层");
|
|
|
|
- basePigpen1.setOther1(Convert.numberToChinese(integer,false) +"层");
|
|
|
|
- basePigpen1.setOther2("0,"+id);
|
|
|
|
- basePigpen1.setFarmId(basePigpen.getFarmId());
|
|
|
|
- basePigpen1.setStageCode(basePigpen.getStageCode());
|
|
|
|
- basePigpenMapper.insert(basePigpen1);
|
|
|
|
|
|
+ BaseBuilding baseBuilding1 = new BaseBuilding();
|
|
|
|
+ baseBuilding1.setFType(2);
|
|
|
|
+ baseBuilding1.setParentId(id);
|
|
|
|
+ baseBuilding1.setBuildName(buildName+Convert.numberToChinese(integer,false) +"层");
|
|
|
|
+ baseBuilding1.setOther1(Convert.numberToChinese(integer,false) +"层");
|
|
|
|
+ baseBuilding1.setOther2("0,"+id);
|
|
|
|
+ baseBuilding1.setFarmId(baseBuilding.getFarmId());
|
|
|
|
+ baseBuilding1.setStageCode(baseBuilding.getStageCode());
|
|
|
|
+ baseBuildingMapper.insert(baseBuilding1);
|
|
}
|
|
}
|
|
return ResultUtil.addResult(insert);
|
|
return ResultUtil.addResult(insert);
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@Transactional
|
|
@Transactional
|
|
- public Result updatePigpen(BasePigpen basePigpen) {
|
|
|
|
- basePigpenMapper.updateById(basePigpen);
|
|
|
|
- Integer id = basePigpen.getId();
|
|
|
|
- List<BasePigpen> parentId = basePigpenMapper.selectList(new QueryWrapper<BasePigpen>().eq("parent_id", id));
|
|
|
|
- String buildName = basePigpen.getBuildName();
|
|
|
|
|
|
+ public Result updatePigpen(BaseBuilding baseBuilding) {
|
|
|
|
+ baseBuildingMapper.updateById(baseBuilding);
|
|
|
|
+ Integer id = baseBuilding.getId();
|
|
|
|
+ List<BaseBuilding> parentId = baseBuildingMapper.selectList(new QueryWrapper<BaseBuilding>().eq("parent_id", id));
|
|
|
|
+ String buildName = baseBuilding.getBuildName();
|
|
if (StringUtils.isNotBlank(buildName)){
|
|
if (StringUtils.isNotBlank(buildName)){
|
|
- for (BasePigpen pigpen : parentId) {
|
|
|
|
|
|
+ for (BaseBuilding pigpen : parentId) {
|
|
String other1 = pigpen.getOther1();
|
|
String other1 = pigpen.getOther1();
|
|
pigpen.setBuildName(buildName+other1);
|
|
pigpen.setBuildName(buildName+other1);
|
|
- basePigpenMapper.updateById(pigpen);
|
|
|
|
|
|
+ baseBuildingMapper.updateById(pigpen);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return ResultUtil.updateResult(1);
|
|
return ResultUtil.updateResult(1);
|
|
@@ -107,15 +107,15 @@ public class BasePigpenServiceImpl extends ServiceImpl<BasePigpenMapper, BasePig
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public Result list(String farmCode, String buildName, String stageCode) {
|
|
public Result list(String farmCode, String buildName, String stageCode) {
|
|
- QueryWrapper<BasePigpen> queryWrapper = new QueryWrapper<>();
|
|
|
|
|
|
+ QueryWrapper<BaseBuilding> queryWrapper = new QueryWrapper<>();
|
|
queryWrapper.like(StringUtils.isNotBlank(buildName),"build_name", buildName);
|
|
queryWrapper.like(StringUtils.isNotBlank(buildName),"build_name", buildName);
|
|
queryWrapper.like(StringUtils.isNotBlank(stageCode),"stage_code", stageCode);
|
|
queryWrapper.like(StringUtils.isNotBlank(stageCode),"stage_code", stageCode);
|
|
queryWrapper.eq(StringUtils.isNotBlank(farmCode),"farm_id", farmCode);
|
|
queryWrapper.eq(StringUtils.isNotBlank(farmCode),"farm_id", farmCode);
|
|
queryWrapper.orderByAsc("sort");
|
|
queryWrapper.orderByAsc("sort");
|
|
//创建排序
|
|
//创建排序
|
|
- List<BasePigpen> basePigpens = basePigpenMapper.selectList(queryWrapper);
|
|
|
|
|
|
+ List<BaseBuilding> baseBuildings = baseBuildingMapper.selectList(queryWrapper);
|
|
//将结果List改为树
|
|
//将结果List改为树
|
|
- List<TreeBasePigpen> treeBasePigpens = parseBizBaseArea(basePigpens);
|
|
|
|
|
|
+ List<TreeBasePigpen> treeBasePigpens = parseBizBaseArea(baseBuildings);
|
|
return new Result(ResultCode.SUCCESS,treeBasePigpens);
|
|
return new Result(ResultCode.SUCCESS,treeBasePigpens);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -124,17 +124,17 @@ public class BasePigpenServiceImpl extends ServiceImpl<BasePigpenMapper, BasePig
|
|
* @param bizBaseAreas 原始数据
|
|
* @param bizBaseAreas 原始数据
|
|
* @return 树
|
|
* @return 树
|
|
*/
|
|
*/
|
|
- private List<TreeBasePigpen> parseBizBaseArea(List<BasePigpen> bizBaseAreas){
|
|
|
|
|
|
+ private List<TreeBasePigpen> parseBizBaseArea(List<BaseBuilding> bizBaseAreas){
|
|
//构建需要展示的树形节点结构
|
|
//构建需要展示的树形节点结构
|
|
- Map<String, TreeBasePigpen> nodeMap = bizBaseAreas.stream().map(basePigpen -> {
|
|
|
|
|
|
+ Map<String, TreeBasePigpen> nodeMap = bizBaseAreas.stream().map(baseBuilding -> {
|
|
TreeBasePigpen baseVo = new TreeBasePigpen();
|
|
TreeBasePigpen baseVo = new TreeBasePigpen();
|
|
- baseVo.setId(basePigpen.getId()+"");
|
|
|
|
- baseVo.setFarmCode(basePigpen.getFarmId());
|
|
|
|
- baseVo.setParentId(basePigpen.getParentId());
|
|
|
|
- baseVo.setSort(basePigpen.getSort());
|
|
|
|
- baseVo.setStageCode(basePigpen.getStageCode());
|
|
|
|
- baseVo.setPigpenName(basePigpen.getBuildName());
|
|
|
|
- baseVo.setType(basePigpen.getFType());
|
|
|
|
|
|
+ baseVo.setId(baseBuilding.getId()+"");
|
|
|
|
+ baseVo.setFarmCode(baseBuilding.getFarmId());
|
|
|
|
+ baseVo.setParentId(baseBuilding.getParentId());
|
|
|
|
+ baseVo.setSort(baseBuilding.getSort());
|
|
|
|
+ baseVo.setStageCode(baseBuilding.getStageCode());
|
|
|
|
+ baseVo.setPigpenName(baseBuilding.getBuildName());
|
|
|
|
+ baseVo.setType(baseBuilding.getFType());
|
|
baseVo.setChildNode(new ArrayList<>());
|
|
baseVo.setChildNode(new ArrayList<>());
|
|
return baseVo;
|
|
return baseVo;
|
|
}).collect(Collectors.toMap(TreeBasePigpen::getId, b -> b,(k1, k2)->k1));
|
|
}).collect(Collectors.toMap(TreeBasePigpen::getId, b -> b,(k1, k2)->k1));
|