|
@@ -0,0 +1,138 @@
|
|
|
+package com.huimv.env.produce.service.impl;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.huimv.common.utils.Result;
|
|
|
+import com.huimv.common.utils.ResultCode;
|
|
|
+import com.huimv.env.produce.entity.Board;
|
|
|
+import com.huimv.env.produce.mapper.BoardMapper;
|
|
|
+import com.huimv.env.produce.service.BoardService;
|
|
|
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+/**
|
|
|
+ * <p>
|
|
|
+ * 服务实现类
|
|
|
+ * </p>
|
|
|
+ *
|
|
|
+ * @author zn
|
|
|
+ * @since 2022-11-01
|
|
|
+ */
|
|
|
+@Service
|
|
|
+public class BoardServiceImpl extends ServiceImpl<BoardMapper, Board> implements BoardService {
|
|
|
+ @Autowired
|
|
|
+ private BoardMapper boardMapper;
|
|
|
+ private static final String globalFarmCode = "14";
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Result getBoardCount(Map<String, String> paramsMap) {
|
|
|
+ String farmCode = paramsMap.get("farmCode");
|
|
|
+ if(farmCode == null){
|
|
|
+ farmCode = globalFarmCode;
|
|
|
+ }
|
|
|
+ QueryWrapper<Board> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.eq(StringUtils.isNotBlank(farmCode),"farm_code",farmCode);
|
|
|
+ Board board = boardMapper.selectOne(queryWrapper);
|
|
|
+ JSONObject resultJo = new JSONObject();
|
|
|
+ if(board == null){
|
|
|
+ resultJo.put("warningCount",0);
|
|
|
+ resultJo.put("tuppingCount",0);
|
|
|
+ resultJo.put("birthCount",0);
|
|
|
+ resultJo.put("weanCount",0);
|
|
|
+ resultJo.put("workplanCount",0);
|
|
|
+ resultJo.put("transferCount",0);
|
|
|
+ resultJo.put("generalImmunityCount",0);
|
|
|
+ resultJo.put("specialImmunityCount",0);
|
|
|
+ }else{
|
|
|
+ resultJo.put("warningCount",board.getWarningCount());
|
|
|
+ resultJo.put("tuppingCount",board.getTuppingCount());
|
|
|
+ resultJo.put("birthCount",board.getBirthCount());
|
|
|
+ resultJo.put("weanCount",board.getWeanCount());
|
|
|
+ resultJo.put("workplanCount",board.getWorkplanCount());
|
|
|
+ resultJo.put("transferCount",board.getTransferCount());
|
|
|
+ resultJo.put("generalImmunityCount",board.getGeneralImmunityCount());
|
|
|
+ resultJo.put("specialImmunityCount",board.getSpecialImmunityCount());
|
|
|
+ }
|
|
|
+ return new Result(ResultCode.SUCCESS,resultJo);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Result save(Map<String, String> paramsMap) {
|
|
|
+ // specialImmunityCount
|
|
|
+ String specialImmunityCount = paramsMap.get("specialImmunityCount");
|
|
|
+ if(specialImmunityCount == null){
|
|
|
+ specialImmunityCount = "0";
|
|
|
+ }
|
|
|
+ // generalImmunityCount
|
|
|
+ String generalImmunityCount = paramsMap.get("generalImmunityCount");
|
|
|
+ if(generalImmunityCount == null){
|
|
|
+ generalImmunityCount = "0";
|
|
|
+ }
|
|
|
+ // birthCount
|
|
|
+ String birthCount = paramsMap.get("birthCount");
|
|
|
+ if(birthCount == null){
|
|
|
+ birthCount = "0";
|
|
|
+ }
|
|
|
+ // weanCount
|
|
|
+ String weanCount = paramsMap.get("weanCount");
|
|
|
+ if(weanCount == null){
|
|
|
+ weanCount = "0";
|
|
|
+ }
|
|
|
+ // tuppingCount
|
|
|
+ String tuppingCount = paramsMap.get("tuppingCount");
|
|
|
+ if(tuppingCount == null){
|
|
|
+ tuppingCount = "0";
|
|
|
+ }
|
|
|
+ // warningCount
|
|
|
+ String warningCount = paramsMap.get("warningCount");
|
|
|
+ if(warningCount == null){
|
|
|
+ warningCount = "0";
|
|
|
+ }
|
|
|
+ // workplanCount
|
|
|
+ String workplanCount = paramsMap.get("workplanCount");
|
|
|
+ if(workplanCount == null){
|
|
|
+ workplanCount = "0";
|
|
|
+ }
|
|
|
+ // transferCount
|
|
|
+ String transferCount = paramsMap.get("transferCount");
|
|
|
+ if(transferCount == null){
|
|
|
+ transferCount = "0";
|
|
|
+ }
|
|
|
+ String farmCode = paramsMap.get("farmCode");
|
|
|
+ if(farmCode == null){
|
|
|
+ farmCode = globalFarmCode;
|
|
|
+ }
|
|
|
+ QueryWrapper<Board> queryWrapper = new QueryWrapper();
|
|
|
+ queryWrapper.eq(StringUtils.isNotBlank(farmCode),"farm_code",farmCode);
|
|
|
+ Board board = boardMapper.selectOne(queryWrapper);
|
|
|
+ if(board == null){
|
|
|
+ board = new Board();
|
|
|
+ board.setWarningCount(Integer.parseInt(warningCount));
|
|
|
+ board.setTuppingCount(Integer.parseInt(tuppingCount));
|
|
|
+ board.setBirthCount(Integer.parseInt(birthCount));
|
|
|
+ board.setWeanCount(Integer.parseInt(weanCount));
|
|
|
+ board.setWorkplanCount(Integer.parseInt(workplanCount));
|
|
|
+ board.setTransferCount(Integer.parseInt(transferCount));
|
|
|
+ board.setGeneralImmunityCount(Integer.parseInt(generalImmunityCount));
|
|
|
+ board.setSpecialImmunityCount(Integer.parseInt(specialImmunityCount));
|
|
|
+ board.setFarmCode(farmCode);
|
|
|
+ boardMapper.insert(board);
|
|
|
+ }else{
|
|
|
+ board.setWarningCount(Integer.parseInt(warningCount));
|
|
|
+ board.setTuppingCount(Integer.parseInt(tuppingCount));
|
|
|
+ board.setBirthCount(Integer.parseInt(birthCount));
|
|
|
+ board.setWeanCount(Integer.parseInt(weanCount));
|
|
|
+ board.setWorkplanCount(Integer.parseInt(workplanCount));
|
|
|
+ board.setTransferCount(Integer.parseInt(transferCount));
|
|
|
+ board.setGeneralImmunityCount(Integer.parseInt(generalImmunityCount));
|
|
|
+ board.setSpecialImmunityCount(Integer.parseInt(specialImmunityCount));
|
|
|
+ boardMapper.updateById(board);
|
|
|
+ }
|
|
|
+ return new Result(ResultCode.SUCCESS);
|
|
|
+ }
|
|
|
+}
|