Merge remote-tracking branch 'origin/0.8.X' into 0.8.X
This commit is contained in:
@@ -1,8 +1,11 @@
|
||||
package com.klp.controller;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Arrays;
|
||||
import java.lang.reflect.Method;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
|
||||
import com.klp.domain.bo.WmsSchedulePlanDetailBo;
|
||||
import com.klp.domain.vo.*;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.validation.constraints.*;
|
||||
@@ -18,10 +21,14 @@ import com.klp.common.core.validate.AddGroup;
|
||||
import com.klp.common.core.validate.EditGroup;
|
||||
import com.klp.common.enums.BusinessType;
|
||||
import com.klp.common.utils.poi.ExcelUtil;
|
||||
import com.klp.domain.vo.WmsProductionLineVo;
|
||||
import com.klp.domain.bo.WmsProductionLineBo;
|
||||
import com.klp.service.IWmsProductionLineService;
|
||||
import com.klp.common.core.page.TableDataInfo;
|
||||
import com.klp.service.IWmsSchedulePlanDetailService;
|
||||
import com.klp.service.IWmsOrderService;
|
||||
import com.klp.service.IWmsOrderDetailService;
|
||||
import com.klp.service.IWmsProductService;
|
||||
import com.klp.service.IWmsSchedulePlanService;
|
||||
|
||||
/**
|
||||
* 产线
|
||||
@@ -36,6 +43,11 @@ import com.klp.common.core.page.TableDataInfo;
|
||||
public class WmsProductionLineController extends BaseController {
|
||||
|
||||
private final IWmsProductionLineService iWmsProductionLineService;
|
||||
private final IWmsSchedulePlanDetailService iWmsSchedulePlanDetailService;
|
||||
private final IWmsOrderService iWmsOrderService;
|
||||
private final IWmsOrderDetailService iWmsOrderDetailService;
|
||||
private final IWmsProductService iWmsProductService;
|
||||
private final IWmsSchedulePlanService iWmsSchedulePlanService;
|
||||
|
||||
/**
|
||||
* 查询产线列表
|
||||
@@ -97,4 +109,77 @@ public class WmsProductionLineController extends BaseController {
|
||||
@PathVariable Long[] lineIds) {
|
||||
return toAjax(iWmsProductionLineService.deleteWithValidByIds(Arrays.asList(lineIds), true));
|
||||
}
|
||||
|
||||
/**
|
||||
* 产线甘特图接口
|
||||
* @param lineId 产线ID
|
||||
* @return 甘特图数据
|
||||
*/
|
||||
@GetMapping("/gantt")
|
||||
public R<?> gantt(@RequestParam Long lineId) {
|
||||
// 查询排产计划明细(按产线过滤,返回所有订单的任务)
|
||||
WmsSchedulePlanDetailBo detailBo = new WmsSchedulePlanDetailBo();
|
||||
detailBo.setLineId(lineId);
|
||||
List<WmsSchedulePlanDetailVo> allDetails = iWmsSchedulePlanDetailService.queryList(detailBo);
|
||||
// 查询产品、订单信息,补充remark
|
||||
Set<Long> orderIdSet = new HashSet<>();
|
||||
for (WmsSchedulePlanDetailVo detail : allDetails) {
|
||||
// 查询产品名和订单编号
|
||||
String productName = null;
|
||||
if (detail.getProductId() != null) {
|
||||
WmsProductVo product = iWmsProductService.queryById(detail.getProductId());
|
||||
if (product != null) {
|
||||
productName = product.getProductName();
|
||||
}
|
||||
}
|
||||
String orderCode = null;
|
||||
Long orderId = null;
|
||||
if (detail.getPlanId() != null) {
|
||||
WmsSchedulePlanVo planVo = iWmsSchedulePlanService.queryById(detail.getPlanId());
|
||||
if (planVo != null && planVo.getOrderId() != null) {
|
||||
orderId = planVo.getOrderId();
|
||||
WmsOrderVo orderVo = iWmsOrderService.queryById(orderId);
|
||||
if (orderVo != null) {
|
||||
orderCode = orderVo.getOrderCode();
|
||||
}
|
||||
}
|
||||
}
|
||||
// 设置remark为“订单编号-产品名”
|
||||
String remark = (orderCode != null ? orderCode : "") + (productName != null ? ("-" + productName) : "");
|
||||
detail.setRemark(remark);
|
||||
// 查询产线日产能
|
||||
BigDecimal capacity = null;
|
||||
if (detail.getLineId() != null) {
|
||||
WmsProductionLineVo lineVo = iWmsProductionLineService.queryById(detail.getLineId());
|
||||
if (lineVo != null) {
|
||||
capacity = lineVo.getCapacity();
|
||||
}
|
||||
}
|
||||
// 计算天数和总产能
|
||||
BigDecimal totalCapacity = null;
|
||||
int days = 0;
|
||||
if (detail.getStartDate() != null && detail.getEndDate() != null) {
|
||||
long diff = detail.getEndDate().getTime() - detail.getStartDate().getTime();
|
||||
days = (int) (diff / (1000 * 3600 * 24)) + 1;
|
||||
if (capacity != null) {
|
||||
totalCapacity = capacity.multiply(new BigDecimal(days));
|
||||
}
|
||||
}
|
||||
// 计划生产数量
|
||||
BigDecimal planQuantity = detail.getQuantity();
|
||||
|
||||
// 直接set字段,无需反射
|
||||
detail.setCapacity(capacity);
|
||||
detail.setTotalCapacity(totalCapacity);
|
||||
detail.setDays(days);
|
||||
detail.setPlanQuantity(planQuantity);
|
||||
}
|
||||
// 查询所有相关订单信息
|
||||
List<WmsOrderVo> orderList = new ArrayList<>();
|
||||
// 返回结构
|
||||
return R.ok(new HashMap<String, Object>() {{
|
||||
put("tasks", allDetails);
|
||||
put("orders", orderList);
|
||||
}});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,6 +36,13 @@ public class WmsPurchasePlanController extends BaseController {
|
||||
|
||||
private final IWmsPurchasePlanService iWmsPurchasePlanService;
|
||||
|
||||
/**
|
||||
* 新增采购计划(含明细)
|
||||
*/
|
||||
@PostMapping("/addWithDetails")
|
||||
public R<Void> addPurchasePlan(@RequestBody WmsPurchasePlanVo planVo) {
|
||||
return toAjax(iWmsPurchasePlanService.insertWithDetails(planVo));
|
||||
}
|
||||
/**
|
||||
* 根据订单ID生成推荐采购计划(只返回,不落库)
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user