feat(mill): 添加生产计划完成功能并修改服务器端口
- 在 MillProductionPlanService 中新增 completePlan 方法用于完成计划 - 在 MillProductionPlanController 中新增 complete 接口用于完成计划操作 - 实现完成计划业务逻辑:更新计划状态为完成并创建生产实绩记录 - 修改 application.yml 配置文件将服务器端口从 8080 改为 8090 - 修改 pom.xml 文件将 artifactId 从 ruoyi-admin 改为 double-rack - 集成事务管理确保数据一致性
This commit is contained in:
@@ -51,4 +51,13 @@ public class MillProductionPlanController extends BaseController {
|
||||
public AjaxResult moveDown(@PathVariable Long id) {
|
||||
return toAjax(planService.moveDown(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 完成计划:将计划状态改为完成,并在实绩表中新建一条记录
|
||||
* @param planId 计划ID
|
||||
*/
|
||||
@PutMapping("/complete/{planId}")
|
||||
public AjaxResult complete(@PathVariable Long planId) {
|
||||
return toAjax(planService.completePlan(planId));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,4 +11,7 @@ public interface IMillProductionPlanService {
|
||||
int deleteById(Long id);
|
||||
int moveUp(Long id);
|
||||
int moveDown(Long id);
|
||||
|
||||
/** 完成计划:将计划状态改为完成,并创建生产实绩记录 */
|
||||
int completePlan(Long planId);
|
||||
}
|
||||
|
||||
@@ -1,18 +1,23 @@
|
||||
package com.ruoyi.mill.service.impl;
|
||||
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import com.ruoyi.mill.domain.MillProductionActual;
|
||||
import com.ruoyi.mill.domain.MillProductionPlan;
|
||||
import com.ruoyi.mill.mapper.MillProductionActualMapper;
|
||||
import com.ruoyi.mill.mapper.MillProductionPlanMapper;
|
||||
import com.ruoyi.mill.service.IMillProductionPlanService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class MillProductionPlanServiceImpl implements IMillProductionPlanService {
|
||||
|
||||
@Autowired private MillProductionPlanMapper planMapper;
|
||||
@Autowired private MillProductionActualMapper actualMapper;
|
||||
|
||||
@Override
|
||||
public List<MillProductionPlan> selectList(MillProductionPlan query) {
|
||||
@@ -81,4 +86,40 @@ public class MillProductionPlanServiceImpl implements IMillProductionPlanService
|
||||
planMapper.updateSortNo(next.getPlanId(), cur.getSortNo());
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public int completePlan(Long planId) {
|
||||
// 1. 查询当前计划
|
||||
MillProductionPlan plan = planMapper.selectById(planId);
|
||||
if (plan == null) {
|
||||
throw new RuntimeException("计划不存在: " + planId);
|
||||
}
|
||||
|
||||
// 2. 更新计划状态为完成(2)
|
||||
plan.setProdStatus("done");
|
||||
plan.setUpdateBy(SecurityUtils.getUsername());
|
||||
int updateResult = planMapper.update(plan);
|
||||
if (updateResult <= 0) {
|
||||
throw new RuntimeException("更新计划状态失败");
|
||||
}
|
||||
|
||||
// 3. 创建生产实绩记录
|
||||
MillProductionActual actual = new MillProductionActual();
|
||||
actual.setPlanId(plan.getPlanId());
|
||||
actual.setPlanNo(plan.getPlanNo());
|
||||
actual.setEntryMatId(plan.getInMatNo()); // 来料卷号 = 生产计划钢卷号
|
||||
actual.setSteelGrade(plan.getAlloyNo()); // 钢种
|
||||
actual.setStatus("已完成"); // 实绩状态:已完成
|
||||
actual.setEndTime(new Date()); // 结束时间
|
||||
actual.setCreateBy(SecurityUtils.getUsername());
|
||||
actual.setDelFlag("0"); // 正常状态
|
||||
|
||||
int actualResult = actualMapper.insertMillProductionActual(actual);
|
||||
if (actualResult <= 0) {
|
||||
throw new RuntimeException("创建生产实绩记录失败");
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user