|
@@ -1,17 +1,23 @@
|
|
package com.huimv.receive.service.impl;
|
|
package com.huimv.receive.service.impl;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
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.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
|
+import com.huimv.receive.common.token.TokenSign;
|
|
|
|
+import com.huimv.receive.common.utils.FlowUtil;
|
|
import com.huimv.receive.common.utils.Result;
|
|
import com.huimv.receive.common.utils.Result;
|
|
import com.huimv.receive.common.utils.ResultCode;
|
|
import com.huimv.receive.common.utils.ResultCode;
|
|
-import com.huimv.receive.entity.BillGoodsInventory;
|
|
|
|
|
|
+import com.huimv.receive.entity.*;
|
|
import com.huimv.receive.entity.vo.BillGoodsInventoryVo;
|
|
import com.huimv.receive.entity.vo.BillGoodsInventoryVo;
|
|
-import com.huimv.receive.mapper.BillGoodsInventoryMapper;
|
|
|
|
|
|
+import com.huimv.receive.mapper.*;
|
|
import com.huimv.receive.service.IBillGoodsInventoryService;
|
|
import com.huimv.receive.service.IBillGoodsInventoryService;
|
|
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 javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
+import java.time.LocalDateTime;
|
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
import java.util.Calendar;
|
|
import java.util.Calendar;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
@@ -29,6 +35,22 @@ public class BillGoodsInventoryServiceImpl extends ServiceImpl<BillGoodsInventor
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
private BillGoodsInventoryMapper inventoryMapper;
|
|
private BillGoodsInventoryMapper inventoryMapper;
|
|
|
|
+ @Autowired
|
|
|
|
+ private BaseProcessMapper processMapper;
|
|
|
|
+ @Autowired
|
|
|
|
+ private BaseLocationMapper locationMapper;
|
|
|
|
+ @Autowired
|
|
|
|
+ private BillPcrMapper pcrMapper;
|
|
|
|
+ @Autowired
|
|
|
|
+ private BillCleanMapper cleanMapper;
|
|
|
|
+ @Autowired
|
|
|
|
+ private BillIsolateMapper isolateMapper;
|
|
|
|
+ @Autowired
|
|
|
|
+ private BillDryMapper dryMapper;
|
|
|
|
+ @Autowired
|
|
|
|
+ private BillCleanBeforeMapper billCleanBeforeMapper;
|
|
|
|
+ @Autowired
|
|
|
|
+ private BillSamplingMapper billSamplingMapper;
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public Result listAll(HttpServletRequest httpServletRequest, Map<String, String> paramsMap) {
|
|
public Result listAll(HttpServletRequest httpServletRequest, Map<String, String> paramsMap) {
|
|
@@ -40,4 +62,223 @@ public class BillGoodsInventoryServiceImpl extends ServiceImpl<BillGoodsInventor
|
|
List<BillGoodsInventoryVo> billGoodsInventoryVos = inventoryMapper.listAll(queryWrapper);
|
|
List<BillGoodsInventoryVo> billGoodsInventoryVos = inventoryMapper.listAll(queryWrapper);
|
|
return new Result(ResultCode.SUCCESS, billGoodsInventoryVos);
|
|
return new Result(ResultCode.SUCCESS, billGoodsInventoryVos);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public Result edit(HttpServletRequest httpServletRequest, Map<String, String> paramsMap) {
|
|
|
|
+ String id = paramsMap.get("id");
|
|
|
|
+ String goodsType = paramsMap.get("goodsType");
|
|
|
|
+ String goodsTypeName = paramsMap.get("goodsTypeName");
|
|
|
|
+ String goodsNum = paramsMap.get("goodsNum");
|
|
|
|
+ String goodsName = paramsMap.get("goodsName");
|
|
|
|
+ String goodsUnit = paramsMap.get("goodsUnit");
|
|
|
|
+ DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm");
|
|
|
|
+ BillGoodsInventory goodsInventory = inventoryMapper.selectById(id);
|
|
|
|
+ goodsInventory.setGoodsName(goodsName);
|
|
|
|
+ goodsInventory.setGoodsType(goodsType);
|
|
|
|
+ goodsInventory.setGoodsNums(goodsNum);
|
|
|
|
+ goodsInventory.setGoodsTypeName(goodsTypeName);
|
|
|
|
+ goodsInventory.setUserId(TokenSign.getMemberIdByJwtToken(httpServletRequest));
|
|
|
|
+ goodsInventory.setUserName(TokenSign.getUserNameByJwtToken(httpServletRequest));
|
|
|
|
+ goodsInventory.setGoodsUnit(goodsUnit);
|
|
|
|
+ goodsInventory.setSubDate(LocalDateTime.now());
|
|
|
|
+
|
|
|
|
+ QueryWrapper<BaseProcess> processQueryWrapper = new QueryWrapper<>();
|
|
|
|
+ processQueryWrapper.eq("farm_id", goodsInventory.getFarmId()).eq("id", goodsInventory.getBillAdmission());
|
|
|
|
+ BaseProcess baseProcess = processMapper.selectOne(processQueryWrapper);//进程
|
|
|
|
+
|
|
|
|
+ QueryWrapper<BaseLocation> locationQueryWrapper = new QueryWrapper<>();
|
|
|
|
+ locationQueryWrapper.eq("id", goodsInventory.getCurrentLocationId());
|
|
|
|
+ BaseLocation baseLocation = locationMapper.selectOne(locationQueryWrapper);//当前pcr检测所在的位置
|
|
|
|
+
|
|
|
|
+ String allLocationId = baseProcess.getAllLocationId();//所有的位置id
|
|
|
|
+ String allFlowId = baseProcess.getAllFlowId();//所有的流程id
|
|
|
|
+ String currentFlowId = baseProcess.getCurrentFlowId();//当前已经完成的流程id
|
|
|
|
+ String substring1 = allFlowId.substring(currentFlowId.length() + 1, allFlowId.length());
|
|
|
|
+ String[] split = substring1.split(",");
|
|
|
|
+ Integer nextId = Integer.parseInt(split[0]);
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ Object newObject = BillPcrServiceImpl.getNewObject(nextId, goodsInventory.getDestName(), goodsInventory.getDestId(), goodsInventory.getAdmissionUserName(),
|
|
|
|
+ goodsInventory.getAdmissionUserId(), goodsInventory.getVistitDate(), goodsInventory.getSubDate(),
|
|
|
|
+ goodsInventory.getBillAdmission(), Integer.parseInt(goodsInventory.getFarmId()), goodsInventory.getCurrentLocation(), goodsInventory.getCurrentLocationId(),
|
|
|
|
+ goodsInventory.getVistitType(), goodsInventory.getPhone(),goodsInventory.getDepartureName(),goodsInventory.getDepartureId());
|
|
|
|
+ if (nextId == 0) {
|
|
|
|
+ if (split.length == 1) {
|
|
|
|
+ baseProcess.setProcessType(1);
|
|
|
|
+ if (allLocationId.length() > 9) {
|
|
|
|
+ baseProcess.setAllLocationStatus("2,2,2,2,2,2,2");
|
|
|
|
+ } else if (allLocationId.length() > 5 && allLocationId.length() < 10) {
|
|
|
|
+ baseProcess.setAllLocationStatus("2,2,2,2,2");
|
|
|
|
+ } else {
|
|
|
|
+ baseProcess.setAllLocationStatus("2,2,2");
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ String[] strings = allLocationId.split(",");
|
|
|
|
+ Integer index = 0;
|
|
|
|
+ for (int i = 0; i < strings.length; i++) {
|
|
|
|
+ if ((baseLocation.getId().toString()).equals(strings[i])) {
|
|
|
|
+ index = i;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ QueryWrapper<BaseLocation> queryWrapper1 = new QueryWrapper();
|
|
|
|
+ queryWrapper1.eq("id", strings[index + 2]);
|
|
|
|
+ BaseLocation location = locationMapper.selectOne(queryWrapper1);
|
|
|
|
+ FlowUtil flowUtil = new FlowUtil();
|
|
|
|
+ Object entity = flowUtil.getEntity(Integer.parseInt(split[1]), goodsInventory.getVistitType(), goodsInventory.getDestName()
|
|
|
|
+ , goodsInventory.getDestId(), goodsInventory.getAdmissionUserId(), goodsInventory.getAdmissionUserName(), goodsInventory.getPhone(),
|
|
|
|
+ goodsInventory.getVistitDate(), location.getId(), location.getLocationName(), Integer.parseInt(goodsInventory.getFarmId())
|
|
|
|
+ , baseProcess.getId(), goodsInventory.getDepartureName(), goodsInventory.getDepartureId());
|
|
|
|
+ if (Integer.parseInt(split[1]) == 1) {
|
|
|
|
+ //新增采样
|
|
|
|
+ BillSampling billSampling = (BillSampling) entity;
|
|
|
|
+ if (goodsInventory.getVistitType() != 0) {
|
|
|
|
+ billSampling.setCarNum(goodsInventory.getCarNum());
|
|
|
|
+ }
|
|
|
|
+ billSamplingMapper.insert(billSampling);
|
|
|
|
+ } else if (Integer.parseInt(split[1]) == 2) {
|
|
|
|
+ //新增pcr
|
|
|
|
+ BillPcr billClean = (BillPcr) entity;
|
|
|
|
+ if (goodsInventory.getVistitType() != 0) {
|
|
|
|
+ billClean.setCarNum(goodsInventory.getCarNum());
|
|
|
|
+ }
|
|
|
|
+ pcrMapper.insert(billClean);
|
|
|
|
+ } else if (Integer.parseInt(split[1]) == 3) {
|
|
|
|
+ //新增洗澡
|
|
|
|
+ BillClean billClean = (BillClean) entity;
|
|
|
|
+ if (goodsInventory.getVistitType() != 0) {
|
|
|
|
+ billClean.setCarNum(goodsInventory.getCarNum());
|
|
|
|
+ }
|
|
|
|
+ cleanMapper.insert(billClean);
|
|
|
|
+ } else if (Integer.parseInt(split[1]) == 4) {
|
|
|
|
+ //新增隔离
|
|
|
|
+ BillIsolate pcr = (BillIsolate) entity;
|
|
|
|
+ isolateMapper.insert(pcr);
|
|
|
|
+ } else if (Integer.parseInt(split[1]) == 5) {
|
|
|
|
+ BillDry billClean = (BillDry) entity;
|
|
|
|
+ if (goodsInventory.getVistitType() != 0) {
|
|
|
|
+ billClean.setCarNum(goodsInventory.getCarNum());
|
|
|
|
+ }
|
|
|
|
+ dryMapper.insert(billClean);
|
|
|
|
+ //新增烘干
|
|
|
|
+ } else if (Integer.parseInt(split[1]) == 6) {
|
|
|
|
+ //新增洗澡前拍照
|
|
|
|
+ BillCleanBefore before = (BillCleanBefore) entity;
|
|
|
|
+ if (goodsInventory.getVistitType() != 0) {
|
|
|
|
+ before.setCarNum(goodsInventory.getCarNum());
|
|
|
|
+ }
|
|
|
|
+ billCleanBeforeMapper.insert(before);
|
|
|
|
+ }
|
|
|
|
+ else if (Integer.parseInt(split[1]) == 7) {
|
|
|
|
+ //新增洗澡前拍照
|
|
|
|
+ BillGoodsInventory before = (BillGoodsInventory) entity;
|
|
|
|
+ if (goodsInventory.getVistitType() != 0) {
|
|
|
|
+ before.setCarNum(goodsInventory.getCarNum());
|
|
|
|
+ }
|
|
|
|
+ inventoryMapper.insert(before);
|
|
|
|
+ }
|
|
|
|
+ baseProcess.setCurrentFlowId(baseProcess.getCurrentFlowId() + "," + nextId + "," + split[1]);
|
|
|
|
+ if (allLocationId.length() > 9) {
|
|
|
|
+ if (index == 1) {
|
|
|
|
+ baseProcess.setAllLocationStatus("2,2,2,1,0,0,0");
|
|
|
|
+ } else {
|
|
|
|
+ baseProcess.setAllLocationStatus("2,2,2,2,2,1,0");
|
|
|
|
+ }
|
|
|
|
+ } else if (allLocationId.length() > 5 && allLocationId.length() < 10) {
|
|
|
|
+ baseProcess.setAllLocationStatus("2,2,2,1,0");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } else if (nextId == 1) {
|
|
|
|
+ //新增采样
|
|
|
|
+ BillSampling billSampling = (BillSampling) newObject;
|
|
|
|
+ if (goodsInventory.getVistitType() != 0) {
|
|
|
|
+ billSampling.setCarNum(goodsInventory.getCarNum());
|
|
|
|
+ }
|
|
|
|
+ billSamplingMapper.insert(billSampling);
|
|
|
|
+ baseProcess.setCurrentFlowId(baseProcess.getCurrentFlowId() + "," + nextId);
|
|
|
|
+ }else if (nextId == 2) {
|
|
|
|
+ //新增pcr
|
|
|
|
+ BillPcr billClean = (BillPcr) newObject;
|
|
|
|
+ if (goodsInventory.getVistitType() != 0) {
|
|
|
|
+ billClean.setCarNum(goodsInventory.getCarNum());
|
|
|
|
+ }
|
|
|
|
+ pcrMapper.insert(billClean);
|
|
|
|
+ baseProcess.setCurrentFlowId(baseProcess.getCurrentFlowId() + "," + nextId);
|
|
|
|
+ }else if (nextId == 3) {
|
|
|
|
+ //新增洗澡
|
|
|
|
+ BillClean billClean = (BillClean) newObject;
|
|
|
|
+ if (goodsInventory.getVistitType() != 0) {
|
|
|
|
+ billClean.setCarNum(goodsInventory.getCarNum());
|
|
|
|
+ }
|
|
|
|
+ cleanMapper.insert(billClean);
|
|
|
|
+ baseProcess.setCurrentFlowId(baseProcess.getCurrentFlowId() + "," + nextId);
|
|
|
|
+ }else if (nextId == 4) {
|
|
|
|
+ //新增隔离
|
|
|
|
+ BillIsolate pcr = (BillIsolate) newObject;
|
|
|
|
+ isolateMapper.insert(pcr);
|
|
|
|
+ baseProcess.setCurrentFlowId(baseProcess.getCurrentFlowId() + "," + nextId);
|
|
|
|
+ }else if (nextId == 5) {
|
|
|
|
+ BillDry billClean = (BillDry) newObject;
|
|
|
|
+ if (goodsInventory.getVistitType() != 0) {
|
|
|
|
+ billClean.setCarNum(goodsInventory.getCarNum());
|
|
|
|
+ }
|
|
|
|
+ dryMapper.insert(billClean);
|
|
|
|
+ baseProcess.setCurrentFlowId(baseProcess.getCurrentFlowId() + "," + nextId);
|
|
|
|
+ //新增烘干
|
|
|
|
+ }else if (nextId == 6) {
|
|
|
|
+ //新增洗澡前拍照
|
|
|
|
+ BillCleanBefore before = (BillCleanBefore) newObject;
|
|
|
|
+ if (goodsInventory.getVistitType() != 0) {
|
|
|
|
+ before.setCarNum(goodsInventory.getCarNum());
|
|
|
|
+ }
|
|
|
|
+ billCleanBeforeMapper.insert(before);
|
|
|
|
+ baseProcess.setCurrentFlowId(baseProcess.getCurrentFlowId() + "," + nextId);
|
|
|
|
+ }
|
|
|
|
+ else if (nextId == 7) {
|
|
|
|
+ //新增洗澡前拍照
|
|
|
|
+ BillGoodsInventory before = (BillGoodsInventory) newObject;
|
|
|
|
+ if (goodsInventory.getVistitType() != 0) {
|
|
|
|
+ before.setCarNum(goodsInventory.getCarNum());
|
|
|
|
+ }
|
|
|
|
+ inventoryMapper.insert(before);
|
|
|
|
+ baseProcess.setCurrentFlowId(baseProcess.getCurrentFlowId() + "," + nextId);
|
|
|
|
+ }
|
|
|
|
+ baseProcess.setUpdateDate(baseProcess.getUpdateDate() + "," + LocalDateTime.now().format(dateTimeFormatter));
|
|
|
|
+ baseProcess.setCurrentLocation(baseProcess.getCurrentLocation() + "," + baseLocation.getLocationName());
|
|
|
|
+ baseProcess.setCurrentLocationId(baseProcess.getCurrentLocationId() + "," + baseLocation.getId());
|
|
|
|
+ String status = baseProcess.getCurrentStatus();
|
|
|
|
+ String substring = status.substring(0, status.length() - 1);
|
|
|
|
+
|
|
|
|
+ baseProcess.setCurrentStatus(substring + "1," + 0);
|
|
|
|
+ processMapper.updateById(baseProcess);
|
|
|
|
+ inventoryMapper.updateById(goodsInventory);
|
|
|
|
+ return new Result(10000, "修改成功!", true);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public Result list(HttpServletRequest httpServletRequest, Map<String, String> paramsMap) {
|
|
|
|
+ String farmId = paramsMap.get("farmId");
|
|
|
|
+ String type = paramsMap.get("type");//0 全部 1未填写 2已填写
|
|
|
|
+ String data = paramsMap.get("data");//来访类型
|
|
|
|
+ String pageNum = paramsMap.get("pageNum");
|
|
|
|
+ String pageSize = paramsMap.get("pageSize");
|
|
|
|
+ if ("".equals(pageNum) || null == pageNum) {
|
|
|
|
+ pageNum = "1";
|
|
|
|
+ }
|
|
|
|
+ if ("".equals(pageSize) || null == pageSize) {
|
|
|
|
+ pageSize = "10";
|
|
|
|
+ }
|
|
|
|
+ if ("".equals(type) || null == type) {
|
|
|
|
+ type = "0";
|
|
|
|
+ }
|
|
|
|
+ QueryWrapper<BillGoodsInventory> queryWrapper = new QueryWrapper<>();
|
|
|
|
+ Page<BillGoodsInventory> page = new Page(Integer.parseInt(pageNum), Integer.parseInt(pageSize));
|
|
|
|
+ queryWrapper.eq("farm_id", farmId).orderByDesc("sub_date");
|
|
|
|
+ queryWrapper.eq(StringUtils.isNotBlank(data), "vistit_type", data);
|
|
|
|
+ if ("0".equals(type)) {
|
|
|
|
+ queryWrapper.in("status", 0, 1);
|
|
|
|
+ } else {
|
|
|
|
+ queryWrapper.eq("status", type);
|
|
|
|
+ }
|
|
|
|
+ return new Result(ResultCode.SUCCESS,inventoryMapper.selectPage(page,queryWrapper));
|
|
|
|
+ }
|
|
}
|
|
}
|