add(mes): 生产工单新增生产派工功能

- 新增生产工单新增生产派工的接口和实现
- 添加 MesProductPlanEditVo 类用于处理生产派工编辑信息
- 在控制器中添加 orderAddProductPlanList 方法处理生产派工列表新增
- 在服务实现类中添加 orderAddMesProductPlanList 方法实现生产派工列表新增逻辑
master
zch 2 weeks ago
parent 90b3eaa764
commit 331a254762

@ -7,6 +7,7 @@ import jakarta.servlet.http.HttpServletResponse;
import jakarta.validation.constraints.*;
import cn.dev33.satoken.annotation.SaCheckPermission;
import org.dromara.mes.domain.ProdBaseRouteProcess;
import org.dromara.mes.domain.vo.MesProductPlanEditVo;
import org.dromara.mes.service.IProdBaseRouteProcessService;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;
@ -152,4 +153,12 @@ public class ProdPlanInfoController extends BaseController {
return R.ok(list);
}
/**
* List
*/
@PostMapping("/orderAddProductPlanList")
public R<Void> orderAddProductPlanList(@RequestBody MesProductPlanEditVo productPlanEditVo) {
return toAjax(prodPlanInfoService.orderAddMesProductPlanList(productPlanEditVo));
}
}

@ -0,0 +1,25 @@
package org.dromara.mes.domain.vo;
import jakarta.validation.constraints.NotBlank;
import lombok.Data;
import org.dromara.mes.domain.ProdPlanInfo;
import org.dromara.mes.domain.bo.ProdPlanInfoBo;
import java.util.List;
@Data
public class MesProductPlanEditVo {
//生产工单ID
@NotBlank(message = "生产工单Id必须输入")
private Long productOrderId;
//此次生产派工数量
private int dispatchAmount;
//保存的生产计划
@NotBlank(message = "没有修改的生产派工提交")
private List<ProdPlanInfoBo> mesProductPlanList;
//待删除的生产计划ID
private Long[] toDeletedPlanIds;
}

@ -1,6 +1,7 @@
package org.dromara.mes.service;
import org.dromara.mes.domain.ProdPlanInfo;
import org.dromara.mes.domain.vo.MesProductPlanEditVo;
import org.dromara.mes.domain.vo.ProdPlanInfoVo;
import org.dromara.mes.domain.bo.ProdPlanInfoBo;
import org.dromara.common.mybatis.core.page.TableDataInfo;
@ -75,6 +76,22 @@ public interface IProdPlanInfoService {
*/
public String getDispatchCode();
/**
* ,join process
*
* @param bo
* @return
*/
public List<ProdPlanInfoVo> selectProdPlanInfoJoinProcessList(ProdPlanInfoBo bo);
/**
*
*
* @param boList
* @return
*/
/* public Boolean insertBatchList(List<ProdPlanInfoBo> boList);*/
public int orderAddMesProductPlanList(MesProductPlanEditVo mesProductPlanEditVo);
}

@ -1,6 +1,8 @@
package org.dromara.mes.service.impl;
import org.dromara.common.constant.DatabaseConstants;
import org.dromara.common.core.exception.ServiceException;
import org.dromara.common.core.utils.DateUtils;
import org.dromara.common.core.utils.MapstructUtils;
import org.dromara.common.core.utils.StringUtils;
import org.dromara.common.core.utils.uuid.Seq;
@ -11,16 +13,19 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.yulichang.toolkit.JoinWrappers;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import lombok.RequiredArgsConstructor;
import org.dromara.common.satoken.utils.LoginHelper;
import org.dromara.mes.domain.vo.MesProductPlanEditVo;
import org.springframework.stereotype.Service;
import org.dromara.mes.domain.bo.ProdPlanInfoBo;
import org.dromara.mes.domain.vo.ProdPlanInfoVo;
import org.dromara.mes.domain.ProdPlanInfo;
import org.dromara.mes.mapper.ProdPlanInfoMapper;
import org.dromara.mes.service.IProdPlanInfoService;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.ObjectUtils;
import java.util.List;
import java.util.Map;
import java.util.Collection;
import java.util.*;
import java.util.stream.Collectors;
/**
* Service
@ -198,4 +203,53 @@ public class ProdPlanInfoServiceImpl implements IProdPlanInfoService {
}
/**
* List
*
* @param mesProductPlanEditVo VO
* @return
*/
@Override
@Transactional(rollbackFor = Exception.class)
public int orderAddMesProductPlanList(MesProductPlanEditVo mesProductPlanEditVo) {
List<ProdPlanInfoBo> prodPlanInfoList = new ArrayList<>();
/* Long userId = LoginHelper.getUserId(); // 获取当前用户ID
Long deptId = LoginHelper.getDeptId(); // 获取当前部门ID*/
List<ProdPlanInfoBo> mesProductPlanList = mesProductPlanEditVo.getMesProductPlanList();
if (!ObjectUtils.isEmpty(mesProductPlanList)) {
for (ProdPlanInfoBo mesProductPlanBo : mesProductPlanList) {
/* mesProductPlanBo.setCreateBy(userId);*/
// mesProductPlanBo.setCreateTime(DateUtils.getNowDate());
mesProductPlanBo.setPlanCode(Seq.getId(Seq.mesPlanCodeSeqType, Seq.mesPlanCodeCode));
prodPlanInfoList.add(mesProductPlanBo);
}
}
if (prodPlanInfoList.isEmpty()) {
throw new ServiceException("无有效的派工数据提交");
}
int successCount = 0;
for (ProdPlanInfoBo mesProductPlanBo : prodPlanInfoList) {
String planCode = Seq.getId(Seq.mesPlanCodeSeqType, Seq.mesPlanCodeCode);
mesProductPlanBo.setPlanCode(planCode);
ProdPlanInfo add = MapstructUtils.convert(mesProductPlanBo, ProdPlanInfo.class);
validEntityBeforeSave(add);
//TODO:后期需调用insertByBo会分表插入
boolean flag = baseMapper.insert(add) > 0;
if (flag) {
mesProductPlanBo.setPlanId(add.getPlanId());
successCount++;
}
}
if (successCount == 0) {
throw new ServiceException("派工数据保存失败");
}
return successCount;
}
}

Loading…
Cancel
Save