refactor(入库计划): 新增入库计划明细实例

This commit is contained in:
LJW 2024-11-08 17:05:48 +08:00
parent 703ca49d2e
commit 50f96b0bdd

View File

@ -1,10 +1,15 @@
package com.ktg.mes.wm.service.impl; package com.ktg.mes.wm.service.impl;
import java.util.List; import java.util.List;
import com.ktg.common.utils.DateUtils; import com.ktg.common.utils.DateUtils;
import com.ktg.mes.wm.domain.WmsInPlanDetailEntity;
import com.ktg.mes.wm.mapper.WmsInPlanDetailEntityMapper;
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 java.util.ArrayList; import java.util.ArrayList;
import com.ktg.common.utils.StringUtils; import com.ktg.common.utils.StringUtils;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import com.ktg.mes.wm.domain.WmsInPlanDetails; import com.ktg.mes.wm.domain.WmsInPlanDetails;
@ -14,50 +19,49 @@ import com.ktg.mes.wm.service.IWmsInPlanService;
/** /**
* 入库计划Service业务层处理 * 入库计划Service业务层处理
* *
* @author yinjinlu * @author yinjinlu
* @date 2024-10-31 * @date 2024-10-31
*/ */
@Service @Service
public class WmsInPlanServiceImpl implements IWmsInPlanService public class WmsInPlanServiceImpl implements IWmsInPlanService {
{
@Autowired @Autowired
private WmsInPlanMapper wmsInPlanMapper; private WmsInPlanMapper wmsInPlanMapper;
@Autowired
private WmsInPlanDetailEntityMapper wmsInPlanDetailEntityMapper;
/** /**
* 查询入库计划 * 查询入库计划
* *
* @param planId 入库计划主键 * @param planId 入库计划主键
* @return 入库计划 * @return 入库计划
*/ */
@Override @Override
public WmsInPlan selectWmsInPlanByPlanId(String planId) public WmsInPlan selectWmsInPlanByPlanId(String planId) {
{
return wmsInPlanMapper.selectWmsInPlanByPlanId(planId); return wmsInPlanMapper.selectWmsInPlanByPlanId(planId);
} }
/** /**
* 查询入库计划列表 * 查询入库计划列表
* *
* @param wmsInPlan 入库计划 * @param wmsInPlan 入库计划
* @return 入库计划 * @return 入库计划
*/ */
@Override @Override
public List<WmsInPlan> selectWmsInPlanList(WmsInPlan wmsInPlan) public List<WmsInPlan> selectWmsInPlanList(WmsInPlan wmsInPlan) {
{
return wmsInPlanMapper.selectWmsInPlanList(wmsInPlan); return wmsInPlanMapper.selectWmsInPlanList(wmsInPlan);
} }
/** /**
* 新增入库计划 * 新增入库计划
* *
* @param wmsInPlan 入库计划 * @param wmsInPlan 入库计划
* @return 结果 * @return 结果
*/ */
@Transactional @Transactional
@Override @Override
public int insertWmsInPlan(WmsInPlan wmsInPlan) public int insertWmsInPlan(WmsInPlan wmsInPlan) {
{
wmsInPlan.setCreateTime(DateUtils.getNowDate()); wmsInPlan.setCreateTime(DateUtils.getNowDate());
int rows = wmsInPlanMapper.insertWmsInPlan(wmsInPlan); int rows = wmsInPlanMapper.insertWmsInPlan(wmsInPlan);
insertWmsInPlanDetails(wmsInPlan); insertWmsInPlanDetails(wmsInPlan);
@ -66,69 +70,89 @@ public class WmsInPlanServiceImpl implements IWmsInPlanService
/** /**
* 修改入库计划 * 修改入库计划
* *
* @param wmsInPlan 入库计划 * @param wmsInPlan 入库计划
* @return 结果 * @return 结果
*/ */
@Transactional @Transactional
@Override @Override
public int updateWmsInPlan(WmsInPlan wmsInPlan) public int updateWmsInPlan(WmsInPlan wmsInPlan) {
{
wmsInPlan.setUpdateTime(DateUtils.getNowDate()); wmsInPlan.setUpdateTime(DateUtils.getNowDate());
wmsInPlanMapper.deleteWmsInPlanDetailsByPlanId(wmsInPlan.getPlanId()); wmsInPlanMapper.deleteWmsInPlanDetailsByPlanId(wmsInPlan.getPlanId().toString());
insertWmsInPlanDetails(wmsInPlan); insertWmsInPlanDetails(wmsInPlan);
return wmsInPlanMapper.updateWmsInPlan(wmsInPlan); return wmsInPlanMapper.updateWmsInPlan(wmsInPlan);
} }
/** /**
* 批量删除入库计划 * 批量删除入库计划
* *
* @param planIds 需要删除的入库计划主键 * @param planIds 需要删除的入库计划主键
* @return 结果 * @return 结果
*/ */
@Transactional @Transactional
@Override @Override
public int deleteWmsInPlanByPlanIds(String[] planIds) public int deleteWmsInPlanByPlanIds(String[] planIds) {
{
wmsInPlanMapper.deleteWmsInPlanDetailsByPlanIds(planIds); wmsInPlanMapper.deleteWmsInPlanDetailsByPlanIds(planIds);
return wmsInPlanMapper.deleteWmsInPlanByPlanIds(planIds); return wmsInPlanMapper.deleteWmsInPlanByPlanIds(planIds);
} }
/** /**
* 删除入库计划信息 * 删除入库计划信息
* *
* @param planId 入库计划主键 * @param planId 入库计划主键
* @return 结果 * @return 结果
*/ */
@Transactional @Transactional
@Override @Override
public int deleteWmsInPlanByPlanId(String planId) public int deleteWmsInPlanByPlanId(String planId) {
{
wmsInPlanMapper.deleteWmsInPlanDetailsByPlanId(planId); wmsInPlanMapper.deleteWmsInPlanDetailsByPlanId(planId);
return wmsInPlanMapper.deleteWmsInPlanByPlanId(planId); return wmsInPlanMapper.deleteWmsInPlanByPlanId(planId);
} }
/** /**
* 新增入库计划明细信息 * 新增入库计划明细信息
* *
* @param wmsInPlan 入库计划对象 * @param wmsInPlan 入库计划对象
*/ */
public void insertWmsInPlanDetails(WmsInPlan wmsInPlan) public void insertWmsInPlanDetails(WmsInPlan wmsInPlan) {
{
List<WmsInPlanDetails> wmsInPlanDetailsList = wmsInPlan.getWmsInPlanDetailsList(); List<WmsInPlanDetails> wmsInPlanDetailsList = wmsInPlan.getWmsInPlanDetailsList();
String planId = wmsInPlan.getPlanId(); Long planId = wmsInPlan.getPlanId();
if (StringUtils.isNotNull(wmsInPlanDetailsList)) if (StringUtils.isNotNull(wmsInPlanDetailsList)) {
{
List<WmsInPlanDetails> list = new ArrayList<WmsInPlanDetails>(); List<WmsInPlanDetails> list = new ArrayList<WmsInPlanDetails>();
for (WmsInPlanDetails wmsInPlanDetails : wmsInPlanDetailsList) for (WmsInPlanDetails wmsInPlanDetails : wmsInPlanDetailsList) {
{
wmsInPlanDetails.setPlanId(planId); wmsInPlanDetails.setPlanId(planId);
list.add(wmsInPlanDetails); list.add(wmsInPlanDetails);
// 插入入库任务明细实例
wmsInPlanDetailEntityMapper.deleteWmsInPlanDetailEntityByPlanDetailsId(wmsInPlanDetails.getDetailsId());
insertWmsInPlanDetailEntity(wmsInPlanDetails);
} }
if (list.size() > 0) if (!list.isEmpty()) {
{
wmsInPlanMapper.batchWmsInPlanDetails(list); wmsInPlanMapper.batchWmsInPlanDetails(list);
} }
} }
} }
/**
* 新增入库计划明细实例
*
* @param wmsInPlanDetails 入库计划明细对象
*/
public void insertWmsInPlanDetailEntity(WmsInPlanDetails wmsInPlanDetails) {
List<WmsInPlanDetailEntity> wmsInPlanDetailEntityList = wmsInPlanDetails.getWmsInPlanDetailEntityList();
Long planId = wmsInPlanDetails.getPlanId();
Long planDetailsId = wmsInPlanDetails.getDetailsId();
if (StringUtils.isNotNull(wmsInPlanDetailEntityList)) {
ArrayList<WmsInPlanDetailEntity> list = new ArrayList<>();
for (WmsInPlanDetailEntity wmsInPlanDetailEntity : wmsInPlanDetailEntityList) {
wmsInPlanDetailEntity.setPlanId(planId);
wmsInPlanDetailEntity.setPlanDetailsId(planDetailsId);
list.add(wmsInPlanDetailEntity);
}
if (!list.isEmpty()) {
wmsInPlanDetailEntityMapper.batchWmsInPlanDetailEntity(list);
}
}
}
} }