更新胶料信息处理逻辑,优化字段描述及数据验证,增强系统稳定性和用户体验。

This commit is contained in:
geht
2026-05-20 19:06:58 +08:00
parent 9f37292eea
commit a10aae420a
17 changed files with 1731 additions and 0 deletions

View File

@@ -0,0 +1,261 @@
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.HashMap;
import java.util.Map;
import lombok.extern.slf4j.Slf4j;
import org.apache.shiro.SecurityUtils;
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.system.query.QueryRuleEnum;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.system.entity.SysDepart;
import org.jeecg.modules.system.service.ISysDepartService;
import org.jeecg.modules.xslmes.entity.MesXslMixerPsCompile;
import org.jeecg.modules.xslmes.service.IMesXslMixerPsCompileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
/**
* MES 密炼PS编制
*/
@Tag(name = "MES密炼PS编制")
@RestController
@RequestMapping("/xslmes/mesXslMixerPsCompile")
@Slf4j
public class MesXslMixerPsCompileController extends JeecgController<MesXslMixerPsCompile, IMesXslMixerPsCompileService> {
@Autowired
private IMesXslMixerPsCompileService mesXslMixerPsCompileService;
@Autowired
private ISysDepartService sysDepartService;
@Operation(summary = "MES密炼PS编制-分页列表查询")
@GetMapping(value = "/list")
public Result<IPage<MesXslMixerPsCompile>> queryPageList(
MesXslMixerPsCompile model,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
HttpServletRequest req) {
Map<String, QueryRuleEnum> customeRuleMap = new HashMap<>();
customeRuleMap.put("psCode", QueryRuleEnum.LIKE);
customeRuleMap.put("title", QueryRuleEnum.LIKE);
QueryWrapper<MesXslMixerPsCompile> queryWrapper =
QueryGenerator.initQueryWrapper(model, req.getParameterMap(), customeRuleMap);
queryWrapper.orderByDesc("issue_date", "create_time");
Page<MesXslMixerPsCompile> page = new Page<>(pageNo, pageSize);
IPage<MesXslMixerPsCompile> pageList = mesXslMixerPsCompileService.page(page, queryWrapper);
return Result.OK(pageList);
}
@AutoLog(value = "MES密炼PS编制-添加")
@Operation(summary = "MES密炼PS编制-添加")
@RequiresPermissions("xslmes:mes_xsl_mixer_ps_compile:add")
@PostMapping(value = "/add")
public Result<String> add(@RequestBody MesXslMixerPsCompile model) {
//update-begin---author:jiangxh ---date:20260520 for【密炼PS编制】保存前校验与冗余回填-----------
String err = validateAndFill(model);
if (err != null) {
return Result.error(err);
}
//update-end---author:jiangxh ---date:20260520 for【密炼PS编制】保存前校验与冗余回填-----------
mesXslMixerPsCompileService.save(model);
return Result.OK("添加成功!");
}
@AutoLog(value = "MES密炼PS编制-编辑")
@Operation(summary = "MES密炼PS编制-编辑")
@RequiresPermissions("xslmes:mes_xsl_mixer_ps_compile:edit")
@RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST})
public Result<String> edit(@RequestBody MesXslMixerPsCompile model) {
//update-begin---author:jiangxh ---date:20260520 for【密炼PS编制】保存前校验与冗余回填-----------
String err = validateAndFill(model);
if (err != null) {
return Result.error(err);
}
//update-end---author:jiangxh ---date:20260520 for【密炼PS编制】保存前校验与冗余回填-----------
MesXslMixerPsCompile existing = mesXslMixerPsCompileService.getById(model.getId());
if (existing == null) {
return Result.error("未找到对应数据");
}
if (!"compile".equals(existing.getStatus())) {
return Result.error("仅编制状态的单据允许编辑");
}
model.setStatus("compile");
model.setProofreadBy(existing.getProofreadBy());
model.setProofreadTime(existing.getProofreadTime());
model.setAuditBy(existing.getAuditBy());
model.setAuditTime(existing.getAuditTime());
model.setApproveBy(existing.getApproveBy());
model.setApproveTime(existing.getApproveTime());
mesXslMixerPsCompileService.updateById(model);
return Result.OK("编辑成功!");
}
@AutoLog(value = "MES密炼PS编制-删除")
@Operation(summary = "MES密炼PS编制-通过id删除")
@RequiresPermissions("xslmes:mes_xsl_mixer_ps_compile:delete")
@DeleteMapping(value = "/delete")
public Result<String> delete(@RequestParam(name = "id", required = true) String id) {
//update-begin---author:jiangxh ---date:20260520 for【密炼PS编制】仅编制状态允许删除-----------
MesXslMixerPsCompile existing = mesXslMixerPsCompileService.getById(id);
String err = assertCompileStatusForDelete(existing);
if (err != null) {
return Result.error(err);
}
//update-end---author:jiangxh ---date:20260520 for【密炼PS编制】仅编制状态允许删除-----------
mesXslMixerPsCompileService.removeById(id);
return Result.OK("删除成功!");
}
@AutoLog(value = "MES密炼PS编制-批量删除")
@Operation(summary = "MES密炼PS编制-批量删除")
@RequiresPermissions("xslmes:mes_xsl_mixer_ps_compile:deleteBatch")
@DeleteMapping(value = "/deleteBatch")
public Result<String> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
//update-begin---author:jiangxh ---date:20260520 for【密炼PS编制】仅编制状态允许删除-----------
if (oConvertUtils.isEmpty(ids)) {
return Result.error("请选择要删除的记录");
}
for (String id : ids.split(",")) {
if (oConvertUtils.isEmpty(id)) {
continue;
}
MesXslMixerPsCompile existing = mesXslMixerPsCompileService.getById(id.trim());
String err = assertCompileStatusForDelete(existing);
if (err != null) {
return Result.error(err);
}
}
//update-end---author:jiangxh ---date:20260520 for【密炼PS编制】仅编制状态允许删除-----------
mesXslMixerPsCompileService.removeByIds(Arrays.asList(ids.split(",")));
return Result.OK("批量删除成功!");
}
@Operation(summary = "MES密炼PS编制-通过id查询")
@GetMapping(value = "/queryById")
public Result<MesXslMixerPsCompile> queryById(@RequestParam(name = "id", required = true) String id) {
MesXslMixerPsCompile entity = mesXslMixerPsCompileService.getById(id);
if (entity == null) {
return Result.error("未找到对应数据");
}
return Result.OK(entity);
}
@RequiresPermissions("xslmes:mes_xsl_mixer_ps_compile:exportXls")
@RequestMapping(value = "/exportXls")
public ModelAndView exportXls(HttpServletRequest request, MesXslMixerPsCompile model) {
return super.exportXls(request, model, MesXslMixerPsCompile.class, "密炼PS编制");
}
@RequiresPermissions("xslmes:mes_xsl_mixer_ps_compile:importExcel")
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
return super.importExcel(request, response, MesXslMixerPsCompile.class);
}
//update-begin---author:jiangxh ---date:20260520 for【密炼PS编制】校对/审核/批准-----------
@AutoLog(value = "MES密炼PS编制-校对")
@Operation(summary = "MES密炼PS编制-校对")
@RequiresPermissions("xslmes:mes_xsl_mixer_ps_compile:proofread")
@PostMapping(value = "/proofread")
public Result<String> proofread(@RequestParam(name = "ids") String ids) {
return doChangeStatus(ids, "compile", "proofread", "校对");
}
@AutoLog(value = "MES密炼PS编制-审核")
@Operation(summary = "MES密炼PS编制-审核")
@RequiresPermissions("xslmes:mes_xsl_mixer_ps_compile:audit")
@PostMapping(value = "/audit")
public Result<String> audit(@RequestParam(name = "ids") String ids) {
return doChangeStatus(ids, "proofread", "audit", "审核");
}
@AutoLog(value = "MES密炼PS编制-批准")
@Operation(summary = "MES密炼PS编制-批准")
@RequiresPermissions("xslmes:mes_xsl_mixer_ps_compile:approve")
@PostMapping(value = "/approve")
public Result<String> approve(@RequestParam(name = "ids") String ids) {
return doChangeStatus(ids, "audit", "approve", "批准");
}
private Result<String> doChangeStatus(String ids, String expectedStatus, String targetStatus, String actionLabel) {
String err = mesXslMixerPsCompileService.changeStatusBatch(
ids, expectedStatus, targetStatus, actionLabel, getOperatorName());
if (err != null) {
return Result.error(err);
}
return Result.OK(actionLabel + "成功!");
}
private String getOperatorName() {
LoginUser loginUser = null;
try {
loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
} catch (Exception e) {
log.debug("获取当前登录用户失败", e);
}
if (loginUser == null) {
return null;
}
if (oConvertUtils.isNotEmpty(loginUser.getRealname())) {
return loginUser.getRealname();
}
return loginUser.getUsername();
}
//update-end---author:jiangxh ---date:20260520 for【密炼PS编制】校对/审核/批准-----------
//update-begin---author:jiangxh ---date:20260520 for【密炼PS编制】保存前校验与冗余回填-----------
private String validateAndFill(MesXslMixerPsCompile model) {
if (oConvertUtils.isEmpty(model.getReceiveDeptId())) {
return "请选择收信部门";
}
if (oConvertUtils.isEmpty(model.getReferenceDeptId())) {
return "请选择参照部门";
}
if (oConvertUtils.isEmpty(model.getTitle())) {
return "请输入标题";
}
if (oConvertUtils.isEmpty(model.getStatus())) {
model.setStatus("compile");
}
if (oConvertUtils.isNotEmpty(model.getFactoryId())) {
SysDepart factory = sysDepartService.getById(model.getFactoryId());
if (factory == null) {
return "所选所属工厂不存在,请重新选择";
}
model.setFactoryName(factory.getDepartName());
} else {
model.setFactoryName(null);
}
return null;
}
//update-end---author:jiangxh ---date:20260520 for【密炼PS编制】保存前校验与冗余回填-----------
//update-begin---author:jiangxh ---date:20260520 for【密炼PS编制】仅编制状态允许删除-----------
private String assertCompileStatusForDelete(MesXslMixerPsCompile entity) {
if (entity == null) {
return "记录不存在或已删除";
}
String status = entity.getStatus() == null ? "" : entity.getStatus();
if (!"compile".equals(status)) {
String psCode = oConvertUtils.isEmpty(entity.getPsCode()) ? entity.getId() : entity.getPsCode();
return "PS编码[" + psCode + "]当前状态不允许删除,仅编制状态可删除";
}
return null;
}
//update-end---author:jiangxh ---date:20260520 for【密炼PS编制】仅编制状态允许删除-----------
}

View File

@@ -0,0 +1,152 @@
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.jeecg.common.aspect.annotation.Dict;
import org.jeecgframework.poi.excel.annotation.Excel;
import org.springframework.format.annotation.DateTimeFormat;
/**
* MES 密炼PS编制
*/
@Data
@TableName("mes_xsl_mixer_ps_compile")
@Accessors(chain = true)
@EqualsAndHashCode(callSuper = false)
@Schema(description = "MES密炼PS编制")
public class MesXslMixerPsCompile implements Serializable {
private static final long serialVersionUID = 1L;
@TableId(type = IdType.ASSIGN_ID)
private String id;
@Excel(name = "所属工厂", width = 20)
@Schema(description = "所属工厂名称冗余(公司)")
private String factoryName;
@Schema(description = "所属工厂IDsys_depart.id公司")
private String factoryId;
@Excel(name = "PS编码", width = 18)
@Schema(description = "PS编码")
private String psCode;
@Excel(name = "类型", width = 15, dicCode = "xslmes_ps_belong")
@Dict(dicCode = "xslmes_ps_belong")
@Schema(description = "类型字典PS归属")
private String psType;
@Excel(name = "施工代号", width = 15, dicCode = "xslmes_construction_code")
@Dict(dicCode = "xslmes_construction_code")
@Schema(description = "施工代号")
private String constructionCode;
@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 = 15, dictTable = "sys_depart", dicText = "depart_name", dicCode = "id")
@Dict(dictTable = "sys_depart", dicText = "depart_name", dicCode = "id")
@Schema(description = "发送部门ID")
private String sendDeptId;
@Excel(name = "收信部门", width = 15, dictTable = "sys_depart", dicText = "depart_name", dicCode = "id")
@Dict(dictTable = "sys_depart", dicText = "depart_name", dicCode = "id")
@Schema(description = "收信部门ID")
private String receiveDeptId;
@Excel(name = "参照部门", width = 15, dictTable = "sys_depart", dicText = "depart_name", dicCode = "id")
@Dict(dictTable = "sys_depart", dicText = "depart_name", dicCode = "id")
@Schema(description = "参照部门ID")
private String referenceDeptId;
@Excel(name = "标题", width = 25)
@Schema(description = "标题")
private String title;
@Excel(name = "目的", width = 30)
@Schema(description = "目的")
private String purpose;
@Excel(name = "依据", width = 30)
@Schema(description = "依据")
private String basis;
@Excel(name = "内容", width = 40)
@Schema(description = "内容")
private String content;
@Excel(name = "担当", width = 12)
@Schema(description = "担当")
private String responsiblePerson;
@Excel(name = "状态", width = 10, dicCode = "xslmes_mixer_ps_status")
@Dict(dicCode = "xslmes_mixer_ps_status")
@Schema(description = "状态")
private String status;
@Excel(name = "校对人", width = 15)
@Schema(description = "校对人")
private String proofreadBy;
@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 proofreadTime;
@Excel(name = "审核人", width = 15)
@Schema(description = "审核人")
private String auditBy;
@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 auditTime;
@Excel(name = "批准人", width = 15)
@Schema(description = "批准人")
private String approveBy;
@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 approveTime;
@Excel(name = "创建人", width = 15, dictTable = "sys_user", dicText = "realname", dicCode = "username")
//update-begin---author:jiangxh ---date:20260520 for【密炼PS编制】创建人翻译为姓名供编制人展示-----------
@Dict(dictTable = "sys_user", dicText = "realname", dicCode = "username")
//update-end---author:jiangxh ---date:20260520 for【密炼PS编制】创建人翻译为姓名供编制人展示-----------
private String createBy;
@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")
private Date createTime;
@Excel(name = "修改人", width = 15)
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;
}

View File

@@ -0,0 +1,12 @@
package org.jeecg.modules.xslmes.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.jeecg.modules.xslmes.entity.MesXslMixerPsCompile;
/**
* MES 密炼PS编制 Mapper
*/
@Mapper
public interface MesXslMixerPsCompileMapper extends BaseMapper<MesXslMixerPsCompile> {
}

View File

@@ -0,0 +1,19 @@
package org.jeecg.modules.xslmes.service;
import com.baomidou.mybatisplus.extension.service.IService;
import org.jeecg.modules.xslmes.entity.MesXslMixerPsCompile;
/**
* MES 密炼PS编制
*/
public interface IMesXslMixerPsCompileService extends IService<MesXslMixerPsCompile> {
//update-begin---author:jiangxh ---date:20260520 for【密炼PS编制】批量流转状态-----------
/**
* 批量变更状态(校验当前状态后更新,并记录操作人/时间)
*
* @return 失败原因null 表示成功
*/
String changeStatusBatch(String ids, String expectedStatus, String targetStatus, String actionLabel, String operatorName);
//update-end---author:jiangxh ---date:20260520 for【密炼PS编制】批量流转状态-----------
}

View File

@@ -0,0 +1,64 @@
package org.jeecg.modules.xslmes.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import org.jeecg.common.util.oConvertUtils;
import org.jeecg.modules.xslmes.entity.MesXslMixerPsCompile;
import org.jeecg.modules.xslmes.mapper.MesXslMixerPsCompileMapper;
import org.jeecg.modules.xslmes.service.IMesXslMixerPsCompileService;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
/**
* MES 密炼PS编制
*/
@Service
public class MesXslMixerPsCompileServiceImpl extends ServiceImpl<MesXslMixerPsCompileMapper, MesXslMixerPsCompile>
implements IMesXslMixerPsCompileService {
//update-begin---author:jiangxh ---date:20260520 for【密炼PS编制】批量流转状态-----------
@Override
@Transactional(rollbackFor = Exception.class)
public String changeStatusBatch(String ids, String expectedStatus, String targetStatus, String actionLabel,
String operatorName) {
if (oConvertUtils.isEmpty(ids)) {
return "请选择要" + actionLabel + "的记录";
}
List<String> idList = Arrays.asList(ids.split(","));
Date now = new Date();
for (String id : idList) {
if (oConvertUtils.isEmpty(id)) {
continue;
}
MesXslMixerPsCompile entity = getById(id.trim());
if (entity == null) {
return "记录不存在或已删除";
}
String current = entity.getStatus() == null ? "" : entity.getStatus();
if (!expectedStatus.equals(current)) {
String psCode = oConvertUtils.isEmpty(entity.getPsCode()) ? id : entity.getPsCode();
return "PS编码[" + psCode + "]当前状态不允许" + actionLabel + ",请先完成上一环节";
}
entity.setStatus(targetStatus);
fillWorkflowInfo(entity, targetStatus, operatorName, now);
updateById(entity);
}
return null;
}
private void fillWorkflowInfo(MesXslMixerPsCompile entity, String targetStatus, String operatorName, Date now) {
if ("proofread".equals(targetStatus)) {
entity.setProofreadBy(operatorName);
entity.setProofreadTime(now);
} else if ("audit".equals(targetStatus)) {
entity.setAuditBy(operatorName);
entity.setAuditTime(now);
} else if ("approve".equals(targetStatus)) {
entity.setApproveBy(operatorName);
entity.setApproveTime(now);
}
}
//update-end---author:jiangxh ---date:20260520 for【密炼PS编制】批量流转状态-----------
}