|
@@ -1,14 +1,18 @@
|
|
|
package com.zkqy.business.controller;
|
|
|
|
|
|
+import java.text.DecimalFormat;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
+import java.util.Objects;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
import com.zkqy.business.domain.ProductInventory;
|
|
|
import com.zkqy.business.domain.vo.NewOldProductCodeListVO;
|
|
|
+import com.zkqy.business.mapper.ProductInventoryMapper;
|
|
|
import com.zkqy.business.service.IProductCodeListService;
|
|
|
import com.zkqy.business.service.IProductCodeLogService;
|
|
|
import com.zkqy.business.service.IProductInventoryService;
|
|
|
+import com.zkqy.common.utils.DateUtils;
|
|
|
import com.zkqy.common.utils.SecurityUtils;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
@@ -46,6 +50,8 @@ public class ProductCodeAListController extends BaseController
|
|
|
private IProductCodeLogService productCodeLogService;
|
|
|
@Autowired
|
|
|
private IProductCodeAListService productCodeAListService;
|
|
|
+ @Autowired
|
|
|
+ private ProductInventoryMapper productInventoryMapper;
|
|
|
|
|
|
/**
|
|
|
* 查询产品码单列表
|
|
@@ -101,7 +107,77 @@ public class ProductCodeAListController extends BaseController
|
|
|
@PutMapping
|
|
|
public AjaxResult edit(@RequestBody ProductCodeAList productCodeAList)
|
|
|
{
|
|
|
- ProductCodeAList historyproductCodeAList = productCodeAListService.selectProductCodeAListById(productCodeAList.getId());
|
|
|
+ ProductCodeAList historyproductCodeAList = productCodeAListService.selectProductCodeAListById(productCodeAList.getId());//查询历史数据
|
|
|
+ if(productCodeAList.getLotNum().equals(historyproductCodeAList.getLotNum()) &&
|
|
|
+ productCodeAList.getProductColour().equals(historyproductCodeAList.getProductColour()) &&
|
|
|
+ productCodeAList.getLevels().equals(historyproductCodeAList.getLevels())
|
|
|
+ ){}else{
|
|
|
+// 判断是否入库
|
|
|
+ if(null != historyproductCodeAList.getWarehouseregionId()){
|
|
|
+ //查询历史条目在库存中是否存在数据
|
|
|
+ ProductInventory productInventory = new ProductInventory();
|
|
|
+ productInventory.setLotNum(historyproductCodeAList.getLotNum());//批号
|
|
|
+ productInventory.setProductId(historyproductCodeAList.getProductId());//产品编号
|
|
|
+ productInventory.setProductColour(historyproductCodeAList.getProductColour());//颜色
|
|
|
+ productInventory.setInventoryType("1");//类型
|
|
|
+ productInventory.setQrCode(historyproductCodeAList.getQrCode());//码单号
|
|
|
+ productInventory.setLevels(historyproductCodeAList.getLevels());//等级
|
|
|
+ ProductInventory productInventory1 = productInventoryMapper.oldselectProductInventoryByLotNumAndProductIdAndqrcoud(productInventory);
|
|
|
+ //减库存操作
|
|
|
+ int kuts = productInventory1.getTotalCanisterNum().intValue();
|
|
|
+ int scts = historyproductCodeAList.getCanisterNum().intValue();
|
|
|
+ kuts = (kuts-scts);
|
|
|
+ productInventory1.setTotalCanisterNum(kuts);//获得合计筒数
|
|
|
+ Integer boxnum = productInventory1.getTotalBoxNum()-1;
|
|
|
+ productInventory1.setTotalBoxNum(boxnum);//合计箱数
|
|
|
+ Double suttle = productInventory1.getTotalSuttle() - historyproductCodeAList.getSuttle();
|
|
|
+ productInventory1.setTotalSuttle(suttle);//合计净重
|
|
|
+ Double grossweight = productInventory1.getTotalGrossWeight() - historyproductCodeAList.getGrossWeight();
|
|
|
+ productInventory1.setTotalGrossWeight(grossweight);//合计毛重
|
|
|
+ productInventoryMapper.updateProductInventory(productInventory1);
|
|
|
+ ProductInventory productInventory11 = productInventoryMapper.oldselectProductInventoryByLotNumAndProductIdAndqrcoud(productInventory);
|
|
|
+ if(productInventory11.getTotalBoxNum() <=0 && productInventory11.getTotalSuttle() <= 0 && productInventory11.getTotalGrossWeight() <= 0){
|
|
|
+ int i = productInventoryMapper.deleteProductInventoryById(productInventory11.getId());
|
|
|
+ }
|
|
|
+
|
|
|
+ //根据当前数据查询是否存在库存数据
|
|
|
+ ProductInventory productInventory2 = new ProductInventory();
|
|
|
+ productInventory2.setLotNum(productCodeAList.getLotNum());//批号
|
|
|
+ productInventory2.setProductId(productCodeAList.getProductId());//产品编号
|
|
|
+ productInventory2.setProductColour(productCodeAList.getProductColour());//颜色
|
|
|
+ productInventory2.setInventoryType("1");//类型
|
|
|
+ productInventory2.setQrCode(productCodeAList.getQrCode());//码单号
|
|
|
+ productInventory2.setLevels(productCodeAList.getLevels());//等级
|
|
|
+ ProductInventory productInventory3 = productInventoryMapper.oldselectProductInventoryByLotNumAndProductIdAndqrcoud(productInventory2);
|
|
|
+ if(Objects.isNull(productInventory3)){
|
|
|
+ ProductInventory addProductInventory = new ProductInventory();
|
|
|
+ BeanUtils.copyProperties(productCodeAList, addProductInventory);
|
|
|
+ addProductInventory.setWarehouseId(productCodeAList.getWarehouseregionId());
|
|
|
+ addProductInventory.setTotalCanisterNum(productCodeAList.getCanisterNum().intValue());//合计筒数
|
|
|
+ addProductInventory.setTotalBoxNum(1);//合计箱数
|
|
|
+ addProductInventory.setTotalSuttle(productCodeAList.getSuttle().doubleValue());//合计净重
|
|
|
+ addProductInventory.setTotalGrossWeight(productCodeAList.getGrossWeight().doubleValue());//合计毛重
|
|
|
+ addProductInventory.setCreateBy(SecurityUtils.getUsername());
|
|
|
+ addProductInventory.setCreateTime(DateUtils.getNowDate());
|
|
|
+ addProductInventory.setCreateById(SecurityUtils.getUserId());
|
|
|
+ productInventoryMapper.insertProductInventory(addProductInventory);
|
|
|
+ }else{
|
|
|
+ ProductInventory editProductInventory = new ProductInventory();
|
|
|
+ editProductInventory.setId(productInventory3.getId());
|
|
|
+ editProductInventory.setTotalCanisterNum(productInventory3.getTotalCanisterNum()+productCodeAList.getCanisterNum().intValue());//合计筒数数
|
|
|
+ editProductInventory.setTotalBoxNum(productInventory3.getTotalBoxNum() + 1);//合计箱数
|
|
|
+ Double suttles = productInventory3.getTotalSuttle().doubleValue()+productCodeAList.getSuttle();
|
|
|
+ editProductInventory.setTotalSuttle(Double.parseDouble(suttles.toString()));//合计净重
|
|
|
+ Double grossWeight = productInventory3.getTotalGrossWeight()+productCodeAList.getGrossWeight().doubleValue();
|
|
|
+ editProductInventory.setTotalGrossWeight(grossWeight);//合计毛重
|
|
|
+ editProductInventory.setUpdateById(SecurityUtils.getUserId());
|
|
|
+ editProductInventory.setUpdateBy(SecurityUtils.getUsername());
|
|
|
+ editProductInventory.setUpdateTime(DateUtils.getNowDate());
|
|
|
+ productInventoryMapper.updateProductInventory(editProductInventory);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ }
|
|
|
ProductCodeLog productCodeLog = new ProductCodeLog();
|
|
|
BeanUtils.copyProperties(historyproductCodeAList,productCodeLog);
|
|
|
productCodeLog.setId(null);
|