Преглед изворни кода

Merge branch 'master' of http://git.dongkesoft.com:9001/iBOSS-2.0-Mini/iboss-server-mdm

于继渤 пре 1 година
родитељ
комит
e43a2cbd11

+ 5 - 0
src/main/java/com/dk/mdm/mapper/sale/OrderMapper.xml

@@ -333,6 +333,7 @@
     <!-- 通用条件列 -->
     <sql id="Condition">
         <where>
+
             <if test="orderNo != null and orderNo != ''">
                 AND t.order_no LIKE concat('%',my_ex.likequery(#{orderNo}),'%')
             </if>
@@ -471,6 +472,7 @@
             <if test="viewVoidedDocuments !=null and viewVoidedDocuments == false">
                 AND  t.flg_valid = true
             </if>
+
             <if test="searchText !=null">
                 AND (  t.order_no LIKE concat('%', my_ex.likequery(#{searchText}), '%')
                 OR   t.contact_phone LIKE concat('%', my_ex.likequery(#{searchText}), '%')
@@ -1080,6 +1082,9 @@
         WHERE T.RK = 1) as i
         on i.sku_id = toi.sku_id and i.non_std_code = toi.non_std_code and i.cp_id = toi.cp_id
         <include refid="Condition"/>
+        <if test="flgSource !=null and flgSource == true">
+            AND toi.item_qty - toi.outing_qty -toi.out_qty + toi.return_qty > 0
+        </if>
         order by t.op_create_time desc
         <if test="pageSize != null and currentPage != null and pageSize != 0 and currentPage != 0">
             limit #{end} offset #{start}

+ 7 - 0
src/main/java/com/dk/mdm/model/query/sale/OrderQuery.java

@@ -395,6 +395,13 @@ public class OrderQuery extends PageInfo<OrderQuery> implements Serializable {
     private String searchText;
     @ApiModelProperty(value = "查询作废")
     private Boolean viewVoidedDocuments;
+
+    /**
+     * 销售出库是否过滤明细的 外协 明细订单量-出库中-已出库+退货数量
+     */
+    @ApiModelProperty(value = "销售出库是否过滤明细的")
+    private Boolean flgSource;
+
     private static final long serialVersionUID = 1L;
 
 }

+ 48 - 48
src/main/java/com/dk/mdm/service/ivt/inventory/InventoryService.java

@@ -92,9 +92,9 @@ public class InventoryService extends BaseService<Inventory> {
     private GoodsSkuMapper goodsSkuMapper;
 
     /**
-     * @desc   : 重写主键
+     * @desc : 重写主键
      * @author : 宋扬
-     * @date   : 2024/5/9 13:10
+     * @date : 2024/5/9 13:10
      */
     @Override
     public String getPrimaryKey() {
@@ -155,20 +155,20 @@ public class InventoryService extends BaseService<Inventory> {
         //region  查询当前公司的系统参数  自动办理信息  并赋值
         Map<String, Object> map = new HashMap<>();
         map.put("cpId", inOutRecordVOList.get(0).getCpId());
-        map.put("code",Constant.SystemConstant.IVT_002.getValue());
+        map.put("code", Constant.SystemConstant.IVT_002.getValue());
         //负数标识1
         String flgHandleSetting = commonMapper.getSettingValue(map);
         //endregion
         //赋值
         for (InOutRecordVO inOutRecordVO : inOutRecordVOList) {
             //如果可以为负数标识为空或者false 那就赋值系统参数的
-            if(inOutRecordVO.getCanNegativeFlag() == null || !inOutRecordVO.getCanNegativeFlag()){
+            if (inOutRecordVO.getCanNegativeFlag() == null || !inOutRecordVO.getCanNegativeFlag()) {
                 //负数标识1 可以
                 if (Constant.FlgAutoHandleStringType.ONE.getValue().equals(flgHandleSetting)) {
                     inOutRecordVO.setCanNegativeFlag(true);
                 }
                 //不可以
-                else{
+                else {
                     inOutRecordVO.setCanNegativeFlag(false);
                 }
             }
@@ -224,16 +224,16 @@ public class InventoryService extends BaseService<Inventory> {
         }
         for (InOutRecordVO inventoryBatchVO : inOutRecordVOList) {
             // 外协供应商ID 不进行判断商品Id和库存ID
-            if(inventoryBatchVO.getSupId() == null) {
+            if (inventoryBatchVO.getSupId() == null) {
                 //商品ID
                 if (inventoryBatchVO.getSkuId() == null || "".equals(inventoryBatchVO.getSkuId())) {
                     throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.SKU_IS_NULL.getMessage());
                 }
-                //存货ID
-                if (Constant.InventoryType.OUTBOUND.equals(inventoryBatchVO.getInventoryType())
-                        && (inventoryBatchVO.getInvId() == null || "".equals(inventoryBatchVO.getInvId()))) {
-                    throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.SKU_IS_NOT_IN_INVENTORY.getMessage());
-                }
+                //存货ID // 后面有判断
+//                if (Constant.InventoryType.OUTBOUND.equals(inventoryBatchVO.getInventoryType())
+//                        && (inventoryBatchVO.getInvId() == null || "".equals(inventoryBatchVO.getInvId()))) {
+//                    throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.SKU_IS_NOT_IN_INVENTORY.getMessage());
+//                }
                 //仓库ID
                 if (!inventoryBatchVO.getCanNegativeFlag() && (inventoryBatchVO.getWhId() == null || "".equals(inventoryBatchVO.getWhId()))) {
                     throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.WAREHOUSE_IS_NULL.getMessage());
@@ -329,9 +329,9 @@ public class InventoryService extends BaseService<Inventory> {
             addOrEditFlag = obj.getBoolean("addOrEditFlag");
         }
         //入库删除
-        if (map.get("delIntoDetail") != null ) {
+        if (map.get("delIntoDetail") != null) {
             delIntoDetail = (JSONArray) JSON.toJSON(map.get("delIntoDetail"));
-            if(delIntoDetail.size()>0){
+            if (delIntoDetail.size() > 0) {
                 JSONObject obj = (JSONObject) delIntoDetail.get(0);
                 inventoryDocCode = obj.get("inventoryDocCode").toString();
             }
@@ -339,7 +339,7 @@ public class InventoryService extends BaseService<Inventory> {
         //出库
         if (map.get("outDetail") != null) {
             outDetail = (JSONArray) JSON.toJSON(map.get("outDetail"));
-            if(outDetail.size() > 0){
+            if (outDetail.size() > 0) {
                 JSONObject obj = (JSONObject) outDetail.get(0);
                 inventoryDocCode = obj.get("inventoryDocCode").toString();
                 addOrEditFlag = obj.getBoolean("addOrEditFlag");
@@ -348,7 +348,7 @@ public class InventoryService extends BaseService<Inventory> {
         //出库删除
         if (map.get("delOutDetail") != null) {
             delOutDetail = (JSONArray) JSON.toJSON(map.get("delOutDetail"));
-            if(delOutDetail.size()>0){
+            if (delOutDetail.size() > 0) {
                 JSONObject obj = (JSONObject) delOutDetail.get(0);
                 inventoryDocCode = obj.get("inventoryDocCode").toString();
             }
@@ -361,7 +361,7 @@ public class InventoryService extends BaseService<Inventory> {
             //region 新建
             if (addOrEditFlag) {
                 //先出
-                if (outDetail.size() > 0 ) {
+                if (outDetail.size() > 0) {
                     outList = outDetail.toJavaList(InOutRecordVO.class);
                     //赋值并校验库存流水数据
                     outList = this.setInOutRecordMessageByOut(outList);
@@ -369,7 +369,7 @@ public class InventoryService extends BaseService<Inventory> {
                     outList = this.warehouseAdjustmentOut(outList);
                     //反写出库单金额等信息
                     this.updateOutbound(outList);
-                } else if (outDetail.size() == 0 && intoDetail.size() == 0 ) {
+                } else if (outDetail.size() == 0 && intoDetail.size() == 0) {
                     throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.NO_DATA_MOVED_OUT.getMessage());
                 }
                 //后入
@@ -383,7 +383,7 @@ public class InventoryService extends BaseService<Inventory> {
                     intoList = this.warehouseAdjustmentInto(intoList);
                     //修改入库单单价、金额、成本等信息
                     this.updateIntobound(intoList);
-                } else if (outDetail.size() == 0 && intoDetail.size() == 0 ) {
+                } else if (outDetail.size() == 0 && intoDetail.size() == 0) {
                     throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.NO_DATA_MOVED_IN.getMessage());
                 }
             }
@@ -451,13 +451,13 @@ public class InventoryService extends BaseService<Inventory> {
                 //赋值并校验库存流水数据
                 intoList = this.setInOutRecordMessageByInto(intoList);
                 //入库新建
-                intoAddList = intoList.stream().filter(it->it.getAddOrEditFlag()).collect(Collectors.toList());
+                intoAddList = intoList.stream().filter(it -> it.getAddOrEditFlag()).collect(Collectors.toList());
                 //入库编辑
-                intoEditList = intoList.stream().filter(it->!it.getAddOrEditFlag()).collect(Collectors.toList());
+                intoEditList = intoList.stream().filter(it -> !it.getAddOrEditFlag()).collect(Collectors.toList());
                 //新建
                 if (intoAddList.size() > 0) {
                     //正常逻辑 新建库存
-                    intoAddList =  this.operatingInsertInventory(intoAddList);
+                    intoAddList = this.operatingInsertInventory(intoAddList);
                     //修改入库单单价、金额、成本等信息
                     this.updateIntobound(intoAddList);
                 }
@@ -475,15 +475,15 @@ public class InventoryService extends BaseService<Inventory> {
                 //赋值并校验库存流水数据
                 outList = this.setInOutRecordMessageByOut(outList);
                 //出库新建
-                outAddList = outList.stream().filter(it->it.getAddOrEditFlag() && !it.getCanNegativeFlag() ).collect(Collectors.toList());
+                outAddList = outList.stream().filter(it -> it.getAddOrEditFlag() && !it.getCanNegativeFlag()).collect(Collectors.toList());
                 //出库编辑
-                outEditList = outList.stream().filter(it->!it.getAddOrEditFlag() && !it.getCanNegativeFlag() ).collect(Collectors.toList());
+                outEditList = outList.stream().filter(it -> !it.getAddOrEditFlag() && !it.getCanNegativeFlag()).collect(Collectors.toList());
                 //负出库新建
-                outNegAddList = outList.stream().filter(it->it.getAddOrEditFlag() && it.getCanNegativeFlag() ).collect(Collectors.toList());
+                outNegAddList = outList.stream().filter(it -> it.getAddOrEditFlag() && it.getCanNegativeFlag()).collect(Collectors.toList());
                 //负出库编辑
-                outNegEditList = outList.stream().filter(it->!it.getAddOrEditFlag() && it.getCanNegativeFlag() ).collect(Collectors.toList());
+                outNegEditList = outList.stream().filter(it -> !it.getAddOrEditFlag() && it.getCanNegativeFlag()).collect(Collectors.toList());
                 //走负库存逻辑 -- 新建
-                if (outNegAddList.size()>0) {
+                if (outNegAddList.size() > 0) {
                     //新建入库单
                     outNegAddList = this.insertOrUpdateInbound(outNegAddList);
                     //操作负库存
@@ -497,7 +497,7 @@ public class InventoryService extends BaseService<Inventory> {
                     this.operatingNegativeInventory(outNegEditList);
                 }
                 //正常库存逻辑 -- 新建
-                if (outAddList.size()>0) {
+                if (outAddList.size() > 0) {
                     //正常逻辑 新建库存
                     this.operatingInsertInventory(outAddList);
                 }
@@ -526,8 +526,8 @@ public class InventoryService extends BaseService<Inventory> {
     public InventoryResponse checkInventoryNumber(InOutRecordVO inOutRecordVO) {
         //存在标识
         //根据sku,仓库,非标号查询
-        InventoryResponse inventoryResponse = null ;
-        if(inOutRecordVO.getSkuId() != null){
+        InventoryResponse inventoryResponse = null;
+        if (inOutRecordVO.getSkuId() != null) {
             inventoryResponse = inventoryMapper.selectByOther(new InventoryQuery()
                     .setSkuId(inOutRecordVO.getSkuId())
                     .setWhId(inOutRecordVO.getWhId())
@@ -544,7 +544,7 @@ public class InventoryService extends BaseService<Inventory> {
     @Transactional(
             rollbackFor = {Exception.class}
     )
-    public List<InOutRecordVO>  operatingInsertInventory(List<InOutRecordVO> inOutRecordVOList) {
+    public List<InOutRecordVO> operatingInsertInventory(List<InOutRecordVO> inOutRecordVOList) {
         for (InOutRecordVO inOutRecordVO : inOutRecordVOList) {
             //校验库存是否存在
             InventoryResponse inventoryResponse = this.checkInventoryNumber(inOutRecordVO);
@@ -627,7 +627,7 @@ public class InventoryService extends BaseService<Inventory> {
                     //endregion
 
                     //region 销售退货出库  (负向出库相当于入库)
-                    if(inOutRecordVO.getSkuId() != null) {
+                    if (inOutRecordVO.getSkuId() != null) {
                         if (Constant.InventoryDocCode.SALE_RETURN.getValue().equals(inOutRecordVO.getInventoryDocCode())) {
                             //region  新建库存
                             inOutRecordVO = this.insertInventory(inOutRecordVO);
@@ -726,7 +726,7 @@ public class InventoryService extends BaseService<Inventory> {
             this.updateIntobound(inOutRecordVOList);
         }
         //出库
-        else{
+        else {
             //修改源出库信息
             this.updateOutboundPri(inOutRecordVOList);
         }
@@ -827,8 +827,8 @@ public class InventoryService extends BaseService<Inventory> {
         //存货资产
         inventory.setCostAmt(costAmt);
         //存货单价
-        inventory.setCostPrice(costAmt.compareTo(BigDecimal.ZERO) > 0 &&  inventory.getInvQty().compareTo(BigDecimal.ZERO) > 0 ?
-               costAmt.divide(inventory.getInvQty(),BigDecimal.ROUND_HALF_UP) : BigDecimal.ZERO);
+        inventory.setCostPrice(costAmt.compareTo(BigDecimal.ZERO) > 0 && inventory.getInvQty().compareTo(BigDecimal.ZERO) > 0 ?
+                costAmt.divide(inventory.getInvQty(), BigDecimal.ROUND_HALF_UP) : BigDecimal.ZERO);
         inventoryMapper.updateAmtAndQty(inventory);
         //endregion
     }
@@ -869,7 +869,7 @@ public class InventoryService extends BaseService<Inventory> {
         else {
             //region 销售退货出库和入库(不是采退入库)  数量正数
             if (Constant.InventoryDocCode.SALE_RETURN.getValue().equals(inOutRecordVO.getInventoryDocCode()) ||
-                    ( !Constant.InventoryDocCode.PURCHASE_RETURN.getValue().equals(inOutRecordVO.getInventoryDocCode()) &&
+                    (!Constant.InventoryDocCode.PURCHASE_RETURN.getValue().equals(inOutRecordVO.getInventoryDocCode()) &&
                             Constant.InventoryType.INBOUND.getName().equals(inOutRecordVO.getInventoryType()))
             ) {
                 //入库价
@@ -883,7 +883,7 @@ public class InventoryService extends BaseService<Inventory> {
 
             //region 采退入库 和出库(不是销退出库) 数量负数
             if (Constant.InventoryDocCode.PURCHASE_RETURN.getValue().equals(inOutRecordVO.getInventoryDocCode()) ||
-                    ( !Constant.InventoryDocCode.SALE_RETURN.getValue().equals(inOutRecordVO.getInventoryDocCode()) &&
+                    (!Constant.InventoryDocCode.SALE_RETURN.getValue().equals(inOutRecordVO.getInventoryDocCode()) &&
                             Constant.InventoryType.OUTBOUND.getName().equals(inOutRecordVO.getInventoryType()))
             ) {
                 //入库价
@@ -933,7 +933,7 @@ public class InventoryService extends BaseService<Inventory> {
                 //库存资产
                 inventory.setCostAmt(inOutRecordVO.getIntoAmt());
                 //库存单价   存货资产/存货数量
-                inventory.setCostPrice(inventory.getCostAmt().negate().divide(inventory.getInvQty().negate(),BigDecimal.ROUND_HALF_UP));
+                inventory.setCostPrice(inventory.getCostAmt().negate().divide(inventory.getInvQty().negate(), BigDecimal.ROUND_HALF_UP));
             } else {
                 //库存数量
                 inventory.setInvQty(inOutRecordVO.getIntoQty());
@@ -942,7 +942,7 @@ public class InventoryService extends BaseService<Inventory> {
                 //库存资产
                 inventory.setCostAmt(inOutRecordVO.getIntoAmt());
                 //库存单价   存货资产/存货数量
-                inventory.setCostPrice(inventory.getCostAmt().divide(inventory.getInvQty(),BigDecimal.ROUND_HALF_UP));
+                inventory.setCostPrice(inventory.getCostAmt().divide(inventory.getInvQty(), BigDecimal.ROUND_HALF_UP));
             }
         }
 
@@ -1126,7 +1126,7 @@ public class InventoryService extends BaseService<Inventory> {
                     OutboundItem outboundItem = new OutboundItem();
                     outboundItem.setItemId(inOutRecordVO.getBiznisItemId());
                     outboundItem.setCostAmt(inOutRecordVO.getIntoAmt());
-                    outboundItem.setCostPrice(inOutRecordVO.getIntoAmt().divide(inOutRecordVO.getIntoQty(),2,BigDecimal.ROUND_HALF_UP));
+                    outboundItem.setCostPrice(inOutRecordVO.getIntoAmt().divide(inOutRecordVO.getIntoQty(), 2, BigDecimal.ROUND_HALF_UP));
                     outboundItemMapper.update(outboundItem,
                             new UpdateWrapper<OutboundItem>().lambda()
                                     .eq(OutboundItem::getItemId, UUID.fromString(outboundItem.getItemId()))
@@ -1136,13 +1136,13 @@ public class InventoryService extends BaseService<Inventory> {
                 //endregion
             }
         } else {
-            if(inOutRecordVO.getSkuId()!=null){
+            if (inOutRecordVO.getSkuId() != null) {
                 List<GoodsSkuResponse> goodsSkuResponses = goodsSkuMapper.selectByCond(new GoodsSkuQuery().setSkuId(inOutRecordVO.getSkuId()));
-                if(goodsSkuResponses!=null && goodsSkuResponses.size()>0){
+                if (goodsSkuResponses != null && goodsSkuResponses.size() > 0) {
                     //提示具体型号不足
-                    throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(),goodsSkuResponses.get(0).getSkuModel()+ ErrorCodeEnum.CAN_OUTBOUND_QUANTITY_INSUFFICIENT.getMessage());
+                    throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), goodsSkuResponses.get(0).getSkuModel() + ErrorCodeEnum.CAN_OUTBOUND_QUANTITY_INSUFFICIENT.getMessage());
                 }
-            }else{
+            } else {
                 throw new BaseBusinessException(ResponseCodeEnum.OPERATE_FAIL.getCode(), ErrorCodeEnum.CAN_OUTBOUND_QUANTITY_INSUFFICIENT.getMessage());
             }
         }
@@ -1274,7 +1274,7 @@ public class InventoryService extends BaseService<Inventory> {
         //endregion
 
         //region 库存数量重算   库存数量-删除数量
-        BigDecimal qty = inOutRecordVO.getQtyBeforeUpdate()!=null && inOutRecordVO.getQtyBeforeUpdate().compareTo(BigDecimal.ZERO)>0 ?inOutRecordVO.getQtyBeforeUpdate():inOutRecordVO.getIntoQty();
+        BigDecimal qty = inOutRecordVO.getQtyBeforeUpdate() != null && inOutRecordVO.getQtyBeforeUpdate().compareTo(BigDecimal.ZERO) > 0 ? inOutRecordVO.getQtyBeforeUpdate() : inOutRecordVO.getIntoQty();
         Inventory inventory = new Inventory();
         //库存id
         inventory.setInvId(inventoryResponse.getInvId());
@@ -1294,7 +1294,7 @@ public class InventoryService extends BaseService<Inventory> {
         inventory.setCostAmt(costAmt);
         //存货单价
         inventory.setCostPrice(costAmt.compareTo(BigDecimal.ZERO) > 0 ?
-                costAmt.divide(inventory.getInvQty(),BigDecimal.ROUND_HALF_UP) : BigDecimal.ZERO);
+                costAmt.divide(inventory.getInvQty(), BigDecimal.ROUND_HALF_UP) : BigDecimal.ZERO);
         inventoryMapper.updateAmtAndQty(inventory);
         //endregion
     }
@@ -1771,7 +1771,7 @@ public class InventoryService extends BaseService<Inventory> {
     )
     public List<InOutRecordVO> selectOutbound(List<InOutRecordVO> inOutRecordVOList) {
         for (InOutRecordVO inOutRecordVO : inOutRecordVOList) {
-            OutboundItemResponse outboundItemResponse = outboundItemMapper.selectItemIndex(inOutRecordVO.getItemIndex(),inOutRecordVO.getOutId());
+            OutboundItemResponse outboundItemResponse = outboundItemMapper.selectItemIndex(inOutRecordVO.getItemIndex(), inOutRecordVO.getOutId());
             //单价
             inOutRecordVO.setPriceInto(outboundItemResponse.getPriceOut());
             //金额
@@ -2259,10 +2259,10 @@ public class InventoryService extends BaseService<Inventory> {
             int invQty = item.getInvQty().intValue();
             Long warningLowerLimit = item.getWarningLowerLimit();
             Long warningUpperLimit = item.getWarningUpperLimit();
-            if (warningUpperLimit != 0 && invQty > warningUpperLimit){
+            if (warningUpperLimit != 0 && invQty > warningUpperLimit) {
                 item.setWarningMsg("超出警戒上限" + "(" + warningUpperLimit + item.getUnitName() + ")");
             }
-            if (warningLowerLimit != 0 && invQty < warningLowerLimit){
+            if (warningLowerLimit != 0 && invQty < warningLowerLimit) {
                 item.setWarningMsg("低于警戒下限" + "(" + warningLowerLimit + item.getUnitName() + ")");
             }
         });

+ 1 - 1
src/main/java/com/dk/mdm/service/ivt/outbound/OutboundSaleOrderService.java

@@ -1787,7 +1787,7 @@ public class OutboundSaleOrderService extends BaseService<Outbound> {
         //出库状态
         String outStatus = null;
         //出库中+已出库 小于 总数   或者 出库中数量小于等于订单总数量
-        if (intoingQty.compareTo(sumQty) <= 0 && intoingQty.add(intoQty).compareTo(sumQty) <= 0   ) {
+        if (intoingQty.compareTo(sumQty) <= 0 && intoingQty.add(intoQty).compareTo(sumQty) < 0   ) {
             //出库中
             outStatus = Constant.OutStatus.CHUKUZHONG.getName();
         }