新增配合示方模块,包括主子表结构、控制器、服务及映射器的实现,支持增删改查功能,优化胶料代号生成逻辑及相关字段,增强数据验证和用户体验。

This commit is contained in:
geht
2026-05-21 18:49:20 +08:00
parent a10aae420a
commit 89407d1f1d
32 changed files with 5711 additions and 9 deletions

View File

@@ -0,0 +1,105 @@
-- author:jiangxh---date:20260521--for: 【配合示方】新增配合示方主子表模块 ---
jeecg-module-system/jeecg-system-start/src/main/resources/flyway/sql/mysql/V3.9.2_91__mes_xsl_formula_spec.sql
jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/entity/MesXslFormulaSpec.java
jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/entity/MesXslFormulaSpecLine.java
jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/vo/MesXslFormulaSpecPage.java
jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/mapper/MesXslFormulaSpecMapper.java
jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/mapper/MesXslFormulaSpecLineMapper.java
jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/IMesXslFormulaSpecService.java
jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/impl/MesXslFormulaSpecServiceImpl.java
jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/controller/MesXslFormulaSpecController.java
jeecgboot-vue3/src/views/xslmes/mesXslFormulaSpec/MesXslFormulaSpecList.vue
jeecgboot-vue3/src/views/xslmes/mesXslFormulaSpec/MesXslFormulaSpec.data.ts
jeecgboot-vue3/src/views/xslmes/mesXslFormulaSpec/MesXslFormulaSpec.api.ts
jeecgboot-vue3/src/views/xslmes/mesXslFormulaSpec/components/MesXslFormulaSpecModal.vue
-- author:jiangxh---date:20260521--for: 【配合示方】主表新增混合段1-7合计字段 ---
jeecg-module-system/jeecg-system-start/src/main/resources/flyway/sql/mysql/V3.9.2_92__mes_xsl_formula_spec_stage_total.sql
jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/entity/MesXslFormulaSpec.java
jeecgboot-vue3/src/views/xslmes/mesXslFormulaSpec/MesXslFormulaSpec.data.ts
jeecgboot-vue3/src/views/xslmes/mesXslFormulaSpec/components/MesXslFormulaSpecModal.vue
-- author:cursor---date:20260521--for: 【配合示方】STEP全为A/Q时对应胶比重清零 ---
jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/impl/MesXslFormulaSpecServiceImpl.java
jeecgboot-vue3/src/views/xslmes/mesXslFormulaSpec/MesXslFormulaSpec.data.ts
jeecgboot-vue3/src/views/xslmes/mesXslFormulaSpec/components/MesXslFormulaSpecModal.vue
-- author:cursor---date:20260521--for: 【配合示方】含胶率按密炼物料小类汇总重量% ---
jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/impl/MesXslFormulaSpecServiceImpl.java
jeecgboot-vue3/src/views/xslmes/mesXslFormulaSpec/MesXslFormulaSpec.data.ts
jeecgboot-vue3/src/views/xslmes/mesXslFormulaSpec/components/MesXslFormulaSpecModal.vue
jeecgboot-vue3/src/views/mes/material/modules/MesMixerMaterialSelectModal.vue
-- author:cursor---date:20260521--for: 【配合示方】含胶率物料小类可配置设置弹窗 ---
jeecg-module-system/jeecg-system-start/src/main/resources/flyway/sql/mysql/V3.9.2_96__mes_xsl_formula_spec_rubber_content_setting.sql
jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/entity/MesXslFormulaSpecSetting.java
jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/vo/MesXslFormulaRubberContentSettingVO.java
jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/mapper/MesXslFormulaSpecSettingMapper.java
jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/IMesXslFormulaSpecSettingService.java
jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/impl/MesXslFormulaSpecSettingServiceImpl.java
jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/controller/MesXslFormulaSpecController.java
jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/impl/MesXslFormulaSpecServiceImpl.java
jeecgboot-vue3/src/views/xslmes/mesXslFormulaSpec/MesXslFormulaSpec.api.ts
jeecgboot-vue3/src/views/xslmes/mesXslFormulaSpec/MesXslFormulaSpec.data.ts
jeecgboot-vue3/src/views/xslmes/mesXslFormulaSpec/components/MesXslFormulaSpecModal.vue
jeecgboot-vue3/src/views/xslmes/mesXslFormulaSpec/components/MesXslFormulaRubberContentSettingModal.vue
-- author:cursor---date:20260521--for: 【配合示方】含胶率设置改用系统MES物料分类字典 ---
jeecgboot-vue3/src/views/xslmes/mesXslFormulaSpec/MesXslFormulaSpec.data.ts
jeecgboot-vue3/src/views/xslmes/mesXslFormulaSpec/MesXslFormulaSpec.api.ts
jeecgboot-vue3/src/views/xslmes/mesXslFormulaSpec/components/MesXslFormulaRubberContentSettingModal.vue
jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/IMesXslFormulaSpecSettingService.java
jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/impl/MesXslFormulaSpecSettingServiceImpl.java
jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/controller/MesXslFormulaSpecController.java
-- author:cursor---date:20260521--for: 【配合示方】含胶率设置小类下拉对齐密炼物料loadTreeData加载 ---
jeecgboot-vue3/src/views/xslmes/mesXslFormulaSpec/MesXslFormulaSpec.data.ts
jeecgboot-vue3/src/views/xslmes/mesXslFormulaSpec/components/MesXslFormulaRubberContentSettingModal.vue
-- author:cursor---date:20260521--for: 【配合示方】含胶率设置改为loadAllData加载MES物料分类全部节点 ---
jeecgboot-vue3/src/views/xslmes/mesXslFormulaSpec/MesXslFormulaSpec.data.ts
jeecgboot-vue3/src/views/xslmes/mesXslFormulaSpec/components/MesXslFormulaRubberContentSettingModal.vue
-- author:cursor---date:20260521--for: 【配合示方】含胶率设置弹窗openModal未传data导致不加载分类 ---
jeecgboot-vue3/src/views/xslmes/mesXslFormulaSpec/components/MesXslFormulaSpecModal.vue
jeecgboot-vue3/src/views/xslmes/mesXslFormulaSpec/components/MesXslFormulaRubberContentSettingModal.vue
-- author:cursor---date:20260521--for: 【配合示方】明细新增物料大类/小类展示列(不落库) ---
jeecgboot-vue3/src/views/xslmes/mesXslFormulaSpec/MesXslFormulaSpec.data.ts
jeecgboot-vue3/src/views/xslmes/mesXslFormulaSpec/components/MesXslFormulaSpecModal.vue
jeecgboot-vue3/src/views/mes/material/modules/MesMixerMaterialSelectModal.vue
-- author:cursor---date:20260521--for: 【配合示方】明细备注列与1-7段列宽适当缩小 ---
jeecgboot-vue3/src/views/xslmes/mesXslFormulaSpec/MesXslFormulaSpec.data.ts
-- author:cursor---date:20260521--for: 【配合示方】基本信息模块改为汇总格状布局 ---
jeecgboot-vue3/src/views/xslmes/mesXslFormulaSpec/components/MesXslFormulaSpecModal.vue
-- author:cursor---date:20260521--for: 【配合示方】基本信息改为显式表格格状布局 ---
jeecgboot-vue3/src/views/xslmes/mesXslFormulaSpec/components/MesXslFormulaSpecModal.vue
jeecgboot-vue3/src/views/xslmes/mesXslFormulaSpec/MesXslFormulaSpec.data.ts
-- author:cursor---date:20260521--for: 【配合示方】汇总与基本信息标题格增加内阴影 ---
jeecgboot-vue3/src/views/xslmes/mesXslFormulaSpec/components/MesXslFormulaSpecModal.vue
-- author:cursor---date:20260521--for: 【配合示方】明细列表新增列显示/隐藏设置 ---
jeecgboot-vue3/src/views/xslmes/mesXslFormulaSpec/MesXslFormulaSpec.data.ts
jeecgboot-vue3/src/views/xslmes/mesXslFormulaSpec/components/MesXslFormulaSpecModal.vue
jeecgboot-vue3/src/views/xslmes/mesXslFormulaSpec/components/MesXslFormulaLineColumnSetting.vue
-- author:cursor---date:20260521--for: 【配合示方】明细列表列设置改为保存后生效并修复勾选状态 ---
jeecgboot-vue3/src/views/xslmes/mesXslFormulaSpec/MesXslFormulaSpec.data.ts
jeecgboot-vue3/src/views/xslmes/mesXslFormulaSpec/components/MesXslFormulaSpecModal.vue
jeecgboot-vue3/src/views/xslmes/mesXslFormulaSpec/components/MesXslFormulaLineColumnSetting.vue
-- author:cursor---date:20260521--for: 【配合示方】审批进度编制人展示真实姓名 ---
jeecgboot-vue3/src/views/xslmes/mesXslFormulaSpec/MesXslFormulaSpec.data.ts
jeecgboot-vue3/src/views/xslmes/mesXslFormulaSpec/components/MesXslFormulaSpecModal.vue
jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/entity/MesXslFormulaSpec.java
jeecg-boot-module/jeecg-module-xslmes/src/main/java/org/jeecg/modules/xslmes/service/impl/MesXslFormulaSpecServiceImpl.java
-- author:cursor---date:20260521--for: 【配合示方】编辑页A胶TOTAL PHR缺失时按明细补算回显 ---
jeecgboot-vue3/src/views/xslmes/mesXslFormulaSpec/components/MesXslFormulaSpecModal.vue
-- author:cursor---date:20260521--for: 【配合示方】编辑打开时基本资料闪清修复 ---
jeecgboot-vue3/src/views/xslmes/mesXslFormulaSpec/components/MesXslFormulaSpecModal.vue

View File

@@ -0,0 +1,208 @@
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 jakarta.servlet.http.HttpServletResponse;
import java.util.Arrays;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import lombok.extern.slf4j.Slf4j;
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.common.util.oConvertUtils;
import org.jeecg.modules.xslmes.entity.MesXslFormulaSpec;
import org.jeecg.modules.xslmes.entity.MesXslFormulaSpecLine;
import org.jeecg.modules.xslmes.service.IMesXslFormulaSpecService;
import org.jeecg.modules.xslmes.service.IMesXslFormulaSpecSettingService;
import org.jeecg.modules.xslmes.vo.MesXslFormulaRubberContentSettingVO;
import org.jeecg.modules.xslmes.vo.MesXslFormulaSpecPage;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
/**
* MES 配合示方
*/
@Tag(name = "MES配合示方")
@RestController
@RequestMapping("/xslmes/mesXslFormulaSpec")
@Slf4j
public class MesXslFormulaSpecController extends JeecgController<MesXslFormulaSpec, IMesXslFormulaSpecService> {
@Autowired
private IMesXslFormulaSpecService mesXslFormulaSpecService;
@Autowired
private IMesXslFormulaSpecSettingService mesXslFormulaSpecSettingService;
@Operation(summary = "MES配合示方-分页列表查询")
@GetMapping(value = "/list")
public Result<IPage<MesXslFormulaSpec>> queryPageList(
MesXslFormulaSpec model,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
@RequestParam(name = "keyword", required = false) String keyword,
HttpServletRequest req) {
QueryWrapper<MesXslFormulaSpec> queryWrapper = QueryGenerator.initQueryWrapper(model, req.getParameterMap());
if (oConvertUtils.isNotEmpty(keyword)) {
queryWrapper.and(
w -> w.like("spec_code", keyword)
.or()
.like("rubber_code", keyword)
.or()
.like("issue_number", keyword)
.or()
.like("purpose", keyword));
}
queryWrapper.orderByDesc("update_time").orderByDesc("create_time");
Page<MesXslFormulaSpec> page = new Page<>(pageNo, pageSize);
IPage<MesXslFormulaSpec> pageList = mesXslFormulaSpecService.page(page, queryWrapper);
return Result.OK(pageList);
}
@AutoLog(value = "MES配合示方-添加")
@Operation(summary = "MES配合示方-添加")
@RequiresPermissions("xslmes:mes_xsl_formula_spec:add")
@PostMapping(value = "/add")
public Result<String> add(@RequestBody MesXslFormulaSpecPage page) {
//update-begin---author:jiangxh ---date:20260521 for【配合示方】主子表保存校验-----------
String err = validateMain(page);
if (err != null) {
return Result.error(err);
}
//update-end---author:jiangxh ---date:20260521 for【配合示方】主子表保存校验-----------
MesXslFormulaSpec main = new MesXslFormulaSpec();
BeanUtils.copyProperties(page, main);
mesXslFormulaSpecService.saveMain(main, page.getLineList());
return Result.OK("添加成功!");
}
@AutoLog(value = "MES配合示方-编辑")
@Operation(summary = "MES配合示方-编辑")
@RequiresPermissions("xslmes:mes_xsl_formula_spec:edit")
@RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST})
public Result<String> edit(@RequestBody MesXslFormulaSpecPage page) {
//update-begin---author:jiangxh ---date:20260521 for【配合示方】主子表保存校验-----------
String err = validateMain(page);
if (err != null) {
return Result.error(err);
}
//update-end---author:jiangxh ---date:20260521 for【配合示方】主子表保存校验-----------
MesXslFormulaSpec main = new MesXslFormulaSpec();
BeanUtils.copyProperties(page, main);
mesXslFormulaSpecService.updateMain(main, page.getLineList());
return Result.OK("编辑成功!");
}
@AutoLog(value = "MES配合示方-删除")
@Operation(summary = "MES配合示方-通过id删除")
@RequiresPermissions("xslmes:mes_xsl_formula_spec:delete")
@DeleteMapping(value = "/delete")
public Result<String> delete(@RequestParam(name = "id", required = true) String id) {
mesXslFormulaSpecService.delMain(id);
return Result.OK("删除成功!");
}
@AutoLog(value = "MES配合示方-批量删除")
@Operation(summary = "MES配合示方-批量删除")
@RequiresPermissions("xslmes:mes_xsl_formula_spec:deleteBatch")
@DeleteMapping(value = "/deleteBatch")
public Result<String> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
mesXslFormulaSpecService.delBatchMain(Arrays.asList(ids.split(",")));
return Result.OK("批量删除成功!");
}
@Operation(summary = "MES配合示方-通过id查询")
@GetMapping(value = "/queryById")
public Result<MesXslFormulaSpec> queryById(@RequestParam(name = "id", required = true) String id) {
MesXslFormulaSpec entity = mesXslFormulaSpecService.getByIdWithLines(id);
if (entity == null) {
return Result.error("未找到对应数据");
}
return Result.OK(entity);
}
@Operation(summary = "MES配合示方-查询明细")
@GetMapping(value = "/queryLineListByMainId")
public Result<List<MesXslFormulaSpecLine>> queryLineListByMainId(@RequestParam(name = "id", required = true) String id) {
return Result.OK(mesXslFormulaSpecService.selectLinesByMainId(id));
}
//update-begin---author:cursor ---date:20260521 for配合示方胶料代号自动生成-----------
@Operation(summary = "MES配合示方-生成胶料代号")
@GetMapping(value = "/generateRubberCode")
public Result<Map<String, String>> generateRubberCode(
@RequestParam(name = "rubberMaterialId") String rubberMaterialId,
@RequestParam(name = "category") String category,
@RequestParam(name = "excludeSpecId", required = false) String excludeSpecId) {
try {
String rubberCode = mesXslFormulaSpecService.generateRubberCode(rubberMaterialId, category, excludeSpecId);
return Result.OK(Map.of("rubberCode", rubberCode));
} catch (IllegalArgumentException ex) {
return Result.error(ex.getMessage());
}
}
//update-end---author:cursor ---date:20260521 for配合示方胶料代号自动生成-----------
//update-begin---author:cursor ---date:20260521 for【配合示方】含胶率物料小类可配置-----------
@Operation(summary = "MES配合示方-查询含胶率物料小类配置")
@GetMapping(value = "/getRubberContentSetting")
public Result<MesXslFormulaRubberContentSettingVO> getRubberContentSetting() {
return Result.OK(mesXslFormulaSpecSettingService.getRubberContentSetting());
}
@AutoLog(value = "MES配合示方-保存含胶率物料小类配置")
@Operation(summary = "MES配合示方-保存含胶率物料小类配置")
@RequiresPermissions("xslmes:mes_xsl_formula_spec:edit")
@PostMapping(value = "/saveRubberContentSetting")
public Result<String> saveRubberContentSetting(@RequestBody MesXslFormulaRubberContentSettingVO setting) {
mesXslFormulaSpecSettingService.saveRubberContentSetting(setting);
return Result.OK("保存成功");
}
//update-end---author:cursor ---date:20260521 for【配合示方】含胶率物料小类可配置-----------
@RequiresPermissions("xslmes:mes_xsl_formula_spec:exportXls")
@RequestMapping(value = "/exportXls")
public ModelAndView exportXls(HttpServletRequest request, MesXslFormulaSpec model) {
return super.exportXls(request, model, MesXslFormulaSpec.class, "配合示方");
}
@RequiresPermissions("xslmes:mes_xsl_formula_spec:importExcel")
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
return super.importExcel(request, response, MesXslFormulaSpec.class);
}
//update-begin---author:jiangxh ---date:20260521 for【配合示方】主子表保存校验-----------
private String validateMain(MesXslFormulaSpecPage page) {
if (oConvertUtils.isEmpty(page.getSpecCode())) {
return "请输入示方编号";
}
if (oConvertUtils.isEmpty(page.getRubberCode())) {
return "请选择胶料并生成胶料代号";
}
if (oConvertUtils.isEmpty(page.getRubberMaterialId())) {
return "请选择胶料信息";
}
if (page.getMixingStages() != null && (page.getMixingStages() < 1 || page.getMixingStages() > 7)) {
return "混合段数必须在1-7之间";
}
if (page.getLineList() == null || page.getLineList().isEmpty()) {
return "请至少添加一行配合明细";
}
return null;
}
//update-end---author:jiangxh ---date:20260521 for【配合示方】主子表保存校验-----------
}

View File

@@ -0,0 +1,220 @@
package org.jeecg.modules.xslmes.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
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.math.BigDecimal;
import java.util.Date;
import java.util.List;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.jeecg.common.aspect.annotation.Dict;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.springframework.format.annotation.DateTimeFormat;
/**
* MES 配合示方
*/
@Data
@TableName("mes_xsl_formula_spec")
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
@Schema(description = "MES配合示方")
public class MesXslFormulaSpec implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(type = IdType.ASSIGN_ID)
private String id;
@Excel(name = "分类", width = 10, dicCode = "xslmes_formula_spec_category")
@Dict(dicCode = "xslmes_formula_spec_category")
@Schema(description = "分类")
private String category;
@Excel(name = "示方编号", width = 18)
@Schema(description = "示方编号")
private String specCode;
@Excel(name = "胶料代号", width = 18)
@Schema(description = "胶料代号")
private String rubberCode;
@Schema(description = "胶料ID关联mes_material.id")
private String rubberMaterialId;
@Excel(name = "基本配合", width = 15)
@Schema(description = "基本配合")
private String basicFormula;
@Excel(name = "发行日期", width = 15, format = "yyyy-MM-dd")
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
@DateTimeFormat(pattern = "yyyy-MM-dd")
@Schema(description = "发行日期")
private Date issueDate;
@Excel(name = "用途", width = 20)
@Schema(description = "用途")
private String purpose;
@Excel(name = "发行编号", width = 15)
@Schema(description = "发行编号")
private String issueNumber;
@Excel(name = "混合段数", width = 10)
@Schema(description = "混合段数")
private Integer mixingStages;
@Excel(name = "混合机器", width = 15)
@Schema(description = "混合机器")
private String mixingMachine;
@Schema(description = "发行部门ID")
private String issueDeptId;
@Excel(name = "发行部门", width = 15)
@Schema(description = "发行部门名称")
private String issueDeptName;
@Excel(name = "A胶TOTAL PHR", width = 14)
@Schema(description = "A胶TOTAL PHR")
private BigDecimal aRubberTotalPhr;
@Excel(name = "TOTAL PHR", width = 12)
@Schema(description = "TOTAL PHR")
private BigDecimal totalPhr;
//update-begin---author:jiangxh ---date:20260521 for【配合示方】主表新增混合段1-7合计字段-----------
@Excel(name = "混合段1合计", width = 12)
@Schema(description = "混合段1合计")
private BigDecimal stage1Total;
@Excel(name = "混合段2合计", width = 12)
@Schema(description = "混合段2合计")
private BigDecimal stage2Total;
@Excel(name = "混合段3合计", width = 12)
@Schema(description = "混合段3合计")
private BigDecimal stage3Total;
@Excel(name = "混合段4合计", width = 12)
@Schema(description = "混合段4合计")
private BigDecimal stage4Total;
@Excel(name = "混合段5合计", width = 12)
@Schema(description = "混合段5合计")
private BigDecimal stage5Total;
@Excel(name = "混合段6合计", width = 12)
@Schema(description = "混合段6合计")
private BigDecimal stage6Total;
@Excel(name = "混合段7合计", width = 12)
@Schema(description = "混合段7合计")
private BigDecimal stage7Total;
//update-end---author:jiangxh ---date:20260521 for【配合示方】主表新增混合段1-7合计字段-----------
@Excel(name = "发行理由", width = 30)
@Schema(description = "发行理由")
private String issueReason;
@Excel(name = "天然橡胶", width = 12)
@Schema(description = "天然橡胶")
private BigDecimal naturalRubber;
@Excel(name = "合成橡胶", width = 12)
@Schema(description = "合成橡胶")
private BigDecimal syntheticRubber;
@Excel(name = "合计", width = 12)
@Schema(description = "合计")
private BigDecimal totalAmount;
@Excel(name = "重量单价", width = 12)
@Schema(description = "重量单价")
private BigDecimal weightUnitPrice;
@Excel(name = "体积单价", width = 12)
@Schema(description = "体积单价")
private BigDecimal volumeUnitPrice;
@Excel(name = "Q胶比重", width = 12)
@Schema(description = "Q胶比重")
@TableField("q_rubber_sg")
private BigDecimal qRubberSg;
@Excel(name = "A胶比重", width = 12)
@Schema(description = "A胶比重")
@TableField("a_rubber_sg")
private BigDecimal aRubberSg;
@Excel(name = "人工配料", width = 10, replace = {"是_1", "否_0"})
@Schema(description = "是否有人工配料0否 1是")
private Integer hasManualBatch;
@Excel(name = "状态", width = 12, dicCode = "xslmes_formula_spec_status")
@Dict(dicCode = "xslmes_formula_spec_status")
@Schema(description = "状态")
private String status;
@Excel(name = "校对人", width = 12)
@Schema(description = "校对人")
private String proofreadBy;
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Schema(description = "校对时间")
private Date proofreadTime;
@Excel(name = "审核人", width = 12)
@Schema(description = "审核人")
private String auditBy;
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Schema(description = "审核时间")
private Date auditTime;
@Excel(name = "批准人", width = 12)
@Schema(description = "批准人")
private String approveBy;
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Schema(description = "批准时间")
private Date approveTime;
@Excel(name = "创建人", width = 12, dictTable = "sys_user", dicText = "realname", dicCode = "username")
@Dict(dictTable = "sys_user", dicText = "realname", dicCode = "username")
private String createBy;
/** queryById 等非分页接口补充创建人姓名DictAspect 仅翻译分页列表) */
@TableField(exist = false)
@Schema(description = "创建人姓名")
private String createBy_dictText;
@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;
@Schema(description = "租户ID")
private Integer tenantId;
private String sysOrgCode;
private Integer delFlag;
@TableField(exist = false)
@Schema(description = "配合明细")
private List<MesXslFormulaSpecLine> lineList;
}

View File

@@ -0,0 +1,105 @@
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.math.BigDecimal;
import java.util.Date;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.jeecg.common.aspect.annotation.Dict;
import org.springframework.format.annotation.DateTimeFormat;
/**
* MES 配合示方明细
*/
@Data
@TableName("mes_xsl_formula_spec_line")
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
@Schema(description = "MES配合示方明细")
public class MesXslFormulaSpecLine implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(type = IdType.ASSIGN_ID)
private String id;
@Schema(description = "配合示方主表ID")
private String formulaSpecId;
@Schema(description = "行序号")
private Integer sortNo;
@Schema(description = "PHR")
private BigDecimal phr;
@Schema(description = "密炼物料ID")
private String mixerMaterialId;
@Schema(description = "密炼物料编码")
private String mixerMaterialCode;
@Schema(description = "密炼物料名称")
private String mixerMaterialName;
@Schema(description = "物料描述")
private String materialDesc;
@Dict(dicCode = "xslmes_formula_spec_step")
@Schema(description = "STEP")
private String step;
@Dict(dicCode = "xslmes_formula_spec_weigh_mode")
@Schema(description = "称量方式")
private String weighMode;
@Schema(description = "重量%")
private BigDecimal weightPercent;
@Schema(description = "体积")
private BigDecimal volume;
@Schema(description = "备注")
private String remark;
@Schema(description = "混合段1")
private BigDecimal stage1;
@Schema(description = "混合段2")
private BigDecimal stage2;
@Schema(description = "混合段3")
private BigDecimal stage3;
@Schema(description = "混合段4")
private BigDecimal stage4;
@Schema(description = "混合段5")
private BigDecimal stage5;
@Schema(description = "混合段6")
private BigDecimal stage6;
@Schema(description = "混合段7")
private BigDecimal stage7;
@Schema(description = "租户ID")
private Integer tenantId;
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;
}

View File

@@ -0,0 +1,48 @@
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.springframework.format.annotation.DateTimeFormat;
/**
* 配合示方模块配置
*/
@Data
@TableName("mes_xsl_formula_spec_setting")
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
@Schema(description = "配合示方模块配置")
public class MesXslFormulaSpecSetting implements Serializable {
private static final long serialVersionUID = 1L;
public static final String DEFAULT_ID = "1993000000000000991";
@TableId(type = IdType.ASSIGN_ID)
private String id;
@Schema(description = "天然橡胶物料小类ID逗号分隔")
private String naturalMinorCategoryIds;
@Schema(description = "合成橡胶物料小类ID逗号分隔")
private String syntheticMinorCategoryIds;
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;
}

View File

@@ -0,0 +1,6 @@
package org.jeecg.modules.xslmes.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.jeecg.modules.xslmes.entity.MesXslFormulaSpecLine;
public interface MesXslFormulaSpecLineMapper extends BaseMapper<MesXslFormulaSpecLine> {}

View File

@@ -0,0 +1,6 @@
package org.jeecg.modules.xslmes.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.jeecg.modules.xslmes.entity.MesXslFormulaSpec;
public interface MesXslFormulaSpecMapper extends BaseMapper<MesXslFormulaSpec> {}

View File

@@ -0,0 +1,7 @@
package org.jeecg.modules.xslmes.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.jeecg.modules.xslmes.entity.MesXslFormulaSpecSetting;
public interface MesXslFormulaSpecSettingMapper extends BaseMapper<MesXslFormulaSpecSetting> {
}

View File

@@ -0,0 +1,28 @@
package org.jeecg.modules.xslmes.service;
import com.baomidou.mybatisplus.extension.service.IService;
import java.io.Serializable;
import java.util.Collection;
import java.util.List;
import org.jeecg.modules.xslmes.entity.MesXslFormulaSpec;
import org.jeecg.modules.xslmes.entity.MesXslFormulaSpecLine;
public interface IMesXslFormulaSpecService extends IService<MesXslFormulaSpec> {
void saveMain(MesXslFormulaSpec main, List<MesXslFormulaSpecLine> lineList);
void updateMain(MesXslFormulaSpec main, List<MesXslFormulaSpecLine> lineList);
void delMain(String id);
void delBatchMain(Collection<? extends Serializable> idList);
List<MesXslFormulaSpecLine> selectLinesByMainId(String mainId);
MesXslFormulaSpec getByIdWithLines(String id);
/**
* 生成胶料代号D + 胶料名称 + 分类键值(S/P/T/C) + 版本号(A01-Z01)
*/
String generateRubberCode(String rubberMaterialId, String category, String excludeSpecId);
}

View File

@@ -0,0 +1,17 @@
package org.jeecg.modules.xslmes.service;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.Set;
import org.jeecg.modules.xslmes.entity.MesXslFormulaSpecSetting;
import org.jeecg.modules.xslmes.vo.MesXslFormulaRubberContentSettingVO;
public interface IMesXslFormulaSpecSettingService extends IService<MesXslFormulaSpecSetting> {
MesXslFormulaRubberContentSettingVO getRubberContentSetting();
void saveRubberContentSetting(MesXslFormulaRubberContentSettingVO setting);
Set<String> getNaturalMinorCategoryIds();
Set<String> getSyntheticMinorCategoryIds();
}

View File

@@ -0,0 +1,403 @@
package org.jeecg.modules.xslmes.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import jakarta.annotation.Resource;
import java.io.Serializable;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.commons.lang3.StringUtils;
import org.jeecg.modules.mes.material.entity.MesMaterial;
import org.jeecg.modules.mes.material.entity.MesMixerMaterial;
import org.jeecg.modules.mes.material.service.IMesMaterialService;
import org.jeecg.modules.mes.material.service.IMesMixerMaterialService;
import org.jeecg.modules.xslmes.entity.MesXslFormulaSpec;
import org.jeecg.modules.xslmes.entity.MesXslFormulaSpecLine;
import org.jeecg.modules.xslmes.mapper.MesXslFormulaSpecLineMapper;
import org.jeecg.modules.xslmes.mapper.MesXslFormulaSpecMapper;
import org.jeecg.modules.xslmes.service.IMesXslFormulaSpecService;
import org.jeecg.modules.xslmes.service.IMesXslFormulaSpecSettingService;
import org.jeecg.modules.system.entity.SysUser;
import org.jeecg.modules.system.service.ISysUserService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
@Service
public class MesXslFormulaSpecServiceImpl extends ServiceImpl<MesXslFormulaSpecMapper, MesXslFormulaSpec>
implements IMesXslFormulaSpecService {
private static final Set<String> RUBBER_CATEGORY_KEYS = Set.of("S", "P", "T", "C");
private static final Pattern RUBBER_CODE_VERSION_PATTERN = Pattern.compile("([A-Z])01$");
@Resource
private MesXslFormulaSpecLineMapper lineMapper;
@Resource
private IMesMixerMaterialService mesMixerMaterialService;
@Resource
private IMesMaterialService mesMaterialService;
@Resource
private IMesXslFormulaSpecSettingService mesXslFormulaSpecSettingService;
@Resource
private ISysUserService sysUserService;
@Override
@Transactional(rollbackFor = Exception.class)
public void saveMain(MesXslFormulaSpec main, List<MesXslFormulaSpecLine> lineList) {
fillMainDefaults(main);
//update-begin---author:cursor ---date:20260521 for配合示方新增时服务端生成胶料代号-----------
fillRubberCodeOnCreate(main);
//update-end---author:cursor ---date:20260521 for配合示方新增时服务端生成胶料代号-----------
this.save(main);
insertLines(main, lineList);
refreshMainSummary(main.getId());
}
@Override
@Transactional(rollbackFor = Exception.class)
public void updateMain(MesXslFormulaSpec main, List<MesXslFormulaSpecLine> lineList) {
fillMainDefaults(main);
this.updateById(main);
lineMapper.delete(new LambdaQueryWrapper<MesXslFormulaSpecLine>().eq(MesXslFormulaSpecLine::getFormulaSpecId, main.getId()));
insertLines(main, lineList);
refreshMainSummary(main.getId());
}
@Override
@Transactional(rollbackFor = Exception.class)
public void delMain(String id) {
lineMapper.delete(new LambdaQueryWrapper<MesXslFormulaSpecLine>().eq(MesXslFormulaSpecLine::getFormulaSpecId, id));
this.removeById(id);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void delBatchMain(Collection<? extends Serializable> idList) {
if (idList == null || idList.isEmpty()) {
return;
}
for (Serializable id : idList) {
if (id != null) {
delMain(id.toString());
}
}
}
@Override
public List<MesXslFormulaSpecLine> selectLinesByMainId(String mainId) {
return lineMapper.selectList(
new LambdaQueryWrapper<MesXslFormulaSpecLine>()
.eq(MesXslFormulaSpecLine::getFormulaSpecId, mainId)
.orderByAsc(MesXslFormulaSpecLine::getSortNo)
.orderByAsc(MesXslFormulaSpecLine::getId));
}
@Override
public MesXslFormulaSpec getByIdWithLines(String id) {
MesXslFormulaSpec main = this.getById(id);
if (main == null) {
return null;
}
main.setLineList(selectLinesByMainId(id));
//update-begin---author:cursor ---date:20260521 for【配合示方】queryById补充创建人姓名供审批进度展示-----------
fillCreateByDictText(main);
//update-end---author:cursor ---date:20260521 for【配合示方】queryById补充创建人姓名供审批进度展示-----------
return main;
}
private void fillCreateByDictText(MesXslFormulaSpec main) {
if (main == null || StringUtils.isBlank(main.getCreateBy())) {
return;
}
SysUser user = sysUserService.getUserByName(main.getCreateBy());
if (user != null && StringUtils.isNotBlank(user.getRealname())) {
main.setCreateBy_dictText(user.getRealname());
}
}
//update-begin---author:cursor ---date:20260521 for配合示方胶料代号自动生成 D+胶料名称+分类+版本号-----------
@Override
public String generateRubberCode(String rubberMaterialId, String category, String excludeSpecId) {
if (StringUtils.isBlank(rubberMaterialId)) {
throw new IllegalArgumentException("请选择胶料信息");
}
if (StringUtils.isBlank(category) || !RUBBER_CATEGORY_KEYS.contains(category)) {
throw new IllegalArgumentException("请选择有效的示方分类");
}
MesMaterial material = mesMaterialService.getById(rubberMaterialId);
if (material == null || StringUtils.isBlank(material.getMaterialName())) {
throw new IllegalArgumentException("所选胶料不存在或未维护胶料名称");
}
String basePrefix = buildRubberCodePrefix(material.getMaterialName(), category);
Set<Character> usedLetters = loadUsedRubberCodeLetters(rubberMaterialId, category, basePrefix, excludeSpecId);
for (char letter = 'A'; letter <= 'Z'; letter++) {
if (!usedLetters.contains(letter)) {
return basePrefix + letter + "01";
}
}
throw new IllegalArgumentException("该胶料在当前分类下的代号版本已用尽(A01-Z01)");
}
private void fillRubberCodeOnCreate(MesXslFormulaSpec main) {
if (StringUtils.isBlank(main.getRubberMaterialId()) || StringUtils.isBlank(main.getCategory())) {
return;
}
main.setRubberCode(generateRubberCode(main.getRubberMaterialId(), main.getCategory(), null));
main.setSpecCode(main.getRubberCode());
}
private String buildRubberCodePrefix(String materialName, String category) {
return "D" + materialName.trim() + category;
}
private Set<Character> loadUsedRubberCodeLetters(
String rubberMaterialId, String category, String basePrefix, String excludeSpecId) {
LambdaQueryWrapper<MesXslFormulaSpec> queryWrapper = new LambdaQueryWrapper<MesXslFormulaSpec>()
.eq(MesXslFormulaSpec::getRubberMaterialId, rubberMaterialId)
.eq(MesXslFormulaSpec::getCategory, category)
.likeRight(MesXslFormulaSpec::getRubberCode, basePrefix);
if (StringUtils.isNotBlank(excludeSpecId)) {
queryWrapper.ne(MesXslFormulaSpec::getId, excludeSpecId);
}
List<MesXslFormulaSpec> existingList = this.list(queryWrapper);
Set<Character> usedLetters = new HashSet<>();
for (MesXslFormulaSpec item : existingList) {
if (item == null || StringUtils.isBlank(item.getRubberCode())) {
continue;
}
if (!item.getRubberCode().startsWith(basePrefix) || item.getRubberCode().length() <= basePrefix.length()) {
continue;
}
String suffix = item.getRubberCode().substring(basePrefix.length());
Matcher matcher = RUBBER_CODE_VERSION_PATTERN.matcher(suffix);
if (matcher.matches()) {
usedLetters.add(matcher.group(1).charAt(0));
}
}
return usedLetters;
}
//update-end---author:cursor ---date:20260521 for配合示方胶料代号自动生成 D+胶料名称+分类+版本号-----------
private void fillMainDefaults(MesXslFormulaSpec main) {
if (StringUtils.isBlank(main.getCategory())) {
//update-begin---author:cursor ---date:20260521 for配合示方分类字典默认值改为 S-----------
main.setCategory("S");
//update-end---author:cursor ---date:20260521 for配合示方分类字典默认值改为 S-----------
}
if (StringUtils.isBlank(main.getStatus())) {
main.setStatus("compile");
}
if (main.getHasManualBatch() == null) {
main.setHasManualBatch(0);
}
}
private void insertLines(MesXslFormulaSpec main, List<MesXslFormulaSpecLine> lineList) {
if (CollectionUtils.isEmpty(lineList)) {
return;
}
Date now = new Date();
int sort = 0;
//update-begin---author:cursor ---date:20260521 for配合示方明细重量%按PHR/总PHR自动计算-----------
BigDecimal totalPhr = BigDecimal.ZERO;
for (MesXslFormulaSpecLine line : lineList) {
if (line == null || StringUtils.isBlank(line.getMixerMaterialId()) || line.getPhr() == null) {
continue;
}
totalPhr = totalPhr.add(line.getPhr());
}
if (main.getTotalPhr() == null) {
main.setTotalPhr(totalPhr);
}
BigDecimal weightBase = main.getTotalPhr() != null && main.getTotalPhr().compareTo(BigDecimal.ZERO) > 0
? main.getTotalPhr()
: totalPhr;
//update-end---author:cursor ---date:20260521 for配合示方明细重量%按PHR/总PHR自动计算-----------
boolean hasManual = false;
for (MesXslFormulaSpecLine line : lineList) {
if (line == null || StringUtils.isBlank(line.getMixerMaterialId())) {
continue;
}
line.setId(null);
line.setFormulaSpecId(main.getId());
line.setSortNo(sort++);
fillMaterialInfo(line);
fillVolumeIfBlank(line);
//update-begin---author:cursor ---date:20260521 for配合示方明细重量%按PHR/总PHR自动计算-----------
fillWeightPercent(line, weightBase);
//update-end---author:cursor ---date:20260521 for配合示方明细重量%按PHR/总PHR自动计算-----------
if (line.getCreateTime() == null) {
line.setCreateTime(now);
}
if (line.getUpdateTime() == null) {
line.setUpdateTime(now);
}
if ("manual".equals(line.getWeighMode())) {
hasManual = true;
}
lineMapper.insert(line);
}
if (main.getTotalPhr() == null) {
main.setTotalPhr(totalPhr);
}
if (main.getHasManualBatch() == null || main.getHasManualBatch() == 0) {
main.setHasManualBatch(hasManual ? 1 : 0);
}
}
private void fillMaterialInfo(MesXslFormulaSpecLine line) {
MesMixerMaterial material = mesMixerMaterialService.getById(line.getMixerMaterialId());
if (material == null) {
return;
}
line.setMixerMaterialCode(material.getMaterialCode());
line.setMixerMaterialName(material.getMaterialName());
if (StringUtils.isBlank(line.getMaterialDesc())) {
line.setMaterialDesc(StringUtils.defaultIfBlank(material.getMaterialDesc(), material.getMaterialName()));
}
}
private void fillVolumeIfBlank(MesXslFormulaSpecLine line) {
if (line.getVolume() != null || line.getPhr() == null || StringUtils.isBlank(line.getMixerMaterialId())) {
return;
}
MesMixerMaterial material = mesMixerMaterialService.getById(line.getMixerMaterialId());
if (material == null || material.getSpecificGravity() == null || material.getSpecificGravity().compareTo(BigDecimal.ZERO) <= 0) {
return;
}
line.setVolume(line.getPhr().divide(material.getSpecificGravity(), 6, RoundingMode.HALF_UP));
}
private void fillWeightPercent(MesXslFormulaSpecLine line, BigDecimal totalPhr) {
//update-begin---author:cursor ---date:20260521 for配合示方明细重量%按PHR/总PHR自动计算可手工覆盖-----------
if (line.getWeightPercent() != null || line.getPhr() == null || totalPhr == null || totalPhr.compareTo(BigDecimal.ZERO) <= 0) {
return;
}
line.setWeightPercent(line.getPhr().multiply(BigDecimal.valueOf(100)).divide(totalPhr, 4, RoundingMode.HALF_UP));
//update-end---author:cursor ---date:20260521 for配合示方明细重量%按PHR/总PHR自动计算可手工覆盖-----------
}
//update-begin---author:cursor ---date:20260521 for【配合示方】保存后汇总A/Q胶比重写入数据库-----------
/** 根据明细重新汇总主表 TOTAL PHR、A胶TOTAL PHR、比重与人工配料标记 */
private void refreshMainSummary(String mainId) {
List<MesXslFormulaSpecLine> lines = selectLinesByMainId(mainId);
if (CollectionUtils.isEmpty(lines)) {
return;
}
BigDecimal totalPhr = BigDecimal.ZERO;
BigDecimal aRubberPhr = BigDecimal.ZERO;
BigDecimal aRubberVolume = BigDecimal.ZERO;
BigDecimal qRubberPhr = BigDecimal.ZERO;
BigDecimal qRubberVolume = BigDecimal.ZERO;
BigDecimal naturalRubber = BigDecimal.ZERO;
BigDecimal syntheticRubber = BigDecimal.ZERO;
boolean hasManual = false;
Map<String, MesMixerMaterial> materialCache = new HashMap<>();
Set<String> naturalCategoryIds = mesXslFormulaSpecSettingService.getNaturalMinorCategoryIds();
Set<String> syntheticCategoryIds = mesXslFormulaSpecSettingService.getSyntheticMinorCategoryIds();
for (MesXslFormulaSpecLine line : lines) {
if (line == null) {
continue;
}
if (line.getPhr() != null) {
totalPhr = totalPhr.add(line.getPhr());
if ("A".equals(line.getStep())) {
aRubberPhr = aRubberPhr.add(line.getPhr());
} else if ("Q".equals(line.getStep())) {
qRubberPhr = qRubberPhr.add(line.getPhr());
}
}
if ("manual".equals(line.getWeighMode())) {
hasManual = true;
}
BigDecimal volume = resolveLineVolume(line);
if (volume == null) {
continue;
}
if ("A".equals(line.getStep())) {
aRubberVolume = aRubberVolume.add(volume);
} else if ("Q".equals(line.getStep())) {
qRubberVolume = qRubberVolume.add(volume);
}
//update-begin---author:cursor ---date:20260521 for【配合示方】含胶率按密炼物料小类汇总重量%-----------
if (line.getWeightPercent() != null && StringUtils.isNotBlank(line.getMixerMaterialId())) {
MesMixerMaterial mixerMaterial = materialCache.computeIfAbsent(
line.getMixerMaterialId(), mesMixerMaterialService::getById);
if (mixerMaterial != null && StringUtils.isNotBlank(mixerMaterial.getMinorCategoryId())) {
String minorCategoryId = mixerMaterial.getMinorCategoryId();
if (!naturalCategoryIds.isEmpty() && naturalCategoryIds.contains(minorCategoryId)) {
naturalRubber = naturalRubber.add(line.getWeightPercent());
} else if (!syntheticCategoryIds.isEmpty() && syntheticCategoryIds.contains(minorCategoryId)) {
syntheticRubber = syntheticRubber.add(line.getWeightPercent());
}
}
}
//update-end---author:cursor ---date:20260521 for【配合示方】含胶率按密炼物料小类汇总重量%-----------
}
//update-begin---author:cursor ---date:20260521 for【配合示方】STEP全为A/Q时对应胶比重清零并写库-----------
BigDecimal aRubberSg = aRubberVolume.compareTo(BigDecimal.ZERO) > 0
? aRubberPhr.divide(aRubberVolume, 6, RoundingMode.HALF_UP)
: null;
BigDecimal qRubberSg = qRubberVolume.compareTo(BigDecimal.ZERO) > 0
? qRubberPhr.divide(qRubberVolume, 6, RoundingMode.HALF_UP)
: null;
BigDecimal aRubberTotalPhr = aRubberPhr.compareTo(BigDecimal.ZERO) > 0 ? aRubberPhr : null;
BigDecimal naturalRubberValue = naturalRubber.compareTo(BigDecimal.ZERO) > 0
? naturalRubber.setScale(4, RoundingMode.HALF_UP)
: null;
BigDecimal syntheticRubberValue = syntheticRubber.compareTo(BigDecimal.ZERO) > 0
? syntheticRubber.setScale(4, RoundingMode.HALF_UP)
: null;
BigDecimal totalAmount = null;
if (naturalRubberValue != null || syntheticRubberValue != null) {
totalAmount = (naturalRubberValue != null ? naturalRubberValue : BigDecimal.ZERO)
.add(syntheticRubberValue != null ? syntheticRubberValue : BigDecimal.ZERO)
.setScale(4, RoundingMode.HALF_UP);
}
LambdaUpdateWrapper<MesXslFormulaSpec> updateWrapper = new LambdaUpdateWrapper<MesXslFormulaSpec>()
.eq(MesXslFormulaSpec::getId, mainId)
.set(MesXslFormulaSpec::getTotalPhr, totalPhr)
.set(MesXslFormulaSpec::getHasManualBatch, hasManual ? 1 : 0)
.set(MesXslFormulaSpec::getARubberTotalPhr, aRubberTotalPhr)
.set(MesXslFormulaSpec::getARubberSg, aRubberSg)
.set(MesXslFormulaSpec::getQRubberSg, qRubberSg)
.set(MesXslFormulaSpec::getNaturalRubber, naturalRubberValue)
.set(MesXslFormulaSpec::getSyntheticRubber, syntheticRubberValue)
.set(MesXslFormulaSpec::getTotalAmount, totalAmount);
this.update(updateWrapper);
//update-end---author:cursor ---date:20260521 for【配合示方】STEP全为A/Q时对应胶比重清零并写库-----------
}
/** 优先取明细已保存体积,缺失时按 PHR/物料比重补算 */
private BigDecimal resolveLineVolume(MesXslFormulaSpecLine line) {
if (line == null) {
return null;
}
if (line.getVolume() != null && line.getVolume().compareTo(BigDecimal.ZERO) > 0) {
return line.getVolume();
}
if (line.getPhr() == null || StringUtils.isBlank(line.getMixerMaterialId())) {
return null;
}
MesMixerMaterial material = mesMixerMaterialService.getById(line.getMixerMaterialId());
if (material == null || material.getSpecificGravity() == null || material.getSpecificGravity().compareTo(BigDecimal.ZERO) <= 0) {
return null;
}
return line.getPhr().divide(material.getSpecificGravity(), 6, RoundingMode.HALF_UP);
}
//update-end---author:cursor ---date:20260521 for【配合示方】保存后汇总A/Q胶比重写入数据库-----------
}

View File

@@ -0,0 +1,104 @@
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.Arrays;
import java.util.Collections;
import java.util.Date;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import org.apache.commons.lang3.StringUtils;
import org.jeecg.modules.system.entity.SysCategory;
import org.jeecg.modules.system.service.ISysCategoryService;
import org.jeecg.modules.xslmes.entity.MesXslFormulaSpecSetting;
import org.jeecg.modules.xslmes.mapper.MesXslFormulaSpecSettingMapper;
import org.jeecg.modules.xslmes.service.IMesXslFormulaSpecSettingService;
import org.jeecg.modules.xslmes.vo.MesXslFormulaRubberContentSettingVO;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@Service
public class MesXslFormulaSpecSettingServiceImpl extends ServiceImpl<MesXslFormulaSpecSettingMapper, MesXslFormulaSpecSetting>
implements IMesXslFormulaSpecSettingService {
private static final String DEFAULT_NATURAL_CATEGORY_CODE = "XSLMES_MATERIAL_RAW_AUX_TRJ";
private static final String DEFAULT_SYNTHETIC_CATEGORY_CODE = "XSLMES_MATERIAL_RAW_AUX_HCJ";
private final ISysCategoryService sysCategoryService;
public MesXslFormulaSpecSettingServiceImpl(ISysCategoryService sysCategoryService) {
this.sysCategoryService = sysCategoryService;
}
@Override
public MesXslFormulaRubberContentSettingVO getRubberContentSetting() {
MesXslFormulaSpecSetting setting = loadOrInitSetting();
MesXslFormulaRubberContentSettingVO vo = new MesXslFormulaRubberContentSettingVO();
vo.setNaturalMinorCategoryIds(parseIdList(setting.getNaturalMinorCategoryIds()));
vo.setSyntheticMinorCategoryIds(parseIdList(setting.getSyntheticMinorCategoryIds()));
return vo;
}
@Override
@Transactional(rollbackFor = Exception.class)
public void saveRubberContentSetting(MesXslFormulaRubberContentSettingVO settingVo) {
MesXslFormulaSpecSetting setting = loadOrInitSetting();
setting.setNaturalMinorCategoryIds(joinIdList(settingVo != null ? settingVo.getNaturalMinorCategoryIds() : null));
setting.setSyntheticMinorCategoryIds(joinIdList(settingVo != null ? settingVo.getSyntheticMinorCategoryIds() : null));
setting.setUpdateTime(new Date());
this.updateById(setting);
}
@Override
public Set<String> getNaturalMinorCategoryIds() {
return new LinkedHashSet<>(parseIdList(loadOrInitSetting().getNaturalMinorCategoryIds()));
}
@Override
public Set<String> getSyntheticMinorCategoryIds() {
return new LinkedHashSet<>(parseIdList(loadOrInitSetting().getSyntheticMinorCategoryIds()));
}
private MesXslFormulaSpecSetting loadOrInitSetting() {
MesXslFormulaSpecSetting setting = this.getById(MesXslFormulaSpecSetting.DEFAULT_ID);
if (setting != null) {
return setting;
}
setting = new MesXslFormulaSpecSetting();
setting.setId(MesXslFormulaSpecSetting.DEFAULT_ID);
setting.setNaturalMinorCategoryIds(resolveCategoryIdByCode(DEFAULT_NATURAL_CATEGORY_CODE));
setting.setSyntheticMinorCategoryIds(resolveCategoryIdByCode(DEFAULT_SYNTHETIC_CATEGORY_CODE));
setting.setCreateTime(new Date());
this.save(setting);
return setting;
}
private String resolveCategoryIdByCode(String categoryCode) {
if (StringUtils.isBlank(categoryCode)) {
return null;
}
SysCategory category = sysCategoryService.getOne(
new LambdaQueryWrapper<SysCategory>().eq(SysCategory::getCode, categoryCode).last("LIMIT 1"));
return category != null ? category.getId() : null;
}
private List<String> parseIdList(String raw) {
if (StringUtils.isBlank(raw)) {
return Collections.emptyList();
}
return Arrays.stream(raw.split(","))
.map(String::trim)
.filter(StringUtils::isNotBlank)
.distinct()
.collect(Collectors.toList());
}
private String joinIdList(List<String> ids) {
if (ids == null || ids.isEmpty()) {
return null;
}
return ids.stream().filter(StringUtils::isNotBlank).map(String::trim).distinct().collect(Collectors.joining(","));
}
}

View File

@@ -0,0 +1,22 @@
package org.jeecg.modules.xslmes.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import lombok.Data;
/**
* 配合示方含胶率物料小类配置
*/
@Data
@Schema(description = "配合示方含胶率物料小类配置")
public class MesXslFormulaRubberContentSettingVO implements Serializable {
private static final long serialVersionUID = 1L;
@Schema(description = "天然橡胶物料小类ID列表")
private List<String> naturalMinorCategoryIds = new ArrayList<>();
@Schema(description = "合成橡胶物料小类ID列表")
private List<String> syntheticMinorCategoryIds = new ArrayList<>();
}

View File

@@ -0,0 +1,10 @@
package org.jeecg.modules.xslmes.vo;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.jeecg.modules.xslmes.entity.MesXslFormulaSpec;
/** 配合示方主子保存 VO */
@Data
@EqualsAndHashCode(callSuper = true)
public class MesXslFormulaSpecPage extends MesXslFormulaSpec {}

View File

@@ -0,0 +1,186 @@
-- 配合示方分类/STEP/称量方式/状态字典 + /子表 + 菜单 MES技术管理+ admin 授权
SET NAMES utf8mb4;
INSERT IGNORE INTO `sys_dict` (`id`, `dict_name`, `dict_code`, `description`, `del_flag`, `create_by`, `create_time`, `type`, `tenant_id`)
VALUES ('1995000000000000010', '配合示方分类', 'xslmes_formula_spec_category', 'MES配合示方分类', 0, 'admin', NOW(), 0, 1002);
INSERT IGNORE INTO `sys_dict_item` (`id`, `dict_id`, `item_text`, `item_value`, `sort_order`, `status`, `create_by`, `create_time`)
VALUES ('1995000000000001001', '1995000000000000010', '标准', 'standard', 1, 1, 'admin', NOW());
INSERT IGNORE INTO `sys_dict_item` (`id`, `dict_id`, `item_text`, `item_value`, `sort_order`, `status`, `create_by`, `create_time`)
VALUES ('1995000000000001002', '1995000000000000010', '临时', 'temporary', 2, 1, 'admin', NOW());
INSERT IGNORE INTO `sys_dict_item` (`id`, `dict_id`, `item_text`, `item_value`, `sort_order`, `status`, `create_by`, `create_time`)
VALUES ('1995000000000001003', '1995000000000000010', '实验', 'trial', 3, 1, 'admin', NOW());
INSERT IGNORE INTO `sys_dict_item` (`id`, `dict_id`, `item_text`, `item_value`, `sort_order`, `status`, `create_by`, `create_time`)
VALUES ('1995000000000001004', '1995000000000000010', '消费', 'consumption', 4, 1, 'admin', NOW());
INSERT IGNORE INTO `sys_dict` (`id`, `dict_name`, `dict_code`, `description`, `del_flag`, `create_by`, `create_time`, `type`, `tenant_id`)
VALUES ('1995000000000000011', '配合示方STEP', 'xslmes_formula_spec_step', 'MES配合示方STEP', 0, 'admin', NOW(), 0, 1002);
INSERT IGNORE INTO `sys_dict_item` (`id`, `dict_id`, `item_text`, `item_value`, `sort_order`, `status`, `create_by`, `create_time`)
VALUES ('1995000000000001011', '1995000000000000011', 'A', 'A', 1, 1, 'admin', NOW());
INSERT IGNORE INTO `sys_dict_item` (`id`, `dict_id`, `item_text`, `item_value`, `sort_order`, `status`, `create_by`, `create_time`)
VALUES ('1995000000000001012', '1995000000000000011', 'B', 'B', 2, 1, 'admin', NOW());
INSERT IGNORE INTO `sys_dict_item` (`id`, `dict_id`, `item_text`, `item_value`, `sort_order`, `status`, `create_by`, `create_time`)
VALUES ('1995000000000001013', '1995000000000000011', 'Q', 'Q', 3, 1, 'admin', NOW());
INSERT IGNORE INTO `sys_dict` (`id`, `dict_name`, `dict_code`, `description`, `del_flag`, `create_by`, `create_time`, `type`, `tenant_id`)
VALUES ('1995000000000000012', '配合示方称量方式', 'xslmes_formula_spec_weigh_mode', 'MES配合示方自动/人工称量', 0, 'admin', NOW(), 0, 1002);
INSERT IGNORE INTO `sys_dict_item` (`id`, `dict_id`, `item_text`, `item_value`, `sort_order`, `status`, `create_by`, `create_time`)
VALUES ('1995000000000001021', '1995000000000000012', '自动称量1', 'auto1', 1, 1, 'admin', NOW());
INSERT IGNORE INTO `sys_dict_item` (`id`, `dict_id`, `item_text`, `item_value`, `sort_order`, `status`, `create_by`, `create_time`)
VALUES ('1995000000000001022', '1995000000000000012', '人工称量', 'manual', 2, 1, 'admin', NOW());
INSERT IGNORE INTO `sys_dict` (`id`, `dict_name`, `dict_code`, `description`, `del_flag`, `create_by`, `create_time`, `type`, `tenant_id`)
VALUES ('1995000000000000013', '配合示方状态', 'xslmes_formula_spec_status', 'MES配合示方状态', 0, 'admin', NOW(), 0, 1002);
INSERT IGNORE INTO `sys_dict_item` (`id`, `dict_id`, `item_text`, `item_value`, `sort_order`, `status`, `create_by`, `create_time`)
VALUES ('1995000000000001031', '1995000000000000013', '编制', 'compile', 1, 1, 'admin', NOW());
INSERT IGNORE INTO `sys_dict_item` (`id`, `dict_id`, `item_text`, `item_value`, `sort_order`, `status`, `create_by`, `create_time`)
VALUES ('1995000000000001032', '1995000000000000013', '校对', 'proofread', 2, 1, 'admin', NOW());
INSERT IGNORE INTO `sys_dict_item` (`id`, `dict_id`, `item_text`, `item_value`, `sort_order`, `status`, `create_by`, `create_time`)
VALUES ('1995000000000001033', '1995000000000000013', '审核', 'audit', 3, 1, 'admin', NOW());
INSERT IGNORE INTO `sys_dict_item` (`id`, `dict_id`, `item_text`, `item_value`, `sort_order`, `status`, `create_by`, `create_time`)
VALUES ('1995000000000001034', '1995000000000000013', '批准', 'approve', 4, 1, 'admin', NOW());
INSERT IGNORE INTO `sys_dict_item` (`id`, `dict_id`, `item_text`, `item_value`, `sort_order`, `status`, `create_by`, `create_time`)
VALUES ('1995000000000001035', '1995000000000000013', '正式发布', 'released', 5, 1, 'admin', NOW());
INSERT IGNORE INTO `sys_dict_item` (`id`, `dict_id`, `item_text`, `item_value`, `sort_order`, `status`, `create_by`, `create_time`)
VALUES ('1995000000000001036', '1995000000000000013', '作废', 'obsolete', 6, 1, 'admin', NOW());
CREATE TABLE IF NOT EXISTS `mes_xsl_formula_spec` (
`id` varchar(32) NOT NULL COMMENT '主键',
`category` varchar(32) DEFAULT 'standard' COMMENT '分类字典xslmes_formula_spec_categorystandard标准 temporary临时 trial实验 consumption消费',
`spec_code` varchar(100) DEFAULT NULL COMMENT '示方编号',
`rubber_code` varchar(100) DEFAULT NULL COMMENT '胶料代号',
`basic_formula` varchar(100) DEFAULT NULL COMMENT '基本配合',
`issue_date` date DEFAULT NULL COMMENT '发行日期',
`purpose` varchar(500) DEFAULT NULL COMMENT '用途',
`issue_number` varchar(100) DEFAULT NULL COMMENT '发行编号',
`mixing_stages` int DEFAULT NULL COMMENT '混合段数1-7',
`mixing_machine` varchar(200) DEFAULT NULL COMMENT '混合机器',
`issue_dept_id` varchar(32) DEFAULT NULL COMMENT '发行部门ID',
`issue_dept_name` varchar(200) DEFAULT NULL COMMENT '发行部门名称冗余',
`a_rubber_total_phr` decimal(18,4) DEFAULT NULL COMMENT 'A胶TOTAL PHR',
`total_phr` decimal(18,4) DEFAULT NULL COMMENT 'TOTAL PHR',
`issue_reason` text COMMENT '发行理由',
`natural_rubber` decimal(18,4) DEFAULT NULL COMMENT '天然橡胶',
`synthetic_rubber` decimal(18,4) DEFAULT NULL COMMENT '合成橡胶',
`total_amount` decimal(18,4) DEFAULT NULL COMMENT '合计',
`weight_unit_price` decimal(18,4) DEFAULT NULL COMMENT '重量单价',
`volume_unit_price` decimal(18,4) DEFAULT NULL COMMENT '体积单价',
`q_rubber_sg` decimal(18,6) DEFAULT NULL COMMENT 'Q胶比重',
`a_rubber_sg` decimal(18,6) DEFAULT NULL COMMENT 'A胶比重',
`has_manual_batch` int DEFAULT 0 COMMENT '是否有人工配料0否 1是',
`status` varchar(32) DEFAULT 'compile' COMMENT '状态字典xslmes_formula_spec_status',
`proofread_by` varchar(50) DEFAULT NULL COMMENT '校对人',
`proofread_time` datetime DEFAULT NULL COMMENT '校对时间',
`audit_by` varchar(50) DEFAULT NULL COMMENT '审核人',
`audit_time` datetime DEFAULT NULL COMMENT '审核时间',
`approve_by` varchar(50) DEFAULT NULL COMMENT '批准人',
`approve_time` datetime DEFAULT NULL COMMENT '批准时间',
`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` int NOT NULL DEFAULT 0 COMMENT '逻辑删除0正常 1已删除',
PRIMARY KEY (`id`),
KEY `idx_mxfs_spec_code` (`spec_code`),
KEY `idx_mxfs_rubber_code` (`rubber_code`),
KEY `idx_mxfs_issue_number` (`issue_number`),
KEY `idx_mxfs_category` (`category`),
KEY `idx_mxfs_status` (`status`),
KEY `idx_mxfs_issue_date` (`issue_date`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='MES配合示方';
CREATE TABLE IF NOT EXISTS `mes_xsl_formula_spec_line` (
`id` varchar(32) NOT NULL COMMENT '主键',
`formula_spec_id` varchar(32) NOT NULL COMMENT '配合示方主表ID',
`sort_no` int DEFAULT NULL COMMENT '行序号',
`phr` decimal(18,4) DEFAULT NULL COMMENT 'PHR',
`mixer_material_id` varchar(32) DEFAULT NULL COMMENT '密炼物料ID',
`mixer_material_code` varchar(100) DEFAULT NULL COMMENT '密炼物料编码冗余',
`mixer_material_name` varchar(200) DEFAULT NULL COMMENT '密炼物料名称冗余',
`material_desc` varchar(500) DEFAULT NULL COMMENT '物料描述',
`step` varchar(8) DEFAULT NULL COMMENT 'STEP字典xslmes_formula_spec_stepA/B/Q',
`weigh_mode` varchar(32) DEFAULT NULL COMMENT '称量方式字典xslmes_formula_spec_weigh_mode',
`weight_percent` decimal(18,4) DEFAULT NULL COMMENT '重量%',
`volume` decimal(18,6) DEFAULT NULL COMMENT '体积',
`remark` varchar(500) DEFAULT NULL COMMENT '备注',
`stage1` decimal(18,4) DEFAULT NULL COMMENT '混合段1',
`stage2` decimal(18,4) DEFAULT NULL COMMENT '混合段2',
`stage3` decimal(18,4) DEFAULT NULL COMMENT '混合段3',
`stage4` decimal(18,4) DEFAULT NULL COMMENT '混合段4',
`stage5` decimal(18,4) DEFAULT NULL COMMENT '混合段5',
`stage6` decimal(18,4) DEFAULT NULL COMMENT '混合段6',
`stage7` decimal(18,4) DEFAULT NULL COMMENT '混合段7',
`tenant_id` int DEFAULT NULL COMMENT '租户ID',
`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 '修改时间',
PRIMARY KEY (`id`),
KEY `idx_mxfsl_formula_spec_id` (`formula_spec_id`),
KEY `idx_mxfsl_mixer_material_id` (`mixer_material_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='MES配合示方明细';
UPDATE `sys_permission`
SET `is_leaf` = 0, `update_time` = NOW()
WHERE `id` = '1900000000000000810' AND `is_leaf` = 1;
INSERT IGNORE 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`
) VALUES (
'177925970995530', '1900000000000000810', '配合示方', '/xslmes/mesXslFormulaSpec',
'xslmes/mesXslFormulaSpec/MesXslFormulaSpecList', 1, 'MesXslFormulaSpecList', NULL,
1, NULL, '0', 1.00, 0, 'ant-design:experiment-outlined', 0, 1,
0, 0, 'MES配合示方', 'admin', NOW(), 'admin', NOW(),
0, 0, '1', 0
);
INSERT IGNORE INTO `sys_permission` (`id`, `parent_id`, `name`, `menu_type`, `perms`, `perms_type`, `sort_no`, `is_route`, `is_leaf`, `hidden`, `status`, `del_flag`, `create_by`, `create_time`)
VALUES ('177925970995531', '177925970995530', '新增', 2, 'xslmes:mes_xsl_formula_spec:add', '1', 1.00, 0, 1, 0, '1', 0, 'admin', NOW());
INSERT IGNORE INTO `sys_permission` (`id`, `parent_id`, `name`, `menu_type`, `perms`, `perms_type`, `sort_no`, `is_route`, `is_leaf`, `hidden`, `status`, `del_flag`, `create_by`, `create_time`)
VALUES ('177925970995532', '177925970995530', '编辑', 2, 'xslmes:mes_xsl_formula_spec:edit', '1', 2.00, 0, 1, 0, '1', 0, 'admin', NOW());
INSERT IGNORE INTO `sys_permission` (`id`, `parent_id`, `name`, `menu_type`, `perms`, `perms_type`, `sort_no`, `is_route`, `is_leaf`, `hidden`, `status`, `del_flag`, `create_by`, `create_time`)
VALUES ('177925970995533', '177925970995530', '删除', 2, 'xslmes:mes_xsl_formula_spec:delete', '1', 3.00, 0, 1, 0, '1', 0, 'admin', NOW());
INSERT IGNORE INTO `sys_permission` (`id`, `parent_id`, `name`, `menu_type`, `perms`, `perms_type`, `sort_no`, `is_route`, `is_leaf`, `hidden`, `status`, `del_flag`, `create_by`, `create_time`)
VALUES ('177925970995534', '177925970995530', '批量删除', 2, 'xslmes:mes_xsl_formula_spec:deleteBatch', '1', 4.00, 0, 1, 0, '1', 0, 'admin', NOW());
INSERT IGNORE INTO `sys_permission` (`id`, `parent_id`, `name`, `menu_type`, `perms`, `perms_type`, `sort_no`, `is_route`, `is_leaf`, `hidden`, `status`, `del_flag`, `create_by`, `create_time`)
VALUES ('177925970995535', '177925970995530', '导出', 2, 'xslmes:mes_xsl_formula_spec:exportXls', '1', 5.00, 0, 1, 0, '1', 0, 'admin', NOW());
INSERT IGNORE INTO `sys_permission` (`id`, `parent_id`, `name`, `menu_type`, `perms`, `perms_type`, `sort_no`, `is_route`, `is_leaf`, `hidden`, `status`, `del_flag`, `create_by`, `create_time`)
VALUES ('177925970995536', '177925970995530', '导入', 2, 'xslmes:mes_xsl_formula_spec:importExcel', '1', 6.00, 0, 1, 0, '1', 0, 'admin', NOW());
INSERT INTO `sys_role_permission` (`id`, `role_id`, `permission_id`, `data_rule_ids`, `operate_date`, `operate_ip`)
SELECT REPLACE(UUID(), '-', ''), r.id, p.id, NULL, NOW(), '127.0.0.1'
FROM `sys_role` r
CROSS JOIN `sys_permission` p
WHERE r.`role_code` = 'admin'
AND p.`id` IN (
'177925970995530', '177925970995531', '177925970995532',
'177925970995533', '177925970995534', '177925970995535', '177925970995536'
)
AND NOT EXISTS (
SELECT 1 FROM `sys_role_permission` rp
WHERE rp.`role_id` = r.id AND rp.`permission_id` = p.id
);

View File

@@ -0,0 +1,9 @@
-- 配合示方主表新增混合段1-7合计字段
ALTER TABLE `mes_xsl_formula_spec`
ADD COLUMN `stage1_total` decimal(18,4) DEFAULT NULL COMMENT '混合段1合计' AFTER `total_phr`,
ADD COLUMN `stage2_total` decimal(18,4) DEFAULT NULL COMMENT '混合段2合计' AFTER `stage1_total`,
ADD COLUMN `stage3_total` decimal(18,4) DEFAULT NULL COMMENT '混合段3合计' AFTER `stage2_total`,
ADD COLUMN `stage4_total` decimal(18,4) DEFAULT NULL COMMENT '混合段4合计' AFTER `stage3_total`,
ADD COLUMN `stage5_total` decimal(18,4) DEFAULT NULL COMMENT '混合段5合计' AFTER `stage4_total`,
ADD COLUMN `stage6_total` decimal(18,4) DEFAULT NULL COMMENT '混合段6合计' AFTER `stage5_total`,
ADD COLUMN `stage7_total` decimal(18,4) DEFAULT NULL COMMENT '混合段7合计' AFTER `stage6_total`;

View File

@@ -0,0 +1,15 @@
-- 配合示方分类字典标准示方 S / 临时示方 P / 试验示方 T / 消费示方 C
SET NAMES utf8mb4;
UPDATE `sys_dict_item` SET `item_text` = '标准示方', `item_value` = 'S' WHERE `id` = '1995000000000001001';
UPDATE `sys_dict_item` SET `item_text` = '临时示方', `item_value` = 'P' WHERE `id` = '1995000000000001002';
UPDATE `sys_dict_item` SET `item_text` = '试验示方', `item_value` = 'T' WHERE `id` = '1995000000000001003';
UPDATE `sys_dict_item` SET `item_text` = '消费示方', `item_value` = 'C' WHERE `id` = '1995000000000001004';
UPDATE `mes_xsl_formula_spec` SET `category` = 'S' WHERE `category` = 'standard';
UPDATE `mes_xsl_formula_spec` SET `category` = 'P' WHERE `category` = 'temporary';
UPDATE `mes_xsl_formula_spec` SET `category` = 'T' WHERE `category` = 'trial';
UPDATE `mes_xsl_formula_spec` SET `category` = 'C' WHERE `category` = 'consumption';
ALTER TABLE `mes_xsl_formula_spec`
MODIFY COLUMN `category` varchar(32) DEFAULT 'S' COMMENT '分类字典xslmes_formula_spec_categoryS标准示方 P临时示方 T试验示方 C消费示方';

View File

@@ -0,0 +1,7 @@
-- 配合示方关联胶料主数据支持胶料代号自动生成
SET NAMES utf8mb4;
ALTER TABLE `mes_xsl_formula_spec`
ADD COLUMN `rubber_material_id` varchar(32) DEFAULT NULL COMMENT '胶料ID关联mes_material.id' AFTER `rubber_code`;
CREATE INDEX `idx_mxfs_rubber_material_id` ON `mes_xsl_formula_spec` (`rubber_material_id`);

View File

@@ -0,0 +1,10 @@
-- 配合示方 STEP 字典删除字典值 B
SET NAMES utf8mb4;
-- 已有业务数据若使用 B清空以便重新选择
UPDATE `mes_xsl_formula_spec_line` SET `step` = NULL WHERE `step` = 'B';
DELETE FROM `sys_dict_item` WHERE `id` = '1995000000000001012';
ALTER TABLE `mes_xsl_formula_spec_line`
MODIFY COLUMN `step` varchar(8) DEFAULT NULL COMMENT 'STEP字典xslmes_formula_spec_stepA/Q';

View File

@@ -0,0 +1,20 @@
-- 配合示方含胶率物料小类配置天然橡胶 / 合成橡胶
DROP TABLE IF EXISTS `mes_xsl_formula_spec_setting`;
CREATE TABLE `mes_xsl_formula_spec_setting` (
`id` varchar(32) NOT NULL COMMENT '主键',
`natural_minor_category_ids` varchar(2000) DEFAULT NULL COMMENT '天然橡胶物料小类ID逗号分隔',
`synthetic_minor_category_ids` varchar(2000) DEFAULT NULL COMMENT '合成橡胶物料小类ID逗号分隔',
`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 '更新时间',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='配合示方模块配置';
INSERT INTO `mes_xsl_formula_spec_setting` (`id`, `natural_minor_category_ids`, `synthetic_minor_category_ids`, `create_time`)
SELECT
'1993000000000000991',
(SELECT `id` FROM `sys_category` WHERE `code` = 'XSLMES_MATERIAL_RAW_AUX_TRJ' LIMIT 1),
(SELECT `id` FROM `sys_category` WHERE `code` = 'XSLMES_MATERIAL_RAW_AUX_HCJ' LIMIT 1),
NOW()
WHERE NOT EXISTS (SELECT 1 FROM `mes_xsl_formula_spec_setting` WHERE `id` = '1993000000000000991');

View File

@@ -9,11 +9,13 @@ enum Api {
deleteBatch = '/mes/material/material/deleteBatch',
importExcel = '/mes/material/material/importExcel',
exportXls = '/mes/material/material/exportXls',
queryById = '/mes/material/material/queryById',
}
export const getExportUrl = Api.exportXls;
export const getImportUrl = Api.importExcel;
export const list = (params) => defHttp.get({ url: Api.list, params });
export const queryById = (params) => defHttp.get({ url: Api.queryById, params }, { successMessageMode: 'none' });
export const deleteOne = (params, handleSuccess) =>
defHttp.delete({ url: Api.deleteOne, params }, { joinParamsToUrl: true }).then(() => handleSuccess());

View File

@@ -0,0 +1,90 @@
<template>
<BasicModal v-bind="$attrs" title="选择胶料" :width="960" @register="registerModal" @ok="handleOk">
<BasicTable @register="registerTable" />
</BasicModal>
</template>
<script lang="ts" setup>
import { ref } from 'vue';
import { BasicModal, useModalInner } from '/@/components/Modal';
import { BasicTable, useTable } from '/@/components/Table';
import { list as materialList, queryById as queryMaterialById } from '../MesMaterial.api';
import { columns as materialColumns, searchFormSchema as materialSearch } from '../MesMaterial.data';
import { useMessage } from '/@/hooks/web/useMessage';
const emit = defineEmits(['register', 'select']);
const { createMessage } = useMessage();
const selectedRow = ref<Recordable | null>(null);
const [registerTable, { reload, getSelectRowKeys, getSelectRows, setSelectedRowKeys, clearSelectedRowKeys }] = useTable({
api: materialList,
columns: materialColumns.slice(0, 6),
rowKey: 'id',
useSearchForm: true,
formConfig: {
labelWidth: 90,
schemas: materialSearch,
},
pagination: { pageSize: 10 },
canResize: false,
showIndexColumn: false,
immediate: true,
beforeFetch: (params) => ({
...params,
enableFlag: params.enableFlag ?? 1,
}),
rowSelection: {
type: 'radio',
columnWidth: 48,
onChange: (_keys, rows) => {
selectedRow.value = rows?.[0] ?? null;
},
},
clickToRowSelect: true,
});
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
selectedRow.value = null;
clearSelectedRowKeys?.();
setModalProps({ confirmLoading: false });
const materialId = data?.materialId as string | undefined;
if (materialId) {
setSelectedRowKeys?.([materialId]);
try {
const raw = await queryMaterialById({ id: materialId });
const row = (raw as Recordable)?.materialName != null ? raw : (raw as Recordable)?.result;
if (row) {
selectedRow.value = row;
}
} catch {
// ignore
}
}
reload();
});
async function handleOk() {
const keys = (getSelectRowKeys?.() || []) as string[];
let row = selectedRow.value || ((getSelectRows?.() || []) as Recordable[])[0];
if (!row && keys.length) {
try {
const raw = await queryMaterialById({ id: keys[0] });
row = (raw as Recordable)?.materialName != null ? raw : (raw as Recordable)?.result;
} catch {
// ignore
}
}
if (!row?.id) {
createMessage.warning('请选择一条胶料信息');
return;
}
emit('select', {
materialId: row.id,
materialName: row.materialName || '',
aliasName: row.aliasName || '',
materialCode: row.materialCode || '',
});
closeModal();
}
</script>

View File

@@ -85,8 +85,12 @@
emit('select', {
mixerMaterialId: row.id,
materialName: row.materialName || '',
materialCode: row.materialCode || '',
materialDesc: row.materialDesc || '',
materialKind: buildKind(row),
minorCategoryId: row.minorCategoryId || '',
majorCategoryText: row.majorCategoryId_dictText || '',
minorCategoryText: row.minorCategoryId_dictText || '',
});
closeModal();
}

View File

@@ -0,0 +1,43 @@
import { defHttp } from '/@/utils/http/axios';
import { Modal } from 'ant-design-vue';
enum Api {
list = '/xslmes/mesXslFormulaSpec/list',
save = '/xslmes/mesXslFormulaSpec/add',
edit = '/xslmes/mesXslFormulaSpec/edit',
deleteOne = '/xslmes/mesXslFormulaSpec/delete',
deleteBatch = '/xslmes/mesXslFormulaSpec/deleteBatch',
importExcel = '/xslmes/mesXslFormulaSpec/importExcel',
exportXls = '/xslmes/mesXslFormulaSpec/exportXls',
queryById = '/xslmes/mesXslFormulaSpec/queryById',
queryLineList = '/xslmes/mesXslFormulaSpec/queryLineListByMainId',
generateRubberCode = '/xslmes/mesXslFormulaSpec/generateRubberCode',
getRubberContentSetting = '/xslmes/mesXslFormulaSpec/getRubberContentSetting',
saveRubberContentSetting = '/xslmes/mesXslFormulaSpec/saveRubberContentSetting',
}
export const getExportUrl = Api.exportXls;
export const getImportUrl = Api.importExcel;
export const list = (params) => defHttp.get({ url: Api.list, params });
export const queryById = (params) => defHttp.get({ url: Api.queryById, params });
export const queryLineListByMainId = (params) => defHttp.get({ url: Api.queryLineList, params });
export const generateRubberCode = (params) =>
defHttp.get({ url: Api.generateRubberCode, params }, { successMessageMode: 'none' });
export const getRubberContentSetting = () => defHttp.get({ url: Api.getRubberContentSetting });
export const saveRubberContentSetting = (params) => defHttp.post({ url: Api.saveRubberContentSetting, params });
export const deleteOne = (params, handleSuccess) =>
defHttp.delete({ url: Api.deleteOne, params }, { joinParamsToUrl: true }).then(() => handleSuccess());
export const batchDelete = (params, handleSuccess) => {
Modal.confirm({
title: '确认删除',
content: '是否删除选中数据',
okText: '确认',
cancelText: '取消',
onOk: () =>
defHttp.delete({ url: Api.deleteBatch, data: params }, { joinParamsToUrl: true }).then(() => handleSuccess()),
});
};
export const saveOrUpdate = (params, isUpdate) => defHttp.post({ url: isUpdate ? Api.edit : Api.save, params });

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,168 @@
<template>
<div>
<BasicTable @register="registerTable" :rowSelection="rowSelection">
<template #tableTitle>
<a-button type="primary" v-auth="'xslmes:mes_xsl_formula_spec:add'" @click="handleAdd" preIcon="ant-design:plus-outlined">
新增
</a-button>
<a-button
type="primary"
v-auth="'xslmes:mes_xsl_formula_spec:exportXls'"
preIcon="ant-design:export-outlined"
@click="onExportXls"
>
导出
</a-button>
<j-upload-button
type="primary"
v-auth="'xslmes:mes_xsl_formula_spec:importExcel'"
preIcon="ant-design:import-outlined"
@click="onImportXls"
>
导入
</j-upload-button>
<a-dropdown v-if="selectedRowKeys.length > 0">
<template #overlay>
<a-menu>
<a-menu-item key="1" @click="batchHandleDelete">
<Icon icon="ant-design:delete-outlined" />
删除
</a-menu-item>
</a-menu>
</template>
<a-button v-auth="'xslmes:mes_xsl_formula_spec:deleteBatch'">
批量操作
<Icon icon="mdi:chevron-down" />
</a-button>
</a-dropdown>
<super-query :config="superQueryConfig" @search="handleSuperQuery" />
</template>
<template #action="{ record }">
<TableAction :actions="getTableActions(record)" :dropDownActions="getDropDownAction(record)" />
</template>
</BasicTable>
<MesXslFormulaSpecModal @register="registerModal" @success="handleSuccess" />
</div>
</template>
<script lang="ts" name="xslmes-mesXslFormulaSpec" setup>
import { reactive } from 'vue';
import { BasicTable, TableAction } from '/@/components/Table';
import { useModal } from '/@/components/Modal';
import { useListPage } from '/@/hooks/system/useListPage';
import Icon from '/@/components/Icon';
import MesXslFormulaSpecModal from './components/MesXslFormulaSpecModal.vue';
import { columns, searchFormSchema, superQuerySchema } from './MesXslFormulaSpec.data';
import { list, deleteOne, batchDelete, getExportUrl, getImportUrl } from './MesXslFormulaSpec.api';
const queryParam = reactive<any>({});
const [registerModal, { openModal }] = useModal();
const { tableContext, onExportXls, onImportXls } = useListPage({
tableProps: {
title: '配合示方',
api: list,
columns,
canResize: true,
formConfig: {
schemas: searchFormSchema,
labelWidth: 90,
autoSubmitOnEnter: true,
showAdvancedButton: true,
},
actionColumn: {
title: '操作',
dataIndex: 'action',
width: 160,
fixed: 'right',
slots: { customRender: 'action' },
},
beforeFetch: (params) => Object.assign(params, queryParam),
},
exportConfig: {
name: '配合示方',
url: getExportUrl,
params: queryParam,
},
importConfig: {
url: getImportUrl,
success: handleSuccess,
},
});
const [registerTable, { reload }, { rowSelection, selectedRowKeys }] = tableContext;
const superQueryConfig = reactive(superQuerySchema);
function handleSuperQuery(params) {
Object.keys(params).forEach((k) => {
queryParam[k] = params[k];
});
reload();
}
function handleAdd() {
openModal(true, { isUpdate: false, showFooter: true });
}
function handleEdit(record: Recordable) {
openModal(true, { record, isUpdate: true, showFooter: true });
}
function handleDetail(record: Recordable) {
openModal(true, { record, isUpdate: true, showFooter: false });
}
function handleDelete(record: Recordable) {
deleteOne({ id: record.id }, handleSuccess);
}
function batchHandleDelete() {
batchDelete({ ids: selectedRowKeys.value.join(',') }, handleSuccess);
}
function handleSuccess() {
reload();
selectedRowKeys.value = [];
}
function canEdit(record: Recordable) {
return !record?.status || record.status === 'compile';
}
function getTableActions(record: Recordable) {
return [
{
label: '编辑',
onClick: handleEdit.bind(null, record),
auth: 'xslmes:mes_xsl_formula_spec:edit',
ifShow: canEdit(record),
},
{
label: '详情',
onClick: handleDetail.bind(null, record),
ifShow: !canEdit(record),
},
];
}
function getDropDownAction(record: Recordable) {
return [
{ label: '详情', onClick: handleDetail.bind(null, record), ifShow: canEdit(record) },
{
label: '删除',
popConfirm: { title: '是否确认删除', confirm: handleDelete.bind(null, record) },
auth: 'xslmes:mes_xsl_formula_spec:delete',
ifShow: canEdit(record),
},
];
}
</script>
<style lang="less" scoped>
:deep(.ant-table) {
.ant-table-thead > tr > th {
background: #fafafa;
font-weight: 600;
}
}
</style>

View File

@@ -0,0 +1,168 @@
<template>
<Popover
v-model:open="popoverOpen"
trigger="click"
placement="bottomRight"
:overlayClassName="`${prefixCls}__popover`"
@open-change="handleOpenChange"
>
<template #title>
<div :class="`${prefixCls}__title`">
<Checkbox :indeterminate="indeterminate" :checked="checkAll" @change="onCheckAllChange">列展示</Checkbox>
</div>
</template>
<template #content>
<div :class="`${prefixCls}__list`">
<CheckboxGroup v-model:value="draftCheckedList" :options="columnOptions" />
</div>
<div :class="`${prefixCls}__footer`">
<a-button size="small" @click="handleReset">重置</a-button>
<a-button size="small" type="primary" @click="handleSave">保存</a-button>
</div>
</template>
<a-tooltip title="列设置">
<a-button size="small" class="formula-line-column-setting-btn" @click.stop>
<Icon icon="ant-design:setting-outlined" />
</a-button>
</a-tooltip>
</Popover>
</template>
<script lang="ts" setup>
import { computed, ref, type PropType } from 'vue';
import { Popover, Checkbox } from 'ant-design-vue';
import type { CheckboxChangeEvent } from 'ant-design-vue/lib/checkbox/interface';
import { Icon } from '/@/components/Icon';
import { useMessage } from '/@/hooks/web/useMessage';
import {
FORMULA_LINE_LOCKED_COLUMN_KEYS,
getFormulaLineColumnSettingItems,
saveFormulaLineHiddenColumnKeys,
type FormulaLineColumnSettingItem,
} from '../MesXslFormulaSpec.data';
const CheckboxGroup = Checkbox.Group;
const prefixCls = 'formula-line-column-setting';
const { createMessage } = useMessage();
const props = defineProps({
hiddenKeys: {
type: Array as PropType<string[]>,
default: () => [],
},
});
const emit = defineEmits<{
(e: 'update:hiddenKeys', value: string[]): void;
(e: 'change', value: string[]): void;
}>();
const popoverOpen = ref(false);
const columnItems = ref<FormulaLineColumnSettingItem[]>(getFormulaLineColumnSettingItems());
const allKeys = computed(() => columnItems.value.map((item) => item.key));
const lockableKeys = computed(() => columnItems.value.filter((item) => !item.locked).map((item) => item.key));
/** 弹窗内草稿勾选状态,保存后才应用到表格 */
const draftCheckedList = ref<string[]>([]);
const columnOptions = computed(() =>
columnItems.value.map((item) => ({
label: item.title,
value: item.key,
disabled: item.locked,
})),
);
const checkAll = computed(() => {
const keys = lockableKeys.value;
return keys.length > 0 && keys.every((key) => draftCheckedList.value.includes(key));
});
const indeterminate = computed(() => {
const keys = lockableKeys.value;
const checkedCount = keys.filter((key) => draftCheckedList.value.includes(key)).length;
return checkedCount > 0 && checkedCount < keys.length;
});
function ensureLockedChecked() {
const next = new Set(draftCheckedList.value);
FORMULA_LINE_LOCKED_COLUMN_KEYS.forEach((key) => next.add(key));
draftCheckedList.value = Array.from(next);
}
function syncDraftFromHidden(hiddenKeys: string[]) {
const hiddenSet = new Set(hiddenKeys || []);
draftCheckedList.value = allKeys.value.filter((key) => !hiddenSet.has(key));
ensureLockedChecked();
}
function buildHiddenKeysFromDraft() {
ensureLockedChecked();
return allKeys.value.filter((key) => !draftCheckedList.value.includes(key));
}
function handleOpenChange(open: boolean) {
if (open) {
syncDraftFromHidden(props.hiddenKeys);
}
}
function onCheckAllChange(e: CheckboxChangeEvent) {
draftCheckedList.value = e.target.checked ? [...allKeys.value] : [...FORMULA_LINE_LOCKED_COLUMN_KEYS];
}
function handleReset() {
draftCheckedList.value = [...allKeys.value];
}
function handleSave() {
const hiddenKeys = buildHiddenKeysFromDraft();
saveFormulaLineHiddenColumnKeys(hiddenKeys);
emit('update:hiddenKeys', hiddenKeys);
emit('change', hiddenKeys);
createMessage.success('保存成功');
popoverOpen.value = false;
}
</script>
<style lang="less" scoped>
.formula-line-column-setting-btn {
display: inline-flex;
align-items: center;
justify-content: center;
padding-inline: 8px;
}
</style>
<style lang="less">
.formula-line-column-setting__popover {
.formula-line-column-setting__title {
min-width: 180px;
}
.formula-line-column-setting__list {
max-height: 320px;
overflow-y: auto;
margin-bottom: 8px;
.ant-checkbox-group {
display: flex;
flex-direction: column;
gap: 4px;
}
.ant-checkbox-group-item {
margin-inline-start: 0;
white-space: nowrap;
}
}
.formula-line-column-setting__footer {
display: flex;
justify-content: flex-end;
gap: 8px;
padding-top: 4px;
border-top: 1px solid #f0f0f0;
}
}
</style>

View File

@@ -0,0 +1,240 @@
<template>
<BasicModal
v-bind="$attrs"
title="含胶率物料小类设置"
:width="640"
@register="registerModal"
@ok="handleSubmit"
>
<a-form layout="vertical" class="rubber-content-setting-form">
<a-form-item label="天然橡胶">
<a-select
v-model:value="formState.naturalMinorCategoryIds"
mode="multiple"
allowClear
showSearch
optionFilterProp="label"
placeholder="请选择计入天然橡胶的物料分类"
:options="minorCategoryOptions"
:loading="optionsLoading"
/>
</a-form-item>
<a-form-item label="合成橡胶">
<a-select
v-model:value="formState.syntheticMinorCategoryIds"
mode="multiple"
allowClear
showSearch
optionFilterProp="label"
placeholder="请选择计入合成橡胶的物料分类"
:options="minorCategoryOptions"
:loading="optionsLoading"
/>
</a-form-item>
<div class="setting-tip">选项来自系统分类字典MES物料分类全部节点保存后含胶率将按所选分类汇总明细行重量%</div>
</a-form>
</BasicModal>
</template>
<script lang="ts" setup>
import { reactive, ref, watch } from 'vue';
import { BasicModal, useModalInner } from '/@/components/Modal';
import { getRubberContentSetting, saveRubberContentSetting } from '../MesXslFormulaSpec.api';
import { fetchMaterialCategoryOptions } from '../MesXslFormulaSpec.data';
import { useMessage } from '/@/hooks/web/useMessage';
const emit = defineEmits(['register', 'success']);
const { createMessage } = useMessage();
const optionsLoading = ref(false);
const minorCategoryOptions = ref<Array<{ label: string; value: string }>>([]);
const formState = reactive({
naturalMinorCategoryIds: [] as string[],
syntheticMinorCategoryIds: [] as string[],
});
const [registerModal, { setModalProps, closeModal, getOpen }] = useModalInner();
watch(
() => getOpen.value,
async (open) => {
if (!open) {
return;
}
setModalProps({ confirmLoading: false });
await Promise.all([loadMinorCategoryOptions(), loadSetting()]);
},
);
async function loadMinorCategoryOptions() {
optionsLoading.value = true;
try {
minorCategoryOptions.value = await fetchMaterialCategoryOptions();
if (!minorCategoryOptions.value.length) {
createMessage.warning('未加载到 MES物料分类请先在分类字典中维护。');
}
} catch {
minorCategoryOptions.value = [];
createMessage.warning('加载 MES物料分类 失败,请检查分类字典是否已配置。');
} finally {
optionsLoading.value = false;
}
}
async function loadSetting() {
try {
const raw = await getRubberContentSetting();
const setting = (raw as Recordable)?.naturalMinorCategoryIds != null ? raw : (raw as Recordable)?.result ?? raw;
formState.naturalMinorCategoryIds = [...((setting as Recordable)?.naturalMinorCategoryIds || [])];
formState.syntheticMinorCategoryIds = [...((setting as Recordable)?.syntheticMinorCategoryIds || [])];
} catch {
formState.naturalMinorCategoryIds = [];
formState.syntheticMinorCategoryIds = [];
}
}
async function handleSubmit() {
try {
setModalProps({ confirmLoading: true });
await saveRubberContentSetting({
naturalMinorCategoryIds: formState.naturalMinorCategoryIds,
syntheticMinorCategoryIds: formState.syntheticMinorCategoryIds,
});
createMessage.success('保存成功');
closeModal();
emit('success', {
naturalMinorCategoryIds: [...formState.naturalMinorCategoryIds],
syntheticMinorCategoryIds: [...formState.syntheticMinorCategoryIds],
});
} finally {
setModalProps({ confirmLoading: false });
}
}
</script>
<style scoped lang="less">
.rubber-content-setting-form {
padding-top: 8px;
}
.setting-tip {
color: rgba(0, 0, 0, 0.45);
font-size: 12px;
line-height: 1.6;
}
</style>

View File

@@ -145,7 +145,6 @@ export const formSchema: FormSchema[] = [
component: 'Input',
componentProps: { disabled: true, bordered: false, placeholder: '保存后按创建人显示' },
colProps: colHalf,
itemProps: { class: 'ps-workflow-item' },
},
{
label: '担当',
@@ -225,7 +224,6 @@ export const formSchema: FormSchema[] = [
component: 'Input',
componentProps: { disabled: true, bordered: false },
colProps: colHalf,
itemProps: { class: 'ps-workflow-item' },
ifShow: ({ values }) => !!values.proofreadBy,
},
{
@@ -234,7 +232,6 @@ export const formSchema: FormSchema[] = [
component: 'Input',
componentProps: { disabled: true, bordered: false },
colProps: colHalf,
itemProps: { class: 'ps-workflow-item' },
ifShow: ({ values }) => !!values.proofreadTime,
},
{
@@ -243,7 +240,6 @@ export const formSchema: FormSchema[] = [
component: 'Input',
componentProps: { disabled: true, bordered: false },
colProps: colHalf,
itemProps: { class: 'ps-workflow-item' },
ifShow: ({ values }) => !!values.auditBy,
},
{
@@ -252,7 +248,6 @@ export const formSchema: FormSchema[] = [
component: 'Input',
componentProps: { disabled: true, bordered: false },
colProps: colHalf,
itemProps: { class: 'ps-workflow-item' },
ifShow: ({ values }) => !!values.auditTime,
},
{
@@ -261,7 +256,6 @@ export const formSchema: FormSchema[] = [
component: 'Input',
componentProps: { disabled: true, bordered: false },
colProps: colHalf,
itemProps: { class: 'ps-workflow-item' },
ifShow: ({ values }) => !!values.approveBy,
},
{
@@ -270,7 +264,6 @@ export const formSchema: FormSchema[] = [
component: 'Input',
componentProps: { disabled: true, bordered: false },
colProps: colHalf,
itemProps: { class: 'ps-workflow-item' },
ifShow: ({ values }) => !!values.approveTime,
},
];

View File

@@ -9,7 +9,7 @@
@ok="handleSubmit"
>
<div class="ps-compile-modal-body">
<BasicForm @register="registerForm" />
<BasicForm @register="registerForm" name="MesXslMixerPsCompileForm" />
</div>
</BasicModal>
</template>
@@ -166,7 +166,13 @@
margin-bottom: 14px;
}
:deep(.ps-workflow-item) {
:deep(#MesXslMixerPsCompileForm_compileBy),
:deep(#MesXslMixerPsCompileForm_proofreadBy),
:deep(#MesXslMixerPsCompileForm_proofreadTime),
:deep(#MesXslMixerPsCompileForm_auditBy),
:deep(#MesXslMixerPsCompileForm_auditTime),
:deep(#MesXslMixerPsCompileForm_approveBy),
:deep(#MesXslMixerPsCompileForm_approveTime) {
margin-bottom: 8px;
.ant-form-item-label > label {

View File

@@ -0,0 +1,101 @@
<template>
<BasicModal v-bind="$attrs" title="选择密炼PS" :width="960" @register="registerModal" @ok="handleOk">
<BasicTable @register="registerTable" />
</BasicModal>
</template>
<script lang="ts" setup>
import { ref } from 'vue';
import { BasicModal, useModalInner } from '/@/components/Modal';
import { BasicTable, useTable } from '/@/components/Table';
import type { FormSchema } from '/@/components/Table';
import { list as mixerPsList, queryById as queryMixerPsById } from '../MesXslMixerPsCompile.api';
import { columns as mixerPsColumns } from '../MesXslMixerPsCompile.data';
import { useMessage } from '/@/hooks/web/useMessage';
const emit = defineEmits(['register', 'select']);
const { createMessage } = useMessage();
const COMPILE_STATUS = 'compile';
const selectSearchSchema: FormSchema[] = [
{ label: 'PS编码', field: 'psCode', component: 'JInput', colProps: { span: 8 } },
{ label: '标题', field: 'title', component: 'JInput', colProps: { span: 8 } },
];
const selectedRow = ref<Recordable | null>(null);
const [registerTable, { reload, getSelectRowKeys, getSelectRows, setSelectedRowKeys, clearSelectedRowKeys }] = useTable({
api: mixerPsList,
columns: mixerPsColumns.slice(0, 7),
rowKey: 'id',
useSearchForm: true,
formConfig: {
labelWidth: 90,
schemas: selectSearchSchema,
},
pagination: { pageSize: 10 },
canResize: false,
showIndexColumn: false,
immediate: true,
beforeFetch: (params) => ({
...params,
status: COMPILE_STATUS,
}),
rowSelection: {
type: 'radio',
columnWidth: 48,
onChange: (_keys, rows) => {
selectedRow.value = rows?.[0] ?? null;
},
},
clickToRowSelect: true,
});
const [registerModal, { setModalProps, closeModal }] = useModalInner(async (data) => {
selectedRow.value = null;
clearSelectedRowKeys?.();
setModalProps({ confirmLoading: false });
const psId = data?.psCompileId as string | undefined;
if (psId) {
setSelectedRowKeys?.([psId]);
try {
const raw = await queryMixerPsById({ id: psId });
const row = (raw as Recordable)?.psCode != null ? raw : (raw as Recordable)?.result;
if (row) {
selectedRow.value = row;
}
} catch {
// ignore
}
}
reload();
});
async function handleOk() {
const keys = (getSelectRowKeys?.() || []) as string[];
let row = selectedRow.value || ((getSelectRows?.() || []) as Recordable[])[0];
if (!row && keys.length) {
try {
const raw = await queryMixerPsById({ id: keys[0] });
row = (raw as Recordable)?.psCode != null ? raw : (raw as Recordable)?.result;
} catch {
// ignore
}
}
if (!row?.id) {
createMessage.warning('请选择一条编制状态的密炼PS');
return;
}
if (row.status && row.status !== COMPILE_STATUS) {
createMessage.warning('仅可选择编制状态的密炼PS');
return;
}
emit('select', {
psCompileId: row.id,
psCode: row.psCode || '',
title: row.title || '',
});
closeModal();
}
</script>