|
@@ -420,6 +420,117 @@ public class OyeResultServiceImpl implements IOyeResultService {
|
|
return "操作成功";
|
|
return "操作成功";
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 划拨实时库存重量
|
|
|
|
+ * @param map
|
|
|
|
+ * @return
|
|
|
|
+ * @throws Exception
|
|
|
|
+ */
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
|
+ public synchronized String updateInsertRealTimeWeight(Map<String, Object> map) throws Exception{
|
|
|
|
+ System.out.println("===========" + new Date());
|
|
|
|
+ JSONObject jsonObject = new JSONObject(map);
|
|
|
|
+ System.out.println(jsonObject);
|
|
|
|
+ System.out.println("===========" + new Date());
|
|
|
|
+ // 划分实时库存数据
|
|
|
|
+ // 针对原先的库存,需要进行出库;针对划分后的库存需要进行入库;先出后入;
|
|
|
|
+ // 创建出库需要的数据;
|
|
|
|
+ BigDecimal newInventoryId = DataChange.dataToBigDecimal(map.get("newInventoryId"));
|
|
|
|
+ OyeOutboundResult oyeOutboundResult = new OyeOutboundResult();
|
|
|
|
+ oyeOutboundResult.setId(oyeOutboundResultMapper.getResultId());
|
|
|
|
+ BigDecimal materialId = DataChange.dataToBigDecimal(map.get("materialId"));
|
|
|
|
+ BigDecimal singleWeight = DataChange.dataToBigDecimal(map.get("singleWeight"));
|
|
|
|
+ BigDecimal meter = DataChange.dataToBigDecimal(map.get("meter"));
|
|
|
|
+ map.put("materialNumber", map.get("materialNumberEdit"));
|
|
|
|
+ map.put("theoryWeight", map.get("theoryWeightEdit"));
|
|
|
|
+ map.put("netWeight", map.get("netWeightEdit"));
|
|
|
|
+ //划拨件数
|
|
|
|
+ BigDecimal materialNumber = DataChange.dataToBigDecimal(map.get("materialNumber"));
|
|
|
|
+ //划拨理重
|
|
|
|
+ BigDecimal theoryWeight = DataChange.dataToBigDecimal(map.get("theoryWeight"));
|
|
|
|
+ //划拨净重
|
|
|
|
+ BigDecimal netWeight = DataChange.dataToBigDecimal(map.get("netWeight"));
|
|
|
|
+ //重量划拨,允许件数为0
|
|
|
|
+ /*if(materialNumber == null || materialNumber.intValue() == 0) {
|
|
|
|
+ throw new Exception("物资件数错误");
|
|
|
|
+ }*/
|
|
|
|
+ materialNumber = materialNumber == null || materialNumber.intValue() < 0 ? new BigDecimal(0) : materialNumber;
|
|
|
|
+ oyeOutboundResult.setInboundArea(map.get("inboundArea").toString());
|
|
|
|
+ oyeOutboundResult.setConsigneeId(DataChange.dataToBigDecimal(map.get("oldConsigneeId")));
|
|
|
|
+ oyeOutboundResult.setSaleArea(map.get("oldSaleArea").toString());
|
|
|
|
+ oyeOutboundResult.setInboundWarehouse(map.get("oldInboundWarehouse").toString());
|
|
|
|
+ //更新制单日期
|
|
|
|
+ oyeOutboundResult.setMaterialId(materialId);
|
|
|
|
+ oyeOutboundResult.setMeter(meter);
|
|
|
|
+ oyeOutboundResult.setSingleWeight(singleWeight);
|
|
|
|
+ oyeOutboundResult.setTheoryWeight(theoryWeight);
|
|
|
|
+ oyeOutboundResult.setNetWeight(netWeight);
|
|
|
|
+ oyeOutboundResult.setMaterialNumber(materialNumber);
|
|
|
|
+ oyeOutboundResult.setInsertUsername(map.get("userName") + "");
|
|
|
|
+ oyeOutboundResult.setInsertTime(new Date());
|
|
|
|
+ oyeOutboundResult.setInventoryId(DataChange.dataToBigDecimal(map.get("inventoryId")));
|
|
|
|
+ oyeOutboundResult.setAlternateFields2("库存重量划拨");
|
|
|
|
+ oyeOutboundResult.setCapacityNumbher("库存重量划拨");
|
|
|
|
+ Map<String, Object> outBoundMap = new HashMap<>();
|
|
|
|
+ outBoundMap.put("inventoryId",map.get("inventoryId"));
|
|
|
|
+ outBoundMap.put("materialNumber",oyeOutboundResult.getMaterialNumber());
|
|
|
|
+ outBoundMap.put("netWeight",oyeOutboundResult.getNetWeight());
|
|
|
|
+ outBoundMap.put("theoryWeight",oyeOutboundResult.getTheoryWeight());
|
|
|
|
+ outBoundMap.put("flag",2);
|
|
|
|
+ OyeRealtimeInventory oyeRealtimeInventoryOut = updateRealTimeInventory(outBoundMap);
|
|
|
|
+ // 创建入库需要的数据
|
|
|
|
+ OyeInboundResult oyeInboundResult = new OyeInboundResult();
|
|
|
|
+ oyeInboundResult.setResultId(oyeInboundResultMapper.getResultId());
|
|
|
|
+ oyeInboundResult.setInboundArea(map.get("inboundArea").toString());
|
|
|
|
+ oyeInboundResult.setConsigneeId(DataChange.dataToBigDecimal(map.get("consigneeId")));
|
|
|
|
+ oyeInboundResult.setSaleArea(map.get("saleArea").toString());
|
|
|
|
+ oyeInboundResult.setInboundWarehouse(map.get("inboundWarehouse").toString());
|
|
|
|
+ oyeInboundResult.setMeter(meter);
|
|
|
|
+ oyeInboundResult.setMaterialId(materialId);
|
|
|
|
+ oyeInboundResult.setSingleWeight(singleWeight);
|
|
|
|
+ oyeInboundResult.setTheoryWeight(theoryWeight);
|
|
|
|
+ oyeInboundResult.setNetWeight(netWeight);
|
|
|
|
+ oyeInboundResult.setMaterialNumber(materialNumber);
|
|
|
|
+ oyeInboundResult.setInsertUsername(map.get("userName") + "");
|
|
|
|
+ oyeInboundResult.setInsertTime(new Date());
|
|
|
|
+ oyeInboundResult.setAlternateFields2("库存重量划拨");
|
|
|
|
+ oyeInboundResult.setCapacityNumbher("库存重量划拨");
|
|
|
|
+ map.put("singleWeight",singleWeight);
|
|
|
|
+ OyeRealtimeInventory oyeRealtimeInventoryInsert = null;
|
|
|
|
+ OyeRealtimeInventory oyeRealtimeInventoryUpdate = null;
|
|
|
|
+ //根据区域,客户,物资,单重,米数,仓库,库区查询实时库存在不在
|
|
|
|
+ BigDecimal inventoryId = null ;
|
|
|
|
+ if(newInventoryId == null || newInventoryId.intValue() == 0) {
|
|
|
|
+ inventoryId = oyeRealtimeInventoryMapper.getInventoryId(map);
|
|
|
|
+ }else{
|
|
|
|
+ inventoryId = newInventoryId;
|
|
|
|
+ }
|
|
|
|
+ if (inventoryId != null && inventoryId.compareTo(DataChange.dataToBigDecimal(map.get("inventoryId"))) == 0) {
|
|
|
|
+ throw new Exception("库存ID一致无法划分");
|
|
|
|
+ }
|
|
|
|
+ if (inventoryId == null) {
|
|
|
|
+ //新增实时库存
|
|
|
|
+ map.put("flag",1);
|
|
|
|
+ oyeRealtimeInventoryInsert = insertRealTimeInventory(map);
|
|
|
|
+ oyeInboundResult.setInventoryId(oyeRealtimeInventoryInsert.getInventoryId());
|
|
|
|
+ }else{
|
|
|
|
+ map.put("inventoryId",inventoryId);
|
|
|
|
+ map.put("flag",1);
|
|
|
|
+ oyeRealtimeInventoryUpdate = updateRealTimeInventory(map);
|
|
|
|
+ oyeInboundResult.setInventoryId(oyeRealtimeInventoryUpdate.getInventoryId());
|
|
|
|
+ }
|
|
|
|
+ if (oyeRealtimeInventoryInsert != null) {
|
|
|
|
+ oyeRealtimeInventoryMapper.insertSelective(oyeRealtimeInventoryInsert);
|
|
|
|
+ }
|
|
|
|
+ if (oyeRealtimeInventoryUpdate != null) {
|
|
|
|
+ oyeRealtimeInventoryMapper.updateByPrimaryKeySelective(oyeRealtimeInventoryUpdate);
|
|
|
|
+ }
|
|
|
|
+ oyeInboundResultMapper.insertSelective(oyeInboundResult);
|
|
|
|
+ oyeRealtimeInventoryMapper.updateByPrimaryKeySelective(oyeRealtimeInventoryOut);
|
|
|
|
+ oyeOutboundResultMapper.insertSelective(oyeOutboundResult);
|
|
|
|
+ return "操作成功";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@Transactional(rollbackFor = Exception.class)
|