|
@@ -1,17 +1,22 @@
|
|
|
package com.huimv.admin.service.impl;
|
|
|
|
|
|
+import cn.hutool.core.bean.BeanUtil;
|
|
|
+import cn.hutool.core.convert.Convert;
|
|
|
+import cn.hutool.core.util.NumberUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
|
import com.huimv.admin.common.utils.Result;
|
|
|
import com.huimv.admin.common.utils.ResultCode;
|
|
|
import com.huimv.admin.common.utils.ResultUtil;
|
|
|
import com.huimv.admin.entity.BasePigpen;
|
|
|
+import com.huimv.admin.entity.dto.BasePigpenDto;
|
|
|
import com.huimv.admin.entity.vo.TreeBasePigpen;
|
|
|
import com.huimv.admin.mapper.BasePigpenMapper;
|
|
|
import com.huimv.admin.service.IBasePigpenService;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
@@ -32,6 +37,27 @@ public class BasePigpenServiceImpl extends ServiceImpl<BasePigpenMapper, BasePig
|
|
|
private BasePigpenMapper basePigpenMapper;
|
|
|
|
|
|
@Override
|
|
|
+ @Transactional
|
|
|
+ public Result addPigpen(BasePigpenDto basePigpenDto) {
|
|
|
+ BasePigpen basePigpen = new BasePigpen();
|
|
|
+ BeanUtil.copyProperties(basePigpen,basePigpenDto);
|
|
|
+ basePigpen.setParentId(0);
|
|
|
+ basePigpen.setFType(1);
|
|
|
+ int insert = basePigpenMapper.insert(basePigpen);
|
|
|
+ Integer floorNum = basePigpenDto.getFloorNum();
|
|
|
+ for (Integer integer = 1; integer <= floorNum; integer++) {
|
|
|
+ BasePigpen basePigpen1 = new BasePigpen();
|
|
|
+ basePigpen1.setFType(2);
|
|
|
+ basePigpen1.setParentId(insert);
|
|
|
+ basePigpen1.setBuildName(Convert.numberToChinese(integer,false));
|
|
|
+ basePigpen1.setFarmId(basePigpen.getFarmId());
|
|
|
+ basePigpen1.setStageCode(basePigpen.getStageCode());
|
|
|
+ }
|
|
|
+
|
|
|
+ return ResultUtil.addResult(insert);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
public Result list(String farmCode, String pigpenName, String stageCode) {
|
|
|
QueryWrapper<BasePigpen> queryWrapper = new QueryWrapper<>();
|
|
|
queryWrapper.like(StringUtils.isNotBlank(pigpenName),"pigpen_name", pigpenName);
|
|
@@ -45,6 +71,7 @@ public class BasePigpenServiceImpl extends ServiceImpl<BasePigpenMapper, BasePig
|
|
|
return new Result(ResultCode.SUCCESS,treeBasePigpens);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
/**
|
|
|
* 查询结果 转换成树形结构
|
|
|
* @param bizBaseAreas 原始数据
|