فهرست منبع

金猪售猪记录

523096025 3 سال پیش
والد
کامیت
807ba0a36f

+ 7 - 0
huimv-goldpig/huimv-goldpig-eartag/src/main/java/com/huimv/eartag/controller/BaseFarmInfoController.java

@@ -95,4 +95,11 @@ public class BaseFarmInfoController {
     public Result list(@RequestParam(name = "type")Integer type){
         return new Result(ResultCode.SUCCESS,  baseFarmInfoService.list(new QueryWrapper<BaseFarmInfo>().eq("type",type)));
     }
+
+    @GetMapping("/listAll")
+    public Result list(){
+
+        return new Result(ResultCode.SUCCESS,baseFarmInfoService.list());
+    }
+
 }

+ 16 - 4
huimv-goldpig/huimv-goldpig-eartag/src/main/java/com/huimv/eartag/controller/BizSellPigApplyController.java

@@ -4,11 +4,9 @@ package com.huimv.eartag.controller;
 import com.huimv.common.utils.Result;
 import com.huimv.eartag.service.IBizSellPigApplyService;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.*;
 
-import org.springframework.web.bind.annotation.RestController;
+import java.util.Map;
 
 /**
  * <p>
@@ -25,5 +23,19 @@ public class BizSellPigApplyController {
     @Autowired
     private IBizSellPigApplyService iBizSellPigApplyService;
 
+    @PostMapping("/sellPigRecord")
+    public Result sellPigRecord(@RequestBody Map<String,String> map){
+      return   iBizSellPigApplyService.sellPigRecord(map);
+    }
+
+    @GetMapping("/sellPigRecordCollect")
+    public Result sellPigRecordCollect(@RequestParam Integer farmId){
+        return   iBizSellPigApplyService.sellPigRecordCollect(farmId);
+    }
+
+    @GetMapping("/sellPigRecordManage")
+    public Result sellPigRecordManage(@RequestParam(name = "batchNo") String batchNo){
+        return   iBizSellPigApplyService.sellPigRecordManage(batchNo);
+    }
 
 }

+ 18 - 2
huimv-goldpig/huimv-goldpig-eartag/src/main/java/com/huimv/eartag/controller/BizSellPigApplyEartagController.java

@@ -3,10 +3,14 @@ package com.huimv.eartag.controller;
 
 import cn.hutool.core.bean.BeanUtil;
 import cn.hutool.core.date.DateUtil;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.huimv.common.utils.Result;
 import com.huimv.eartag.entity.BizSellPigApply;
 import com.huimv.eartag.entity.BizSellPigApplyEartag;
+import com.huimv.eartag.entity.EartagRegisterEntity;
 import com.huimv.eartag.entity.dto.SellPig;
+import com.huimv.eartag.service.EartagRegisterService;
 import com.huimv.eartag.service.IBizSellPigApplyEartagService;
 import com.huimv.eartag.service.IBizSellPigApplyService;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -18,6 +22,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Date;
 import java.util.List;
 
@@ -41,13 +46,17 @@ public class BizSellPigApplyEartagController {
     @Autowired
     private IBizSellPigApplyEartagService bizSellPigApplyEartagService;
 
+
+    @Autowired
+    private EartagRegisterService eartagRegisterService;
+
     @Transactional
     @PostMapping("/addSellPig")
     public Result addSellPig(@RequestBody SellPig sellPig){
 
-
         BizSellPigApply bizSellPigApply = new BizSellPigApply();
-        BeanUtil.copyProperties(bizSellPigApply,sellPig);
+        BeanUtil.copyProperties(sellPig,bizSellPigApply);
+
 
         String[] eartagNos = sellPig.getEartagNos().split(",");
         String bacthNo = DateUtil.format(new Date(), "yyyyMMddHHmmssSSS");
@@ -55,6 +64,8 @@ public class BizSellPigApplyEartagController {
         bizSellPigApply.setSellTime(new Date());
         bizSellPigApply.setAutoEartagNum(eartagNos.length);
 
+
+
         bizSellPigApplyService.save(bizSellPigApply);
 
 
@@ -69,6 +80,11 @@ public class BizSellPigApplyEartagController {
         bizSellPigApplyEartagService.saveBatch(list);
 
 
+        EartagRegisterEntity eartagRegisterEntity = new EartagRegisterEntity();
+        eartagRegisterEntity.setSellStatus(2);
+        eartagRegisterService.update(eartagRegisterEntity, new UpdateWrapper<EartagRegisterEntity>().in("eartag_no", Arrays.asList(eartagNos)));
+
+
         return new Result(10000,"申请成功",true);
     }
 

+ 21 - 1
huimv-goldpig/huimv-goldpig-eartag/src/main/java/com/huimv/eartag/entity/BizSellPigApply.java

@@ -61,7 +61,7 @@ public class BizSellPigApply extends Model {
     private Integer realEartagNum;
 
     /**
-     * 记录状态  0:暂存 1:已提交 2:取消
+     *记录状态  0:暂存 1:已提交 2:取消  3:已完成  4:检疫失败  5:屠宰失败
      */
     private Integer recordStatus;
 
@@ -102,5 +102,25 @@ public class BizSellPigApply extends Model {
      */
     private Integer inspecType;
 
+    /**
+     * 提交时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
+    private Date inspecTime;
+
+
+    /**
+     * 提交时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
+    private Date butcherInspecTime;
+
+
+    /**
+     * 提交时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
+    private Date butcherTime;
+
 
 }

+ 1 - 7
huimv-goldpig/huimv-goldpig-eartag/src/main/java/com/huimv/eartag/entity/dto/SellPig.java

@@ -11,11 +11,8 @@ public class SellPig {
     private String eartagNos;
 
 
-    private Integer id;
 
-    /**
-     * 批次编号
-     */
+
     private String batchNo;
 
     /**
@@ -26,7 +23,6 @@ public class SellPig {
     /**
      * 卖猪时间
      */
-    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
     private Date sellTime;
 
     /**
@@ -67,13 +63,11 @@ public class SellPig {
     /**
      * 创建时间
      */
-    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
     private Date createTime;
 
     /**
      * 提交时间
      */
-    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss",timezone = "GMT+8")
     private Date applyTime;
 
     /**

+ 15 - 0
huimv-goldpig/huimv-goldpig-eartag/src/main/java/com/huimv/eartag/entity/vo/BizSellPigApplyVo.java

@@ -0,0 +1,15 @@
+package com.huimv.eartag.entity.vo;
+
+import lombok.Data;
+
+@Data
+public class BizSellPigApplyVo {
+
+    private Integer allPigNum;
+    //已完成
+    private Integer completedNum;
+    //进行中
+    private Integer underwayNum;
+    //失败数量
+    private Integer failNum;
+}

+ 4 - 8
huimv-goldpig/huimv-goldpig-eartag/src/main/java/com/huimv/eartag/mapper/BizSellPigApplyMapper.java

@@ -2,15 +2,11 @@ package com.huimv.eartag.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.huimv.eartag.entity.BizSellPigApply;
+import org.apache.ibatis.annotations.Mapper;
+import org.springframework.stereotype.Repository;
 
-/**
- * <p>
- *  Mapper 接口
- * </p>
- *
- * @author astupidcoder
- * @since 2022-03-01
- */
+
+@Repository
 public interface BizSellPigApplyMapper extends BaseMapper<BizSellPigApply> {
 
 }

+ 9 - 0
huimv-goldpig/huimv-goldpig-eartag/src/main/java/com/huimv/eartag/service/IBizSellPigApplyService.java

@@ -1,8 +1,11 @@
 package com.huimv.eartag.service;
 
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.huimv.common.utils.Result;
 import com.huimv.eartag.entity.BizSellPigApply;
 
+import java.util.Map;
+
 /**
  * <p>
  *  服务类
@@ -13,4 +16,10 @@ import com.huimv.eartag.entity.BizSellPigApply;
  */
 public interface IBizSellPigApplyService extends IService<BizSellPigApply> {
 
+
+    Result sellPigRecord(Map<String,String>  map);
+
+    Result sellPigRecordCollect(Integer farmId);
+
+    Result sellPigRecordManage(String batchNo);
 }

+ 165 - 0
huimv-goldpig/huimv-goldpig-eartag/src/main/java/com/huimv/eartag/service/impl/BizSellPigApplyServiceImpl.java

@@ -1,11 +1,26 @@
 package com.huimv.eartag.service.impl;
 
+import cn.hutool.core.date.DateTime;
+import cn.hutool.core.date.DateUtil;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.toolkit.StringUtils;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.huimv.common.utils.Result;
+import com.huimv.common.utils.ResultCode;
 import com.huimv.eartag.entity.BizSellPigApply;
+import com.huimv.eartag.entity.vo.BizSellPigApplyVo;
 import com.huimv.eartag.mapper.BizSellPigApplyMapper;
 import com.huimv.eartag.service.IBizSellPigApplyService;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
 /**
  * <p>
  *  服务实现类
@@ -17,4 +32,154 @@ import org.springframework.stereotype.Service;
 @Service
 public class BizSellPigApplyServiceImpl extends ServiceImpl<BizSellPigApplyMapper, BizSellPigApply> implements IBizSellPigApplyService {
 
+    @Autowired
+    private BizSellPigApplyMapper bizSellPigApplyMapper;
+
+    @Override
+    public Result sellPigRecord(Map<String,String>  map) {
+        String farmId = map.get("farmId");
+        String type = map.get("type");
+
+        String current = map.get("current");
+        String size =  map.get("size");
+        Page<BizSellPigApply> bizSellPigApplyPage ;
+        if (StringUtils.isBlank(current) || StringUtils.isBlank(size)){
+            bizSellPigApplyPage = new Page<>(1, 10);
+        }else {
+            bizSellPigApplyPage =new Page<>(Integer.parseInt(current), Integer.parseInt(size));
+        }
+        QueryWrapper<BizSellPigApply> wrapper = new QueryWrapper<>();
+        wrapper.eq("farm_id",farmId);
+        //未提交
+        if ("1".equals(type)){
+            wrapper.eq("record_status",0);
+        }
+        //进行中
+        else if("2".equals(type)){
+            wrapper.eq("record_status",1);
+        }
+        //已完成
+        else if ("3".equals(type)){
+            wrapper.eq("record_status",3);
+        }
+
+        //失败
+        else if("4".equals(type)){
+            wrapper.in("record_status",4,5);
+        }
+
+        //全部
+
+        Page<BizSellPigApply> page = this.page(bizSellPigApplyPage, wrapper);
+        return new Result(ResultCode.SUCCESS,page);
+    }
+
+    @Override
+    public Result sellPigRecordCollect(Integer farmId) {
+
+
+        BizSellPigApplyVo bizSellPigApplyVo = new BizSellPigApplyVo();
+
+        QueryWrapper<BizSellPigApply> wrapper = new QueryWrapper<>();
+        wrapper.eq("farm_id",farmId);
+        bizSellPigApplyVo.setAllPigNum(this.count(wrapper));
+
+        wrapper.eq("record_status",3);
+        bizSellPigApplyVo.setCompletedNum(this.count(wrapper));
+
+        wrapper.clear();
+        wrapper.eq("farm_id",farmId);
+        wrapper.in("record_status",4,5);
+        bizSellPigApplyVo.setFailNum(this.count(wrapper));
+
+
+        wrapper.clear();
+        wrapper.eq("farm_id",farmId);
+        wrapper.eq("record_status",1);
+        bizSellPigApplyVo.setUnderwayNum(this.count(wrapper));
+
+        return new Result(ResultCode.SUCCESS,bizSellPigApplyVo);
+    }
+
+    @Override
+    public Result sellPigRecordManage(String batchNo) {
+
+
+        Map endMap = new HashMap();
+        endMap.put("now",1);
+        List list = new ArrayList();
+
+        Map map1 = new HashMap();
+        map1.put("title","提交申请");
+        map1.put("subTitle","未提交");
+
+        Map map2 = new HashMap();
+        map2.put("title","检疫部门检疫");
+        map2.put("subTitle","检疫部门未检疫");
+
+        Map map3 = new HashMap();
+        map3.put("title","屠宰部门检疫");
+        map3.put("subTitle","屠宰部门未检疫");
+
+        Map map4 = new HashMap();
+        map4.put("title","已屠宰");
+        map4.put("subTitle","未屠宰");
+
+
+
+
+        BizSellPigApply batch = this.getOne(new QueryWrapper<BizSellPigApply>().eq("batch_no", batchNo));
+
+        String inspecTime = DateUtil.format(batch.getInspecTime(), "yyyy-MM-dd HH:mm:ss");
+        String sellTime = DateUtil.format(batch.getSellTime(), "yyyy-MM-dd HH:mm:ss");
+        String butcherInspecTime = DateUtil.format(batch.getButcherInspecTime(), "yyyy-MM-dd HH:mm:ss");
+        String butcherTime = DateUtil.format(batch.getButcherTime(), "yyyy-MM-dd HH:mm:ss");
+
+        //0:暂存 1:已提交 2:取消 3:已完成 4:检疫失败 5:屠宰失败
+        Integer recordStatus = batch.getRecordStatus();
+
+        //检验流程状态 0:未检验, 1:在场检验,2:屠宰检验
+        Integer inspecFlowStatus = batch.getInspecFlowStatus();
+        if (1 == recordStatus ){
+            map1.put("subTitle",sellTime);
+            if (1 == inspecFlowStatus){
+                map2.put("subTitle",inspecTime);
+                endMap.put("now",2);
+            }
+            if ( 2== inspecFlowStatus){
+                map2.put("subTitle",inspecTime);
+                map3.put("subTitle",butcherInspecTime);
+                endMap.put("now",3);
+            }
+        }
+        if ( 3== recordStatus){
+            map1.put("subTitle",sellTime);
+            map2.put("subTitle",inspecTime);
+            map3.put("subTitle",butcherInspecTime);
+            map4.put("subTitle",butcherTime);
+            endMap.put("now",4);
+        }
+        if ( 4==recordStatus){
+            map1.put("subTitle",sellTime);
+            map2.put("subTitle","检疫失败");
+            endMap.put("now",2);
+        }
+
+        if ( 5==recordStatus){
+            map1.put("subTitle",sellTime);
+            map2.put("subTitle",inspecTime);
+            map3.put("subTitle","屠宰检疫失败");
+            endMap.put("now",3);
+        }
+        list.add(map1);
+        list.add(map2);
+        list.add(map3);
+        list.add(map4);
+        endMap.put("data",list);
+        endMap.put("inspecPic",null);
+        endMap.put("butcherPic",null);
+
+
+        return new Result(ResultCode.SUCCESS,endMap);
+    }
 }