refactor(mes): 重构生产计划监控功能

- 修改接口名称和返回类型:queryMoritorPageList -> queryMoritorList,返回类型从 TableDataInfo 改为 List
- 新增 PlanMonitorVo 和 ShiftGroupVo 类用于监控数据展示
- 优化前端监控页面,按机台和班次分组展示计划信息
- 重构后端查询逻辑,按时间区间参数查询监控数据
- 更新数据库查询语句,使用 WITH 子句进行预处理
master
zch 2 days ago
parent 61d39f6a4f
commit 347c6e2e30

@ -1,29 +1,31 @@
package org.dromara.mes.controller; package org.dromara.mes.controller;
import java.util.List;
import lombok.RequiredArgsConstructor;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.constraints.*;
import cn.dev33.satoken.annotation.SaCheckPermission; import cn.dev33.satoken.annotation.SaCheckPermission;
import org.dromara.mes.domain.ProdBaseRouteProcess; import jakarta.servlet.http.HttpServletResponse;
import org.dromara.mes.domain.vo.MesProductPlanEditVo; import jakarta.validation.constraints.NotEmpty;
import org.dromara.mes.service.IProdBaseRouteProcessService; import jakarta.validation.constraints.NotNull;
import org.springframework.web.bind.annotation.*; import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.dromara.common.idempotent.annotation.RepeatSubmit;
import org.dromara.common.log.annotation.Log;
import org.dromara.common.web.core.BaseController;
import org.dromara.common.mybatis.core.page.PageQuery;
import org.dromara.common.core.domain.R; import org.dromara.common.core.domain.R;
import org.dromara.common.core.validate.AddGroup; import org.dromara.common.core.validate.AddGroup;
import org.dromara.common.core.validate.EditGroup; import org.dromara.common.core.validate.EditGroup;
import org.dromara.common.log.enums.BusinessType;
import org.dromara.common.excel.utils.ExcelUtil; import org.dromara.common.excel.utils.ExcelUtil;
import org.dromara.mes.domain.vo.ProdPlanInfoVo; import org.dromara.common.idempotent.annotation.RepeatSubmit;
import org.dromara.common.log.annotation.Log;
import org.dromara.common.log.enums.BusinessType;
import org.dromara.common.mybatis.core.page.PageQuery;
import org.dromara.common.mybatis.core.page.TableDataInfo;
import org.dromara.common.web.core.BaseController;
import org.dromara.mes.domain.ProdBaseRouteProcess;
import org.dromara.mes.domain.bo.ProdPlanInfoBo; import org.dromara.mes.domain.bo.ProdPlanInfoBo;
import org.dromara.mes.domain.vo.MesProductPlanEditVo;
import org.dromara.mes.domain.vo.PlanMonitorVo;
import org.dromara.mes.domain.vo.ProdPlanInfoVo;
import org.dromara.mes.service.IProdBaseRouteProcessService;
import org.dromara.mes.service.IProdPlanInfoService; import org.dromara.mes.service.IProdPlanInfoService;
import org.dromara.common.mybatis.core.page.TableDataInfo; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/** /**
* *
@ -174,12 +176,12 @@ public class ProdPlanInfoController extends BaseController {
} }
/** /**
* * ()
*/ */
@SaCheckPermission("mes:planInfo:list") @SaCheckPermission("mes:planInfo:list")
@GetMapping("/queryMoritorPageList") @GetMapping("/queryMoritorList")
public TableDataInfo<ProdPlanInfoVo> queryMoritorPageList(ProdPlanInfoBo bo, PageQuery pageQuery) { public R<List<PlanMonitorVo>> queryMoritorList(ProdPlanInfoBo bo) {
return prodPlanInfoService.queryMoritorPageList(bo, pageQuery); return R.ok(prodPlanInfoService.queryMoritorList(bo));
} }
} }

@ -0,0 +1,26 @@
package org.dromara.mes.domain.vo;
import lombok.Data;
import java.util.List;
/**
* -
*/
@Data
public class PlanMonitorVo {
/**
* ID
*/
private Long machineId;
/**
*
*/
private String machineName;
/**
*
*/
private List<ShiftGroupVo> shifts;
}

@ -0,0 +1,26 @@
package org.dromara.mes.domain.vo;
import lombok.Data;
import java.util.List;
/**
*
*/
@Data
public class ShiftGroupVo {
/**
* ID
*/
private Long shiftId;
/**
*
*/
private String shiftName;
/**
*
*/
private List<ProdPlanInfoVo> plans;
}

@ -4,12 +4,11 @@ import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.toolkit.Constants; import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.dromara.mes.domain.ProdOrderInfo; import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
import org.dromara.mes.domain.ProdPlanInfo; import org.dromara.mes.domain.ProdPlanInfo;
import org.dromara.mes.domain.bo.ProdPlanInfoBo; import org.dromara.mes.domain.bo.ProdPlanInfoBo;
import org.dromara.mes.domain.vo.ProdOrderInfoVo; import org.dromara.mes.domain.vo.PlanMonitorVo;
import org.dromara.mes.domain.vo.ProdPlanInfoVo; import org.dromara.mes.domain.vo.ProdPlanInfoVo;
import org.dromara.common.mybatis.core.mapper.BaseMapperPlus;
import java.util.List; import java.util.List;
@ -48,10 +47,8 @@ public interface ProdPlanInfoMapper extends BaseMapperPlus<ProdPlanInfo, ProdPla
/** /**
* * ()
* @param page
* @param queryWrapper
* @return
*/ */
public Page<ProdPlanInfoVo> queryMoritorPageList(@Param("page") Page<ProdPlanInfoVo> page, @Param("tableName")String tableName,@Param(Constants.WRAPPER) Wrapper<ProdPlanInfo> queryWrapper); List<PlanMonitorVo> queryMoritorList(@Param("tableName") String tableName,
@Param(Constants.WRAPPER) Wrapper<ProdPlanInfo> queryWrapper);
} }

@ -1,6 +1,7 @@
package org.dromara.mes.service; package org.dromara.mes.service;
import org.dromara.mes.domain.vo.MesProductPlanEditVo; import org.dromara.mes.domain.vo.MesProductPlanEditVo;
import org.dromara.mes.domain.vo.PlanMonitorVo;
import org.dromara.mes.domain.vo.ProdPlanInfoVo; import org.dromara.mes.domain.vo.ProdPlanInfoVo;
import org.dromara.mes.domain.bo.ProdPlanInfoBo; import org.dromara.mes.domain.bo.ProdPlanInfoBo;
import org.dromara.common.mybatis.core.page.TableDataInfo; import org.dromara.common.mybatis.core.page.TableDataInfo;
@ -101,11 +102,9 @@ public interface IProdPlanInfoService {
Boolean issuePlanByPlanIds(Long workshopId, List<Long> planIds); Boolean issuePlanByPlanIds(Long workshopId, List<Long> planIds);
/** /**
* * ()
* * @param bo
* @param bo * @return
* @param pageQuery
* @return
*/ */
TableDataInfo<ProdPlanInfoVo> queryMoritorPageList(ProdPlanInfoBo bo, PageQuery pageQuery); List<PlanMonitorVo> queryMoritorList(ProdPlanInfoBo bo);
} }

@ -1,29 +1,31 @@
package org.dromara.mes.service.impl; package org.dromara.mes.service.impl;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.yulichang.toolkit.JoinWrappers;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import lombok.RequiredArgsConstructor;
import org.dromara.common.constant.DatabaseConstants; import org.dromara.common.constant.DatabaseConstants;
import org.dromara.common.core.exception.ServiceException; import org.dromara.common.core.exception.ServiceException;
import org.dromara.common.core.utils.MapstructUtils; import org.dromara.common.core.utils.MapstructUtils;
import org.dromara.common.core.utils.StringUtils; import org.dromara.common.core.utils.StringUtils;
import org.dromara.common.core.utils.uuid.Seq; import org.dromara.common.core.utils.uuid.Seq;
import org.dromara.common.mapper.DynamicBaseSqlMapper; import org.dromara.common.mapper.DynamicBaseSqlMapper;
import org.dromara.common.mybatis.core.page.TableDataInfo;
import org.dromara.common.mybatis.core.page.PageQuery; import org.dromara.common.mybatis.core.page.PageQuery;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import org.dromara.common.mybatis.core.page.TableDataInfo;
import com.github.yulichang.toolkit.JoinWrappers; import org.dromara.mes.domain.ProdPlanInfo;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import lombok.RequiredArgsConstructor;
import org.dromara.mes.domain.BaseShiftInfo;
import org.dromara.mes.domain.vo.MesProductPlanEditVo;
import org.springframework.stereotype.Service;
import org.dromara.mes.domain.bo.ProdPlanInfoBo; import org.dromara.mes.domain.bo.ProdPlanInfoBo;
import org.dromara.mes.domain.vo.MesProductPlanEditVo;
import org.dromara.mes.domain.vo.PlanMonitorVo;
import org.dromara.mes.domain.vo.ProdPlanInfoVo; import org.dromara.mes.domain.vo.ProdPlanInfoVo;
import org.dromara.mes.domain.ProdPlanInfo;
import org.dromara.mes.mapper.ProdPlanInfoMapper; import org.dromara.mes.mapper.ProdPlanInfoMapper;
import org.dromara.mes.service.IProdPlanInfoService; import org.dromara.mes.service.IProdPlanInfoService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ObjectUtils; import org.springframework.util.ObjectUtils;
import java.util.*; import java.util.Collection;
import java.util.List;
import java.util.Map;
/** /**
* Service * Service
@ -284,18 +286,18 @@ public class ProdPlanInfoServiceImpl implements IProdPlanInfoService {
} }
/** /**
* * ()
*
* @param bo
* @param pageQuery
* @return
*/ */
@Override @Override
public TableDataInfo<ProdPlanInfoVo> queryMoritorPageList(ProdPlanInfoBo bo, PageQuery pageQuery) { public List<PlanMonitorVo> queryMoritorList(ProdPlanInfoBo bo) {
MPJLambdaWrapper<ProdPlanInfo> lqw = buildQW(bo); // 校验时间区间参数
Map<String, Object> params = bo.getParams();
if (ObjectUtils.isEmpty(params.get("monitorBeginTime")) || ObjectUtils.isEmpty(params.get("monitorEndTime"))) {
throw new ServiceException("时间区间不能为空");
}
String tableName = getPlanInfoTableName(bo.getWorkshopId()); String tableName = getPlanInfoTableName(bo.getWorkshopId());
Page<ProdPlanInfoVo> result = baseMapper.queryMoritorPageList(pageQuery.build(), tableName, lqw); return baseMapper.queryMoritorList(tableName, buildQW(bo));
return TableDataInfo.build(result);
} }
private MPJLambdaWrapper<ProdPlanInfo> buildQW(ProdPlanInfoBo bo) { private MPJLambdaWrapper<ProdPlanInfo> buildQW(ProdPlanInfoBo bo) {

@ -169,38 +169,105 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
order by mpp.dispatch_code,mpp.process_order order by mpp.dispatch_code,mpp.process_order
</select> </select>
<select id="queryMoritorPageList" parameterType="ProdPlanInfoBo" resultType="ProdPlanInfoVo"> <!-- 查询生产计划监控列表(按机台和班次分组) -->
select <resultMap id="planMonitorResultMap" type="org.dromara.mes.domain.vo.PlanMonitorVo">
${ew.getSqlSelect}, <id property="machineId" column="machineId"/>
bmi.material_code, <result property="machineName" column="machineName"/>
bmi.material_name, <collection property="shifts" ofType="org.dromara.mes.domain.vo.ShiftGroupVo">
bomi.material_name material_bom_name, <id property="shiftId" column="shiftId"/>
<result property="shiftName" column="shiftName"/>
case <collection property="plans" ofType="org.dromara.mes.domain.vo.ProdPlanInfoVo">
when t.release_type = 1 then (select pbmi.machine_name <id property="planId" column="planId"/>
from prod_base_machine_info pbmi <result property="productOrderId" column="product_order_id"/>
where t.release_id = pbmi.machine_id) <result property="saleOrderId" column="sale_order_id"/>
<result property="saleorderCode" column="saleorder_code"/>
when t.release_type = 2 then (select su.nick_name <result property="planCode" column="plan_code"/>
from sys_user su <result property="dispatchCode" column="dispatch_code"/>
where t.release_id = su.user_id) <result property="materialId" column="material_id"/>
<result property="materialName" column="material_name"/>
when t.release_type = 3 then (select pbsi.station_name <result property="processId" column="process_id"/>
from prod_base_station_info pbsi <result property="processOrder" column="process_order"/>
where t.release_id = pbsi.station_id) <result property="lastProcessId" column="last_process_id"/>
end as release_name, <result property="finalProcessFlag" column="final_process_flag"/>
<result property="releaseType" column="release_type"/>
<result property="releaseId" column="release_id"/>
<result property="productionTime" column="production_time"/>
<result property="planAmount" column="plan_amount"/>
<result property="dispatchAmount" column="dispatch_amount"/>
<result property="completeAmount" column="complete_amount"/>
<result property="planBeginTime" column="plan_begin_time"/>
<result property="planEndTime" column="plan_end_time"/>
<result property="realBeginTime" column="real_begin_time"/>
<result property="realEndTime" column="real_end_time"/>
<result property="attachId" column="attach_id"/>
<result property="planStatus" column="plan_status"/>
<result property="importFlag" column="import_flag"/>
<result property="finishFlag" column="finish_flag"/>
<result property="priority" column="priority"/>
<result property="shiftId" column="shift_id"/>
<result property="classTeamId" column="class_team_id"/>
<result property="modelCode" column="model_code"/>
<result property="remark" column="remark"/>
</collection>
</collection>
</resultMap>
pbpi.process_name, <select id="queryMoritorList" resultMap="planMonitorResultMap">
bsi.shift_name, WITH ReleaseInfo AS (
bcti.team_name SELECT
from ${tableName} t t.release_id as machineId,
left join base_material_info bmi on bmi.material_id = t.material_id t.tenant_id,
left join prod_material_bom pmb on pmb.material_bom_id = t.material_bom_id CASE
left join base_material_info bomi on bomi.material_id = pmb.material_id WHEN t.release_type = 1 THEN (SELECT pbmi.machine_name FROM prod_base_machine_info pbmi WHERE t.release_id = pbmi.machine_id)
left join prod_base_process_info pbpi on pbpi.process_id = t.process_id /* WHEN t.release_type = 2 THEN (SELECT su.nick_name FROM sys_user su WHERE t.release_id = su.user_id)
left join base_shift_info bsi on bsi.shift_id = t.shift_id WHEN t.release_type = 3 THEN (SELECT pbsi.station_name FROM prod_base_station_info pbsi WHERE t.release_id = pbsi.station_id)*/
left join base_class_team_info bcti on bcti.class_team_id = t.class_team_id END as machineName
${ew.getCustomSqlSegment} FROM ${tableName} t
WHERE t.release_id IS NOT NULL
GROUP BY t.release_id, t.release_type, t.tenant_id
)
SELECT
r.machineId,
r.machineName,
COALESCE(t.shift_id, 0) as shiftId,
COALESCE(bsi.shift_name, '未分班') as shiftName,
t.plan_id as planId,
t.product_order_id,
t.sale_order_id,
t.saleorder_code,
t.plan_code,
t.dispatch_code,
t.material_id,
bmi.material_name,
t.process_id,
t.process_order,
t.last_process_id,
t.final_process_flag,
t.release_type,
t.release_id,
t.production_time,
t.plan_amount,
t.dispatch_amount,
t.complete_amount,
t.plan_begin_time,
t.plan_end_time,
t.real_begin_time,
t.real_end_time,
t.attach_id,
t.plan_status,
t.import_flag,
t.finish_flag,
t.priority,
t.shift_id,
t.class_team_id,
t.model_code,
t.remark
FROM ReleaseInfo r
LEFT JOIN ${tableName} t ON r.machineId = t.release_id
LEFT JOIN base_shift_info bsi ON t.shift_id = bsi.shift_id
LEFT JOIN base_material_info bmi ON t.material_id = bmi.material_id
${ew.customSqlSegment}
ORDER BY r.machineId, t.shift_id, t.plan_id
</select> </select>
</mapper> </mapper>

Loading…
Cancel
Save