Kaynağa Gözat

PDA增加仓库校验,面损表调整

fenghaifu 1 yıl önce
ebeveyn
işleme
2ea21f4d98

+ 24 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/openApi/controller/SubcontractingOrderController.java

@@ -2,6 +2,7 @@ package org.jeecg.modules.openApi.controller;
 
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
@@ -13,6 +14,9 @@ import org.jeecg.modules.openApi.entity.ResHttpStatus;
 import org.jeecg.modules.openApi.entity.SubcontractingOrder;
 import org.jeecg.modules.openApi.service.IPurchaseWarehousingService;
 import org.jeecg.modules.openApi.service.SubcontractingOrderService;
+import org.jeecg.modules.system.entity.SysDictItem;
+import org.jeecg.modules.system.service.ISysDictItemService;
+import org.jeecg.modules.system.util.oConvertUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.http.HttpStatus;
 import org.springframework.http.ResponseEntity;
@@ -37,6 +41,8 @@ public class SubcontractingOrderController extends JeecgController<Subcontractin
     private HttpServletRequest request;
     @Autowired
     private SubcontractingOrderService subcontractingOrderService;
+    @Autowired
+    private ISysDictItemService sysDictItemService;
 
     /**
      * 根据订单号审核入库单(pda功能) 0000000003
@@ -66,6 +72,24 @@ public class SubcontractingOrderController extends JeecgController<Subcontractin
             res.setMsg("审核人姓名不能为空");
             return new ResponseEntity<>(res, HttpStatus.OK);
         }
+        // 仓库比较逻辑,仓库在数据字典里面未配置的,返回错误
+        String rdWarehouseCode = subcontractingOrderService.getRdrecord01Warehouse(json.getString("id"));
+        LambdaQueryWrapper<SysDictItem> queryWrapper = new LambdaQueryWrapper<>();
+        queryWrapper.eq(SysDictItem::getItemText, "pda_warehouse");
+        List<SysDictItem> dictItemList = sysDictItemService.list(queryWrapper);
+        String settingWarehouseCode = "";
+        if (dictItemList.size()>0){
+            settingWarehouseCode = oConvertUtils.getString(dictItemList.get(0).getItemValue(),"");
+        }
+        if (oConvertUtils.isNotEmpty(settingWarehouseCode)){
+            settingWarehouseCode = ","+settingWarehouseCode+",";
+            rdWarehouseCode = ","+rdWarehouseCode+",";
+            if (settingWarehouseCode.indexOf(rdWarehouseCode)==-1){
+                res.setMsg("不能审核当前仓库的入库单");
+                return new ResponseEntity<>(res, HttpStatus.OK);
+            }
+        }
+
         int st = subcontractingOrderService.toExamine(json.getString("id"),json.getString("cbSysBarCode"),json.getString("cHandler"));
 
         res.setCode("200");

+ 7 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/openApi/mapper/SubcontractingOrderMapper.java

@@ -106,4 +106,11 @@ public interface SubcontractingOrderMapper extends BaseMapper<SubcontractingOrde
      */
     int selectNum(@Param("id") String id);
 
+    /**
+     * pda根据id获取仓库编号
+     * @param id
+     * @return
+     */
+    Map<String,Object> selectWhCodeById(String id);
+
 }

+ 9 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/openApi/mapper/xml/SubcontractingOrderMapper.xml

@@ -247,4 +247,13 @@
         where id = #{id}
     </update>
 
+
+    <select id="selectWhCodeById" resultType="map">
+
+        select
+               cWhCode
+        from RdRecord01 where id = #{id}
+
+    </select>
+
 </mapper>

+ 2 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/openApi/service/SubcontractingOrderService.java

@@ -24,4 +24,6 @@ public interface SubcontractingOrderService extends IService<SubcontractingOrder
     Map<String,Object> selectRdAllByBar(String cbSysBarCode);
 
     int toExamine(String id,String cbSysBarCode,String cHandler);
+
+    String getRdrecord01Warehouse(String id);
 }

+ 16 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/openApi/service/impl/SubcontractingOrderImpl.java

@@ -6,6 +6,7 @@ import org.jeecg.modules.openApi.entity.SubcontractingOrder;
 import org.jeecg.modules.openApi.mapper.PurchaseWarehousingMapper;
 import org.jeecg.modules.openApi.mapper.SubcontractingOrderMapper;
 import org.jeecg.modules.openApi.service.SubcontractingOrderService;
+import org.jeecg.modules.system.util.oConvertUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Propagation;
@@ -250,6 +251,21 @@ public class SubcontractingOrderImpl extends ServiceImpl<SubcontractingOrderMapp
 
     }
 
+    /**
+     * 获取入库单仓库
+     * @param id
+     * @return
+     */
+    @DS("multi-three")
+    public String getRdrecord01Warehouse(String id){
+        Map<String,Object> map = subcontractingOrderMapper.selectWhCodeById(id);
+        if (map == null){
+            return "";
+        }
+        return oConvertUtils.getString(map.get("cWhCode"),"");
+
+    }
+
 //    public Integer getMaxId(String id, String tableName) {
 //        Integer maxId=purchaseWarehousingMapper.getMaxId(id,tableName);
 //        if(maxId!=null){

+ 24 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/report/entity/FabricPoSaleOut.java

@@ -0,0 +1,24 @@
+package org.jeecg.modules.report.entity;
+
+import lombok.Data;
+
+/**
+ * 采购入库物料,销售出库
+ */
+@Data
+public class FabricPoSaleOut {
+    // 存货编码
+    private String cInvCode;
+    // 批号
+    private String cBatch;
+    // 颜色
+    private String cColor;
+    // 供应商简称
+    private String cCusAbbName;
+    // 数量
+    private Double iQuantity;
+
+    public String getInvId(){
+        return cInvCode+cColor+cBatch;
+    }
+}

+ 3 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/report/mapper/FabricLossMapper.java

@@ -152,4 +152,7 @@ public interface FabricLossMapper extends BaseMapper<FabricLoss> {
 	// 根据委外入库单行id 获取 委外订单行id
 	@DS("multi-three")
 	List<Map<String,Integer>> getMoDetailIdListByAutoId(@Param("autoIdList")List<Integer> autoIdList);
+	@DS("multi-three")
+	@InterceptorIgnore(tenantLine = "1")
+	List<FabricPoSaleOut> getSaleOutByInventory(@Param("invIdList")List<String> invIdList);
 }

+ 18 - 3
jeecg-boot-module-system/src/main/java/org/jeecg/modules/report/mapper/xml/FabricLossMapper.xml

@@ -94,18 +94,19 @@
 	<!--获取销售出库委外订单行id-->
 	<select id="getOmOrderListGw" resultType="String">
 
-			SELECT b.MODetailsID
+			SELECT distinct b.MODetailsID
 			FROM
 				om_momain a
 				INNER JOIN OM_MODetails b ON a.moid = b.moid
 				INNER JOIN Inventory c ON b.cinvcode = c.cinvcode
 				inner join Vendor  d on a.cVenCode=d.cVenCode
 				inner join VendorClass e on d.cVCCode =e.cVCCode
+				inner join RdRecords01 x on x.iOMoDID=b.MODetailsID
 			WHERE
 				c.cInvCCode NOT LIKE '19%'
 				AND (trim(a.cCode) LIKE CONCAT(#{code},'%') and a.cCode not like '%样%')
-				and b.cInvCode+isnull(b.cFree1,'') in (
-				select cInvCode+isnull(cFree1,'') from rdrecords32 where (trim(cbatch) like CONCAT(#{code},'%') and cbatch not like '%样%')
+				and x.cInvCode+isnull(x.cFree1,'')+isnull(x.cBatch,'') in (
+				select distinct cInvCode+isnull(cFree1,'')+isnull(cBatch,'') from rdrecords32
 				)
 
 	</select>
@@ -683,4 +684,18 @@
             #{item}
         </foreach>
     </select>
+
+	<!-- 根据物料id(编码,颜色,批号)获取销售出库数量,供应商 -->
+	<select id="getSaleOutByInventory" resultType="org.jeecg.modules.report.entity.FabricPoSaleOut">
+		select c.cCusAbbName ,b.cInvCode,isnull(b.cBatch,'') as cBatch,isnull(b.cfree1,'') as cColor,sum(b.iquantity) as iQuantity from
+		rdrecord32 a inner join
+		rdrecords32 b on a.id=b.id
+		inner join Customer  c on a.cCusCode=c.cCusCode
+		where
+		b.cInvCode + isnull(b.cFree1,'') + isnull(b.cBatch,'') in
+		<foreach item="item" collection="invIdList" index="index" open="(" separator="," close=")">
+			#{item}
+		</foreach>
+		group by c.cCusAbbName ,b.cinvcode,b.cbatch,b.cfree1
+	</select>
 </mapper>

+ 46 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/report/service/impl/FabricLossServiceImpl.java

@@ -1743,6 +1743,9 @@ public class FabricLossServiceImpl extends ServiceImpl<FabricLossMapper, FabricL
 		}
 
 		// ---- 采购订单分行修改 end ---------------
+		// ---- 采购订单分配数量是0,库存余纱小于采购数量,查找销售 begin
+		setPoOrderSaleOut(poOrderList);
+		// ---- 采购订单分配数量是0,库存余纱小于采购数量,查找销售 end
 		// 设置来源余纱和其他入库的纱:批号是期初的,算来源余纱;物料名称是杂纱的,算其他入库的纱
 		List<FabricPoOrderOut> lyysList = new ArrayList<>();    // 来源余纱
 		List<FabricPoOrderOut> qtrkList = new ArrayList<>();    // 其他入库的纱
@@ -2146,4 +2149,47 @@ public class FabricLossServiceImpl extends ServiceImpl<FabricLossMapper, FabricL
 		}
 		return pInList.stream().filter(e->(e.getMODetailsID()==0 && e.getPoDetailsID()==0) || e.getIQuantity()>0 ).collect(Collectors.toList());
 	}
+
+	/**
+	 * 采购订单分配数量是0,库存余纱小于采购数量,查找销售
+	 */
+	private void setPoOrderSaleOut(List<FabricPoOrder> orderList){
+		List<String> invIdList = new ArrayList<>();
+		for (FabricPoOrder order : orderList){
+			if (order.getIQuantityOut() == 0 && order.getIQuantityIn()>order.getIQuantityLeft() &&
+			oConvertUtils.listIsNotEmpty(order.getFabricPoOrderInList())){
+				List<FabricPoOrderIn> inList = order.getFabricPoOrderInList();
+				for (FabricPoOrderIn orderIn : inList){
+					invIdList.add(orderIn.getInvId());
+				}
+			}
+		}
+		if (oConvertUtils.listIsNotEmpty(invIdList)){
+			invIdList = invIdList.stream().distinct().collect(Collectors.toList());
+			List<FabricPoSaleOut> saleOutList = fabricLossMapper.getSaleOutByInventory(invIdList);
+			for (FabricPoOrder order : orderList){
+				if (order.getIQuantityOut() == 0 && order.getIQuantityIn()>order.getIQuantityLeft() &&
+						oConvertUtils.listIsNotEmpty(order.getFabricPoOrderInList())){
+					List<FabricPoOrderIn> inList = order.getFabricPoOrderInList();
+					Double iQuantity = 0.0;
+					String vendorName = "";
+					for (FabricPoSaleOut saleOut : saleOutList){
+						if (inList.stream().filter(e->e.getInvId().equalsIgnoreCase(saleOut.getInvId())).count()>0){
+							iQuantity = DoubleOperation.add(iQuantity, saleOut.getIQuantity());
+							if (vendorName.indexOf(saleOut.getCCusAbbName()) == -1){
+								if (vendorName.length()>0){
+									vendorName +=",";
+								}
+								vendorName += saleOut.getCCusAbbName();
+							}
+						}
+					}
+					iQuantity = Math.min(iQuantity, DoubleOperation.sub(order.getIQuantityIn(), order.getIQuantityLeft()));
+					order.setIQuantityOut(iQuantity);
+					order.setOmcVenAbbName(vendorName);
+					order.setCVenName(vendorName);
+				}
+			}
+		}
+	}
 }