|
|
|
@ -17,6 +17,9 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
|
|
|
|
import javax.validation.Valid;
|
|
|
|
|
import java.text.DateFormat;
|
|
|
|
|
import java.text.ParseException;
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
|
|
import jnpf.annotation.JnpfField;
|
|
|
|
@ -525,4 +528,72 @@ public class YysMonthlyProductionController {
|
|
|
|
|
return ActionResult.success(yysMonthlyProductionMap);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@PostMapping("/mrp/{month}")
|
|
|
|
|
@Operation(summary = "MRP运算")
|
|
|
|
|
public ActionResult MRP(@PathVariable String month) {
|
|
|
|
|
if (StringUtil.isNotEmpty(month)) {
|
|
|
|
|
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM");
|
|
|
|
|
try {
|
|
|
|
|
format.parse(month);
|
|
|
|
|
} catch (ParseException e) {
|
|
|
|
|
return ActionResult.fail("月份格式不正确");
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
return ActionResult.fail("月份不能为空");
|
|
|
|
|
}
|
|
|
|
|
List<YysMonthlyProductionEntity> unMPRList = yysMonthlyProductionService.getUnMPRList(month);
|
|
|
|
|
if(unMPRList.size() == 0) return ActionResult.fail("没有需要生成MRP的月度生产计划");
|
|
|
|
|
// 获取没有生成MRP的月度生产计划
|
|
|
|
|
|
|
|
|
|
Set<Map<String, Object>> collect = unMPRList.stream().map(entity -> {
|
|
|
|
|
Map<String, Object> map = new HashMap<>();
|
|
|
|
|
map.put("productId", entity.getProductId());
|
|
|
|
|
return map;
|
|
|
|
|
}).collect(Collectors.toSet());
|
|
|
|
|
|
|
|
|
|
// 根据计划生成的物料 获取BOM清单
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 计算一个计划的物料需求量
|
|
|
|
|
|
|
|
|
|
// 循环计划
|
|
|
|
|
|
|
|
|
|
// 所需物料 合并同类项
|
|
|
|
|
|
|
|
|
|
// 获取已排产未生产的物料
|
|
|
|
|
|
|
|
|
|
// 计算未生产的物料需求量
|
|
|
|
|
|
|
|
|
|
// 与所需物料编码 交集 求同类需求量
|
|
|
|
|
|
|
|
|
|
// 根据同类需求量 获取库存量
|
|
|
|
|
|
|
|
|
|
// 计算同类需求量 采购未入库的物料量
|
|
|
|
|
|
|
|
|
|
// 计算 同类需求量 - 库存量 - 采购未入库的物料量 = 需要采购的物料量
|
|
|
|
|
|
|
|
|
|
// 插入物料需求计划表中
|
|
|
|
|
|
|
|
|
|
// 更新计划表中物料需求计划ID
|
|
|
|
|
|
|
|
|
|
// 完结
|
|
|
|
|
|
|
|
|
|
return ActionResult.success("成功");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@PostMapping("/scheduling")
|
|
|
|
|
@Operation(summary = "生产排产")
|
|
|
|
|
public ActionResult ProductionScheduling(@RequestBody YysMonthlyProductionStrategyVO strategyVO) {
|
|
|
|
|
|
|
|
|
|
// 获取月度生产计划
|
|
|
|
|
|
|
|
|
|
// 根据计划生成的物料 获取BOM清单
|
|
|
|
|
|
|
|
|
|
// 计算一个计划的物料需求量
|
|
|
|
|
|
|
|
|
|
// 循环计划
|
|
|
|
|
|
|
|
|
|
return ActionResult.success("成功");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|