diff --git a/win-framework/win-spring-boot-starter-excel/src/main/java/com/win/framework/excel/core/util/ExcelUtils.java b/win-framework/win-spring-boot-starter-excel/src/main/java/com/win/framework/excel/core/util/ExcelUtils.java index 0636d3d2..8d8dc737 100644 --- a/win-framework/win-spring-boot-starter-excel/src/main/java/com/win/framework/excel/core/util/ExcelUtils.java +++ b/win-framework/win-spring-boot-starter-excel/src/main/java/com/win/framework/excel/core/util/ExcelUtils.java @@ -102,7 +102,6 @@ public class ExcelUtils { */ public static String writeLocalFile(String fileName, String sheetName, List dataList) throws FileNotFoundException { WebProperties webProperties = SpringUtil.getBean(WebProperties.class); - fileName = fileName + LocalDateTime.now().toEpochSecond(ZoneOffset.of("+8")) + ".xlsx"; File file = ResourceUtils.getFile( webProperties.getProfile() + "/" + fileName); EasyExcel.write(file).sheet(sheetName).doWrite(dataList); return Constant.RESOURCE_PREFIX + fileName; diff --git a/win-framework/win-spring-boot-starter-web/src/main/java/com/win/framework/web/constant/Constant.java b/win-framework/win-spring-boot-starter-web/src/main/java/com/win/framework/web/constant/Constant.java index 6df8ab34..7d2d0390 100644 --- a/win-framework/win-spring-boot-starter-web/src/main/java/com/win/framework/web/constant/Constant.java +++ b/win-framework/win-spring-boot-starter-web/src/main/java/com/win/framework/web/constant/Constant.java @@ -5,6 +5,6 @@ public class Constant { /** * 资源映射路径 前缀 */ - public static final String RESOURCE_PREFIX = "/profile"; + public static final String RESOURCE_PREFIX = "/profile/"; } diff --git a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/dal/dataobject/barcode/BarcodeDO.java b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/dal/dataobject/barcode/BarcodeDO.java index 553ad2e6..cb8ed046 100644 --- a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/dal/dataobject/barcode/BarcodeDO.java +++ b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/dal/dataobject/barcode/BarcodeDO.java @@ -1,5 +1,6 @@ package com.win.module.wms.dal.dataobject.barcode; +import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import com.win.framework.mybatis.core.dataobject.BaseDO; @@ -39,6 +40,7 @@ public class BarcodeDO extends BaseDO { /** * 顺序 */ + @TableField(value = "`order`") private Integer order; /** * 长度 diff --git a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/service/itembasic/ItembasicServiceImpl.java b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/service/itembasic/ItembasicServiceImpl.java index c4cd0dd8..806ba24c 100644 --- a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/service/itembasic/ItembasicServiceImpl.java +++ b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/service/itembasic/ItembasicServiceImpl.java @@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.google.common.annotations.VisibleForTesting; + import com.win.framework.common.exception.ServiceException; import com.win.framework.common.pojo.CustomConditions; import com.win.framework.common.pojo.PageResult; @@ -118,27 +119,95 @@ public class ItembasicServiceImpl implements ItembasicService { } List errorList = new ArrayList<>(); importItembasics.forEach(importItembasic -> { + String massage = ""; // 校验,判断是否有不符合的原因 - try { - if(mode != null){ - validateItembasicForCreateOrUpdate(null,importItembasic.getCode(),importItembasic.getStatus(),importItembasic.getUom(),importItembasic.getIsStdPack() - ,importItembasic.getEnableBuy(),importItembasic.getEnableMake(),importItembasic.getEnableOutsourcing() - ,importItembasic.getIsRecycled(),importItembasic.getIsPhantom(),importItembasic.getAbcClass() - ,importItembasic.getType(),importItembasic.getValidityDays(),importItembasic.getAvailable()); + if(mode != null){ + try { + validateItembasicExists(null); + } catch (ServiceException ex) { + massage += ex.getMessage() + ","; + } + try { + validateCodeExists(null,importItembasic.getCode()); + } catch (ServiceException ex) { + massage += ex.getMessage() + ","; + } + try { + validateStatusExists(importItembasic.getStatus()); + } catch (ServiceException ex) { + massage += ex.getMessage() + ","; + } + try { + validateUomExists(importItembasic.getUom()); + } catch (ServiceException ex) { + massage += ex.getMessage() + ","; + } + try { + validateIsStdPackExists(importItembasic.getIsStdPack()); + } catch (ServiceException ex) { + massage += ex.getMessage() + ","; + } + try { + validateEnableBuyExists(importItembasic.getEnableMake()); + } catch (ServiceException ex) { + massage += ex.getMessage() + ","; + } + try { + validateEnableMakeExists(importItembasic.getEnableBuy()); + } catch (ServiceException ex) { + massage += ex.getMessage() + ","; + } + try { + validateEnableOutsouringExists(importItembasic.getEnableOutsourcing()); + } catch (ServiceException ex) { + massage += ex.getMessage() + ","; + } + try { + validateIsRecycledExists(importItembasic.getIsRecycled()); + } catch (ServiceException ex) { + massage += ex.getMessage() + ","; + } + try { + validateIsPhantomExists(importItembasic.getIsPhantom()); + } catch (ServiceException ex) { + massage += ex.getMessage() + ","; + } + try { + validateAbcClassExists(importItembasic.getAbcClass()); + } catch (ServiceException ex) { + massage += ex.getMessage() + ","; + } + try { + validateTypeExists(importItembasic.getType()); + } catch (ServiceException ex) { + massage += ex.getMessage() + ","; + } + try { + validateValidityDaysExists(importItembasic.getValidityDays()); + } catch (ServiceException ex) { + massage += ex.getMessage() + ","; + } + try { + validateAvailableExists(importItembasic.getAvailable()); + } catch (ServiceException ex) { + massage += ex.getMessage() + ","; } - } catch (ServiceException ex) { - errorList.add(importItembasic); - return; } - // 判断如果不存在,在进行插入 - ItembasicDO existItembasic = itembasicMapper.selectByCode(importItembasic.getCode()); - if (existItembasic == null&& mode != 3) { - itembasicMapper.insert(ItembasicConvert.INSTANCE.convert(importItembasic)); + if(StrUtil.isNotEmpty(massage)){ + massage.substring(0,massage.length()-1); + errorList.add(importItembasic); } - else if (existItembasic != null && mode != 2) {// 如果存在,判断是否允许更新 - ItembasicDO itembasicDO = ItembasicConvert.INSTANCE.convert(importItembasic); - itembasicDO.setId(existItembasic.getId()); - itembasicMapper.updateById(itembasicDO); + if(errorList == null){ + // 判断如果不存在,在进行插入 + ItembasicDO existItembasic = itembasicMapper.selectByCode(importItembasic.getCode()); + if (existItembasic == null&& mode != 3) { + itembasicMapper.insert(ItembasicConvert.INSTANCE.convert(importItembasic)); + } + else if (existItembasic != null && mode != 2) {// 如果存在,判断是否允许更新 + ItembasicDO itembasicDO = ItembasicConvert.INSTANCE.convert(importItembasic); + itembasicDO.setId(existItembasic.getId()); + itembasicMapper.updateById(itembasicDO); + } } }); //错误不为空并非部分更新,手工回滚 @@ -203,73 +272,73 @@ public class ItembasicServiceImpl implements ItembasicService { } @VisibleForTesting private void validateStatusExists(String status) { - if (status.isEmpty()) { + if (status == null || status.isEmpty()) { throw exception(ITEMBASIC_STATUS_NOT_EXISTS); } } @VisibleForTesting private void validateUomExists(String uom) { - if (uom.isEmpty()) { + if (uom == null || uom.isEmpty()) { throw exception(ITEMBASIC_UOM_NOT_EXISTS); } } @VisibleForTesting private void validateIsStdPackExists(String stdPack) { - if (stdPack == null) { + if (stdPack == null || stdPack == null) { throw exception(ITEMBASIC_IS_STDPACK_NOT_EXISTS); } } @VisibleForTesting private void validateEnableBuyExists(String enableBuy) { - if (enableBuy == null) { + if (enableBuy == null || enableBuy == null) { throw exception(ITEMBASIC_ENABLE_BUY_NOT_EXISTS); } } @VisibleForTesting private void validateEnableMakeExists(String enableMark) { - if (enableMark == null) { + if (enableMark == null || enableMark == null) { throw exception(ITEMBASIC_ENABLE_MAKE_NOT_EXISTS); } } @VisibleForTesting private void validateEnableOutsouringExists(String enblOutsouring) { - if (enblOutsouring == null) { + if (enblOutsouring == null || enblOutsouring.isEmpty()) { throw exception(ITEMBASIC_ENABLE_OUTSOURING_NOT_EXISTS); } } @VisibleForTesting private void validateIsRecycledExists(String isRecycled) { - if (isRecycled == null) { + if (isRecycled == null || isRecycled.isEmpty()) { throw exception(ITEMBASIC_IS_RECYCLED_NOT_EXISTS); } } @VisibleForTesting private void validateIsPhantomExists(String isPhantom) { - if (isPhantom == null) { + if (isPhantom == null|| isPhantom.isEmpty()) { throw exception(ITEMBASIC_IS_PHANTOM_NOT_EXISTS); } } @VisibleForTesting private void validateAbcClassExists(String abcClass) { - if (abcClass.isEmpty()) { + if (abcClass == null ||abcClass.isEmpty()) { throw exception(ITEMBASIC_ABC_CLASS_NOT_EXISTS); } } @VisibleForTesting private void validateTypeExists(String type) { - if (type.isEmpty()) { + if (type == null || type.isEmpty()) { throw exception(ITEMBASIC_TYPE_NOT_EXISTS); } } @VisibleForTesting private void validateValidityDaysExists(Integer validityDays) { - if (validityDays == null) { + if (validityDays == null) { throw exception(ITEMBASIC_VALIDITY_DAYS_NOT_EXISTS); } } @VisibleForTesting private void validateAvailableExists(String available) { - if (available == null) { + if (available == null || available.isEmpty()) { throw exception(ITEMBASIC_AVAIABLE_NOT_EXISTS); } } @@ -278,7 +347,7 @@ public class ItembasicServiceImpl implements ItembasicService { QueryWrapper queryWrapper = new QueryWrapper(); queryWrapper.eq("code",code); ItembasicDO itembasicDO = itembasicMapper.selectOne(queryWrapper); - if(itembasicDO != null && "ENABLE".equals(itembasicDO.getStatus())){ + if(itembasicDO != null || "ENABLE".equals(itembasicDO.getStatus())){ return itembasicDO; }else { throw exception(ITEMBASIC_NOT_EXISTS); diff --git a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/until/job/JobUtils.java b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/until/job/JobUtils.java index 3d01ccc9..fd03e3f6 100644 --- a/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/until/job/JobUtils.java +++ b/win-module-wms/win-module-wms-biz/src/main/java/com/win/module/wms/until/job/JobUtils.java @@ -103,22 +103,16 @@ public class JobUtils { /** * 数量与任务是否一致(可配置) + * author:yejiaxing * - * @return List + * @param recommendQty 任务参数 + * @param handleQty 记录参数 + * @param allowBiggerQty + * @param allowSmallerQty + * @return */ - public static boolean numAndJobIsSame(List param) { + public static boolean numAndJobIsSame(BigDecimal recommendQty, BigDecimal handleQty, String allowBiggerQty, BigDecimal allowSmallerQty) { boolean result = false; - // 任务参数 - Map jobMap = (Map) param.get(0).get("details"); - BigDecimal recommendQty = new BigDecimal(Integer.parseInt(jobMap.get("qty").toString())); - - // 记录参数 - Map recordMap = (Map) param.get(1).get("details"); - BigDecimal handleQty = new BigDecimal(Integer.parseInt(recordMap.get("qty").toString())); - - String allowBiggerQty = (String) jobMap.get("allowBiggerQty"); - String allowSmallerQty = (String) jobMap.get("allowBiggerQty"); - // 验证数据 if (handleQty.compareTo(recommendQty) == 1) { if ("TRUE".equals(allowBiggerQty)) { @@ -138,12 +132,48 @@ public class JobUtils { return result; } + /** + * @param jobDetailBatch // 任务参数 + * @param recordDetailBatch // 记录参数 + * @param allowModifyBatch + * @return + */ + public static boolean batchAndJobIsSame(BigDecimal jobDetailBatch, BigDecimal recordDetailBatch, String allowModifyBatch) { + boolean result = false; + // 验证数据 + if (jobDetailBatch.compareTo(recordDetailBatch) == 1) { + if ("TRUE".equals(allowModifyBatch)) { + result = true; + } else { + throw new UtilException("实际数量" + jobDetailBatch + " 不允许大于推荐数量" + recordDetailBatch); + } + } else if (jobDetailBatch.compareTo(recordDetailBatch) == -1) { + if ("TRUE".equals(allowModifyBatch)) { + result = true; + } else { + throw new UtilException("实际数量" + jobDetailBatch + " 不允许小于推荐数量" + recordDetailBatch); + } + } + + if (jobDetailBatch.compareTo(recordDetailBatch) == 0) { + result = true; + } else { + if ("TRUE".equals(allowModifyBatch)) { + result = true; + } else { + throw new UtilException("实际批次" + jobDetailBatch + " 与任务推荐批次" + recordDetailBatch + "不一致"); + } + } + return result; + } + /** * 校验物料有效,状态正确 - * @author chenfang + * * @param itemCode 物品代码 * @return 物品基本信息列表 * @author chenfang + * @author chenfang */ public ItembasicDO itemCodeExist(String itemCode) { ItembasicDO itembasicDO = itembasicService.selectItembasic(itemCode); @@ -156,10 +186,11 @@ public class JobUtils { /** * 校验供应商有效,状态正确 - * @author chenfang + * * @param supplierCode 代码 * @return 供应商列表 * @author chenfang + * @author chenfang */ public SupplierDO supplierExist(String supplierCode) { SupplierDO supplierDO = supplierService.selectSupplier(supplierCode); @@ -192,10 +223,11 @@ public class JobUtils { * 从库位号有效,状态正确,开关正确 * 到库位号有效,状态正确,开关正确 * 共用同一个方法 - * @author chenfang + * * @param locationCode 库位 * @return 库位信息 * @author chenfang + * @author chenfang */ public LocationDO selectLocationExist(String locationCode) { LocationDO locationDO = locationService.selectLocation(locationCode); @@ -220,10 +252,11 @@ public class JobUtils { /** * 零件库位关系有效 - * @author chenfang + * * @param pitemCode 物品代码 * @return 上架策略信息 * @author chenfang + * @author chenfang */ public RuleRespVO selectLocationAndModRelation(String pitemCode) { RuleRespVO grounding = ruleService.grounding(null, null, null, null, null, null, pitemCode, null, null, null, null, null, null); @@ -351,13 +384,14 @@ public class JobUtils { /** * TB-------TB1 * 查询库存返回管理精度 - * @author lianhongxi - * @param itemcode 零件号 - * @param packingnumber 包装号 - * @param batch 批次 - * @param locationcode 库位号 + * + * @param itemcode 零件号 + * @param packingnumber 包装号 + * @param batch 批次 + * @param locationcode 库位号 * @param inventoryStatus 入库库存状态 * @return + * @author lianhongxi */ public List selectlocation(String itemcode, String packingnumber, String batch, String locationcode, String inventoryStatus) { RuleRespVO managementtRule = ruleService.management(null, null, null, null, null, null, itemcode, null, null, @@ -381,13 +415,14 @@ public class JobUtils { /** * 跟据管理模式查询预计库存 * TB-----TB3-----TEO----TEO1 - * @author lianhongxi - * @param itemcode 零件号 - * @param packingnumber 包装号 - * @param batch 批次 - * @param locationcode 库位号 + * + * @param itemcode 零件号 + * @param packingnumber 包装号 + * @param batch 批次 + * @param locationcode 库位号 * @param inventoryStatus 入库库存状态 * @return + * @author lianhongxi */ public List selectLocatioNew(String itemcode, String packingnumber, String batch, String locationcode, String inventoryStatus) { RuleRespVO managementtRule = ruleService.management(null, null, null, null, null, null, itemcode, null, null, @@ -409,13 +444,14 @@ public class JobUtils { /** * 查询可用库存 * TB----TB3 - * @author lianhongxi - * @param itemcode 零件号 - * @param packingnumber 包装号 - * @param batch 批次 - * @param locationcode 库位好 + * + * @param itemcode 零件号 + * @param packingnumber 包装号 + * @param batch 批次 + * @param locationcode 库位好 * @param inventoryStatus 入库库存状态 * @return + * @author lianhongxi */ public BigDecimal CountLocaltion(String itemcode, String packingnumber, String batch, String locationcode, String inventoryStatus) { List balanceDO = selectlocation(itemcode, packingnumber, batch, locationcode, inventoryStatus); @@ -428,14 +464,15 @@ public class JobUtils { /** * 请求库存校验是否有库存余额 - * @author lianhongxi - * @param itemcode 零件号 - * @param packingnumber 包装号 - * @param batch 批次 - * @param locationcode 库位好 + * + * @param itemcode 零件号 + * @param packingnumber 包装号 + * @param batch 批次 + * @param locationcode 库位好 * @param inventoryStatus 入库库存状态 - * @param requstqty 请求数量 + * @param requstqty 请求数量 * @return + * @author lianhongxi */ public String LocaltionExist(String itemcode, String packingnumber, String batch, String locationcode, String inventoryStatus, BigDecimal requstqty) { BigDecimal enableqty = CountLocaltion(itemcode, packingnumber, batch, locationcode, inventoryStatus); @@ -500,19 +537,20 @@ public class JobUtils { /** * 根据管理模式查询预计出库存 * TEO----TEO1 - * @author lianhongxi - * @param pitemcode 零件号 - * @param ppackingnumber 包装号 - * @param pbatch 批次 + * + * @param pitemcode 零件号 + * @param ppackingnumber 包装号 + * @param pbatch 批次 * @param pinventorystatus 入库库存状态 - * @param plocationcode 库位号 + * @param plocationcode 库位号 * @return + * @author lianhongxi */ - public List selectExpectort(String pitemcode, String ppackingnumber, String pbatch, String pinventorystatus, String plocationcode){ + public List selectExpectort(String pitemcode, String ppackingnumber, String pbatch, String pinventorystatus, String plocationcode) { RuleRespVO management = ruleService.management(null, null, null, null, null, null, pitemcode, null, null, null, plocationcode, null, null); List expectoutDO = null; - if(management != null){ + if (management != null) { String[] splits = management.getConfiguration().split("\""); for (String split : splits) { if ("{\"ManagementPrecision\":\"BY_QUANTITY\"}".equals(management.getConfiguration())) { @@ -526,9 +564,80 @@ public class JobUtils { } return expectoutDO; } - }else { + } else { throw exception(RULE_NOT_EXISTS); } return expectoutDO; } + + /** + * 数量与任务是否一致(可配置) + * author:yejiaxing + * + * @param itemCode + * @param packingNumber + * @param batch + * @param locationCode + * @param inventoryStatus + * @return + */ + public List numAndJobIsSame(String itemCode, String packingNumber, String batch, String locationCode, String inventoryStatus) { + List balanceDOList = new ArrayList<>(); + try { + balanceDOList = selectlocation(itemCode, packingNumber, batch, locationCode, inventoryStatus); + } catch (Exception e) { + throw exception(new ErrorCode(1256, "接口调用异常,请重试")); + } + return balanceDOList; + } + + + /** + * 从库存有效,状态正确 + * author:yejiaxing + * + * @param itemCode + * @param packingNumber + * @param batch + * @param locationCode + * @param inventoryStatus + * @return + */ + public List fromInventoryEffective(String itemCode, String packingNumber, String batch, String locationCode, String inventoryStatus) { + List balanceDOList = new ArrayList<>(); + try { + balanceDOList = selectlocation(itemCode, packingNumber, batch, locationCode, inventoryStatus); + } catch (Exception e) { + throw exception(new ErrorCode(1256, "接口调用异常,请重试")); + } + return balanceDOList; + } + + /** + * 从库存有效,状态正确(使用客户寄售库) + * author:yejiaxing + * + * @param itemCode + * @param packingNumber + * @param batch + * @param locationCode + * @param inventoryStatus + * @return + */ + public Boolean fromInventoryEffectiveCustomer(String locationCode, String itemCode, String packingNumber, String batch, String inventoryStatus) { + Boolean returnRes = false; + List balanceDOList = new ArrayList<>(); + try { + String restlt = selectlocation(locationCode); + if ("TURE".equals(restlt)) { + fromInventoryEffective(itemCode, packingNumber, batch, locationCode, inventoryStatus); + } else if ("FALSE".equals(restlt)) { + return returnRes; + } + } catch (Exception e) { + throw exception(new ErrorCode(1256, "接口调用异常,请重试")); + } + return true; + } + }