密炼生产计划优化
This commit is contained in:
76
jeecg-boot/db/mes-xsl-small-material-demand-plan-menu.sql
Normal file
76
jeecg-boot/db/mes-xsl-small-material-demand-plan-menu.sql
Normal file
@@ -0,0 +1,76 @@
|
||||
-- 自动/人工小料需求计划 菜单与权限(挂载到 MES密炼工程,兼容 MES管理)
|
||||
SET NAMES utf8mb4;
|
||||
|
||||
SET @small_parent_id = (
|
||||
SELECT id
|
||||
FROM sys_permission
|
||||
WHERE name = 'MES密炼工程' AND menu_type = 0 AND del_flag = 0
|
||||
ORDER BY create_time ASC
|
||||
LIMIT 1
|
||||
);
|
||||
SET @small_parent_id = IFNULL(@small_parent_id, (
|
||||
SELECT id
|
||||
FROM sys_permission
|
||||
WHERE url = '/mes' AND menu_type = 0 AND del_flag = 0
|
||||
ORDER BY create_time ASC
|
||||
LIMIT 1
|
||||
));
|
||||
SET @small_parent_id = IFNULL(@small_parent_id, '1860000000000000001');
|
||||
|
||||
-- 自动小料需求计划
|
||||
INSERT INTO sys_permission
|
||||
(`id`,`parent_id`,`name`,`url`,`component`,`component_name`,`menu_type`,`perms`,`perms_type`,`sort_no`,`always_show`,`icon`,`is_route`,`is_leaf`,`keep_alive`,`hidden`,`hide_tab`,`description`,`status`,`del_flag`,`create_by`,`create_time`,`rule_flag`,`internal_or_external`)
|
||||
VALUES
|
||||
('1900000000000000720',@small_parent_id,'自动小料需求计划','/mes/autosmallmaterialdemandplan','mes/autosmallmaterialdemandplan/index','MesXslAutoSmallMaterialDemandPlanList',1,NULL,'1',96,0,'ant-design:ordered-list-outlined',1,1,1,0,0,'自动小料需求计划',1,0,'admin',NOW(),0,0)
|
||||
ON DUPLICATE KEY UPDATE
|
||||
`parent_id`=VALUES(`parent_id`),`name`=VALUES(`name`),`url`=VALUES(`url`),`component`=VALUES(`component`),
|
||||
`component_name`=VALUES(`component_name`),`menu_type`=VALUES(`menu_type`),`sort_no`=VALUES(`sort_no`),
|
||||
`is_route`=VALUES(`is_route`),`is_leaf`=VALUES(`is_leaf`),`keep_alive`=VALUES(`keep_alive`),`icon`=VALUES(`icon`),
|
||||
`status`=VALUES(`status`),`hidden`=VALUES(`hidden`),`del_flag`=VALUES(`del_flag`);
|
||||
|
||||
INSERT INTO sys_permission
|
||||
(`id`,`parent_id`,`name`,`menu_type`,`perms`,`perms_type`,`sort_no`,`status`,`del_flag`,`create_by`,`create_time`)
|
||||
VALUES
|
||||
('1900000000000000721','1900000000000000720','导出',2,'xslmes:mes_xsl_auto_small_material_demand_plan:exportXls','1',1,'1',0,'admin',NOW())
|
||||
ON DUPLICATE KEY UPDATE
|
||||
`name`=VALUES(`name`),`perms`=VALUES(`perms`),`sort_no`=VALUES(`sort_no`),`status`=VALUES(`status`),`del_flag`=VALUES(`del_flag`);
|
||||
|
||||
-- 人工小料需求计划
|
||||
INSERT INTO sys_permission
|
||||
(`id`,`parent_id`,`name`,`url`,`component`,`component_name`,`menu_type`,`perms`,`perms_type`,`sort_no`,`always_show`,`icon`,`is_route`,`is_leaf`,`keep_alive`,`hidden`,`hide_tab`,`description`,`status`,`del_flag`,`create_by`,`create_time`,`rule_flag`,`internal_or_external`)
|
||||
VALUES
|
||||
('1900000000000000730',@small_parent_id,'人工小料需求计划','/mes/manualsmallmaterialdemandplan','mes/manualsmallmaterialdemandplan/index','MesXslManualSmallMaterialDemandPlanList',1,NULL,'1',97,0,'ant-design:ordered-list-outlined',1,1,1,0,0,'人工小料需求计划',1,0,'admin',NOW(),0,0)
|
||||
ON DUPLICATE KEY UPDATE
|
||||
`parent_id`=VALUES(`parent_id`),`name`=VALUES(`name`),`url`=VALUES(`url`),`component`=VALUES(`component`),
|
||||
`component_name`=VALUES(`component_name`),`menu_type`=VALUES(`menu_type`),`sort_no`=VALUES(`sort_no`),
|
||||
`is_route`=VALUES(`is_route`),`is_leaf`=VALUES(`is_leaf`),`keep_alive`=VALUES(`keep_alive`),`icon`=VALUES(`icon`),
|
||||
`status`=VALUES(`status`),`hidden`=VALUES(`hidden`),`del_flag`=VALUES(`del_flag`);
|
||||
|
||||
INSERT INTO sys_permission
|
||||
(`id`,`parent_id`,`name`,`menu_type`,`perms`,`perms_type`,`sort_no`,`status`,`del_flag`,`create_by`,`create_time`)
|
||||
VALUES
|
||||
('1900000000000000731','1900000000000000730','导出',2,'xslmes:mes_xsl_manual_small_material_demand_plan:exportXls','1',1,'1',0,'admin',NOW())
|
||||
ON DUPLICATE KEY UPDATE
|
||||
`name`=VALUES(`name`),`perms`=VALUES(`perms`),`sort_no`=VALUES(`sort_no`),`status`=VALUES(`status`),`del_flag`=VALUES(`del_flag`);
|
||||
|
||||
-- admin 角色授权
|
||||
INSERT INTO sys_role_permission(id, role_id, permission_id, operate_date, operate_ip)
|
||||
SELECT REPLACE(UUID(), '-', ''), 'f6817f48af4fb3af11b9e8bf182f618b', p.id, NOW(), '127.0.0.1'
|
||||
FROM sys_permission p
|
||||
WHERE p.id IN ('1900000000000000720','1900000000000000721','1900000000000000730','1900000000000000731')
|
||||
AND NOT EXISTS (
|
||||
SELECT 1 FROM sys_role_permission rp
|
||||
WHERE rp.role_id = 'f6817f48af4fb3af11b9e8bf182f618b'
|
||||
AND rp.permission_id = p.id
|
||||
);
|
||||
|
||||
-- 强制修复
|
||||
UPDATE sys_permission
|
||||
SET parent_id=@small_parent_id,url='/mes/autosmallmaterialdemandplan',component='mes/autosmallmaterialdemandplan/index',
|
||||
component_name='MesXslAutoSmallMaterialDemandPlanList',menu_type=1,is_route=1,is_leaf=1,hidden=0,status='1',del_flag=0,redirect=NULL
|
||||
WHERE id='1900000000000000720' OR name='自动小料需求计划' OR url='/mes/autosmallmaterialdemandplan';
|
||||
|
||||
UPDATE sys_permission
|
||||
SET parent_id=@small_parent_id,url='/mes/manualsmallmaterialdemandplan',component='mes/manualsmallmaterialdemandplan/index',
|
||||
component_name='MesXslManualSmallMaterialDemandPlanList',menu_type=1,is_route=1,is_leaf=1,hidden=0,status='1',del_flag=0,redirect=NULL
|
||||
WHERE id='1900000000000000730' OR name='人工小料需求计划' OR url='/mes/manualsmallmaterialdemandplan';
|
||||
75
jeecg-boot/db/mes-xsl-small-material-plan-maintain-menu.sql
Normal file
75
jeecg-boot/db/mes-xsl-small-material-plan-maintain-menu.sql
Normal file
@@ -0,0 +1,75 @@
|
||||
-- 自动/人工小料计划维护 菜单与权限(挂载到 MES密炼工程,兼容 MES管理)
|
||||
SET NAMES utf8mb4;
|
||||
|
||||
SET @plan_parent_id = (
|
||||
SELECT id
|
||||
FROM sys_permission
|
||||
WHERE name = 'MES密炼工程' AND menu_type = 0 AND del_flag = 0
|
||||
ORDER BY create_time ASC
|
||||
LIMIT 1
|
||||
);
|
||||
SET @plan_parent_id = IFNULL(@plan_parent_id, (
|
||||
SELECT id
|
||||
FROM sys_permission
|
||||
WHERE url = '/mes' AND menu_type = 0 AND del_flag = 0
|
||||
ORDER BY create_time ASC
|
||||
LIMIT 1
|
||||
));
|
||||
SET @plan_parent_id = IFNULL(@plan_parent_id, '1860000000000000001');
|
||||
|
||||
-- 自动小料计划维护
|
||||
INSERT INTO sys_permission
|
||||
(`id`,`parent_id`,`name`,`url`,`component`,`component_name`,`menu_type`,`perms`,`perms_type`,`sort_no`,`always_show`,`icon`,`is_route`,`is_leaf`,`keep_alive`,`hidden`,`hide_tab`,`description`,`status`,`del_flag`,`create_by`,`create_time`,`rule_flag`,`internal_or_external`)
|
||||
VALUES
|
||||
('1900000000000000740',@plan_parent_id,'自动小料计划维护','/mes/autosmallmaterialplanmaintain','mes/autosmallmaterialplanmaintain/index','MesXslAutoSmallMaterialPlanMaintainList',1,NULL,'1',98,0,'ant-design:table-outlined',1,1,1,0,0,'自动小料计划维护',1,0,'admin',NOW(),0,0)
|
||||
ON DUPLICATE KEY UPDATE
|
||||
`parent_id`=VALUES(`parent_id`),`name`=VALUES(`name`),`url`=VALUES(`url`),`component`=VALUES(`component`),
|
||||
`component_name`=VALUES(`component_name`),`menu_type`=VALUES(`menu_type`),`sort_no`=VALUES(`sort_no`),
|
||||
`is_route`=VALUES(`is_route`),`is_leaf`=VALUES(`is_leaf`),`keep_alive`=VALUES(`keep_alive`),`icon`=VALUES(`icon`),
|
||||
`status`=VALUES(`status`),`hidden`=VALUES(`hidden`),`del_flag`=VALUES(`del_flag`);
|
||||
|
||||
INSERT INTO sys_permission
|
||||
(`id`,`parent_id`,`name`,`menu_type`,`perms`,`perms_type`,`sort_no`,`status`,`del_flag`,`create_by`,`create_time`)
|
||||
VALUES
|
||||
('1900000000000000741','1900000000000000740','整表保存',2,'xslmes:mes_xsl_auto_small_material_plan_maintain:saveAll','1',1,'1',0,'admin',NOW())
|
||||
ON DUPLICATE KEY UPDATE
|
||||
`name`=VALUES(`name`),`perms`=VALUES(`perms`),`sort_no`=VALUES(`sort_no`),`status`=VALUES(`status`),`del_flag`=VALUES(`del_flag`);
|
||||
|
||||
-- 人工小料计划维护
|
||||
INSERT INTO sys_permission
|
||||
(`id`,`parent_id`,`name`,`url`,`component`,`component_name`,`menu_type`,`perms`,`perms_type`,`sort_no`,`always_show`,`icon`,`is_route`,`is_leaf`,`keep_alive`,`hidden`,`hide_tab`,`description`,`status`,`del_flag`,`create_by`,`create_time`,`rule_flag`,`internal_or_external`)
|
||||
VALUES
|
||||
('1900000000000000750',@plan_parent_id,'人工小料计划维护','/mes/manualsmallmaterialplanmaintain','mes/manualsmallmaterialplanmaintain/index','MesXslManualSmallMaterialPlanMaintainList',1,NULL,'1',99,0,'ant-design:table-outlined',1,1,1,0,0,'人工小料计划维护',1,0,'admin',NOW(),0,0)
|
||||
ON DUPLICATE KEY UPDATE
|
||||
`parent_id`=VALUES(`parent_id`),`name`=VALUES(`name`),`url`=VALUES(`url`),`component`=VALUES(`component`),
|
||||
`component_name`=VALUES(`component_name`),`menu_type`=VALUES(`menu_type`),`sort_no`=VALUES(`sort_no`),
|
||||
`is_route`=VALUES(`is_route`),`is_leaf`=VALUES(`is_leaf`),`keep_alive`=VALUES(`keep_alive`),`icon`=VALUES(`icon`),
|
||||
`status`=VALUES(`status`),`hidden`=VALUES(`hidden`),`del_flag`=VALUES(`del_flag`);
|
||||
|
||||
INSERT INTO sys_permission
|
||||
(`id`,`parent_id`,`name`,`menu_type`,`perms`,`perms_type`,`sort_no`,`status`,`del_flag`,`create_by`,`create_time`)
|
||||
VALUES
|
||||
('1900000000000000751','1900000000000000750','整表保存',2,'xslmes:mes_xsl_manual_small_material_plan_maintain:saveAll','1',1,'1',0,'admin',NOW())
|
||||
ON DUPLICATE KEY UPDATE
|
||||
`name`=VALUES(`name`),`perms`=VALUES(`perms`),`sort_no`=VALUES(`sort_no`),`status`=VALUES(`status`),`del_flag`=VALUES(`del_flag`);
|
||||
|
||||
-- admin授权
|
||||
INSERT INTO sys_role_permission(id, role_id, permission_id, operate_date, operate_ip)
|
||||
SELECT REPLACE(UUID(), '-', ''), 'f6817f48af4fb3af11b9e8bf182f618b', p.id, NOW(), '127.0.0.1'
|
||||
FROM sys_permission p
|
||||
WHERE p.id IN ('1900000000000000740','1900000000000000741','1900000000000000750','1900000000000000751')
|
||||
AND NOT EXISTS (
|
||||
SELECT 1 FROM sys_role_permission rp
|
||||
WHERE rp.role_id = 'f6817f48af4fb3af11b9e8bf182f618b' AND rp.permission_id = p.id
|
||||
);
|
||||
|
||||
-- 强制修正
|
||||
UPDATE sys_permission
|
||||
SET parent_id=@plan_parent_id,url='/mes/autosmallmaterialplanmaintain',component='mes/autosmallmaterialplanmaintain/index',
|
||||
component_name='MesXslAutoSmallMaterialPlanMaintainList',menu_type=1,is_route=1,is_leaf=1,hidden=0,status='1',del_flag=0,redirect=NULL
|
||||
WHERE id='1900000000000000740' OR name='自动小料计划维护' OR url='/mes/autosmallmaterialplanmaintain';
|
||||
|
||||
UPDATE sys_permission
|
||||
SET parent_id=@plan_parent_id,url='/mes/manualsmallmaterialplanmaintain',component='mes/manualsmallmaterialplanmaintain/index',
|
||||
component_name='MesXslManualSmallMaterialPlanMaintainList',menu_type=1,is_route=1,is_leaf=1,hidden=0,status='1',del_flag=0,redirect=NULL
|
||||
WHERE id='1900000000000000750' OR name='人工小料计划维护' OR url='/mes/manualsmallmaterialplanmaintain';
|
||||
@@ -0,0 +1,176 @@
|
||||
package org.jeecg.modules.xslmes.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.system.vo.LoginUser;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslSmallMaterialDemandPlanSummary;
|
||||
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
|
||||
import org.jeecgframework.poi.excel.entity.ExportParams;
|
||||
import org.jeecgframework.poi.excel.entity.enmus.ExcelType;
|
||||
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
@Tag(name = "自动小料需求计划")
|
||||
@RestController
|
||||
@RequestMapping("/xslmes/mesXslAutoSmallMaterialDemandPlan")
|
||||
public class MesXslAutoSmallMaterialDemandPlanController {
|
||||
|
||||
private static final String TABLE_NAME = "mes_xsl_auto_small_material_demand_plan";
|
||||
|
||||
@Autowired private JdbcTemplate jdbcTemplate;
|
||||
|
||||
@Operation(summary = "自动小料需求计划-分页列表查询")
|
||||
@GetMapping("/list")
|
||||
public Result<IPage<MesXslSmallMaterialDemandPlanSummary>> queryPageList(
|
||||
MesXslSmallMaterialDemandPlanSummary query,
|
||||
@RequestParam(name = "groupByMachine", required = false, defaultValue = "0") Integer groupByMachine,
|
||||
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
||||
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
|
||||
boolean groupedByMachine = groupByMachine != null && groupByMachine == 1;
|
||||
List<Object> params = new ArrayList<>();
|
||||
String groupedSql = buildGroupedSql(query, groupedByMachine, params);
|
||||
|
||||
String countSql = "SELECT COUNT(1) FROM (" + groupedSql + ") t";
|
||||
Long total = jdbcTemplate.queryForObject(countSql, Long.class, params.toArray());
|
||||
long totalCount = total == null ? 0L : total;
|
||||
|
||||
int offset = Math.max((pageNo - 1) * pageSize, 0);
|
||||
String pageSql = groupedSql + buildOrderBy(groupedByMachine) + " LIMIT ? OFFSET ?";
|
||||
List<Object> pageParams = new ArrayList<>(params);
|
||||
pageParams.add(pageSize);
|
||||
pageParams.add(offset);
|
||||
List<MesXslSmallMaterialDemandPlanSummary> rows = queryRows(pageSql, pageParams, groupedByMachine);
|
||||
|
||||
Page<MesXslSmallMaterialDemandPlanSummary> page = new Page<>(pageNo, pageSize, totalCount);
|
||||
page.setRecords(rows);
|
||||
return Result.OK(page);
|
||||
}
|
||||
|
||||
@RequiresPermissions("xslmes:mes_xsl_auto_small_material_demand_plan:exportXls")
|
||||
@RequestMapping("/exportXls")
|
||||
public ModelAndView exportXls(
|
||||
HttpServletRequest request,
|
||||
MesXslSmallMaterialDemandPlanSummary query,
|
||||
@RequestParam(name = "groupByMachine", required = false, defaultValue = "0") Integer groupByMachine) {
|
||||
boolean groupedByMachine = groupByMachine != null && groupByMachine == 1;
|
||||
List<Object> params = new ArrayList<>();
|
||||
String groupedSql = buildGroupedSql(query, groupedByMachine, params) + buildOrderBy(groupedByMachine);
|
||||
List<MesXslSmallMaterialDemandPlanSummary> exportList = queryRows(groupedSql, params, groupedByMachine);
|
||||
|
||||
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
|
||||
mv.addObject(NormalExcelConstants.FILE_NAME, "自动小料需求计划");
|
||||
mv.addObject(NormalExcelConstants.CLASS, MesXslSmallMaterialDemandPlanSummary.class);
|
||||
mv.addObject(
|
||||
NormalExcelConstants.PARAMS,
|
||||
new ExportParams(
|
||||
"自动小料需求计划",
|
||||
"导出人:" + (sysUser == null ? "admin" : sysUser.getRealname()),
|
||||
"自动小料需求计划",
|
||||
ExcelType.XSSF));
|
||||
mv.addObject(NormalExcelConstants.DATA_LIST, exportList);
|
||||
String exportFields = request.getParameter(NormalExcelConstants.EXPORT_FIELDS);
|
||||
if (oConvertUtils.isNotEmpty(exportFields)) {
|
||||
mv.addObject(NormalExcelConstants.EXPORT_FIELDS, exportFields);
|
||||
}
|
||||
return mv;
|
||||
}
|
||||
|
||||
private String buildGroupedSql(
|
||||
MesXslSmallMaterialDemandPlanSummary query, boolean groupedByMachine, List<Object> params) {
|
||||
String machineExpr = "COALESCE(NULLIF(TRIM(t.machine_name),''), '')";
|
||||
String rawMaterialExpr = "COALESCE(NULLIF(TRIM(t.raw_material_name),''), '')";
|
||||
String statDateExpr = "DATE_FORMAT(t.stat_date, '%Y-%m-%d')";
|
||||
|
||||
StringBuilder sql = new StringBuilder();
|
||||
sql.append("SELECT ");
|
||||
if (groupedByMachine) {
|
||||
sql.append(machineExpr).append(" AS machineName, ");
|
||||
} else {
|
||||
sql.append("'' AS machineName, ");
|
||||
}
|
||||
sql.append(rawMaterialExpr)
|
||||
.append(" AS rawMaterialName, ")
|
||||
.append("SUM(COALESCE(t.demand_weight,0)) AS demandWeight, ")
|
||||
.append("MAX(")
|
||||
.append(statDateExpr)
|
||||
.append(") AS statDate ")
|
||||
.append("FROM ")
|
||||
.append(TABLE_NAME)
|
||||
.append(" t ")
|
||||
.append("WHERE (t.del_flag = 0 OR t.del_flag IS NULL) ");
|
||||
|
||||
if (query != null && StringUtils.isNotBlank(query.getStatDate())) {
|
||||
sql.append("AND ").append(statDateExpr).append(" = ? ");
|
||||
params.add(query.getStatDate().trim());
|
||||
}
|
||||
if (query != null && StringUtils.isNotBlank(query.getRawMaterialName())) {
|
||||
sql.append("AND ").append(rawMaterialExpr).append(" LIKE ? ");
|
||||
params.add("%" + query.getRawMaterialName().trim() + "%");
|
||||
}
|
||||
if (groupedByMachine && query != null && StringUtils.isNotBlank(query.getMachineName())) {
|
||||
sql.append("AND ").append(machineExpr).append(" LIKE ? ");
|
||||
params.add("%" + query.getMachineName().trim() + "%");
|
||||
}
|
||||
|
||||
sql.append("GROUP BY ");
|
||||
if (groupedByMachine) {
|
||||
sql.append(machineExpr).append(", ");
|
||||
}
|
||||
sql.append(rawMaterialExpr);
|
||||
return sql.toString();
|
||||
}
|
||||
|
||||
private List<MesXslSmallMaterialDemandPlanSummary> queryRows(
|
||||
String sql, List<Object> params, boolean groupedByMachine) {
|
||||
return jdbcTemplate.query(
|
||||
sql,
|
||||
rs -> {
|
||||
List<MesXslSmallMaterialDemandPlanSummary> list = new ArrayList<>();
|
||||
int seq = 1;
|
||||
while (rs.next()) {
|
||||
MesXslSmallMaterialDemandPlanSummary row = new MesXslSmallMaterialDemandPlanSummary();
|
||||
row.setMachineName(groupedByMachine ? trim(rs.getString("machineName")) : "");
|
||||
row.setRawMaterialName(trim(rs.getString("rawMaterialName")));
|
||||
row.setDemandWeight(rs.getBigDecimal("demandWeight"));
|
||||
row.setStatDate(trim(rs.getString("statDate")));
|
||||
row.setId(buildRowId(row, groupedByMachine, seq++));
|
||||
list.add(row);
|
||||
}
|
||||
return list;
|
||||
},
|
||||
params.toArray());
|
||||
}
|
||||
|
||||
private String buildOrderBy(boolean groupedByMachine) {
|
||||
if (groupedByMachine) {
|
||||
return " ORDER BY machineName, rawMaterialName";
|
||||
}
|
||||
return " ORDER BY rawMaterialName";
|
||||
}
|
||||
|
||||
private String buildRowId(MesXslSmallMaterialDemandPlanSummary row, boolean groupedByMachine, int seq) {
|
||||
String machine = groupedByMachine ? StringUtils.defaultString(row.getMachineName()) : "ALL";
|
||||
return machine + "_" + StringUtils.defaultString(row.getRawMaterialName()) + "_" + seq;
|
||||
}
|
||||
|
||||
private String trim(String value) {
|
||||
return value == null ? "" : value.trim();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package org.jeecg.modules.xslmes.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.aspect.annotation.AutoLog;
|
||||
import org.jeecg.common.system.base.controller.JeecgController;
|
||||
import org.jeecg.common.system.query.QueryGenerator;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslAutoSmallMaterialPlanMaintain;
|
||||
import org.jeecg.modules.xslmes.service.IMesXslAutoSmallMaterialPlanMaintainService;
|
||||
import org.jeecg.modules.xslmes.vo.MesXslAutoSmallMaterialPlanMaintainSaveAllVO;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@Tag(name = "自动小料计划维护")
|
||||
@RestController
|
||||
@RequestMapping("/xslmes/mesXslAutoSmallMaterialPlanMaintain")
|
||||
public class MesXslAutoSmallMaterialPlanMaintainController
|
||||
extends JeecgController<
|
||||
MesXslAutoSmallMaterialPlanMaintain, IMesXslAutoSmallMaterialPlanMaintainService> {
|
||||
|
||||
private final IMesXslAutoSmallMaterialPlanMaintainService service;
|
||||
|
||||
public MesXslAutoSmallMaterialPlanMaintainController(
|
||||
IMesXslAutoSmallMaterialPlanMaintainService service) {
|
||||
this.service = service;
|
||||
}
|
||||
|
||||
@Operation(summary = "自动小料计划维护-分页列表查询")
|
||||
@GetMapping("/list")
|
||||
public Result<IPage<MesXslAutoSmallMaterialPlanMaintain>> queryPageList(
|
||||
MesXslAutoSmallMaterialPlanMaintain model,
|
||||
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
||||
@RequestParam(name = "pageSize", defaultValue = "50") Integer pageSize,
|
||||
HttpServletRequest req) {
|
||||
QueryWrapper<MesXslAutoSmallMaterialPlanMaintain> queryWrapper =
|
||||
QueryGenerator.initQueryWrapper(model, req.getParameterMap());
|
||||
queryWrapper.orderByAsc("sort_no").orderByAsc("create_time");
|
||||
IPage<MesXslAutoSmallMaterialPlanMaintain> pageList =
|
||||
service.page(new Page<>(pageNo, pageSize), queryWrapper);
|
||||
return Result.OK(pageList);
|
||||
}
|
||||
|
||||
@AutoLog(value = "自动小料计划维护-整表保存")
|
||||
@Operation(summary = "自动小料计划维护-整表保存")
|
||||
@RequiresPermissions("xslmes:mes_xsl_auto_small_material_plan_maintain:saveAll")
|
||||
@PostMapping("/saveAll")
|
||||
public Result<String> saveAll(@RequestBody MesXslAutoSmallMaterialPlanMaintainSaveAllVO req) {
|
||||
service.saveAllRows(req == null ? null : req.getRows());
|
||||
return Result.OK("保存成功");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,176 @@
|
||||
package org.jeecg.modules.xslmes.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.shiro.SecurityUtils;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.system.vo.LoginUser;
|
||||
import org.jeecg.common.util.oConvertUtils;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslSmallMaterialDemandPlanSummary;
|
||||
import org.jeecgframework.poi.excel.def.NormalExcelConstants;
|
||||
import org.jeecgframework.poi.excel.entity.ExportParams;
|
||||
import org.jeecgframework.poi.excel.entity.enmus.ExcelType;
|
||||
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
@Tag(name = "人工小料需求计划")
|
||||
@RestController
|
||||
@RequestMapping("/xslmes/mesXslManualSmallMaterialDemandPlan")
|
||||
public class MesXslManualSmallMaterialDemandPlanController {
|
||||
|
||||
private static final String TABLE_NAME = "mes_xsl_manual_small_material_demand_plan";
|
||||
|
||||
@Autowired private JdbcTemplate jdbcTemplate;
|
||||
|
||||
@Operation(summary = "人工小料需求计划-分页列表查询")
|
||||
@GetMapping("/list")
|
||||
public Result<IPage<MesXslSmallMaterialDemandPlanSummary>> queryPageList(
|
||||
MesXslSmallMaterialDemandPlanSummary query,
|
||||
@RequestParam(name = "groupByMachine", required = false, defaultValue = "0") Integer groupByMachine,
|
||||
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
||||
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
|
||||
boolean groupedByMachine = groupByMachine != null && groupByMachine == 1;
|
||||
List<Object> params = new ArrayList<>();
|
||||
String groupedSql = buildGroupedSql(query, groupedByMachine, params);
|
||||
|
||||
String countSql = "SELECT COUNT(1) FROM (" + groupedSql + ") t";
|
||||
Long total = jdbcTemplate.queryForObject(countSql, Long.class, params.toArray());
|
||||
long totalCount = total == null ? 0L : total;
|
||||
|
||||
int offset = Math.max((pageNo - 1) * pageSize, 0);
|
||||
String pageSql = groupedSql + buildOrderBy(groupedByMachine) + " LIMIT ? OFFSET ?";
|
||||
List<Object> pageParams = new ArrayList<>(params);
|
||||
pageParams.add(pageSize);
|
||||
pageParams.add(offset);
|
||||
List<MesXslSmallMaterialDemandPlanSummary> rows = queryRows(pageSql, pageParams, groupedByMachine);
|
||||
|
||||
Page<MesXslSmallMaterialDemandPlanSummary> page = new Page<>(pageNo, pageSize, totalCount);
|
||||
page.setRecords(rows);
|
||||
return Result.OK(page);
|
||||
}
|
||||
|
||||
@RequiresPermissions("xslmes:mes_xsl_manual_small_material_demand_plan:exportXls")
|
||||
@RequestMapping("/exportXls")
|
||||
public ModelAndView exportXls(
|
||||
HttpServletRequest request,
|
||||
MesXslSmallMaterialDemandPlanSummary query,
|
||||
@RequestParam(name = "groupByMachine", required = false, defaultValue = "0") Integer groupByMachine) {
|
||||
boolean groupedByMachine = groupByMachine != null && groupByMachine == 1;
|
||||
List<Object> params = new ArrayList<>();
|
||||
String groupedSql = buildGroupedSql(query, groupedByMachine, params) + buildOrderBy(groupedByMachine);
|
||||
List<MesXslSmallMaterialDemandPlanSummary> exportList = queryRows(groupedSql, params, groupedByMachine);
|
||||
|
||||
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
|
||||
ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
|
||||
mv.addObject(NormalExcelConstants.FILE_NAME, "人工小料需求计划");
|
||||
mv.addObject(NormalExcelConstants.CLASS, MesXslSmallMaterialDemandPlanSummary.class);
|
||||
mv.addObject(
|
||||
NormalExcelConstants.PARAMS,
|
||||
new ExportParams(
|
||||
"人工小料需求计划",
|
||||
"导出人:" + (sysUser == null ? "admin" : sysUser.getRealname()),
|
||||
"人工小料需求计划",
|
||||
ExcelType.XSSF));
|
||||
mv.addObject(NormalExcelConstants.DATA_LIST, exportList);
|
||||
String exportFields = request.getParameter(NormalExcelConstants.EXPORT_FIELDS);
|
||||
if (oConvertUtils.isNotEmpty(exportFields)) {
|
||||
mv.addObject(NormalExcelConstants.EXPORT_FIELDS, exportFields);
|
||||
}
|
||||
return mv;
|
||||
}
|
||||
|
||||
private String buildGroupedSql(
|
||||
MesXslSmallMaterialDemandPlanSummary query, boolean groupedByMachine, List<Object> params) {
|
||||
String machineExpr = "COALESCE(NULLIF(TRIM(t.machine_name),''), '')";
|
||||
String rawMaterialExpr = "COALESCE(NULLIF(TRIM(t.raw_material_name),''), '')";
|
||||
String statDateExpr = "DATE_FORMAT(t.stat_date, '%Y-%m-%d')";
|
||||
|
||||
StringBuilder sql = new StringBuilder();
|
||||
sql.append("SELECT ");
|
||||
if (groupedByMachine) {
|
||||
sql.append(machineExpr).append(" AS machineName, ");
|
||||
} else {
|
||||
sql.append("'' AS machineName, ");
|
||||
}
|
||||
sql.append(rawMaterialExpr)
|
||||
.append(" AS rawMaterialName, ")
|
||||
.append("SUM(COALESCE(t.demand_weight,0)) AS demandWeight, ")
|
||||
.append("MAX(")
|
||||
.append(statDateExpr)
|
||||
.append(") AS statDate ")
|
||||
.append("FROM ")
|
||||
.append(TABLE_NAME)
|
||||
.append(" t ")
|
||||
.append("WHERE (t.del_flag = 0 OR t.del_flag IS NULL) ");
|
||||
|
||||
if (query != null && StringUtils.isNotBlank(query.getStatDate())) {
|
||||
sql.append("AND ").append(statDateExpr).append(" = ? ");
|
||||
params.add(query.getStatDate().trim());
|
||||
}
|
||||
if (query != null && StringUtils.isNotBlank(query.getRawMaterialName())) {
|
||||
sql.append("AND ").append(rawMaterialExpr).append(" LIKE ? ");
|
||||
params.add("%" + query.getRawMaterialName().trim() + "%");
|
||||
}
|
||||
if (groupedByMachine && query != null && StringUtils.isNotBlank(query.getMachineName())) {
|
||||
sql.append("AND ").append(machineExpr).append(" LIKE ? ");
|
||||
params.add("%" + query.getMachineName().trim() + "%");
|
||||
}
|
||||
|
||||
sql.append("GROUP BY ");
|
||||
if (groupedByMachine) {
|
||||
sql.append(machineExpr).append(", ");
|
||||
}
|
||||
sql.append(rawMaterialExpr);
|
||||
return sql.toString();
|
||||
}
|
||||
|
||||
private List<MesXslSmallMaterialDemandPlanSummary> queryRows(
|
||||
String sql, List<Object> params, boolean groupedByMachine) {
|
||||
return jdbcTemplate.query(
|
||||
sql,
|
||||
rs -> {
|
||||
List<MesXslSmallMaterialDemandPlanSummary> list = new ArrayList<>();
|
||||
int seq = 1;
|
||||
while (rs.next()) {
|
||||
MesXslSmallMaterialDemandPlanSummary row = new MesXslSmallMaterialDemandPlanSummary();
|
||||
row.setMachineName(groupedByMachine ? trim(rs.getString("machineName")) : "");
|
||||
row.setRawMaterialName(trim(rs.getString("rawMaterialName")));
|
||||
row.setDemandWeight(rs.getBigDecimal("demandWeight"));
|
||||
row.setStatDate(trim(rs.getString("statDate")));
|
||||
row.setId(buildRowId(row, groupedByMachine, seq++));
|
||||
list.add(row);
|
||||
}
|
||||
return list;
|
||||
},
|
||||
params.toArray());
|
||||
}
|
||||
|
||||
private String buildOrderBy(boolean groupedByMachine) {
|
||||
if (groupedByMachine) {
|
||||
return " ORDER BY machineName, rawMaterialName";
|
||||
}
|
||||
return " ORDER BY rawMaterialName";
|
||||
}
|
||||
|
||||
private String buildRowId(MesXslSmallMaterialDemandPlanSummary row, boolean groupedByMachine, int seq) {
|
||||
String machine = groupedByMachine ? StringUtils.defaultString(row.getMachineName()) : "ALL";
|
||||
return machine + "_" + StringUtils.defaultString(row.getRawMaterialName()) + "_" + seq;
|
||||
}
|
||||
|
||||
private String trim(String value) {
|
||||
return value == null ? "" : value.trim();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package org.jeecg.modules.xslmes.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
||||
import org.jeecg.common.api.vo.Result;
|
||||
import org.jeecg.common.aspect.annotation.AutoLog;
|
||||
import org.jeecg.common.system.base.controller.JeecgController;
|
||||
import org.jeecg.common.system.query.QueryGenerator;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslManualSmallMaterialPlanMaintain;
|
||||
import org.jeecg.modules.xslmes.service.IMesXslManualSmallMaterialPlanMaintainService;
|
||||
import org.jeecg.modules.xslmes.vo.MesXslManualSmallMaterialPlanMaintainSaveAllVO;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@Tag(name = "人工小料计划维护")
|
||||
@RestController
|
||||
@RequestMapping("/xslmes/mesXslManualSmallMaterialPlanMaintain")
|
||||
public class MesXslManualSmallMaterialPlanMaintainController
|
||||
extends JeecgController<
|
||||
MesXslManualSmallMaterialPlanMaintain, IMesXslManualSmallMaterialPlanMaintainService> {
|
||||
|
||||
private final IMesXslManualSmallMaterialPlanMaintainService service;
|
||||
|
||||
public MesXslManualSmallMaterialPlanMaintainController(
|
||||
IMesXslManualSmallMaterialPlanMaintainService service) {
|
||||
this.service = service;
|
||||
}
|
||||
|
||||
@Operation(summary = "人工小料计划维护-分页列表查询")
|
||||
@GetMapping("/list")
|
||||
public Result<IPage<MesXslManualSmallMaterialPlanMaintain>> queryPageList(
|
||||
MesXslManualSmallMaterialPlanMaintain model,
|
||||
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
||||
@RequestParam(name = "pageSize", defaultValue = "50") Integer pageSize,
|
||||
HttpServletRequest req) {
|
||||
QueryWrapper<MesXslManualSmallMaterialPlanMaintain> queryWrapper =
|
||||
QueryGenerator.initQueryWrapper(model, req.getParameterMap());
|
||||
queryWrapper.orderByAsc("sort_no").orderByAsc("create_time");
|
||||
IPage<MesXslManualSmallMaterialPlanMaintain> pageList =
|
||||
service.page(new Page<>(pageNo, pageSize), queryWrapper);
|
||||
return Result.OK(pageList);
|
||||
}
|
||||
|
||||
@AutoLog(value = "人工小料计划维护-整表保存")
|
||||
@Operation(summary = "人工小料计划维护-整表保存")
|
||||
@RequiresPermissions("xslmes:mes_xsl_manual_small_material_plan_maintain:saveAll")
|
||||
@PostMapping("/saveAll")
|
||||
public Result<String> saveAll(@RequestBody MesXslManualSmallMaterialPlanMaintainSaveAllVO req) {
|
||||
service.saveAllRows(req == null ? null : req.getRows());
|
||||
return Result.OK("保存成功");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
package org.jeecg.modules.xslmes.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
/**
|
||||
* 自动小料计划维护
|
||||
*/
|
||||
@Data
|
||||
@TableName("mes_xsl_auto_small_material_plan_maintain")
|
||||
@Accessors(chain = true)
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Schema(description = "自动小料计划维护")
|
||||
public class MesXslAutoSmallMaterialPlanMaintain implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
private String id;
|
||||
|
||||
@Excel(name = "排序号", width = 10)
|
||||
private Integer sortNo;
|
||||
|
||||
@Excel(name = "配方名称", width = 20)
|
||||
private String formulaName;
|
||||
|
||||
@Excel(name = "早班序号", width = 12)
|
||||
private Integer morningSeqNo;
|
||||
@Excel(name = "早班计划", width = 12)
|
||||
private Integer morningPlanCount;
|
||||
@Excel(name = "早班备注", width = 20)
|
||||
private String morningRemark;
|
||||
|
||||
@Excel(name = "中班序号", width = 12)
|
||||
private Integer noonSeqNo;
|
||||
@Excel(name = "中班计划", width = 12)
|
||||
private Integer noonPlanCount;
|
||||
@Excel(name = "中班备注", width = 20)
|
||||
private String noonRemark;
|
||||
|
||||
@Excel(name = "夜班序号", width = 12)
|
||||
private Integer nightSeqNo;
|
||||
@Excel(name = "夜班计划", width = 12)
|
||||
private Integer nightPlanCount;
|
||||
@Excel(name = "夜班备注", width = 20)
|
||||
private String nightRemark;
|
||||
|
||||
private Integer tenantId;
|
||||
private String sysOrgCode;
|
||||
private String createBy;
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date createTime;
|
||||
private String updateBy;
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date updateTime;
|
||||
private Integer delFlag;
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
package org.jeecg.modules.xslmes.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
/**
|
||||
* 人工小料计划维护
|
||||
*/
|
||||
@Data
|
||||
@TableName("mes_xsl_manual_small_material_plan_maintain")
|
||||
@Accessors(chain = true)
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
@Schema(description = "人工小料计划维护")
|
||||
public class MesXslManualSmallMaterialPlanMaintain implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
private String id;
|
||||
|
||||
@Excel(name = "排序号", width = 10)
|
||||
private Integer sortNo;
|
||||
|
||||
@Excel(name = "配方名称", width = 20)
|
||||
private String formulaName;
|
||||
|
||||
@Excel(name = "早班序号", width = 12)
|
||||
private Integer morningSeqNo;
|
||||
@Excel(name = "早班计划", width = 12)
|
||||
private Integer morningPlanCount;
|
||||
@Excel(name = "早班备注", width = 20)
|
||||
private String morningRemark;
|
||||
|
||||
@Excel(name = "中班序号", width = 12)
|
||||
private Integer noonSeqNo;
|
||||
@Excel(name = "中班计划", width = 12)
|
||||
private Integer noonPlanCount;
|
||||
@Excel(name = "中班备注", width = 20)
|
||||
private String noonRemark;
|
||||
|
||||
@Excel(name = "夜班序号", width = 12)
|
||||
private Integer nightSeqNo;
|
||||
@Excel(name = "夜班计划", width = 12)
|
||||
private Integer nightPlanCount;
|
||||
@Excel(name = "夜班备注", width = 20)
|
||||
private String nightRemark;
|
||||
|
||||
private Integer tenantId;
|
||||
private String sysOrgCode;
|
||||
private String createBy;
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date createTime;
|
||||
private String updateBy;
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date updateTime;
|
||||
private Integer delFlag;
|
||||
}
|
||||
@@ -43,10 +43,17 @@ public class MesXslMixingProductionPlan implements Serializable {
|
||||
@Schema(description = "机台名称")
|
||||
private String machineName;
|
||||
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
|
||||
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||
@Schema(description = "计划日期(保存时写入当前日期)")
|
||||
private Date planDate;
|
||||
|
||||
@Schema(description = "早班计划ID")
|
||||
private String morningPlanId;
|
||||
@Schema(description = "早班计划类型 M母胶/F终胶")
|
||||
private String morningPlanType;
|
||||
@Schema(description = "早班生产订单ID")
|
||||
private String morningSourceOrderId;
|
||||
@Excel(name = "早班生产订单", width = 20)
|
||||
private String morningOrderNo;
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
|
||||
@@ -72,6 +79,8 @@ public class MesXslMixingProductionPlan implements Serializable {
|
||||
private String noonPlanId;
|
||||
@Schema(description = "中班计划类型 M母胶/F终胶")
|
||||
private String noonPlanType;
|
||||
@Schema(description = "中班生产订单ID")
|
||||
private String noonSourceOrderId;
|
||||
@Excel(name = "中班生产订单", width = 20)
|
||||
private String noonOrderNo;
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
|
||||
@@ -97,6 +106,8 @@ public class MesXslMixingProductionPlan implements Serializable {
|
||||
private String nightPlanId;
|
||||
@Schema(description = "晚班计划类型 M母胶/F终胶")
|
||||
private String nightPlanType;
|
||||
@Schema(description = "晚班生产订单ID")
|
||||
private String nightSourceOrderId;
|
||||
@Excel(name = "晚班生产订单", width = 20)
|
||||
private String nightOrderNo;
|
||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
package org.jeecg.modules.xslmes.entity;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import lombok.Data;
|
||||
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||
|
||||
/**
|
||||
* 小料需求计划汇总(自动/人工)
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "小料需求计划汇总")
|
||||
public class MesXslSmallMaterialDemandPlanSummary implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Schema(description = "主键")
|
||||
private String id;
|
||||
|
||||
@Excel(name = "机台", width = 20)
|
||||
@Schema(description = "机台")
|
||||
private String machineName;
|
||||
|
||||
@Excel(name = "原材料名称", width = 24)
|
||||
@Schema(description = "原材料名称")
|
||||
private String rawMaterialName;
|
||||
|
||||
@Excel(name = "需求重量(KG)", width = 18)
|
||||
@Schema(description = "需求重量(KG)")
|
||||
private BigDecimal demandWeight;
|
||||
|
||||
@Schema(description = "统计日期(yyyy-MM-dd)")
|
||||
private String statDate;
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
package org.jeecg.modules.xslmes.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslAutoSmallMaterialPlanMaintain;
|
||||
|
||||
public interface MesXslAutoSmallMaterialPlanMaintainMapper
|
||||
extends BaseMapper<MesXslAutoSmallMaterialPlanMaintain> {}
|
||||
@@ -0,0 +1,7 @@
|
||||
package org.jeecg.modules.xslmes.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslManualSmallMaterialPlanMaintain;
|
||||
|
||||
public interface MesXslManualSmallMaterialPlanMaintainMapper
|
||||
extends BaseMapper<MesXslManualSmallMaterialPlanMaintain> {}
|
||||
@@ -0,0 +1,10 @@
|
||||
package org.jeecg.modules.xslmes.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import java.util.List;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslAutoSmallMaterialPlanMaintain;
|
||||
|
||||
public interface IMesXslAutoSmallMaterialPlanMaintainService
|
||||
extends IService<MesXslAutoSmallMaterialPlanMaintain> {
|
||||
void saveAllRows(List<MesXslAutoSmallMaterialPlanMaintain> rows);
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package org.jeecg.modules.xslmes.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import java.util.List;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslManualSmallMaterialPlanMaintain;
|
||||
|
||||
public interface IMesXslManualSmallMaterialPlanMaintainService
|
||||
extends IService<MesXslManualSmallMaterialPlanMaintain> {
|
||||
void saveAllRows(List<MesXslManualSmallMaterialPlanMaintain> rows);
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package org.jeecg.modules.xslmes.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.jeecg.common.constant.CommonConstant;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslAutoSmallMaterialPlanMaintain;
|
||||
import org.jeecg.modules.xslmes.mapper.MesXslAutoSmallMaterialPlanMaintainMapper;
|
||||
import org.jeecg.modules.xslmes.service.IMesXslAutoSmallMaterialPlanMaintainService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
@Service
|
||||
public class MesXslAutoSmallMaterialPlanMaintainServiceImpl
|
||||
extends ServiceImpl<MesXslAutoSmallMaterialPlanMaintainMapper, MesXslAutoSmallMaterialPlanMaintain>
|
||||
implements IMesXslAutoSmallMaterialPlanMaintainService {
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void saveAllRows(List<MesXslAutoSmallMaterialPlanMaintain> rows) {
|
||||
this.remove(new LambdaQueryWrapper<>());
|
||||
if (CollectionUtils.isEmpty(rows)) {
|
||||
return;
|
||||
}
|
||||
List<MesXslAutoSmallMaterialPlanMaintain> saveList = new ArrayList<>();
|
||||
int sort = 1;
|
||||
Date now = new Date();
|
||||
for (MesXslAutoSmallMaterialPlanMaintain row : rows) {
|
||||
if (row == null || !hasBusinessData(row)) {
|
||||
continue;
|
||||
}
|
||||
row.setId(null);
|
||||
row.setSortNo(sort++);
|
||||
row.setFormulaName(StringUtils.trimToNull(row.getFormulaName()));
|
||||
row.setMorningRemark(StringUtils.trimToNull(row.getMorningRemark()));
|
||||
row.setNoonRemark(StringUtils.trimToNull(row.getNoonRemark()));
|
||||
row.setNightRemark(StringUtils.trimToNull(row.getNightRemark()));
|
||||
row.setCreateTime(now);
|
||||
row.setUpdateTime(now);
|
||||
if (row.getDelFlag() == null) {
|
||||
row.setDelFlag(CommonConstant.DEL_FLAG_0);
|
||||
}
|
||||
saveList.add(row);
|
||||
}
|
||||
if (!saveList.isEmpty()) {
|
||||
this.saveBatch(saveList, 200);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean hasBusinessData(MesXslAutoSmallMaterialPlanMaintain row) {
|
||||
return StringUtils.isNotBlank(row.getFormulaName())
|
||||
|| row.getMorningSeqNo() != null
|
||||
|| row.getMorningPlanCount() != null
|
||||
|| StringUtils.isNotBlank(row.getMorningRemark())
|
||||
|| row.getNoonSeqNo() != null
|
||||
|| row.getNoonPlanCount() != null
|
||||
|| StringUtils.isNotBlank(row.getNoonRemark())
|
||||
|| row.getNightSeqNo() != null
|
||||
|| row.getNightPlanCount() != null
|
||||
|| StringUtils.isNotBlank(row.getNightRemark());
|
||||
}
|
||||
}
|
||||
@@ -13,8 +13,12 @@ import org.jeecg.common.exception.JeecgBootException;
|
||||
import org.jeecg.modules.mes.material.entity.MesMaterial;
|
||||
import org.jeecg.modules.mes.material.mapper.MesMaterialMapper;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslFinalBatchPlan;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslMixingSpec;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslMixingSpecMaterial;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslProductionOrder;
|
||||
import org.jeecg.modules.xslmes.mapper.MesXslFinalBatchPlanMapper;
|
||||
import org.jeecg.modules.xslmes.mapper.MesXslMixingSpecMapper;
|
||||
import org.jeecg.modules.xslmes.mapper.MesXslMixingSpecMaterialMapper;
|
||||
import org.jeecg.modules.xslmes.service.IMesXslFinalBatchPlanService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -25,6 +29,8 @@ public class MesXslFinalBatchPlanServiceImpl
|
||||
implements IMesXslFinalBatchPlanService {
|
||||
|
||||
@Autowired private MesMaterialMapper mesMaterialMapper;
|
||||
@Autowired private MesXslMixingSpecMapper mesXslMixingSpecMapper;
|
||||
@Autowired private MesXslMixingSpecMaterialMapper mesXslMixingSpecMaterialMapper;
|
||||
|
||||
@Override
|
||||
public MesXslFinalBatchPlan generateFromProductionOrder(MesXslProductionOrder productionOrder) {
|
||||
@@ -43,7 +49,11 @@ public class MesXslFinalBatchPlanServiceImpl
|
||||
}
|
||||
|
||||
BigDecimal planWeight = productionOrder.getPlanQty() == null ? BigDecimal.ZERO : productionOrder.getPlanQty();
|
||||
BigDecimal perCarWeight = BigDecimal.ZERO;
|
||||
BigDecimal perCarWeight = resolvePerCarWeightFromMixingSpec(finalMaterial.getMaterialCode());
|
||||
if (perCarWeight.compareTo(BigDecimal.ZERO) <= 0) {
|
||||
throw new JeecgBootException(
|
||||
"对应混炼示方未配置有效合计重量,无法计算每车重量(物料:" + finalMaterial.getMaterialCode() + ")");
|
||||
}
|
||||
int planCarCount = calcPlanCarCount(planWeight, perCarWeight);
|
||||
|
||||
MesXslFinalBatchPlan plan = new MesXslFinalBatchPlan();
|
||||
@@ -136,4 +146,38 @@ public class MesXslFinalBatchPlanServiceImpl
|
||||
}
|
||||
return planWeight.divide(perCarWeight, 0, RoundingMode.CEILING).intValue();
|
||||
}
|
||||
|
||||
private BigDecimal resolvePerCarWeightFromMixingSpec(String materialCode) {
|
||||
String specName = buildMixingSpecName(materialCode);
|
||||
MesXslMixingSpec spec =
|
||||
mesXslMixingSpecMapper.selectOne(
|
||||
new LambdaQueryWrapper<MesXslMixingSpec>()
|
||||
.eq(MesXslMixingSpec::getSpecName, specName)
|
||||
.and(w -> w.eq(MesXslMixingSpec::getDelFlag, 0).or().isNull(MesXslMixingSpec::getDelFlag))
|
||||
.orderByDesc(MesXslMixingSpec::getCreateTime)
|
||||
.orderByDesc(MesXslMixingSpec::getId)
|
||||
.last("LIMIT 1"));
|
||||
if (spec == null || StringUtils.isBlank(spec.getId())) {
|
||||
return BigDecimal.ZERO;
|
||||
}
|
||||
List<MesXslMixingSpecMaterial> materials =
|
||||
mesXslMixingSpecMaterialMapper.selectList(
|
||||
new LambdaQueryWrapper<MesXslMixingSpecMaterial>()
|
||||
.eq(MesXslMixingSpecMaterial::getMixingSpecId, spec.getId()));
|
||||
BigDecimal total = BigDecimal.ZERO;
|
||||
for (MesXslMixingSpecMaterial item : materials) {
|
||||
if (item != null && item.getUnitWeight() != null) {
|
||||
total = total.add(item.getUnitWeight());
|
||||
}
|
||||
}
|
||||
return total;
|
||||
}
|
||||
|
||||
private String buildMixingSpecName(String materialCode) {
|
||||
String code = StringUtils.trimToEmpty(materialCode).toUpperCase();
|
||||
if (code.matches(".*SA\\d{2}$")) {
|
||||
return code;
|
||||
}
|
||||
return code + "SA01";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
package org.jeecg.modules.xslmes.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.jeecg.common.constant.CommonConstant;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslManualSmallMaterialPlanMaintain;
|
||||
import org.jeecg.modules.xslmes.mapper.MesXslManualSmallMaterialPlanMaintainMapper;
|
||||
import org.jeecg.modules.xslmes.service.IMesXslManualSmallMaterialPlanMaintainService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
@Service
|
||||
public class MesXslManualSmallMaterialPlanMaintainServiceImpl
|
||||
extends ServiceImpl<
|
||||
MesXslManualSmallMaterialPlanMaintainMapper, MesXslManualSmallMaterialPlanMaintain>
|
||||
implements IMesXslManualSmallMaterialPlanMaintainService {
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void saveAllRows(List<MesXslManualSmallMaterialPlanMaintain> rows) {
|
||||
this.remove(new LambdaQueryWrapper<>());
|
||||
if (CollectionUtils.isEmpty(rows)) {
|
||||
return;
|
||||
}
|
||||
List<MesXslManualSmallMaterialPlanMaintain> saveList = new ArrayList<>();
|
||||
int sort = 1;
|
||||
Date now = new Date();
|
||||
for (MesXslManualSmallMaterialPlanMaintain row : rows) {
|
||||
if (row == null || !hasBusinessData(row)) {
|
||||
continue;
|
||||
}
|
||||
row.setId(null);
|
||||
row.setSortNo(sort++);
|
||||
row.setFormulaName(StringUtils.trimToNull(row.getFormulaName()));
|
||||
row.setMorningRemark(StringUtils.trimToNull(row.getMorningRemark()));
|
||||
row.setNoonRemark(StringUtils.trimToNull(row.getNoonRemark()));
|
||||
row.setNightRemark(StringUtils.trimToNull(row.getNightRemark()));
|
||||
row.setCreateTime(now);
|
||||
row.setUpdateTime(now);
|
||||
if (row.getDelFlag() == null) {
|
||||
row.setDelFlag(CommonConstant.DEL_FLAG_0);
|
||||
}
|
||||
saveList.add(row);
|
||||
}
|
||||
if (!saveList.isEmpty()) {
|
||||
this.saveBatch(saveList, 200);
|
||||
}
|
||||
}
|
||||
|
||||
private boolean hasBusinessData(MesXslManualSmallMaterialPlanMaintain row) {
|
||||
return StringUtils.isNotBlank(row.getFormulaName())
|
||||
|| row.getMorningSeqNo() != null
|
||||
|| row.getMorningPlanCount() != null
|
||||
|| StringUtils.isNotBlank(row.getMorningRemark())
|
||||
|| row.getNoonSeqNo() != null
|
||||
|| row.getNoonPlanCount() != null
|
||||
|| StringUtils.isNotBlank(row.getNoonRemark())
|
||||
|| row.getNightSeqNo() != null
|
||||
|| row.getNightPlanCount() != null
|
||||
|| StringUtils.isNotBlank(row.getNightRemark());
|
||||
}
|
||||
}
|
||||
@@ -13,8 +13,12 @@ import org.jeecg.common.exception.JeecgBootException;
|
||||
import org.jeecg.modules.mes.material.entity.MesMaterial;
|
||||
import org.jeecg.modules.mes.material.mapper.MesMaterialMapper;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslMasterBatchPlan;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslMixingSpec;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslMixingSpecMaterial;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslProductionOrder;
|
||||
import org.jeecg.modules.xslmes.mapper.MesXslMasterBatchPlanMapper;
|
||||
import org.jeecg.modules.xslmes.mapper.MesXslMixingSpecMapper;
|
||||
import org.jeecg.modules.xslmes.mapper.MesXslMixingSpecMaterialMapper;
|
||||
import org.jeecg.modules.xslmes.service.IMesXslMasterBatchPlanService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -25,6 +29,8 @@ public class MesXslMasterBatchPlanServiceImpl
|
||||
implements IMesXslMasterBatchPlanService {
|
||||
|
||||
@Autowired private MesMaterialMapper mesMaterialMapper;
|
||||
@Autowired private MesXslMixingSpecMapper mesXslMixingSpecMapper;
|
||||
@Autowired private MesXslMixingSpecMaterialMapper mesXslMixingSpecMaterialMapper;
|
||||
|
||||
@Override
|
||||
public List<MesXslMasterBatchPlan> generateBatchFromProductionOrder(MesXslProductionOrder productionOrder) {
|
||||
@@ -70,7 +76,11 @@ public class MesXslMasterBatchPlanServiceImpl
|
||||
private MesXslMasterBatchPlan buildMotherPlan(
|
||||
MesXslProductionOrder productionOrder, MesMaterial motherMaterial, int stageIndex) {
|
||||
BigDecimal planWeight = productionOrder.getPlanQty() == null ? BigDecimal.ZERO : productionOrder.getPlanQty();
|
||||
BigDecimal perCarWeight = BigDecimal.ZERO;
|
||||
BigDecimal perCarWeight = resolvePerCarWeightFromMixingSpec(motherMaterial.getMaterialCode());
|
||||
if (perCarWeight.compareTo(BigDecimal.ZERO) <= 0) {
|
||||
throw new JeecgBootException(
|
||||
"对应混炼示方未配置有效合计重量,无法计算每车重量(物料:" + motherMaterial.getMaterialCode() + ")");
|
||||
}
|
||||
int planCarCount = calcPlanCarCount(planWeight, perCarWeight);
|
||||
|
||||
MesXslMasterBatchPlan plan = new MesXslMasterBatchPlan();
|
||||
@@ -182,4 +192,38 @@ public class MesXslMasterBatchPlanServiceImpl
|
||||
}
|
||||
return planWeight.divide(perCarWeight, 0, RoundingMode.CEILING).intValue();
|
||||
}
|
||||
|
||||
private BigDecimal resolvePerCarWeightFromMixingSpec(String materialCode) {
|
||||
String specName = buildMixingSpecName(materialCode);
|
||||
MesXslMixingSpec spec =
|
||||
mesXslMixingSpecMapper.selectOne(
|
||||
new LambdaQueryWrapper<MesXslMixingSpec>()
|
||||
.eq(MesXslMixingSpec::getSpecName, specName)
|
||||
.and(w -> w.eq(MesXslMixingSpec::getDelFlag, 0).or().isNull(MesXslMixingSpec::getDelFlag))
|
||||
.orderByDesc(MesXslMixingSpec::getCreateTime)
|
||||
.orderByDesc(MesXslMixingSpec::getId)
|
||||
.last("LIMIT 1"));
|
||||
if (spec == null || StringUtils.isBlank(spec.getId())) {
|
||||
return BigDecimal.ZERO;
|
||||
}
|
||||
List<MesXslMixingSpecMaterial> materials =
|
||||
mesXslMixingSpecMaterialMapper.selectList(
|
||||
new LambdaQueryWrapper<MesXslMixingSpecMaterial>()
|
||||
.eq(MesXslMixingSpecMaterial::getMixingSpecId, spec.getId()));
|
||||
BigDecimal total = BigDecimal.ZERO;
|
||||
for (MesXslMixingSpecMaterial item : materials) {
|
||||
if (item != null && item.getUnitWeight() != null) {
|
||||
total = total.add(item.getUnitWeight());
|
||||
}
|
||||
}
|
||||
return total;
|
||||
}
|
||||
|
||||
private String buildMixingSpecName(String materialCode) {
|
||||
String code = StringUtils.trimToEmpty(materialCode).toUpperCase();
|
||||
if (code.matches(".*SA\\d{2}$")) {
|
||||
return code;
|
||||
}
|
||||
return code + "SA01";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,6 +93,7 @@ public class MesXslMixingProductionPlanServiceImpl
|
||||
row.setId(null);
|
||||
row.setMachineId(StringUtils.trimToNull(row.getMachineId()));
|
||||
row.setMachineName(resolveMachineName(row.getMachineId(), machineNameCache));
|
||||
row.setPlanDate(new Date());
|
||||
fillShiftFromPlan(row, "morning");
|
||||
fillShiftFromPlan(row, "noon");
|
||||
fillShiftFromPlan(row, "night");
|
||||
@@ -161,13 +162,18 @@ public class MesXslMixingProductionPlanServiceImpl
|
||||
private void setShiftFromMasterPlan(
|
||||
MesXslMixingProductionPlan row, String shift, MesXslMasterBatchPlan plan) {
|
||||
setShiftPlanType(row, shift, "M");
|
||||
setShiftSourceOrderId(row, shift, plan.getSourceOrderId());
|
||||
setShiftOrderNo(row, shift, plan.getOrderNo());
|
||||
setShiftOrderDate(row, shift, plan.getOrderDate());
|
||||
setShiftFormulaName(
|
||||
row,
|
||||
shift,
|
||||
resolveFormulaNameByMachineAndMaterial(
|
||||
row.getMachineId(), row.getMachineName(), plan.getMaterialCode(), plan.getMesMaterialName()));
|
||||
row.getMachineId(),
|
||||
row.getMachineName(),
|
||||
plan.getMaterialCode(),
|
||||
plan.getMesMaterialName(),
|
||||
true));
|
||||
setShiftPlanWeight(row, shift, plan.getPlanWeight());
|
||||
setShiftPlannedCarCount(row, shift, plan.getPlannedCarCount());
|
||||
setShiftScheduledCarCount(row, shift, plan.getScheduledCarCount());
|
||||
@@ -177,13 +183,18 @@ public class MesXslMixingProductionPlanServiceImpl
|
||||
private void setShiftFromFinalPlan(
|
||||
MesXslMixingProductionPlan row, String shift, MesXslFinalBatchPlan plan) {
|
||||
setShiftPlanType(row, shift, "F");
|
||||
setShiftSourceOrderId(row, shift, plan.getSourceOrderId());
|
||||
setShiftOrderNo(row, shift, plan.getOrderNo());
|
||||
setShiftOrderDate(row, shift, plan.getOrderDate());
|
||||
setShiftFormulaName(
|
||||
row,
|
||||
shift,
|
||||
resolveFormulaNameByMachineAndMaterial(
|
||||
row.getMachineId(), row.getMachineName(), plan.getMaterialCode(), plan.getMesMaterialName()));
|
||||
row.getMachineId(),
|
||||
row.getMachineName(),
|
||||
plan.getMaterialCode(),
|
||||
plan.getMesMaterialName(),
|
||||
true));
|
||||
setShiftPlanWeight(row, shift, plan.getPlanWeight());
|
||||
setShiftPlannedCarCount(row, shift, plan.getPlannedCarCount());
|
||||
setShiftScheduledCarCount(row, shift, plan.getScheduledCarCount());
|
||||
@@ -192,6 +203,7 @@ public class MesXslMixingProductionPlanServiceImpl
|
||||
|
||||
private void clearShiftPlanFields(MesXslMixingProductionPlan row, String shift) {
|
||||
setShiftPlanType(row, shift, null);
|
||||
setShiftSourceOrderId(row, shift, null);
|
||||
setShiftOrderNo(row, shift, null);
|
||||
setShiftOrderDate(row, shift, null);
|
||||
setShiftFormulaName(row, shift, null);
|
||||
@@ -209,6 +221,14 @@ public class MesXslMixingProductionPlanServiceImpl
|
||||
}
|
||||
}
|
||||
|
||||
private void setShiftSourceOrderId(MesXslMixingProductionPlan row, String shift, String value) {
|
||||
switch (shift) {
|
||||
case "morning" -> row.setMorningSourceOrderId(value);
|
||||
case "noon" -> row.setNoonSourceOrderId(value);
|
||||
default -> row.setNightSourceOrderId(value);
|
||||
}
|
||||
}
|
||||
|
||||
private void setShiftOrderNo(MesXslMixingProductionPlan row, String shift, String value) {
|
||||
switch (shift) {
|
||||
case "morning" -> row.setMorningOrderNo(value);
|
||||
@@ -271,6 +291,9 @@ public class MesXslMixingProductionPlanServiceImpl
|
||||
Integer pageNo, Integer pageSize, String keyword, String machineId, String machineName) {
|
||||
String machineIdTrimmed = StringUtils.trimToNull(machineId);
|
||||
String machineNameTrimmed = StringUtils.trimToNull(machineName);
|
||||
if (machineIdTrimmed == null && machineNameTrimmed == null) {
|
||||
return buildEmptyPage(pageNo, pageSize);
|
||||
}
|
||||
List<MesXslMixingProductionPlanOrderOptionVO> all = new ArrayList<>();
|
||||
LambdaQueryWrapper<MesXslMasterBatchPlan> masterWrapper =
|
||||
new LambdaQueryWrapper<MesXslMasterBatchPlan>()
|
||||
@@ -297,9 +320,17 @@ public class MesXslMixingProductionPlanServiceImpl
|
||||
vo.setPlanType("M");
|
||||
vo.setOrderNo(m.getOrderNo());
|
||||
vo.setOrderDate(m.getOrderDate());
|
||||
vo.setFormulaName(
|
||||
String formulaName =
|
||||
resolveFormulaNameByMachineAndMaterial(
|
||||
machineIdTrimmed, machineNameTrimmed, m.getMaterialCode(), m.getMesMaterialName()));
|
||||
machineIdTrimmed,
|
||||
machineNameTrimmed,
|
||||
m.getMaterialCode(),
|
||||
m.getMesMaterialName(),
|
||||
true);
|
||||
if (StringUtils.isBlank(formulaName)) {
|
||||
continue;
|
||||
}
|
||||
vo.setFormulaName(formulaName);
|
||||
vo.setPlanWeight(m.getPlanWeight());
|
||||
vo.setPlannedCarCount(m.getPlannedCarCount());
|
||||
vo.setScheduledCarCount(m.getScheduledCarCount());
|
||||
@@ -313,9 +344,17 @@ public class MesXslMixingProductionPlanServiceImpl
|
||||
vo.setPlanType("F");
|
||||
vo.setOrderNo(f.getOrderNo());
|
||||
vo.setOrderDate(f.getOrderDate());
|
||||
vo.setFormulaName(
|
||||
String formulaName =
|
||||
resolveFormulaNameByMachineAndMaterial(
|
||||
machineIdTrimmed, machineNameTrimmed, f.getMaterialCode(), f.getMesMaterialName()));
|
||||
machineIdTrimmed,
|
||||
machineNameTrimmed,
|
||||
f.getMaterialCode(),
|
||||
f.getMesMaterialName(),
|
||||
true);
|
||||
if (StringUtils.isBlank(formulaName)) {
|
||||
continue;
|
||||
}
|
||||
vo.setFormulaName(formulaName);
|
||||
vo.setPlanWeight(f.getPlanWeight());
|
||||
vo.setPlannedCarCount(f.getPlannedCarCount());
|
||||
vo.setScheduledCarCount(f.getScheduledCarCount());
|
||||
@@ -346,7 +385,11 @@ public class MesXslMixingProductionPlanServiceImpl
|
||||
}
|
||||
|
||||
private String resolveFormulaNameByMachineAndMaterial(
|
||||
String machineId, String machineName, String materialCode, String fallbackName) {
|
||||
String machineId,
|
||||
String machineName,
|
||||
String materialCode,
|
||||
String fallbackName,
|
||||
boolean requireMachineMatch) {
|
||||
String code = StringUtils.trimToEmpty(materialCode);
|
||||
if (StringUtils.isBlank(code)) {
|
||||
return StringUtils.defaultString(fallbackName);
|
||||
@@ -382,9 +425,21 @@ public class MesXslMixingProductionPlanServiceImpl
|
||||
if (prefix != null && StringUtils.isNotBlank(prefix.getSpecName())) {
|
||||
return prefix.getSpecName().trim();
|
||||
}
|
||||
if (requireMachineMatch) {
|
||||
return null;
|
||||
}
|
||||
return StringUtils.defaultIfBlank(fallbackName, targetSpec);
|
||||
}
|
||||
|
||||
private IPage<MesXslMixingProductionPlanOrderOptionVO> buildEmptyPage(Integer pageNo, Integer pageSize) {
|
||||
long current = pageNo == null || pageNo < 1 ? 1 : pageNo;
|
||||
long size = pageSize == null || pageSize < 1 ? 20 : pageSize;
|
||||
Page<MesXslMixingProductionPlanOrderOptionVO> empty = new Page<>(current, size);
|
||||
empty.setTotal(0);
|
||||
empty.setRecords(Collections.emptyList());
|
||||
return empty;
|
||||
}
|
||||
|
||||
private String buildTargetSpecName(String materialCode) {
|
||||
String code = StringUtils.trimToEmpty(materialCode).toUpperCase();
|
||||
if (code.matches(".*SA\\d{2}$")) {
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
package org.jeecg.modules.xslmes.vo;
|
||||
|
||||
import java.util.List;
|
||||
import lombok.Data;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslAutoSmallMaterialPlanMaintain;
|
||||
|
||||
@Data
|
||||
public class MesXslAutoSmallMaterialPlanMaintainSaveAllVO {
|
||||
private List<MesXslAutoSmallMaterialPlanMaintain> rows;
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package org.jeecg.modules.xslmes.vo;
|
||||
|
||||
import java.util.List;
|
||||
import lombok.Data;
|
||||
import org.jeecg.modules.xslmes.entity.MesXslManualSmallMaterialPlanMaintain;
|
||||
|
||||
@Data
|
||||
public class MesXslManualSmallMaterialPlanMaintainSaveAllVO {
|
||||
private List<MesXslManualSmallMaterialPlanMaintain> rows;
|
||||
}
|
||||
@@ -34,11 +34,22 @@ public class MesMaterialController extends JeecgController<MesMaterial, IMesMate
|
||||
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
|
||||
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
|
||||
@RequestParam(name = "onlySales", required = false) Integer onlySales,
|
||||
@RequestParam(name = "excludeProductionFB1", required = false) Integer excludeProductionFB1,
|
||||
HttpServletRequest req) {
|
||||
QueryWrapper<MesMaterial> queryWrapper = QueryGenerator.initQueryWrapper(model, req.getParameterMap());
|
||||
if (onlySales != null && onlySales == 1) {
|
||||
queryWrapper.and(w -> w.isNull("material_phase").or().eq("material_phase", ""));
|
||||
}
|
||||
if (excludeProductionFB1 != null && excludeProductionFB1 == 1) {
|
||||
queryWrapper.and(
|
||||
w ->
|
||||
w.and(p -> p.isNull("material_phase").or().notLikeRight("material_phase", "F"))
|
||||
.and(p -> p.isNull("material_phase").or().notLikeRight("material_phase", "B1"))
|
||||
.and(c -> c.isNull("material_code").or().notLikeRight("material_code", "F"))
|
||||
.and(c -> c.isNull("material_code").or().notLikeRight("material_code", "B1"))
|
||||
.and(n -> n.isNull("material_name").or().notLikeRight("material_name", "F"))
|
||||
.and(n -> n.isNull("material_name").or().notLikeRight("material_name", "B1")));
|
||||
}
|
||||
IPage<MesMaterial> pageList = mesMaterialService.page(new Page<>(pageNo, pageSize), queryWrapper);
|
||||
return Result.OK(pageList);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
SET NAMES utf8mb4;
|
||||
|
||||
-- 视图1:橡胶及配合剂(自动)
|
||||
DROP VIEW IF EXISTS `vw_mes_xsl_mixing_spec_material_auto`;
|
||||
CREATE VIEW `vw_mes_xsl_mixing_spec_material_auto` AS
|
||||
SELECT
|
||||
CONCAT(
|
||||
COALESCE(TRIM(s.spec_name), ''),
|
||||
'-自动-',
|
||||
COALESCE(NULLIF(TRIM(s.machine_name), ''), '')
|
||||
) AS `spec_name`,
|
||||
m.`mixer_material_name` AS `mixer_material_name`,
|
||||
m.`unit_weight` AS `unit_weight`
|
||||
FROM `mes_xsl_mixing_spec_material` m
|
||||
INNER JOIN `mes_xsl_mixing_spec` s ON s.`id` = m.`mixing_spec_id`
|
||||
WHERE (s.`del_flag` = 0 OR s.`del_flag` IS NULL)
|
||||
AND TRIM(COALESCE(m.`material_kind`, '')) = '自动';
|
||||
|
||||
-- 视图2:橡胶及配合剂(人工)
|
||||
DROP VIEW IF EXISTS `vw_mes_xsl_mixing_spec_material_manual`;
|
||||
CREATE VIEW `vw_mes_xsl_mixing_spec_material_manual` AS
|
||||
SELECT
|
||||
CONCAT(
|
||||
COALESCE(TRIM(s.spec_name), ''),
|
||||
'-人工-',
|
||||
COALESCE(NULLIF(TRIM(s.machine_name), ''), '')
|
||||
) AS `spec_name`,
|
||||
m.`mixer_material_name` AS `mixer_material_name`,
|
||||
m.`unit_weight` AS `unit_weight`
|
||||
FROM `mes_xsl_mixing_spec_material` m
|
||||
INNER JOIN `mes_xsl_mixing_spec` s ON s.`id` = m.`mixing_spec_id`
|
||||
WHERE (s.`del_flag` = 0 OR s.`del_flag` IS NULL)
|
||||
AND TRIM(COALESCE(m.`material_kind`, '')) = '人工';
|
||||
@@ -0,0 +1,45 @@
|
||||
SET NAMES utf8mb4;
|
||||
|
||||
-- 自动小料需求计划
|
||||
CREATE TABLE IF NOT EXISTS `mes_xsl_auto_small_material_demand_plan` (
|
||||
`id` varchar(32) NOT NULL COMMENT '主键',
|
||||
`stat_date` date DEFAULT NULL COMMENT '统计日期',
|
||||
`machine_id` varchar(32) DEFAULT NULL COMMENT '机台ID',
|
||||
`machine_name` varchar(64) DEFAULT NULL COMMENT '机台名称',
|
||||
`raw_material_name` varchar(128) NOT NULL COMMENT '原材料名称',
|
||||
`demand_weight` decimal(18,6) DEFAULT '0.000000' COMMENT '需求重量(KG)',
|
||||
`tenant_id` int DEFAULT NULL COMMENT '租户ID',
|
||||
`sys_org_code` varchar(64) DEFAULT NULL COMMENT '所属部门',
|
||||
`create_by` varchar(50) DEFAULT NULL COMMENT '创建人',
|
||||
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
|
||||
`update_by` varchar(50) DEFAULT NULL COMMENT '修改人',
|
||||
`update_time` datetime DEFAULT NULL COMMENT '修改时间',
|
||||
`del_flag` tinyint(1) DEFAULT '0' COMMENT '删除标识(0-正常,1-删除)',
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `idx_auto_small_date` (`stat_date`),
|
||||
KEY `idx_auto_small_machine` (`machine_name`),
|
||||
KEY `idx_auto_small_material` (`raw_material_name`),
|
||||
KEY `idx_auto_small_del` (`del_flag`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='自动小料需求计划';
|
||||
|
||||
-- 人工小料需求计划
|
||||
CREATE TABLE IF NOT EXISTS `mes_xsl_manual_small_material_demand_plan` (
|
||||
`id` varchar(32) NOT NULL COMMENT '主键',
|
||||
`stat_date` date DEFAULT NULL COMMENT '统计日期',
|
||||
`machine_id` varchar(32) DEFAULT NULL COMMENT '机台ID',
|
||||
`machine_name` varchar(64) DEFAULT NULL COMMENT '机台名称',
|
||||
`raw_material_name` varchar(128) NOT NULL COMMENT '原材料名称',
|
||||
`demand_weight` decimal(18,6) DEFAULT '0.000000' COMMENT '需求重量(KG)',
|
||||
`tenant_id` int DEFAULT NULL COMMENT '租户ID',
|
||||
`sys_org_code` varchar(64) DEFAULT NULL COMMENT '所属部门',
|
||||
`create_by` varchar(50) DEFAULT NULL COMMENT '创建人',
|
||||
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
|
||||
`update_by` varchar(50) DEFAULT NULL COMMENT '修改人',
|
||||
`update_time` datetime DEFAULT NULL COMMENT '修改时间',
|
||||
`del_flag` tinyint(1) DEFAULT '0' COMMENT '删除标识(0-正常,1-删除)',
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `idx_manual_small_date` (`stat_date`),
|
||||
KEY `idx_manual_small_machine` (`machine_name`),
|
||||
KEY `idx_manual_small_material` (`raw_material_name`),
|
||||
KEY `idx_manual_small_del` (`del_flag`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='人工小料需求计划';
|
||||
@@ -0,0 +1,51 @@
|
||||
SET NAMES utf8mb4;
|
||||
|
||||
-- 自动小料计划维护
|
||||
CREATE TABLE IF NOT EXISTS `mes_xsl_auto_small_material_plan_maintain` (
|
||||
`id` varchar(32) NOT NULL COMMENT '主键',
|
||||
`sort_no` int DEFAULT NULL COMMENT '排序号',
|
||||
`formula_name` varchar(128) DEFAULT NULL COMMENT '配方名称',
|
||||
`morning_seq_no` int DEFAULT NULL COMMENT '早班序号',
|
||||
`morning_plan_count` int DEFAULT NULL COMMENT '早班计划',
|
||||
`morning_remark` varchar(500) DEFAULT NULL COMMENT '早班备注',
|
||||
`noon_seq_no` int DEFAULT NULL COMMENT '中班序号',
|
||||
`noon_plan_count` int DEFAULT NULL COMMENT '中班计划',
|
||||
`noon_remark` varchar(500) DEFAULT NULL COMMENT '中班备注',
|
||||
`night_seq_no` int DEFAULT NULL COMMENT '夜班序号',
|
||||
`night_plan_count` int DEFAULT NULL COMMENT '夜班计划',
|
||||
`night_remark` varchar(500) DEFAULT NULL COMMENT '夜班备注',
|
||||
`tenant_id` int DEFAULT NULL COMMENT '租户',
|
||||
`sys_org_code` varchar(64) DEFAULT NULL COMMENT '部门编码',
|
||||
`create_by` varchar(32) DEFAULT NULL COMMENT '创建人',
|
||||
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
|
||||
`update_by` varchar(32) DEFAULT NULL COMMENT '更新人',
|
||||
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
|
||||
`del_flag` int DEFAULT '0' COMMENT '删除标记(0正常1删除)',
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `idx_auto_small_plan_sort` (`sort_no`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='自动小料计划维护';
|
||||
|
||||
-- 人工小料计划维护
|
||||
CREATE TABLE IF NOT EXISTS `mes_xsl_manual_small_material_plan_maintain` (
|
||||
`id` varchar(32) NOT NULL COMMENT '主键',
|
||||
`sort_no` int DEFAULT NULL COMMENT '排序号',
|
||||
`formula_name` varchar(128) DEFAULT NULL COMMENT '配方名称',
|
||||
`morning_seq_no` int DEFAULT NULL COMMENT '早班序号',
|
||||
`morning_plan_count` int DEFAULT NULL COMMENT '早班计划',
|
||||
`morning_remark` varchar(500) DEFAULT NULL COMMENT '早班备注',
|
||||
`noon_seq_no` int DEFAULT NULL COMMENT '中班序号',
|
||||
`noon_plan_count` int DEFAULT NULL COMMENT '中班计划',
|
||||
`noon_remark` varchar(500) DEFAULT NULL COMMENT '中班备注',
|
||||
`night_seq_no` int DEFAULT NULL COMMENT '夜班序号',
|
||||
`night_plan_count` int DEFAULT NULL COMMENT '夜班计划',
|
||||
`night_remark` varchar(500) DEFAULT NULL COMMENT '夜班备注',
|
||||
`tenant_id` int DEFAULT NULL COMMENT '租户',
|
||||
`sys_org_code` varchar(64) DEFAULT NULL COMMENT '部门编码',
|
||||
`create_by` varchar(32) DEFAULT NULL COMMENT '创建人',
|
||||
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
|
||||
`update_by` varchar(32) DEFAULT NULL COMMENT '更新人',
|
||||
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
|
||||
`del_flag` int DEFAULT '0' COMMENT '删除标记(0正常1删除)',
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `idx_manual_small_plan_sort` (`sort_no`)
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='人工小料计划维护';
|
||||
@@ -0,0 +1,9 @@
|
||||
-- 密炼生产计划维护:补充保存字段(当前日期、生产订单ID)
|
||||
SET NAMES utf8mb4;
|
||||
|
||||
ALTER TABLE `mes_xsl_mixing_production_plan`
|
||||
ADD COLUMN IF NOT EXISTS `plan_date` date DEFAULT NULL COMMENT '计划日期(保存时写入当前日期)' AFTER `machine_name`,
|
||||
ADD COLUMN IF NOT EXISTS `morning_source_order_id` varchar(32) DEFAULT NULL COMMENT '早班生产订单ID' AFTER `morning_plan_type`,
|
||||
ADD COLUMN IF NOT EXISTS `noon_source_order_id` varchar(32) DEFAULT NULL COMMENT '中班生产订单ID' AFTER `noon_plan_type`,
|
||||
ADD COLUMN IF NOT EXISTS `night_source_order_id` varchar(32) DEFAULT NULL COMMENT '晚班生产订单ID' AFTER `night_plan_type`;
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
<template>
|
||||
<MesXslAutoSmallMaterialDemandPlanList />
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import MesXslAutoSmallMaterialDemandPlanList from '../../xslmes/mesXslAutoSmallMaterialDemandPlan/MesXslAutoSmallMaterialDemandPlanList.vue';
|
||||
</script>
|
||||
@@ -0,0 +1,7 @@
|
||||
<template>
|
||||
<MesXslAutoSmallMaterialPlanMaintainList />
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import MesXslAutoSmallMaterialPlanMaintainList from '../../xslmes/mesXslAutoSmallMaterialPlanMaintain/MesXslAutoSmallMaterialPlanMaintainList.vue';
|
||||
</script>
|
||||
@@ -0,0 +1,7 @@
|
||||
<template>
|
||||
<MesXslManualSmallMaterialDemandPlanList />
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import MesXslManualSmallMaterialDemandPlanList from '../../xslmes/mesXslManualSmallMaterialDemandPlan/MesXslManualSmallMaterialDemandPlanList.vue';
|
||||
</script>
|
||||
@@ -0,0 +1,7 @@
|
||||
<template>
|
||||
<MesXslManualSmallMaterialPlanMaintainList />
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import MesXslManualSmallMaterialPlanMaintainList from '../../xslmes/mesXslManualSmallMaterialPlanMaintain/MesXslManualSmallMaterialPlanMaintainList.vue';
|
||||
</script>
|
||||
@@ -17,6 +17,7 @@
|
||||
|
||||
const selectedRow = ref<Recordable | null>(null);
|
||||
const onlySales = ref(false);
|
||||
const excludeProductionFB1 = ref(false);
|
||||
|
||||
const [registerTable, { reload, getSelectRowKeys, getSelectRows, setSelectedRowKeys, clearSelectedRowKeys }] = useTable({
|
||||
api: materialList,
|
||||
@@ -35,6 +36,7 @@
|
||||
...params,
|
||||
enableFlag: params.enableFlag ?? 1,
|
||||
onlySales: onlySales.value ? 1 : undefined,
|
||||
excludeProductionFB1: excludeProductionFB1.value ? 1 : undefined,
|
||||
}),
|
||||
rowSelection: {
|
||||
type: 'radio',
|
||||
@@ -49,6 +51,7 @@
|
||||
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
|
||||
selectedRow.value = null;
|
||||
onlySales.value = !!data?.onlySales;
|
||||
excludeProductionFB1.value = !!data?.excludeProductionFB1;
|
||||
clearSelectedRowKeys?.();
|
||||
setModalProps({ confirmLoading: false });
|
||||
const materialId = data?.materialId as string | undefined;
|
||||
@@ -84,9 +87,9 @@
|
||||
}
|
||||
emit('select', {
|
||||
materialId: row.id,
|
||||
materialName: row.materialName || '',
|
||||
aliasName: row.aliasName || '',
|
||||
materialCode: row.materialCode || '',
|
||||
materialName: row.materialName || row.material_name || '',
|
||||
aliasName: row.aliasName || row.alias_name || '',
|
||||
materialCode: row.materialCode || row.material_code || '',
|
||||
});
|
||||
closeModal();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
import { defHttp } from '/@/utils/http/axios';
|
||||
|
||||
enum Api {
|
||||
list = '/xslmes/mesXslAutoSmallMaterialDemandPlan/list',
|
||||
exportXls = '/xslmes/mesXslAutoSmallMaterialDemandPlan/exportXls',
|
||||
}
|
||||
|
||||
export const getExportUrl = Api.exportXls;
|
||||
|
||||
export const list = (params) => defHttp.get({ url: Api.list, params });
|
||||
@@ -0,0 +1,26 @@
|
||||
import { BasicColumn, FormSchema } from '/@/components/Table';
|
||||
|
||||
export const baseColumns: BasicColumn[] = [
|
||||
{ title: '原材料名称', align: 'center', dataIndex: 'rawMaterialName', width: 260, ellipsis: true },
|
||||
{ title: '需求重量(KG)', align: 'center', dataIndex: 'demandWeight', width: 180 },
|
||||
];
|
||||
|
||||
export const machineColumns: BasicColumn[] = [{ title: '机台', align: 'center', dataIndex: 'machineName', width: 180 }, ...baseColumns];
|
||||
|
||||
export const searchFormSchema: FormSchema[] = [
|
||||
{
|
||||
label: '日期',
|
||||
field: 'statDate',
|
||||
component: 'DatePicker',
|
||||
componentProps: { valueFormat: 'YYYY-MM-DD', placeholder: '请选择日期' },
|
||||
colProps: { span: 6 },
|
||||
},
|
||||
{ label: '原材料名称', field: 'rawMaterialName', component: 'JInput', colProps: { span: 6 } },
|
||||
];
|
||||
|
||||
export const superQuerySchema = {
|
||||
machineName: { title: '机台', order: 0, view: 'text' },
|
||||
statDate: { title: '日期', order: 1, view: 'date' },
|
||||
rawMaterialName: { title: '原材料名称', order: 2, view: 'text' },
|
||||
demandWeight: { title: '需求重量(KG)', order: 3, view: 'number' },
|
||||
};
|
||||
@@ -0,0 +1,83 @@
|
||||
<template>
|
||||
<div>
|
||||
<BasicTable @register="registerTable">
|
||||
<template #tableTitle>
|
||||
<a-checkbox v-model:checked="groupByMachine" @change="onGroupByMachineChange">按机台统计</a-checkbox>
|
||||
<a-button
|
||||
style="margin-left: 8px"
|
||||
type="primary"
|
||||
v-auth="'xslmes:mes_xsl_auto_small_material_demand_plan:exportXls'"
|
||||
preIcon="ant-design:export-outlined"
|
||||
@click="onExportXls"
|
||||
>
|
||||
导出
|
||||
</a-button>
|
||||
<super-query :config="superQueryConfig" @search="handleSuperQuery" />
|
||||
</template>
|
||||
</BasicTable>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" name="xslmes-mesXslAutoSmallMaterialDemandPlan" setup>
|
||||
import { onMounted, reactive, ref } from 'vue';
|
||||
import { BasicTable } from '/@/components/Table';
|
||||
import { useListPage } from '/@/hooks/system/useListPage';
|
||||
import {
|
||||
baseColumns,
|
||||
machineColumns,
|
||||
searchFormSchema,
|
||||
superQuerySchema,
|
||||
} from './MesXslAutoSmallMaterialDemandPlan.data';
|
||||
import { list, getExportUrl } from './MesXslAutoSmallMaterialDemandPlan.api';
|
||||
|
||||
const queryParam = reactive<any>({ groupByMachine: 0 });
|
||||
const groupByMachine = ref(false);
|
||||
|
||||
const { tableContext, onExportXls } = useListPage({
|
||||
tableProps: {
|
||||
title: '自动小料需求计划',
|
||||
api: list,
|
||||
columns: baseColumns,
|
||||
canResize: true,
|
||||
formConfig: {
|
||||
schemas: searchFormSchema,
|
||||
autoSubmitOnEnter: true,
|
||||
showAdvancedButton: true,
|
||||
},
|
||||
beforeFetch: (params) => {
|
||||
return Object.assign(params, queryParam, {
|
||||
groupByMachine: groupByMachine.value ? 1 : 0,
|
||||
});
|
||||
},
|
||||
},
|
||||
exportConfig: {
|
||||
name: '自动小料需求计划',
|
||||
url: getExportUrl,
|
||||
params: queryParam,
|
||||
},
|
||||
});
|
||||
|
||||
const [registerTable, { reload, setColumns }] = tableContext;
|
||||
const superQueryConfig = reactive(superQuerySchema);
|
||||
|
||||
onMounted(() => {
|
||||
applyColumns();
|
||||
});
|
||||
|
||||
function applyColumns() {
|
||||
setColumns(groupByMachine.value ? machineColumns : baseColumns);
|
||||
}
|
||||
|
||||
function onGroupByMachineChange() {
|
||||
queryParam.groupByMachine = groupByMachine.value ? 1 : 0;
|
||||
applyColumns();
|
||||
reload();
|
||||
}
|
||||
|
||||
function handleSuperQuery(params) {
|
||||
Object.keys(params).forEach((k) => {
|
||||
queryParam[k] = params[k];
|
||||
});
|
||||
reload();
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,9 @@
|
||||
import { defHttp } from '/@/utils/http/axios';
|
||||
|
||||
enum Api {
|
||||
list = '/xslmes/mesXslAutoSmallMaterialPlanMaintain/list',
|
||||
saveAll = '/xslmes/mesXslAutoSmallMaterialPlanMaintain/saveAll',
|
||||
}
|
||||
|
||||
export const list = (params) => defHttp.get({ url: Api.list, params });
|
||||
export const saveAll = (params) => defHttp.post({ url: Api.saveAll, params });
|
||||
@@ -0,0 +1,198 @@
|
||||
<template>
|
||||
<div class="small-plan-page">
|
||||
<div class="small-plan-toolbar">
|
||||
<a-button type="primary" preIcon="ant-design:save-outlined" :loading="saving" @click="handleSaveAll">保存</a-button>
|
||||
</div>
|
||||
|
||||
<a-table :columns="columns" :data-source="rows" :pagination="false" :scroll="{ x: 1220 }" row-key="_rowKey" size="small" bordered>
|
||||
<template #bodyCell="{ column, record, index }">
|
||||
<template v-if="column.dataIndex === 'formulaName'">
|
||||
<a-input :value="record.formulaName" @change="(e) => updateCell(index, 'formulaName', e?.target?.value)" />
|
||||
</template>
|
||||
|
||||
<template
|
||||
v-else-if="
|
||||
column.dataIndex === 'morningSeqNo' ||
|
||||
column.dataIndex === 'noonSeqNo' ||
|
||||
column.dataIndex === 'nightSeqNo' ||
|
||||
column.dataIndex === 'morningPlanCount' ||
|
||||
column.dataIndex === 'noonPlanCount' ||
|
||||
column.dataIndex === 'nightPlanCount'
|
||||
"
|
||||
>
|
||||
<a-input-number
|
||||
:value="record[column.dataIndex]"
|
||||
:min="0"
|
||||
:precision="0"
|
||||
:controls="false"
|
||||
style="width: 100%"
|
||||
@change="(v) => updateCell(index, column.dataIndex as string, v)"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<template
|
||||
v-else-if="
|
||||
column.dataIndex === 'morningRemark' || column.dataIndex === 'noonRemark' || column.dataIndex === 'nightRemark'
|
||||
"
|
||||
>
|
||||
<a-input :value="record[column.dataIndex]" @change="(e) => updateCell(index, column.dataIndex as string, e?.target?.value)" />
|
||||
</template>
|
||||
|
||||
<template v-else-if="column.key === 'action'">
|
||||
<a-button type="text" size="small" class="insert-plus-btn" title="新增" @click="insertBelow(index)">+</a-button>
|
||||
<a-button type="link" size="small" danger @click="removeRow(index)">删</a-button>
|
||||
</template>
|
||||
</template>
|
||||
</a-table>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { computed, ref } from 'vue';
|
||||
import { useMessage } from '/@/hooks/web/useMessage';
|
||||
import { buildUUID } from '/@/utils/uuid';
|
||||
import { list, saveAll } from './MesXslAutoSmallMaterialPlanMaintain.api';
|
||||
|
||||
const { createMessage } = useMessage();
|
||||
const saving = ref(false);
|
||||
const rows = ref<Recordable[]>([]);
|
||||
|
||||
const columns = computed(() => [
|
||||
{ title: '操作', key: 'action', width: 96, fixed: 'left', align: 'center' },
|
||||
{ title: '配方名称', dataIndex: 'formulaName', width: 220, fixed: 'left', align: 'center' },
|
||||
{
|
||||
title: '早班',
|
||||
align: 'center',
|
||||
children: [
|
||||
{ title: '序号', dataIndex: 'morningSeqNo', width: 90, align: 'center' },
|
||||
{ title: '计划', dataIndex: 'morningPlanCount', width: 90, align: 'center' },
|
||||
{ title: '备注', dataIndex: 'morningRemark', width: 160, align: 'center' },
|
||||
],
|
||||
},
|
||||
{
|
||||
title: '中班',
|
||||
align: 'center',
|
||||
children: [
|
||||
{ title: '序号', dataIndex: 'noonSeqNo', width: 90, align: 'center' },
|
||||
{ title: '计划', dataIndex: 'noonPlanCount', width: 90, align: 'center' },
|
||||
{ title: '备注', dataIndex: 'noonRemark', width: 160, align: 'center' },
|
||||
],
|
||||
},
|
||||
{
|
||||
title: '夜班',
|
||||
align: 'center',
|
||||
children: [
|
||||
{ title: '序号', dataIndex: 'nightSeqNo', width: 90, align: 'center' },
|
||||
{ title: '计划', dataIndex: 'nightPlanCount', width: 90, align: 'center' },
|
||||
{ title: '备注', dataIndex: 'nightRemark', width: 160, align: 'center' },
|
||||
],
|
||||
},
|
||||
]);
|
||||
|
||||
function createEmptyRow(): Recordable {
|
||||
return {
|
||||
_rowKey: buildUUID(),
|
||||
id: '',
|
||||
formulaName: '',
|
||||
morningSeqNo: null,
|
||||
morningPlanCount: null,
|
||||
morningRemark: '',
|
||||
noonSeqNo: null,
|
||||
noonPlanCount: null,
|
||||
noonRemark: '',
|
||||
nightSeqNo: null,
|
||||
nightPlanCount: null,
|
||||
nightRemark: '',
|
||||
};
|
||||
}
|
||||
|
||||
function createBlankRows(count = 12) {
|
||||
return Array.from({ length: count }, () => createEmptyRow());
|
||||
}
|
||||
|
||||
function updateCell(index: number, field: string, value: any) {
|
||||
const row = rows.value[index];
|
||||
if (!row) return;
|
||||
row[field] = value;
|
||||
}
|
||||
|
||||
function insertBelow(index: number) {
|
||||
rows.value.splice(index + 1, 0, createEmptyRow());
|
||||
}
|
||||
|
||||
function removeRow(index: number) {
|
||||
rows.value.splice(index, 1);
|
||||
if (!rows.value.length) {
|
||||
rows.value = createBlankRows();
|
||||
}
|
||||
}
|
||||
|
||||
async function loadRows() {
|
||||
const res = await list({ pageNo: 1, pageSize: 500 });
|
||||
const records = (res?.records || res?.result?.records || []) as Recordable[];
|
||||
rows.value = (records || []).map((item) => ({ ...createEmptyRow(), ...item, _rowKey: item.id || buildUUID() }));
|
||||
if (!rows.value.length) {
|
||||
rows.value = createBlankRows();
|
||||
}
|
||||
}
|
||||
|
||||
async function handleSaveAll() {
|
||||
saving.value = true;
|
||||
try {
|
||||
const payload = rows.value.map((r) => {
|
||||
const { _rowKey, ...rest } = r;
|
||||
return rest;
|
||||
});
|
||||
await saveAll({ rows: payload });
|
||||
createMessage.success('保存成功');
|
||||
await loadRows();
|
||||
} finally {
|
||||
saving.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
loadRows();
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.small-plan-page {
|
||||
padding: 8px;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.small-plan-toolbar {
|
||||
margin-bottom: 12px;
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
:deep(.ant-table-thead > tr > th) {
|
||||
text-align: center !important;
|
||||
padding: 4px 6px !important;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
:deep(.ant-table-tbody > tr > td) {
|
||||
padding: 2px 3px !important;
|
||||
}
|
||||
|
||||
:deep(.ant-input),
|
||||
:deep(.ant-input-number),
|
||||
:deep(.ant-input-number-input) {
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
:deep(.ant-input),
|
||||
:deep(.ant-input-number) {
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.insert-plus-btn {
|
||||
color: #52c41a;
|
||||
font-size: 18px;
|
||||
font-weight: 700;
|
||||
line-height: 1;
|
||||
padding: 0 4px;
|
||||
}
|
||||
</style>
|
||||
@@ -0,0 +1,10 @@
|
||||
import { defHttp } from '/@/utils/http/axios';
|
||||
|
||||
enum Api {
|
||||
list = '/xslmes/mesXslManualSmallMaterialDemandPlan/list',
|
||||
exportXls = '/xslmes/mesXslManualSmallMaterialDemandPlan/exportXls',
|
||||
}
|
||||
|
||||
export const getExportUrl = Api.exportXls;
|
||||
|
||||
export const list = (params) => defHttp.get({ url: Api.list, params });
|
||||
@@ -0,0 +1,26 @@
|
||||
import { BasicColumn, FormSchema } from '/@/components/Table';
|
||||
|
||||
export const baseColumns: BasicColumn[] = [
|
||||
{ title: '原材料名称', align: 'center', dataIndex: 'rawMaterialName', width: 260, ellipsis: true },
|
||||
{ title: '需求重量(KG)', align: 'center', dataIndex: 'demandWeight', width: 180 },
|
||||
];
|
||||
|
||||
export const machineColumns: BasicColumn[] = [{ title: '机台', align: 'center', dataIndex: 'machineName', width: 180 }, ...baseColumns];
|
||||
|
||||
export const searchFormSchema: FormSchema[] = [
|
||||
{
|
||||
label: '日期',
|
||||
field: 'statDate',
|
||||
component: 'DatePicker',
|
||||
componentProps: { valueFormat: 'YYYY-MM-DD', placeholder: '请选择日期' },
|
||||
colProps: { span: 6 },
|
||||
},
|
||||
{ label: '原材料名称', field: 'rawMaterialName', component: 'JInput', colProps: { span: 6 } },
|
||||
];
|
||||
|
||||
export const superQuerySchema = {
|
||||
machineName: { title: '机台', order: 0, view: 'text' },
|
||||
statDate: { title: '日期', order: 1, view: 'date' },
|
||||
rawMaterialName: { title: '原材料名称', order: 2, view: 'text' },
|
||||
demandWeight: { title: '需求重量(KG)', order: 3, view: 'number' },
|
||||
};
|
||||
@@ -0,0 +1,83 @@
|
||||
<template>
|
||||
<div>
|
||||
<BasicTable @register="registerTable">
|
||||
<template #tableTitle>
|
||||
<a-checkbox v-model:checked="groupByMachine" @change="onGroupByMachineChange">按机台统计</a-checkbox>
|
||||
<a-button
|
||||
style="margin-left: 8px"
|
||||
type="primary"
|
||||
v-auth="'xslmes:mes_xsl_manual_small_material_demand_plan:exportXls'"
|
||||
preIcon="ant-design:export-outlined"
|
||||
@click="onExportXls"
|
||||
>
|
||||
导出
|
||||
</a-button>
|
||||
<super-query :config="superQueryConfig" @search="handleSuperQuery" />
|
||||
</template>
|
||||
</BasicTable>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" name="xslmes-mesXslManualSmallMaterialDemandPlan" setup>
|
||||
import { onMounted, reactive, ref } from 'vue';
|
||||
import { BasicTable } from '/@/components/Table';
|
||||
import { useListPage } from '/@/hooks/system/useListPage';
|
||||
import {
|
||||
baseColumns,
|
||||
machineColumns,
|
||||
searchFormSchema,
|
||||
superQuerySchema,
|
||||
} from './MesXslManualSmallMaterialDemandPlan.data';
|
||||
import { list, getExportUrl } from './MesXslManualSmallMaterialDemandPlan.api';
|
||||
|
||||
const queryParam = reactive<any>({ groupByMachine: 0 });
|
||||
const groupByMachine = ref(false);
|
||||
|
||||
const { tableContext, onExportXls } = useListPage({
|
||||
tableProps: {
|
||||
title: '人工小料需求计划',
|
||||
api: list,
|
||||
columns: baseColumns,
|
||||
canResize: true,
|
||||
formConfig: {
|
||||
schemas: searchFormSchema,
|
||||
autoSubmitOnEnter: true,
|
||||
showAdvancedButton: true,
|
||||
},
|
||||
beforeFetch: (params) => {
|
||||
return Object.assign(params, queryParam, {
|
||||
groupByMachine: groupByMachine.value ? 1 : 0,
|
||||
});
|
||||
},
|
||||
},
|
||||
exportConfig: {
|
||||
name: '人工小料需求计划',
|
||||
url: getExportUrl,
|
||||
params: queryParam,
|
||||
},
|
||||
});
|
||||
|
||||
const [registerTable, { reload, setColumns }] = tableContext;
|
||||
const superQueryConfig = reactive(superQuerySchema);
|
||||
|
||||
onMounted(() => {
|
||||
applyColumns();
|
||||
});
|
||||
|
||||
function applyColumns() {
|
||||
setColumns(groupByMachine.value ? machineColumns : baseColumns);
|
||||
}
|
||||
|
||||
function onGroupByMachineChange() {
|
||||
queryParam.groupByMachine = groupByMachine.value ? 1 : 0;
|
||||
applyColumns();
|
||||
reload();
|
||||
}
|
||||
|
||||
function handleSuperQuery(params) {
|
||||
Object.keys(params).forEach((k) => {
|
||||
queryParam[k] = params[k];
|
||||
});
|
||||
reload();
|
||||
}
|
||||
</script>
|
||||
@@ -0,0 +1,9 @@
|
||||
import { defHttp } from '/@/utils/http/axios';
|
||||
|
||||
enum Api {
|
||||
list = '/xslmes/mesXslManualSmallMaterialPlanMaintain/list',
|
||||
saveAll = '/xslmes/mesXslManualSmallMaterialPlanMaintain/saveAll',
|
||||
}
|
||||
|
||||
export const list = (params) => defHttp.get({ url: Api.list, params });
|
||||
export const saveAll = (params) => defHttp.post({ url: Api.saveAll, params });
|
||||
@@ -0,0 +1,198 @@
|
||||
<template>
|
||||
<div class="small-plan-page">
|
||||
<div class="small-plan-toolbar">
|
||||
<a-button type="primary" preIcon="ant-design:save-outlined" :loading="saving" @click="handleSaveAll">保存</a-button>
|
||||
</div>
|
||||
|
||||
<a-table :columns="columns" :data-source="rows" :pagination="false" :scroll="{ x: 1220 }" row-key="_rowKey" size="small" bordered>
|
||||
<template #bodyCell="{ column, record, index }">
|
||||
<template v-if="column.dataIndex === 'formulaName'">
|
||||
<a-input :value="record.formulaName" @change="(e) => updateCell(index, 'formulaName', e?.target?.value)" />
|
||||
</template>
|
||||
|
||||
<template
|
||||
v-else-if="
|
||||
column.dataIndex === 'morningSeqNo' ||
|
||||
column.dataIndex === 'noonSeqNo' ||
|
||||
column.dataIndex === 'nightSeqNo' ||
|
||||
column.dataIndex === 'morningPlanCount' ||
|
||||
column.dataIndex === 'noonPlanCount' ||
|
||||
column.dataIndex === 'nightPlanCount'
|
||||
"
|
||||
>
|
||||
<a-input-number
|
||||
:value="record[column.dataIndex]"
|
||||
:min="0"
|
||||
:precision="0"
|
||||
:controls="false"
|
||||
style="width: 100%"
|
||||
@change="(v) => updateCell(index, column.dataIndex as string, v)"
|
||||
/>
|
||||
</template>
|
||||
|
||||
<template
|
||||
v-else-if="
|
||||
column.dataIndex === 'morningRemark' || column.dataIndex === 'noonRemark' || column.dataIndex === 'nightRemark'
|
||||
"
|
||||
>
|
||||
<a-input :value="record[column.dataIndex]" @change="(e) => updateCell(index, column.dataIndex as string, e?.target?.value)" />
|
||||
</template>
|
||||
|
||||
<template v-else-if="column.key === 'action'">
|
||||
<a-button type="text" size="small" class="insert-plus-btn" title="新增" @click="insertBelow(index)">+</a-button>
|
||||
<a-button type="link" size="small" danger @click="removeRow(index)">删</a-button>
|
||||
</template>
|
||||
</template>
|
||||
</a-table>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { computed, ref } from 'vue';
|
||||
import { useMessage } from '/@/hooks/web/useMessage';
|
||||
import { buildUUID } from '/@/utils/uuid';
|
||||
import { list, saveAll } from './MesXslManualSmallMaterialPlanMaintain.api';
|
||||
|
||||
const { createMessage } = useMessage();
|
||||
const saving = ref(false);
|
||||
const rows = ref<Recordable[]>([]);
|
||||
|
||||
const columns = computed(() => [
|
||||
{ title: '操作', key: 'action', width: 96, fixed: 'left', align: 'center' },
|
||||
{ title: '配方名称', dataIndex: 'formulaName', width: 220, fixed: 'left', align: 'center' },
|
||||
{
|
||||
title: '早班',
|
||||
align: 'center',
|
||||
children: [
|
||||
{ title: '序号', dataIndex: 'morningSeqNo', width: 90, align: 'center' },
|
||||
{ title: '计划', dataIndex: 'morningPlanCount', width: 90, align: 'center' },
|
||||
{ title: '备注', dataIndex: 'morningRemark', width: 160, align: 'center' },
|
||||
],
|
||||
},
|
||||
{
|
||||
title: '中班',
|
||||
align: 'center',
|
||||
children: [
|
||||
{ title: '序号', dataIndex: 'noonSeqNo', width: 90, align: 'center' },
|
||||
{ title: '计划', dataIndex: 'noonPlanCount', width: 90, align: 'center' },
|
||||
{ title: '备注', dataIndex: 'noonRemark', width: 160, align: 'center' },
|
||||
],
|
||||
},
|
||||
{
|
||||
title: '夜班',
|
||||
align: 'center',
|
||||
children: [
|
||||
{ title: '序号', dataIndex: 'nightSeqNo', width: 90, align: 'center' },
|
||||
{ title: '计划', dataIndex: 'nightPlanCount', width: 90, align: 'center' },
|
||||
{ title: '备注', dataIndex: 'nightRemark', width: 160, align: 'center' },
|
||||
],
|
||||
},
|
||||
]);
|
||||
|
||||
function createEmptyRow(): Recordable {
|
||||
return {
|
||||
_rowKey: buildUUID(),
|
||||
id: '',
|
||||
formulaName: '',
|
||||
morningSeqNo: null,
|
||||
morningPlanCount: null,
|
||||
morningRemark: '',
|
||||
noonSeqNo: null,
|
||||
noonPlanCount: null,
|
||||
noonRemark: '',
|
||||
nightSeqNo: null,
|
||||
nightPlanCount: null,
|
||||
nightRemark: '',
|
||||
};
|
||||
}
|
||||
|
||||
function createBlankRows(count = 12) {
|
||||
return Array.from({ length: count }, () => createEmptyRow());
|
||||
}
|
||||
|
||||
function updateCell(index: number, field: string, value: any) {
|
||||
const row = rows.value[index];
|
||||
if (!row) return;
|
||||
row[field] = value;
|
||||
}
|
||||
|
||||
function insertBelow(index: number) {
|
||||
rows.value.splice(index + 1, 0, createEmptyRow());
|
||||
}
|
||||
|
||||
function removeRow(index: number) {
|
||||
rows.value.splice(index, 1);
|
||||
if (!rows.value.length) {
|
||||
rows.value = createBlankRows();
|
||||
}
|
||||
}
|
||||
|
||||
async function loadRows() {
|
||||
const res = await list({ pageNo: 1, pageSize: 500 });
|
||||
const records = (res?.records || res?.result?.records || []) as Recordable[];
|
||||
rows.value = (records || []).map((item) => ({ ...createEmptyRow(), ...item, _rowKey: item.id || buildUUID() }));
|
||||
if (!rows.value.length) {
|
||||
rows.value = createBlankRows();
|
||||
}
|
||||
}
|
||||
|
||||
async function handleSaveAll() {
|
||||
saving.value = true;
|
||||
try {
|
||||
const payload = rows.value.map((r) => {
|
||||
const { _rowKey, ...rest } = r;
|
||||
return rest;
|
||||
});
|
||||
await saveAll({ rows: payload });
|
||||
createMessage.success('保存成功');
|
||||
await loadRows();
|
||||
} finally {
|
||||
saving.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
loadRows();
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
.small-plan-page {
|
||||
padding: 8px;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.small-plan-toolbar {
|
||||
margin-bottom: 12px;
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
:deep(.ant-table-thead > tr > th) {
|
||||
text-align: center !important;
|
||||
padding: 4px 6px !important;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
:deep(.ant-table-tbody > tr > td) {
|
||||
padding: 2px 3px !important;
|
||||
}
|
||||
|
||||
:deep(.ant-input),
|
||||
:deep(.ant-input-number),
|
||||
:deep(.ant-input-number-input) {
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
:deep(.ant-input),
|
||||
:deep(.ant-input-number) {
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.insert-plus-btn {
|
||||
color: #52c41a;
|
||||
font-size: 18px;
|
||||
font-weight: 700;
|
||||
line-height: 1;
|
||||
padding: 0 4px;
|
||||
}
|
||||
</style>
|
||||
@@ -1,7 +1,17 @@
|
||||
<template>
|
||||
<div class="mixing-plan-page">
|
||||
<div class="mixing-plan-toolbar">
|
||||
<a-date-picker
|
||||
v-model:value="queryPlanDate"
|
||||
value-format="YYYY-MM-DD"
|
||||
format="YYYY-MM-DD"
|
||||
placeholder="选择计划日期"
|
||||
style="width: 160px"
|
||||
:disabled="saving || refreshing"
|
||||
/>
|
||||
<a-button preIcon="ant-design:search-outlined" :loading="querying" :disabled="saving" @click="handleQuery">查询</a-button>
|
||||
<a-button type="primary" preIcon="ant-design:save-outlined" :loading="saving" @click="handleSaveAll">保存</a-button>
|
||||
<a-button preIcon="ant-design:reload-outlined" :loading="refreshing" :disabled="saving" @click="handleRefresh">刷新</a-button>
|
||||
</div>
|
||||
|
||||
<a-table
|
||||
@@ -100,6 +110,9 @@
|
||||
|
||||
const { createMessage } = useMessage();
|
||||
const saving = ref(false);
|
||||
const refreshing = ref(false);
|
||||
const querying = ref(false);
|
||||
const queryPlanDate = ref<string>('');
|
||||
const rows = ref<Recordable[]>([]);
|
||||
const pickerContext = ref<{ rowIndex: number; shift?: 'morning' | 'noon' | 'night' } | null>(null);
|
||||
|
||||
@@ -228,8 +241,12 @@
|
||||
}
|
||||
|
||||
function openOrderPicker(rowIndex: number, shift: 'morning' | 'noon' | 'night') {
|
||||
pickerContext.value = { rowIndex, shift };
|
||||
const row = rows.value[rowIndex];
|
||||
if (!row?.machineId && !row?.machineName) {
|
||||
createMessage.warning('请先选择机台信息');
|
||||
return;
|
||||
}
|
||||
pickerContext.value = { rowIndex, shift };
|
||||
openOrderModal(true, {
|
||||
planId: row?.[`${shift}PlanId`] || '',
|
||||
machineId: row?.machineId || '',
|
||||
@@ -252,11 +269,26 @@
|
||||
row[`${shift}PlannedCarCount`] = payload?.plannedCarCount ?? null;
|
||||
row[`${shift}ScheduledCarCount`] = payload?.scheduledCarCount ?? null;
|
||||
row[`${shift}FinishedCarCount`] = payload?.finishedCarCount ?? null;
|
||||
row[`${shift}PlanCount`] = calcPlanCount(payload?.plannedCarCount, payload?.finishedCarCount);
|
||||
pickerContext.value = null;
|
||||
}
|
||||
|
||||
function calcPlanCount(plannedCarCount?: number | null, finishedCarCount?: number | null) {
|
||||
const planned = Number(plannedCarCount ?? 0);
|
||||
const finished = Number(finishedCarCount ?? 0);
|
||||
const remain = planned - finished;
|
||||
if (!Number.isFinite(remain)) {
|
||||
return null;
|
||||
}
|
||||
return Math.max(0, remain);
|
||||
}
|
||||
|
||||
async function loadRows() {
|
||||
const res = await list({ pageNo: 1, pageSize: 500 });
|
||||
const res = await list({
|
||||
pageNo: 1,
|
||||
pageSize: 500,
|
||||
planDate: queryPlanDate.value || undefined,
|
||||
});
|
||||
const records = (res?.records || res?.result?.records || []) as Recordable[];
|
||||
rows.value = (records || []).map((item) => ({ ...createEmptyRow(), ...item, _rowKey: item.id || buildUUID() }));
|
||||
if (!rows.value.length) {
|
||||
@@ -279,6 +311,25 @@
|
||||
}
|
||||
}
|
||||
|
||||
async function handleRefresh() {
|
||||
refreshing.value = true;
|
||||
try {
|
||||
await loadRows();
|
||||
createMessage.success('已刷新最新数据');
|
||||
} finally {
|
||||
refreshing.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function handleQuery() {
|
||||
querying.value = true;
|
||||
try {
|
||||
await loadRows();
|
||||
} finally {
|
||||
querying.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
loadRows();
|
||||
</script>
|
||||
|
||||
|
||||
@@ -51,7 +51,12 @@ export const formSchema: FormSchema[] = [
|
||||
},
|
||||
{ label: '生产车间', field: 'productionWorkshop', component: 'Input' },
|
||||
{ label: '加工段数', field: 'processSegmentCount', component: 'InputNumber', componentProps: { min: 0, precision: 0 } },
|
||||
{ label: '物料编号', field: 'materialCode', component: 'Input' },
|
||||
{
|
||||
label: '物料编号',
|
||||
field: 'materialCode',
|
||||
component: 'Input',
|
||||
slot: 'materialCodeSlot',
|
||||
},
|
||||
{ label: 'MES胶料名称', field: 'mesMaterialName', component: 'Input' },
|
||||
{ label: '金蝶物料名称', field: 'kingdeeMaterialName', component: 'Input' },
|
||||
{ label: '金蝶物料规格', field: 'kingdeeMaterialSpec', component: 'Input' },
|
||||
|
||||
@@ -1,19 +1,32 @@
|
||||
<template>
|
||||
<BasicModal v-bind="$attrs" @register="registerModal" :title="title" width="860px" @ok="handleSubmit">
|
||||
<BasicForm @register="registerForm" />
|
||||
<BasicForm @register="registerForm">
|
||||
<template #materialCodeSlot="{ model }">
|
||||
<a-input
|
||||
:value="model.materialCode"
|
||||
readonly
|
||||
placeholder="点击选择胶料"
|
||||
@click="openMaterialPicker"
|
||||
/>
|
||||
</template>
|
||||
</BasicForm>
|
||||
</BasicModal>
|
||||
<MesMaterialSelectModal @register="registerMaterialModal" @select="onMaterialSelected" />
|
||||
</template>
|
||||
|
||||
<script lang="ts" setup>
|
||||
import { computed, ref, unref } from 'vue';
|
||||
import { BasicModal, useModalInner } from '/@/components/Modal';
|
||||
import { BasicForm, useForm } from '/@/components/Form/index';
|
||||
import { useModal } from '/@/components/Modal';
|
||||
import { formSchema } from '../MesXslProductionOrder.data';
|
||||
import { saveOrUpdate } from '../MesXslProductionOrder.api';
|
||||
import MesMaterialSelectModal from '/@/views/mes/material/modules/MesMaterialSelectModal.vue';
|
||||
|
||||
const emit = defineEmits(['register', 'success']);
|
||||
const isUpdate = ref(true);
|
||||
const isDetail = ref(false);
|
||||
const [registerMaterialModal, { openModal: openMaterialModal }] = useModal();
|
||||
|
||||
const [registerForm, { resetFields, setFieldsValue, validate, setProps }] = useForm({
|
||||
labelWidth: 110,
|
||||
@@ -50,4 +63,22 @@
|
||||
setModalProps({ confirmLoading: false });
|
||||
}
|
||||
}
|
||||
|
||||
function openMaterialPicker() {
|
||||
if (isDetail.value) {
|
||||
return;
|
||||
}
|
||||
openMaterialModal(true, {
|
||||
materialId: '',
|
||||
excludeProductionFB1: true,
|
||||
});
|
||||
}
|
||||
|
||||
async function onMaterialSelected(payload: Recordable) {
|
||||
const materialName = payload?.materialName || payload?.material_name || '';
|
||||
await setFieldsValue({
|
||||
materialCode: materialName,
|
||||
mesMaterialName: materialName,
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user