update add生产计划完成率报表
parent
347c6e2e30
commit
539e8c2012
@ -0,0 +1,62 @@
|
||||
package org.dromara.mes.controller;
|
||||
|
||||
|
||||
import jakarta.servlet.http.HttpServletResponse;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.common.core.domain.R;
|
||||
import org.dromara.common.core.utils.sql.SqlUtil;
|
||||
import org.dromara.common.excel.utils.ExcelUtil;
|
||||
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.bo.ProdMaterialBomBo;
|
||||
import org.dromara.mes.domain.vo.PlanCompletionRateReportVo;
|
||||
import org.dromara.mes.domain.vo.ProdMaterialBomVo;
|
||||
import org.dromara.mes.domain.vo.ProdOrderInfoVo;
|
||||
import org.dromara.mes.domain.vo.ProdPlanInfoVo;
|
||||
import org.dromara.mes.service.IProdReportService;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
* MES生产报表Controller
|
||||
*
|
||||
* @author Yinq
|
||||
* @date 2025-02-27
|
||||
*/
|
||||
@Validated
|
||||
@RequiredArgsConstructor
|
||||
@RestController
|
||||
@RequestMapping("/prodReport")
|
||||
public class ProdReportController extends BaseController {
|
||||
|
||||
private final IProdReportService prodReportService;
|
||||
|
||||
/**
|
||||
* 生产计划完成率报表
|
||||
*
|
||||
* @param hashMap
|
||||
* @return
|
||||
*/
|
||||
@GetMapping("/planCompletionRateReport")
|
||||
public TableDataInfo<PlanCompletionRateReportVo> qualityIssuesReportList(@RequestParam(required = false) Map hashMap, PageQuery pageQuery) {
|
||||
return prodReportService.planCompletionRateReportVoList(hashMap, pageQuery);
|
||||
}
|
||||
|
||||
/**
|
||||
* 生产计划完成率报表导出
|
||||
*
|
||||
* @param hashMap
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/planCompletionRateReport/export")
|
||||
public void export(@RequestParam(required = false) Map hashMap, HttpServletResponse response) {
|
||||
List<PlanCompletionRateReportVo> list = prodReportService.planCompletionRateReportVoList(hashMap);
|
||||
ExcelUtil.exportExcel(list, "生产计划完成率报表", PlanCompletionRateReportVo.class, response);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,55 @@
|
||||
package org.dromara.mes.domain.vo;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
|
||||
/**
|
||||
* 生产计划完成率
|
||||
*
|
||||
* @author Yinq
|
||||
* @date 2025-02-28
|
||||
*/
|
||||
@Data
|
||||
@ExcelIgnoreUnannotated
|
||||
public class PlanCompletionRateReportVo implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 物料名称
|
||||
*/
|
||||
@ExcelProperty(value = "物料名称")
|
||||
private String materialName;
|
||||
|
||||
/**
|
||||
* 计划数
|
||||
*/
|
||||
@ExcelProperty(value = "计划数")
|
||||
private BigDecimal planNumber;
|
||||
|
||||
/**
|
||||
* 实际数量
|
||||
*/
|
||||
@ExcelProperty(value = "实际数量")
|
||||
private BigDecimal actualNumber;
|
||||
|
||||
/**
|
||||
* 偏差数
|
||||
*/
|
||||
@ExcelProperty(value = "偏差数")
|
||||
private BigDecimal deviationNumber;
|
||||
|
||||
/**
|
||||
* 完成率
|
||||
*/
|
||||
@ExcelProperty(value = "完成率")
|
||||
private String completionRate;
|
||||
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
package org.dromara.mes.mapper;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.dromara.mes.domain.vo.PlanCompletionRateReportVo;
|
||||
import org.dromara.mes.domain.vo.ProdPlanInfoVo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* MES生产报表Mapper接口
|
||||
*
|
||||
* @author Yinq
|
||||
* @date 2025-02-27
|
||||
*/
|
||||
public interface ProdReportMapper {
|
||||
|
||||
/**
|
||||
* 生产计划完成率报表
|
||||
*
|
||||
* @param hashMap
|
||||
* @return
|
||||
*/
|
||||
Page<PlanCompletionRateReportVo> planCompletionRateReportVoList(@Param("map") Map hashMap, @Param("page") Page<ProdPlanInfoVo> page, @Param("tableName")String tableName);
|
||||
|
||||
/**
|
||||
* 生产计划完成率报表导出
|
||||
*
|
||||
* @param hashMap
|
||||
* @return
|
||||
*/
|
||||
List<PlanCompletionRateReportVo> planCompletionRateReportVoList(@Param("map") Map hashMap, @Param("tableName")String tableName);
|
||||
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
package org.dromara.mes.service;
|
||||
|
||||
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.mes.domain.vo.PlanCompletionRateReportVo;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* MES生产报表Service接口
|
||||
*
|
||||
* @author Yinq
|
||||
* @date 2025-02-27
|
||||
*/
|
||||
public interface IProdReportService {
|
||||
|
||||
/**
|
||||
* 生产计划完成率报表
|
||||
*
|
||||
* @param hashMap
|
||||
* @return
|
||||
*/
|
||||
TableDataInfo<PlanCompletionRateReportVo> planCompletionRateReportVoList(Map hashMap, PageQuery pageQuery);
|
||||
|
||||
/**
|
||||
* 生产计划完成率报表导出
|
||||
*
|
||||
* @param hashMap
|
||||
* @return
|
||||
*/
|
||||
List<PlanCompletionRateReportVo> planCompletionRateReportVoList(Map hashMap);
|
||||
|
||||
}
|
@ -0,0 +1,75 @@
|
||||
package org.dromara.mes.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.dromara.common.constant.DatabaseConstants;
|
||||
import org.dromara.common.core.utils.StringUtils;
|
||||
import org.dromara.common.mybatis.core.page.PageQuery;
|
||||
import org.dromara.common.mybatis.core.page.TableDataInfo;
|
||||
import org.dromara.mes.domain.vo.PlanCompletionRateReportVo;
|
||||
import org.dromara.mes.mapper.ProdReportMapper;
|
||||
import org.dromara.mes.service.IProdReportService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* MES生产报表Service业务层处理
|
||||
*
|
||||
* @author Yinq
|
||||
* @date 2025-02-27
|
||||
*/
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class ProdReportServiceImpl implements IProdReportService {
|
||||
|
||||
private final ProdReportMapper prodReportMapper;
|
||||
|
||||
/**
|
||||
* 生产计划完成率报表
|
||||
*
|
||||
* @param hashMap
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public TableDataInfo<PlanCompletionRateReportVo> planCompletionRateReportVoList(Map hashMap, PageQuery pageQuery) {
|
||||
String tableName = getPlanInfoTableNameByProcessId(Long.parseLong(String.valueOf(hashMap.get("processId"))));
|
||||
Page<PlanCompletionRateReportVo> page = prodReportMapper.planCompletionRateReportVoList(hashMap, pageQuery.build(), tableName);
|
||||
return TableDataInfo.build(page);
|
||||
}
|
||||
|
||||
/**
|
||||
* 生产计划完成率报表导出
|
||||
*
|
||||
* @param hashMap
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<PlanCompletionRateReportVo> planCompletionRateReportVoList(Map hashMap) {
|
||||
String tableName = getPlanInfoTableNameByProcessId(Long.parseLong(String.valueOf(hashMap.get("processId"))));
|
||||
return prodReportMapper.planCompletionRateReportVoList(hashMap, tableName);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据工序获取获取生产计划数据库表名
|
||||
*
|
||||
* @param processId 工序ID
|
||||
* @return 生产计划数据库表名
|
||||
*/
|
||||
public String getPlanInfoTableNameByProcessId(Long processId) {
|
||||
String tableName = null;
|
||||
if (StringUtils.isNull(processId)) {
|
||||
return null;
|
||||
}
|
||||
if (processId == 17L) {
|
||||
tableName = DatabaseConstants.TABLE_NAME_PROD_PLAN_INFO_PREFIX + "_3";
|
||||
} else if (processId == 18L) {
|
||||
tableName = DatabaseConstants.TABLE_NAME_PROD_PLAN_INFO_PREFIX + "_4";
|
||||
} else {
|
||||
tableName = DatabaseConstants.TABLE_NAME_PROD_PLAN_INFO_PREFIX + "_2";
|
||||
}
|
||||
return tableName;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="org.dromara.mes.mapper.ProdReportMapper">
|
||||
|
||||
<select id="planCompletionRateReportVoList" resultType="org.dromara.mes.domain.vo.PlanCompletionRateReportVo">
|
||||
SELECT bmi.material_name materialName,
|
||||
CAST(SUM(t.plan_amount) AS DECIMAL(10, 2)) planNumber,
|
||||
CAST(SUM(t.complete_amount) AS DECIMAL(10, 2)) actualNumber,
|
||||
CAST(SUM(t.complete_amount - t.plan_amount) AS DECIMAL(10, 2)) deviationNumber,
|
||||
CONCAT(CAST((SUM(t.complete_amount) / SUM(t.plan_amount))
|
||||
* 100 AS DECIMAL(10, 2)), '%') completionRate
|
||||
FROM ${tableName} t
|
||||
LEFT JOIN base_material_info bmi on bmi.material_id = t.material_id
|
||||
<where>
|
||||
<if test="map.beginDate != null and map.beginDate != '' and map.endDate != null and map.endDate != ''">
|
||||
AND FORMAT(t.plan_begin_time, 'yyyy-MM-dd') BETWEEN #{map.beginDate} AND #{map.endDate}
|
||||
</if>
|
||||
<if test="map.processId != null and map.processId != ''">
|
||||
AND t.process_id = #{map.processId}
|
||||
</if>
|
||||
<if test="map.machineId != null and map.machineId != ''">
|
||||
AND t.release_id = #{map.machineId}
|
||||
</if>
|
||||
<if test="map.shiftId != null and map.shiftId != ''">
|
||||
AND t.shift_id = #{map.shiftId}
|
||||
</if>
|
||||
<if test="map.classTeamId != null and map.classTeamId != ''">
|
||||
AND t.class_team_id = #{map.classTeamId}
|
||||
</if>
|
||||
<if test="map.planCode != null and map.planCode != ''">
|
||||
AND t.plan_code LIKE CONCAT('%', #{map.planCode}, '%')
|
||||
</if>
|
||||
<if test="map.materialName != null and map.materialName != ''">
|
||||
AND bmi.material_name LIKE CONCAT('%', #{map.materialName}, '%')
|
||||
</if>
|
||||
</where>
|
||||
GROUP BY bmi.material_name
|
||||
ORDER BY materialName
|
||||
</select>
|
||||
|
||||
</mapper>
|
Loading…
Reference in New Issue