|
@@ -31,49 +31,63 @@ public class AdjustUtil {
|
|
* @param type
|
|
* @param type
|
|
*/
|
|
*/
|
|
public static void nonSegAdjust(List<MaterialReportDetails> reports, List<LiKuResourcePool> pools, List<CompareHistory> compareList,String type){
|
|
public static void nonSegAdjust(List<MaterialReportDetails> reports, List<LiKuResourcePool> pools, List<CompareHistory> compareList,String type){
|
|
- for (MaterialReportDetails report:reports) {
|
|
|
|
- String code = report.getMaterialCode();
|
|
|
|
- String exCode = report.getExtendedCoding();
|
|
|
|
- BigDecimal applyRemain = BigDecimal.valueOf(report.getNumberOfApplications());//剩余物资需求数量
|
|
|
|
- BigDecimal applyTotal = BigDecimal.valueOf(report.getTotal());//总需求数量
|
|
|
|
- BigDecimal applyLiku = BigDecimal.valueOf(report.getNumberOfNiches());//利库数量
|
|
|
|
- //如果总需求数量等于利库数量则不利库
|
|
|
|
- if (applyTotal.compareTo(applyLiku) == 0) {
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
- for (LiKuResourcePool pool:pools) {
|
|
|
|
- String poolCode = pool.getMaterialCode();
|
|
|
|
- String poExCode = pool.getExtendedCoding();
|
|
|
|
- BigDecimal poolRemain = BigDecimal.valueOf(pool.getRemaining());//利库剩余库存数量
|
|
|
|
- BigDecimal poolLiku = BigDecimal.valueOf(pool.getNumberOfNiches());//利库数量
|
|
|
|
- if (code.equals(poolCode) && exCode.equals(poExCode) && poolRemain.compareTo(BigDecimal.ZERO) != 0) {
|
|
|
|
- BigDecimal likuAmount;//本次利库数量
|
|
|
|
- if(applyRemain.compareTo(poolRemain) >= 0){
|
|
|
|
- likuAmount = poolRemain;
|
|
|
|
- }else {
|
|
|
|
- likuAmount = applyRemain;
|
|
|
|
|
|
+ try {
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ for (MaterialReportDetails report : reports) {
|
|
|
|
+ String code = report.getMaterialCode();
|
|
|
|
+ String exCode = report.getExtendedCoding();
|
|
|
|
+ BigDecimal applyRemain = BigDecimal.valueOf(report.getNumberOfApplications());//剩余物资需求数量
|
|
|
|
+ BigDecimal applyTotal = BigDecimal.valueOf(report.getTotal());//总需求数量
|
|
|
|
+ BigDecimal applyLiku = BigDecimal.valueOf(report.getNumberOfNiches());//利库数量
|
|
|
|
+ //如果总需求数量等于利库数量则不利库
|
|
|
|
+ if (applyTotal.compareTo(applyLiku) == 0) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ for (LiKuResourcePool pool : pools) {
|
|
|
|
+ String poolCode = pool.getMaterialCode();
|
|
|
|
+ String poExCode = pool.getExtendedCoding();
|
|
|
|
+ Double remaining = pool.getRemaining();
|
|
|
|
+ if (null == remaining) {
|
|
|
|
+ remaining = 0.0;
|
|
}
|
|
}
|
|
- //修改利库资源池的 剩余库存数量和利库数量
|
|
|
|
- pool.setRemaining(poolRemain.subtract(likuAmount).setScale(2, ROUND_HALF_UP).doubleValue());
|
|
|
|
- pool.setNumberOfNiches(poolLiku.add(likuAmount).setScale(2, ROUND_HALF_UP).doubleValue());
|
|
|
|
- //修改物料申请的 利库数量和剩余申请数量
|
|
|
|
- applyRemain = applyRemain.subtract(likuAmount).setScale(2, ROUND_HALF_UP);
|
|
|
|
- applyLiku = applyLiku.add(likuAmount).setScale(2, ROUND_HALF_UP);
|
|
|
|
- report.setNumberOfNiches(applyLiku.doubleValue());
|
|
|
|
- report.setNumberOfApplications(applyRemain.doubleValue());
|
|
|
|
- //记录利库详细信息
|
|
|
|
- CompareHistory compareHistory = new CompareHistory();
|
|
|
|
- compareHistory.setLiKuId(pool.getId());
|
|
|
|
- compareHistory.setMaterialId(report.getId());
|
|
|
|
- compareHistory.setComparisonType(type);
|
|
|
|
- compareHistory.setNumberNiches(likuAmount.doubleValue());
|
|
|
|
-
|
|
|
|
- compareList.add(compareHistory);
|
|
|
|
- if (report.getNumberOfNiches().compareTo(report.getTotal()) == 0) {
|
|
|
|
- break;
|
|
|
|
|
|
+ Double numberOfNiches = pool.getNumberOfNiches();
|
|
|
|
+ if (null == numberOfNiches) {
|
|
|
|
+ numberOfNiches = 0.0;
|
|
|
|
+ }
|
|
|
|
+ BigDecimal poolRemain = BigDecimal.valueOf(remaining);//利库剩余库存数量
|
|
|
|
+ BigDecimal poolLiku = BigDecimal.valueOf(numberOfNiches);//利库数量
|
|
|
|
+ if (code.equals(poolCode) && exCode.equals(poExCode) && poolRemain.compareTo(BigDecimal.ZERO) != 0) {
|
|
|
|
+ BigDecimal likuAmount;//本次利库数量
|
|
|
|
+ if (applyRemain.compareTo(poolRemain) >= 0) {
|
|
|
|
+ likuAmount = poolRemain;
|
|
|
|
+ } else {
|
|
|
|
+ likuAmount = applyRemain;
|
|
|
|
+ }
|
|
|
|
+ //修改利库资源池的 剩余库存数量和利库数量
|
|
|
|
+ pool.setRemaining(poolRemain.subtract(likuAmount).setScale(2, ROUND_HALF_UP).doubleValue());
|
|
|
|
+ pool.setNumberOfNiches(poolLiku.add(likuAmount).setScale(2, ROUND_HALF_UP).doubleValue());
|
|
|
|
+ //修改物料申请的 利库数量和剩余申请数量
|
|
|
|
+ applyRemain = applyRemain.subtract(likuAmount).setScale(2, ROUND_HALF_UP);
|
|
|
|
+ applyLiku = applyLiku.add(likuAmount).setScale(2, ROUND_HALF_UP);
|
|
|
|
+ report.setNumberOfNiches(applyLiku.doubleValue());
|
|
|
|
+ report.setNumberOfApplications(applyRemain.doubleValue());
|
|
|
|
+ //记录利库详细信息
|
|
|
|
+ CompareHistory compareHistory = new CompareHistory();
|
|
|
|
+ compareHistory.setLiKuId(pool.getId());
|
|
|
|
+ compareHistory.setMaterialId(report.getId());
|
|
|
|
+ compareHistory.setComparisonType(type);
|
|
|
|
+ compareHistory.setNumberNiches(likuAmount.doubleValue());
|
|
|
|
+
|
|
|
|
+ compareList.add(compareHistory);
|
|
|
|
+ if (report.getNumberOfNiches().compareTo(report.getTotal()) == 0) {
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ e.printStackTrace();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|