7 Commits

15 changed files with 384 additions and 1327 deletions

View File

@@ -148,3 +148,60 @@ WHERE id IN (
'1860000000000000041',
'1860000000000000051'
);
-- ======================================================
-- 新增菜单原材料检验项目
-- ======================================================
INSERT INTO sys_permission(id, parent_id, name, url, component, component_name, menu_type, perms, perms_type, sort_no, is_route, is_leaf, hidden, status, del_flag, keep_alive, internal_or_external, create_by, create_time)
VALUES ('1860000000000000061', '1860000000000000001', '原材料检验项目', '/mes/rawmaterialinspectitem', 'mes/material/MesRawMaterialInspectItemList', 'MesRawMaterialInspectItemList', 1, NULL, '1', 6, 1, 1, 0, '1', 0, 1, 0, 'admin', NOW())
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), perms=VALUES(perms), perms_type=VALUES(perms_type), sort_no=VALUES(sort_no),
is_route=VALUES(is_route), is_leaf=VALUES(is_leaf), hidden=VALUES(hidden), status=VALUES(status), del_flag=VALUES(del_flag),
keep_alive=VALUES(keep_alive), internal_or_external=VALUES(internal_or_external);
INSERT INTO sys_permission(id,parent_id,name,menu_type,perms,perms_type,status,del_flag,create_by,create_time) VALUES
('1860000000000000062','1860000000000000061','新增',2,'mes:mes_raw_material_inspect_item:add','1','1',0,'admin',NOW()),
('1860000000000000063','1860000000000000061','编辑',2,'mes:mes_raw_material_inspect_item:edit','1','1',0,'admin',NOW()),
('1860000000000000064','1860000000000000061','删除',2,'mes:mes_raw_material_inspect_item:delete','1','1',0,'admin',NOW()),
('1860000000000000065','1860000000000000061','批量删除',2,'mes:mes_raw_material_inspect_item:deleteBatch','1','1',0,'admin',NOW()),
('1860000000000000066','1860000000000000061','导出',2,'mes:mes_raw_material_inspect_item:exportXls','1','1',0,'admin',NOW()),
('1860000000000000067','1860000000000000061','导入',2,'mes:mes_raw_material_inspect_item:importExcel','1','1',0,'admin',NOW())
ON DUPLICATE KEY UPDATE
parent_id=VALUES(parent_id), name=VALUES(name), menu_type=VALUES(menu_type), perms=VALUES(perms), perms_type=VALUES(perms_type),
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, is_route, is_leaf, hidden, status, del_flag, keep_alive, internal_or_external, create_by, create_time)
VALUES ('1860000000000000071', '1860000000000000001', '原材料检验标准', '/mes/rawmaterialinspectstd', 'mes/material/MesRawMaterialInspectStdList', 'MesRawMaterialInspectStdList', 1, NULL, '1', 7, 1, 1, 0, '1', 0, 1, 0, 'admin', NOW())
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), perms=VALUES(perms), perms_type=VALUES(perms_type), sort_no=VALUES(sort_no),
is_route=VALUES(is_route), is_leaf=VALUES(is_leaf), hidden=VALUES(hidden), status=VALUES(status), del_flag=VALUES(del_flag),
keep_alive=VALUES(keep_alive), internal_or_external=VALUES(internal_or_external);
INSERT INTO sys_permission(id,parent_id,name,menu_type,perms,perms_type,status,del_flag,create_by,create_time) VALUES
('1860000000000000072','1860000000000000071','新增',2,'mes:mes_raw_material_inspect_std:add','1','1',0,'admin',NOW()),
('1860000000000000073','1860000000000000071','编辑',2,'mes:mes_raw_material_inspect_std:edit','1','1',0,'admin',NOW()),
('1860000000000000074','1860000000000000071','删除',2,'mes:mes_raw_material_inspect_std:delete','1','1',0,'admin',NOW()),
('1860000000000000075','1860000000000000071','批量删除',2,'mes:mes_raw_material_inspect_std:deleteBatch','1','1',0,'admin',NOW()),
('1860000000000000076','1860000000000000071','启用停用',2,'mes:mes_raw_material_inspect_std:enable','1','1',0,'admin',NOW()),
('1860000000000000077','1860000000000000071','导出',2,'mes:mes_raw_material_inspect_std:exportXls','1','1',0,'admin',NOW()),
('1860000000000000078','1860000000000000071','导入',2,'mes:mes_raw_material_inspect_std:importExcel','1','1',0,'admin',NOW())
ON DUPLICATE KEY UPDATE
parent_id=VALUES(parent_id), name=VALUES(name), menu_type=VALUES(menu_type), perms=VALUES(perms), perms_type=VALUES(perms_type),
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 (
'1860000000000000061','1860000000000000062','1860000000000000063','1860000000000000064','1860000000000000065','1860000000000000066','1860000000000000067',
'1860000000000000071','1860000000000000072','1860000000000000073','1860000000000000074','1860000000000000075','1860000000000000076','1860000000000000077','1860000000000000078'
) AND NOT EXISTS (
SELECT 1
FROM sys_role_permission rp
WHERE rp.role_id = 'f6817f48af4fb3af11b9e8bf182f618b'
AND rp.permission_id = p.id
);

View File

@@ -0,0 +1,37 @@
-- 原材料汇总页面菜单参考原材料库存菜单配置
SET NAMES utf8mb4;
-- 优先复用原材料库存的父级菜单不存在时回退到原固定父级
SET @xsl_parent_id = (
SELECT parent_id
FROM sys_permission
WHERE id = '1900000000000000600'
LIMIT 1
);
SET @xsl_parent_id = IFNULL(@xsl_parent_id, '1900000000000000300');
-- 页面菜单
INSERT INTO `sys_permission` (`id`, `parent_id`, `name`, `url`, `component`, `is_route`, `component_name`, `redirect`, `menu_type`, `perms`, `perms_type`, `sort_no`, `always_show`, `icon`, `is_leaf`, `keep_alive`, `hidden`, `hide_tab`, `description`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`, `rule_flag`, `status`, `internal_or_external`)
SELECT '1900000000000000610', @xsl_parent_id, '原材料汇总', '/xslmes/mesXslRawMaterialSummary', 'xslmes/mesXslRawMaterialSummary/MesXslRawMaterialSummaryList', 1, NULL, NULL, 1, NULL, '0', 13.00, 0, 'ant-design:database-outlined', 0, 1, 0, 0, '原材料汇总', 'admin', NOW(), 'admin', NOW(), 0, 0, '1', 0
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM `sys_permission` WHERE `id` = '1900000000000000610');
-- 导出按钮权限
INSERT INTO `sys_permission` (`id`, `parent_id`, `name`, `url`, `component`, `is_route`, `component_name`, `redirect`, `menu_type`, `perms`, `perms_type`, `sort_no`, `always_show`, `icon`, `is_leaf`, `keep_alive`, `hidden`, `hide_tab`, `description`, `create_by`, `create_time`, `update_by`, `update_time`, `del_flag`, `rule_flag`, `status`, `internal_or_external`)
SELECT '1900000000000000611', '1900000000000000610', '导出', NULL, NULL, 0, NULL, NULL, 2, 'xslmes:mes_xsl_raw_material_summary:exportXls', '1', 1.00, 0, NULL, 1, 0, 0, 0, NULL, 'admin', NOW(), 'admin', NOW(), 0, 0, '1', 0
FROM DUAL WHERE NOT EXISTS (SELECT 1 FROM `sys_permission` WHERE `id` = '1900000000000000611');
-- 默认管理员角色授权
INSERT INTO `sys_role_permission` (`id`, `role_id`, `permission_id`, `data_rule_ids`, `operate_date`, `operate_ip`)
SELECT REPLACE(UUID(), '-', ''), 'f6817f48af4fb3af11b9e8bf182f618b', '1900000000000000610', NULL, NOW(), '127.0.0.1'
WHERE NOT EXISTS (
SELECT 1 FROM `sys_role_permission`
WHERE `role_id` = 'f6817f48af4fb3af11b9e8bf182f618b' AND `permission_id` = '1900000000000000610'
);
INSERT INTO `sys_role_permission` (`id`, `role_id`, `permission_id`, `data_rule_ids`, `operate_date`, `operate_ip`)
SELECT REPLACE(UUID(), '-', ''), 'f6817f48af4fb3af11b9e8bf182f618b', '1900000000000000611', NULL, NOW(), '127.0.0.1'
WHERE NOT EXISTS (
SELECT 1 FROM `sys_role_permission`
WHERE `role_id` = 'f6817f48af4fb3af11b9e8bf182f618b' AND `permission_id` = '1900000000000000611'
);

View File

@@ -0,0 +1,150 @@
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 lombok.extern.slf4j.Slf4j;
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.MesXslRawMaterialSummary;
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/mesXslRawMaterialSummary")
@Slf4j
public class MesXslRawMaterialSummaryController {
@Autowired
private JdbcTemplate jdbcTemplate;
@Operation(summary = "原材料汇总-分页列表查询")
@GetMapping(value = "/list")
public Result<IPage<MesXslRawMaterialSummary>> queryPageList(
MesXslRawMaterialSummary query,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
List<Object> params = new ArrayList<>();
String groupedSql = buildGroupedSql(query, 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 + " ORDER BY warehouseName, materialName LIMIT ? OFFSET ?";
List<Object> pageParams = new ArrayList<>(params);
pageParams.add(pageSize);
pageParams.add(offset);
List<MesXslRawMaterialSummary> rows = queryRows(pageSql, pageParams);
Page<MesXslRawMaterialSummary> page = new Page<>(pageNo, pageSize, totalCount);
page.setRecords(rows);
return Result.OK(page);
}
@RequiresPermissions("xslmes:mes_xsl_raw_material_summary:exportXls")
@RequestMapping(value = "/exportXls")
public ModelAndView exportXls(HttpServletRequest request, MesXslRawMaterialSummary query) {
List<Object> params = new ArrayList<>();
String groupedSql = buildGroupedSql(query, params) + " ORDER BY warehouseName, materialName";
List<MesXslRawMaterialSummary> exportList = queryRows(groupedSql, params);
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
mv.addObject(NormalExcelConstants.FILE_NAME, "原材料汇总");
mv.addObject(NormalExcelConstants.CLASS, MesXslRawMaterialSummary.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(MesXslRawMaterialSummary query, List<Object> params) {
String warehouseExpr = "COALESCE(NULLIF(TRIM(i.warehouse_name),''), TRIM(w.warehouse_name))";
String materialNameExpr = "COALESCE(NULLIF(TRIM(i.material_name),''), TRIM(m.material_name))";
String materialCodeExpr = "COALESCE(NULLIF(TRIM(i.material_code),''), TRIM(m.material_code))";
StringBuilder sql = new StringBuilder();
sql.append("SELECT ")
.append(warehouseExpr).append(" AS warehouseName, ")
.append(materialNameExpr).append(" AS materialName, ")
.append(materialCodeExpr).append(" AS materialCode, ")
.append("SUM(COALESCE(i.total_packages,0)) AS totalPackages, ")
.append("SUM(COALESCE(i.total_weight,0)) AS totalWeight ")
.append("FROM mes_xsl_raw_material_inventory i ")
.append("LEFT JOIN mes_xsl_warehouse w ON w.id = i.warehouse_id ")
.append("AND (w.del_flag = 0 OR w.del_flag IS NULL) ")
.append("LEFT JOIN mes_mixer_material m ON m.id = i.material_id ")
.append("AND (m.del_flag = 0 OR m.del_flag IS NULL) ")
.append("WHERE (i.del_flag = 0 OR i.del_flag IS NULL) ");
if (query != null && StringUtils.isNotBlank(query.getWarehouseName())) {
sql.append("AND ").append(warehouseExpr).append(" LIKE ? ");
params.add("%" + query.getWarehouseName().trim() + "%");
}
if (query != null && StringUtils.isNotBlank(query.getMaterialName())) {
sql.append("AND ").append(materialNameExpr).append(" LIKE ? ");
params.add("%" + query.getMaterialName().trim() + "%");
}
if (query != null && StringUtils.isNotBlank(query.getMaterialCode())) {
sql.append("AND ").append(materialCodeExpr).append(" LIKE ? ");
params.add("%" + query.getMaterialCode().trim() + "%");
}
sql.append("GROUP BY ")
.append(warehouseExpr).append(", ")
.append(materialNameExpr).append(", ")
.append(materialCodeExpr);
return sql.toString();
}
private List<MesXslRawMaterialSummary> queryRows(String sql, List<Object> params) {
return jdbcTemplate.query(
sql,
rs -> {
List<MesXslRawMaterialSummary> list = new ArrayList<>();
int seq = 1;
while (rs.next()) {
MesXslRawMaterialSummary row = new MesXslRawMaterialSummary();
row.setWarehouseName(trim(rs.getString("warehouseName")));
row.setMaterialName(trim(rs.getString("materialName")));
row.setMaterialCode(trim(rs.getString("materialCode")));
row.setTotalPackages(rs.getBigDecimal("totalPackages"));
row.setTotalWeight(rs.getBigDecimal("totalWeight"));
row.setId(row.getWarehouseName() + "_" + row.getMaterialCode() + "_" + seq++);
list.add(row);
}
return list;
},
params.toArray());
}
private String trim(String v) {
return v == null ? "" : v.trim();
}
}

View File

@@ -0,0 +1,40 @@
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 MesXslRawMaterialSummary implements Serializable {
private static final long serialVersionUID = 1L;
@Schema(description = "主键")
private String id;
@Excel(name = "所在仓库", width = 20)
@Schema(description = "所在仓库")
private String warehouseName;
@Excel(name = "物料名称", width = 20)
@Schema(description = "物料名称")
private String materialName;
@Excel(name = "物料编码", width = 20)
@Schema(description = "物料编码")
private String materialCode;
@Excel(name = "总包数", width = 15)
@Schema(description = "总包数")
private BigDecimal totalPackages;
@Excel(name = "总重量", width = 15)
@Schema(description = "总重量")
private BigDecimal totalWeight;
}

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.3 KiB

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.3 KiB

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.3 KiB

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.3 KiB

After

Width:  |  Height:  |  Size: 20 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 24 KiB

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 65 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.9 KiB

After

Width:  |  Height:  |  Size: 20 KiB

View File

@@ -0,0 +1,10 @@
import { defHttp } from '/@/utils/http/axios';
enum Api {
list = '/xslmes/mesXslRawMaterialSummary/list',
exportXls = '/xslmes/mesXslRawMaterialSummary/exportXls',
}
export const getExportUrl = Api.exportXls;
export const list = (params) => defHttp.get({ url: Api.list, params });

View File

@@ -0,0 +1,23 @@
import { BasicColumn, FormSchema } from '/@/components/Table';
export const columns: BasicColumn[] = [
{ title: '所在仓库', align: 'center', dataIndex: 'warehouseName', width: 180 },
{ title: '物料名称', align: 'center', dataIndex: 'materialName', width: 180, ellipsis: true },
{ title: '物料编码', align: 'center', dataIndex: 'materialCode', width: 180 },
{ title: '总包数', align: 'center', dataIndex: 'totalPackages', width: 140 },
{ title: '总重量', align: 'center', dataIndex: 'totalWeight', width: 140 },
];
export const searchFormSchema: FormSchema[] = [
{ label: '所在仓库', field: 'warehouseName', component: 'JInput', colProps: { span: 6 } },
{ label: '物料名称', field: 'materialName', component: 'JInput', colProps: { span: 6 } },
{ label: '物料编码', field: 'materialCode', component: 'JInput', colProps: { span: 6 } },
];
export const superQuerySchema = {
warehouseName: { title: '所在仓库', order: 0, view: 'text' },
materialName: { title: '物料名称', order: 1, view: 'text' },
materialCode: { title: '物料编码', order: 2, view: 'text' },
totalPackages: { title: '总包数', order: 3, view: 'number' },
totalWeight: { title: '总重量', order: 4, view: 'number' },
};

View File

@@ -0,0 +1,54 @@
<template>
<div>
<BasicTable @register="registerTable">
<template #tableTitle>
<a-button type="primary" v-auth="'xslmes:mes_xsl_raw_material_summary: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-mesXslRawMaterialSummary" setup>
import { reactive } from 'vue';
import { BasicTable } from '/@/components/Table';
import { useListPage } from '/@/hooks/system/useListPage';
import { columns, searchFormSchema, superQuerySchema } from './MesXslRawMaterialSummary.data';
import { list, getExportUrl } from './MesXslRawMaterialSummary.api';
const queryParam = reactive<any>({});
const { tableContext, onExportXls } = useListPage({
tableProps: {
title: '原材料汇总',
api: list,
columns,
canResize: true,
formConfig: {
schemas: searchFormSchema,
autoSubmitOnEnter: true,
showAdvancedButton: true,
},
beforeFetch: (params) => {
return Object.assign(params, queryParam);
},
},
exportConfig: {
name: '原材料汇总',
url: getExportUrl,
params: queryParam,
},
});
const [registerTable, { reload }] = tableContext;
const superQueryConfig = reactive(superQuerySchema);
function handleSuperQuery(params) {
Object.keys(params).forEach((k) => {
queryParam[k] = params[k];
});
reload();
}
</script>