|
@@ -1,7 +1,9 @@
|
|
|
package com.huimv.eartag.service.impl;
|
|
|
|
|
|
+import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.date.DateTime;
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
+import cn.hutool.core.util.ObjectUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
@@ -9,8 +11,15 @@ 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.BizSellPigApplyEartag;
|
|
|
+import com.huimv.eartag.entity.EartagRegisterEntity;
|
|
|
import com.huimv.eartag.entity.vo.BizSellPigApplyVo;
|
|
|
+import com.huimv.eartag.entity.vo.EartagNoVo;
|
|
|
+import com.huimv.eartag.entity.vo.InspecVo;
|
|
|
+import com.huimv.eartag.mapper.BizSellPigApplyEartagMapper;
|
|
|
import com.huimv.eartag.mapper.BizSellPigApplyMapper;
|
|
|
+import com.huimv.eartag.mapper.EartagRegisterMapper;
|
|
|
+import com.huimv.eartag.service.EartagRegisterService;
|
|
|
import com.huimv.eartag.service.IBizSellPigApplyService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
@@ -20,6 +29,7 @@ import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
@@ -35,6 +45,12 @@ public class BizSellPigApplyServiceImpl extends ServiceImpl<BizSellPigApplyMappe
|
|
|
@Autowired
|
|
|
private BizSellPigApplyMapper bizSellPigApplyMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private BizSellPigApplyEartagMapper bizSellPigApplyEartagMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private EartagRegisterMapper eartagRegisterMapper;
|
|
|
+
|
|
|
@Override
|
|
|
public Result sellPigRecord(Map<String,String> map) {
|
|
|
String farmId = map.get("farmId");
|
|
@@ -79,7 +95,6 @@ public class BizSellPigApplyServiceImpl extends ServiceImpl<BizSellPigApplyMappe
|
|
|
@Override
|
|
|
public Result sellPigRecordCollect(Integer farmId) {
|
|
|
|
|
|
-
|
|
|
BizSellPigApplyVo bizSellPigApplyVo = new BizSellPigApplyVo();
|
|
|
|
|
|
QueryWrapper<BizSellPigApply> wrapper = new QueryWrapper<>();
|
|
@@ -108,6 +123,7 @@ public class BizSellPigApplyServiceImpl extends ServiceImpl<BizSellPigApplyMappe
|
|
|
return new Result(ResultCode.SUCCESS,bizSellPigApplyVo);
|
|
|
}
|
|
|
|
|
|
+ //很low的卖猪流程,别看
|
|
|
@Override
|
|
|
public Result sellPigRecordManage(String batchNo) {
|
|
|
|
|
@@ -189,4 +205,125 @@ public class BizSellPigApplyServiceImpl extends ServiceImpl<BizSellPigApplyMappe
|
|
|
|
|
|
return new Result(ResultCode.SUCCESS,endMap);
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Result getInspecCollect(String farmId) {
|
|
|
+ InspecVo inspecVo = new InspecVo();
|
|
|
+ QueryWrapper<BizSellPigApply> wrapper = new QueryWrapper<>();
|
|
|
+ wrapper.eq("inspec_org_id",farmId);
|
|
|
+ wrapper.in("inspec_flow_status",0,1);
|
|
|
+ inspecVo.setInspecNum(this.count(wrapper));
|
|
|
+
|
|
|
+
|
|
|
+ wrapper.clear();
|
|
|
+ wrapper.eq("inspec_org_id",farmId);
|
|
|
+ wrapper.eq("inspec_flow_status",1);
|
|
|
+ int count = this.count(wrapper);
|
|
|
+ inspecVo.setAccomplishNum(count);
|
|
|
+
|
|
|
+
|
|
|
+ wrapper.eq("real_eartag_num",4);
|
|
|
+ int count1 = this.count(wrapper);
|
|
|
+ inspecVo.setUnQualifiedNum(count1);
|
|
|
+
|
|
|
+
|
|
|
+ inspecVo.setQualifiedNum(count -count);
|
|
|
+
|
|
|
+ return new Result(ResultCode.SUCCESS,inspecVo);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Result getInspecRecord(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("inspec_org_id",farmId);
|
|
|
+ wrapper.orderByDesc("sell_time");
|
|
|
+ //未审批
|
|
|
+ if ("1".equals(type)){
|
|
|
+ wrapper.eq("inspec_flow_status",0);
|
|
|
+
|
|
|
+ }
|
|
|
+ //合格
|
|
|
+ else if ("2".equals(type)){
|
|
|
+ wrapper.eq("inspec_flow_status",1);
|
|
|
+ wrapper.ne("record_status",4);
|
|
|
+ }
|
|
|
+
|
|
|
+ //不合格
|
|
|
+ else if ("3".equals(type)){
|
|
|
+ wrapper.eq("inspec_flow_status",1);
|
|
|
+ wrapper.eq("record_status",4);
|
|
|
+ }
|
|
|
+ //全部
|
|
|
+ else {
|
|
|
+ wrapper.in("inspec_flow_status",0,1);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ Page<BizSellPigApply> page = this.page(bizSellPigApplyPage, wrapper);
|
|
|
+ return new Result(ResultCode.SUCCESS,page);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Result inspecCheck(Map<String,String> map) {
|
|
|
+
|
|
|
+ Map endMap = new HashMap();
|
|
|
+
|
|
|
+ String batchNo = map.get("batchNo");
|
|
|
+ String farmId = map.get("farmId");
|
|
|
+ List<BizSellPigApplyEartag> inspecNos = bizSellPigApplyEartagMapper.selectList(new QueryWrapper<BizSellPigApplyEartag>().eq("batch_no", batchNo));
|
|
|
+ // DOTO
|
|
|
+ List<EartagRegisterEntity> eartagRegisterEntities = eartagRegisterMapper.selectList(new QueryWrapper<EartagRegisterEntity>().eq("stage", 11).eq("inspec_id", farmId));
|
|
|
+
|
|
|
+ List<String> inspecNos1 = inspecNos.stream().map(BizSellPigApplyEartag::getEarmark).collect(Collectors.toList());
|
|
|
+ List<String> eartagRegister1 = eartagRegisterEntities.stream().map(EartagRegisterEntity::getEartagNo).collect(Collectors.toList());
|
|
|
+ int inspecNos1Size = inspecNos1.size();
|
|
|
+ int artagRegister1Size = eartagRegister1.size();
|
|
|
+
|
|
|
+ List<EartagNoVo> list = new ArrayList<>();
|
|
|
+ inspecNos1.stream().forEach( s -> list.add(new EartagNoVo(s,0)));
|
|
|
+ endMap.put("total",inspecNos1Size);
|
|
|
+ if (inspecNos1Size == artagRegister1Size){
|
|
|
+
|
|
|
+
|
|
|
+ endMap.put("abnormal",0);
|
|
|
+
|
|
|
+ }else if (inspecNos1Size > artagRegister1Size){
|
|
|
+ List<String> inspecNos2 = ObjectUtil.clone(inspecNos1);
|
|
|
+ inspecNos2.removeAll(eartagRegister1);
|
|
|
+ for (String s : inspecNos2) {
|
|
|
+
|
|
|
+ list.stream().filter( o -> o.getEartagNo().equals(s)).forEach( e ->e.setStatus(1));
|
|
|
+ }
|
|
|
+
|
|
|
+ endMap.put("abnormal",inspecNos2.size());
|
|
|
+ } else{
|
|
|
+
|
|
|
+ List<String> eartagRegister2 = ObjectUtil.clone(eartagRegister1);
|
|
|
+ eartagRegister2.removeAll(inspecNos1);
|
|
|
+ for (String s : eartagRegister2) {
|
|
|
+
|
|
|
+ list.stream().filter( o -> o.getEartagNo().equals(s)).forEach( e ->e.setStatus(1));
|
|
|
+ }
|
|
|
+
|
|
|
+ endMap.put("abnormal",eartagRegister2.size());
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ endMap.put("eartagNos",list);
|
|
|
+ return new Result(ResultCode.SUCCESS,endMap);
|
|
|
+ }
|
|
|
}
|