辅材盘盈盘亏支持小数
This commit is contained in:
parent
b31a0876a0
commit
3301969c33
@ -6688,7 +6688,7 @@ public class ToSAPServiceImpl {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 转工单-新
|
* 转工单-新
|
||||||
* @param materialPackingList
|
* @param mapList
|
||||||
* @param mes
|
* @param mes
|
||||||
* @param bwart
|
* @param bwart
|
||||||
* @return
|
* @return
|
||||||
@ -6769,8 +6769,8 @@ public class ToSAPServiceImpl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
System.out.println(mapList);
|
System.out.println(mapList);
|
||||||
/*log.info("SendTOSAP >>>>" + sendData);
|
log.info("SendTOSAP >>>>" + sendData);
|
||||||
String sendDatas = sendData.toJSONString();
|
/*String sendDatas = sendData.toJSONString();
|
||||||
String sapreturn = toSAPMessageUtil.sendHttpPost(toSAPMessageUtil.materialChangeLocationUrl, "", sendDatas);
|
String sapreturn = toSAPMessageUtil.sendHttpPost(toSAPMessageUtil.materialChangeLocationUrl, "", sendDatas);
|
||||||
org.json.JSONObject receiveJsonObject = new org.json.JSONObject(sapreturn);
|
org.json.JSONObject receiveJsonObject = new org.json.JSONObject(sapreturn);
|
||||||
org.json.JSONObject returnJsonObject = (org.json.JSONObject) receiveJsonObject.get("RETURN");
|
org.json.JSONObject returnJsonObject = (org.json.JSONObject) receiveJsonObject.get("RETURN");
|
||||||
|
@ -335,6 +335,7 @@ public class MaterialReceiveActController {
|
|||||||
String checkType = auxiliaryOutIn.getCheckType();
|
String checkType = auxiliaryOutIn.getCheckType();
|
||||||
String user = auxiliaryOutIn.getUser();
|
String user = auxiliaryOutIn.getUser();
|
||||||
String nums = auxiliaryOutIn.getNums();
|
String nums = auxiliaryOutIn.getNums();
|
||||||
|
BigDecimal numsBigDecimal = new BigDecimal(nums);
|
||||||
String siteName = auxiliaryOutIn.getSiteName();
|
String siteName = auxiliaryOutIn.getSiteName();
|
||||||
String erpFactory = auxiliaryOutIn.getErpFactory();
|
String erpFactory = auxiliaryOutIn.getErpFactory();
|
||||||
String erpLocation = auxiliaryOutIn.getErpLocation();
|
String erpLocation = auxiliaryOutIn.getErpLocation();
|
||||||
@ -388,44 +389,32 @@ public class MaterialReceiveActController {
|
|||||||
if (maps == null || maps.size() <= 0) {
|
if (maps == null || maps.size() <= 0) {
|
||||||
return AjaxResult.me().setSuccess(false).setMessage("没有符合条件的数据");
|
return AjaxResult.me().setSuccess(false).setMessage("没有符合条件的数据");
|
||||||
}
|
}
|
||||||
int materialquantity = maps.stream()
|
BigDecimal materialquantity = maps.stream()
|
||||||
.mapToInt(map -> {
|
.map(map -> (BigDecimal) map.get("MATERIALQUANTITY"))
|
||||||
Object qtyObj = map.get("MATERIALQUANTITY");
|
.filter(Objects::nonNull)
|
||||||
if (qtyObj instanceof Integer) {
|
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||||
return (Integer) qtyObj;
|
if (materialquantity.compareTo(numsBigDecimal) < 0) {
|
||||||
} else if (qtyObj instanceof Number) {
|
|
||||||
// 如果可能是 Double、Long 等,也可以安全转为 int
|
|
||||||
return ((Number) qtyObj).intValue();
|
|
||||||
} else if (qtyObj != null) {
|
|
||||||
try {
|
|
||||||
return Integer.parseInt(qtyObj.toString());
|
|
||||||
} catch (NumberFormatException ignored) {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0; // 默认值
|
|
||||||
})
|
|
||||||
.sum();
|
|
||||||
if (materialquantity < Integer.parseInt(nums)) {
|
|
||||||
return AjaxResult.me().setSuccess(false).setMessage("数量不足");
|
return AjaxResult.me().setSuccess(false).setMessage("数量不足");
|
||||||
}
|
}
|
||||||
List<LinkedHashMap<String, Object>> linkedHashMaps = pickMaterialQuantities(maps, Integer.parseInt(nums));
|
List<LinkedHashMap<String, Object>> linkedHashMaps = pickMaterialQuantities(maps, numsBigDecimal);
|
||||||
return AjaxResult.me().setResultObj(linkedHashMaps);
|
return AjaxResult.me().setResultObj(linkedHashMaps);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<LinkedHashMap<String, Object>> pickMaterialQuantities(List<LinkedHashMap<String, Object>> maps, int requiredQuantity) {
|
public List<LinkedHashMap<String, Object>> pickMaterialQuantities(List<LinkedHashMap<String, Object>> maps, BigDecimal requiredQuantity) {
|
||||||
List<LinkedHashMap <String, Object>> resultList = new ArrayList<>();
|
List<LinkedHashMap <String, Object>> resultList = new ArrayList<>();
|
||||||
int remaining = requiredQuantity;
|
BigDecimal remaining = requiredQuantity;
|
||||||
|
|
||||||
for (LinkedHashMap<String, Object> item : maps) {
|
for (LinkedHashMap<String, Object> item : maps) {
|
||||||
// 获取当前记录的数量
|
// 获取当前记录的数量
|
||||||
Integer materialQuantity = Integer.parseInt(item.get("MATERIALQUANTITY").toString());
|
BigDecimal materialQuantity = (BigDecimal) item.get("MATERIALQUANTITY");
|
||||||
if (materialQuantity == null || materialQuantity <= 0 || remaining <= 0) {
|
if (materialQuantity == null || materialQuantity.compareTo(BigDecimal.ZERO) <= 0
|
||||||
continue; // 跳过无效或已满足的情况
|
|| remaining.compareTo(BigDecimal.ZERO) <= 0) {
|
||||||
|
continue; // 数量无效
|
||||||
}
|
}
|
||||||
|
|
||||||
// 计算可以取多少
|
// 计算可以取多少
|
||||||
int take = Math.min(materialQuantity, remaining);
|
BigDecimal take = materialQuantity.min(remaining);
|
||||||
|
|
||||||
// 创建新的记录并设置数量
|
// 创建新的记录并设置数量
|
||||||
LinkedHashMap<String, Object> newItem = new LinkedHashMap<>(item); // 复制原有字段
|
LinkedHashMap<String, Object> newItem = new LinkedHashMap<>(item); // 复制原有字段
|
||||||
@ -435,10 +424,10 @@ public class MaterialReceiveActController {
|
|||||||
resultList.add(newItem);
|
resultList.add(newItem);
|
||||||
|
|
||||||
// 更新剩余数量
|
// 更新剩余数量
|
||||||
remaining -= take;
|
remaining = remaining.subtract(take);
|
||||||
|
|
||||||
// 如果已经满足需求,退出循环
|
// 如果已经满足需求,退出循环
|
||||||
if (remaining == 0) {
|
if (remaining.compareTo(BigDecimal.ZERO) == 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -518,10 +507,10 @@ public class MaterialReceiveActController {
|
|||||||
}
|
}
|
||||||
HashMap<String, Object> hashMap = maps.get(0);
|
HashMap<String, Object> hashMap = maps.get(0);
|
||||||
// 数据库中数量
|
// 数据库中数量
|
||||||
Integer materialquantity = Integer.parseInt(hashMap.get("MATERIALQUANTITY").toString());
|
BigDecimal materialquantity = (BigDecimal)hashMap.get("MATERIALQUANTITY");
|
||||||
// 前端传递数量
|
// 前端传递数量
|
||||||
Integer materialQuantityFont = (int)materialPacking.getMaterialQuantity();
|
BigDecimal materialQuantityFont = BigDecimal.valueOf(materialPacking.getMaterialQuantity());
|
||||||
if (materialquantity <= materialQuantityFont) {
|
if (materialquantity.compareTo(materialQuantityFont) <= 0) {
|
||||||
updateList.add(materialPacking);
|
updateList.add(materialPacking);
|
||||||
} else {
|
} else {
|
||||||
// 更新库存数量
|
// 更新库存数量
|
||||||
|
@ -6,6 +6,7 @@ import org.apache.ibatis.annotations.Mapper;
|
|||||||
import org.apache.ibatis.annotations.Param;
|
import org.apache.ibatis.annotations.Param;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -65,6 +66,6 @@ public interface CostCenterDao {
|
|||||||
List<HashMap<String, Object>> getByMaterialPackingName(String newBoxId);
|
List<HashMap<String, Object>> getByMaterialPackingName(String newBoxId);
|
||||||
|
|
||||||
void updateQty(@Param("materialPackingName") String materialPackingName,
|
void updateQty(@Param("materialPackingName") String materialPackingName,
|
||||||
@Param("materialQuantityFont") Integer materialQuantityFont,
|
@Param("materialQuantityFont") BigDecimal materialQuantityFont,
|
||||||
@Param("user") String user);
|
@Param("user") String user);
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@ import com.cim.idm.model.CostCenter;
|
|||||||
import com.cim.idm.model.MaterialPacking;
|
import com.cim.idm.model.MaterialPacking;
|
||||||
import com.cim.idm.model.vo.MaterialInfo;
|
import com.cim.idm.model.vo.MaterialInfo;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -28,5 +29,5 @@ public interface CostCenterService {
|
|||||||
|
|
||||||
List<HashMap<String, Object>> getByMaterialPackingName(String newBoxId);
|
List<HashMap<String, Object>> getByMaterialPackingName(String newBoxId);
|
||||||
|
|
||||||
void updateQty(String materialPackingName, Integer materialQuantityFont, String user);
|
void updateQty(String materialPackingName, BigDecimal materialQuantityFont, String user);
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
@Service("CostCenterService")
|
@Service("CostCenterService")
|
||||||
@ -171,7 +172,7 @@ public class CostCenterServiceImpl implements CostCenterService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateQty(String materialPackingName, Integer materialQuantityFont, String user) {
|
public void updateQty(String materialPackingName, BigDecimal materialQuantityFont, String user) {
|
||||||
costCenterDao.updateQty(materialPackingName, materialQuantityFont, user);
|
costCenterDao.updateQty(materialPackingName, materialQuantityFont, user);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -673,7 +673,7 @@ public class MESToWMSServiceImpl implements MESToWMSService {
|
|||||||
// 组织
|
// 组织
|
||||||
String WERKS = jsonObject.getString("WERKS");
|
String WERKS = jsonObject.getString("WERKS");
|
||||||
// 仓库
|
// 仓库
|
||||||
String LGORT = jsonObject.getString("LGORT");
|
String LGORT = jsonObject.getString("erpLocation");
|
||||||
// 数量
|
// 数量
|
||||||
String MENGE = jsonObject.getString("MENGE");
|
String MENGE = jsonObject.getString("MENGE");
|
||||||
// 单位
|
// 单位
|
||||||
@ -683,7 +683,7 @@ public class MESToWMSServiceImpl implements MESToWMSService {
|
|||||||
// 自定义领料单行号
|
// 自定义领料单行号
|
||||||
String ZLLITEM = jsonObject.getString("ZLLITEM");
|
String ZLLITEM = jsonObject.getString("ZLLITEM");
|
||||||
// 工单
|
// 工单
|
||||||
String AUFNR = jsonObject.getString("AUFNR");
|
String AUFNR = jsonObject.getString("toOrder");
|
||||||
|
|
||||||
map.put("MATNR", materialSpecname);
|
map.put("MATNR", materialSpecname);
|
||||||
map.put("WERKS", WERKS);
|
map.put("WERKS", WERKS);
|
||||||
@ -696,8 +696,19 @@ public class MESToWMSServiceImpl implements MESToWMSService {
|
|||||||
mapList.add(map);
|
mapList.add(map);
|
||||||
}
|
}
|
||||||
// 出库
|
// 出库
|
||||||
String undoid = toSAPService.StockOutByOrder_new(mapList, "MES", "262");
|
// String undoidOut = toSAPService.StockOutByOrder_new(mapList, "MES", "262");
|
||||||
return AjaxResult.me().setResultObj(null).setSuccess(true).setErrorCode(200).setMessage("执行成功,物料凭证 " + undoid);
|
// 入库
|
||||||
|
String undoidIn = toSAPService.StockOutByOrder_new(mapList, "MES", "261");
|
||||||
|
/*if (StringUtils.isEmpty(undoidIn)) {
|
||||||
|
// 冲销
|
||||||
|
String undo = invoiceService.cancelShipInter(undoidOut, "MES");
|
||||||
|
if (undo == null || undo.isEmpty()) {
|
||||||
|
throw new GlobalException("下发mes失败后冲销失败!");
|
||||||
|
} else {
|
||||||
|
throw new GlobalException("发送到mes失败!");
|
||||||
|
}
|
||||||
|
}*/
|
||||||
|
return AjaxResult.me().setResultObj(null).setSuccess(true).setErrorCode(200).setMessage("执行成功,物料凭证 " + undoidIn);
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* 接收MES请求工单请求
|
* 接收MES请求工单请求
|
||||||
|
Loading…
x
Reference in New Issue
Block a user