Commit ab35d3a4 张少辉

1.增加电子仓货架料箱手动出入库

1 个父辈 73a53585
......@@ -11,4 +11,6 @@ public class CORRESPONDING_WAREHOUSE {
//成品仓
public static final int FINISHED_GOODS_WAREHOUSE = 2;
//电子仓货架
public static final int ELECTRONIC_WAREHOUSE_BOX = 3;
}
......@@ -196,7 +196,7 @@ public class TaskService {
* @param task
*/
public void updateFinishedTask(DataLog task) {
dataLogDao.save(task);
task = dataLogDao.save(task);
theFinishedTaskMap.put(task.getId(), task);
tiggerTaskChangeListener(task);
}
......
......@@ -26,6 +26,10 @@ public class Aiqingzhiyin1643Menu {
public void init(){
String menuLabel = "1643";
Menu elecWarehouse = Menu.CreatePMenu("电子仓管理", 3, "elecWarehouse", "elecWarehouse", null);
MenuInit.addMenu(menuLabel,elecWarehouse,1, "扫码入箱","scanInBox", "neolight/scanInBox/index","scanInBox");
MenuInit.addMenu(menuLabel,elecWarehouse,2, "扫码出箱","scanOutBox", "neolight/scanOutBox/index","scanOutBox");
Menu finishedGoodsWarehouse = Menu.CreatePMenu("成品仓管理", 4, "finishedGoodsWarehouse", "FGStorage", null);
MenuInit.addMenu(menuLabel,finishedGoodsWarehouse,1, "上架","putAway", "neolight/putAway/index","putAway");
MenuInit.addMenu(menuLabel,finishedGoodsWarehouse,2, "下架","putOut", "neolight/putOut/index","putOut");
......
package com.neotel.smfcore.custom.aiqingzhiyin1643.electronicWarehouse.rest;
import com.neotel.smfcore.common.bean.ResultBean;
import com.neotel.smfcore.common.exception.ValidateException;
import com.neotel.smfcore.common.utils.SecurityUtils;
import com.neotel.smfcore.common.utils.StringUtils;
import com.neotel.smfcore.core.barcode.bean.CodeBean;
import com.neotel.smfcore.core.barcode.enums.COMPONENT_TYPE;
import com.neotel.smfcore.core.barcode.rest.bean.dto.BarcodeDto;
import com.neotel.smfcore.core.barcode.rest.bean.mapstruct.BarcodeMapper;
import com.neotel.smfcore.core.barcode.service.manager.IBarcodeManager;
import com.neotel.smfcore.core.barcode.service.manager.IComponentManager;
import com.neotel.smfcore.core.barcode.service.po.Barcode;
import com.neotel.smfcore.core.barcode.service.po.Component;
import com.neotel.smfcore.core.barcode.utils.CodeResolve;
import com.neotel.smfcore.core.device.enums.OP;
import com.neotel.smfcore.core.device.enums.OP_STATUS;
import com.neotel.smfcore.core.device.util.DataCache;
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.StoragePos;
import com.neotel.smfcore.core.system.service.po.DataLog;
import com.neotel.smfcore.core.system.util.TaskService;
import com.neotel.smfcore.security.annotation.AnonymousAccess;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@Slf4j
@RequestMapping("/scanInBox")
@RestController
public class ScanInBoxController {
@Autowired
private IBarcodeManager barcodeManager;
@Autowired
private CodeResolve codeResolve;
@Autowired
private IComponentManager componentManager;
@Autowired
private TaskService taskService;
@Autowired
private BarcodeMapper barcodeMapper;
@Autowired
private IStoragePosManager storagePosManager;
@Autowired
private DataCache dataCache;
@ApiOperation("查询料箱信息")
@RequestMapping("/boxInfo")
@AnonymousAccess
public BarcodeDto boxInfo(@RequestBody String code){
CodeBean codeBean = new CodeBean();
try {
codeBean = codeResolve.resolveSingleCode(code.trim(), COMPONENT_TYPE.FIXTURE);
} catch (ValidateException e) {
codeBean.setError(e.getMessage());
}
if (codeBean == null || codeBean.getBarcode() == null) {
throw new ValidateException("smfcore.error.barcode.invalid", "未找到有效的条码");
}
if (codeBean.getErrorCode() != null) {
throw new ValidateException(codeBean.getErrorCode(), codeBean.getError(), codeBean.getParams());
}
List<BarcodeDto> codeDtos = new ArrayList<BarcodeDto>();
Barcode barcode = codeBean.getBarcode();
//此处需要判断是否是料盒
Component component=componentManager.findOneByPN(barcode.getPartNumber() );
if(component==null||(component.getType()!=COMPONENT_TYPE.FIXTURE)){
throw new ValidateException("smfcore.materialBox.invalid", "未找到料盒信息{0}", new String[]{code});
}
//判断是否有任务,有任务直接完成,不清空库存信息
DataLog dataLog = null;
List<DataLog> allTasks = taskService.getAllTasks();
for (DataLog task : allTasks) {
if (task.isCheckOutTask() && !task.isFinished() && !task.isCancel()) {
if (barcode.getBarcode().equals(task.getBarcode())){
dataLog = task;
break;
}
}
}
if (dataLog != null){
throw new ValidateException("smfcore.error.task.notFinished", "料箱[{0}]还有未完成的任务", new String[]{barcode.getBarcode()});
}
BarcodeDto barcodeDto=barcodeMapper.toDto(barcode);
if(barcodeDto.getSubCodeList()==null){
barcodeDto.setSubCodeList(new ArrayList<>());
}
return barcodeDto;
}
@ApiOperation("(唯一码)物料放入料盒中")
@PostMapping(value = "/reelToBox")
@AnonymousAccess
public ResultBean reelToBox(@RequestBody Map<String, String> paramMap) {
String code = paramMap.get("barcode");//料盒条码
String operageStr = paramMap.get("operatePN");//操作信息
log.info("收到物料放入料箱,boxStr:" + code + ",operageStr:" + operageStr);
//判断料箱是否存在
Barcode barcode = barcodeManager.findByBarcode(code);
if (barcode == null) {
throw new ValidateException("smfcore.error.barcode.invalid", "{0}不是有效的条码", new String[]{code});
}
//判断是否在库位中
StoragePos pos = storagePosManager.getByBarcode(barcode.getBarcode());
if (pos != null) {
throw new ValidateException("smfcore.materialBox.inPos", "料箱[{0}]已在库位[{1}]中", new String[]{barcode.getBarcode(), pos.getPosName()});
}
//解析失败,直接报错
String newCodeStr = "=1x1=" + operageStr;
CodeBean codeBean = codeResolve.resolveSingleCode(newCodeStr);
if (!codeBean.isValid()) {
return ResultBean.newErrorResult(-1, "smfcore.error.barcode.invalid", "未找到有效的条码");
}
Barcode subCode = codeBean.getBarcode();
//判断是否存在其他料盒中
String hostBarcodeId = subCode.getHostBarcodeId();
if (StringUtils.isNotEmpty(hostBarcodeId)) {
if (!hostBarcodeId.equals(barcode.getId())) {
Barcode hostBarcode = barcodeManager.get(hostBarcodeId);
if (hostBarcode != null) {
throw new ValidateException("smfcore.materialBox.inOtherBox", "物料已在料盒{0}中", new String[]{hostBarcode.getBarcode()});
}
}
}
//判断库位是否为空
String posName = subCode.getPosName();
if (StringUtils.isNotEmpty(posName)) {
throw new ValidateException("smfcore.materialBox.inPos", "物料已在库位{0}中", new String[]{posName});
}
subCode.setHostBarcodeId(barcode.getId());
subCode.setPosName(barcode.getBarcode());
subCode.setPutInTime(System.currentTimeMillis());
barcodeManager.saveBarcode(subCode);
barcode = finishTask(barcode, OP.PUT_IN, subCode, subCode.getAmount(), OP_STATUS.FINISHED.name(), subCode.getAmount());
log.info("条码" + subCode.getBarcode() + "[" + subCode.getPartNumber() + "]入库到料盒[" + barcode.getBarcode() + "]数量:" + barcode.getAmount());
return ResultBean.newOkResult(barcodeMapper.toDto(barcode));
}
private Barcode finishTask(Barcode pidBarcode, int opType, Barcode subBarcode, int opQty, String status, int amount) 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缓存
pidBarcode.UpdateSubCode(subBarcode);
barcodeManager.save(subBarcode);
barcodeManager.saveBarcode(pidBarcode);
DataLog task = new DataLog();
task.setStatus(status);
task.setPartNumber(subBarcode.getPartNumber());
task.setBarcode(subBarcode.getBarcode());
task.setNum(opQty);
task.setType(opType);
task.setCid(pidBarcode.getPartNumber());
task.setStorageName(pidBarcode.getBarcode());
task.setPosName(pidBarcode.getBarcode());
task.setOperator(SecurityUtils.getLoginUsername());
if (StringUtils.isNotEmpty(orderItemId)) {
task.setSubSourceId(orderItemId);
}
if (StringUtils.isNotEmpty(orderNo)) {
task.setSourceName(orderNo);
}
if (StringUtils.isNotEmpty(orderId)) {
task.setSourceId(orderId);
}
taskService.updateFinishedTask(task);
return pidBarcode;
}
}
package com.neotel.smfcore.custom.aiqingzhiyin1643.electronicWarehouse.rest;
import com.neotel.smfcore.common.bean.ResultBean;
import com.neotel.smfcore.common.exception.ValidateException;
import com.neotel.smfcore.common.utils.SecurityUtils;
import com.neotel.smfcore.common.utils.StringUtils;
import com.neotel.smfcore.core.barcode.bean.CodeBean;
import com.neotel.smfcore.core.barcode.enums.COMPONENT_TYPE;
import com.neotel.smfcore.core.barcode.rest.bean.dto.BarcodeDto;
import com.neotel.smfcore.core.barcode.rest.bean.mapstruct.BarcodeMapper;
import com.neotel.smfcore.core.barcode.service.manager.IBarcodeManager;
import com.neotel.smfcore.core.barcode.service.manager.IComponentManager;
import com.neotel.smfcore.core.barcode.service.po.Barcode;
import com.neotel.smfcore.core.barcode.service.po.Component;
import com.neotel.smfcore.core.barcode.utils.CodeResolve;
import com.neotel.smfcore.core.device.enums.OP;
import com.neotel.smfcore.core.device.enums.OP_STATUS;
import com.neotel.smfcore.core.device.util.DataCache;
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.StoragePos;
import com.neotel.smfcore.core.system.service.po.DataLog;
import com.neotel.smfcore.core.system.util.TaskService;
import com.neotel.smfcore.security.annotation.AnonymousAccess;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@Slf4j
@RequestMapping("/scanOutBox")
@RestController
public class ScanOutBoxController {
@Autowired
private IBarcodeManager barcodeManager;
@Autowired
private CodeResolve codeResolve;
@Autowired
private IComponentManager componentManager;
@Autowired
private TaskService taskService;
@Autowired
private BarcodeMapper barcodeMapper;
@Autowired
private IStoragePosManager storagePosManager;
@Autowired
private DataCache dataCache;
@ApiOperation("查询料箱信息")
@RequestMapping("/boxInfo")
@AnonymousAccess
public BarcodeDto boxInfo(@RequestBody String code) {
CodeBean codeBean = new CodeBean();
try {
codeBean = codeResolve.resolveSingleCode(code.trim(), COMPONENT_TYPE.FIXTURE);
} catch (ValidateException e) {
codeBean.setError(e.getMessage());
}
if (codeBean == null || codeBean.getBarcode() == null) {
throw new ValidateException("smfcore.error.barcode.invalid", "未找到有效的条码");
}
if (codeBean.getErrorCode() != null) {
throw new ValidateException(codeBean.getErrorCode(), codeBean.getError(), codeBean.getParams());
}
List<BarcodeDto> codeDtos = new ArrayList<BarcodeDto>();
Barcode barcode = codeBean.getBarcode();
//此处需要判断是否是料盒
Component component = componentManager.findOneByPN(barcode.getPartNumber());
if (component == null || (component.getType() != COMPONENT_TYPE.FIXTURE)) {
throw new ValidateException("smfcore.materialBox.invalid", "未找到料盒信息{0}", new String[]{code});
}
//判断是否有任务,有任务直接完成,不清空库存信息
DataLog dataLog = null;
List<DataLog> allTasks = taskService.getAllTasks();
for (DataLog task : allTasks) {
if (task.isCheckOutTask() && !task.isFinished() && !task.isCancel()) {
if (barcode.getBarcode().equals(task.getBarcode())) {
dataLog = task;
break;
}
}
}
if (dataLog != null) {
throw new ValidateException("smfcore.error.task.notFinished", "料箱[{0}]还有未完成的任务", new String[]{barcode.getBarcode()});
}
BarcodeDto barcodeDto = barcodeMapper.toDto(barcode);
if (barcodeDto.getSubCodeList() == null) {
barcodeDto.setSubCodeList(new ArrayList<>());
}
return barcodeDto;
}
@ApiOperation("物料从料盒中取出(唯一码出库)")
@PostMapping(value = "/reelFromBox")
//@AnonymousAccess
public ResultBean reelFromBox(@RequestBody Map<String, String> paramMap) {
String code = paramMap.get("barcode");//料盒条码
String operageStr = paramMap.get("operatePN");//操作信息
//判断料箱是不是有效的参数
Barcode barcode = barcodeManager.findByBarcode(code);
if (barcode == null) {
throw new ValidateException("smfcore.error.barcode.invalid", "{0}不是有效的条码", new String[]{code});
}
//判断是否在库位中
StoragePos pos = storagePosManager.getByBarcode(barcode.getBarcode());
if (pos != null) {
throw new ValidateException("smfcore.materialBox.inPos", "料箱[{0}]已在库位[{1}]中", new String[]{barcode.getBarcode(), pos.getPosName()});
}
//判断输入的条码是否正确
CodeBean codeBean = codeResolve.resolveSingleCode("=1x1=" + operageStr);
if (!codeBean.isValid()) {
throw new ValidateException("smfcore.error.barcode.invalid", "{0}不是有效的条码", new String[]{operageStr});
}
Barcode subBarcode = codeBean.getBarcode();
int opQty = subBarcode.getAmount();
//判断是否在此料箱中
String hostBarcodeId = subBarcode.getHostBarcodeId();
if (StringUtils.isEmpty(hostBarcodeId)) {
throw new ValidateException("smfcore.materialBox.noReel", "料盒中未找到对应物料");
}
if (!hostBarcodeId.equals(barcode.getId())) {
Barcode hostBarcode = barcodeManager.get(hostBarcodeId);
if (hostBarcode != null) {
throw new ValidateException("smfcore.materialBox.inOtherBox", "物料已在料盒{0}中", new String[]{hostBarcode.getBarcode()});
}
}
int amount = subBarcode.getAmount();
int qty = amount - opQty;
if (qty < 0) {
qty = 0;
}
Integer awaitingNum = subBarcode.getAppendData("awaiting");
if (awaitingNum != null) {
if (opQty < awaitingNum) {
throw new ValidateException("smfcore.virtual.quantityError", "取出数量应为[{0}]", new String[]{awaitingNum + ""});
}
}
//出库
subBarcode.setAmount(qty);
subBarcode = barcodeManager.save(subBarcode);
barcode = finishTask(barcode, OP.CHECKOUT, subBarcode, opQty, OP_STATUS.FINISHED.name(), amount);
log.info("条码" + subBarcode.getBarcode() + "[" + subBarcode.getPartNumber() + "]从料盒[" + barcode.getBarcode() + "]出库,数量:" + qty);
return ResultBean.newOkResult("");
}
private Barcode finishTask(Barcode pidBarcode, int opType, Barcode subBarcode, int opQty, String status, int amount) 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缓存
pidBarcode.UpdateSubCode(subBarcode);
subBarcode.setHostBarcodeId("");
subBarcode.setPosName("");
subBarcode.setAmount(amount);
barcodeManager.save(subBarcode);
barcodeManager.saveBarcode(pidBarcode);
DataLog task = new DataLog();
task.setStatus(status);
task.setPartNumber(subBarcode.getPartNumber());
task.setBarcode(subBarcode.getBarcode());
task.setNum(opQty);
task.setType(opType);
task.setCid(pidBarcode.getPartNumber());
task.setStorageName(pidBarcode.getBarcode());
task.setPosName(pidBarcode.getBarcode());
task.setOperator(SecurityUtils.getLoginUsername());
if (StringUtils.isNotEmpty(orderItemId)) {
task.setSubSourceId(orderItemId);
}
if (StringUtils.isNotEmpty(orderNo)) {
task.setSourceName(orderNo);
}
if (StringUtils.isNotEmpty(orderId)) {
task.setSourceId(orderId);
}
taskService.updateFinishedTask(task);
return pidBarcode;
}
}
......@@ -81,6 +81,9 @@ public class MaterialLossManagerImpl implements IMaterialLossManager {
public void savaOrUpdate(DataLog task) {
String cid = task.getCid();
Storage storage = dataCache.getStorage(cid);
if (storage == null){
return;
}
if (storage.getCorrespondingWarehouse() != CORRESPONDING_WAREHOUSE.ELECTRONIC_WAREHOUSE){
return;
}
......
......@@ -66,7 +66,7 @@ app:
type: ""
menu:
show: lossReport
show: lossReport,scanInBox,scanOutBox
hide:
smd:
......
......@@ -28,7 +28,7 @@ public class ApplicationTests {
private void saveLanguageFile(String type){
try {
String url = "http://192.168.1.242/smf-core/api/translation/getLanguageMsgList";
String url = "http://192.168.1.237/smf-core/api/translation/getLanguageMsgList";
Map<String,Object> params = new HashMap<>();
params.put("type",type);
System.out.println("开始获取最新["+type+"]翻译资源...");
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!