新增物料类型处理逻辑,确保在保存和编辑称重记录时自动设置默认物料类型。更新前端表单以支持密炼物料的选择和显示,优化用户体验。添加分类字典和数据字典的事件广播功能,增强系统的实时数据同步能力。

This commit is contained in:
geht
2026-05-07 17:53:48 +08:00
parent ce9dc8efd8
commit f60a4fb203
55 changed files with 2968 additions and 375 deletions

View File

@@ -379,6 +379,7 @@ public class MesXslDesktopAnonController {
mesXslWeightRecord.getGrossWeight().subtract(mesXslWeightRecord.getTareWeight()));
}
applyWeightBillType(mesXslWeightRecord);
applyMaterialTypeDefault(mesXslWeightRecord);
weightRecordService.save(mesXslWeightRecord);
stompNotify.publishWeightRecordChanged("add", mesXslWeightRecord.getId());
return Result.OK("添加成功!");
@@ -396,6 +397,7 @@ public class MesXslDesktopAnonController {
mesXslWeightRecord.getGrossWeight().subtract(mesXslWeightRecord.getTareWeight()));
}
applyWeightBillType(mesXslWeightRecord);
applyMaterialTypeDefault(mesXslWeightRecord);
boolean ok = weightRecordService.updateById(mesXslWeightRecord);
if (!ok) {
return Result.error("数据已被他人修改,请刷新后重试");
@@ -436,6 +438,13 @@ public class MesXslDesktopAnonController {
}
}
private void applyMaterialTypeDefault(MesXslWeightRecord record) {
if (oConvertUtils.isEmpty(record.getMaterialType())) {
// 默认“自动”桌面端手动勾选时会传“2”
record.setMaterialType("1");
}
}
private void applyVehicleBelong(MesXslVehicle v) {
if (oConvertUtils.isEmpty(v.getVehicleBelong())) {
return;

View File

@@ -0,0 +1,109 @@
package org.jeecg.modules.xslmes.controller;
import java.util.Arrays;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.jeecg.common.api.vo.Result;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.modules.xslmes.entity.MesXslRawMaterialEntry;
import org.jeecg.modules.xslmes.service.IMesXslRawMaterialEntryService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.system.base.controller.JeecgController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import org.jeecg.common.aspect.annotation.AutoLog;
import org.apache.shiro.authz.annotation.RequiresPermissions;
/**
* @Description: 原料入场记录
* @Author: jeecg-boot
* @Date: 2026-05-07
* @Version: V1.0
*/
@Tag(name = "原料入场记录")
@RestController
@RequestMapping("/xslmes/mesXslRawMaterialEntry")
@Slf4j
public class MesXslRawMaterialEntryController extends JeecgController<MesXslRawMaterialEntry, IMesXslRawMaterialEntryService> {
@Autowired
private IMesXslRawMaterialEntryService mesXslRawMaterialEntryService;
@Operation(summary = "原料入场记录-分页列表查询")
@GetMapping(value = "/list")
public Result<IPage<MesXslRawMaterialEntry>> queryPageList(MesXslRawMaterialEntry mesXslRawMaterialEntry,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
HttpServletRequest req) {
QueryWrapper<MesXslRawMaterialEntry> queryWrapper = QueryGenerator.initQueryWrapper(mesXslRawMaterialEntry, req.getParameterMap());
Page<MesXslRawMaterialEntry> page = new Page<>(pageNo, pageSize);
IPage<MesXslRawMaterialEntry> pageList = mesXslRawMaterialEntryService.page(page, queryWrapper);
return Result.OK(pageList);
}
@AutoLog(value = "原料入场记录-添加")
@Operation(summary = "原料入场记录-添加")
@RequiresPermissions("xslmes:mes_xsl_raw_material_entry:add")
@PostMapping(value = "/add")
public Result<String> add(@RequestBody MesXslRawMaterialEntry mesXslRawMaterialEntry) {
mesXslRawMaterialEntryService.save(mesXslRawMaterialEntry);
return Result.OK("添加成功!");
}
@AutoLog(value = "原料入场记录-编辑")
@Operation(summary = "原料入场记录-编辑")
@RequiresPermissions("xslmes:mes_xsl_raw_material_entry:edit")
@RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST})
public Result<String> edit(@RequestBody MesXslRawMaterialEntry mesXslRawMaterialEntry) {
mesXslRawMaterialEntryService.updateById(mesXslRawMaterialEntry);
return Result.OK("编辑成功!");
}
@AutoLog(value = "原料入场记录-通过id删除")
@Operation(summary = "原料入场记录-通过id删除")
@RequiresPermissions("xslmes:mes_xsl_raw_material_entry:delete")
@DeleteMapping(value = "/delete")
public Result<String> delete(@RequestParam(name = "id", required = true) String id) {
mesXslRawMaterialEntryService.removeById(id);
return Result.OK("删除成功!");
}
@AutoLog(value = "原料入场记录-批量删除")
@Operation(summary = "原料入场记录-批量删除")
@RequiresPermissions("xslmes:mes_xsl_raw_material_entry:deleteBatch")
@DeleteMapping(value = "/deleteBatch")
public Result<String> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
this.mesXslRawMaterialEntryService.removeByIds(Arrays.asList(ids.split(",")));
return Result.OK("批量删除成功!");
}
@Operation(summary = "原料入场记录-通过id查询")
@GetMapping(value = "/queryById")
public Result<MesXslRawMaterialEntry> queryById(@RequestParam(name = "id", required = true) String id) {
MesXslRawMaterialEntry mesXslRawMaterialEntry = mesXslRawMaterialEntryService.getById(id);
if (mesXslRawMaterialEntry == null) {
return Result.error("未找到对应数据");
}
return Result.OK(mesXslRawMaterialEntry);
}
@RequiresPermissions("xslmes:mes_xsl_raw_material_entry:exportXls")
@RequestMapping(value = "/exportXls")
public ModelAndView exportXls(HttpServletRequest request, MesXslRawMaterialEntry mesXslRawMaterialEntry) {
return super.exportXls(request, mesXslRawMaterialEntry, MesXslRawMaterialEntry.class, "原料入场记录");
}
@RequiresPermissions("xslmes:mes_xsl_raw_material_entry:importExcel")
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
return super.importExcel(request, response, MesXslRawMaterialEntry.class);
}
}

View File

@@ -65,6 +65,7 @@ public class MesXslWeightRecordController extends JeecgController<MesXslWeightRe
mesXslWeightRecord.setBillNo("BDH-" + dateStr + seq);
}
computeBillType(mesXslWeightRecord);
applyMaterialTypeDefault(mesXslWeightRecord);
computeNetWeight(mesXslWeightRecord);
mesXslWeightRecordService.save(mesXslWeightRecord);
stompNotifyService.publishWeightRecordChanged("add", mesXslWeightRecord.getId());
@@ -77,6 +78,7 @@ public class MesXslWeightRecordController extends JeecgController<MesXslWeightRe
@RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST})
public Result<String> edit(@RequestBody MesXslWeightRecord mesXslWeightRecord) {
computeBillType(mesXslWeightRecord);
applyMaterialTypeDefault(mesXslWeightRecord);
computeNetWeight(mesXslWeightRecord);
mesXslWeightRecordService.updateById(mesXslWeightRecord);
stompNotifyService.publishWeightRecordChanged("edit", mesXslWeightRecord.getId());
@@ -147,4 +149,11 @@ public class MesXslWeightRecordController extends JeecgController<MesXslWeightRe
record.setBillType("3");
}
}
private void applyMaterialTypeDefault(MesXslWeightRecord record) {
if (record.getMaterialType() == null || record.getMaterialType().isBlank()) {
// 默认“自动”手动模式由前端显式传“2”
record.setMaterialType("1");
}
}
}

View File

@@ -0,0 +1,177 @@
package org.jeecg.modules.xslmes.entity;
import java.io.Serializable;
import java.util.Date;
import java.math.BigDecimal;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.springframework.format.annotation.DateTimeFormat;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.jeecg.common.aspect.annotation.Dict;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* @Description: 原料入场记录
* @Author: jeecg-boot
* @Date: 2026-05-07
* @Version: V1.0
*/
@Data
@TableName("mes_xsl_raw_material_entry")
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
@Schema(description = "原料入场记录")
public class MesXslRawMaterialEntry implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(type = IdType.ASSIGN_ID)
@Schema(description = "主键")
private String id;
@Excel(name = "条码", width = 20)
@Schema(description = "条码")
private String barcode;
@Excel(name = "批次号", width = 20)
@Schema(description = "批次号")
private String batchNo;
@Excel(name = "入场时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Schema(description = "入场时间")
private Date entryTime;
@Schema(description = "榜单ID")
private String weightRecordId;
@Excel(name = "榜单号", width = 20)
@Schema(description = "榜单号")
private String billNo;
@Schema(description = "物料ID")
private String materialId;
@Excel(name = "物料名称", width = 20)
@Schema(description = "物料名称")
private String materialName;
@Excel(name = "供料客户", width = 20)
@Schema(description = "供料客户")
private String supplyCustomer;
@Schema(description = "供应商ID")
private String supplierId;
@Excel(name = "供应商名称", width = 25)
@Schema(description = "供应商名称")
private String supplierName;
@Excel(name = "厂家物料名称", width = 25)
@Schema(description = "厂家物料名称")
private String manufacturerMaterialName;
@Excel(name = "保质期", width = 15)
@Schema(description = "保质期")
private String shelfLife;
@Excel(name = "总重(KG)", width = 12)
@Schema(description = "总重(KG)")
private BigDecimal totalWeight;
@Excel(name = "总份数", width = 10)
@Schema(description = "总份数")
private Integer totalPortions;
@Excel(name = "每份总重(KG)", width = 12)
@Schema(description = "每份总重(KG)")
private BigDecimal portionWeight;
@Excel(name = "每份包数", width = 10)
@Schema(description = "每份包数")
private Integer portionPackages;
@Excel(name = "检测结果", width = 12, dicCode = "xslmes_test_result")
@Dict(dicCode = "xslmes_test_result")
@Schema(description = "检测结果(字典 xslmes_test_result0未检 1合格 2不合格")
private String testResult;
@Excel(name = "检测状态", width = 12, dicCode = "xslmes_test_status")
@Dict(dicCode = "xslmes_test_status")
@Schema(description = "检测状态(字典 xslmes_test_status0送样 1已批准")
private String testStatus;
@Excel(name = "打印标记", width = 12, dicCode = "xslmes_print_flag")
@Dict(dicCode = "xslmes_print_flag")
@Schema(description = "打印标记(字典 xslmes_print_flag1已打印 0未打印")
private String printFlag;
@Excel(name = "入库结存", width = 10, dicCode = "yn")
@Dict(dicCode = "yn")
@Schema(description = "入库结存(字典 yn1是 0否")
private String stockBalance;
@Excel(name = "库位", width = 15)
@Schema(description = "库位")
private String warehouseLocation;
@Excel(name = "卸货人", width = 15)
@Schema(description = "卸货人")
private String unloadOperator;
@Excel(name = "是否特采", width = 10, dicCode = "yn")
@Dict(dicCode = "yn")
@Schema(description = "是否特采(字典 yn1是 0否")
private String isSpecialAdoption;
@Excel(name = "特采操作人", width = 15)
@Schema(description = "特采操作人")
private String specialAdoptionOperator;
@Excel(name = "特采时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Schema(description = "特采时间")
private Date specialAdoptionTime;
@Excel(name = "特采原因", width = 30)
@Schema(description = "特采原因")
private String specialAdoptionReason;
@Excel(name = "状态", width = 10, dicCode = "xslmes_entry_status")
@Dict(dicCode = "xslmes_entry_status")
@Schema(description = "状态(字典 xslmes_entry_status")
private String status;
@Excel(name = "备注", width = 30)
@Schema(description = "备注")
private String remark;
/**创建人*/
@Schema(description = "创建人")
private String createBy;
/**创建日期*/
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Schema(description = "创建日期")
private Date createTime;
/**更新人*/
@Schema(description = "更新人")
private String updateBy;
/**更新日期*/
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Schema(description = "更新日期")
private Date updateTime;
@Schema(description = "租户ID")
private Integer tenantId;
}

View File

@@ -1,6 +1,7 @@
package org.jeecg.modules.xslmes.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@@ -23,6 +24,26 @@ import java.util.Date;
@Accessors(chain = true)
@TableName("mes_xsl_weight_record")
@Schema(description = "地磅数据记录")
@JsonPropertyOrder({
"billNo",
"weighDate",
"inoutDirection",
"vehicleId",
"plateNumber",
"senderUnit",
"receiverUnit",
// 将“密炼物料”放到“毛重”之前:桌面端可能按 JSON 字段顺序动态生成列
"mixerMaterialIds",
"mixerMaterialNames",
"materialType",
"grossWeight",
"tareWeight",
"netWeight",
"driverName",
"driverPhone",
"billType",
"tenantId"
})
public class MesXslWeightRecord extends JeecgEntity implements Serializable {
private static final long serialVersionUID = 1L;
@@ -57,10 +78,6 @@ public class MesXslWeightRecord extends JeecgEntity implements Serializable {
@Schema(description = "收货单位(出厂时为客户简称)")
private String receiverUnit;
@Excel(name = "货物名称", width = 20)
@Schema(description = "货物名称")
private String goodsName;
@Excel(name = "毛重(KG)", width = 12)
@Schema(description = "毛重(KG),实际称量")
private BigDecimal grossWeight;
@@ -86,6 +103,19 @@ public class MesXslWeightRecord extends JeecgEntity implements Serializable {
@Schema(description = "单据类型1已称毛重 2称重完成")
private String billType;
@Excel(name = "密炼物料ID", width = 30)
@Schema(description = "密炼物料ID分号分隔")
private String mixerMaterialIds;
@Excel(name = "密炼物料名称", width = 30)
@Schema(description = "密炼物料名称(分号分隔)")
private String mixerMaterialNames;
@Excel(name = "类型", width = 10, dicCode = "xslmes_weight_material_type")
@Dict(dicCode = "xslmes_weight_material_type")
@Schema(description = "磅单物料类型1自动 2手动")
private String materialType;
@Schema(description = "租户ID")
private Integer tenantId;
}

View File

@@ -0,0 +1,13 @@
package org.jeecg.modules.xslmes.mapper;
import org.jeecg.modules.xslmes.entity.MesXslRawMaterialEntry;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* @Description: 原料入场记录
* @Author: jeecg-boot
* @Date: 2026-05-07
* @Version: V1.0
*/
public interface MesXslRawMaterialEntryMapper extends BaseMapper<MesXslRawMaterialEntry> {
}

View File

@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.jeecg.modules.xslmes.mapper.MesXslRawMaterialEntryMapper">
</mapper>

View File

@@ -0,0 +1,13 @@
package org.jeecg.modules.xslmes.service;
import org.jeecg.modules.xslmes.entity.MesXslRawMaterialEntry;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* @Description: 原料入场记录
* @Author: jeecg-boot
* @Date: 2026-05-07
* @Version: V1.0
*/
public interface IMesXslRawMaterialEntryService extends IService<MesXslRawMaterialEntry> {
}

View File

@@ -45,6 +45,16 @@ public class MesXslStompNotifyService {
publish("/topic/sync/mes-mixer-materials", "MIXER_MATERIAL_CHANGED", "mixerMaterialId", mixerMaterialId, action);
}
/** 广播分类字典变更事件到 /topic/sync/sys-categories */
public void publishSysCategoryChanged(String action, String categoryId) {
publish("/topic/sync/sys-categories", "SYS_CATEGORY_CHANGED", "categoryId", categoryId, action);
}
/** 广播数据字典变更事件到 /topic/sync/sys-dicts */
public void publishSysDictChanged(String action, String dictId) {
publish("/topic/sync/sys-dicts", "SYS_DICT_CHANGED", "dictId", dictId, action);
}
// ─────────────────────────── 私有辅助 ────────────────────────────
private void publish(String topic, String cmd, String idKey, String idValue, String action) {

View File

@@ -0,0 +1,17 @@
package org.jeecg.modules.xslmes.service.impl;
import org.jeecg.modules.xslmes.entity.MesXslRawMaterialEntry;
import org.jeecg.modules.xslmes.mapper.MesXslRawMaterialEntryMapper;
import org.jeecg.modules.xslmes.service.IMesXslRawMaterialEntryService;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
/**
* @Description: 原料入场记录
* @Author: jeecg-boot
* @Date: 2026-05-07
* @Version: V1.0
*/
@Service
public class MesXslRawMaterialEntryServiceImpl extends ServiceImpl<MesXslRawMaterialEntryMapper, MesXslRawMaterialEntry> implements IMesXslRawMaterialEntryService {
}