From 12714c71c7737e21c3268b44a39f8f02befc5cb5 Mon Sep 17 00:00:00 2001 From: gdg <764716047@qq.com> Date: 星期一, 18 一月 2021 09:55:45 +0800 Subject: [PATCH] 模块:仓库库存管理 修改:订单入库流程 提出:秦老师 --- src/main/java/com/nanometer/smartlab/controller/WarehouseStockMngController.java | 290 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 289 insertions(+), 1 deletions(-) diff --git a/src/main/java/com/nanometer/smartlab/controller/WarehouseStockMngController.java b/src/main/java/com/nanometer/smartlab/controller/WarehouseStockMngController.java index 04cd748..314fe5a 100644 --- a/src/main/java/com/nanometer/smartlab/controller/WarehouseStockMngController.java +++ b/src/main/java/com/nanometer/smartlab/controller/WarehouseStockMngController.java @@ -5,10 +5,12 @@ import com.nanometer.smartlab.dao.OpeWarehouseReserveDao; import com.nanometer.smartlab.entity.*; import com.nanometer.smartlab.entity.dto.ApplyListDto; +import com.nanometer.smartlab.entity.enumtype.ApplyStatus; import com.nanometer.smartlab.entity.enumtype.ArrivalStatus; import com.nanometer.smartlab.entity.enumtype.SeeFlag; import com.nanometer.smartlab.entity.enumtype.ValidFlag; import com.nanometer.smartlab.exception.BusinessException; +import com.nanometer.smartlab.exception.ExceptionEnumCode; import com.nanometer.smartlab.service.*; import com.nanometer.smartlab.util.*; import org.apache.commons.lang.StringUtils; @@ -26,6 +28,7 @@ import org.springframework.context.annotation.PropertySource; import org.springframework.context.annotation.Scope; import org.springframework.stereotype.Controller; +import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; import javax.faces.context.ExternalContext; @@ -37,6 +40,7 @@ import java.math.BigDecimal; import java.math.BigInteger; import java.net.URLEncoder; +import java.sql.Timestamp; import java.util.*; import java.util.concurrent.atomic.AtomicBoolean; import java.util.stream.Collectors; @@ -66,6 +70,8 @@ private SysUserService sysUserService; @Resource private SysSupplierService sysSupplierService; + @Resource + private OpeOrderService opeOrderService; @Resource private MenuController menuController; @@ -83,6 +89,8 @@ @Resource(name = "opeReagentStatusDao") OpeReagentStatusDao opeReagentStatusDao; + @Resource + OpeUseFlowService opeUseFlowService; @Resource OpeWarehouseReserveDao opeWarehouseReserveDao; @@ -233,7 +241,20 @@ private List<OpeApplyReserve> selectedListForPerson; private List<OpeApplyReserve> selectedTmpOrderList; private List<OpeApplyReserve> trulySelectedOrderList; - + /** + * 入库车 + */ + private List<OpeApplyReserve> selectedInputStorageTmpOrderList; + private List<OpeApplyReserve> trulyInputStorageTmpSelectedOrderList; + /** + * 订单入库变量 + */ + //到货时间 + private Timestamp arrivalTime; + //收货人 + private String consigneeId; + //OpeApply + private List<OpeApplyReserve> opeApplyList; /** * 条形码对话框中选择的条形码集合 */ @@ -296,6 +317,33 @@ } this.onWarehouseSelectChange(null); + } + + public void initInputWarehouse() { + logger.info("WarehouseStockMngController initInputWarehouse start"); + this.warehouseList = this.sysWarehouseService.getSysWarehouseList(null, null, null, null); + this.warehouseNameMap = new HashMap<String, String>(); + if (this.warehouseList != null && this.warehouseList.size() > 0) { + for (SysWarehouse house : this.warehouseList) { + this.warehouseNameMap.put(house.getId(), house.getName()); + } + } + this.warehouseContainerMap = new HashMap<String, SysWarehouseContainer>(); + this.warehouseIdContainerMap = new HashMap<String, List<SysWarehouseContainer>>(); + List<SysWarehouseContainer> warehouseContainerList = this.sysWarehouseContainerService.getSysWarehouseContainerList(null, null, null, null, null); + if (warehouseContainerList != null && warehouseContainerList.size() > 0) { + for (SysWarehouseContainer container : warehouseContainerList) { + warehouseContainerMap.put(container.getId(), container); + + if (!warehouseIdContainerMap.containsKey(container.getWarehouseId()) + || warehouseIdContainerMap.get(container.getWarehouseId()) == null) { + warehouseIdContainerMap.put(container.getWarehouseId(), new ArrayList<SysWarehouseContainer>()); + } + warehouseIdContainerMap.get(container.getWarehouseId()).add(container); + } + } + + this.onWarehouseSelectChange(null); } private void initReagentSelectList() { @@ -418,6 +466,40 @@ } } + public void addInputStorageOrder() { + if (this.selectedListForPerson == null || this.selectedListForPerson.size() == 0) { + FacesUtils.warn("请选择数据。"); + return; + } + //1.判断非状态为确认的申购单不能入库 + for (OpeApplyReserve opeApplyReserve : this.selectedListForPerson) { + if (opeApplyReserve.getStatus() != ApplyStatus.SUPPLIER_CONFIRM) { + FacesUtils.warn("非已确认的数据不能入库。"); + return; + } + } + //2.加入暂存 + if (selectedInputStorageTmpOrderList !=null && selectedInputStorageTmpOrderList.size()>0){ + ArrayList<OpeApplyReserve> tmp = new ArrayList<>(); + selectedListForPerson.forEach(opeApplyReserve -> { + AtomicBoolean flag = new AtomicBoolean(false); + selectedInputStorageTmpOrderList.forEach(opeApplyReserve1 -> { + if (opeApplyReserve.getId().equals(opeApplyReserve1.getId())){ + flag.set(true); + } + + }); + if(!flag.get()) { + tmp.add(opeApplyReserve); + } + }); + selectedInputStorageTmpOrderList.addAll(tmp); + }else{ + selectedInputStorageTmpOrderList = new ArrayList<>(); + selectedInputStorageTmpOrderList.addAll(selectedListForPerson); + } + } + public void clear(){ selectedTmpList = null; @@ -425,6 +507,10 @@ public void clearOrderTmp(){ selectedTmpOrderList = null; + } + + public void clearInputStorageTmp(){ + selectedInputStorageTmpOrderList = null; } public void cancel(){ @@ -483,6 +569,34 @@ } + public void cancelInputStorageTmp(){ + if (trulyInputStorageTmpSelectedOrderList == null || trulyInputStorageTmpSelectedOrderList.size()<=0){ + FacesUtils.info("至少选择一个"); + return; + } + + if (selectedInputStorageTmpOrderList == null || selectedInputStorageTmpOrderList.size()<=0){ + FacesUtils.info("至少选择一个"); + return; + } + + ArrayList<Object> indexs = new ArrayList<>(); + for (OpeApplyReserve opeApplyReserve : trulyInputStorageTmpSelectedOrderList) { + for (OpeApplyReserve applyReserve : selectedInputStorageTmpOrderList) { + if (opeApplyReserve.getId().equals(applyReserve.getId())) { + indexs.add(opeApplyReserve); + } + } + } + + if (indexs.size()>0){ + indexs.forEach(obj -> { + selectedInputStorageTmpOrderList.remove(obj); + }); + } + + } + public void onUseBtnClick(){ if (selectedTmpList == null || selectedTmpList.size()<=0){ FacesUtils.info("至少选择一个"); @@ -499,6 +613,21 @@ } this.menuController.goToPage(Constants.PAGE_WAREHOUSE_REAGENT_USE_NEW_PERSON, Constants.PAGE_WAREHOUSE_STOCK_MNG); + } + + public void onUseBtnClickInputStorageTmp(){ + if (selectedInputStorageTmpOrderList == null || selectedInputStorageTmpOrderList.size()<=0){ + FacesUtils.info("至少选择一个"); + return; + } + opeApplyList = new ArrayList<>(); + selectedInputStorageTmpOrderList.forEach(opeApplyReserve -> { + OpeApplyReserve applyDetail = opeApplyService.getOpeApplyDetail(opeApplyReserve.getId()); + opeApplyList.add(applyDetail); + + }); + //跳转编辑页面 + this.menuController.goToPage(Constants.PAGE_ORDER_INPUT_WAREHOUSE, Constants.PAGE_WAREHOUSE_STOCK_MNG); } public void onUseBtnClickForPerson() { @@ -823,6 +952,7 @@ public void onCancelBtnClick() { this.selectedTmpOrderList = null; this.selectedTmpList = null; + this.selectedInputStorageTmpOrderList = null; this.menuController.backToPage(); } @@ -1192,6 +1322,52 @@ logger.error(e.getMessage(), e); FacesUtils.warn("操作失败。"); } + } + /** + * @Description: 订单入库保存 + */ + public void onSaveInputWarehouseClick(){ + try{ + //用来检验提交表单得试剂条码是否重复 + Map<String,Boolean> checkTable= new HashMap<>(); + if (opeApplyList != null && opeApplyList.size() > 0) { + for (OpeApplyReserve opeApplyReserve:opeApplyList) { + //0.1获取该申购单的订单 + OpeOrder oo = opeOrderService.getOrder(opeApplyReserve.getId()); + if (oo == null) { + throw new BusinessException(ExceptionEnumCode.ORDER_ERROR,"订单不存在"); + } + //0.2检查条码->得到试剂条码列表 + List<String> codeList = opeReagentStatusService + .checkReagentCode(opeApplyReserve.getStartReagentCode2(), opeApplyReserve.getEndReagentCode2(), opeApplyReserve.getArrivalNum()); + if (codeList != null && codeList.size() > 0) { + for (String code:codeList) { + if (checkTable.get(code) == null) { + checkTable.put(code, true); + }else{ + throw new BusinessException(ExceptionEnumCode.PARAM_EXIST, "当前订单条码重复,"+code); + } + } + } + } + + + checkTable = null; + opeApplyService.orderInputWarehouse(opeApplyList,consigneeId,arrivalTime); + } + + FacesUtils.info("入库完成"); + //返回 + this.onCancelBtnClick(); + }catch (BusinessException e){ + e.printStackTrace(); + FacesUtils.warn(e.getMessage()); + + } catch (Exception e) { + e.printStackTrace(); + FacesUtils.warn("系统异常,操作失败"); + } + } @SuppressWarnings("serial") @@ -2231,4 +2407,116 @@ public void setTabValue(Integer tabValue) { this.tabValue = tabValue; } + + + public List<OpeApplyReserve> getSelectedInputStorageTmpOrderList() { + return selectedInputStorageTmpOrderList; + } + + public void setSelectedInputStorageTmpOrderList(List<OpeApplyReserve> selectedInputStorageTmpOrderList) { + this.selectedInputStorageTmpOrderList = selectedInputStorageTmpOrderList; + } + + public List<OpeApplyReserve> getTrulyInputStorageTmpSelectedOrderList() { + return trulyInputStorageTmpSelectedOrderList; + } + + public void setTrulyInputStorageTmpSelectedOrderList(List<OpeApplyReserve> trulyInputStorageTmpSelectedOrderList) { + this.trulyInputStorageTmpSelectedOrderList = trulyInputStorageTmpSelectedOrderList; + } + + public Timestamp getArrivalTime() { + return arrivalTime; + } + + public void setArrivalTime(Timestamp arrivalTime) { + this.arrivalTime = arrivalTime; + } + + public String getConsigneeId() { + return consigneeId; + } + + public void setConsigneeId(String consigneeId) { + this.consigneeId = consigneeId; + } + + public List getConsignee() { + List<SysUser> dataList = this.sysUserService.getSysUserList(null, null, null, null, null); + //将admin置于首位 + for (int i = 0; i < dataList.size(); i++) { + if ("admin".equals(dataList.get(i).getAccount())){ + dataList.add(0, dataList.remove(i)); + } + } + return dataList; + } + + public List<OpeApplyReserve> getOpeApplyList() { + return opeApplyList; + } + + public void setOpeApplyList(List<OpeApplyReserve> opeApplyList) { + this.opeApplyList = opeApplyList; + } + + + public void setArrival(OpeApplyReserve oar) { + //强制-》全到货 + oar.setArrivalNum(oar.getNum()); + } + + public void reagentStartCodeChange(OpeApplyReserve oar) { + //先输入条形码,到货数量帮填 + oar.setArrivalNum(oar.getNum()); + String startReagentCode2 = oar.getStartReagentCode2(); + String endReagentCode2 = oar.getEndReagentCode2(); + //1.如果开始条码为空,条码就为空,或者没有到货 + if (StringUtils.isBlank(startReagentCode2) + || oar.getArrivalNum() == null || oar.getArrivalNum() < 1) { + + oar.setStartReagentCode2(""); + oar.setEndReagentCode2(""); + return; + } + //2如果开始条码不为空 + //2.0如果包含字母不等于24位的直接不管 + if (startReagentCode2.matches(".*[A-F]+.*")) { + if (startReagentCode2.length() ==24){ + //2.2长度为24位编码的 + BigInteger arrNum = BigInteger.valueOf(oar.getArrivalNum().longValue()); + //后5位随机码 + String randomCode = startReagentCode2.substring(startReagentCode2.length() - 5); + String reagentCodePrefix = startReagentCode2.substring(0,startReagentCode2.length() - 5); + + BigInteger startReagentCodeSuffix = new BigInteger(randomCode); + BigInteger endReagentCodeSuffix = startReagentCodeSuffix.add(arrNum).subtract((new BigInteger("1"))); + String reagentCodeSuffix= autoGenericCode(randomCode, endReagentCodeSuffix); + oar.setEndReagentCode2(reagentCodePrefix + reagentCodeSuffix); + }else{ + oar.setEndReagentCode2(""); + } + }else{ + + BigInteger startReagentCode = new BigInteger(startReagentCode2); + //2.1长度不为24位编码 + //数据1 + BigInteger arrNum = BigInteger.valueOf(oar.getArrivalNum().longValue()); + BigInteger code1 = startReagentCode.add(arrNum).subtract(BigInteger.ONE); + oar.setEndReagentCode2(autoGenericCode(startReagentCode2, code1)); + } + } + + + + + private String autoGenericCode(String code, BigInteger code1) { + String result = ""; + //补充位数 + result = String.format("%0" + code.length() + "d", code1); + + return result; + } + + } -- Gitblit v1.9.2