|
@@ -1,14 +1,21 @@
|
|
package com.huimv.center.service.impl;
|
|
package com.huimv.center.service.impl;
|
|
|
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.huimv.center.pojo.BizFarm;
|
|
import com.huimv.center.pojo.BizFarm;
|
|
import com.huimv.center.mapper.BizFarmMapper;
|
|
import com.huimv.center.mapper.BizFarmMapper;
|
|
|
|
+import com.huimv.center.pojo.BizRawData;
|
|
import com.huimv.center.service.BizFarmService;
|
|
import com.huimv.center.service.BizFarmService;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
+import com.huimv.eartag2.common.utils.DateUtil;
|
|
import com.huimv.eartag2.common.utils.Result;
|
|
import com.huimv.eartag2.common.utils.Result;
|
|
import com.huimv.eartag2.common.utils.ResultCode;
|
|
import com.huimv.eartag2.common.utils.ResultCode;
|
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
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 java.text.ParseException;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* <p>
|
|
* <p>
|
|
* 服务实现类
|
|
* 服务实现类
|
|
@@ -22,44 +29,99 @@ public class BizFarmServiceImpl extends ServiceImpl<BizFarmMapper, BizFarm> impl
|
|
@Autowired
|
|
@Autowired
|
|
private BizFarmMapper BizFarmMapper;
|
|
private BizFarmMapper BizFarmMapper;
|
|
private BizFarm farm;
|
|
private BizFarm farm;
|
|
|
|
+ @Autowired
|
|
|
|
+ private com.huimv.center.utils.IDUtil idUtil;
|
|
|
|
+ @Autowired
|
|
|
|
+ private com.huimv.center.utils.DateUtil dateUtil;
|
|
|
|
+ @Autowired
|
|
|
|
+ private com.huimv.center.utils.ResultUtil ResultUtil;
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * @Method : save
|
|
|
|
+ * @Description :
|
|
|
|
+ * @Params : [farmName, farmCode, linkman, phone, remark]
|
|
|
|
+ * @Return : com.huimv.eartag2.common.utils.Result
|
|
|
|
+ *
|
|
|
|
+ * @Author : ZhuoNing
|
|
|
|
+ * @Date : 2022/6/24
|
|
|
|
+ * @Time : 14:46
|
|
|
|
+ */
|
|
@Override
|
|
@Override
|
|
- public Result save(String farmName, String farmCode, String linkman, String phone, String remark) {
|
|
|
|
|
|
+ public Result save(String farmName, String farmCode, String linkman, String phone, String remark) throws ParseException {
|
|
|
|
+ DateUtil dateUtil = new DateUtil();
|
|
BizFarm farm = new BizFarm();
|
|
BizFarm farm = new BizFarm();
|
|
farm.setFarmName(farmName);
|
|
farm.setFarmName(farmName);
|
|
farm.setFarmCode(farmCode);
|
|
farm.setFarmCode(farmCode);
|
|
farm.setLinkman(linkman);
|
|
farm.setLinkman(linkman);
|
|
farm.setPhone(phone);
|
|
farm.setPhone(phone);
|
|
farm.setRemark(remark);
|
|
farm.setRemark(remark);
|
|
- int result = BizFarmMapper.insert(farm);
|
|
|
|
- System.out.println(result); //影响的行数
|
|
|
|
- System.out.println(farm); //影响的行数
|
|
|
|
- return new Result(ResultCode.SUCCESS, "添加成功.");
|
|
|
|
|
|
+ farm.setAddTime(dateUtil.getTodayDatetime());
|
|
|
|
+ return ResultUtil.result(BizFarmMapper.insert(farm));
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * @Method : edit
|
|
|
|
+ * @Description :
|
|
|
|
+ * @Params : [id, farmName, farmCode, linkman, phone, remark]
|
|
|
|
+ * @Return : com.huimv.eartag2.common.utils.Result
|
|
|
|
+ *
|
|
|
|
+ * @Author : ZhuoNing
|
|
|
|
+ * @Date : 2022/6/24
|
|
|
|
+ * @Time : 14:44
|
|
|
|
+ */
|
|
@Override
|
|
@Override
|
|
- public Result edit(Integer id, String farmName, String farmCode, String linkman, String phone, String remark){
|
|
|
|
|
|
+ public Result edit(Integer id, String farmName, String farmCode, String linkman, String phone, String remark) throws ParseException {
|
|
|
|
+ DateUtil dateUtil = new DateUtil();
|
|
BizFarm farm = BizFarmMapper.selectById(id);
|
|
BizFarm farm = BizFarmMapper.selectById(id);
|
|
farm.setFarmName(farmName);
|
|
farm.setFarmName(farmName);
|
|
farm.setFarmCode(farmCode);
|
|
farm.setFarmCode(farmCode);
|
|
farm.setLinkman(linkman);
|
|
farm.setLinkman(linkman);
|
|
farm.setPhone(phone);
|
|
farm.setPhone(phone);
|
|
farm.setRemark(remark);
|
|
farm.setRemark(remark);
|
|
- int result = BizFarmMapper.updateById(farm);
|
|
|
|
- System.out.println(result); //影响的行数
|
|
|
|
- System.out.println(farm); //影响的行数
|
|
|
|
- return new Result(ResultCode.SUCCESS, "编辑成功.");
|
|
|
|
|
|
+ farm.setAddTime(dateUtil.getTodayDatetime());
|
|
|
|
+ return ResultUtil.result(BizFarmMapper.updateById(farm));
|
|
}
|
|
}
|
|
|
|
|
|
- @Autowired
|
|
|
|
- private com.huimv.center.utils.IDUtil idUtil;
|
|
|
|
-
|
|
|
|
|
|
+ /**
|
|
|
|
+ * @Method : remove
|
|
|
|
+ * @Description :
|
|
|
|
+ * @Params : [ids]
|
|
|
|
+ * @Return : com.huimv.eartag2.common.utils.Result
|
|
|
|
+ *
|
|
|
|
+ * @Author : ZhuoNing
|
|
|
|
+ * @Date : 2022/6/24
|
|
|
|
+ * @Time : 14:44
|
|
|
|
+ */
|
|
@Override
|
|
@Override
|
|
public Result remove(String ids){
|
|
public Result remove(String ids){
|
|
- //
|
|
|
|
- int result = BizFarmMapper.deleteBatchIds(idUtil.convert(ids));
|
|
|
|
- System.out.println(result); //影响的行数
|
|
|
|
- System.out.println(ids); //影响的行数
|
|
|
|
- return new Result(ResultCode.SUCCESS, "删除成功.");
|
|
|
|
|
|
+ return ResultUtil.result(BizFarmMapper.deleteBatchIds(idUtil.convert(ids)));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * @Method : list
|
|
|
|
+ * @Description :
|
|
|
|
+ * @Params : [pageNo, pageSize, farmName, farmCode, startDate, endDate]
|
|
|
|
+ * @Return : com.huimv.eartag2.common.utils.Result
|
|
|
|
+ *
|
|
|
|
+ * @Author : ZhuoNing
|
|
|
|
+ * @Date : 2022/6/24
|
|
|
|
+ * @Time : 14:44
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ public Result list(Integer pageNo, Integer pageSize, String farmName,String farmCode,String startDate,String endDate){
|
|
|
|
+ if(pageNo == 0){
|
|
|
|
+ pageNo = 1;
|
|
|
|
+ }
|
|
|
|
+ startDate = dateUtil.buildStartDate(startDate);
|
|
|
|
+ endDate = dateUtil.buildEndDate(endDate);
|
|
|
|
+ Page<BizFarm> page = new Page<>(pageNo, pageSize);
|
|
|
|
+ QueryWrapper<BizFarm> queryWrapper = new QueryWrapper<>();
|
|
|
|
+ queryWrapper.like(StringUtils.isNotBlank(farmName),"farm_name", farmName);
|
|
|
|
+ queryWrapper.like(StringUtils.isNotBlank(farmCode),"farm_code", farmCode);
|
|
|
|
+ queryWrapper.ge(StringUtils.isNotBlank(startDate),"add_time", startDate);
|
|
|
|
+ queryWrapper.le(StringUtils.isNotBlank(endDate),"add_time", endDate);
|
|
|
|
+ //创建时间降序
|
|
|
|
+ queryWrapper.orderByDesc("id");
|
|
|
|
+ return new Result(ResultCode.SUCCESS,BizFarmMapper.selectPage(page, queryWrapper));
|
|
}
|
|
}
|
|
}
|
|
}
|