Compare commits
5 Commits
73a22b5ed9
...
a9b3720446
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a9b3720446 | ||
| 372dc10be2 | |||
| 816af5df6e | |||
| 2ec2b6a628 | |||
| 7d7198b802 |
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("保存成功");
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -13,6 +13,7 @@ import org.jeecg.common.system.base.controller.JeecgController;
|
|||||||
import org.jeecg.common.system.query.QueryGenerator;
|
import org.jeecg.common.system.query.QueryGenerator;
|
||||||
import org.jeecg.modules.xslmes.entity.MesXslMixingProductionPlan;
|
import org.jeecg.modules.xslmes.entity.MesXslMixingProductionPlan;
|
||||||
import org.jeecg.modules.xslmes.service.IMesXslMixingProductionPlanService;
|
import org.jeecg.modules.xslmes.service.IMesXslMixingProductionPlanService;
|
||||||
|
import org.jeecg.modules.xslmes.service.MesXslStompNotifyService;
|
||||||
import org.jeecg.modules.xslmes.vo.MesXslMixingProductionPlanOrderOptionVO;
|
import org.jeecg.modules.xslmes.vo.MesXslMixingProductionPlanOrderOptionVO;
|
||||||
import org.jeecg.modules.xslmes.vo.MesXslMixingProductionPlanSaveAllVO;
|
import org.jeecg.modules.xslmes.vo.MesXslMixingProductionPlanSaveAllVO;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
@@ -29,10 +30,13 @@ public class MesXslMixingProductionPlanController
|
|||||||
extends JeecgController<MesXslMixingProductionPlan, IMesXslMixingProductionPlanService> {
|
extends JeecgController<MesXslMixingProductionPlan, IMesXslMixingProductionPlanService> {
|
||||||
|
|
||||||
private final IMesXslMixingProductionPlanService mixingProductionPlanService;
|
private final IMesXslMixingProductionPlanService mixingProductionPlanService;
|
||||||
|
private final MesXslStompNotifyService stompNotify;
|
||||||
|
|
||||||
public MesXslMixingProductionPlanController(
|
public MesXslMixingProductionPlanController(
|
||||||
IMesXslMixingProductionPlanService mixingProductionPlanService) {
|
IMesXslMixingProductionPlanService mixingProductionPlanService,
|
||||||
|
MesXslStompNotifyService stompNotify) {
|
||||||
this.mixingProductionPlanService = mixingProductionPlanService;
|
this.mixingProductionPlanService = mixingProductionPlanService;
|
||||||
|
this.stompNotify = stompNotify;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Operation(summary = "密炼生产计划维护-分页列表查询")
|
@Operation(summary = "密炼生产计划维护-分页列表查询")
|
||||||
@@ -56,6 +60,9 @@ public class MesXslMixingProductionPlanController
|
|||||||
@PostMapping("/saveAll")
|
@PostMapping("/saveAll")
|
||||||
public Result<String> saveAll(@RequestBody MesXslMixingProductionPlanSaveAllVO req) {
|
public Result<String> saveAll(@RequestBody MesXslMixingProductionPlanSaveAllVO req) {
|
||||||
mixingProductionPlanService.saveAllRows(req == null ? null : req.getRows());
|
mixingProductionPlanService.saveAllRows(req == null ? null : req.getRows());
|
||||||
|
//update-begin---author:jiangxh ---date:20260617 for:【密炼计划】整表保存后广播桌面端同步-----------
|
||||||
|
stompNotify.publishMixingProductionPlanChanged("saveAll", null);
|
||||||
|
//update-end---author:jiangxh ---date:20260617 for:【密炼计划】整表保存后广播桌面端同步-----------
|
||||||
return Result.OK("保存成功");
|
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,80 +43,47 @@ public class MesXslMixingProductionPlan implements Serializable {
|
|||||||
@Schema(description = "机台名称")
|
@Schema(description = "机台名称")
|
||||||
private String machineName;
|
private String machineName;
|
||||||
|
|
||||||
@Schema(description = "早班计划ID")
|
@Excel(name = "班次标识", width = 10)
|
||||||
private String morningPlanId;
|
@Schema(description = "班次标识:1早班 2中班 3晚班")
|
||||||
@Schema(description = "早班计划类型 M母胶/F终胶")
|
private Integer shiftFlag;
|
||||||
private String morningPlanType;
|
|
||||||
@Excel(name = "早班生产订单", width = 20)
|
|
||||||
private String morningOrderNo;
|
|
||||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
|
|
||||||
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
|
||||||
@Schema(description = "早班订单日期")
|
|
||||||
private Date morningOrderDate;
|
|
||||||
@Excel(name = "早班配方名称", width = 20)
|
|
||||||
private String morningFormulaName;
|
|
||||||
@Excel(name = "早班计划重量", width = 15)
|
|
||||||
private BigDecimal morningPlanWeight;
|
|
||||||
@Excel(name = "早班计划车数", width = 12)
|
|
||||||
private Integer morningPlannedCarCount;
|
|
||||||
@Excel(name = "早班已排产车数", width = 12)
|
|
||||||
private Integer morningScheduledCarCount;
|
|
||||||
@Excel(name = "早班完成车数", width = 12)
|
|
||||||
private Integer morningFinishedCarCount;
|
|
||||||
@Excel(name = "早班计划", width = 12)
|
|
||||||
private Integer morningPlanCount;
|
|
||||||
@Excel(name = "早班备注", width = 20)
|
|
||||||
private String morningRemark;
|
|
||||||
|
|
||||||
@Schema(description = "中班计划ID")
|
|
||||||
private String noonPlanId;
|
|
||||||
@Schema(description = "中班计划类型 M母胶/F终胶")
|
|
||||||
private String noonPlanType;
|
|
||||||
@Excel(name = "中班生产订单", width = 20)
|
|
||||||
private String noonOrderNo;
|
|
||||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
|
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
|
||||||
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||||
@Schema(description = "中班订单日期")
|
@Schema(description = "计划日期(保存时写入当前日期)")
|
||||||
private Date noonOrderDate;
|
private Date planDate;
|
||||||
@Excel(name = "中班配方名称", width = 20)
|
@Schema(description = "计划号(yyyyMMddA三位流水)")
|
||||||
private String noonFormulaName;
|
private String planNo;
|
||||||
@Excel(name = "中班计划重量", width = 15)
|
|
||||||
private BigDecimal noonPlanWeight;
|
|
||||||
@Excel(name = "中班计划车数", width = 12)
|
|
||||||
private Integer noonPlannedCarCount;
|
|
||||||
@Excel(name = "中班已排产车数", width = 12)
|
|
||||||
private Integer noonScheduledCarCount;
|
|
||||||
@Excel(name = "中班完成车数", width = 12)
|
|
||||||
private Integer noonFinishedCarCount;
|
|
||||||
@Excel(name = "中班计划", width = 12)
|
|
||||||
private Integer noonPlanCount;
|
|
||||||
@Excel(name = "中班备注", width = 20)
|
|
||||||
private String noonRemark;
|
|
||||||
|
|
||||||
@Schema(description = "晚班计划ID")
|
@Schema(description = "计划ID(母胶/终胶计划)")
|
||||||
private String nightPlanId;
|
private String planId;
|
||||||
@Schema(description = "晚班计划类型 M母胶/F终胶")
|
@Schema(description = "计划类型 M母胶/F终胶")
|
||||||
private String nightPlanType;
|
private String planType;
|
||||||
@Excel(name = "晚班生产订单", width = 20)
|
@Schema(description = "生产订单ID")
|
||||||
private String nightOrderNo;
|
private String sourceOrderId;
|
||||||
|
@Schema(description = "胶料ID(取母胶/终胶计划materialCode)")
|
||||||
|
private String materialId;
|
||||||
|
@Schema(description = "胶料名称(取母胶/终胶计划mesMaterialName)")
|
||||||
|
private String materialName;
|
||||||
|
@Excel(name = "生产订单", width = 20)
|
||||||
|
private String orderNo;
|
||||||
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
|
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
|
||||||
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
@DateTimeFormat(pattern = "yyyy-MM-dd")
|
||||||
@Schema(description = "晚班订单日期")
|
@Schema(description = "订单日期")
|
||||||
private Date nightOrderDate;
|
private Date orderDate;
|
||||||
@Excel(name = "晚班配方名称", width = 20)
|
@Excel(name = "配方名称", width = 20)
|
||||||
private String nightFormulaName;
|
private String formulaName;
|
||||||
@Excel(name = "晚班计划重量", width = 15)
|
@Excel(name = "计划重量", width = 15)
|
||||||
private BigDecimal nightPlanWeight;
|
private BigDecimal planWeight;
|
||||||
@Excel(name = "晚班计划车数", width = 12)
|
@Excel(name = "计划车数", width = 12)
|
||||||
private Integer nightPlannedCarCount;
|
private Integer plannedCarCount;
|
||||||
@Excel(name = "晚班已排产车数", width = 12)
|
@Excel(name = "已排产车数", width = 12)
|
||||||
private Integer nightScheduledCarCount;
|
private Integer scheduledCarCount;
|
||||||
@Excel(name = "晚班完成车数", width = 12)
|
@Excel(name = "完成车数", width = 12)
|
||||||
private Integer nightFinishedCarCount;
|
private Integer finishedCarCount;
|
||||||
@Excel(name = "晚班计划", width = 12)
|
@Excel(name = "计划", width = 12)
|
||||||
private Integer nightPlanCount;
|
private Integer planCount;
|
||||||
@Excel(name = "晚班备注", width = 20)
|
@Excel(name = "备注", width = 20)
|
||||||
private String nightRemark;
|
private String remark;
|
||||||
|
|
||||||
private Integer tenantId;
|
private Integer tenantId;
|
||||||
private String sysOrgCode;
|
private String sysOrgCode;
|
||||||
|
|||||||
@@ -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);
|
||||||
|
}
|
||||||
@@ -99,6 +99,14 @@ public class MesXslStompNotifyService {
|
|||||||
}
|
}
|
||||||
//update-end---author:jiangxh ---date:20260617 for:【快检实验标准】桌面端只读同步 STOMP-----------
|
//update-end---author:jiangxh ---date:20260617 for:【快检实验标准】桌面端只读同步 STOMP-----------
|
||||||
|
|
||||||
|
//update-begin---author:jiangxh ---date:20260617 for:【密炼计划】桌面端只读同步 STOMP-----------
|
||||||
|
/** 广播密炼生产计划变更事件到 /topic/sync/mes-mixing-production-plans */
|
||||||
|
public void publishMixingProductionPlanChanged(String action, String mixingProductionPlanId) {
|
||||||
|
publish("/topic/sync/mes-mixing-production-plans", "MIXING_PRODUCTION_PLAN_CHANGED",
|
||||||
|
"mixingProductionPlanId", mixingProductionPlanId, action);
|
||||||
|
}
|
||||||
|
//update-end---author:jiangxh ---date:20260617 for:【密炼计划】桌面端只读同步 STOMP-----------
|
||||||
|
|
||||||
// ─────────────────────────── 私有辅助 ────────────────────────────
|
// ─────────────────────────── 私有辅助 ────────────────────────────
|
||||||
|
|
||||||
private void publish(String topic, String cmd, String idKey, String idValue, String action) {
|
private void publish(String topic, String cmd, String idKey, String idValue, String action) {
|
||||||
|
|||||||
@@ -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.entity.MesMaterial;
|
||||||
import org.jeecg.modules.mes.material.mapper.MesMaterialMapper;
|
import org.jeecg.modules.mes.material.mapper.MesMaterialMapper;
|
||||||
import org.jeecg.modules.xslmes.entity.MesXslFinalBatchPlan;
|
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.entity.MesXslProductionOrder;
|
||||||
import org.jeecg.modules.xslmes.mapper.MesXslFinalBatchPlanMapper;
|
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.jeecg.modules.xslmes.service.IMesXslFinalBatchPlanService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@@ -25,6 +29,8 @@ public class MesXslFinalBatchPlanServiceImpl
|
|||||||
implements IMesXslFinalBatchPlanService {
|
implements IMesXslFinalBatchPlanService {
|
||||||
|
|
||||||
@Autowired private MesMaterialMapper mesMaterialMapper;
|
@Autowired private MesMaterialMapper mesMaterialMapper;
|
||||||
|
@Autowired private MesXslMixingSpecMapper mesXslMixingSpecMapper;
|
||||||
|
@Autowired private MesXslMixingSpecMaterialMapper mesXslMixingSpecMaterialMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public MesXslFinalBatchPlan generateFromProductionOrder(MesXslProductionOrder productionOrder) {
|
public MesXslFinalBatchPlan generateFromProductionOrder(MesXslProductionOrder productionOrder) {
|
||||||
@@ -43,7 +49,11 @@ public class MesXslFinalBatchPlanServiceImpl
|
|||||||
}
|
}
|
||||||
|
|
||||||
BigDecimal planWeight = productionOrder.getPlanQty() == null ? BigDecimal.ZERO : productionOrder.getPlanQty();
|
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);
|
int planCarCount = calcPlanCarCount(planWeight, perCarWeight);
|
||||||
|
|
||||||
MesXslFinalBatchPlan plan = new MesXslFinalBatchPlan();
|
MesXslFinalBatchPlan plan = new MesXslFinalBatchPlan();
|
||||||
@@ -136,4 +146,38 @@ public class MesXslFinalBatchPlanServiceImpl
|
|||||||
}
|
}
|
||||||
return planWeight.divide(perCarWeight, 0, RoundingMode.CEILING).intValue();
|
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.entity.MesMaterial;
|
||||||
import org.jeecg.modules.mes.material.mapper.MesMaterialMapper;
|
import org.jeecg.modules.mes.material.mapper.MesMaterialMapper;
|
||||||
import org.jeecg.modules.xslmes.entity.MesXslMasterBatchPlan;
|
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.entity.MesXslProductionOrder;
|
||||||
import org.jeecg.modules.xslmes.mapper.MesXslMasterBatchPlanMapper;
|
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.jeecg.modules.xslmes.service.IMesXslMasterBatchPlanService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
@@ -25,6 +29,8 @@ public class MesXslMasterBatchPlanServiceImpl
|
|||||||
implements IMesXslMasterBatchPlanService {
|
implements IMesXslMasterBatchPlanService {
|
||||||
|
|
||||||
@Autowired private MesMaterialMapper mesMaterialMapper;
|
@Autowired private MesMaterialMapper mesMaterialMapper;
|
||||||
|
@Autowired private MesXslMixingSpecMapper mesXslMixingSpecMapper;
|
||||||
|
@Autowired private MesXslMixingSpecMaterialMapper mesXslMixingSpecMaterialMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<MesXslMasterBatchPlan> generateBatchFromProductionOrder(MesXslProductionOrder productionOrder) {
|
public List<MesXslMasterBatchPlan> generateBatchFromProductionOrder(MesXslProductionOrder productionOrder) {
|
||||||
@@ -70,7 +76,11 @@ public class MesXslMasterBatchPlanServiceImpl
|
|||||||
private MesXslMasterBatchPlan buildMotherPlan(
|
private MesXslMasterBatchPlan buildMotherPlan(
|
||||||
MesXslProductionOrder productionOrder, MesMaterial motherMaterial, int stageIndex) {
|
MesXslProductionOrder productionOrder, MesMaterial motherMaterial, int stageIndex) {
|
||||||
BigDecimal planWeight = productionOrder.getPlanQty() == null ? BigDecimal.ZERO : productionOrder.getPlanQty();
|
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);
|
int planCarCount = calcPlanCarCount(planWeight, perCarWeight);
|
||||||
|
|
||||||
MesXslMasterBatchPlan plan = new MesXslMasterBatchPlan();
|
MesXslMasterBatchPlan plan = new MesXslMasterBatchPlan();
|
||||||
@@ -182,4 +192,38 @@ public class MesXslMasterBatchPlanServiceImpl
|
|||||||
}
|
}
|
||||||
return planWeight.divide(perCarWeight, 0, RoundingMode.CEILING).intValue();
|
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";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import java.time.ZoneId;
|
||||||
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
@@ -15,6 +17,8 @@ import java.util.Objects;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.jeecg.common.constant.CommonConstant;
|
import org.jeecg.common.constant.CommonConstant;
|
||||||
|
import org.jeecg.modules.mes.material.entity.MesMaterial;
|
||||||
|
import org.jeecg.modules.mes.material.mapper.MesMaterialMapper;
|
||||||
import org.jeecg.modules.xslmes.entity.MesXslEquipmentLedger;
|
import org.jeecg.modules.xslmes.entity.MesXslEquipmentLedger;
|
||||||
import org.jeecg.modules.xslmes.entity.MesXslFinalBatchPlan;
|
import org.jeecg.modules.xslmes.entity.MesXslFinalBatchPlan;
|
||||||
import org.jeecg.modules.xslmes.entity.MesXslMasterBatchPlan;
|
import org.jeecg.modules.xslmes.entity.MesXslMasterBatchPlan;
|
||||||
@@ -35,21 +39,25 @@ import org.springframework.util.CollectionUtils;
|
|||||||
public class MesXslMixingProductionPlanServiceImpl
|
public class MesXslMixingProductionPlanServiceImpl
|
||||||
extends ServiceImpl<MesXslMixingProductionPlanMapper, MesXslMixingProductionPlan>
|
extends ServiceImpl<MesXslMixingProductionPlanMapper, MesXslMixingProductionPlan>
|
||||||
implements IMesXslMixingProductionPlanService {
|
implements IMesXslMixingProductionPlanService {
|
||||||
|
private static final DateTimeFormatter PLAN_NO_DATE_FMT = DateTimeFormatter.BASIC_ISO_DATE;
|
||||||
|
|
||||||
private final MesXslEquipmentLedgerMapper equipmentLedgerMapper;
|
private final MesXslEquipmentLedgerMapper equipmentLedgerMapper;
|
||||||
private final MesXslMasterBatchPlanMapper masterBatchPlanMapper;
|
private final MesXslMasterBatchPlanMapper masterBatchPlanMapper;
|
||||||
private final MesXslFinalBatchPlanMapper finalBatchPlanMapper;
|
private final MesXslFinalBatchPlanMapper finalBatchPlanMapper;
|
||||||
private final MesXslMixingSpecMapper mixingSpecMapper;
|
private final MesXslMixingSpecMapper mixingSpecMapper;
|
||||||
|
private final MesMaterialMapper mesMaterialMapper;
|
||||||
|
|
||||||
public MesXslMixingProductionPlanServiceImpl(
|
public MesXslMixingProductionPlanServiceImpl(
|
||||||
MesXslEquipmentLedgerMapper equipmentLedgerMapper,
|
MesXslEquipmentLedgerMapper equipmentLedgerMapper,
|
||||||
MesXslMasterBatchPlanMapper masterBatchPlanMapper,
|
MesXslMasterBatchPlanMapper masterBatchPlanMapper,
|
||||||
MesXslFinalBatchPlanMapper finalBatchPlanMapper,
|
MesXslFinalBatchPlanMapper finalBatchPlanMapper,
|
||||||
MesXslMixingSpecMapper mixingSpecMapper) {
|
MesXslMixingSpecMapper mixingSpecMapper,
|
||||||
|
MesMaterialMapper mesMaterialMapper) {
|
||||||
this.equipmentLedgerMapper = equipmentLedgerMapper;
|
this.equipmentLedgerMapper = equipmentLedgerMapper;
|
||||||
this.masterBatchPlanMapper = masterBatchPlanMapper;
|
this.masterBatchPlanMapper = masterBatchPlanMapper;
|
||||||
this.finalBatchPlanMapper = finalBatchPlanMapper;
|
this.finalBatchPlanMapper = finalBatchPlanMapper;
|
||||||
this.mixingSpecMapper = mixingSpecMapper;
|
this.mixingSpecMapper = mixingSpecMapper;
|
||||||
|
this.mesMaterialMapper = mesMaterialMapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -60,13 +68,14 @@ public class MesXslMixingProductionPlanServiceImpl
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Map<String, String> machineNameCache = new HashMap<>();
|
Map<String, String> machineNameCache = new HashMap<>();
|
||||||
|
Map<String, Integer> dailyPlanNoCounter = new HashMap<>();
|
||||||
List<MesXslMixingProductionPlan> saveList = new ArrayList<>();
|
List<MesXslMixingProductionPlan> saveList = new ArrayList<>();
|
||||||
int sort = 1;
|
int sort = 1;
|
||||||
for (MesXslMixingProductionPlan row : rows) {
|
for (MesXslMixingProductionPlan row : rows) {
|
||||||
if (row == null || !hasBusinessData(row)) {
|
if (row == null || !hasBusinessData(row)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
normalizeRow(row, machineNameCache);
|
normalizeRow(row, machineNameCache, dailyPlanNoCounter);
|
||||||
row.setSortNo(sort++);
|
row.setSortNo(sort++);
|
||||||
saveList.add(row);
|
saveList.add(row);
|
||||||
}
|
}
|
||||||
@@ -77,25 +86,27 @@ public class MesXslMixingProductionPlanServiceImpl
|
|||||||
|
|
||||||
private boolean hasBusinessData(MesXslMixingProductionPlan row) {
|
private boolean hasBusinessData(MesXslMixingProductionPlan row) {
|
||||||
return StringUtils.isNotBlank(row.getMachineId())
|
return StringUtils.isNotBlank(row.getMachineId())
|
||||||
|| StringUtils.isNotBlank(row.getMorningPlanId())
|
|| StringUtils.isNotBlank(row.getPlanId())
|
||||||
|| StringUtils.isNotBlank(row.getNoonPlanId())
|
|| StringUtils.isNotBlank(row.getRemark())
|
||||||
|| StringUtils.isNotBlank(row.getNightPlanId())
|
|| row.getPlanCount() != null;
|
||||||
|| StringUtils.isNotBlank(row.getMorningRemark())
|
|
||||||
|| StringUtils.isNotBlank(row.getNoonRemark())
|
|
||||||
|| StringUtils.isNotBlank(row.getNightRemark())
|
|
||||||
|| row.getMorningPlanCount() != null
|
|
||||||
|| row.getNoonPlanCount() != null
|
|
||||||
|| row.getNightPlanCount() != null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void normalizeRow(
|
private void normalizeRow(
|
||||||
MesXslMixingProductionPlan row, Map<String, String> machineNameCache) {
|
MesXslMixingProductionPlan row,
|
||||||
|
Map<String, String> machineNameCache,
|
||||||
|
Map<String, Integer> dailyPlanNoCounter) {
|
||||||
row.setId(null);
|
row.setId(null);
|
||||||
row.setMachineId(StringUtils.trimToNull(row.getMachineId()));
|
row.setMachineId(StringUtils.trimToNull(row.getMachineId()));
|
||||||
row.setMachineName(resolveMachineName(row.getMachineId(), machineNameCache));
|
row.setMachineName(resolveMachineName(row.getMachineId(), machineNameCache));
|
||||||
fillShiftFromPlan(row, "morning");
|
Integer shiftFlag = row.getShiftFlag();
|
||||||
fillShiftFromPlan(row, "noon");
|
if (shiftFlag == null || shiftFlag < 1 || shiftFlag > 3) {
|
||||||
fillShiftFromPlan(row, "night");
|
row.setShiftFlag(1);
|
||||||
|
}
|
||||||
|
row.setPlanId(StringUtils.trimToNull(row.getPlanId()));
|
||||||
|
row.setPlanType(StringUtils.upperCase(StringUtils.trimToNull(row.getPlanType())));
|
||||||
|
row.setPlanDate(new Date());
|
||||||
|
row.setPlanNo(generatePlanNo(row.getPlanDate(), dailyPlanNoCounter));
|
||||||
|
fillFromPlan(row);
|
||||||
Date now = new Date();
|
Date now = new Date();
|
||||||
if (row.getCreateTime() == null) {
|
if (row.getCreateTime() == null) {
|
||||||
row.setCreateTime(now);
|
row.setCreateTime(now);
|
||||||
@@ -106,6 +117,14 @@ public class MesXslMixingProductionPlanServiceImpl
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private String generatePlanNo(Date planDate, Map<String, Integer> dailyPlanNoCounter) {
|
||||||
|
String datePart = planDate.toInstant().atZone(ZoneId.systemDefault()).toLocalDate().format(PLAN_NO_DATE_FMT);
|
||||||
|
Integer current = dailyPlanNoCounter.get(datePart);
|
||||||
|
int next = current == null ? 1 : current + 1;
|
||||||
|
dailyPlanNoCounter.put(datePart, next);
|
||||||
|
return datePart + "A" + String.format("%03d", next);
|
||||||
|
}
|
||||||
|
|
||||||
private String resolveMachineName(String machineId, Map<String, String> cache) {
|
private String resolveMachineName(String machineId, Map<String, String> cache) {
|
||||||
if (StringUtils.isBlank(machineId)) {
|
if (StringUtils.isBlank(machineId)) {
|
||||||
return null;
|
return null;
|
||||||
@@ -118,152 +137,118 @@ public class MesXslMixingProductionPlanServiceImpl
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void fillShiftFromPlan(MesXslMixingProductionPlan row, String shift) {
|
private void fillFromPlan(MesXslMixingProductionPlan row) {
|
||||||
String planId = getPlanId(row, shift);
|
String planId = row.getPlanId();
|
||||||
String planType = StringUtils.upperCase(StringUtils.trimToEmpty(getPlanType(row, shift)));
|
String planType = StringUtils.upperCase(StringUtils.trimToEmpty(row.getPlanType()));
|
||||||
if (StringUtils.isBlank(planId)) {
|
if (StringUtils.isBlank(planId)) {
|
||||||
clearShiftPlanFields(row, shift);
|
clearPlanFields(row);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ("M".equals(planType)) {
|
if ("M".equals(planType)) {
|
||||||
MesXslMasterBatchPlan plan = masterBatchPlanMapper.selectById(planId);
|
MesXslMasterBatchPlan plan = masterBatchPlanMapper.selectById(planId);
|
||||||
if (plan == null) {
|
if (plan == null) {
|
||||||
clearShiftPlanFields(row, shift);
|
clearPlanFields(row);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setShiftFromMasterPlan(row, shift, plan);
|
setFromMasterPlan(row, plan);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
MesXslFinalBatchPlan finalPlan = finalBatchPlanMapper.selectById(planId);
|
MesXslFinalBatchPlan finalPlan = finalBatchPlanMapper.selectById(planId);
|
||||||
if (finalPlan == null) {
|
if (finalPlan == null) {
|
||||||
clearShiftPlanFields(row, shift);
|
clearPlanFields(row);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setShiftFromFinalPlan(row, shift, finalPlan);
|
setFromFinalPlan(row, finalPlan);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getPlanId(MesXslMixingProductionPlan row, String shift) {
|
private void setFromMasterPlan(MesXslMixingProductionPlan row, MesXslMasterBatchPlan plan) {
|
||||||
return switch (shift) {
|
row.setPlanType("M");
|
||||||
case "morning" -> StringUtils.trimToNull(row.getMorningPlanId());
|
row.setSourceOrderId(plan.getSourceOrderId());
|
||||||
case "noon" -> StringUtils.trimToNull(row.getNoonPlanId());
|
row.setMaterialId(resolveMesMaterialId(plan.getMesMaterialName(), plan.getMaterialCode()));
|
||||||
default -> StringUtils.trimToNull(row.getNightPlanId());
|
row.setMaterialName(plan.getMesMaterialName());
|
||||||
};
|
row.setOrderNo(plan.getOrderNo());
|
||||||
}
|
row.setOrderDate(plan.getOrderDate());
|
||||||
|
row.setFormulaName(
|
||||||
private String getPlanType(MesXslMixingProductionPlan row, String shift) {
|
|
||||||
return switch (shift) {
|
|
||||||
case "morning" -> row.getMorningPlanType();
|
|
||||||
case "noon" -> row.getNoonPlanType();
|
|
||||||
default -> row.getNightPlanType();
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setShiftFromMasterPlan(
|
|
||||||
MesXslMixingProductionPlan row, String shift, MesXslMasterBatchPlan plan) {
|
|
||||||
setShiftPlanType(row, shift, "M");
|
|
||||||
setShiftOrderNo(row, shift, plan.getOrderNo());
|
|
||||||
setShiftOrderDate(row, shift, plan.getOrderDate());
|
|
||||||
setShiftFormulaName(
|
|
||||||
row,
|
|
||||||
shift,
|
|
||||||
resolveFormulaNameByMachineAndMaterial(
|
resolveFormulaNameByMachineAndMaterial(
|
||||||
row.getMachineId(), row.getMachineName(), plan.getMaterialCode(), plan.getMesMaterialName()));
|
row.getMachineId(),
|
||||||
setShiftPlanWeight(row, shift, plan.getPlanWeight());
|
row.getMachineName(),
|
||||||
setShiftPlannedCarCount(row, shift, plan.getPlannedCarCount());
|
plan.getMaterialCode(),
|
||||||
setShiftScheduledCarCount(row, shift, plan.getScheduledCarCount());
|
plan.getMesMaterialName(),
|
||||||
setShiftFinishedCarCount(row, shift, plan.getFinishedCarCount());
|
true));
|
||||||
|
row.setPlanWeight(plan.getPlanWeight());
|
||||||
|
row.setPlannedCarCount(plan.getPlannedCarCount());
|
||||||
|
row.setScheduledCarCount(plan.getScheduledCarCount());
|
||||||
|
row.setFinishedCarCount(plan.getFinishedCarCount());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setShiftFromFinalPlan(
|
private void setFromFinalPlan(MesXslMixingProductionPlan row, MesXslFinalBatchPlan plan) {
|
||||||
MesXslMixingProductionPlan row, String shift, MesXslFinalBatchPlan plan) {
|
row.setPlanType("F");
|
||||||
setShiftPlanType(row, shift, "F");
|
row.setSourceOrderId(plan.getSourceOrderId());
|
||||||
setShiftOrderNo(row, shift, plan.getOrderNo());
|
row.setMaterialId(resolveMesMaterialId(plan.getMesMaterialName(), plan.getMaterialCode()));
|
||||||
setShiftOrderDate(row, shift, plan.getOrderDate());
|
row.setMaterialName(plan.getMesMaterialName());
|
||||||
setShiftFormulaName(
|
row.setOrderNo(plan.getOrderNo());
|
||||||
row,
|
row.setOrderDate(plan.getOrderDate());
|
||||||
shift,
|
row.setFormulaName(
|
||||||
resolveFormulaNameByMachineAndMaterial(
|
resolveFormulaNameByMachineAndMaterial(
|
||||||
row.getMachineId(), row.getMachineName(), plan.getMaterialCode(), plan.getMesMaterialName()));
|
row.getMachineId(),
|
||||||
setShiftPlanWeight(row, shift, plan.getPlanWeight());
|
row.getMachineName(),
|
||||||
setShiftPlannedCarCount(row, shift, plan.getPlannedCarCount());
|
plan.getMaterialCode(),
|
||||||
setShiftScheduledCarCount(row, shift, plan.getScheduledCarCount());
|
plan.getMesMaterialName(),
|
||||||
setShiftFinishedCarCount(row, shift, plan.getFinishedCarCount());
|
true));
|
||||||
|
row.setPlanWeight(plan.getPlanWeight());
|
||||||
|
row.setPlannedCarCount(plan.getPlannedCarCount());
|
||||||
|
row.setScheduledCarCount(plan.getScheduledCarCount());
|
||||||
|
row.setFinishedCarCount(plan.getFinishedCarCount());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void clearShiftPlanFields(MesXslMixingProductionPlan row, String shift) {
|
private void clearPlanFields(MesXslMixingProductionPlan row) {
|
||||||
setShiftPlanType(row, shift, null);
|
row.setPlanType(null);
|
||||||
setShiftOrderNo(row, shift, null);
|
row.setSourceOrderId(null);
|
||||||
setShiftOrderDate(row, shift, null);
|
row.setMaterialId(null);
|
||||||
setShiftFormulaName(row, shift, null);
|
row.setMaterialName(null);
|
||||||
setShiftPlanWeight(row, shift, null);
|
row.setOrderNo(null);
|
||||||
setShiftPlannedCarCount(row, shift, null);
|
row.setOrderDate(null);
|
||||||
setShiftScheduledCarCount(row, shift, null);
|
row.setFormulaName(null);
|
||||||
setShiftFinishedCarCount(row, shift, null);
|
row.setPlanWeight(null);
|
||||||
|
row.setPlannedCarCount(null);
|
||||||
|
row.setScheduledCarCount(null);
|
||||||
|
row.setFinishedCarCount(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setShiftPlanType(MesXslMixingProductionPlan row, String shift, String value) {
|
private String resolveMesMaterialId(String mesMaterialName, String materialCode) {
|
||||||
switch (shift) {
|
String name = StringUtils.trimToNull(mesMaterialName);
|
||||||
case "morning" -> row.setMorningPlanType(value);
|
String code = StringUtils.trimToNull(materialCode);
|
||||||
case "noon" -> row.setNoonPlanType(value);
|
LambdaQueryWrapper<MesMaterial> byNameWrapper =
|
||||||
default -> row.setNightPlanType(value);
|
new LambdaQueryWrapper<MesMaterial>()
|
||||||
|
.eq(name != null, MesMaterial::getMaterialName, name)
|
||||||
|
.and(
|
||||||
|
w ->
|
||||||
|
w.eq(MesMaterial::getDelFlag, CommonConstant.DEL_FLAG_0)
|
||||||
|
.or()
|
||||||
|
.isNull(MesMaterial::getDelFlag))
|
||||||
|
.orderByDesc(MesMaterial::getUpdateTime)
|
||||||
|
.orderByDesc(MesMaterial::getCreateTime)
|
||||||
|
.last("LIMIT 1");
|
||||||
|
MesMaterial byName = mesMaterialMapper.selectOne(byNameWrapper);
|
||||||
|
if (byName != null) {
|
||||||
|
return byName.getId();
|
||||||
}
|
}
|
||||||
}
|
if (code == null) {
|
||||||
|
return null;
|
||||||
private void setShiftOrderNo(MesXslMixingProductionPlan row, String shift, String value) {
|
|
||||||
switch (shift) {
|
|
||||||
case "morning" -> row.setMorningOrderNo(value);
|
|
||||||
case "noon" -> row.setNoonOrderNo(value);
|
|
||||||
default -> row.setNightOrderNo(value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setShiftOrderDate(MesXslMixingProductionPlan row, String shift, Date value) {
|
|
||||||
switch (shift) {
|
|
||||||
case "morning" -> row.setMorningOrderDate(value);
|
|
||||||
case "noon" -> row.setNoonOrderDate(value);
|
|
||||||
default -> row.setNightOrderDate(value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setShiftFormulaName(MesXslMixingProductionPlan row, String shift, String value) {
|
|
||||||
switch (shift) {
|
|
||||||
case "morning" -> row.setMorningFormulaName(value);
|
|
||||||
case "noon" -> row.setNoonFormulaName(value);
|
|
||||||
default -> row.setNightFormulaName(value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setShiftPlanWeight(
|
|
||||||
MesXslMixingProductionPlan row, String shift, java.math.BigDecimal value) {
|
|
||||||
switch (shift) {
|
|
||||||
case "morning" -> row.setMorningPlanWeight(value);
|
|
||||||
case "noon" -> row.setNoonPlanWeight(value);
|
|
||||||
default -> row.setNightPlanWeight(value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setShiftPlannedCarCount(MesXslMixingProductionPlan row, String shift, Integer value) {
|
|
||||||
switch (shift) {
|
|
||||||
case "morning" -> row.setMorningPlannedCarCount(value);
|
|
||||||
case "noon" -> row.setNoonPlannedCarCount(value);
|
|
||||||
default -> row.setNightPlannedCarCount(value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setShiftScheduledCarCount(MesXslMixingProductionPlan row, String shift, Integer value) {
|
|
||||||
switch (shift) {
|
|
||||||
case "morning" -> row.setMorningScheduledCarCount(value);
|
|
||||||
case "noon" -> row.setNoonScheduledCarCount(value);
|
|
||||||
default -> row.setNightScheduledCarCount(value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setShiftFinishedCarCount(MesXslMixingProductionPlan row, String shift, Integer value) {
|
|
||||||
switch (shift) {
|
|
||||||
case "morning" -> row.setMorningFinishedCarCount(value);
|
|
||||||
case "noon" -> row.setNoonFinishedCarCount(value);
|
|
||||||
default -> row.setNightFinishedCarCount(value);
|
|
||||||
}
|
}
|
||||||
|
LambdaQueryWrapper<MesMaterial> byCodeWrapper =
|
||||||
|
new LambdaQueryWrapper<MesMaterial>()
|
||||||
|
.eq(MesMaterial::getMaterialCode, code)
|
||||||
|
.and(
|
||||||
|
w ->
|
||||||
|
w.eq(MesMaterial::getDelFlag, CommonConstant.DEL_FLAG_0)
|
||||||
|
.or()
|
||||||
|
.isNull(MesMaterial::getDelFlag))
|
||||||
|
.orderByDesc(MesMaterial::getUpdateTime)
|
||||||
|
.orderByDesc(MesMaterial::getCreateTime)
|
||||||
|
.last("LIMIT 1");
|
||||||
|
MesMaterial byCode = mesMaterialMapper.selectOne(byCodeWrapper);
|
||||||
|
return byCode == null ? null : byCode.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -271,6 +256,9 @@ public class MesXslMixingProductionPlanServiceImpl
|
|||||||
Integer pageNo, Integer pageSize, String keyword, String machineId, String machineName) {
|
Integer pageNo, Integer pageSize, String keyword, String machineId, String machineName) {
|
||||||
String machineIdTrimmed = StringUtils.trimToNull(machineId);
|
String machineIdTrimmed = StringUtils.trimToNull(machineId);
|
||||||
String machineNameTrimmed = StringUtils.trimToNull(machineName);
|
String machineNameTrimmed = StringUtils.trimToNull(machineName);
|
||||||
|
if (machineIdTrimmed == null && machineNameTrimmed == null) {
|
||||||
|
return buildEmptyPage(pageNo, pageSize);
|
||||||
|
}
|
||||||
List<MesXslMixingProductionPlanOrderOptionVO> all = new ArrayList<>();
|
List<MesXslMixingProductionPlanOrderOptionVO> all = new ArrayList<>();
|
||||||
LambdaQueryWrapper<MesXslMasterBatchPlan> masterWrapper =
|
LambdaQueryWrapper<MesXslMasterBatchPlan> masterWrapper =
|
||||||
new LambdaQueryWrapper<MesXslMasterBatchPlan>()
|
new LambdaQueryWrapper<MesXslMasterBatchPlan>()
|
||||||
@@ -297,9 +285,17 @@ public class MesXslMixingProductionPlanServiceImpl
|
|||||||
vo.setPlanType("M");
|
vo.setPlanType("M");
|
||||||
vo.setOrderNo(m.getOrderNo());
|
vo.setOrderNo(m.getOrderNo());
|
||||||
vo.setOrderDate(m.getOrderDate());
|
vo.setOrderDate(m.getOrderDate());
|
||||||
vo.setFormulaName(
|
String formulaName =
|
||||||
resolveFormulaNameByMachineAndMaterial(
|
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.setPlanWeight(m.getPlanWeight());
|
||||||
vo.setPlannedCarCount(m.getPlannedCarCount());
|
vo.setPlannedCarCount(m.getPlannedCarCount());
|
||||||
vo.setScheduledCarCount(m.getScheduledCarCount());
|
vo.setScheduledCarCount(m.getScheduledCarCount());
|
||||||
@@ -313,9 +309,17 @@ public class MesXslMixingProductionPlanServiceImpl
|
|||||||
vo.setPlanType("F");
|
vo.setPlanType("F");
|
||||||
vo.setOrderNo(f.getOrderNo());
|
vo.setOrderNo(f.getOrderNo());
|
||||||
vo.setOrderDate(f.getOrderDate());
|
vo.setOrderDate(f.getOrderDate());
|
||||||
vo.setFormulaName(
|
String formulaName =
|
||||||
resolveFormulaNameByMachineAndMaterial(
|
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.setPlanWeight(f.getPlanWeight());
|
||||||
vo.setPlannedCarCount(f.getPlannedCarCount());
|
vo.setPlannedCarCount(f.getPlannedCarCount());
|
||||||
vo.setScheduledCarCount(f.getScheduledCarCount());
|
vo.setScheduledCarCount(f.getScheduledCarCount());
|
||||||
@@ -346,7 +350,11 @@ public class MesXslMixingProductionPlanServiceImpl
|
|||||||
}
|
}
|
||||||
|
|
||||||
private String resolveFormulaNameByMachineAndMaterial(
|
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);
|
String code = StringUtils.trimToEmpty(materialCode);
|
||||||
if (StringUtils.isBlank(code)) {
|
if (StringUtils.isBlank(code)) {
|
||||||
return StringUtils.defaultString(fallbackName);
|
return StringUtils.defaultString(fallbackName);
|
||||||
@@ -382,9 +390,21 @@ public class MesXslMixingProductionPlanServiceImpl
|
|||||||
if (prefix != null && StringUtils.isNotBlank(prefix.getSpecName())) {
|
if (prefix != null && StringUtils.isNotBlank(prefix.getSpecName())) {
|
||||||
return prefix.getSpecName().trim();
|
return prefix.getSpecName().trim();
|
||||||
}
|
}
|
||||||
|
if (requireMachineMatch) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
return StringUtils.defaultIfBlank(fallbackName, targetSpec);
|
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) {
|
private String buildTargetSpecName(String materialCode) {
|
||||||
String code = StringUtils.trimToEmpty(materialCode).toUpperCase();
|
String code = StringUtils.trimToEmpty(materialCode).toUpperCase();
|
||||||
if (code.matches(".*SA\\d{2}$")) {
|
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 = "pageNo", defaultValue = "1") Integer pageNo,
|
||||||
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
|
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
|
||||||
@RequestParam(name = "onlySales", required = false) Integer onlySales,
|
@RequestParam(name = "onlySales", required = false) Integer onlySales,
|
||||||
|
@RequestParam(name = "excludeProductionFB1", required = false) Integer excludeProductionFB1,
|
||||||
HttpServletRequest req) {
|
HttpServletRequest req) {
|
||||||
QueryWrapper<MesMaterial> queryWrapper = QueryGenerator.initQueryWrapper(model, req.getParameterMap());
|
QueryWrapper<MesMaterial> queryWrapper = QueryGenerator.initQueryWrapper(model, req.getParameterMap());
|
||||||
if (onlySales != null && onlySales == 1) {
|
if (onlySales != null && onlySales == 1) {
|
||||||
queryWrapper.and(w -> w.isNull("material_phase").or().eq("material_phase", ""));
|
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);
|
IPage<MesMaterial> pageList = mesMaterialService.page(new Page<>(pageNo, pageSize), queryWrapper);
|
||||||
return Result.OK(pageList);
|
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,18 @@
|
|||||||
|
-- 密炼生产计划维护:早中晚共用字段 + 班次标识
|
||||||
|
SET NAMES utf8mb4;
|
||||||
|
|
||||||
|
ALTER TABLE `mes_xsl_mixing_production_plan`
|
||||||
|
ADD COLUMN IF NOT EXISTS `shift_flag` int DEFAULT NULL COMMENT '班次标识:1早班 2中班 3晚班' AFTER `machine_name`,
|
||||||
|
ADD COLUMN IF NOT EXISTS `plan_id` varchar(32) DEFAULT NULL COMMENT '计划ID(母胶/终胶计划)' AFTER `plan_date`,
|
||||||
|
ADD COLUMN IF NOT EXISTS `plan_type` varchar(2) DEFAULT NULL COMMENT '计划类型:M母胶/F终胶' AFTER `plan_id`,
|
||||||
|
ADD COLUMN IF NOT EXISTS `source_order_id` varchar(32) DEFAULT NULL COMMENT '生产订单ID' AFTER `plan_type`,
|
||||||
|
ADD COLUMN IF NOT EXISTS `order_no` varchar(64) DEFAULT NULL COMMENT '生产订单号' AFTER `source_order_id`,
|
||||||
|
ADD COLUMN IF NOT EXISTS `order_date` date DEFAULT NULL COMMENT '订单日期' AFTER `order_no`,
|
||||||
|
ADD COLUMN IF NOT EXISTS `formula_name` varchar(128) DEFAULT NULL COMMENT '配方名称' AFTER `order_date`,
|
||||||
|
ADD COLUMN IF NOT EXISTS `plan_weight` decimal(18,6) DEFAULT NULL COMMENT '计划重量' AFTER `formula_name`,
|
||||||
|
ADD COLUMN IF NOT EXISTS `planned_car_count` int DEFAULT NULL COMMENT '计划车数' AFTER `plan_weight`,
|
||||||
|
ADD COLUMN IF NOT EXISTS `scheduled_car_count` int DEFAULT NULL COMMENT '已排产车数' AFTER `planned_car_count`,
|
||||||
|
ADD COLUMN IF NOT EXISTS `finished_car_count` int DEFAULT NULL COMMENT '完成车数' AFTER `scheduled_car_count`,
|
||||||
|
ADD COLUMN IF NOT EXISTS `plan_count` int DEFAULT NULL COMMENT '计划' AFTER `finished_car_count`,
|
||||||
|
ADD COLUMN IF NOT EXISTS `remark` varchar(500) DEFAULT NULL COMMENT '备注' AFTER `plan_count`;
|
||||||
|
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
-- 密炼生产计划维护:删除早/中/晚冗余字段,保留共用字段 + 班次标识
|
||||||
|
SET NAMES utf8mb4;
|
||||||
|
|
||||||
|
SET @drop_sql = (
|
||||||
|
SELECT IFNULL(
|
||||||
|
CONCAT(
|
||||||
|
'ALTER TABLE `mes_xsl_mixing_production_plan` ',
|
||||||
|
GROUP_CONCAT(CONCAT('DROP COLUMN `', column_name, '`') ORDER BY ordinal_position SEPARATOR ', ')
|
||||||
|
),
|
||||||
|
'SELECT 1'
|
||||||
|
)
|
||||||
|
FROM information_schema.COLUMNS
|
||||||
|
WHERE TABLE_SCHEMA = DATABASE()
|
||||||
|
AND TABLE_NAME = 'mes_xsl_mixing_production_plan'
|
||||||
|
AND COLUMN_NAME IN (
|
||||||
|
'morning_plan_id', 'morning_plan_type', 'morning_source_order_id', 'morning_order_no', 'morning_order_date',
|
||||||
|
'morning_formula_name', 'morning_plan_weight', 'morning_planned_car_count', 'morning_scheduled_car_count',
|
||||||
|
'morning_finished_car_count', 'morning_plan_count', 'morning_remark',
|
||||||
|
'noon_plan_id', 'noon_plan_type', 'noon_source_order_id', 'noon_order_no', 'noon_order_date',
|
||||||
|
'noon_formula_name', 'noon_plan_weight', 'noon_planned_car_count', 'noon_scheduled_car_count',
|
||||||
|
'noon_finished_car_count', 'noon_plan_count', 'noon_remark',
|
||||||
|
'night_plan_id', 'night_plan_type', 'night_source_order_id', 'night_order_no', 'night_order_date',
|
||||||
|
'night_formula_name', 'night_plan_weight', 'night_planned_car_count', 'night_scheduled_car_count',
|
||||||
|
'night_finished_car_count', 'night_plan_count', 'night_remark'
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
PREPARE stmt FROM @drop_sql;
|
||||||
|
EXECUTE stmt;
|
||||||
|
DEALLOCATE PREPARE stmt;
|
||||||
|
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
-- 密炼生产计划维护:删表重建(注意:会清空原表数据)
|
||||||
|
SET NAMES utf8mb4;
|
||||||
|
|
||||||
|
DROP TABLE IF EXISTS `mes_xsl_mixing_production_plan`;
|
||||||
|
|
||||||
|
CREATE TABLE `mes_xsl_mixing_production_plan` (
|
||||||
|
`id` varchar(32) NOT NULL COMMENT '主键',
|
||||||
|
`sort_no` int DEFAULT NULL COMMENT '排序号',
|
||||||
|
`machine_id` varchar(32) DEFAULT NULL COMMENT '机台ID(mes_xsl_equipment_ledger.id)',
|
||||||
|
`machine_name` varchar(128) DEFAULT NULL COMMENT '机台名称冗余',
|
||||||
|
`shift_flag` int DEFAULT NULL COMMENT '班次标识:1早班 2中班 3晚班',
|
||||||
|
`plan_date` date DEFAULT NULL COMMENT '计划日期(保存时写入当前日期)',
|
||||||
|
`plan_no` varchar(32) DEFAULT NULL COMMENT '计划号(yyyyMMddA三位流水)',
|
||||||
|
`plan_id` varchar(32) DEFAULT NULL COMMENT '计划ID(母胶/终胶计划)',
|
||||||
|
`plan_type` varchar(2) DEFAULT NULL COMMENT '计划类型:M母胶/F终胶',
|
||||||
|
`source_order_id` varchar(32) DEFAULT NULL COMMENT '生产订单ID',
|
||||||
|
`material_id` varchar(32) DEFAULT NULL COMMENT '胶料ID(mes_material.id)',
|
||||||
|
`material_name` varchar(128) DEFAULT NULL COMMENT '胶料名称(取母胶/终胶计划mesMaterialName)',
|
||||||
|
`order_no` varchar(64) DEFAULT NULL COMMENT '生产订单号',
|
||||||
|
`order_date` date DEFAULT NULL COMMENT '订单日期',
|
||||||
|
`formula_name` varchar(128) DEFAULT NULL COMMENT '配方名称',
|
||||||
|
`plan_weight` decimal(18,6) DEFAULT NULL COMMENT '计划重量',
|
||||||
|
`planned_car_count` int DEFAULT NULL COMMENT '计划车数',
|
||||||
|
`scheduled_car_count` int DEFAULT NULL COMMENT '已排产车数',
|
||||||
|
`finished_car_count` int DEFAULT NULL COMMENT '完成车数',
|
||||||
|
`plan_count` int DEFAULT NULL COMMENT '计划',
|
||||||
|
`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_mxmp_machine` (`machine_id`),
|
||||||
|
KEY `idx_mxmp_plan_date` (`plan_date`),
|
||||||
|
KEY `idx_mxmp_plan_no` (`plan_no`),
|
||||||
|
KEY `idx_mxmp_shift_flag` (`shift_flag`),
|
||||||
|
KEY `idx_mxmp_plan_id` (`plan_id`),
|
||||||
|
KEY `idx_mxmp_sort` (`sort_no`),
|
||||||
|
KEY `idx_mxmp_tenant` (`tenant_id`)
|
||||||
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='MES密炼生产计划维护';
|
||||||
|
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
-- 密炼生产计划维护:新增胶料ID和胶料名称字段
|
||||||
|
SET NAMES utf8mb4;
|
||||||
|
|
||||||
|
ALTER TABLE `mes_xsl_mixing_production_plan`
|
||||||
|
ADD COLUMN IF NOT EXISTS `material_id` varchar(32) DEFAULT NULL COMMENT '胶料ID(mes_material.id)' AFTER `source_order_id`,
|
||||||
|
ADD COLUMN IF NOT EXISTS `material_name` varchar(128) DEFAULT NULL COMMENT '胶料名称(取母胶/终胶计划mesMaterialName)' AFTER `material_id`;
|
||||||
|
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
-- 密炼生产计划维护:修正胶料ID字段定义为mes_material主键ID
|
||||||
|
SET NAMES utf8mb4;
|
||||||
|
|
||||||
|
ALTER TABLE `mes_xsl_mixing_production_plan`
|
||||||
|
MODIFY COLUMN `material_id` varchar(32) DEFAULT NULL COMMENT '胶料ID(mes_material.id)';
|
||||||
|
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
-- 密炼生产计划维护:新增计划号字段
|
||||||
|
SET NAMES utf8mb4;
|
||||||
|
|
||||||
|
ALTER TABLE `mes_xsl_mixing_production_plan`
|
||||||
|
ADD COLUMN IF NOT EXISTS `plan_no` varchar(32) DEFAULT NULL COMMENT '计划号(yyyyMMddA三位流水)' AFTER `plan_date`,
|
||||||
|
ADD INDEX `idx_mxmp_plan_no` (`plan_no`);
|
||||||
|
|
||||||
374
jeecg-boot/scan_mixing_plan.json
Normal file
374
jeecg-boot/scan_mixing_plan.json
Normal file
@@ -0,0 +1,374 @@
|
|||||||
|
{
|
||||||
|
"scanKeyword": "MesXslMixingProductionPlan",
|
||||||
|
"entityClass": "MesXslMixingProductionPlan",
|
||||||
|
"tableName": "mes_xsl_mixing_production_plan",
|
||||||
|
"javaEntityFile": "jeecg-boot\\jeecg-boot-module\\jeecg-module-xslmes\\src\\main\\java\\org\\jeecg\\modules\\xslmes\\entity\\MesXslMixingProductionPlan.java",
|
||||||
|
"hasIzEnable": false,
|
||||||
|
"hasCodeUniqueness": false,
|
||||||
|
"uniquenessFields": [],
|
||||||
|
"backendArch": {
|
||||||
|
"unifiedAnonCtrl": "jeecg-boot\\jeecg-boot-module\\jeecg-module-xslmes\\src\\main\\java\\org\\jeecg\\modules\\xslmes\\controller\\MesXslDesktopAnonController.java",
|
||||||
|
"registeredInAnonCtrl": true,
|
||||||
|
"anonEndpoints": [
|
||||||
|
"list"
|
||||||
|
],
|
||||||
|
"stompNotifySvc": "jeecg-boot\\jeecg-boot-module\\jeecg-module-xslmes\\src\\main\\java\\org\\jeecg\\modules\\xslmes\\service\\MesXslStompNotifyService.java",
|
||||||
|
"registeredInStompSvc": false,
|
||||||
|
"bizCtrlFile": "jeecg-boot\\jeecg-boot-module\\jeecg-module-xslmes\\src\\main\\java\\org\\jeecg\\modules\\xslmes\\controller\\MesXslMixingProductionPlanController.java",
|
||||||
|
"bizCtrlUsesSharedNotify": false,
|
||||||
|
"bizCtrlHasPrivatePublish": false
|
||||||
|
},
|
||||||
|
"wpfRegistrationStatus": {
|
||||||
|
"syncModuleService": false,
|
||||||
|
"syncModuleCoordinator": false,
|
||||||
|
"navigationView": false,
|
||||||
|
"stompSubscribe": false,
|
||||||
|
"menuRegistered": false,
|
||||||
|
"tenantMenuRegistered": false,
|
||||||
|
"syncModuleFilePath": "yy-admin-master\\YY.Admin\\Module\\SyncModule.cs",
|
||||||
|
"navExtFilePath": "yy-admin-master\\YY.Admin\\Module\\NavigationExtensions.cs",
|
||||||
|
"stompWsFilePath": "yy-admin-master\\YY.Admin\\Infrastructure\\Hubs\\StompWebSocketService.cs",
|
||||||
|
"menuSeedFilePath": "yy-admin-master\\YY.Admin.Core\\SeedData\\SysMenuSeedData.cs",
|
||||||
|
"summary": "✗ 待完成: SyncModule服务注册, SyncModule协调器注册, NavigationExtensions视图注册, STOMP订阅, 菜单注册"
|
||||||
|
},
|
||||||
|
"menuSuggestion": {
|
||||||
|
"parentMenuId": 1300150000101,
|
||||||
|
"parentMenuTitle": "基础资料",
|
||||||
|
"nextMenuId": 1300150011401,
|
||||||
|
"nextOrderNo": 113,
|
||||||
|
"menuIdPattern": "130015001{N}01,N 每次 +1(1→101,2→201...)",
|
||||||
|
"alreadyExists": false,
|
||||||
|
"existingMenuId": null
|
||||||
|
},
|
||||||
|
"apiPrefix": "/xslmes/mesXslMixingProductionPlan",
|
||||||
|
"stompCmd": "MIXING_PRODUCTION_PLAN_CHANGED",
|
||||||
|
"stompTopic": "/topic/sync/mes-mixing-production-plans",
|
||||||
|
"stompSubscriptionId": "sub-mes-xsl-mixing-production-plan",
|
||||||
|
"syncMode": "B",
|
||||||
|
"syncModeReason": "有/anon/免密端点,适合模式B",
|
||||||
|
"filterFields": [
|
||||||
|
"machineId",
|
||||||
|
"machineName",
|
||||||
|
"planNo",
|
||||||
|
"planType",
|
||||||
|
"materialName"
|
||||||
|
],
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"javaName": "sortNo",
|
||||||
|
"csName": "SortNo",
|
||||||
|
"sqlName": "sort_no",
|
||||||
|
"javaType": "Integer",
|
||||||
|
"csType": "int?",
|
||||||
|
"comment": "",
|
||||||
|
"isPk": false,
|
||||||
|
"isAudit": false,
|
||||||
|
"isIzEnable": false,
|
||||||
|
"required": false,
|
||||||
|
"dictCode": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"javaName": "machineId",
|
||||||
|
"csName": "MachineId",
|
||||||
|
"sqlName": "machine_id",
|
||||||
|
"javaType": "String",
|
||||||
|
"csType": "string?",
|
||||||
|
"comment": "",
|
||||||
|
"isPk": false,
|
||||||
|
"isAudit": false,
|
||||||
|
"isIzEnable": false,
|
||||||
|
"required": false,
|
||||||
|
"dictCode": "id"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"javaName": "machineName",
|
||||||
|
"csName": "MachineName",
|
||||||
|
"sqlName": "machine_name",
|
||||||
|
"javaType": "String",
|
||||||
|
"csType": "string?",
|
||||||
|
"comment": "",
|
||||||
|
"isPk": false,
|
||||||
|
"isAudit": false,
|
||||||
|
"isIzEnable": false,
|
||||||
|
"required": false,
|
||||||
|
"dictCode": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"javaName": "shiftFlag",
|
||||||
|
"csName": "ShiftFlag",
|
||||||
|
"sqlName": "shift_flag",
|
||||||
|
"javaType": "Integer",
|
||||||
|
"csType": "int?",
|
||||||
|
"comment": "",
|
||||||
|
"isPk": false,
|
||||||
|
"isAudit": false,
|
||||||
|
"isIzEnable": false,
|
||||||
|
"required": false,
|
||||||
|
"dictCode": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"javaName": "planDate",
|
||||||
|
"csName": "PlanDate",
|
||||||
|
"sqlName": "plan_date",
|
||||||
|
"javaType": "Date",
|
||||||
|
"csType": "DateTime?",
|
||||||
|
"comment": "",
|
||||||
|
"isPk": false,
|
||||||
|
"isAudit": false,
|
||||||
|
"isIzEnable": false,
|
||||||
|
"required": false,
|
||||||
|
"dictCode": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"javaName": "planNo",
|
||||||
|
"csName": "PlanNo",
|
||||||
|
"sqlName": "plan_no",
|
||||||
|
"javaType": "String",
|
||||||
|
"csType": "string?",
|
||||||
|
"comment": "",
|
||||||
|
"isPk": false,
|
||||||
|
"isAudit": false,
|
||||||
|
"isIzEnable": false,
|
||||||
|
"required": false,
|
||||||
|
"dictCode": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"javaName": "planId",
|
||||||
|
"csName": "PlanId",
|
||||||
|
"sqlName": "plan_id",
|
||||||
|
"javaType": "String",
|
||||||
|
"csType": "string?",
|
||||||
|
"comment": "",
|
||||||
|
"isPk": false,
|
||||||
|
"isAudit": false,
|
||||||
|
"isIzEnable": false,
|
||||||
|
"required": false,
|
||||||
|
"dictCode": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"javaName": "planType",
|
||||||
|
"csName": "PlanType",
|
||||||
|
"sqlName": "plan_type",
|
||||||
|
"javaType": "String",
|
||||||
|
"csType": "string?",
|
||||||
|
"comment": "",
|
||||||
|
"isPk": false,
|
||||||
|
"isAudit": false,
|
||||||
|
"isIzEnable": false,
|
||||||
|
"required": false,
|
||||||
|
"dictCode": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"javaName": "sourceOrderId",
|
||||||
|
"csName": "SourceOrderId",
|
||||||
|
"sqlName": "source_order_id",
|
||||||
|
"javaType": "String",
|
||||||
|
"csType": "string?",
|
||||||
|
"comment": "",
|
||||||
|
"isPk": false,
|
||||||
|
"isAudit": false,
|
||||||
|
"isIzEnable": false,
|
||||||
|
"required": false,
|
||||||
|
"dictCode": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"javaName": "materialId",
|
||||||
|
"csName": "MaterialId",
|
||||||
|
"sqlName": "material_id",
|
||||||
|
"javaType": "String",
|
||||||
|
"csType": "string?",
|
||||||
|
"comment": "",
|
||||||
|
"isPk": false,
|
||||||
|
"isAudit": false,
|
||||||
|
"isIzEnable": false,
|
||||||
|
"required": false,
|
||||||
|
"dictCode": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"javaName": "materialName",
|
||||||
|
"csName": "MaterialName",
|
||||||
|
"sqlName": "material_name",
|
||||||
|
"javaType": "String",
|
||||||
|
"csType": "string?",
|
||||||
|
"comment": "",
|
||||||
|
"isPk": false,
|
||||||
|
"isAudit": false,
|
||||||
|
"isIzEnable": false,
|
||||||
|
"required": false,
|
||||||
|
"dictCode": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"javaName": "orderNo",
|
||||||
|
"csName": "OrderNo",
|
||||||
|
"sqlName": "order_no",
|
||||||
|
"javaType": "String",
|
||||||
|
"csType": "string?",
|
||||||
|
"comment": "",
|
||||||
|
"isPk": false,
|
||||||
|
"isAudit": false,
|
||||||
|
"isIzEnable": false,
|
||||||
|
"required": false,
|
||||||
|
"dictCode": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"javaName": "orderDate",
|
||||||
|
"csName": "OrderDate",
|
||||||
|
"sqlName": "order_date",
|
||||||
|
"javaType": "Date",
|
||||||
|
"csType": "DateTime?",
|
||||||
|
"comment": "",
|
||||||
|
"isPk": false,
|
||||||
|
"isAudit": false,
|
||||||
|
"isIzEnable": false,
|
||||||
|
"required": false,
|
||||||
|
"dictCode": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"javaName": "formulaName",
|
||||||
|
"csName": "FormulaName",
|
||||||
|
"sqlName": "formula_name",
|
||||||
|
"javaType": "String",
|
||||||
|
"csType": "string?",
|
||||||
|
"comment": "",
|
||||||
|
"isPk": false,
|
||||||
|
"isAudit": false,
|
||||||
|
"isIzEnable": false,
|
||||||
|
"required": false,
|
||||||
|
"dictCode": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"javaName": "planWeight",
|
||||||
|
"csName": "PlanWeight",
|
||||||
|
"sqlName": "plan_weight",
|
||||||
|
"javaType": "BigDecimal",
|
||||||
|
"csType": "double?",
|
||||||
|
"comment": "",
|
||||||
|
"isPk": false,
|
||||||
|
"isAudit": false,
|
||||||
|
"isIzEnable": false,
|
||||||
|
"required": false,
|
||||||
|
"dictCode": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"javaName": "plannedCarCount",
|
||||||
|
"csName": "PlannedCarCount",
|
||||||
|
"sqlName": "planned_car_count",
|
||||||
|
"javaType": "Integer",
|
||||||
|
"csType": "int?",
|
||||||
|
"comment": "",
|
||||||
|
"isPk": false,
|
||||||
|
"isAudit": false,
|
||||||
|
"isIzEnable": false,
|
||||||
|
"required": false,
|
||||||
|
"dictCode": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"javaName": "scheduledCarCount",
|
||||||
|
"csName": "ScheduledCarCount",
|
||||||
|
"sqlName": "scheduled_car_count",
|
||||||
|
"javaType": "Integer",
|
||||||
|
"csType": "int?",
|
||||||
|
"comment": "",
|
||||||
|
"isPk": false,
|
||||||
|
"isAudit": false,
|
||||||
|
"isIzEnable": false,
|
||||||
|
"required": false,
|
||||||
|
"dictCode": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"javaName": "finishedCarCount",
|
||||||
|
"csName": "FinishedCarCount",
|
||||||
|
"sqlName": "finished_car_count",
|
||||||
|
"javaType": "Integer",
|
||||||
|
"csType": "int?",
|
||||||
|
"comment": "",
|
||||||
|
"isPk": false,
|
||||||
|
"isAudit": false,
|
||||||
|
"isIzEnable": false,
|
||||||
|
"required": false,
|
||||||
|
"dictCode": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"javaName": "planCount",
|
||||||
|
"csName": "PlanCount",
|
||||||
|
"sqlName": "plan_count",
|
||||||
|
"javaType": "Integer",
|
||||||
|
"csType": "int?",
|
||||||
|
"comment": "",
|
||||||
|
"isPk": false,
|
||||||
|
"isAudit": false,
|
||||||
|
"isIzEnable": false,
|
||||||
|
"required": false,
|
||||||
|
"dictCode": null
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"javaName": "remark",
|
||||||
|
"csName": "Remark",
|
||||||
|
"sqlName": "remark",
|
||||||
|
"javaType": "String",
|
||||||
|
"csType": "string?",
|
||||||
|
"comment": "",
|
||||||
|
"isPk": false,
|
||||||
|
"isAudit": false,
|
||||||
|
"isIzEnable": false,
|
||||||
|
"required": false,
|
||||||
|
"dictCode": null
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"pkField": {
|
||||||
|
"javaName": "id",
|
||||||
|
"csName": "Id",
|
||||||
|
"sqlName": "id",
|
||||||
|
"javaType": "String",
|
||||||
|
"csType": "string?",
|
||||||
|
"comment": "",
|
||||||
|
"isPk": true,
|
||||||
|
"isAudit": false,
|
||||||
|
"isIzEnable": false,
|
||||||
|
"required": false,
|
||||||
|
"dictCode": null
|
||||||
|
},
|
||||||
|
"auditFields": [
|
||||||
|
"TenantId",
|
||||||
|
"SysOrgCode",
|
||||||
|
"CreateBy",
|
||||||
|
"CreateTime",
|
||||||
|
"UpdateBy",
|
||||||
|
"UpdateTime",
|
||||||
|
"DelFlag"
|
||||||
|
],
|
||||||
|
"dbConfig": {
|
||||||
|
"url": "jdbc:mysql://localhost:3306/jeecg-boot-dev?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai",
|
||||||
|
"username": "root",
|
||||||
|
"configFile": "jeecg-boot\\jeecg-boot-module\\jeecg-boot-module-airag\\src\\main\\resources\\application.yml"
|
||||||
|
},
|
||||||
|
"dbColumns": [],
|
||||||
|
"csEntityStub": "public class MesXslMixingProductionPlan\n{\n public string? Id { get; set; }\n public int? SortNo { get; set; }\n public string? MachineId { get; set; } [Dict:id]\n public string? MachineName { get; set; }\n public int? ShiftFlag { get; set; }\n public DateTime? PlanDate { get; set; }\n public string? PlanNo { get; set; }\n public string? PlanId { get; set; }\n public string? PlanType { get; set; }\n public string? SourceOrderId { get; set; }\n public string? MaterialId { get; set; }\n public string? MaterialName { get; set; }\n public string? OrderNo { get; set; }\n public DateTime? OrderDate { get; set; }\n public string? FormulaName { get; set; }\n public double? PlanWeight { get; set; }\n public int? PlannedCarCount { get; set; }\n public int? ScheduledCarCount { get; set; }\n public int? FinishedCarCount { get; set; }\n public int? PlanCount { get; set; }\n public string? Remark { get; set; }\n public int? TenantId { get; set; }\n public string? SysOrgCode { get; set; }\n public string? CreateBy { get; set; }\n public DateTime? CreateTime { get; set; }\n public string? UpdateBy { get; set; }\n public DateTime? UpdateTime { get; set; }\n public int? DelFlag { get; set; }\n // 只读显示属性:\n // public string StatusText => Status == \"1\" ? \"停用\" : \"启用\";\n}",
|
||||||
|
"generationHints": {
|
||||||
|
"eventClassName": "MesXslMixingProductionPlanChangedEvent",
|
||||||
|
"serviceInterface": "IMixingProductionPlanService",
|
||||||
|
"serviceImpl": "MixingProductionPlanService",
|
||||||
|
"syncCoordinator": "MixingProductionPlanSyncCoordinator",
|
||||||
|
"listViewModel": "MixingProductionPlanListViewModel",
|
||||||
|
"editDialogViewModel": "MixingProductionPlanEditDialogViewModel",
|
||||||
|
"listView": "MixingProductionPlanListView",
|
||||||
|
"editDialogView": "MixingProductionPlanEditDialogView",
|
||||||
|
"pendingOpsFile": "mes-xsl-mixing-production-plan-pending-ops.json",
|
||||||
|
"cacheFile": "mes-xsl-mixing-production-plan-cache.json",
|
||||||
|
"nextMenuId": 1300150011401,
|
||||||
|
"nextMenuOrderNo": 113,
|
||||||
|
"backendFilesToModify": [
|
||||||
|
"jeecg-boot\\jeecg-boot-module\\jeecg-module-xslmes\\src\\main\\java\\org\\jeecg\\modules\\xslmes\\controller\\MesXslDesktopAnonController.java",
|
||||||
|
"jeecg-boot\\jeecg-boot-module\\jeecg-module-xslmes\\src\\main\\java\\org\\jeecg\\modules\\xslmes\\service\\MesXslStompNotifyService.java",
|
||||||
|
"jeecg-boot\\jeecg-boot-module\\jeecg-module-xslmes\\src\\main\\java\\org\\jeecg\\modules\\xslmes\\controller\\MesXslMixingProductionPlanController.java",
|
||||||
|
"jeecg-boot-base-core/.../ShiroConfig.java"
|
||||||
|
],
|
||||||
|
"wpfFilesToModify": [
|
||||||
|
"yy-admin-master\\YY.Admin\\Module\\SyncModule.cs",
|
||||||
|
"yy-admin-master\\YY.Admin\\Module\\NavigationExtensions.cs",
|
||||||
|
"yy-admin-master\\YY.Admin\\Infrastructure\\Hubs\\StompWebSocketService.cs",
|
||||||
|
"yy-admin-master\\YY.Admin.Core\\SeedData\\SysMenuSeedData.cs",
|
||||||
|
"YY.Admin.Core/SeedData/SysTenantMenuSeedData.cs"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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 selectedRow = ref<Recordable | null>(null);
|
||||||
const onlySales = ref(false);
|
const onlySales = ref(false);
|
||||||
|
const excludeProductionFB1 = ref(false);
|
||||||
|
|
||||||
const [registerTable, { reload, getSelectRowKeys, getSelectRows, setSelectedRowKeys, clearSelectedRowKeys }] = useTable({
|
const [registerTable, { reload, getSelectRowKeys, getSelectRows, setSelectedRowKeys, clearSelectedRowKeys }] = useTable({
|
||||||
api: materialList,
|
api: materialList,
|
||||||
@@ -35,6 +36,7 @@
|
|||||||
...params,
|
...params,
|
||||||
enableFlag: params.enableFlag ?? 1,
|
enableFlag: params.enableFlag ?? 1,
|
||||||
onlySales: onlySales.value ? 1 : undefined,
|
onlySales: onlySales.value ? 1 : undefined,
|
||||||
|
excludeProductionFB1: excludeProductionFB1.value ? 1 : undefined,
|
||||||
}),
|
}),
|
||||||
rowSelection: {
|
rowSelection: {
|
||||||
type: 'radio',
|
type: 'radio',
|
||||||
@@ -49,6 +51,7 @@
|
|||||||
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
|
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
|
||||||
selectedRow.value = null;
|
selectedRow.value = null;
|
||||||
onlySales.value = !!data?.onlySales;
|
onlySales.value = !!data?.onlySales;
|
||||||
|
excludeProductionFB1.value = !!data?.excludeProductionFB1;
|
||||||
clearSelectedRowKeys?.();
|
clearSelectedRowKeys?.();
|
||||||
setModalProps({ confirmLoading: false });
|
setModalProps({ confirmLoading: false });
|
||||||
const materialId = data?.materialId as string | undefined;
|
const materialId = data?.materialId as string | undefined;
|
||||||
@@ -84,9 +87,9 @@
|
|||||||
}
|
}
|
||||||
emit('select', {
|
emit('select', {
|
||||||
materialId: row.id,
|
materialId: row.id,
|
||||||
materialName: row.materialName || '',
|
materialName: row.materialName || row.material_name || '',
|
||||||
aliasName: row.aliasName || '',
|
aliasName: row.aliasName || row.alias_name || '',
|
||||||
materialCode: row.materialCode || '',
|
materialCode: row.materialCode || row.material_code || '',
|
||||||
});
|
});
|
||||||
closeModal();
|
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,18 +1,20 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="mixing-plan-page">
|
<div class="mixing-plan-page">
|
||||||
<div class="mixing-plan-toolbar">
|
<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 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>
|
</div>
|
||||||
|
|
||||||
<a-table
|
<a-table :columns="columns" :data-source="rows" :pagination="false" :scroll="{ x: 1560 }" row-key="_rowKey" size="small" bordered>
|
||||||
:columns="columns"
|
|
||||||
:data-source="rows"
|
|
||||||
:pagination="false"
|
|
||||||
:scroll="{ x: 1560 }"
|
|
||||||
row-key="_rowKey"
|
|
||||||
size="small"
|
|
||||||
bordered
|
|
||||||
>
|
|
||||||
<template #bodyCell="{ column, record, index }">
|
<template #bodyCell="{ column, record, index }">
|
||||||
<template v-if="column.dataIndex === 'machineName'">
|
<template v-if="column.dataIndex === 'machineName'">
|
||||||
<a-input
|
<a-input
|
||||||
@@ -98,10 +100,15 @@
|
|||||||
import MesXslMixingPlanOrderSelectModal from './components/MesXslMixingPlanOrderSelectModal.vue';
|
import MesXslMixingPlanOrderSelectModal from './components/MesXslMixingPlanOrderSelectModal.vue';
|
||||||
import { list, saveAll } from './MesXslMixingProductionPlan.api';
|
import { list, saveAll } from './MesXslMixingProductionPlan.api';
|
||||||
|
|
||||||
|
type ShiftKey = 'morning' | 'noon' | 'night';
|
||||||
|
|
||||||
const { createMessage } = useMessage();
|
const { createMessage } = useMessage();
|
||||||
const saving = ref(false);
|
const saving = ref(false);
|
||||||
|
const refreshing = ref(false);
|
||||||
|
const querying = ref(false);
|
||||||
|
const queryPlanDate = ref<string>('');
|
||||||
const rows = ref<Recordable[]>([]);
|
const rows = ref<Recordable[]>([]);
|
||||||
const pickerContext = ref<{ rowIndex: number; shift?: 'morning' | 'noon' | 'night' } | null>(null);
|
const pickerContext = ref<{ rowIndex: number; shift?: ShiftKey } | null>(null);
|
||||||
|
|
||||||
const [registerEquipmentModal, { openModal: openEquipmentModal }] = useModal();
|
const [registerEquipmentModal, { openModal: openEquipmentModal }] = useModal();
|
||||||
const [registerOrderModal, { openModal: openOrderModal }] = useModal();
|
const [registerOrderModal, { openModal: openOrderModal }] = useModal();
|
||||||
@@ -145,11 +152,14 @@
|
|||||||
function createEmptyRow(): Recordable {
|
function createEmptyRow(): Recordable {
|
||||||
return {
|
return {
|
||||||
_rowKey: buildUUID(),
|
_rowKey: buildUUID(),
|
||||||
id: '',
|
planDate: queryPlanDate.value || '',
|
||||||
machineId: '',
|
machineId: '',
|
||||||
machineName: '',
|
machineName: '',
|
||||||
|
morningId: '',
|
||||||
|
morningShiftFlag: 1,
|
||||||
morningPlanId: '',
|
morningPlanId: '',
|
||||||
morningPlanType: '',
|
morningPlanType: '',
|
||||||
|
morningSourceOrderId: '',
|
||||||
morningOrderNo: '',
|
morningOrderNo: '',
|
||||||
morningOrderDate: '',
|
morningOrderDate: '',
|
||||||
morningFormulaName: '',
|
morningFormulaName: '',
|
||||||
@@ -159,8 +169,11 @@
|
|||||||
morningFinishedCarCount: null,
|
morningFinishedCarCount: null,
|
||||||
morningPlanCount: null,
|
morningPlanCount: null,
|
||||||
morningRemark: '',
|
morningRemark: '',
|
||||||
|
noonId: '',
|
||||||
|
noonShiftFlag: 2,
|
||||||
noonPlanId: '',
|
noonPlanId: '',
|
||||||
noonPlanType: '',
|
noonPlanType: '',
|
||||||
|
noonSourceOrderId: '',
|
||||||
noonOrderNo: '',
|
noonOrderNo: '',
|
||||||
noonOrderDate: '',
|
noonOrderDate: '',
|
||||||
noonFormulaName: '',
|
noonFormulaName: '',
|
||||||
@@ -170,8 +183,11 @@
|
|||||||
noonFinishedCarCount: null,
|
noonFinishedCarCount: null,
|
||||||
noonPlanCount: null,
|
noonPlanCount: null,
|
||||||
noonRemark: '',
|
noonRemark: '',
|
||||||
|
nightId: '',
|
||||||
|
nightShiftFlag: 3,
|
||||||
nightPlanId: '',
|
nightPlanId: '',
|
||||||
nightPlanType: '',
|
nightPlanType: '',
|
||||||
|
nightSourceOrderId: '',
|
||||||
nightOrderNo: '',
|
nightOrderNo: '',
|
||||||
nightOrderDate: '',
|
nightOrderDate: '',
|
||||||
nightFormulaName: '',
|
nightFormulaName: '',
|
||||||
@@ -184,7 +200,7 @@
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function shiftByOrderField(field: string): 'morning' | 'noon' | 'night' {
|
function shiftByOrderField(field: string): ShiftKey {
|
||||||
if (field.startsWith('morning')) return 'morning';
|
if (field.startsWith('morning')) return 'morning';
|
||||||
if (field.startsWith('noon')) return 'noon';
|
if (field.startsWith('noon')) return 'noon';
|
||||||
return 'night';
|
return 'night';
|
||||||
@@ -227,9 +243,13 @@
|
|||||||
pickerContext.value = null;
|
pickerContext.value = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
function openOrderPicker(rowIndex: number, shift: 'morning' | 'noon' | 'night') {
|
function openOrderPicker(rowIndex: number, shift: ShiftKey) {
|
||||||
pickerContext.value = { rowIndex, shift };
|
|
||||||
const row = rows.value[rowIndex];
|
const row = rows.value[rowIndex];
|
||||||
|
if (!row?.machineId && !row?.machineName) {
|
||||||
|
createMessage.warning('请先选择机台信息');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
pickerContext.value = { rowIndex, shift };
|
||||||
openOrderModal(true, {
|
openOrderModal(true, {
|
||||||
planId: row?.[`${shift}PlanId`] || '',
|
planId: row?.[`${shift}PlanId`] || '',
|
||||||
machineId: row?.machineId || '',
|
machineId: row?.machineId || '',
|
||||||
@@ -252,24 +272,146 @@
|
|||||||
row[`${shift}PlannedCarCount`] = payload?.plannedCarCount ?? null;
|
row[`${shift}PlannedCarCount`] = payload?.plannedCarCount ?? null;
|
||||||
row[`${shift}ScheduledCarCount`] = payload?.scheduledCarCount ?? null;
|
row[`${shift}ScheduledCarCount`] = payload?.scheduledCarCount ?? null;
|
||||||
row[`${shift}FinishedCarCount`] = payload?.finishedCarCount ?? null;
|
row[`${shift}FinishedCarCount`] = payload?.finishedCarCount ?? null;
|
||||||
|
row[`${shift}PlanCount`] = calcPlanCount(payload?.plannedCarCount, payload?.finishedCarCount);
|
||||||
pickerContext.value = null;
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
function applyShiftRecord(row: Recordable, shift: ShiftKey, record: Recordable) {
|
||||||
|
if (!record) return;
|
||||||
|
row[`${shift}Id`] = record.id || '';
|
||||||
|
row[`${shift}ShiftFlag`] = record.shiftFlag ?? (shift === 'morning' ? 1 : shift === 'noon' ? 2 : 3);
|
||||||
|
row[`${shift}PlanId`] = record.planId || '';
|
||||||
|
row[`${shift}PlanType`] = record.planType || '';
|
||||||
|
row[`${shift}SourceOrderId`] = record.sourceOrderId || '';
|
||||||
|
row[`${shift}OrderNo`] = record.orderNo || '';
|
||||||
|
row[`${shift}OrderDate`] = record.orderDate || '';
|
||||||
|
row[`${shift}FormulaName`] = record.formulaName || '';
|
||||||
|
row[`${shift}PlanWeight`] = record.planWeight ?? null;
|
||||||
|
row[`${shift}PlannedCarCount`] = record.plannedCarCount ?? null;
|
||||||
|
row[`${shift}ScheduledCarCount`] = record.scheduledCarCount ?? null;
|
||||||
|
row[`${shift}FinishedCarCount`] = record.finishedCarCount ?? null;
|
||||||
|
row[`${shift}PlanCount`] = record.planCount ?? null;
|
||||||
|
row[`${shift}Remark`] = record.remark || '';
|
||||||
|
}
|
||||||
|
|
||||||
|
function convertSharedRecordsToDisplayRows(records: Recordable[]) {
|
||||||
|
const groupMap = new Map<string, { machineId: string; machineName: string; planDate: string; morning: Recordable[]; noon: Recordable[]; night: Recordable[] }>();
|
||||||
|
(records || []).forEach((rec) => {
|
||||||
|
const machineId = rec.machineId || '';
|
||||||
|
const machineName = rec.machineName || '';
|
||||||
|
const planDate = rec.planDate || '';
|
||||||
|
const key = `${planDate}__${machineId}__${machineName}`;
|
||||||
|
if (!groupMap.has(key)) {
|
||||||
|
groupMap.set(key, {
|
||||||
|
machineId,
|
||||||
|
machineName,
|
||||||
|
planDate,
|
||||||
|
morning: [],
|
||||||
|
noon: [],
|
||||||
|
night: [],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
const group = groupMap.get(key)!;
|
||||||
|
const flag = Number(rec.shiftFlag);
|
||||||
|
if (flag === 1) group.morning.push(rec);
|
||||||
|
else if (flag === 2) group.noon.push(rec);
|
||||||
|
else group.night.push(rec);
|
||||||
|
});
|
||||||
|
|
||||||
|
const result: Recordable[] = [];
|
||||||
|
Array.from(groupMap.values()).forEach((group) => {
|
||||||
|
const maxLen = Math.max(group.morning.length, group.noon.length, group.night.length);
|
||||||
|
for (let i = 0; i < maxLen; i++) {
|
||||||
|
const row = createEmptyRow();
|
||||||
|
row._rowKey = buildUUID();
|
||||||
|
row.planDate = group.planDate;
|
||||||
|
row.machineId = group.machineId;
|
||||||
|
row.machineName = group.machineName;
|
||||||
|
applyShiftRecord(row, 'morning', group.morning[i]);
|
||||||
|
applyShiftRecord(row, 'noon', group.noon[i]);
|
||||||
|
applyShiftRecord(row, 'night', group.night[i]);
|
||||||
|
result.push(row);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
function hasShiftData(row: Recordable, shift: ShiftKey) {
|
||||||
|
return !!(
|
||||||
|
row?.[`${shift}PlanId`] ||
|
||||||
|
row?.[`${shift}OrderNo`] ||
|
||||||
|
row?.[`${shift}FormulaName`] ||
|
||||||
|
row?.[`${shift}PlanCount`] != null ||
|
||||||
|
row?.[`${shift}Remark`]
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function buildSharedShiftRecord(row: Recordable, shift: ShiftKey): Recordable | null {
|
||||||
|
if (!hasShiftData(row, shift) || (!row?.machineId && !row?.machineName)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
const shiftFlag = shift === 'morning' ? 1 : shift === 'noon' ? 2 : 3;
|
||||||
|
return {
|
||||||
|
id: row?.[`${shift}Id`] || '',
|
||||||
|
planDate: row?.planDate || queryPlanDate.value || '',
|
||||||
|
machineId: row?.machineId || '',
|
||||||
|
machineName: row?.machineName || '',
|
||||||
|
shiftFlag,
|
||||||
|
planId: row?.[`${shift}PlanId`] || '',
|
||||||
|
planType: row?.[`${shift}PlanType`] || '',
|
||||||
|
sourceOrderId: row?.[`${shift}SourceOrderId`] || '',
|
||||||
|
orderNo: row?.[`${shift}OrderNo`] || '',
|
||||||
|
orderDate: row?.[`${shift}OrderDate`] || '',
|
||||||
|
formulaName: row?.[`${shift}FormulaName`] || '',
|
||||||
|
planWeight: row?.[`${shift}PlanWeight`] ?? null,
|
||||||
|
plannedCarCount: row?.[`${shift}PlannedCarCount`] ?? null,
|
||||||
|
scheduledCarCount: row?.[`${shift}ScheduledCarCount`] ?? null,
|
||||||
|
finishedCarCount: row?.[`${shift}FinishedCarCount`] ?? null,
|
||||||
|
planCount: row?.[`${shift}PlanCount`] ?? null,
|
||||||
|
remark: row?.[`${shift}Remark`] || '',
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
async function loadRows() {
|
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[];
|
const records = (res?.records || res?.result?.records || []) as Recordable[];
|
||||||
rows.value = (records || []).map((item) => ({ ...createEmptyRow(), ...item, _rowKey: item.id || buildUUID() }));
|
rows.value = convertSharedRecordsToDisplayRows(records);
|
||||||
|
const minRows = 20;
|
||||||
if (!rows.value.length) {
|
if (!rows.value.length) {
|
||||||
rows.value = createBlankRows();
|
rows.value = createBlankRows(minRows);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (rows.value.length < minRows) {
|
||||||
|
rows.value.push(...createBlankRows(minRows - rows.value.length));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async function handleSaveAll() {
|
async function handleSaveAll() {
|
||||||
saving.value = true;
|
saving.value = true;
|
||||||
try {
|
try {
|
||||||
const payload = rows.value.map((r) => {
|
const payload = rows.value.flatMap((row) => {
|
||||||
const { _rowKey, ...rest } = r;
|
const list: Recordable[] = [];
|
||||||
return rest;
|
const morning = buildSharedShiftRecord(row, 'morning');
|
||||||
|
const noon = buildSharedShiftRecord(row, 'noon');
|
||||||
|
const night = buildSharedShiftRecord(row, 'night');
|
||||||
|
if (morning) list.push(morning);
|
||||||
|
if (noon) list.push(noon);
|
||||||
|
if (night) list.push(night);
|
||||||
|
return list;
|
||||||
});
|
});
|
||||||
await saveAll({ rows: payload });
|
await saveAll({ rows: payload });
|
||||||
createMessage.success('保存成功');
|
createMessage.success('保存成功');
|
||||||
@@ -279,6 +421,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();
|
loadRows();
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -51,7 +51,12 @@ export const formSchema: FormSchema[] = [
|
|||||||
},
|
},
|
||||||
{ label: '生产车间', field: 'productionWorkshop', component: 'Input' },
|
{ label: '生产车间', field: 'productionWorkshop', component: 'Input' },
|
||||||
{ label: '加工段数', field: 'processSegmentCount', component: 'InputNumber', componentProps: { min: 0, precision: 0 } },
|
{ 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: 'MES胶料名称', field: 'mesMaterialName', component: 'Input' },
|
||||||
{ label: '金蝶物料名称', field: 'kingdeeMaterialName', component: 'Input' },
|
{ label: '金蝶物料名称', field: 'kingdeeMaterialName', component: 'Input' },
|
||||||
{ label: '金蝶物料规格', field: 'kingdeeMaterialSpec', component: 'Input' },
|
{ label: '金蝶物料规格', field: 'kingdeeMaterialSpec', component: 'Input' },
|
||||||
|
|||||||
@@ -1,19 +1,32 @@
|
|||||||
<template>
|
<template>
|
||||||
<BasicModal v-bind="$attrs" @register="registerModal" :title="title" width="860px" @ok="handleSubmit">
|
<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>
|
</BasicModal>
|
||||||
|
<MesMaterialSelectModal @register="registerMaterialModal" @select="onMaterialSelected" />
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { computed, ref, unref } from 'vue';
|
import { computed, ref, unref } from 'vue';
|
||||||
import { BasicModal, useModalInner } from '/@/components/Modal';
|
import { BasicModal, useModalInner } from '/@/components/Modal';
|
||||||
import { BasicForm, useForm } from '/@/components/Form/index';
|
import { BasicForm, useForm } from '/@/components/Form/index';
|
||||||
|
import { useModal } from '/@/components/Modal';
|
||||||
import { formSchema } from '../MesXslProductionOrder.data';
|
import { formSchema } from '../MesXslProductionOrder.data';
|
||||||
import { saveOrUpdate } from '../MesXslProductionOrder.api';
|
import { saveOrUpdate } from '../MesXslProductionOrder.api';
|
||||||
|
import MesMaterialSelectModal from '/@/views/mes/material/modules/MesMaterialSelectModal.vue';
|
||||||
|
|
||||||
const emit = defineEmits(['register', 'success']);
|
const emit = defineEmits(['register', 'success']);
|
||||||
const isUpdate = ref(true);
|
const isUpdate = ref(true);
|
||||||
const isDetail = ref(false);
|
const isDetail = ref(false);
|
||||||
|
const [registerMaterialModal, { openModal: openMaterialModal }] = useModal();
|
||||||
|
|
||||||
const [registerForm, { resetFields, setFieldsValue, validate, setProps }] = useForm({
|
const [registerForm, { resetFields, setFieldsValue, validate, setProps }] = useForm({
|
||||||
labelWidth: 110,
|
labelWidth: 110,
|
||||||
@@ -50,4 +63,22 @@
|
|||||||
setModalProps({ confirmLoading: false });
|
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>
|
</script>
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
using Prism.Events;
|
||||||
|
|
||||||
|
namespace YY.Admin.Core.Events;
|
||||||
|
|
||||||
|
public class MixingProductionPlanChangedPayload
|
||||||
|
{
|
||||||
|
public string Action { get; set; } = string.Empty;
|
||||||
|
public string? MixingProductionPlanId { get; set; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public class MixingProductionPlanChangedEvent : PubSubEvent<MixingProductionPlanChangedPayload> { }
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
using YY.Admin.Core.Entity;
|
||||||
|
|
||||||
|
namespace YY.Admin.Core.Services;
|
||||||
|
|
||||||
|
/// <summary>密炼生产计划(MES 只读同步)</summary>
|
||||||
|
public interface IMixingProductionPlanService
|
||||||
|
{
|
||||||
|
Task<MixingProductionPlanPageResult> PageAsync(
|
||||||
|
int pageNo, int pageSize,
|
||||||
|
DateTime? planDateFrom = null,
|
||||||
|
DateTime? planDateTo = null,
|
||||||
|
string? machineName = null,
|
||||||
|
int? shiftFlag = null,
|
||||||
|
string? planNo = null,
|
||||||
|
string? materialName = null,
|
||||||
|
CancellationToken ct = default);
|
||||||
|
|
||||||
|
Task<List<MesXslMixingProductionPlan>> GetAllCachedAsync(CancellationToken ct = default);
|
||||||
|
|
||||||
|
/// <returns>本地缓存是否有变更(有差异才写入)</returns>
|
||||||
|
Task<bool> SyncFromRemoteAsync(CancellationToken ct = default);
|
||||||
|
}
|
||||||
|
|
||||||
|
public record MixingProductionPlanPageResult(
|
||||||
|
List<MesXslMixingProductionPlan> Records,
|
||||||
|
long Total,
|
||||||
|
int PageNo,
|
||||||
|
int PageSize);
|
||||||
@@ -14,7 +14,8 @@ public interface IRubberQuickTestStdService
|
|||||||
|
|
||||||
Task<MesXslRubberQuickTestStd?> GetByIdAsync(string id, CancellationToken ct = default);
|
Task<MesXslRubberQuickTestStd?> GetByIdAsync(string id, CancellationToken ct = default);
|
||||||
|
|
||||||
Task SyncFromRemoteAsync(CancellationToken ct = default);
|
/// <returns>本地缓存是否有变更(有差异才写入)</returns>
|
||||||
|
Task<bool> SyncFromRemoteAsync(CancellationToken ct = default);
|
||||||
}
|
}
|
||||||
|
|
||||||
public record RubberQuickTestStdPageResult(
|
public record RubberQuickTestStdPageResult(
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
namespace YY.Admin.Core.Entity;
|
namespace YY.Admin.Core.Entity;
|
||||||
|
|
||||||
/// <summary>密炼生产计划维护(桌面端快检记录筛选用)</summary>
|
/// <summary>密炼生产计划维护(MES 数据源,桌面端只读同步)</summary>
|
||||||
public class MesXslMixingProductionPlan
|
public class MesXslMixingProductionPlan
|
||||||
{
|
{
|
||||||
public string? Id { get; set; }
|
public string? Id { get; set; }
|
||||||
@@ -8,21 +8,43 @@ public class MesXslMixingProductionPlan
|
|||||||
public string? MachineId { get; set; }
|
public string? MachineId { get; set; }
|
||||||
public string? MachineName { get; set; }
|
public string? MachineName { get; set; }
|
||||||
|
|
||||||
public string? MorningPlanId { get; set; }
|
/// <summary>班次标识:1早班 2中班 3晚班</summary>
|
||||||
public string? MorningPlanType { get; set; }
|
public int? ShiftFlag { get; set; }
|
||||||
public string? MorningOrderNo { get; set; }
|
|
||||||
public DateTime? MorningOrderDate { get; set; }
|
|
||||||
public string? MorningFormulaName { get; set; }
|
|
||||||
|
|
||||||
public string? NoonPlanId { get; set; }
|
/// <summary>计划日期(密炼日期)</summary>
|
||||||
public string? NoonPlanType { get; set; }
|
public DateTime? PlanDate { get; set; }
|
||||||
public string? NoonOrderNo { get; set; }
|
|
||||||
public DateTime? NoonOrderDate { get; set; }
|
|
||||||
public string? NoonFormulaName { get; set; }
|
|
||||||
|
|
||||||
public string? NightPlanId { get; set; }
|
public string? PlanNo { get; set; }
|
||||||
public string? NightPlanType { get; set; }
|
public string? PlanId { get; set; }
|
||||||
public string? NightOrderNo { get; set; }
|
public string? PlanType { get; set; }
|
||||||
public DateTime? NightOrderDate { get; set; }
|
public string? SourceOrderId { get; set; }
|
||||||
public string? NightFormulaName { get; set; }
|
public string? MaterialId { get; set; }
|
||||||
|
public string? MaterialName { get; set; }
|
||||||
|
public string? OrderNo { get; set; }
|
||||||
|
public DateTime? OrderDate { get; set; }
|
||||||
|
public string? FormulaName { get; set; }
|
||||||
|
public double? PlanWeight { get; set; }
|
||||||
|
public int? PlannedCarCount { get; set; }
|
||||||
|
public int? ScheduledCarCount { get; set; }
|
||||||
|
public int? FinishedCarCount { get; set; }
|
||||||
|
/// <summary>计划数量(MES plan_count)</summary>
|
||||||
|
public int? PlanCount { get; set; }
|
||||||
|
public string? Remark { get; set; }
|
||||||
|
public int? TenantId { get; set; }
|
||||||
|
public string? SysOrgCode { get; set; }
|
||||||
|
public string? CreateBy { get; set; }
|
||||||
|
public DateTime? CreateTime { get; set; }
|
||||||
|
public string? UpdateBy { get; set; }
|
||||||
|
public DateTime? UpdateTime { get; set; }
|
||||||
|
public int? DelFlag { get; set; }
|
||||||
|
|
||||||
|
public string ShiftFlagText => ShiftFlag switch
|
||||||
|
{
|
||||||
|
1 => "早班",
|
||||||
|
2 => "中班",
|
||||||
|
3 => "晚班",
|
||||||
|
_ => ShiftFlag?.ToString() ?? string.Empty
|
||||||
|
};
|
||||||
|
|
||||||
|
public string PlanDateText => PlanDate?.ToString("yyyy-MM-dd") ?? string.Empty;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,66 @@
|
|||||||
|
namespace YY.Admin.Core.Helper;
|
||||||
|
|
||||||
|
/// <summary>MES 只读数据:远端列表与本地缓存按 Id 对比合并</summary>
|
||||||
|
public static class MesReadOnlyCacheMergeHelper
|
||||||
|
{
|
||||||
|
public sealed record MergeResult(int Added, int Updated, int Removed)
|
||||||
|
{
|
||||||
|
public bool HasChanges => Added > 0 || Updated > 0 || Removed > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 对比远端与本地,返回合并后的列表及变更统计。
|
||||||
|
/// 内容相同则保留本地副本;<paramref name="mergeUpdated"/> 可定制变更行的合并策略(如保留本地子表)。
|
||||||
|
/// </summary>
|
||||||
|
public static (List<T> Merged, MergeResult Stats) Merge<T>(
|
||||||
|
IReadOnlyList<T> local,
|
||||||
|
IReadOnlyList<T> remote,
|
||||||
|
Func<T, string?> getId,
|
||||||
|
Func<T, T, bool> isContentEqual,
|
||||||
|
Func<T, T> clone,
|
||||||
|
Func<T, T, T>? mergeUpdated = null)
|
||||||
|
{
|
||||||
|
var localById = new Dictionary<string, T>(StringComparer.OrdinalIgnoreCase);
|
||||||
|
foreach (var item in local)
|
||||||
|
{
|
||||||
|
var id = getId(item);
|
||||||
|
if (!string.IsNullOrWhiteSpace(id))
|
||||||
|
localById[id] = item;
|
||||||
|
}
|
||||||
|
|
||||||
|
var remoteIds = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
|
||||||
|
var merged = new List<T>(remote.Count);
|
||||||
|
int added = 0, updated = 0;
|
||||||
|
|
||||||
|
foreach (var remoteItem in remote)
|
||||||
|
{
|
||||||
|
var id = getId(remoteItem);
|
||||||
|
if (string.IsNullOrWhiteSpace(id))
|
||||||
|
{
|
||||||
|
merged.Add(clone(remoteItem));
|
||||||
|
added++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
remoteIds.Add(id);
|
||||||
|
|
||||||
|
if (!localById.TryGetValue(id, out var localItem))
|
||||||
|
{
|
||||||
|
merged.Add(clone(remoteItem));
|
||||||
|
added++;
|
||||||
|
}
|
||||||
|
else if (!isContentEqual(localItem, remoteItem))
|
||||||
|
{
|
||||||
|
merged.Add(mergeUpdated != null ? mergeUpdated(localItem, remoteItem) : clone(remoteItem));
|
||||||
|
updated++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
merged.Add(clone(localItem));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int removed = localById.Keys.Count(id => !remoteIds.Contains(id));
|
||||||
|
return (merged, new MergeResult(added, updated, removed));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -52,6 +52,8 @@ public class SysMenuSeedData : ISqlSugarEntitySeedData<SysMenu>
|
|||||||
new SysMenu{ Id=1300150011201, Pid=1300150000101, Title="快检记录", Path="/xslmes/rubberQuickTestOperation", Name="rubberQuickTestOperation", Component="RubberQuickTestOperationView", Icon="", Type=MenuTypeEnum.Menu, CreateTime=DateTime.Parse("2022-02-10 00:00:00"), OrderNo=111 },
|
new SysMenu{ Id=1300150011201, Pid=1300150000101, Title="快检记录", Path="/xslmes/rubberQuickTestOperation", Name="rubberQuickTestOperation", Component="RubberQuickTestOperationView", Icon="", Type=MenuTypeEnum.Menu, CreateTime=DateTime.Parse("2022-02-10 00:00:00"), OrderNo=111 },
|
||||||
// 胶料快检实验标准(桌面端只读)
|
// 胶料快检实验标准(桌面端只读)
|
||||||
new SysMenu{ Id=1300150011301, Pid=1300150000101, Title="胶料快检实验标准", Path="/xslmes/mesXslRubberQuickTestStd", Name="mesXslRubberQuickTestStd", Component="RubberQuickTestStdListView", Icon="", Type=MenuTypeEnum.Menu, CreateTime=DateTime.Parse("2022-02-10 00:00:00"), OrderNo=112 },
|
new SysMenu{ Id=1300150011301, Pid=1300150000101, Title="胶料快检实验标准", Path="/xslmes/mesXslRubberQuickTestStd", Name="mesXslRubberQuickTestStd", Component="RubberQuickTestStdListView", Icon="", Type=MenuTypeEnum.Menu, CreateTime=DateTime.Parse("2022-02-10 00:00:00"), OrderNo=112 },
|
||||||
|
// 密炼计划
|
||||||
|
new SysMenu{ Id=1300150011401, Pid=1300150000101, Title="密炼计划", Path="/xslmes/mesXslMixingProductionPlan", Name="mesXslMixingProductionPlan", Component="MixingProductionPlanListView", Icon="", Type=MenuTypeEnum.Menu, CreateTime=DateTime.Parse("2022-02-10 00:00:00"), OrderNo=113 },
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ public class SysTenantMenuSeedData : ISqlSugarEntitySeedData<SysTenantMenu>
|
|||||||
new SysTenantMenu(){ TenantId=1300000000001,MenuId=1300150011101},
|
new SysTenantMenu(){ TenantId=1300000000001,MenuId=1300150011101},
|
||||||
new SysTenantMenu(){ TenantId=1300000000001,MenuId=1300150011201},
|
new SysTenantMenu(){ TenantId=1300000000001,MenuId=1300150011201},
|
||||||
new SysTenantMenu(){ TenantId=1300000000001,MenuId=1300150011301},
|
new SysTenantMenu(){ TenantId=1300000000001,MenuId=1300150011301},
|
||||||
|
new SysTenantMenu(){ TenantId=1300000000001,MenuId=1300150011401},
|
||||||
new SysTenantMenu(){ TenantId=1300000000001,MenuId=1300200012101},
|
new SysTenantMenu(){ TenantId=1300000000001,MenuId=1300200012101},
|
||||||
new SysTenantMenu(){ TenantId=1300000000001,MenuId=1300200012111},
|
new SysTenantMenu(){ TenantId=1300000000001,MenuId=1300200012111},
|
||||||
new SysTenantMenu(){ TenantId=1300000000001,MenuId=1300200012121},
|
new SysTenantMenu(){ TenantId=1300000000001,MenuId=1300200012121},
|
||||||
|
|||||||
@@ -0,0 +1,326 @@
|
|||||||
|
using Microsoft.Extensions.Configuration;
|
||||||
|
using Prism.Events;
|
||||||
|
using System.IO;
|
||||||
|
using System.Net.Http;
|
||||||
|
using System.Text.Json;
|
||||||
|
using System.Text.Json.Serialization;
|
||||||
|
using System.Web;
|
||||||
|
using YY.Admin.Core;
|
||||||
|
using YY.Admin.Core.Entity;
|
||||||
|
using YY.Admin.Core.Events;
|
||||||
|
using YY.Admin.Core.Helper;
|
||||||
|
using YY.Admin.Core.Services;
|
||||||
|
namespace YY.Admin.Services.Service.MixingProductionPlan;
|
||||||
|
|
||||||
|
/// <summary>密炼生产计划:MES 只读拉取 + 本地缓存,断网读缓存,联网刷新</summary>
|
||||||
|
public class MixingProductionPlanService : IMixingProductionPlanService, ISingletonDependency
|
||||||
|
{
|
||||||
|
private readonly IHttpClientFactory _httpClientFactory;
|
||||||
|
private readonly IConfiguration _configuration;
|
||||||
|
private readonly INetworkMonitor _networkMonitor;
|
||||||
|
private readonly IEventAggregator _eventAggregator;
|
||||||
|
private readonly ILoggerService _logger;
|
||||||
|
private readonly SemaphoreSlim _syncLock = new(1, 1);
|
||||||
|
private readonly object _cacheLock = new();
|
||||||
|
private readonly string _cacheFilePath;
|
||||||
|
private List<MesXslMixingProductionPlan> _localCache = new();
|
||||||
|
|
||||||
|
private static readonly JsonSerializerOptions _jsonOpts = new()
|
||||||
|
{
|
||||||
|
PropertyNameCaseInsensitive = true,
|
||||||
|
PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
|
||||||
|
Converters = { new NullableDateTimeJsonConverter() }
|
||||||
|
};
|
||||||
|
|
||||||
|
public MixingProductionPlanService(
|
||||||
|
IHttpClientFactory httpClientFactory,
|
||||||
|
IConfiguration configuration,
|
||||||
|
INetworkMonitor networkMonitor,
|
||||||
|
IEventAggregator eventAggregator,
|
||||||
|
ILoggerService logger)
|
||||||
|
{
|
||||||
|
_httpClientFactory = httpClientFactory;
|
||||||
|
_configuration = configuration;
|
||||||
|
_networkMonitor = networkMonitor;
|
||||||
|
_eventAggregator = eventAggregator;
|
||||||
|
_logger = logger;
|
||||||
|
|
||||||
|
var appDataDir = Path.Combine(
|
||||||
|
Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData),
|
||||||
|
"YY.Admin", "sync-cache");
|
||||||
|
Directory.CreateDirectory(appDataDir);
|
||||||
|
_cacheFilePath = Path.Combine(appDataDir, "mes-xsl-mixing-production-plan-cache.json");
|
||||||
|
|
||||||
|
LoadCacheFromDisk();
|
||||||
|
_logger.Information($"[密炼计划] 服务初始化,缓存={_localCache.Count},在线={_networkMonitor.IsOnline}");
|
||||||
|
|
||||||
|
_networkMonitor.StatusChanged += OnNetworkStatusChanged;
|
||||||
|
if (_networkMonitor.IsOnline)
|
||||||
|
_ = Task.Run(() => SyncFromRemoteAsync(CancellationToken.None));
|
||||||
|
}
|
||||||
|
|
||||||
|
private string BaseUrl => (_configuration.GetValue<string>("JeecgIntegration:BaseUrl") ?? "http://localhost:8080/jeecg-boot").TrimEnd('/');
|
||||||
|
private int DefaultTenantId => (int?)_configuration.GetValue<long?>("JeecgIntegration:DefaultTenantId") ?? 1002;
|
||||||
|
private HttpClient CreateClient() => _httpClientFactory.CreateClient("JeecgApi");
|
||||||
|
|
||||||
|
public async Task<MixingProductionPlanPageResult> PageAsync(
|
||||||
|
int pageNo, int pageSize,
|
||||||
|
DateTime? planDateFrom = null,
|
||||||
|
DateTime? planDateTo = null,
|
||||||
|
string? machineName = null,
|
||||||
|
int? shiftFlag = null,
|
||||||
|
string? planNo = null,
|
||||||
|
string? materialName = null,
|
||||||
|
CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
if (_networkMonitor.IsOnline)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await SyncFromRemoteAsync(ct).ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.Warning($"[密炼计划] 列表拉取失败,使用本地缓存:{ex.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
List<MesXslMixingProductionPlan> source;
|
||||||
|
lock (_cacheLock)
|
||||||
|
source = _localCache.Select(Clone).ToList();
|
||||||
|
|
||||||
|
var filtered = ApplyFilters(source, planDateFrom, planDateTo, machineName, shiftFlag, planNo, materialName);
|
||||||
|
var total = filtered.Count;
|
||||||
|
var records = filtered
|
||||||
|
.Skip(Math.Max(0, (pageNo - 1) * pageSize))
|
||||||
|
.Take(pageSize)
|
||||||
|
.ToList();
|
||||||
|
return new MixingProductionPlanPageResult(records, total, pageNo, pageSize);
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<List<MesXslMixingProductionPlan>> GetAllCachedAsync(CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
if (_networkMonitor.IsOnline)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await SyncFromRemoteAsync(ct).ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.Warning($"[密炼计划] 全量拉取失败,使用本地缓存:{ex.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
lock (_cacheLock)
|
||||||
|
return _localCache.Select(Clone).ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task<bool> SyncFromRemoteAsync(CancellationToken ct = default)
|
||||||
|
{
|
||||||
|
await _syncLock.WaitAsync(ct).ConfigureAwait(false);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (!_networkMonitor.IsOnline)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
var all = new List<MesXslMixingProductionPlan>();
|
||||||
|
int pageNo = 1;
|
||||||
|
const int pageSize = 500;
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
var query = HttpUtility.ParseQueryString(string.Empty);
|
||||||
|
query["pageNo"] = pageNo.ToString();
|
||||||
|
query["pageSize"] = pageSize.ToString();
|
||||||
|
query["tenantId"] = DefaultTenantId.ToString();
|
||||||
|
var url = $"{BaseUrl}/xslmes/mesXslMixingProductionPlan/anon/list?{query}";
|
||||||
|
|
||||||
|
using var client = CreateClient();
|
||||||
|
var resp = await client.GetAsync(url, ct).ConfigureAwait(false);
|
||||||
|
resp.EnsureSuccessStatusCode();
|
||||||
|
|
||||||
|
var json = await resp.Content.ReadAsStringAsync(ct).ConfigureAwait(false);
|
||||||
|
using var doc = JsonDocument.Parse(json);
|
||||||
|
if (!doc.RootElement.TryGetProperty("result", out var resultEl)) break;
|
||||||
|
|
||||||
|
var page = resultEl.GetProperty("records")
|
||||||
|
.Deserialize<List<MesXslMixingProductionPlan>>(_jsonOpts) ?? new();
|
||||||
|
all.AddRange(page);
|
||||||
|
|
||||||
|
long total = 0;
|
||||||
|
if (resultEl.TryGetProperty("total", out var totalEl)) total = totalEl.GetInt64();
|
||||||
|
if (all.Count >= total || page.Count < pageSize) break;
|
||||||
|
pageNo++;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<MesXslMixingProductionPlan> localSnapshot;
|
||||||
|
lock (_cacheLock)
|
||||||
|
localSnapshot = _localCache.Select(Clone).ToList();
|
||||||
|
|
||||||
|
var (merged, stats) = MesReadOnlyCacheMergeHelper.Merge(
|
||||||
|
localSnapshot,
|
||||||
|
all,
|
||||||
|
x => x.Id,
|
||||||
|
IsPlanContentEqual,
|
||||||
|
Clone);
|
||||||
|
|
||||||
|
if (!stats.HasChanges)
|
||||||
|
{
|
||||||
|
_logger.Information($"[密炼计划] 与 MES 对比无差异,跳过更新 count={merged.Count}");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
lock (_cacheLock)
|
||||||
|
{
|
||||||
|
_localCache = merged;
|
||||||
|
SaveCacheToDiskUnsafe();
|
||||||
|
}
|
||||||
|
_logger.Information(
|
||||||
|
$"[密炼计划] 差异同步完成 total={merged.Count} 新增={stats.Added} 变更={stats.Updated} 删除={stats.Removed}");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.Warning($"[密炼计划] 远程同步失败:{ex.Message}");
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
_syncLock.Release();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnNetworkStatusChanged(bool isOnline)
|
||||||
|
{
|
||||||
|
if (!isOnline) return;
|
||||||
|
_ = Task.Run(async () =>
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (!await SyncFromRemoteAsync(CancellationToken.None).ConfigureAwait(false))
|
||||||
|
return;
|
||||||
|
_eventAggregator.GetEvent<MixingProductionPlanChangedEvent>()
|
||||||
|
.Publish(new MixingProductionPlanChangedPayload { Action = "reconnect" });
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.Warning($"[密炼计划] 重连同步失败:{ex.Message}");
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
private static bool IsPlanContentEqual(MesXslMixingProductionPlan a, MesXslMixingProductionPlan b) =>
|
||||||
|
string.Equals(GetPlanFingerprint(a), GetPlanFingerprint(b), StringComparison.Ordinal);
|
||||||
|
|
||||||
|
private static string GetPlanFingerprint(MesXslMixingProductionPlan x) =>
|
||||||
|
JsonSerializer.Serialize(Clone(x), _jsonOpts);
|
||||||
|
private static List<MesXslMixingProductionPlan> ApplyFilters(
|
||||||
|
List<MesXslMixingProductionPlan> source,
|
||||||
|
DateTime? planDateFrom,
|
||||||
|
DateTime? planDateTo,
|
||||||
|
string? machineName,
|
||||||
|
int? shiftFlag,
|
||||||
|
string? planNo,
|
||||||
|
string? materialName)
|
||||||
|
{
|
||||||
|
IEnumerable<MesXslMixingProductionPlan> q = source;
|
||||||
|
if (planDateFrom.HasValue)
|
||||||
|
q = q.Where(x => x.PlanDate?.Date >= planDateFrom.Value.Date);
|
||||||
|
if (planDateTo.HasValue)
|
||||||
|
q = q.Where(x => x.PlanDate?.Date <= planDateTo.Value.Date);
|
||||||
|
if (!string.IsNullOrWhiteSpace(machineName))
|
||||||
|
q = q.Where(x => (x.MachineName ?? "").Contains(machineName.Trim(), StringComparison.OrdinalIgnoreCase));
|
||||||
|
if (shiftFlag.HasValue && shiftFlag.Value > 0)
|
||||||
|
q = q.Where(x => x.ShiftFlag == shiftFlag.Value);
|
||||||
|
if (!string.IsNullOrWhiteSpace(planNo))
|
||||||
|
q = q.Where(x => (x.PlanNo ?? "").Contains(planNo.Trim(), StringComparison.OrdinalIgnoreCase));
|
||||||
|
if (!string.IsNullOrWhiteSpace(materialName))
|
||||||
|
q = q.Where(x => (x.MaterialName ?? "").Contains(materialName.Trim(), StringComparison.OrdinalIgnoreCase));
|
||||||
|
|
||||||
|
return q
|
||||||
|
.OrderByDescending(x => x.PlanDate ?? DateTime.MinValue)
|
||||||
|
.ThenBy(x => x.SortNo ?? int.MaxValue)
|
||||||
|
.ThenBy(x => x.MachineName)
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void LoadCacheFromDisk()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (!File.Exists(_cacheFilePath)) return;
|
||||||
|
_localCache = JsonSerializer.Deserialize<List<MesXslMixingProductionPlan>>(
|
||||||
|
File.ReadAllText(_cacheFilePath), _jsonOpts) ?? new();
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
_localCache = new();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SaveCacheToDiskUnsafe() =>
|
||||||
|
File.WriteAllText(_cacheFilePath, JsonSerializer.Serialize(_localCache, _jsonOpts));
|
||||||
|
|
||||||
|
private static MesXslMixingProductionPlan Clone(MesXslMixingProductionPlan x) => new()
|
||||||
|
{
|
||||||
|
Id = x.Id,
|
||||||
|
SortNo = x.SortNo,
|
||||||
|
MachineId = x.MachineId,
|
||||||
|
MachineName = x.MachineName,
|
||||||
|
ShiftFlag = x.ShiftFlag,
|
||||||
|
PlanDate = x.PlanDate,
|
||||||
|
PlanNo = x.PlanNo,
|
||||||
|
PlanId = x.PlanId,
|
||||||
|
PlanType = x.PlanType,
|
||||||
|
SourceOrderId = x.SourceOrderId,
|
||||||
|
MaterialId = x.MaterialId,
|
||||||
|
MaterialName = x.MaterialName,
|
||||||
|
OrderNo = x.OrderNo,
|
||||||
|
OrderDate = x.OrderDate,
|
||||||
|
FormulaName = x.FormulaName,
|
||||||
|
PlanWeight = x.PlanWeight,
|
||||||
|
PlannedCarCount = x.PlannedCarCount,
|
||||||
|
ScheduledCarCount = x.ScheduledCarCount,
|
||||||
|
FinishedCarCount = x.FinishedCarCount,
|
||||||
|
PlanCount = x.PlanCount,
|
||||||
|
Remark = x.Remark,
|
||||||
|
TenantId = x.TenantId,
|
||||||
|
SysOrgCode = x.SysOrgCode,
|
||||||
|
CreateBy = x.CreateBy,
|
||||||
|
CreateTime = x.CreateTime,
|
||||||
|
UpdateBy = x.UpdateBy,
|
||||||
|
UpdateTime = x.UpdateTime,
|
||||||
|
DelFlag = x.DelFlag
|
||||||
|
};
|
||||||
|
|
||||||
|
private sealed class NullableDateTimeJsonConverter : JsonConverter<DateTime?>
|
||||||
|
{
|
||||||
|
private static readonly string[] Formats =
|
||||||
|
[
|
||||||
|
"yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd HH:mm:ss.fff",
|
||||||
|
"yyyy-MM-ddTHH:mm:ss", "yyyy-MM-ddTHH:mm:ss.fff",
|
||||||
|
"yyyy-MM-ddTHH:mm:ssZ", "yyyy-MM-ddTHH:mm:ss.fffZ",
|
||||||
|
"yyyy-MM-dd"
|
||||||
|
];
|
||||||
|
|
||||||
|
public override DateTime? Read(ref Utf8JsonReader reader, Type typeToConvert, JsonSerializerOptions options)
|
||||||
|
{
|
||||||
|
if (reader.TokenType == JsonTokenType.Null) return null;
|
||||||
|
if (reader.TokenType == JsonTokenType.String)
|
||||||
|
{
|
||||||
|
var raw = reader.GetString();
|
||||||
|
if (string.IsNullOrWhiteSpace(raw)) return null;
|
||||||
|
if (DateTime.TryParseExact(raw, Formats, System.Globalization.CultureInfo.InvariantCulture,
|
||||||
|
System.Globalization.DateTimeStyles.AssumeLocal, out var dt)) return dt;
|
||||||
|
if (DateTime.TryParse(raw, out var fb)) return fb;
|
||||||
|
}
|
||||||
|
throw new JsonException($"无法转换为 DateTime?,token={reader.TokenType}");
|
||||||
|
}
|
||||||
|
|
||||||
|
public override void Write(Utf8JsonWriter writer, DateTime? value, JsonSerializerOptions options)
|
||||||
|
{
|
||||||
|
if (value.HasValue) writer.WriteStringValue(value.Value.ToString("yyyy-MM-dd HH:mm:ss"));
|
||||||
|
else writer.WriteNullValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,63 @@
|
|||||||
|
using Prism.Events;
|
||||||
|
using System.Text.Json;
|
||||||
|
using YY.Admin.Core;
|
||||||
|
using YY.Admin.Core.Events;
|
||||||
|
using YY.Admin.Core.Services;
|
||||||
|
|
||||||
|
namespace YY.Admin.Services.Service.MixingProductionPlan;
|
||||||
|
|
||||||
|
public class MixingProductionPlanSyncCoordinator : ISingletonDependency
|
||||||
|
{
|
||||||
|
private readonly IEventAggregator _eventAggregator;
|
||||||
|
private readonly ILoggerService _logger;
|
||||||
|
|
||||||
|
public MixingProductionPlanSyncCoordinator(
|
||||||
|
IEventAggregator eventAggregator,
|
||||||
|
SyncPollManager pollManager,
|
||||||
|
ILoggerService logger)
|
||||||
|
{
|
||||||
|
_eventAggregator = eventAggregator;
|
||||||
|
_logger = logger;
|
||||||
|
|
||||||
|
_eventAggregator.GetEvent<RemoteCommandReceivedEvent>()
|
||||||
|
.Subscribe(OnRemoteCommand, ThreadOption.BackgroundThread);
|
||||||
|
|
||||||
|
pollManager.Register("密炼计划", () =>
|
||||||
|
{
|
||||||
|
_eventAggregator.GetEvent<MixingProductionPlanChangedEvent>()
|
||||||
|
.Publish(new MixingProductionPlanChangedPayload { Action = "poll" });
|
||||||
|
return Task.CompletedTask;
|
||||||
|
});
|
||||||
|
|
||||||
|
_logger.Information("[密炼计划] MixingProductionPlanSyncCoordinator 已启动");
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnRemoteCommand(RemoteCommandPayload payload)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var json = payload.CommandJson ?? string.Empty;
|
||||||
|
if (string.IsNullOrWhiteSpace(json)) return;
|
||||||
|
|
||||||
|
using var doc = JsonDocument.Parse(json);
|
||||||
|
if (!doc.RootElement.TryGetProperty("cmd", out var cmdEl)) return;
|
||||||
|
if (!cmdEl.GetString()?.Equals("MIXING_PRODUCTION_PLAN_CHANGED", StringComparison.OrdinalIgnoreCase) ?? true)
|
||||||
|
return;
|
||||||
|
|
||||||
|
doc.RootElement.TryGetProperty("action", out var actionEl);
|
||||||
|
doc.RootElement.TryGetProperty("mixingProductionPlanId", out var idEl);
|
||||||
|
|
||||||
|
var changed = new MixingProductionPlanChangedPayload
|
||||||
|
{
|
||||||
|
Action = actionEl.GetString() ?? string.Empty,
|
||||||
|
MixingProductionPlanId = idEl.ValueKind == JsonValueKind.String ? idEl.GetString() : null
|
||||||
|
};
|
||||||
|
_logger.Information($"[密炼计划] STOMP action={changed.Action}, id={changed.MixingProductionPlanId}");
|
||||||
|
_eventAggregator.GetEvent<MixingProductionPlanChangedEvent>().Publish(changed);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_logger.Warning($"[密炼计划] 处理 STOMP 命令失败:{ex.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -14,6 +14,7 @@ public class RubberQuickTestOperationService : IRubberQuickTestOperationService,
|
|||||||
private readonly IHttpClientFactory _httpClientFactory;
|
private readonly IHttpClientFactory _httpClientFactory;
|
||||||
private readonly IConfiguration _configuration;
|
private readonly IConfiguration _configuration;
|
||||||
private readonly INetworkMonitor _networkMonitor;
|
private readonly INetworkMonitor _networkMonitor;
|
||||||
|
private readonly IMixingProductionPlanService _mixingProductionPlanService;
|
||||||
private readonly ILoggerService _logger;
|
private readonly ILoggerService _logger;
|
||||||
|
|
||||||
private static readonly JsonSerializerOptions _jsonOpts = new()
|
private static readonly JsonSerializerOptions _jsonOpts = new()
|
||||||
@@ -27,11 +28,13 @@ public class RubberQuickTestOperationService : IRubberQuickTestOperationService,
|
|||||||
IHttpClientFactory httpClientFactory,
|
IHttpClientFactory httpClientFactory,
|
||||||
IConfiguration configuration,
|
IConfiguration configuration,
|
||||||
INetworkMonitor networkMonitor,
|
INetworkMonitor networkMonitor,
|
||||||
|
IMixingProductionPlanService mixingProductionPlanService,
|
||||||
ILoggerService logger)
|
ILoggerService logger)
|
||||||
{
|
{
|
||||||
_httpClientFactory = httpClientFactory;
|
_httpClientFactory = httpClientFactory;
|
||||||
_configuration = configuration;
|
_configuration = configuration;
|
||||||
_networkMonitor = networkMonitor;
|
_networkMonitor = networkMonitor;
|
||||||
|
_mixingProductionPlanService = mixingProductionPlanService;
|
||||||
_logger = logger;
|
_logger = logger;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -40,32 +43,7 @@ public class RubberQuickTestOperationService : IRubberQuickTestOperationService,
|
|||||||
|
|
||||||
public async Task<List<MesXslMixingProductionPlan>> GetMixingProductionPlansAsync(CancellationToken ct = default)
|
public async Task<List<MesXslMixingProductionPlan>> GetMixingProductionPlansAsync(CancellationToken ct = default)
|
||||||
{
|
{
|
||||||
if (!_networkMonitor.IsOnline)
|
var result = await _mixingProductionPlanService.GetAllCachedAsync(ct).ConfigureAwait(false);
|
||||||
throw new InvalidOperationException("网络未连接,无法加载密炼生产计划");
|
|
||||||
|
|
||||||
var result = new List<MesXslMixingProductionPlan>();
|
|
||||||
int pageNo = 1;
|
|
||||||
const int pageSize = 500;
|
|
||||||
while (true)
|
|
||||||
{
|
|
||||||
var url = $"{BaseUrl}/xslmes/mesXslMixingProductionPlan/anon/list?pageNo={pageNo}&pageSize={pageSize}&tenantId={DefaultTenantId}";
|
|
||||||
using var client = _httpClientFactory.CreateClient("JeecgApi");
|
|
||||||
var resp = await client.GetAsync(url, ct).ConfigureAwait(false);
|
|
||||||
resp.EnsureSuccessStatusCode();
|
|
||||||
var json = await resp.Content.ReadAsStringAsync(ct).ConfigureAwait(false);
|
|
||||||
using var doc = JsonDocument.Parse(json);
|
|
||||||
if (!doc.RootElement.TryGetProperty("result", out var resultEl)) break;
|
|
||||||
if (resultEl.TryGetProperty("records", out var recordsEl))
|
|
||||||
{
|
|
||||||
var page = recordsEl.Deserialize<List<MesXslMixingProductionPlan>>(_jsonOpts);
|
|
||||||
if (page != null) result.AddRange(page);
|
|
||||||
}
|
|
||||||
long total = 0;
|
|
||||||
if (resultEl.TryGetProperty("total", out var totalEl)) total = totalEl.GetInt64();
|
|
||||||
if (result.Count >= total || (resultEl.TryGetProperty("records", out var r2) && r2.GetArrayLength() < pageSize)) break;
|
|
||||||
pageNo++;
|
|
||||||
}
|
|
||||||
|
|
||||||
_logger.Information($"[快检记录] 加载密炼生产计划 {result.Count} 条");
|
_logger.Information($"[快检记录] 加载密炼生产计划 {result.Count} 条");
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ using System.Web;
|
|||||||
using YY.Admin.Core;
|
using YY.Admin.Core;
|
||||||
using YY.Admin.Core.Entity;
|
using YY.Admin.Core.Entity;
|
||||||
using YY.Admin.Core.Events;
|
using YY.Admin.Core.Events;
|
||||||
|
using YY.Admin.Core.Helper;
|
||||||
using YY.Admin.Core.Services;
|
using YY.Admin.Core.Services;
|
||||||
|
|
||||||
namespace YY.Admin.Services.Service.RubberQuickTestStd;
|
namespace YY.Admin.Services.Service.RubberQuickTestStd;
|
||||||
@@ -115,7 +116,7 @@ public class RubberQuickTestStdService : IRubberQuickTestStdService, ISingletonD
|
|||||||
var entity = resultEl.Deserialize<MesXslRubberQuickTestStd>(_jsonOpts);
|
var entity = resultEl.Deserialize<MesXslRubberQuickTestStd>(_jsonOpts);
|
||||||
if (entity != null)
|
if (entity != null)
|
||||||
{
|
{
|
||||||
UpsertLocalCacheMain(entity);
|
UpsertIfChanged(entity);
|
||||||
return CloneMain(entity);
|
return CloneMain(entity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -134,14 +135,14 @@ public class RubberQuickTestStdService : IRubberQuickTestStdService, ISingletonD
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task SyncFromRemoteAsync(CancellationToken ct = default)
|
public async Task<bool> SyncFromRemoteAsync(CancellationToken ct = default)
|
||||||
{
|
{
|
||||||
await _syncLock.WaitAsync(ct).ConfigureAwait(false);
|
await _syncLock.WaitAsync(ct).ConfigureAwait(false);
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (!_networkMonitor.IsOnline)
|
if (!_networkMonitor.IsOnline)
|
||||||
return;
|
return false;
|
||||||
|
|
||||||
var query = HttpUtility.ParseQueryString(string.Empty);
|
var query = HttpUtility.ParseQueryString(string.Empty);
|
||||||
query["pageNo"] = "1";
|
query["pageNo"] = "1";
|
||||||
@@ -158,16 +159,37 @@ public class RubberQuickTestStdService : IRubberQuickTestStdService, ISingletonD
|
|||||||
var records = doc.RootElement.GetProperty("result").GetProperty("records")
|
var records = doc.RootElement.GetProperty("result").GetProperty("records")
|
||||||
.Deserialize<List<MesXslRubberQuickTestStd>>(_jsonOpts) ?? new();
|
.Deserialize<List<MesXslRubberQuickTestStd>>(_jsonOpts) ?? new();
|
||||||
|
|
||||||
|
List<MesXslRubberQuickTestStd> localSnapshot;
|
||||||
|
lock (_cacheLock)
|
||||||
|
localSnapshot = _localCache.Select(CloneMain).ToList();
|
||||||
|
|
||||||
|
var (merged, stats) = MesReadOnlyCacheMergeHelper.Merge(
|
||||||
|
localSnapshot,
|
||||||
|
records,
|
||||||
|
x => x.Id,
|
||||||
|
IsStdListContentEqual,
|
||||||
|
CloneMain,
|
||||||
|
MergeStdUpdated);
|
||||||
|
|
||||||
|
if (!stats.HasChanges)
|
||||||
|
{
|
||||||
|
_logger.Information($"[快检实验标准] 与 MES 对比无差异,跳过更新 count={merged.Count}");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
lock (_cacheLock)
|
lock (_cacheLock)
|
||||||
{
|
{
|
||||||
_localCache = records.Select(CloneMain).ToList();
|
_localCache = merged;
|
||||||
SaveCacheToDiskUnsafe();
|
SaveCacheToDiskUnsafe();
|
||||||
}
|
}
|
||||||
_logger.Information($"[快检实验标准] 同步完成 count={records.Count}");
|
_logger.Information(
|
||||||
|
$"[快检实验标准] 差异同步完成 total={merged.Count} 新增={stats.Added} 变更={stats.Updated} 删除={stats.Removed}");
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
_logger.Warning($"[快检实验标准] 远程同步失败:{ex.Message}");
|
_logger.Warning($"[快检实验标准] 远程同步失败:{ex.Message}");
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
finally
|
finally
|
||||||
{
|
{
|
||||||
@@ -180,7 +202,8 @@ public class RubberQuickTestStdService : IRubberQuickTestStdService, ISingletonD
|
|||||||
if (!isOnline) return;
|
if (!isOnline) return;
|
||||||
_ = Task.Run(async () =>
|
_ = Task.Run(async () =>
|
||||||
{
|
{
|
||||||
await SyncFromRemoteAsync(CancellationToken.None).ConfigureAwait(false);
|
if (!await SyncFromRemoteAsync(CancellationToken.None).ConfigureAwait(false))
|
||||||
|
return;
|
||||||
_eventAggregator.GetEvent<RubberQuickTestStdChangedEvent>()
|
_eventAggregator.GetEvent<RubberQuickTestStdChangedEvent>()
|
||||||
.Publish(new RubberQuickTestStdChangedPayload { Action = "reconnect" });
|
.Publish(new RubberQuickTestStdChangedPayload { Action = "reconnect" });
|
||||||
});
|
});
|
||||||
@@ -202,19 +225,67 @@ public class RubberQuickTestStdService : IRubberQuickTestStdService, ISingletonD
|
|||||||
return q.OrderByDescending(x => x.CreateTime ?? DateTime.MinValue).ToList();
|
return q.OrderByDescending(x => x.CreateTime ?? DateTime.MinValue).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpsertLocalCacheMain(MesXslRubberQuickTestStd entity)
|
private bool UpsertIfChanged(MesXslRubberQuickTestStd entity)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(entity.Id)) return;
|
if (string.IsNullOrWhiteSpace(entity.Id)) return false;
|
||||||
lock (_cacheLock)
|
lock (_cacheLock)
|
||||||
{
|
{
|
||||||
var idx = _localCache.FindIndex(x => string.Equals(x.Id, entity.Id, StringComparison.OrdinalIgnoreCase));
|
var idx = _localCache.FindIndex(x => string.Equals(x.Id, entity.Id, StringComparison.OrdinalIgnoreCase));
|
||||||
var copy = CloneMain(entity);
|
if (idx >= 0)
|
||||||
if (idx >= 0) _localCache[idx] = copy;
|
{
|
||||||
else _localCache.Insert(0, copy);
|
if (IsStdDetailContentEqual(_localCache[idx], entity))
|
||||||
|
return false;
|
||||||
|
_localCache[idx] = CloneMain(entity);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_localCache.Insert(0, CloneMain(entity));
|
||||||
|
}
|
||||||
SaveCacheToDiskUnsafe();
|
SaveCacheToDiskUnsafe();
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static bool IsStdListContentEqual(MesXslRubberQuickTestStd a, MesXslRubberQuickTestStd b) =>
|
||||||
|
string.Equals(GetStdListFingerprint(a), GetStdListFingerprint(b), StringComparison.Ordinal);
|
||||||
|
|
||||||
|
private static bool IsStdDetailContentEqual(MesXslRubberQuickTestStd a, MesXslRubberQuickTestStd b) =>
|
||||||
|
string.Equals(GetStdDetailFingerprint(a), GetStdDetailFingerprint(b), StringComparison.Ordinal);
|
||||||
|
|
||||||
|
private static string GetStdListFingerprint(MesXslRubberQuickTestStd x)
|
||||||
|
{
|
||||||
|
var snap = CloneMain(x);
|
||||||
|
snap.LineList = null;
|
||||||
|
return JsonSerializer.Serialize(snap, _jsonOpts);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static string GetStdDetailFingerprint(MesXslRubberQuickTestStd x) =>
|
||||||
|
JsonSerializer.Serialize(CloneMain(x), _jsonOpts);
|
||||||
|
|
||||||
|
private static MesXslRubberQuickTestStd MergeStdUpdated(MesXslRubberQuickTestStd local, MesXslRubberQuickTestStd remote)
|
||||||
|
{
|
||||||
|
var copy = CloneMain(remote);
|
||||||
|
if ((copy.LineList == null || copy.LineList.Count == 0) && local.LineList is { Count: > 0 })
|
||||||
|
{
|
||||||
|
copy.LineList = local.LineList.Select(l => new MesXslRubberQuickTestStdLine
|
||||||
|
{
|
||||||
|
Id = l.Id,
|
||||||
|
StdId = l.StdId,
|
||||||
|
DataPointId = l.DataPointId,
|
||||||
|
PointName = l.PointName,
|
||||||
|
LowerLimit = l.LowerLimit,
|
||||||
|
UpperLimit = l.UpperLimit,
|
||||||
|
LowerWarn = l.LowerWarn,
|
||||||
|
UpperWarn = l.UpperWarn,
|
||||||
|
TargetValue = l.TargetValue,
|
||||||
|
SortNo = l.SortNo
|
||||||
|
}).ToList();
|
||||||
|
}
|
||||||
|
return copy;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void UpsertLocalCacheMain(MesXslRubberQuickTestStd entity) => UpsertIfChanged(entity);
|
||||||
|
|
||||||
private void LoadCacheFromDisk()
|
private void LoadCacheFromDisk()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ using Prism.Events;
|
|||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using YY.Admin.Core;
|
using YY.Admin.Core;
|
||||||
using YY.Admin.Core.Events;
|
using YY.Admin.Core.Events;
|
||||||
using YY.Admin.Core.Events;
|
|
||||||
|
|
||||||
namespace YY.Admin.Services.Service.RubberQuickTestStd;
|
namespace YY.Admin.Services.Service.RubberQuickTestStd;
|
||||||
|
|
||||||
@@ -21,8 +20,6 @@ public class RubberQuickTestStdSyncCoordinator : ISingletonDependency
|
|||||||
|
|
||||||
_eventAggregator.GetEvent<RemoteCommandReceivedEvent>()
|
_eventAggregator.GetEvent<RemoteCommandReceivedEvent>()
|
||||||
.Subscribe(OnRemoteCommand, ThreadOption.BackgroundThread);
|
.Subscribe(OnRemoteCommand, ThreadOption.BackgroundThread);
|
||||||
_eventAggregator.GetEvent<NetworkStatusChangedEvent>()
|
|
||||||
.Subscribe(OnNetworkStatusChanged, ThreadOption.BackgroundThread);
|
|
||||||
|
|
||||||
pollManager.Register("胶料快检实验标准", () =>
|
pollManager.Register("胶料快检实验标准", () =>
|
||||||
{
|
{
|
||||||
@@ -34,14 +31,6 @@ public class RubberQuickTestStdSyncCoordinator : ISingletonDependency
|
|||||||
_logger.Information("[快检实验标准] RubberQuickTestStdSyncCoordinator 已启动");
|
_logger.Information("[快检实验标准] RubberQuickTestStdSyncCoordinator 已启动");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnNetworkStatusChanged(NetworkStatusChangedPayload payload)
|
|
||||||
{
|
|
||||||
if (!payload.IsOnline) return;
|
|
||||||
_logger.Information("[快检实验标准] 网络恢复,触发补偿刷新");
|
|
||||||
_eventAggregator.GetEvent<RubberQuickTestStdChangedEvent>()
|
|
||||||
.Publish(new RubberQuickTestStdChangedPayload { Action = "reconnect" });
|
|
||||||
}
|
|
||||||
|
|
||||||
private void OnRemoteCommand(RemoteCommandPayload payload)
|
private void OnRemoteCommand(RemoteCommandPayload payload)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|||||||
@@ -178,6 +178,10 @@ public class StompWebSocketService : ISignalRService
|
|||||||
await SendFrameAsync(
|
await SendFrameAsync(
|
||||||
BuildSubscribeFrame("sub-mes-rubber-quick-test-stds", "/topic/sync/mes-rubber-quick-test-stds"),
|
BuildSubscribeFrame("sub-mes-rubber-quick-test-stds", "/topic/sync/mes-rubber-quick-test-stds"),
|
||||||
cancellationToken).ConfigureAwait(false);
|
cancellationToken).ConfigureAwait(false);
|
||||||
|
// 密炼生产计划变更:订阅 /topic/sync/mes-mixing-production-plans
|
||||||
|
await SendFrameAsync(
|
||||||
|
BuildSubscribeFrame("sub-mes-xsl-mixing-production-plan", "/topic/sync/mes-mixing-production-plans"),
|
||||||
|
cancellationToken).ConfigureAwait(false);
|
||||||
|
|
||||||
// 订阅服务端 PONG 回复(应用层假在线检测)
|
// 订阅服务端 PONG 回复(应用层假在线检测)
|
||||||
await SendFrameAsync(
|
await SendFrameAsync(
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ using YY.Admin.Views.Print;
|
|||||||
using YY.Admin.Views.MixerMaterialTareStrategy;
|
using YY.Admin.Views.MixerMaterialTareStrategy;
|
||||||
using YY.Admin.Views.RubberQuickTest;
|
using YY.Admin.Views.RubberQuickTest;
|
||||||
using YY.Admin.Views.RubberQuickTestStd;
|
using YY.Admin.Views.RubberQuickTestStd;
|
||||||
|
using YY.Admin.Views.MixingProductionPlan;
|
||||||
|
|
||||||
namespace YY.Admin
|
namespace YY.Admin
|
||||||
{
|
{
|
||||||
@@ -101,6 +102,8 @@ namespace YY.Admin
|
|||||||
containerRegistry.RegisterForNavigation<RubberQuickTestOperationView>();
|
containerRegistry.RegisterForNavigation<RubberQuickTestOperationView>();
|
||||||
// 胶料快检实验标准(只读)
|
// 胶料快检实验标准(只读)
|
||||||
containerRegistry.RegisterForNavigation<RubberQuickTestStdListView>();
|
containerRegistry.RegisterForNavigation<RubberQuickTestStdListView>();
|
||||||
|
// 密炼计划(只读)
|
||||||
|
containerRegistry.RegisterForNavigation<MixingProductionPlanListView>();
|
||||||
// 打印设置
|
// 打印设置
|
||||||
containerRegistry.RegisterForNavigation<PrintSettingsView>();
|
containerRegistry.RegisterForNavigation<PrintSettingsView>();
|
||||||
// 打印模板列表
|
// 打印模板列表
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ using YY.Admin.Services.Service.WeightRecord;
|
|||||||
using YY.Admin.Services.Service.Print;
|
using YY.Admin.Services.Service.Print;
|
||||||
using YY.Admin.Services.Service.RubberQuickTest;
|
using YY.Admin.Services.Service.RubberQuickTest;
|
||||||
using YY.Admin.Services.Service.RubberQuickTestStd;
|
using YY.Admin.Services.Service.RubberQuickTestStd;
|
||||||
|
using YY.Admin.Services.Service.MixingProductionPlan;
|
||||||
|
|
||||||
namespace YY.Admin.Module;
|
namespace YY.Admin.Module;
|
||||||
|
|
||||||
@@ -95,6 +96,10 @@ public class SyncModule : IModule
|
|||||||
containerRegistry.RegisterSingleton<IRubberQuickTestStdService, RubberQuickTestStdService>();
|
containerRegistry.RegisterSingleton<IRubberQuickTestStdService, RubberQuickTestStdService>();
|
||||||
containerRegistry.RegisterSingleton<RubberQuickTestStdSyncCoordinator>();
|
containerRegistry.RegisterSingleton<RubberQuickTestStdSyncCoordinator>();
|
||||||
|
|
||||||
|
// 密炼计划(MES 只读同步)
|
||||||
|
containerRegistry.RegisterSingleton<IMixingProductionPlanService, MixingProductionPlanService>();
|
||||||
|
containerRegistry.RegisterSingleton<MixingProductionPlanSyncCoordinator>();
|
||||||
|
|
||||||
var serviceCollection = new ServiceCollection();
|
var serviceCollection = new ServiceCollection();
|
||||||
serviceCollection.AddTransient<DisconnectGuardHandler>();
|
serviceCollection.AddTransient<DisconnectGuardHandler>();
|
||||||
serviceCollection.AddHttpClient("JeecgApi", (sp, client) =>
|
serviceCollection.AddHttpClient("JeecgApi", (sp, client) =>
|
||||||
@@ -167,6 +172,8 @@ public class SyncModule : IModule
|
|||||||
_ = containerProvider.Resolve<PrintBizTemplateBindSyncCoordinator>();
|
_ = containerProvider.Resolve<PrintBizTemplateBindSyncCoordinator>();
|
||||||
// 胶料快检实验标准只读同步协调器
|
// 胶料快检实验标准只读同步协调器
|
||||||
_ = containerProvider.Resolve<RubberQuickTestStdSyncCoordinator>();
|
_ = containerProvider.Resolve<RubberQuickTestStdSyncCoordinator>();
|
||||||
|
// 密炼计划只读同步协调器
|
||||||
|
_ = containerProvider.Resolve<MixingProductionPlanSyncCoordinator>();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static IAsyncPolicy<HttpResponseMessage> GetRetryPolicy()
|
private static IAsyncPolicy<HttpResponseMessage> GetRetryPolicy()
|
||||||
|
|||||||
@@ -162,6 +162,11 @@ namespace YY.Admin.ViewModels.Control
|
|||||||
["/xslmes/mesXslRubberQuickTestStd"] = "RubberQuickTestStdListView",
|
["/xslmes/mesXslRubberQuickTestStd"] = "RubberQuickTestStdListView",
|
||||||
["mesXslRubberQuickTestStd"] = "RubberQuickTestStdListView",
|
["mesXslRubberQuickTestStd"] = "RubberQuickTestStdListView",
|
||||||
|
|
||||||
|
// 已实现页面:密炼计划(只读)
|
||||||
|
["MixingProductionPlanListView"] = "MixingProductionPlanListView",
|
||||||
|
["/xslmes/mesXslMixingProductionPlan"] = "MixingProductionPlanListView",
|
||||||
|
["mesXslMixingProductionPlan"] = "MixingProductionPlanListView",
|
||||||
|
|
||||||
// 已实现页面:打印设置
|
// 已实现页面:打印设置
|
||||||
["PrintSettingsView"] = "PrintSettingsView",
|
["PrintSettingsView"] = "PrintSettingsView",
|
||||||
["/system/printSettings"] = "PrintSettingsView",
|
["/system/printSettings"] = "PrintSettingsView",
|
||||||
|
|||||||
@@ -0,0 +1,139 @@
|
|||||||
|
using HandyControl.Controls;
|
||||||
|
using Prism.Events;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using YY.Admin.Core;
|
||||||
|
using YY.Admin.Core.Entity;
|
||||||
|
using YY.Admin.Core.Events;
|
||||||
|
using YY.Admin.Core.Helper;
|
||||||
|
using YY.Admin.Core.Services;
|
||||||
|
using YY.Admin.Services.Service;
|
||||||
|
|
||||||
|
namespace YY.Admin.ViewModels.MixingProductionPlan;
|
||||||
|
|
||||||
|
public class MixingProductionPlanListViewModel : BaseViewModel
|
||||||
|
{
|
||||||
|
private readonly IMixingProductionPlanService _planService;
|
||||||
|
private SubscriptionToken? _changedToken;
|
||||||
|
|
||||||
|
private ObservableCollection<MesXslMixingProductionPlan> _items = new();
|
||||||
|
public ObservableCollection<MesXslMixingProductionPlan> Items
|
||||||
|
{
|
||||||
|
get => _items;
|
||||||
|
set => SetProperty(ref _items, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
private long _total;
|
||||||
|
public long Total { get => _total; set => SetProperty(ref _total, value); }
|
||||||
|
|
||||||
|
private int _pageNo = 1;
|
||||||
|
public int PageNo { get => _pageNo; set => SetProperty(ref _pageNo, value); }
|
||||||
|
|
||||||
|
private int _pageSize = 20;
|
||||||
|
public int PageSize { get => _pageSize; set => SetProperty(ref _pageSize, value); }
|
||||||
|
|
||||||
|
private DateTime? _filterPlanDateFrom;
|
||||||
|
public DateTime? FilterPlanDateFrom { get => _filterPlanDateFrom; set => SetProperty(ref _filterPlanDateFrom, value); }
|
||||||
|
|
||||||
|
private DateTime? _filterPlanDateTo;
|
||||||
|
public DateTime? FilterPlanDateTo { get => _filterPlanDateTo; set => SetProperty(ref _filterPlanDateTo, value); }
|
||||||
|
|
||||||
|
private string? _filterMachineName;
|
||||||
|
public string? FilterMachineName { get => _filterMachineName; set => SetProperty(ref _filterMachineName, value); }
|
||||||
|
|
||||||
|
private int? _filterShiftFlag;
|
||||||
|
public int? FilterShiftFlag { get => _filterShiftFlag; set => SetProperty(ref _filterShiftFlag, value); }
|
||||||
|
|
||||||
|
private string? _filterPlanNo;
|
||||||
|
public string? FilterPlanNo { get => _filterPlanNo; set => SetProperty(ref _filterPlanNo, value); }
|
||||||
|
|
||||||
|
private string? _filterMaterialName;
|
||||||
|
public string? FilterMaterialName { get => _filterMaterialName; set => SetProperty(ref _filterMaterialName, value); }
|
||||||
|
|
||||||
|
public ObservableCollection<KeyValuePair<string, int?>> ShiftOptions { get; } = new()
|
||||||
|
{
|
||||||
|
new KeyValuePair<string, int?>("全部", null),
|
||||||
|
new KeyValuePair<string, int?>("早班", 1),
|
||||||
|
new KeyValuePair<string, int?>("中班", 2),
|
||||||
|
new KeyValuePair<string, int?>("晚班", 3)
|
||||||
|
};
|
||||||
|
|
||||||
|
public DelegateCommand SearchCommand { get; }
|
||||||
|
public DelegateCommand ResetCommand { get; }
|
||||||
|
public DelegateCommand PrevPageCommand { get; }
|
||||||
|
public DelegateCommand NextPageCommand { get; }
|
||||||
|
|
||||||
|
public MixingProductionPlanListViewModel(
|
||||||
|
IMixingProductionPlanService planService,
|
||||||
|
IContainerExtension container,
|
||||||
|
IRegionManager regionManager) : base(container, regionManager)
|
||||||
|
{
|
||||||
|
_planService = planService;
|
||||||
|
|
||||||
|
SearchCommand = new DelegateCommand(async () => { PageNo = 1; await LoadAsync(); });
|
||||||
|
ResetCommand = new DelegateCommand(async () =>
|
||||||
|
{
|
||||||
|
FilterPlanDateFrom = null;
|
||||||
|
FilterPlanDateTo = null;
|
||||||
|
FilterMachineName = null;
|
||||||
|
FilterShiftFlag = null;
|
||||||
|
FilterPlanNo = null;
|
||||||
|
FilterMaterialName = null;
|
||||||
|
PageNo = 1;
|
||||||
|
await LoadAsync();
|
||||||
|
});
|
||||||
|
PrevPageCommand = new DelegateCommand(async () => { if (PageNo > 1) { PageNo--; await LoadAsync(); } });
|
||||||
|
NextPageCommand = new DelegateCommand(async () => { if ((long)PageNo * PageSize < Total) { PageNo++; await LoadAsync(); } });
|
||||||
|
|
||||||
|
_changedToken = _eventAggregator.GetEvent<MixingProductionPlanChangedEvent>()
|
||||||
|
.Subscribe(async _ => await LoadAsync(), ThreadOption.UIThread);
|
||||||
|
|
||||||
|
_ = InitializeAsync();
|
||||||
|
}
|
||||||
|
|
||||||
|
private async Task InitializeAsync()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
await UIHelper.WaitForRenderAsync();
|
||||||
|
await LoadAsync();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Debug.WriteLine($"密炼计划列表初始化失败: {ex.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public async Task LoadAsync()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
IsLoading = true;
|
||||||
|
var result = await _planService.PageAsync(
|
||||||
|
PageNo, PageSize,
|
||||||
|
FilterPlanDateFrom, FilterPlanDateTo,
|
||||||
|
FilterMachineName, FilterShiftFlag,
|
||||||
|
FilterPlanNo, FilterMaterialName);
|
||||||
|
Items = new ObservableCollection<MesXslMixingProductionPlan>(result.Records);
|
||||||
|
Total = result.Total;
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Growl.Error($"加载密炼计划失败:{ex.Message}");
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
IsLoading = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected override void CleanUp()
|
||||||
|
{
|
||||||
|
base.CleanUp();
|
||||||
|
if (_changedToken != null)
|
||||||
|
{
|
||||||
|
_eventAggregator.GetEvent<MixingProductionPlanChangedEvent>().Unsubscribe(_changedToken);
|
||||||
|
_changedToken = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -25,9 +25,10 @@ public class MixingPlanShiftOption
|
|||||||
public string? PlanId { get; set; }
|
public string? PlanId { get; set; }
|
||||||
public string? OrderNo { get; set; }
|
public string? OrderNo { get; set; }
|
||||||
public string? FormulaName { get; set; }
|
public string? FormulaName { get; set; }
|
||||||
|
public string? MaterialName { get; set; }
|
||||||
public string DisplayText => string.IsNullOrWhiteSpace(OrderNo)
|
public string DisplayText => string.IsNullOrWhiteSpace(OrderNo)
|
||||||
? FormulaName ?? string.Empty
|
? MaterialName ?? FormulaName ?? string.Empty
|
||||||
: $"{OrderNo} | {FormulaName}";
|
: $"{OrderNo} | {MaterialName ?? FormulaName}";
|
||||||
}
|
}
|
||||||
|
|
||||||
public class QuickTestInspectCellViewModel : BindableBase
|
public class QuickTestInspectCellViewModel : BindableBase
|
||||||
@@ -217,7 +218,7 @@ public class RubberQuickTestOperationViewModel : BaseViewModel
|
|||||||
public string? ProductionOrderNo => _selectedPlan?.OrderNo;
|
public string? ProductionOrderNo => _selectedPlan?.OrderNo;
|
||||||
public string? MachineName => _selectedPlan?.MachineName ?? SelectedMachine;
|
public string? MachineName => _selectedPlan?.MachineName ?? SelectedMachine;
|
||||||
public string? WorkShiftDisplay => SelectedShift?.Name ?? string.Empty;
|
public string? WorkShiftDisplay => SelectedShift?.Name ?? string.Empty;
|
||||||
public string? RubberMaterialName => _selectedPlan?.FormulaName;
|
public string? RubberMaterialName => _selectedPlan?.MaterialName ?? _selectedPlan?.FormulaName;
|
||||||
|
|
||||||
private string? _trainNo;
|
private string? _trainNo;
|
||||||
public string? TrainNo
|
public string? TrainNo
|
||||||
@@ -286,32 +287,25 @@ public class RubberQuickTestOperationViewModel : BaseViewModel
|
|||||||
_allShiftOptions.Clear();
|
_allShiftOptions.Clear();
|
||||||
foreach (var row in _allPlans)
|
foreach (var row in _allPlans)
|
||||||
{
|
{
|
||||||
AddShiftOption(row, "morning", "1", "早班", row.MorningPlanId, row.MorningOrderDate, row.MorningOrderNo, row.MorningFormulaName);
|
if (string.IsNullOrWhiteSpace(row.PlanId)) continue;
|
||||||
AddShiftOption(row, "noon", "2", "中班", row.NoonPlanId, row.NoonOrderDate, row.NoonOrderNo, row.NoonFormulaName);
|
var shiftCode = row.ShiftFlag?.ToString() ?? string.Empty;
|
||||||
AddShiftOption(row, "night", "3", "晚班", row.NightPlanId, row.NightOrderDate, row.NightOrderNo, row.NightFormulaName);
|
_allShiftOptions.Add(new MixingPlanShiftOption
|
||||||
|
{
|
||||||
|
PlanRowId = row.Id ?? string.Empty,
|
||||||
|
MachineId = row.MachineId,
|
||||||
|
MachineName = row.MachineName,
|
||||||
|
ShiftKey = shiftCode,
|
||||||
|
ShiftCode = shiftCode,
|
||||||
|
ShiftName = row.ShiftFlagText,
|
||||||
|
OrderDate = row.PlanDate,
|
||||||
|
PlanId = row.PlanId,
|
||||||
|
OrderNo = row.OrderNo,
|
||||||
|
FormulaName = row.FormulaName,
|
||||||
|
MaterialName = row.MaterialName
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void AddShiftOption(
|
|
||||||
MesXslMixingProductionPlan row, string shiftKey, string shiftCode, string shiftName,
|
|
||||||
string? planId, DateTime? orderDate, string? orderNo, string? formulaName)
|
|
||||||
{
|
|
||||||
if (string.IsNullOrWhiteSpace(planId) || string.IsNullOrWhiteSpace(orderNo)) return;
|
|
||||||
_allShiftOptions.Add(new MixingPlanShiftOption
|
|
||||||
{
|
|
||||||
PlanRowId = row.Id ?? string.Empty,
|
|
||||||
MachineId = row.MachineId,
|
|
||||||
MachineName = row.MachineName,
|
|
||||||
ShiftKey = shiftKey,
|
|
||||||
ShiftCode = shiftCode,
|
|
||||||
ShiftName = shiftName,
|
|
||||||
OrderDate = orderDate,
|
|
||||||
PlanId = planId,
|
|
||||||
OrderNo = orderNo,
|
|
||||||
FormulaName = formulaName
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
private IEnumerable<MixingPlanShiftOption> FilteredByDate =>
|
private IEnumerable<MixingPlanShiftOption> FilteredByDate =>
|
||||||
_allShiftOptions.Where(o => o.OrderDate?.Date == MixingDate.Date);
|
_allShiftOptions.Where(o => o.OrderDate?.Date == MixingDate.Date);
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,133 @@
|
|||||||
|
<UserControl x:Class="YY.Admin.Views.MixingProductionPlan.MixingProductionPlanListView"
|
||||||
|
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:hc="https://handyorg.github.io/handycontrol"
|
||||||
|
xmlns:md="http://materialdesigninxaml.net/winfx/xaml/themes"
|
||||||
|
xmlns:prism="http://prismlibrary.com/"
|
||||||
|
prism:ViewModelLocator.AutoWireViewModel="True"
|
||||||
|
mc:Ignorable="d">
|
||||||
|
|
||||||
|
<Grid Style="{StaticResource BaseViewStyle}">
|
||||||
|
<Grid.RowDefinitions>
|
||||||
|
<RowDefinition Height="Auto"/>
|
||||||
|
<RowDefinition Height="Auto"/>
|
||||||
|
<RowDefinition Height="*"/>
|
||||||
|
<RowDefinition Height="Auto"/>
|
||||||
|
</Grid.RowDefinitions>
|
||||||
|
|
||||||
|
<Border Grid.Row="0" CornerRadius="4" Margin="0 0 -10 0">
|
||||||
|
<hc:Row>
|
||||||
|
<hc:Col Layout="{hc:ColLayout Xs=12, Sm=8, Md=6, Lg=6, Xl=4}">
|
||||||
|
<hc:DatePicker SelectedDate="{Binding FilterPlanDateFrom}"
|
||||||
|
Margin="0 0 10 10"
|
||||||
|
hc:InfoElement.Title="密炼日期起"
|
||||||
|
hc:InfoElement.TitlePlacement="Left"
|
||||||
|
hc:InfoElement.TitleWidth="80"
|
||||||
|
hc:InfoElement.Placeholder="开始日期"/>
|
||||||
|
</hc:Col>
|
||||||
|
<hc:Col Layout="{hc:ColLayout Xs=12, Sm=8, Md=6, Lg=6, Xl=4}">
|
||||||
|
<hc:DatePicker SelectedDate="{Binding FilterPlanDateTo}"
|
||||||
|
Margin="0 0 10 10"
|
||||||
|
hc:InfoElement.Title="密炼日期止"
|
||||||
|
hc:InfoElement.TitlePlacement="Left"
|
||||||
|
hc:InfoElement.TitleWidth="80"
|
||||||
|
hc:InfoElement.Placeholder="结束日期"/>
|
||||||
|
</hc:Col>
|
||||||
|
<hc:Col Layout="{hc:ColLayout Xs=12, Sm=8, Md=6, Lg=6, Xl=4}">
|
||||||
|
<hc:TextBox Text="{Binding FilterMachineName, UpdateSourceTrigger=PropertyChanged}"
|
||||||
|
Margin="0 0 10 10"
|
||||||
|
hc:InfoElement.Title="机台名称"
|
||||||
|
hc:InfoElement.TitlePlacement="Left"
|
||||||
|
hc:InfoElement.TitleWidth="80"
|
||||||
|
hc:InfoElement.Placeholder="机台名称"
|
||||||
|
hc:InfoElement.ShowClearButton="True"/>
|
||||||
|
</hc:Col>
|
||||||
|
<hc:Col Layout="{hc:ColLayout Xs=12, Sm=8, Md=6, Lg=6, Xl=4}">
|
||||||
|
<hc:ComboBox SelectedValuePath="Value"
|
||||||
|
DisplayMemberPath="Key"
|
||||||
|
ItemsSource="{Binding ShiftOptions}"
|
||||||
|
SelectedValue="{Binding FilterShiftFlag}"
|
||||||
|
Margin="0 0 10 10"
|
||||||
|
hc:InfoElement.Title="班次"
|
||||||
|
hc:InfoElement.TitlePlacement="Left"
|
||||||
|
hc:InfoElement.TitleWidth="80"
|
||||||
|
hc:InfoElement.Placeholder="全部"/>
|
||||||
|
</hc:Col>
|
||||||
|
<hc:Col Layout="{hc:ColLayout Xs=12, Sm=8, Md=6, Lg=6, Xl=4}">
|
||||||
|
<hc:TextBox Text="{Binding FilterPlanNo, UpdateSourceTrigger=PropertyChanged}"
|
||||||
|
Margin="0 0 10 10"
|
||||||
|
hc:InfoElement.Title="计划号"
|
||||||
|
hc:InfoElement.TitlePlacement="Left"
|
||||||
|
hc:InfoElement.TitleWidth="80"
|
||||||
|
hc:InfoElement.Placeholder="计划号"
|
||||||
|
hc:InfoElement.ShowClearButton="True"/>
|
||||||
|
</hc:Col>
|
||||||
|
<hc:Col Layout="{hc:ColLayout Xs=12, Sm=8, Md=6, Lg=6, Xl=4}">
|
||||||
|
<hc:TextBox Text="{Binding FilterMaterialName, UpdateSourceTrigger=PropertyChanged}"
|
||||||
|
Margin="0 0 10 10"
|
||||||
|
hc:InfoElement.Title="胶料名称"
|
||||||
|
hc:InfoElement.TitlePlacement="Left"
|
||||||
|
hc:InfoElement.TitleWidth="80"
|
||||||
|
hc:InfoElement.Placeholder="胶料名称"
|
||||||
|
hc:InfoElement.ShowClearButton="True"/>
|
||||||
|
</hc:Col>
|
||||||
|
</hc:Row>
|
||||||
|
</Border>
|
||||||
|
|
||||||
|
<Border Grid.Row="1" Margin="0,10">
|
||||||
|
<hc:UniformSpacingPanel Spacing="10">
|
||||||
|
<Button Style="{StaticResource ButtonPrimary}" Command="{Binding SearchCommand}">
|
||||||
|
<StackPanel Orientation="Horizontal">
|
||||||
|
<md:PackIcon Kind="Search"/>
|
||||||
|
<TextBlock Text="搜索" Style="{StaticResource IconButtonStyle}"/>
|
||||||
|
</StackPanel>
|
||||||
|
</Button>
|
||||||
|
<Button Style="{StaticResource ButtonDefault}" Command="{Binding ResetCommand}">
|
||||||
|
<StackPanel Orientation="Horizontal">
|
||||||
|
<md:PackIcon Kind="Refresh"/>
|
||||||
|
<TextBlock Text="重置" Style="{StaticResource IconButtonStyle}"/>
|
||||||
|
</StackPanel>
|
||||||
|
</Button>
|
||||||
|
<TextBlock Text="数据来自 MES 密炼生产计划维护,桌面端只读;断网时显示本地缓存,联网后自动刷新"
|
||||||
|
VerticalAlignment="Center"
|
||||||
|
Foreground="{DynamicResource SecondaryTextBrush}"
|
||||||
|
FontSize="12"/>
|
||||||
|
</hc:UniformSpacingPanel>
|
||||||
|
</Border>
|
||||||
|
|
||||||
|
<DataGrid Grid.Row="2"
|
||||||
|
ItemsSource="{Binding Items}"
|
||||||
|
AutoGenerateColumns="False"
|
||||||
|
IsReadOnly="True"
|
||||||
|
CanUserAddRows="False"
|
||||||
|
SelectionMode="Single"
|
||||||
|
GridLinesVisibility="Horizontal"
|
||||||
|
HorizontalGridLinesBrush="#FFEDEDED"
|
||||||
|
VerticalGridLinesBrush="Transparent"
|
||||||
|
HeadersVisibility="All"
|
||||||
|
ColumnHeaderStyle="{StaticResource CusDataGridColumnHeaderStyle}"
|
||||||
|
Style="{StaticResource CusDataGridStyle}"
|
||||||
|
VerticalScrollBarVisibility="Auto"
|
||||||
|
HorizontalScrollBarVisibility="Auto">
|
||||||
|
<DataGrid.Columns>
|
||||||
|
<DataGridTextColumn Header="密炼日期" Binding="{Binding PlanDateText}" CellStyle="{StaticResource CusDataGridCellStyle}" Width="110"/>
|
||||||
|
<DataGridTextColumn Header="机台名称" Binding="{Binding MachineName}" CellStyle="{StaticResource CusDataGridCellStyle}" Width="140"/>
|
||||||
|
<DataGridTextColumn Header="班次" Binding="{Binding ShiftFlagText}" CellStyle="{StaticResource CusDataGridCellStyle}" Width="80"/>
|
||||||
|
<DataGridTextColumn Header="计划号" Binding="{Binding PlanNo}" CellStyle="{StaticResource CusDataGridCellStyle}" Width="140"/>
|
||||||
|
<DataGridTextColumn Header="计划数量" Binding="{Binding PlanCount}" CellStyle="{StaticResource CusDataGridCellStyle}" Width="90"/>
|
||||||
|
<DataGridTextColumn Header="胶料名称" Binding="{Binding MaterialName}" CellStyle="{StaticResource CusDataGridCellStyle}" Width="*"/>
|
||||||
|
</DataGrid.Columns>
|
||||||
|
</DataGrid>
|
||||||
|
|
||||||
|
<StackPanel Grid.Row="3" Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,10,0,0">
|
||||||
|
<TextBlock Text="{Binding Total, StringFormat=共 {0} 条}" VerticalAlignment="Center" Margin="0,0,16,0"
|
||||||
|
Foreground="{DynamicResource SecondaryTextBrush}"/>
|
||||||
|
<Button Content="上一页" Command="{Binding PrevPageCommand}" Style="{StaticResource ButtonDefault}" Margin="0,0,4,0" Width="80"/>
|
||||||
|
<TextBlock Text="{Binding PageNo, StringFormat=第 {0} 页}" VerticalAlignment="Center" Margin="8,0"
|
||||||
|
Foreground="{DynamicResource PrimaryTextBrush}"/>
|
||||||
|
<Button Content="下一页" Command="{Binding NextPageCommand}" Style="{StaticResource ButtonDefault}" Width="80"/>
|
||||||
|
</StackPanel>
|
||||||
|
</Grid>
|
||||||
|
</UserControl>
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
using System.Windows.Controls;
|
||||||
|
|
||||||
|
namespace YY.Admin.Views.MixingProductionPlan;
|
||||||
|
|
||||||
|
public partial class MixingProductionPlanListView : UserControl
|
||||||
|
{
|
||||||
|
public MixingProductionPlanListView()
|
||||||
|
{
|
||||||
|
InitializeComponent();
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user