|
@@ -23,7 +23,6 @@ import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
-import java.math.BigDecimal;
|
|
|
import java.util.List;
|
|
|
|
|
|
import static java.util.stream.Collectors.toList;
|
|
@@ -66,16 +65,15 @@ public class EquBarrelServiceImpl extends SuperServiceImpl<EquBarrelMapper, EquB
|
|
|
// 查询该设备上的所有商品
|
|
|
List<EquGoodsDto> equGoodsDtoList = productionTenantResourceService.getEquGoods(equId);
|
|
|
|
|
|
- if (equGoodsDtoList != null) {
|
|
|
+ if (equGoodsDtoList != null&&equGoodsDtoList.size()>0) {
|
|
|
equGoodsDtoList.forEach(equGoodsDto -> {
|
|
|
List<Spe> speList = equGoodsDto.getSpeList();
|
|
|
- if (null != speList) {
|
|
|
+ if (null != speList&&speList.size()>0) {
|
|
|
speList.forEach(spe -> {
|
|
|
QueryWrap<Formula> formulaQueryWrap = new QueryWrap<>();
|
|
|
formulaQueryWrap.eq("formula_spe_id", spe.getId());
|
|
|
List<Formula> formulaList = formulaService.list(formulaQueryWrap);
|
|
|
- if (formulaList != null) {
|
|
|
-
|
|
|
+ if (formulaList != null&&formulaList.size()>0) {
|
|
|
if (barrelList != null) {
|
|
|
List<Long> mtList = barrelList.stream().map(EquBarrel::getMtrId).collect(toList());
|
|
|
formulaList.forEach(formula -> {
|
|
@@ -122,59 +120,59 @@ public class EquBarrelServiceImpl extends SuperServiceImpl<EquBarrelMapper, EquB
|
|
|
|
|
|
|
|
|
// 查询出配方
|
|
|
- QueryWrap<Formula> formulaQueryWrap = new QueryWrap<>();
|
|
|
- formulaQueryWrap.eq("formula_spe_id", speId);
|
|
|
- List<Formula> formulaList = formulaService.list(formulaQueryWrap);
|
|
|
- System.out.println("查询到的配方" + JSON.toJSONString(formulaList));
|
|
|
+// QueryWrap<Formula> formulaQueryWrap = new QueryWrap<>();
|
|
|
+// formulaQueryWrap.eq("formula_spe_id", speId);
|
|
|
+// List<Formula> formulaList = formulaService.list(formulaQueryWrap);
|
|
|
+// System.out.println("查询到的配方" + JSON.toJSONString(formulaList));
|
|
|
|
|
|
|
|
|
// 遍历配方,扣减每种原料的余量
|
|
|
- if (barrelList != null && formulaList != null) {
|
|
|
-
|
|
|
-
|
|
|
- for (Formula f : formulaList
|
|
|
- ) {
|
|
|
- Long formulaMtId = f.getFormulaMtId();
|
|
|
-
|
|
|
- BigDecimal formulaMtQuantity = f.getFormulaMtQuantity();
|
|
|
-
|
|
|
-
|
|
|
- for (EquBarrel barrel : barrelList
|
|
|
- ) {
|
|
|
-// 查询料筒余料
|
|
|
- BigDecimal mtrResidue = barrel.getMtrResidue();
|
|
|
- if (barrel.getMtrId().equals(formulaMtId)) {
|
|
|
- System.out.println("比对出料筒里的原料" + barrel.getMtrId() + "等于配方里的原料" + formulaMtId);
|
|
|
- BigDecimal subtract = mtrResidue.subtract(formulaMtQuantity);
|
|
|
- System.out.println("料筒原先的余料" + mtrResidue);
|
|
|
- System.out.println("料筒生产后的余料" + subtract);
|
|
|
- UpdateWrapper<EquBarrel> equBarrelUpdateWrapper = new UpdateWrapper<>();
|
|
|
- equBarrelUpdateWrapper.set("mtr_residue", subtract).eq("id", barrel.getId());
|
|
|
-// 扣减后,余料达到余料预警,更新料筒余料
|
|
|
- this.update(equBarrelUpdateWrapper);
|
|
|
- if (subtract.compareTo(barrel.getResidueWarn()) != 1) {
|
|
|
-// 扣减后,余料小于余料预警,更新商品缺料
|
|
|
- Spe spe = speService.getById(speId);
|
|
|
- Long goodsId = spe.getGoodsId();
|
|
|
- System.out.println("商品id" + goodsId + "规格" + speId + "原料不足了");
|
|
|
- UpdateWrapper<EquAndGoods> equAndGoodsUpdateWrapper = new UpdateWrapper<>();
|
|
|
- equAndGoodsUpdateWrapper.eq("equ_id", equId).eq("goods_id", goodsId).set("is_starving", "0");
|
|
|
- equAndGoodsService.update(equAndGoodsUpdateWrapper);
|
|
|
-// 更新料筒缺料
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- } else {
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
+// if (barrelList != null && formulaList != null) {
|
|
|
+//
|
|
|
+//
|
|
|
+// for (Formula f : formulaList
|
|
|
+// ) {
|
|
|
+// Long formulaMtId = f.getFormulaMtId();
|
|
|
+//
|
|
|
+// BigDecimal formulaMtQuantity = f.getFormulaMtQuantity();
|
|
|
+//
|
|
|
+//
|
|
|
+// for (EquBarrel barrel : barrelList
|
|
|
+// ) {
|
|
|
+//// 查询料筒余料
|
|
|
+// BigDecimal mtrResidue = barrel.getMtrResidue();
|
|
|
+// if (barrel.getMtrId().equals(formulaMtId)) {
|
|
|
+// System.out.println("比对出料筒里的原料" + barrel.getMtrId() + "等于配方里的原料" + formulaMtId);
|
|
|
+// BigDecimal subtract = mtrResidue.subtract(formulaMtQuantity);
|
|
|
+// System.out.println("料筒原先的余料" + mtrResidue);
|
|
|
+// System.out.println("料筒生产后的余料" + subtract);
|
|
|
+// UpdateWrapper<EquBarrel> equBarrelUpdateWrapper = new UpdateWrapper<>();
|
|
|
+// equBarrelUpdateWrapper.set("mtr_residue", subtract).eq("id", barrel.getId());
|
|
|
+//// 扣减后,余料达到余料预警,更新料筒余料
|
|
|
+// this.update(equBarrelUpdateWrapper);
|
|
|
+// if (subtract.compareTo(barrel.getResidueWarn()) != 1) {
|
|
|
+//// 扣减后,余料小于余料预警,更新商品缺料
|
|
|
+// Spe spe = speService.getById(speId);
|
|
|
+// Long goodsId = spe.getGoodsId();
|
|
|
+// System.out.println("商品id" + goodsId + "规格" + speId + "原料不足了");
|
|
|
+// UpdateWrapper<EquAndGoods> equAndGoodsUpdateWrapper = new UpdateWrapper<>();
|
|
|
+// equAndGoodsUpdateWrapper.eq("equ_id", equId).eq("goods_id", goodsId).set("is_starving", "0");
|
|
|
+// equAndGoodsService.update(equAndGoodsUpdateWrapper);
|
|
|
+//// 更新料筒缺料
|
|
|
+//
|
|
|
+//
|
|
|
+// }
|
|
|
+//
|
|
|
+// } else {
|
|
|
+//
|
|
|
+// }
|
|
|
+//
|
|
|
+// }
|
|
|
+//
|
|
|
+// }
|
|
|
+//
|
|
|
+//
|
|
|
+// }
|
|
|
|
|
|
|
|
|
}
|