Commit 26dee82e LN

修改品名后更新库存报表

1 个父辈 06ed675a
...@@ -15,12 +15,16 @@ import com.neotel.smfcore.core.barcode.service.manager.IBarcodeManager; ...@@ -15,12 +15,16 @@ import com.neotel.smfcore.core.barcode.service.manager.IBarcodeManager;
import com.neotel.smfcore.core.barcode.service.po.Barcode; import com.neotel.smfcore.core.barcode.service.po.Barcode;
import com.neotel.smfcore.core.barcode.utils.QrcodeUtils; import com.neotel.smfcore.core.barcode.utils.QrcodeUtils;
import com.neotel.smfcore.core.device.util.DataCache; import com.neotel.smfcore.core.device.util.DataCache;
import com.neotel.smfcore.core.storage.service.manager.IStoragePosManager;
import com.neotel.smfcore.core.storage.service.manager.impl.StoragePosManagerImpl;
import com.neotel.smfcore.core.storage.service.po.StoragePos;
import com.neotel.smfcore.core.system.service.po.Settings; import com.neotel.smfcore.core.system.service.po.Settings;
import com.neotel.smfcore.security.bean.FileProperties; import com.neotel.smfcore.security.bean.FileProperties;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import net.bytebuddy.asm.Advice;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable; import org.springframework.data.domain.Pageable;
import org.springframework.data.mongodb.core.query.Query; import org.springframework.data.mongodb.core.query.Query;
...@@ -57,6 +61,9 @@ public class BarcodeController { ...@@ -57,6 +61,9 @@ public class BarcodeController {
@Autowired @Autowired
private final FileProperties properties; private final FileProperties properties;
@Autowired
private final IStoragePosManager storagePosManager;
@ApiOperation("导出条码数据") @ApiOperation("导出条码数据")
@GetMapping(value = "/download") @GetMapping(value = "/download")
public void download(HttpServletResponse response, BarcodeQueryCriteria criteria) throws Exception { public void download(HttpServletResponse response, BarcodeQueryCriteria criteria) throws Exception {
...@@ -91,7 +98,36 @@ public class BarcodeController { ...@@ -91,7 +98,36 @@ public class BarcodeController {
if (barcode.getId() == null) { if (barcode.getId() == null) {
throw new ValidateException("smfcore.valueCanotNull","{0}不能为空",new String[]{"ID"}); throw new ValidateException("smfcore.valueCanotNull","{0}不能为空",new String[]{"ID"});
} }
barcodeManager.saveBarcode(barcode); barcode= barcodeManager.saveBarcode(barcode);
//更新库存报表
dataCache.updateInventoryPn(barcode.getPartNumber(),barcode.getPn());
//更改库位号和箱子中的信息
try{
String[] array=barcode.getBarcode().split("-");
if(array.length==2){
String boxbarcode=array[0];
barcode =barcodeManager.get(barcode.getId());
Barcode boxCode=barcodeManager.findByBarcode(boxbarcode);
if(boxCode!=null){
boxCode.updateSubCodes(barcode);
barcodeManager.save(boxCode);
log.info("修改条码"+barcode.getBarcode()+" 后,更新料箱"+boxCode.getBarcode());
//修改库位
StoragePos pos=storagePosManager.getByBarcode(boxCode.getBarcode());
if(pos!=null){
pos.setBarcode(boxCode);
storagePosManager.save(pos);
log.info("修改条码"+barcode.getBarcode()+" 后,更新所在库位"+pos.getPosName());
}
}
}
}catch (Exception exception){
log.error("修改条码 "+barcode.getBarcode()+",更改箱子中的品名出错");
}
return new ResponseEntity<>(HttpStatus.OK); return new ResponseEntity<>(HttpStatus.OK);
} }
@ApiOperation("删除条码") @ApiOperation("删除条码")
......
...@@ -572,6 +572,32 @@ public class DataCache { ...@@ -572,6 +572,32 @@ public class DataCache {
inventoryMap.put(cid, storageInventoryMap); inventoryMap.put(cid, storageInventoryMap);
return storageInventoryMap; return storageInventoryMap;
} }
public boolean updateInventoryPn(String partNumber,String partNo) {
try {
if (ObjectUtil.isEmpty(partNo)) {
partNo = "";
}
if (ObjectUtil.isEmpty(partNumber)) {
return false;
}
List<String> allStorageIds = new ArrayList<>(inventoryMap.keySet());
for (String cid :
allStorageIds) {
InventoryItem inventoryItem = getStorageInventoryByPartNumber(cid, partNumber);
if (inventoryItem == null) {
return false;
}
log.info("updateInventoryPn : partNumber=" + partNumber + ",partNo=" + partNo);
inventoryItem.setPartname(partNo);
updateStorageInventory(cid, inventoryItem);
return true;
}
} catch (Exception exception) {
log.error("updateInventoryPn partNumber=" + partNumber + ",partNo=" + partNo+" error :" + exception.toString());
}
return false;
}
/** /**
* 手动修改数量的时候更新库存 * 手动修改数量的时候更新库存
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!