Merge branch '0.8.X' of http://49.232.154.205:10100/DeXun/klp-oa into 0.8.X
This commit is contained in:
@@ -16,6 +16,6 @@ public class WmsFurnacePlanLocationItemBo {
|
|||||||
@NotNull(message = "钢卷ID不能为空")
|
@NotNull(message = "钢卷ID不能为空")
|
||||||
private Long coilId;
|
private Long coilId;
|
||||||
|
|
||||||
@NotNull(message = "实际库位不能为空")
|
@NotNull(message = "逻辑库位不能为空")
|
||||||
private Long actualWarehouseId;
|
private Long warehouseId;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -346,6 +346,11 @@ public class WmsMaterialCoilVo extends BaseEntity {
|
|||||||
*/
|
*/
|
||||||
private Integer exclusiveStatus;
|
private Integer exclusiveStatus;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 炉火层级(1=一层,2=二层,3=三层)
|
||||||
|
*/
|
||||||
|
private Integer furnaceLevel;
|
||||||
|
|
||||||
// ========== 发货绑定信息(由发货单明细占用) ==========
|
// ========== 发货绑定信息(由发货单明细占用) ==========
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
package com.klp.domain.vo.anneal;
|
package com.klp.domain.vo.anneal;
|
||||||
|
|
||||||
|
import com.klp.domain.vo.WmsMaterialCoilVo;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 炉火实绩明细视图对象
|
* 炉火实绩明细视图对象
|
||||||
@@ -33,4 +35,12 @@ public class WmsAnnealPerformanceDetailVo {
|
|||||||
private String currentCoilNo;
|
private String currentCoilNo;
|
||||||
|
|
||||||
private BigDecimal netWeight;
|
private BigDecimal netWeight;
|
||||||
|
|
||||||
|
private Long logicWarehouseId;
|
||||||
|
|
||||||
|
private String logicWarehouseName;
|
||||||
|
|
||||||
|
private Integer furnaceLevel;
|
||||||
|
|
||||||
|
private List<WmsMaterialCoilVo> coils;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,15 +1,28 @@
|
|||||||
package com.klp.service.impl;
|
package com.klp.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
|
import com.klp.common.core.domain.PageQuery;
|
||||||
|
import com.klp.common.core.page.TableDataInfo;
|
||||||
import com.klp.domain.bo.WmsAnnealPerformanceBo;
|
import com.klp.domain.bo.WmsAnnealPerformanceBo;
|
||||||
|
import com.klp.domain.bo.WmsMaterialCoilBo;
|
||||||
|
import com.klp.domain.vo.WmsMaterialCoilVo;
|
||||||
import com.klp.domain.vo.anneal.WmsAnnealPerformanceDetailVo;
|
import com.klp.domain.vo.anneal.WmsAnnealPerformanceDetailVo;
|
||||||
import com.klp.domain.vo.anneal.WmsAnnealPerformanceSummaryVo;
|
import com.klp.domain.vo.anneal.WmsAnnealPerformanceSummaryVo;
|
||||||
import com.klp.domain.vo.anneal.WmsAnnealPerformanceVo;
|
import com.klp.domain.vo.anneal.WmsAnnealPerformanceVo;
|
||||||
|
import com.klp.domain.WmsFurnacePlanCoil;
|
||||||
|
import com.klp.domain.WmsWarehouse;
|
||||||
import com.klp.mapper.WmsAnnealPerformanceMapper;
|
import com.klp.mapper.WmsAnnealPerformanceMapper;
|
||||||
|
import com.klp.mapper.WmsFurnacePlanCoilMapper;
|
||||||
|
import com.klp.mapper.WmsWarehouseMapper;
|
||||||
import com.klp.service.IWmsAnnealPerformanceService;
|
import com.klp.service.IWmsAnnealPerformanceService;
|
||||||
|
import com.klp.service.IWmsMaterialCoilService;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.data.domain.Page;
|
||||||
|
import org.springframework.data.domain.PageRequest;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 炉火实绩Service业务层处理
|
* 炉火实绩Service业务层处理
|
||||||
@@ -22,11 +35,112 @@ import java.util.List;
|
|||||||
public class WmsAnnealPerformanceServiceImpl implements IWmsAnnealPerformanceService {
|
public class WmsAnnealPerformanceServiceImpl implements IWmsAnnealPerformanceService {
|
||||||
|
|
||||||
private final WmsAnnealPerformanceMapper performanceMapper;
|
private final WmsAnnealPerformanceMapper performanceMapper;
|
||||||
|
private final WmsFurnacePlanCoilMapper planCoilMapper;
|
||||||
|
private final WmsWarehouseMapper warehouseMapper;
|
||||||
|
private final IWmsMaterialCoilService materialCoilService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public WmsAnnealPerformanceVo queryPerformance(WmsAnnealPerformanceBo bo) {
|
public WmsAnnealPerformanceVo queryPerformance(WmsAnnealPerformanceBo bo) {
|
||||||
WmsAnnealPerformanceSummaryVo summary = performanceMapper.selectSummary(bo);
|
WmsAnnealPerformanceSummaryVo summary = performanceMapper.selectSummary(bo);
|
||||||
List<WmsAnnealPerformanceDetailVo> details = performanceMapper.selectDetails(bo);
|
List<WmsAnnealPerformanceDetailVo> details = performanceMapper.selectDetails(bo);
|
||||||
|
|
||||||
|
if (details != null && !details.isEmpty()) {
|
||||||
|
// 收集所有计划ID
|
||||||
|
List<Long> planIds = details.stream()
|
||||||
|
.map(WmsAnnealPerformanceDetailVo::getPlanId)
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.distinct()
|
||||||
|
.collect(Collectors.toList());
|
||||||
|
|
||||||
|
if (!planIds.isEmpty()) {
|
||||||
|
// 批量查询所有计划的钢卷关联记录
|
||||||
|
List<WmsFurnacePlanCoil> allPlanCoils = planCoilMapper.selectList(
|
||||||
|
new LambdaQueryWrapper<WmsFurnacePlanCoil>()
|
||||||
|
.in(WmsFurnacePlanCoil::getPlanId, planIds)
|
||||||
|
.eq(WmsFurnacePlanCoil::getDelFlag, 0)
|
||||||
|
);
|
||||||
|
|
||||||
|
// 按planId分组
|
||||||
|
Map<Long, List<WmsFurnacePlanCoil>> planCoilsMap = allPlanCoils.stream()
|
||||||
|
.collect(Collectors.groupingBy(WmsFurnacePlanCoil::getPlanId));
|
||||||
|
|
||||||
|
// 收集所有逻辑库区ID
|
||||||
|
Set<Long> allLogicWarehouseIds = allPlanCoils.stream()
|
||||||
|
.map(WmsFurnacePlanCoil::getLogicWarehouseId)
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.collect(Collectors.toSet());
|
||||||
|
|
||||||
|
// 批量查询逻辑库区名称
|
||||||
|
Map<Long, String> logicWarehouseNameMap = new HashMap<>();
|
||||||
|
if (!allLogicWarehouseIds.isEmpty()) {
|
||||||
|
List<WmsWarehouse> warehouses = warehouseMapper.selectBatchIds(allLogicWarehouseIds);
|
||||||
|
for (WmsWarehouse warehouse : warehouses) {
|
||||||
|
logicWarehouseNameMap.put(warehouse.getWarehouseId(), warehouse.getWarehouseName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 收集所有钢卷ID
|
||||||
|
Set<Long> allCoilIds = allPlanCoils.stream()
|
||||||
|
.map(WmsFurnacePlanCoil::getCoilId)
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.collect(Collectors.toSet());
|
||||||
|
|
||||||
|
// 批量查询钢卷信息
|
||||||
|
Map<Long, WmsMaterialCoilVo> coilVoMap = new HashMap<>();
|
||||||
|
if (!allCoilIds.isEmpty()) {
|
||||||
|
WmsMaterialCoilBo coilBo = new WmsMaterialCoilBo();
|
||||||
|
coilBo.setCoilIds(allCoilIds.stream().map(String::valueOf).collect(Collectors.joining(",")));
|
||||||
|
PageQuery pageQuery = new PageQuery();
|
||||||
|
pageQuery.setPageNum(1);
|
||||||
|
pageQuery.setPageSize(Integer.MAX_VALUE);
|
||||||
|
TableDataInfo<WmsMaterialCoilVo> coilPage = materialCoilService.queryPageList(coilBo, pageQuery);
|
||||||
|
if (coilPage != null && coilPage.getRows() != null) {
|
||||||
|
for (WmsMaterialCoilVo coilVo : coilPage.getRows()) {
|
||||||
|
if (coilVo.getCoilId() != null) {
|
||||||
|
coilVoMap.put(coilVo.getCoilId(), coilVo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 处理每个计划
|
||||||
|
for (WmsAnnealPerformanceDetailVo detail : details) {
|
||||||
|
Long planId = detail.getPlanId();
|
||||||
|
List<WmsFurnacePlanCoil> planCoils = planCoilsMap.get(planId);
|
||||||
|
|
||||||
|
if (planCoils == null || planCoils.isEmpty()) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// 为每个钢卷设置逻辑库区ID、层级和钢卷信息
|
||||||
|
List<WmsMaterialCoilVo> coilVos = new ArrayList<>();
|
||||||
|
for (WmsFurnacePlanCoil planCoil : planCoils) {
|
||||||
|
Long coilId = planCoil.getCoilId();
|
||||||
|
if (coilId == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
WmsMaterialCoilVo coilVo = coilVoMap.get(coilId);
|
||||||
|
if (coilVo == null) {
|
||||||
|
coilVo = new WmsMaterialCoilVo();
|
||||||
|
coilVo.setCoilId(coilId);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 设置逻辑库区ID和层级(每个钢卷可能不同)
|
||||||
|
if (planCoil.getLogicWarehouseId() != null) {
|
||||||
|
coilVo.setWarehouseId(planCoil.getLogicWarehouseId());
|
||||||
|
coilVo.setWarehouseName(logicWarehouseNameMap.get(planCoil.getLogicWarehouseId()));
|
||||||
|
}
|
||||||
|
// 设置炉火层级
|
||||||
|
coilVo.setFurnaceLevel(planCoil.getFurnaceLevel());
|
||||||
|
|
||||||
|
coilVos.add(coilVo);
|
||||||
|
}
|
||||||
|
detail.setCoils(coilVos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
WmsAnnealPerformanceVo vo = new WmsAnnealPerformanceVo();
|
WmsAnnealPerformanceVo vo = new WmsAnnealPerformanceVo();
|
||||||
vo.setSummary(summary);
|
vo.setSummary(summary);
|
||||||
vo.setDetails(details);
|
vo.setDetails(details);
|
||||||
|
|||||||
@@ -220,6 +220,7 @@ public class WmsFurnacePlanServiceImpl implements IWmsFurnacePlanService {
|
|||||||
}
|
}
|
||||||
// 设置逻辑库区名称
|
// 设置逻辑库区名称
|
||||||
if (item.getLogicWarehouseId() != null) {
|
if (item.getLogicWarehouseId() != null) {
|
||||||
|
item.setLogicWarehouseId(item.getLogicWarehouseId());
|
||||||
item.setLogicWarehouseName(logicWarehouseMap.get(item.getLogicWarehouseId()));
|
item.setLogicWarehouseName(logicWarehouseMap.get(item.getLogicWarehouseId()));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -317,17 +318,17 @@ public class WmsFurnacePlanServiceImpl implements IWmsFurnacePlanService {
|
|||||||
throw new ServiceException("计划未绑定钢卷");
|
throw new ServiceException("计划未绑定钢卷");
|
||||||
}
|
}
|
||||||
if (locations == null || locations.isEmpty()) {
|
if (locations == null || locations.isEmpty()) {
|
||||||
throw new ServiceException("请先分配实际库位");
|
throw new ServiceException("请先分配逻辑库位");
|
||||||
}
|
}
|
||||||
java.util.Map<Long, Long> locationMap = locations.stream()
|
java.util.Map<Long, Long> locationMap = locations.stream()
|
||||||
.collect(Collectors.toMap(com.klp.domain.bo.WmsFurnacePlanLocationItemBo::getCoilId,
|
.collect(Collectors.toMap(com.klp.domain.bo.WmsFurnacePlanLocationItemBo::getCoilId,
|
||||||
com.klp.domain.bo.WmsFurnacePlanLocationItemBo::getActualWarehouseId, (a, b) -> a));
|
com.klp.domain.bo.WmsFurnacePlanLocationItemBo::getWarehouseId, (a, b) -> a));
|
||||||
for (WmsFurnacePlanCoilVo coil : coils) {
|
for (WmsFurnacePlanCoilVo coil : coils) {
|
||||||
Long targetLocation = locationMap.get(coil.getCoilId());
|
Long targetLocation = locationMap.get(coil.getCoilId());
|
||||||
if (targetLocation == null) {
|
if (targetLocation == null) {
|
||||||
throw new ServiceException("钢卷" + coil.getEnterCoilNo() + "未分配库位");
|
throw new ServiceException("钢卷" + coil.getEnterCoilNo() + "未分配库位");
|
||||||
}
|
}
|
||||||
occupyActualWarehouse(coil.getCoilId(), targetLocation);
|
occupyWarehouse(planId, coil.getCoilId(), targetLocation);
|
||||||
}
|
}
|
||||||
Date now = new Date();
|
Date now = new Date();
|
||||||
WmsFurnacePlan update = new WmsFurnacePlan();
|
WmsFurnacePlan update = new WmsFurnacePlan();
|
||||||
@@ -357,25 +358,36 @@ public class WmsFurnacePlanServiceImpl implements IWmsFurnacePlanService {
|
|||||||
.set(WmsMaterialCoil::getExclusiveStatus, 2));
|
.set(WmsMaterialCoil::getExclusiveStatus, 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void occupyActualWarehouse(Long coilId, Long actualWarehouseId) {
|
private void occupyWarehouse(Long planId, Long coilId, Long warehouseId) {
|
||||||
if (actualWarehouseId == null) {
|
if (warehouseId == null) {
|
||||||
throw new ServiceException("实际库位不能为空");
|
throw new ServiceException("逻辑库位不能为空");
|
||||||
}
|
}
|
||||||
WmsActualWarehouse warehouse = actualWarehouseMapper.selectById(actualWarehouseId);
|
WmsWarehouse warehouse = warehouseMapper.selectById(warehouseId);
|
||||||
if (warehouse == null || warehouse.getDelFlag() != null && warehouse.getDelFlag() == 1) {
|
if (warehouse == null || warehouse.getDelFlag() != null && warehouse.getDelFlag() == 1) {
|
||||||
throw new ServiceException("实际库位不存在");
|
throw new ServiceException("逻辑库位不存在");
|
||||||
}
|
}
|
||||||
if (warehouse.getIsEnabled() != null && warehouse.getIsEnabled() == 0) {
|
|
||||||
throw new ServiceException("实际库位已被占用");
|
WmsWarehouse updateWarehouse = new WmsWarehouse();
|
||||||
}
|
updateWarehouse.setWarehouseId(warehouseId);
|
||||||
WmsActualWarehouse updateWarehouse = new WmsActualWarehouse();
|
|
||||||
updateWarehouse.setActualWarehouseId(actualWarehouseId);
|
|
||||||
updateWarehouse.setIsEnabled(0);
|
updateWarehouse.setIsEnabled(0);
|
||||||
actualWarehouseMapper.updateById(updateWarehouse);
|
warehouseMapper.updateById(updateWarehouse);
|
||||||
|
|
||||||
|
// wmsfurnace_plan_coil也要插入这个去向的逻辑库区
|
||||||
|
WmsFurnacePlanCoil wmsFurnacePlanCoil = planCoilMapper.selectOne(Wrappers.<WmsFurnacePlanCoil>lambdaQuery()
|
||||||
|
.eq(WmsFurnacePlanCoil::getPlanId, planId)
|
||||||
|
.eq(WmsFurnacePlanCoil::getCoilId, coilId)
|
||||||
|
//逻辑删除
|
||||||
|
.eq(WmsFurnacePlanCoil::getDelFlag, 0));
|
||||||
|
|
||||||
|
if (wmsFurnacePlanCoil != null && wmsFurnacePlanCoil.getPlanCoilId() != null) {
|
||||||
|
planCoilMapper.update(null, Wrappers.<WmsFurnacePlanCoil>lambdaUpdate()
|
||||||
|
.eq(WmsFurnacePlanCoil::getPlanCoilId, wmsFurnacePlanCoil.getPlanCoilId())
|
||||||
|
.set(WmsFurnacePlanCoil::getLogicWarehouseId, warehouseId));
|
||||||
|
}
|
||||||
|
|
||||||
WmsMaterialCoil updateCoil = new WmsMaterialCoil();
|
WmsMaterialCoil updateCoil = new WmsMaterialCoil();
|
||||||
updateCoil.setCoilId(coilId);
|
updateCoil.setCoilId(coilId);
|
||||||
updateCoil.setActualWarehouseId(actualWarehouseId);
|
updateCoil.setWarehouseId(warehouseId);
|
||||||
updateCoil.setExclusiveStatus(0);
|
updateCoil.setExclusiveStatus(0);
|
||||||
materialCoilMapper.updateById(updateCoil);
|
materialCoilMapper.updateById(updateCoil);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,16 +39,11 @@
|
|||||||
p.target_furnace_id AS targetFurnaceId,
|
p.target_furnace_id AS targetFurnaceId,
|
||||||
f.furnace_name AS targetFurnaceName,
|
f.furnace_name AS targetFurnaceName,
|
||||||
p.actual_start_time AS actualStartTime,
|
p.actual_start_time AS actualStartTime,
|
||||||
p.end_time AS endTime,
|
p.end_time AS endTime
|
||||||
mc.coil_id AS coilId,
|
|
||||||
mc.enter_coil_no AS enterCoilNo,
|
|
||||||
mc.current_coil_no AS currentCoilNo,
|
|
||||||
mc.net_weight AS netWeight
|
|
||||||
FROM wms_furnace_plan p
|
FROM wms_furnace_plan p
|
||||||
INNER JOIN wms_furnace_plan_coil pc ON pc.plan_id = p.plan_id AND pc.del_flag = 0
|
|
||||||
INNER JOIN wms_material_coil mc ON mc.coil_id = pc.coil_id AND mc.del_flag = 0
|
|
||||||
LEFT JOIN wms_furnace f ON f.furnace_id = p.target_furnace_id
|
LEFT JOIN wms_furnace f ON f.furnace_id = p.target_furnace_id
|
||||||
<include refid="AnnealPerformanceWhere" />
|
<include refid="AnnealPerformanceWhere" />
|
||||||
|
GROUP BY p.plan_id, p.plan_no, p.target_furnace_id, f.furnace_name, p.actual_start_time, p.end_time
|
||||||
ORDER BY p.actual_start_time DESC, p.plan_no DESC
|
ORDER BY p.actual_start_time DESC, p.plan_no DESC
|
||||||
</select>
|
</select>
|
||||||
</mapper>
|
</mapper>
|
||||||
|
|||||||
Reference in New Issue
Block a user