|
|
@ -1,13 +1,24 @@
|
|
|
|
package com.hw.mes.service.impl;
|
|
|
|
package com.hw.mes.service.impl;
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
import com.hw.common.core.constant.MesConstants;
|
|
|
|
|
|
|
|
import com.hw.common.core.exception.ServiceException;
|
|
|
|
import com.hw.common.core.utils.DateUtils;
|
|
|
|
import com.hw.common.core.utils.DateUtils;
|
|
|
|
|
|
|
|
import com.hw.common.core.utils.uuid.Seq;
|
|
|
|
|
|
|
|
import com.hw.common.security.utils.SecurityUtils;
|
|
|
|
|
|
|
|
import com.hw.mes.domain.MesProductPlan;
|
|
|
|
|
|
|
|
import com.hw.mes.domain.MesProductPlanDetail;
|
|
|
|
import com.hw.mes.domain.vo.MesProductPlanDetailVo;
|
|
|
|
import com.hw.mes.domain.vo.MesProductPlanDetailVo;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
import com.hw.mes.mapper.MesProductPlanDetailMapper;
|
|
|
|
import com.hw.mes.mapper.MesProductPlanDetailMapper;
|
|
|
|
import com.hw.mes.domain.MesProductPlanDetail;
|
|
|
|
import com.hw.mes.mapper.MesProductPlanMapper;
|
|
|
|
import com.hw.mes.service.IMesProductPlanDetailService;
|
|
|
|
import com.hw.mes.service.IMesProductPlanDetailService;
|
|
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 生产计划明细Service业务层处理
|
|
|
|
* 生产计划明细Service业务层处理
|
|
|
@ -16,11 +27,13 @@ import com.hw.mes.service.IMesProductPlanDetailService;
|
|
|
|
* @date 2024-02-21
|
|
|
|
* @date 2024-02-21
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@Service
|
|
|
|
@Service
|
|
|
|
public class MesProductPlanDetailServiceImpl implements IMesProductPlanDetailService
|
|
|
|
public class MesProductPlanDetailServiceImpl implements IMesProductPlanDetailService {
|
|
|
|
{
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
private MesProductPlanDetailMapper mesProductPlanDetailMapper;
|
|
|
|
private MesProductPlanDetailMapper mesProductPlanDetailMapper;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
|
|
private MesProductPlanMapper mesProductPlanMapper;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 查询生产计划明细
|
|
|
|
* 查询生产计划明细
|
|
|
|
*
|
|
|
|
*
|
|
|
@ -28,8 +41,7 @@ public class MesProductPlanDetailServiceImpl implements IMesProductPlanDetailSer
|
|
|
|
* @return 生产计划明细
|
|
|
|
* @return 生产计划明细
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public MesProductPlanDetail selectMesProductPlanDetailByPlanDetailId(Long planDetailId)
|
|
|
|
public MesProductPlanDetail selectMesProductPlanDetailByPlanDetailId(Long planDetailId) {
|
|
|
|
{
|
|
|
|
|
|
|
|
return mesProductPlanDetailMapper.selectMesProductPlanDetailByPlanDetailId(planDetailId);
|
|
|
|
return mesProductPlanDetailMapper.selectMesProductPlanDetailByPlanDetailId(planDetailId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -40,8 +52,7 @@ public class MesProductPlanDetailServiceImpl implements IMesProductPlanDetailSer
|
|
|
|
* @return 生产计划明细
|
|
|
|
* @return 生产计划明细
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public List<MesProductPlanDetail> selectMesProductPlanDetailList(MesProductPlanDetail mesProductPlanDetail)
|
|
|
|
public List<MesProductPlanDetail> selectMesProductPlanDetailList(MesProductPlanDetail mesProductPlanDetail) {
|
|
|
|
{
|
|
|
|
|
|
|
|
return mesProductPlanDetailMapper.selectMesProductPlanDetailList(mesProductPlanDetail);
|
|
|
|
return mesProductPlanDetailMapper.selectMesProductPlanDetailList(mesProductPlanDetail);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -52,8 +63,7 @@ public class MesProductPlanDetailServiceImpl implements IMesProductPlanDetailSer
|
|
|
|
* @return 结果
|
|
|
|
* @return 结果
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public int insertMesProductPlanDetail(MesProductPlanDetail mesProductPlanDetail)
|
|
|
|
public int insertMesProductPlanDetail(MesProductPlanDetail mesProductPlanDetail) {
|
|
|
|
{
|
|
|
|
|
|
|
|
mesProductPlanDetail.setCreateTime(DateUtils.getNowDate());
|
|
|
|
mesProductPlanDetail.setCreateTime(DateUtils.getNowDate());
|
|
|
|
return mesProductPlanDetailMapper.insertMesProductPlanDetail(mesProductPlanDetail);
|
|
|
|
return mesProductPlanDetailMapper.insertMesProductPlanDetail(mesProductPlanDetail);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -65,8 +75,7 @@ public class MesProductPlanDetailServiceImpl implements IMesProductPlanDetailSer
|
|
|
|
* @return 结果
|
|
|
|
* @return 结果
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public int updateMesProductPlanDetail(MesProductPlanDetail mesProductPlanDetail)
|
|
|
|
public int updateMesProductPlanDetail(MesProductPlanDetail mesProductPlanDetail) {
|
|
|
|
{
|
|
|
|
|
|
|
|
mesProductPlanDetail.setUpdateTime(DateUtils.getNowDate());
|
|
|
|
mesProductPlanDetail.setUpdateTime(DateUtils.getNowDate());
|
|
|
|
return mesProductPlanDetailMapper.updateMesProductPlanDetail(mesProductPlanDetail);
|
|
|
|
return mesProductPlanDetailMapper.updateMesProductPlanDetail(mesProductPlanDetail);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -78,8 +87,7 @@ public class MesProductPlanDetailServiceImpl implements IMesProductPlanDetailSer
|
|
|
|
* @return 结果
|
|
|
|
* @return 结果
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public int deleteMesProductPlanDetailByPlanDetailIds(Long[] planDetailIds)
|
|
|
|
public int deleteMesProductPlanDetailByPlanDetailIds(Long[] planDetailIds) {
|
|
|
|
{
|
|
|
|
|
|
|
|
return mesProductPlanDetailMapper.deleteMesProductPlanDetailByPlanDetailIds(planDetailIds);
|
|
|
|
return mesProductPlanDetailMapper.deleteMesProductPlanDetailByPlanDetailIds(planDetailIds);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -90,14 +98,11 @@ public class MesProductPlanDetailServiceImpl implements IMesProductPlanDetailSer
|
|
|
|
* @return 结果
|
|
|
|
* @return 结果
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public int deleteMesProductPlanDetailByPlanDetailId(Long planDetailId)
|
|
|
|
public int deleteMesProductPlanDetailByPlanDetailId(Long planDetailId) {
|
|
|
|
{
|
|
|
|
|
|
|
|
return mesProductPlanDetailMapper.deleteMesProductPlanDetailByPlanDetailId(planDetailId);
|
|
|
|
return mesProductPlanDetailMapper.deleteMesProductPlanDetailByPlanDetailId(planDetailId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 根据生产计划新增生产计划明细
|
|
|
|
* 根据生产计划新增生产计划明细
|
|
|
|
*
|
|
|
|
*
|
|
|
@ -105,12 +110,208 @@ public class MesProductPlanDetailServiceImpl implements IMesProductPlanDetailSer
|
|
|
|
* @return 结果
|
|
|
|
* @return 结果
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public int insertMesProductPlanDetails(MesProductPlanDetailVo mesProductPlanDetailVo)
|
|
|
|
public int insertMesProductPlanDetails(MesProductPlanDetailVo mesProductPlanDetailVo) {
|
|
|
|
{
|
|
|
|
Long planId = mesProductPlanDetailVo.getPlanId();
|
|
|
|
// mesProductPlanDetail.setCreateTime(DateUtils.getNowDate());
|
|
|
|
MesProductPlan mesProductPlan = mesProductPlanMapper.selectMesProductPlanByPlanId(planId);
|
|
|
|
// return mesProductPlanDetailMapper.insertMesProductPlanDetail(mesProductPlanDetail);
|
|
|
|
|
|
|
|
// MesProductPlan mesProductPlan
|
|
|
|
MesProductPlanDetail queryProductPlanDetail = new MesProductPlanDetail();
|
|
|
|
return 1;
|
|
|
|
queryProductPlanDetail.setPlanId(mesProductPlanDetailVo.getPlanId());
|
|
|
|
|
|
|
|
List<MesProductPlanDetail> mesProductPlanDetails = mesProductPlanDetailMapper.selectMesProductPlanDetailList(queryProductPlanDetail);
|
|
|
|
|
|
|
|
if (mesProductPlanDetails != null && mesProductPlanDetails.size() > 0) {
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
Date currentDate = new Date();
|
|
|
|
|
|
|
|
String userName = SecurityUtils.getUsername();
|
|
|
|
|
|
|
|
List<MesProductPlanDetail> newMesProductPlanDetails = new ArrayList<>();
|
|
|
|
|
|
|
|
BigDecimal planAmount = mesProductPlan.getPlanAmount();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Long planAmountL = planAmount.longValue();
|
|
|
|
|
|
|
|
//todo 大于100条需要拆分,每100条批量保存一次
|
|
|
|
|
|
|
|
for (long i = 0; i < planAmountL; i++) {
|
|
|
|
|
|
|
|
MesProductPlanDetail newMesProductPlanDetail = new MesProductPlanDetail();
|
|
|
|
|
|
|
|
newMesProductPlanDetail.setPlanId(mesProductPlanDetailVo.getPlanId());
|
|
|
|
|
|
|
|
newMesProductPlanDetail.setPlanCode(mesProductPlan.getPlanCode());
|
|
|
|
|
|
|
|
newMesProductPlanDetail.setPlanDetailCode(Seq.getId(Seq.mesProductPlanDetailSeqType, Seq.mesProductPlanDetailCode));
|
|
|
|
|
|
|
|
newMesProductPlanDetail.setPlanDetailStatus(MesConstants.MES_PRODUCT_PLAN_DETAIL_STATUS_TO_START);
|
|
|
|
|
|
|
|
newMesProductPlanDetail.setCreateTime(currentDate);
|
|
|
|
|
|
|
|
newMesProductPlanDetail.setCreateBy(userName);
|
|
|
|
|
|
|
|
newMesProductPlanDetail.setIsFlag("1");
|
|
|
|
|
|
|
|
newMesProductPlanDetails.add(newMesProductPlanDetail);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mesProductPlanMapper.batchMesProductPlanDetail(newMesProductPlanDetails);
|
|
|
|
|
|
|
|
return newMesProductPlanDetails.size();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 开始生产计划明细
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @param mesProductPlanDetail 生产计划明细
|
|
|
|
|
|
|
|
* @return 结果
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
|
|
|
public int startMesProductPlanDetail(MesProductPlanDetail mesProductPlanDetail) {
|
|
|
|
|
|
|
|
MesProductPlanDetail dbProductPlanDetail = mesProductPlanDetailMapper.selectMesProductPlanDetailByPlanDetailId(mesProductPlanDetail.getPlanDetailId());
|
|
|
|
|
|
|
|
if (dbProductPlanDetail.getPlanDetailStatus().equals(MesConstants.MES_PRODUCT_PLAN_DETAIL_STATUS_FINISH)) {
|
|
|
|
|
|
|
|
throw new ServiceException("此生成计划明细已完成");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MesProductPlan dbProductPlan = mesProductPlanMapper.selectMesProductPlanByPlanId(dbProductPlanDetail.getPlanId());
|
|
|
|
|
|
|
|
String planStatus = dbProductPlan.getPlanStatus();
|
|
|
|
|
|
|
|
if (planStatus.equals(MesConstants.MES_PRODUCT_PLAN_STATUS_TO_DISPATCH)) {
|
|
|
|
|
|
|
|
throw new ServiceException("此生产计划未派工,不能开始");
|
|
|
|
|
|
|
|
} else if (planStatus.equals(MesConstants.MES_PRODUCT_PLAN_STATUS_FINISH)) {
|
|
|
|
|
|
|
|
throw new ServiceException("此生产计划已结束");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Date currentDate = new Date();
|
|
|
|
|
|
|
|
String userName = SecurityUtils.getUsername();
|
|
|
|
|
|
|
|
Long userId = SecurityUtils.getUserId();
|
|
|
|
|
|
|
|
if (planStatus.equals(MesConstants.MES_PRODUCT_PLAN_STATUS_DISPATCHED)) {
|
|
|
|
|
|
|
|
dbProductPlan.setRealBeginTime(currentDate);
|
|
|
|
|
|
|
|
dbProductPlan.setPlanStatus(MesConstants.MES_PRODUCT_PLAN_STATUS_STARTED);
|
|
|
|
|
|
|
|
dbProductPlan.setUpdateBy(userName);
|
|
|
|
|
|
|
|
dbProductPlan.setUpdateTime(currentDate);
|
|
|
|
|
|
|
|
mesProductPlanMapper.updateMesProductPlan(dbProductPlan);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mesProductPlanDetail.setPlanDetailStatus(MesConstants.MES_PRODUCT_PLAN_DETAIL_STATUS_STARTED);
|
|
|
|
|
|
|
|
mesProductPlanDetail.setUserId(userId);
|
|
|
|
|
|
|
|
mesProductPlanDetail.setUserName(userName);
|
|
|
|
|
|
|
|
mesProductPlanDetail.setRealBeginTime(currentDate);
|
|
|
|
|
|
|
|
mesProductPlanDetail.setUpdateTime(currentDate);
|
|
|
|
|
|
|
|
mesProductPlanDetail.setUpdateBy(userName);
|
|
|
|
|
|
|
|
return mesProductPlanDetailMapper.updateMesProductPlanDetail(mesProductPlanDetail);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 完成生产计划明细
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @param mesProductPlanDetail 生产计划明细
|
|
|
|
|
|
|
|
* @return 结果
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
|
|
|
public int completeMesProductPlanDetail(MesProductPlanDetail mesProductPlanDetail) {
|
|
|
|
|
|
|
|
MesProductPlanDetail dbProductPlanDetail = mesProductPlanDetailMapper.selectMesProductPlanDetailByPlanDetailId(mesProductPlanDetail.getPlanDetailId());
|
|
|
|
|
|
|
|
String planDetailStatus = dbProductPlanDetail.getPlanDetailStatus();
|
|
|
|
|
|
|
|
if (planDetailStatus.equals(MesConstants.MES_PRODUCT_PLAN_DETAIL_STATUS_TO_START)) {
|
|
|
|
|
|
|
|
throw new ServiceException("此生产计划明细未开始");
|
|
|
|
|
|
|
|
} else if (planDetailStatus.equals(MesConstants.MES_PRODUCT_PLAN_DETAIL_STATUS_FINISH)) {
|
|
|
|
|
|
|
|
throw new ServiceException("此生产计划明细已结束");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MesProductPlan dbProductPlan = mesProductPlanMapper.selectMesProductPlanByPlanId(dbProductPlanDetail.getPlanId());
|
|
|
|
|
|
|
|
String planStatus = dbProductPlan.getPlanStatus();
|
|
|
|
|
|
|
|
if (planStatus.equals(MesConstants.MES_PRODUCT_PLAN_STATUS_TO_DISPATCH)) {
|
|
|
|
|
|
|
|
throw new ServiceException("此生产计划未派工,不能结束");
|
|
|
|
|
|
|
|
} else if (planStatus.equals(MesConstants.MES_PRODUCT_PLAN_STATUS_FINISH)) {
|
|
|
|
|
|
|
|
throw new ServiceException("此生产计划已结束");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//todo:校验生产计划明细校验信息
|
|
|
|
|
|
|
|
Date currentDate = new Date();
|
|
|
|
|
|
|
|
String userName = SecurityUtils.getUsername();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BigDecimal planAmount = dbProductPlan.getPlanAmount();
|
|
|
|
|
|
|
|
BigDecimal complementAmount = dbProductPlan.getCompleteAmount() == null ? BigDecimal.ZERO : dbProductPlan.getCompleteAmount();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
BigDecimal newComplementAmount = complementAmount.add(BigDecimal.ONE);
|
|
|
|
|
|
|
|
if (newComplementAmount.compareTo(planAmount) >= 0) {
|
|
|
|
|
|
|
|
dbProductPlan.setPlanStatus(MesConstants.MES_PRODUCT_PLAN_STATUS_FINISH);
|
|
|
|
|
|
|
|
dbProductPlan.setRealEndTime(currentDate);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
dbProductPlan.setCompleteAmount(newComplementAmount);
|
|
|
|
|
|
|
|
dbProductPlan.setUpdateTime(currentDate);
|
|
|
|
|
|
|
|
dbProductPlan.setUpdateBy(userName);
|
|
|
|
|
|
|
|
mesProductPlanMapper.updateMesProductPlan(dbProductPlan);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mesProductPlanDetail.setUpdateTime(currentDate);
|
|
|
|
|
|
|
|
mesProductPlanDetail.setUpdateBy(userName);
|
|
|
|
|
|
|
|
mesProductPlanDetail.setPlanDetailStatus(MesConstants.MES_PRODUCT_PLAN_DETAIL_STATUS_FINISH);
|
|
|
|
|
|
|
|
mesProductPlanDetail.setRealEndTime(currentDate);
|
|
|
|
|
|
|
|
return mesProductPlanDetailMapper.updateMesProductPlanDetail(mesProductPlanDetail);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 查询最新生产计划明细
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @param mesProductPlanDetail 生产计划明细
|
|
|
|
|
|
|
|
* @return 生产计划明细
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public MesProductPlanDetail selectNewestMesProductPlanDetail(MesProductPlanDetail mesProductPlanDetail) {
|
|
|
|
|
|
|
|
return mesProductPlanDetailMapper.selectNewestMesProductPlanDetail(mesProductPlanDetail);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 开始下一生产计划明细
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @param mesProductPlanDetail 生产计划明细
|
|
|
|
|
|
|
|
* @return MesProductPlanDetail
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
|
|
|
public MesProductPlanDetail startNextMesProductPlanDetail(MesProductPlanDetail mesProductPlanDetail) {
|
|
|
|
|
|
|
|
//根据planId获取最新一条的生产计划明细
|
|
|
|
|
|
|
|
MesProductPlanDetail newestPlanDetail = mesProductPlanDetailMapper.selectNewestMesProductPlanDetail(mesProductPlanDetail);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//如果此计划有最新的计划明细
|
|
|
|
|
|
|
|
if (newestPlanDetail != null) {
|
|
|
|
|
|
|
|
String planDetailStatus = newestPlanDetail.getPlanDetailStatus();
|
|
|
|
|
|
|
|
//判断最新任务明细的状态
|
|
|
|
|
|
|
|
if (!planDetailStatus.equals(MesConstants.MES_PRODUCT_PLAN_DETAIL_STATUS_FINISH)
|
|
|
|
|
|
|
|
&& !planDetailStatus.equals(MesConstants.MES_PRODUCT_PLAN_DETAIL_STATUS_ABNORMAL_FINISH)) {
|
|
|
|
|
|
|
|
//如果不是完成状态则不能开始下一任务明细
|
|
|
|
|
|
|
|
throw new ServiceException("请先完成上一任务明细");
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
Date realEndTime = newestPlanDetail.getRealEndTime();
|
|
|
|
|
|
|
|
//todo:在完成任务后需要过多久才能继续下一任务
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MesProductPlan mesProductPlan = mesProductPlanMapper.selectMesProductPlanByPlanId(mesProductPlanDetail.getPlanId());
|
|
|
|
|
|
|
|
//判断生产计划的状态
|
|
|
|
|
|
|
|
String planStatus = mesProductPlan.getPlanStatus();
|
|
|
|
|
|
|
|
if (planStatus.equals(MesConstants.MES_PRODUCT_PLAN_STATUS_TO_DISPATCH)) {
|
|
|
|
|
|
|
|
throw new ServiceException("还未派工,不能开始");
|
|
|
|
|
|
|
|
} else if (planStatus.equals(MesConstants.MES_PRODUCT_PLAN_STATUS_FINISH)) {
|
|
|
|
|
|
|
|
throw new ServiceException("此生产派工已经结束");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Date currentDate = new Date();
|
|
|
|
|
|
|
|
String userName = SecurityUtils.getUsername();
|
|
|
|
|
|
|
|
Long userId = SecurityUtils.getUserId();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (planStatus.equals(MesConstants.MES_PRODUCT_PLAN_STATUS_DISPATCHED)) {//如果状态是已开始,需要修改计划的状态和开始时间
|
|
|
|
|
|
|
|
mesProductPlan.setPlanStatus(MesConstants.MES_PRODUCT_PLAN_STATUS_STARTED);
|
|
|
|
|
|
|
|
mesProductPlan.setRealBeginTime(currentDate);
|
|
|
|
|
|
|
|
mesProductPlan.setUpdateTime(currentDate);
|
|
|
|
|
|
|
|
mesProductPlan.setUpdateBy(userName);
|
|
|
|
|
|
|
|
mesProductPlanMapper.updateMesProductPlan(mesProductPlan);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mesProductPlanDetail.setPlanDetailStatus(MesConstants.MES_PRODUCT_PLAN_DETAIL_STATUS_STARTED);
|
|
|
|
|
|
|
|
mesProductPlanDetail.setPlanDetailCode(Seq.getId(Seq.mesProductPlanDetailSeqType, Seq.mesProductPlanDetailCode));
|
|
|
|
|
|
|
|
mesProductPlanDetail.setPlanCode(mesProductPlan.getPlanCode());
|
|
|
|
|
|
|
|
mesProductPlanDetail.setPlanDetailStatus(MesConstants.MES_PRODUCT_PLAN_DETAIL_STATUS_STARTED);
|
|
|
|
|
|
|
|
mesProductPlanDetail.setIsFlag("1");
|
|
|
|
|
|
|
|
mesProductPlanDetail.setUserId(userId);
|
|
|
|
|
|
|
|
mesProductPlanDetail.setUserName(userName);
|
|
|
|
|
|
|
|
mesProductPlan.setRealBeginTime(currentDate);
|
|
|
|
|
|
|
|
mesProductPlanDetail.setCreateTime(currentDate);
|
|
|
|
|
|
|
|
mesProductPlanDetail.setCreateBy(userName);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
mesProductPlanDetailMapper.insertMesProductPlanDetail(mesProductPlanDetail);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return mesProductPlanDetail;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|