|
@@ -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);
|
|
|
+ }
|
|
|
}
|