|
|
|
@ -7,7 +7,6 @@ import com.hw.common.core.utils.StringUtils;
|
|
|
|
|
import com.hw.common.core.utils.uuid.Seq;
|
|
|
|
|
import com.hw.common.security.utils.SecurityUtils;
|
|
|
|
|
import com.hw.mes.api.domain.MesBaseBarcodeInfo;
|
|
|
|
|
import com.hw.mes.config.MesConfig;
|
|
|
|
|
import com.hw.mes.domain.*;
|
|
|
|
|
import com.hw.mes.domain.vo.MesProductPlanDetailVo;
|
|
|
|
|
import com.hw.mes.mapper.*;
|
|
|
|
@ -28,6 +27,8 @@ import java.util.stream.Collectors;
|
|
|
|
|
* @author xins
|
|
|
|
|
* @date 2024-02-21
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Service
|
|
|
|
|
public class MesProductPlanDetailServiceImpl implements IMesProductPlanDetailService {
|
|
|
|
|
@Autowired
|
|
|
|
@ -221,8 +222,17 @@ public class MesProductPlanDetailServiceImpl implements IMesProductPlanDetailSer
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
public int completeMesProductPlanDetail(MesProductPlanDetail mesProductPlanDetail) {
|
|
|
|
|
Long planDetailId = mesProductPlanDetail.getPlanDetailId();
|
|
|
|
|
MesProductPlanDetail dbProductPlanDetail = mesProductPlanDetailMapper.
|
|
|
|
|
selectMesProductPlanDetailByPlanDetailId(planDetailId);
|
|
|
|
|
MesProductPlanDetail dbProductPlanDetail = new MesProductPlanDetail();
|
|
|
|
|
if (planDetailId != null) {
|
|
|
|
|
dbProductPlanDetail = mesProductPlanDetailMapper.
|
|
|
|
|
selectMesProductPlanDetailByPlanDetailId(planDetailId);
|
|
|
|
|
} else if (StringUtils.isNotEmpty(mesProductPlanDetail.getMaterialBarcode())) {//适用于5楼组装区域,PDA操作
|
|
|
|
|
dbProductPlanDetail = mesProductPlanDetailMapper.selectMesProductPlanDetailByMaterialBarcode(mesProductPlanDetail.getMaterialBarcode());
|
|
|
|
|
}
|
|
|
|
|
if (dbProductPlanDetail == null) {
|
|
|
|
|
throw new ServiceException("未找到生产明细");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String planDetailStatus = dbProductPlanDetail.getPlanDetailStatus();
|
|
|
|
|
if (planDetailStatus.equals(MesConstants.MES_PRODUCT_PLAN_DETAIL_STATUS_TO_START)) {
|
|
|
|
|
throw new ServiceException("此生产明细未开始");
|
|
|
|
@ -232,6 +242,10 @@ public class MesProductPlanDetailServiceImpl implements IMesProductPlanDetailSer
|
|
|
|
|
|
|
|
|
|
Long planId = dbProductPlanDetail.getPlanId();
|
|
|
|
|
MesProductPlan dbProductPlan = mesProductPlanMapper.selectMesProductPlanByPlanId(planId);
|
|
|
|
|
if(!dbProductPlan.getUserId().equals(SecurityUtils.getUserId())){
|
|
|
|
|
throw new ServiceException("此派工信息没有派工到您");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String planStatus = dbProductPlan.getPlanStatus();
|
|
|
|
|
if (planStatus.equals(MesConstants.MES_PRODUCT_PLAN_STATUS_TO_DISPATCH)) {
|
|
|
|
|
throw new ServiceException("还未派工,不能结束");
|
|
|
|
@ -376,63 +390,70 @@ public class MesProductPlanDetailServiceImpl implements IMesProductPlanDetailSer
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String planDetailCode = Seq.getId(Seq.mesProductPlanDetailSeqType, Seq.mesProductPlanDetailCode);
|
|
|
|
|
//五楼装配工位要扫码开始
|
|
|
|
|
if (startType.equals(MesConstants.MES_START_TYPE_FIFTH_FLOOR_ASSEMBLE)) {
|
|
|
|
|
String materialBarcode = mesProductPlanDetail.getMaterialBarcode();
|
|
|
|
|
MesBaseBarcodeInfo mesBaseBarcodeInfo = mesBaseBarcodeInfoMapper.selectMesBaseBarcodeInfoByBarcodeInfo(materialBarcode);
|
|
|
|
|
if (mesBaseBarcodeInfo == null) {
|
|
|
|
|
throw new ServiceException("条码有误");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!mesBaseBarcodeInfo.getBarcodeType().equals(MesConstants.MES_BARCODE_TYPE_BIND)) {
|
|
|
|
|
throw new ServiceException("请扫描背板或门板条码开始");
|
|
|
|
|
MesProductPlan mesProductPlan = new MesProductPlan();
|
|
|
|
|
|
|
|
|
|
if (startType.equals(MesConstants.MES_START_TYPE_FIFTH_FLOOR_INSTALL)) {//五楼组装工序
|
|
|
|
|
//在拆分区拿柜体拆分时,需要打印配对码,然后跟柜体码绑定
|
|
|
|
|
//在从4楼到5楼接驳位时,需要根据4楼的成品码重新打印原材料条码
|
|
|
|
|
MesBaseBarcodeInfo mesBaseBarcodeInfo = mesBaseBarcodeInfoMapper.selectMesBaseBarcodeInfoByBarcodeInfo(
|
|
|
|
|
mesProductPlanDetail.getMaterialBarcode());
|
|
|
|
|
if (mesBaseBarcodeInfo == null) {
|
|
|
|
|
throw new ServiceException("无派工任务");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (StringUtils.isEmpty(mesBaseBarcodeInfo.getBindBarcode())) {
|
|
|
|
|
throw new ServiceException("此条码有误,未绑定任何柜体");
|
|
|
|
|
String planCode = mesBaseBarcodeInfo.getPlanCode();
|
|
|
|
|
if (StringUtils.isEmpty(planCode)) {
|
|
|
|
|
throw new ServiceException("无派工任务");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (StringUtils.isNotEmpty(mesBaseBarcodeInfo.getTransferredPlanDetailCode())) {
|
|
|
|
|
throw new ServiceException("此条码已经扫描使用过,不能再次使用");
|
|
|
|
|
MesProductPlanDetail dbProductPlanDetail = mesProductPlanDetailMapper.selectMesProductPlanDetailByMaterialBarcode(
|
|
|
|
|
mesProductPlanDetail.getMaterialBarcode());
|
|
|
|
|
if (dbProductPlanDetail != null) {
|
|
|
|
|
throw new ServiceException("已经开始,无须重复开始");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//校验此条码是否是同一派工单
|
|
|
|
|
MesProductPlan barcodeProductPlan = mesProductPlanMapper.selectOnlyMesProductPlanByPlanCode(mesBaseBarcodeInfo.getPlanCode());
|
|
|
|
|
if (barcodeProductPlan == null) {
|
|
|
|
|
throw new ServiceException("条码有误,没有相关派工");
|
|
|
|
|
MesProductPlan barcodeProductPlan = mesProductPlanMapper.selectOnlyMesProductPlanByPlanCode(planCode);
|
|
|
|
|
if(barcodeProductPlan==null){
|
|
|
|
|
throw new ServiceException("无派工信息");
|
|
|
|
|
}
|
|
|
|
|
if (!barcodeProductPlan.getDispatchCode().equals(mesProductPlan.getDispatchCode())) {
|
|
|
|
|
throw new ServiceException("此条码的派工单号为:" + barcodeProductPlan.getDispatchCode() + ",与此派工单号不符");
|
|
|
|
|
MesProductPlan queryProductPlan = new MesProductPlan();
|
|
|
|
|
queryProductPlan.setDispatchCode(barcodeProductPlan.getDispatchCode());
|
|
|
|
|
queryProductPlan.setFinalProcessFlag(MesConstants.MES_FINAL_PROCESS_FLAG_YES);
|
|
|
|
|
List<MesProductPlan> mesProductPlans = mesProductPlanMapper.selectOnlyMesProductPlans(queryProductPlan);
|
|
|
|
|
if(mesProductPlans==null || mesProductPlans.isEmpty()){
|
|
|
|
|
throw new ServiceException("没有派工信息");
|
|
|
|
|
}
|
|
|
|
|
mesProductPlan = mesProductPlans.get(0);
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
//五楼装配工序要扫码开始
|
|
|
|
|
mesProductPlan = mesProductPlanMapper.selectMesProductPlanByPlanId(mesProductPlanDetail.getPlanId());
|
|
|
|
|
if (startType.equals(MesConstants.MES_START_TYPE_FIFTH_FLOOR_ASSEMBLE)) {
|
|
|
|
|
this.start5thFloorAssemble(mesProductPlanDetail.getMaterialBarcode(), mesProductPlan.getDispatchCode(), planDetailCode, userName, currentDate);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// MesMaterialAssignInfo queryMaterialAssignInfo = new MesMaterialAssignInfo();
|
|
|
|
|
// queryMaterialAssignInfo.setMaterialBarcode(materialBarcode);
|
|
|
|
|
// List<MesMaterialAssignInfo> mesMaterialAssignInfoList = mesMaterialAssignInfoMapper.selectMesMaterialAssignInfoList(queryMaterialAssignInfo);
|
|
|
|
|
// if (mesMaterialAssignInfoList == null || mesMaterialAssignInfoList.isEmpty()) {
|
|
|
|
|
// throw new ServiceException("此物料条码还没下发到工位");
|
|
|
|
|
// }
|
|
|
|
|
if (mesProductPlan == null) {
|
|
|
|
|
throw new ServiceException("无派工信息");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
mesBaseBarcodeInfo.setTransferredPlanDetailCode(planDetailCode);
|
|
|
|
|
mesBaseBarcodeInfo.setUpdateTime(currentDate);
|
|
|
|
|
mesBaseBarcodeInfo.setUpdateBy(userName);
|
|
|
|
|
mesBaseBarcodeInfoMapper.updateMesBaseBarcodeInfo(mesBaseBarcodeInfo);
|
|
|
|
|
if(!mesProductPlan.getUserId().equals(SecurityUtils.getUserId())){
|
|
|
|
|
throw new ServiceException("此派工信息没有派工到您");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//判断生产计划的状态
|
|
|
|
|
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("此生产派工已经结束");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -448,6 +469,7 @@ public class MesProductPlanDetailServiceImpl implements IMesProductPlanDetailSer
|
|
|
|
|
mesProductPlanMapper.updateMesProductPlan(mesProductPlan);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
mesProductPlanDetail.setPlanId(mesProductPlan.getPlanId());
|
|
|
|
|
mesProductPlanDetail.setPlanDetailStatus(MesConstants.MES_PRODUCT_PLAN_DETAIL_STATUS_STARTED);
|
|
|
|
|
mesProductPlanDetail.setPlanDetailCode(planDetailCode);
|
|
|
|
|
mesProductPlanDetail.setPlanCode(mesProductPlan.getPlanCode());
|
|
|
|
@ -465,6 +487,74 @@ public class MesProductPlanDetailServiceImpl implements IMesProductPlanDetailSer
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void start5thFloorAssemble(String materialBarcode, String dispatchCode, String planDetailCode, String userName, Date currentDate) {
|
|
|
|
|
MesBaseBarcodeInfo mesBaseBarcodeInfo = mesBaseBarcodeInfoMapper.selectMesBaseBarcodeInfoByBarcodeInfo(materialBarcode);
|
|
|
|
|
if (mesBaseBarcodeInfo == null) {
|
|
|
|
|
throw new ServiceException("条码有误");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!mesBaseBarcodeInfo.getBarcodeType().equals(MesConstants.MES_BARCODE_TYPE_BIND)) {
|
|
|
|
|
throw new ServiceException("请扫描背板或门板条码开始");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (StringUtils.isEmpty(mesBaseBarcodeInfo.getBindBarcode())) {
|
|
|
|
|
throw new ServiceException("此条码有误,未绑定任何柜体");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (StringUtils.isNotEmpty(mesBaseBarcodeInfo.getTransferredPlanDetailCode())) {
|
|
|
|
|
throw new ServiceException("此条码已经扫描使用过,不能再次使用");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//校验此条码是否是同一派工单
|
|
|
|
|
MesProductPlan barcodeProductPlan = mesProductPlanMapper.selectOnlyMesProductPlanByPlanCode(mesBaseBarcodeInfo.getPlanCode());
|
|
|
|
|
if (barcodeProductPlan == null) {
|
|
|
|
|
throw new ServiceException("条码有误,没有相关派工");
|
|
|
|
|
}
|
|
|
|
|
if (!barcodeProductPlan.getDispatchCode().equals(dispatchCode)) {
|
|
|
|
|
throw new ServiceException("此条码的派工单号为:" + barcodeProductPlan.getDispatchCode() + ",与此派工单号不符");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// MesMaterialAssignInfo queryMaterialAssignInfo = new MesMaterialAssignInfo();
|
|
|
|
|
// queryMaterialAssignInfo.setMaterialBarcode(materialBarcode);
|
|
|
|
|
// List<MesMaterialAssignInfo> mesMaterialAssignInfoList = mesMaterialAssignInfoMapper.selectMesMaterialAssignInfoList(queryMaterialAssignInfo);
|
|
|
|
|
// if (mesMaterialAssignInfoList == null || mesMaterialAssignInfoList.isEmpty()) {
|
|
|
|
|
// throw new ServiceException("此物料条码还没下发到工位");
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
mesBaseBarcodeInfo.setTransferredPlanDetailCode(planDetailCode);
|
|
|
|
|
mesBaseBarcodeInfo.setUpdateTime(currentDate);
|
|
|
|
|
mesBaseBarcodeInfo.setUpdateBy(userName);
|
|
|
|
|
mesBaseBarcodeInfoMapper.updateMesBaseBarcodeInfo(mesBaseBarcodeInfo);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 五楼组装区PDA根据组装出库开始工单明细
|
|
|
|
|
*
|
|
|
|
|
* @param materialBarcode
|
|
|
|
|
*/
|
|
|
|
|
public void start5thFloorInstall(String materialBarcode) {
|
|
|
|
|
//在拆分区拿柜体拆分时,需要打印配对码,然后跟柜体码绑定
|
|
|
|
|
//在从4楼到5楼接驳位时,需要根据4楼的成品码重新打印原材料条码
|
|
|
|
|
MesBaseBarcodeInfo mesBaseBarcodeInfo = mesBaseBarcodeInfoMapper.selectMesBaseBarcodeInfoByBarcodeInfo(materialBarcode);
|
|
|
|
|
if (mesBaseBarcodeInfo == null) {
|
|
|
|
|
throw new ServiceException("无派工任务");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String planCode = mesBaseBarcodeInfo.getPlanCode();
|
|
|
|
|
if (StringUtils.isEmpty(planCode)) {
|
|
|
|
|
throw new ServiceException("无派工任务");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
MesProductPlanDetail mesProductPlanDetail = mesProductPlanDetailMapper.selectMesProductPlanDetailByMaterialBarcode(materialBarcode);
|
|
|
|
|
if (mesProductPlanDetail != null) {
|
|
|
|
|
throw new ServiceException("已经开始,无须重复开始");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void startProductOrder(MesProductPlan productPlan, Date currentDate, String userName) {
|
|
|
|
|
MesProductOrder productOrder = mesProductOrderMapper.selectMesProductOrderByProductOrderId(productPlan.getProductOrderId());
|
|
|
|
|
if (productOrder == null) {
|
|
|
|
@ -488,4 +578,5 @@ public class MesProductPlanDetailServiceImpl implements IMesProductPlanDetailSer
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|