Commit 2f39a58c 张少辉

1.电子仓CTU入库对接momo系统

1 个父辈 44a024cb
...@@ -16,9 +16,16 @@ import com.neotel.smfcore.core.barcode.utils.CodeResolve; ...@@ -16,9 +16,16 @@ import com.neotel.smfcore.core.barcode.utils.CodeResolve;
import com.neotel.smfcore.core.device.enums.OP; import com.neotel.smfcore.core.device.enums.OP;
import com.neotel.smfcore.core.device.enums.OP_STATUS; import com.neotel.smfcore.core.device.enums.OP_STATUS;
import com.neotel.smfcore.core.device.util.DataCache; import com.neotel.smfcore.core.device.util.DataCache;
import com.neotel.smfcore.core.inList.enums.INLIST_STATUS;
import com.neotel.smfcore.core.inList.service.manager.IInListManager;
import com.neotel.smfcore.core.inList.service.po.InList;
import com.neotel.smfcore.core.inList.service.po.InListItem;
import com.neotel.smfcore.core.inList.util.InListCache;
import com.neotel.smfcore.core.storage.enums.CORRESPONDING_WAREHOUSE;
import com.neotel.smfcore.core.storage.service.manager.IStoragePosManager; import com.neotel.smfcore.core.storage.service.manager.IStoragePosManager;
import com.neotel.smfcore.core.storage.service.po.Storage; import com.neotel.smfcore.core.storage.service.po.Storage;
import com.neotel.smfcore.core.storage.service.po.StoragePos; import com.neotel.smfcore.core.storage.service.po.StoragePos;
import com.neotel.smfcore.core.system.service.dao.impl.SettingsDaoImpl;
import com.neotel.smfcore.core.system.service.po.DataLog; import com.neotel.smfcore.core.system.service.po.DataLog;
import com.neotel.smfcore.core.system.util.TaskService; import com.neotel.smfcore.core.system.util.TaskService;
import com.neotel.smfcore.security.annotation.AnonymousAccess; import com.neotel.smfcore.security.annotation.AnonymousAccess;
...@@ -31,6 +38,7 @@ import org.springframework.web.bind.annotation.RequestMapping; ...@@ -31,6 +38,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -60,6 +68,12 @@ public class ScanInBoxController { ...@@ -60,6 +68,12 @@ public class ScanInBoxController {
@Autowired @Autowired
private DataCache dataCache; private DataCache dataCache;
@Autowired
private InListCache inListCache;
@Autowired
private IInListManager inListManager;
@ApiOperation("查询料箱信息") @ApiOperation("查询料箱信息")
@RequestMapping("/boxInfo") @RequestMapping("/boxInfo")
@AnonymousAccess @AnonymousAccess
...@@ -144,27 +158,52 @@ public class ScanInBoxController { ...@@ -144,27 +158,52 @@ public class ScanInBoxController {
if (StringUtils.isNotEmpty(posName)) { if (StringUtils.isNotEmpty(posName)) {
throw new ValidateException("smfcore.materialBox.inPos", "物料已在库位{0}中", new String[]{posName}); throw new ValidateException("smfcore.materialBox.inPos", "物料已在库位{0}中", new String[]{posName});
} }
//判断是否在入库单中
InListItem item = hasInListItem(subCode);
if (item == null) {
throw new ValidateException("smfcore.noValidInList", "[{0}]入库单中未找到该物料", new String[]{subCode.getBarcode()});
}
if (item.getInNum() >= item.getNum()) {
throw new ValidateException("smfcore.noValidInList", "[{0}]入库单中该物料已入库完成,不能继续入库", new String[]{subCode.getBarcode()});
}
updateInListItem(item,subCode.getAmount());
subCode.setStockoutNo("");
subCode.setStockoutNoLine("");
subCode.setReceiptOrder(item.getName());
subCode.setRowNumber(item.getRowNumber());
subCode.setHostBarcodeId(barcode.getId()); subCode.setHostBarcodeId(barcode.getId());
subCode.setPosName(barcode.getBarcode()); subCode.setPosName(barcode.getBarcode());
subCode.setPutInTime(System.currentTimeMillis()); subCode.setPutInTime(System.currentTimeMillis());
//设置元器件中的其他值
Component component = componentManager.findByPartNumberAndProvider(barcode.getPartNumber(), barcode.getProvider());
if (component != null) {
subCode.setDescription(component.getDescription());
subCode.setProviderMaterialCode(component.getProviderMaterialCode());
subCode.setProviderNumber(component.getProviderNumber());
subCode.setContainmentAmount(component.getContainmentAmount());
subCode.setPlant(component.getPlant());
subCode.setOriginalFactory(component.getOriginalFactory());
subCode.setMassProduction(component.getMassProduction());
}
barcodeManager.saveBarcode(subCode); barcodeManager.saveBarcode(subCode);
barcode = finishTask(barcode, OP.PUT_IN, subCode, subCode.getAmount(), OP_STATUS.FINISHED.name(), subCode.getAmount()); barcode = finishTask(barcode, OP.PUT_IN, subCode, subCode.getAmount(), OP_STATUS.FINISHED.name(), subCode.getAmount(),item.getName());
log.info("条码" + subCode.getBarcode() + "[" + subCode.getPartNumber() + "]入库到料盒[" + barcode.getBarcode() + "]数量:" + barcode.getAmount()); log.info("条码" + subCode.getBarcode() + "[" + subCode.getPartNumber() + "]入库到料盒[" + barcode.getBarcode() + "]数量:" + barcode.getAmount());
return ResultBean.newOkResult(barcodeMapper.toDto(barcode)); return ResultBean.newOkResult(barcodeMapper.toDto(barcode));
} }
private Barcode finishTask(Barcode pidBarcode, int opType, Barcode subBarcode, int opQty, String status, int amount) throws ValidateException { private Barcode finishTask(Barcode pidBarcode, int opType, Barcode subBarcode, int opQty, String status, int amount,String itemName) throws ValidateException {
String orderItemId = subBarcode.getAppendData("orderItemId");
String orderNo = subBarcode.getAppendData("orderNo");
String orderId = subBarcode.getAppendData("orderId");
subBarcode.updateAppendData("orderItemId", null);
subBarcode.updateAppendData("orderNo", null);
subBarcode.updateAppendData("orderId", null);
subBarcode.updateAppendData("awaiting", null);
barcodeManager.save(subBarcode);
//更新barcode缓存 //更新barcode缓存
pidBarcode.UpdateSubCode(subBarcode); pidBarcode.UpdateSubCode(subBarcode);
//设置数量信息
int pidAmount = 0;
List<Barcode> subCodeList = pidBarcode.getSubCodeList();
for (Barcode subCode : subCodeList) {
pidAmount = pidAmount + subCode.getAmount();
}
pidBarcode.setAmount(pidAmount);
barcodeManager.save(subBarcode); barcodeManager.save(subBarcode);
barcodeManager.saveBarcode(pidBarcode); barcodeManager.saveBarcode(pidBarcode);
DataLog task = new DataLog(); DataLog task = new DataLog();
...@@ -177,16 +216,65 @@ public class ScanInBoxController { ...@@ -177,16 +216,65 @@ public class ScanInBoxController {
task.setStorageName(pidBarcode.getBarcode()); task.setStorageName(pidBarcode.getBarcode());
task.setPosName(pidBarcode.getBarcode()); task.setPosName(pidBarcode.getBarcode());
task.setOperator(SecurityUtils.getLoginUsername()); task.setOperator(SecurityUtils.getLoginUsername());
if (StringUtils.isNotEmpty(orderItemId)) { task.setSourceName(itemName);
task.setSubSourceId(orderItemId); //这里默认是电子仓CTU的
} Storage elecCtuStorage = null;
if (StringUtils.isNotEmpty(orderNo)) { for (Storage storage : dataCache.getAllStorage().values()) {
task.setSourceName(orderNo); if (storage.getCorrespondingWarehouse() == CORRESPONDING_WAREHOUSE.ELECTRONIC_WAREHOUSE_BOX) {
elecCtuStorage = storage;
break;
}
} }
if (StringUtils.isNotEmpty(orderId)) { if (elecCtuStorage != null) {
task.setSourceId(orderId); task.setCid(elecCtuStorage.getCid());
task.setStorageName(elecCtuStorage.getName());
task.setStorageId(elecCtuStorage.getId());
} }
taskService.updateFinishedTask(task); taskService.updateFinishedTask(task);
return pidBarcode; return pidBarcode;
} }
private InListItem hasInListItem(Barcode barcode) {
//判断是否有入库单
Collection<InList> aLlInList = inListCache.getALlInList();
InListItem item = null;
for (InList inList : aLlInList) {
List<InListItem> inListItems = inList.getInListItems();
for (InListItem inListItem : inListItems) {
if (barcode.getBarcode().equals(inListItem.getRi())) {
item = inListItem;
break;
}
}
if (item != null) {
break;
}
}
return item;
}
private void updateInListItem(InListItem item, int amount) {
String name = item.getName();
InList inList = inListCache.getInList(name);
item.setInNum(item.getInNum() + amount);
inList.getInListItems().remove(item);
inList.getInListItems().add(item);
//判断是否已经全部执行完成
boolean finish = true;
for (InListItem inListItem : inList.getInListItems()) {
if (inListItem.getInNum() < inListItem.getNum()) {
finish = false;
break;
}
}
if (finish) {
inList.setStatus(INLIST_STATUS.OK);
}
inList = inListManager.createWithItems(inList);
inListCache.addInListToMap(inList);
log.info("【物料入箱】任务单数据更新完成,receiptOrder={}", name);
inListCache.addInListToMap(inList);
}
} }
...@@ -74,6 +74,7 @@ public class MomoApi extends BaseSmfApiListener { ...@@ -74,6 +74,7 @@ public class MomoApi extends BaseSmfApiListener {
//默认结构仓的 //默认结构仓的
if (storage.getCorrespondingWarehouse() == CORRESPONDING_WAREHOUSE.STRUCTURAL_WAREHOUSE if (storage.getCorrespondingWarehouse() == CORRESPONDING_WAREHOUSE.STRUCTURAL_WAREHOUSE
|| storage.getCorrespondingWarehouse() == CORRESPONDING_WAREHOUSE.ELECTRONIC_WAREHOUSE || storage.getCorrespondingWarehouse() == CORRESPONDING_WAREHOUSE.ELECTRONIC_WAREHOUSE
|| storage.getCorrespondingWarehouse() == CORRESPONDING_WAREHOUSE.ELECTRONIC_WAREHOUSE_BOX
) { ) {
String receiptOrder = barcode.getReceiptOrder(); String receiptOrder = barcode.getReceiptOrder();
if (StringUtils.isNotEmpty(receiptOrder)) { if (StringUtils.isNotEmpty(receiptOrder)) {
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!