feat(mill): 添加生产计划完成功能并修改服务器端口
- 在 MillProductionPlanService 中新增 completePlan 方法用于完成计划 - 在 MillProductionPlanController 中新增 complete 接口用于完成计划操作 - 实现完成计划业务逻辑:更新计划状态为完成并创建生产实绩记录 - 修改 application.yml 配置文件将服务器端口从 8080 改为 8090 - 修改 pom.xml 文件将 artifactId 从 ruoyi-admin 改为 double-rack - 集成事务管理确保数据一致性
This commit is contained in:
@@ -9,7 +9,7 @@
|
|||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<artifactId>ruoyi-admin</artifactId>
|
<artifactId>double-rack</artifactId>
|
||||||
|
|
||||||
<description>
|
<description>
|
||||||
web服务入口
|
web服务入口
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ ruoyi:
|
|||||||
# 开发环境配置
|
# 开发环境配置
|
||||||
server:
|
server:
|
||||||
# 服务器的HTTP端口,默认为8080
|
# 服务器的HTTP端口,默认为8080
|
||||||
port: 8080
|
port: 8090
|
||||||
servlet:
|
servlet:
|
||||||
# 应用的访问路径
|
# 应用的访问路径
|
||||||
context-path: /
|
context-path: /
|
||||||
|
|||||||
@@ -51,4 +51,13 @@ public class MillProductionPlanController extends BaseController {
|
|||||||
public AjaxResult moveDown(@PathVariable Long id) {
|
public AjaxResult moveDown(@PathVariable Long id) {
|
||||||
return toAjax(planService.moveDown(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 deleteById(Long id);
|
||||||
int moveUp(Long id);
|
int moveUp(Long id);
|
||||||
int moveDown(Long id);
|
int moveDown(Long id);
|
||||||
|
|
||||||
|
/** 完成计划:将计划状态改为完成,并创建生产实绩记录 */
|
||||||
|
int completePlan(Long planId);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,18 +1,23 @@
|
|||||||
package com.ruoyi.mill.service.impl;
|
package com.ruoyi.mill.service.impl;
|
||||||
|
|
||||||
import com.ruoyi.common.utils.SecurityUtils;
|
import com.ruoyi.common.utils.SecurityUtils;
|
||||||
|
import com.ruoyi.mill.domain.MillProductionActual;
|
||||||
import com.ruoyi.mill.domain.MillProductionPlan;
|
import com.ruoyi.mill.domain.MillProductionPlan;
|
||||||
|
import com.ruoyi.mill.mapper.MillProductionActualMapper;
|
||||||
import com.ruoyi.mill.mapper.MillProductionPlanMapper;
|
import com.ruoyi.mill.mapper.MillProductionPlanMapper;
|
||||||
import com.ruoyi.mill.service.IMillProductionPlanService;
|
import com.ruoyi.mill.service.IMillProductionPlanService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class MillProductionPlanServiceImpl implements IMillProductionPlanService {
|
public class MillProductionPlanServiceImpl implements IMillProductionPlanService {
|
||||||
|
|
||||||
@Autowired private MillProductionPlanMapper planMapper;
|
@Autowired private MillProductionPlanMapper planMapper;
|
||||||
|
@Autowired private MillProductionActualMapper actualMapper;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<MillProductionPlan> selectList(MillProductionPlan query) {
|
public List<MillProductionPlan> selectList(MillProductionPlan query) {
|
||||||
@@ -81,4 +86,40 @@ public class MillProductionPlanServiceImpl implements IMillProductionPlanService
|
|||||||
planMapper.updateSortNo(next.getPlanId(), cur.getSortNo());
|
planMapper.updateSortNo(next.getPlanId(), cur.getSortNo());
|
||||||
return 1;
|
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