MES:增加如下接口
通用
1、获取生产计划列表(查询车间派工信息列表表(适用于各楼层各工序))
mes/getProductPlans
2、完成生产计划明细(适用于各工位)
Mes/completeProductPlanDetail

一楼
1、根据生产计划ID查询车间生产计划明细表(适用于1楼、四楼装配工位)
mes/getProductPlanDetails
2、获取仓库列表
GET http://localhost:7108/dev-api/wms/api/getWarehouses?warehouseFloor=1

3、获取物料列表
http://localhost:7018/dev-api/mes/api/getMaterialBoms?ancestors=1
ancestors就是成品ID
4、申请领料
5、生成生产计划明细(适用于1楼、四楼装配工位)
mes/insertProductPlanDetails
6、开始生产计划明细(开始生产计划明细(适用于1楼、四楼装配工位),在生成计划明细时一条一条的开始)
mes/startProductPlanDetail
四楼激光切割、折弯焊接
1、获取最新的生产计划明细,在刚登录页面打开时获取根据工位ID获取,如果点击生产计划则根据生产计划ID获取(适用于四楼激光切割、折弯焊接和五楼)
Mes/getNewestProductPlanDetail
刚进入不传参数
GET http://localhost:7305/api/getNewestProductPlanDetail
点击生产计划时传planId
2、开始下一生产计划明细(开始下一生产计划明细(适用于四楼激光切割、折弯焊接和五楼),开始时才生成一条计划明细)
mes/startNextProductPlanDetail
master
xins 9 months ago
parent 4c34612a58
commit 4f9e132ef3

@ -36,4 +36,17 @@ public class MesConstants {
/** 工单状态9-已删除 */
public static final String DELETE = "9";
/*生产计划明细状态*/
public static final String MES_PRODUCT_PLAN_DETAIL_STATUS_TO_START = "1";//未开始
public static final String MES_PRODUCT_PLAN_DETAIL_STATUS_STARTED = "2";//已开始
public static final String MES_PRODUCT_PLAN_DETAIL_STATUS_FINISH = "3";//已完成
public static final String MES_PRODUCT_PLAN_DETAIL_STATUS_ABNORMAL_FINISH = "9";// 异常完成(校验物料信息不完整)
/*生产计划状态*/
public static final String MES_PRODUCT_PLAN_STATUS_TO_DISPATCH = "0";//未派工
public static final String MES_PRODUCT_PLAN_STATUS_DISPATCHED = "1";//已派工
public static final String MES_PRODUCT_PLAN_STATUS_STARTED = "2";//已开始
public static final String MES_PRODUCT_PLAN_STATUS_FINISH = "3";//已完成
}

@ -15,7 +15,23 @@ public class QmsConstants {
/*检验项目项目属性*/
public static final String QMS_CHECK_PROJECT_PROPERTY_QUALITATIVE = "1";//定性
public static final String QMS_CHECK_PROJECT_PROPERTY_QUANTIFY = "2";//定量;
/*检验方式*/
public static final String QMS_CHECK_MODE = "1";//全检
/*质检结果和质检结果详情检验状态*/
public static final String QMS_CHECK_RESULT_CHECK_STATUS_TO_CHECK="0";//待检验
public static final String QMS_CHECK_RESULT_CHECK_STATUS_CHECKED="1";//检验中
public static final String QMS_CHECK_RESULT_CHECK_STATUS_PASS="2";//质检通过
public static final String QMS_CHECK_RESULT_CHECK_STATUS_FAIL="3";//质检不通过
/**质检结果详情项目信息检验结果*/
public static final String QMS_CHECK_PROJECT_STATUS_PASS = "1";//合格
public static final String QMS_CHECK_PROJECT_STATUS_FAIL = "0";//不合格
}

@ -71,6 +71,16 @@ public class Seq {
// 派工计划编号记录标识
public static final String planCodeCode = "JL";
// 生产计划明细编号记录标识
public static final String mesProductPlanDetailSeqType = "PRODUCTPLANDETAIL";
// 生产计划明细接口序列数
private static AtomicInteger mesProductPlanDetailSeq = new AtomicInteger(1);
// 生产计划明细标识
public static final String mesProductPlanDetailCode = "PD";
/**
*
*
@ -139,6 +149,8 @@ public class Seq {
atomicInt = rawReturnSeq;
}else if (orderCodeSeqType.equals(type)) {
atomicInt = orderCodeSeq;
} else if (mesProductPlanDetailSeqType.equals(type)) {
atomicInt = mesProductPlanDetailSeq;
}else if (dispatchCodeSeqType.equals(type)) {
atomicInt = dispatchCodeSeq;
}else if (planCodeSeqType.equals(type)) {

@ -97,4 +97,15 @@ public enum BusinessType
*/
TRANSFER,
/**
*
*/
START,
/**
*
*/
COMPLETE,
}

@ -43,7 +43,7 @@ public class SecurityUtils
/**
* ID
*/
public static Long getStationd()
public static Long getStationId()
{
return SecurityContextHolder.getStationId();
}

@ -2,14 +2,17 @@ package com.hw.mes.controller;
import com.hw.common.core.web.controller.BaseController;
import com.hw.common.core.web.domain.AjaxResult;
import com.hw.common.core.web.page.TableDataInfo;
import com.hw.common.log.annotation.Log;
import com.hw.common.log.enums.BusinessType;
import com.hw.common.security.annotation.RequiresPermissions;
import com.hw.common.security.utils.SecurityUtils;
import com.hw.mes.domain.MesMaterialBom;
import com.hw.mes.domain.MesProductPlan;
import com.hw.mes.domain.MesProductPlanDetail;
import com.hw.mes.domain.vo.MesProductPlanDetailVo;
import com.hw.mes.service.IMesMaterialBomService;
import com.hw.mes.service.IMesProductOrderService;
import com.hw.mes.service.IMesProductPlanDetailService;
import com.hw.mes.service.IMesProductPlanService;
import org.springframework.beans.factory.annotation.Autowired;
@ -26,8 +29,7 @@ import java.util.List;
*/
@RestController
@RequestMapping("/api")
public class MesApiController extends BaseController
{
public class MesApiController extends BaseController {
@Autowired
private IMesMaterialBomService mesMaterialBomService;
@ -42,44 +44,91 @@ public class MesApiController extends BaseController
*/
// @RequiresPermissions("mes:materialBom:list")
@GetMapping("/getMaterialBoms")
public AjaxResult getMaterialBoms(MesMaterialBom mesMaterialBom)
{
public AjaxResult getMaterialBoms(MesMaterialBom mesMaterialBom) {
String ancestors = mesMaterialBom.getAncestors();
ancestors = "0," + ancestors;
mesMaterialBom.setAncestors(ancestors);
List<MesMaterialBom> list = mesMaterialBomService.selectMesMaterialBomJoinList(mesMaterialBom);
return success(list);
}
/**
*
*
*/
// @RequiresPermissions("mes:materialBom:list")
@GetMapping("/getProductPlans")
public AjaxResult getProductPlans(MesProductPlan mesProductPlan)
{
public TableDataInfo getProductPlans(MesProductPlan mesProductPlan) {
startPage();
List<MesProductPlan> list = productPlanService.selectMesProductPlanJoinList(mesProductPlan);
return success(list);
return getDataTable(list);
}
/**
*
* 1
*/
@Log(title = "生产计划明细", businessType = BusinessType.INSERT)
@PostMapping(("/insertProductPlanDetails"))
public AjaxResult insertProductPlanDetails(@Validated @RequestBody MesProductPlanDetailVo mesProductPlanDetailVo) {
return toAjax(productPlanDetailService.insertMesProductPlanDetails(mesProductPlanDetailVo));
return success(productPlanDetailService.insertMesProductPlanDetails(mesProductPlanDetailVo));
}
/**
* ID
* ID1
*/
// @RequiresPermissions("mes:materialBom:list")
@GetMapping("/getProductPlanDetails")
public AjaxResult getProductPlanDetails(MesProductPlanDetail mesProductPlanDetail)
{
public TableDataInfo getProductPlanDetails(MesProductPlanDetail mesProductPlanDetail) {
startPage();
List<MesProductPlanDetail> list = productPlanDetailService.selectMesProductPlanDetailList(mesProductPlanDetail);
return success(list);
return getDataTable(list);
}
/**
* 1
*/
@Log(title = "生产计划明细", businessType = BusinessType.START)
@PostMapping(("/startProductPlanDetail"))
public AjaxResult startProductPlanDetail(@RequestBody MesProductPlanDetail mesProductPlanDetail) {
return success(productPlanDetailService.startMesProductPlanDetail(mesProductPlanDetail));
}
/**
*
*/
@Log(title = "生产计划明细", businessType = BusinessType.COMPLETE)
@PostMapping(("/completeProductPlanDetail"))
public AjaxResult completeProductPlanDetail(@RequestBody MesProductPlanDetail mesProductPlanDetail) {
return success(productPlanDetailService.completeMesProductPlanDetail(mesProductPlanDetail));
}
/**
* IDID()
*/
// @RequiresPermissions("mes:baseAttachInfo:query")
@GetMapping(value = "/getNewestProductPlanDetail")
public AjaxResult getNewestProductPlanDetail(MesProductPlanDetail queryProductPlanDetail) {
if (queryProductPlanDetail.getPlanId() == null) {
Long stationId = SecurityUtils.getStationId();
queryProductPlanDetail.setStationId(stationId);
}
return success(productPlanDetailService.selectNewestMesProductPlanDetail(queryProductPlanDetail));
}
/**
*
*/
@Log(title = "生产计划明细", businessType = BusinessType.START)
@PostMapping(("/startNextProductPlanDetail"))
public AjaxResult startNextProductPlanDetail(@RequestBody MesProductPlanDetail mesProductPlanDetail) {
return success(productPlanDetailService.startNextMesProductPlanDetail(mesProductPlanDetail));
}
}

@ -179,21 +179,6 @@ public class MesProductOrder extends BaseEntity {
@Excel(name = "物料名称")
private String materialName;
public String getMaterialCode() {
return materialCode;
}
public void setMaterialCode(String materialCode) {
this.materialCode = materialCode;
}
public String getMaterialName() {
return materialName;
}
public void setMaterialName(String materialName) {
this.materialName = materialName;
}
public String getDispatchName() {
return dispatchName;
@ -203,6 +188,8 @@ public class MesProductOrder extends BaseEntity {
this.dispatchName = dispatchName;
}
public Date getPlanDeliveryDate() {
return planDeliveryDate;
}
@ -387,6 +374,22 @@ public class MesProductOrder extends BaseEntity {
return stockLockFlag;
}
public String getMaterialCode() {
return materialCode;
}
public void setMaterialCode(String materialCode) {
this.materialCode = materialCode;
}
public String getMaterialName() {
return materialName;
}
public void setMaterialName(String materialName) {
this.materialName = materialName;
}
@Override
public String toString() {
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)

@ -133,6 +133,11 @@ public class MesProductPlan extends BaseEntity
*/
private Date planDeliveryDate;
/**
*
*/
private String materialCode;
/**
*
*/
@ -402,6 +407,14 @@ public class MesProductPlan extends BaseEntity
this.planDeliveryDate = planDeliveryDate;
}
public String getMaterialCode() {
return materialCode;
}
public void setMaterialCode(String materialCode) {
this.materialCode = materialCode;
}
public String getMaterialName() {
return materialName;
}

@ -9,7 +9,7 @@ import com.hw.common.core.web.domain.BaseEntity;
/**
* mes_product_plan_detail
*
*
* @author xins
* @date 2024-02-21
*/
@ -58,97 +58,107 @@ public class MesProductPlanDetail extends BaseEntity
@Excel(name = "是否标识1-是0-否")
private String isFlag;
public void setPlanDetailId(Long planDetailId)
private Long stationId;
public void setPlanDetailId(Long planDetailId)
{
this.planDetailId = planDetailId;
}
public Long getPlanDetailId()
public Long getPlanDetailId()
{
return planDetailId;
}
public void setPlanDetailCode(String planDetailCode)
public void setPlanDetailCode(String planDetailCode)
{
this.planDetailCode = planDetailCode;
}
public String getPlanDetailCode()
public String getPlanDetailCode()
{
return planDetailCode;
}
public void setPlanId(Long planId)
public void setPlanId(Long planId)
{
this.planId = planId;
}
public Long getPlanId()
public Long getPlanId()
{
return planId;
}
public void setPlanCode(String planCode)
public void setPlanCode(String planCode)
{
this.planCode = planCode;
}
public String getPlanCode()
public String getPlanCode()
{
return planCode;
}
public void setUserId(Long userId)
public void setUserId(Long userId)
{
this.userId = userId;
}
public Long getUserId()
public Long getUserId()
{
return userId;
}
public void setUserName(String userName)
public void setUserName(String userName)
{
this.userName = userName;
}
public String getUserName()
public String getUserName()
{
return userName;
}
public void setRealBeginTime(Date realBeginTime)
public void setRealBeginTime(Date realBeginTime)
{
this.realBeginTime = realBeginTime;
}
public Date getRealBeginTime()
public Date getRealBeginTime()
{
return realBeginTime;
}
public void setRealEndTime(Date realEndTime)
public void setRealEndTime(Date realEndTime)
{
this.realEndTime = realEndTime;
}
public Date getRealEndTime()
public Date getRealEndTime()
{
return realEndTime;
}
public void setPlanDetailStatus(String planDetailStatus)
public void setPlanDetailStatus(String planDetailStatus)
{
this.planDetailStatus = planDetailStatus;
}
public String getPlanDetailStatus()
public String getPlanDetailStatus()
{
return planDetailStatus;
}
public void setIsFlag(String isFlag)
public void setIsFlag(String isFlag)
{
this.isFlag = isFlag;
}
public String getIsFlag()
public String getIsFlag()
{
return isFlag;
}
public Long getStationId() {
return stationId;
}
public void setStationId(Long stationId) {
this.stationId = stationId;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)

@ -19,16 +19,5 @@ public class MesProductPlanDetailVo {
@NotNull(message = "生产计划ID必须输入")
private Long planId;
//成品批次
@NotNull(message = "物料ID必须输入")
private Long materialId;
//成品批次
@NotNull(message = "物料BomID必须输入")
private Long materialBomId;
//成品批次
@NotBlank(message = "计划数量必须输入")
private String planAmount;
}

@ -58,4 +58,14 @@ public interface MesProductPlanDetailMapper
* @return
*/
public int deleteMesProductPlanDetailByPlanDetailIds(Long[] planDetailIds);
/**
*
*
* @param mesProductPlanDetail
* @return
*/
public MesProductPlanDetail selectNewestMesProductPlanDetail(MesProductPlanDetail mesProductPlanDetail);
}

@ -1,6 +1,9 @@
package com.hw.mes.service;
import java.util.List;
import com.hw.common.core.utils.DateUtils;
import com.hw.mes.domain.MesProductPlan;
import com.hw.mes.domain.MesProductPlanDetail;
import com.hw.mes.domain.vo.MesProductPlanDetailVo;
@ -10,8 +13,7 @@ import com.hw.mes.domain.vo.MesProductPlanDetailVo;
* @author xins
* @date 2024-02-21
*/
public interface IMesProductPlanDetailService
{
public interface IMesProductPlanDetailService {
/**
*
*
@ -61,9 +63,6 @@ public interface IMesProductPlanDetailService
public int deleteMesProductPlanDetailByPlanDetailId(Long planDetailId);
/**
*
*
@ -71,4 +70,38 @@ public interface IMesProductPlanDetailService
* @return
*/
public int insertMesProductPlanDetails(MesProductPlanDetailVo mesProductPlanDetailVo);
/**
*
*
* @param mesProductPlanDetail
* @return
*/
public int startMesProductPlanDetail(MesProductPlanDetail mesProductPlanDetail);
/**
*
*
* @param mesProductPlanDetail
* @return
*/
public int completeMesProductPlanDetail(MesProductPlanDetail mesProductPlanDetail);
/**
*
*
* @param mesProductPlanDetail
* @return
*/
public MesProductPlanDetail selectNewestMesProductPlanDetail(MesProductPlanDetail mesProductPlanDetail);
/**
*
*
* @param mesProductPlanDetail
* @return MesProductPlanDetail
*/
public MesProductPlanDetail startNextMesProductPlanDetail(MesProductPlanDetail mesProductPlanDetail);
}

@ -1,13 +1,24 @@
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.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 org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
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 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
@ -16,11 +27,13 @@ import com.hw.mes.service.IMesProductPlanDetailService;
* @date 2024-02-21
*/
@Service
public class MesProductPlanDetailServiceImpl implements IMesProductPlanDetailService
{
public class MesProductPlanDetailServiceImpl implements IMesProductPlanDetailService {
@Autowired
private MesProductPlanDetailMapper mesProductPlanDetailMapper;
@Autowired
private MesProductPlanMapper mesProductPlanMapper;
/**
*
*
@ -28,8 +41,7 @@ public class MesProductPlanDetailServiceImpl implements IMesProductPlanDetailSer
* @return
*/
@Override
public MesProductPlanDetail selectMesProductPlanDetailByPlanDetailId(Long planDetailId)
{
public MesProductPlanDetail selectMesProductPlanDetailByPlanDetailId(Long planDetailId) {
return mesProductPlanDetailMapper.selectMesProductPlanDetailByPlanDetailId(planDetailId);
}
@ -40,8 +52,7 @@ public class MesProductPlanDetailServiceImpl implements IMesProductPlanDetailSer
* @return
*/
@Override
public List<MesProductPlanDetail> selectMesProductPlanDetailList(MesProductPlanDetail mesProductPlanDetail)
{
public List<MesProductPlanDetail> selectMesProductPlanDetailList(MesProductPlanDetail mesProductPlanDetail) {
return mesProductPlanDetailMapper.selectMesProductPlanDetailList(mesProductPlanDetail);
}
@ -52,8 +63,7 @@ public class MesProductPlanDetailServiceImpl implements IMesProductPlanDetailSer
* @return
*/
@Override
public int insertMesProductPlanDetail(MesProductPlanDetail mesProductPlanDetail)
{
public int insertMesProductPlanDetail(MesProductPlanDetail mesProductPlanDetail) {
mesProductPlanDetail.setCreateTime(DateUtils.getNowDate());
return mesProductPlanDetailMapper.insertMesProductPlanDetail(mesProductPlanDetail);
}
@ -65,8 +75,7 @@ public class MesProductPlanDetailServiceImpl implements IMesProductPlanDetailSer
* @return
*/
@Override
public int updateMesProductPlanDetail(MesProductPlanDetail mesProductPlanDetail)
{
public int updateMesProductPlanDetail(MesProductPlanDetail mesProductPlanDetail) {
mesProductPlanDetail.setUpdateTime(DateUtils.getNowDate());
return mesProductPlanDetailMapper.updateMesProductPlanDetail(mesProductPlanDetail);
}
@ -78,8 +87,7 @@ public class MesProductPlanDetailServiceImpl implements IMesProductPlanDetailSer
* @return
*/
@Override
public int deleteMesProductPlanDetailByPlanDetailIds(Long[] planDetailIds)
{
public int deleteMesProductPlanDetailByPlanDetailIds(Long[] planDetailIds) {
return mesProductPlanDetailMapper.deleteMesProductPlanDetailByPlanDetailIds(planDetailIds);
}
@ -90,14 +98,11 @@ public class MesProductPlanDetailServiceImpl implements IMesProductPlanDetailSer
* @return
*/
@Override
public int deleteMesProductPlanDetailByPlanDetailId(Long planDetailId)
{
public int deleteMesProductPlanDetailByPlanDetailId(Long planDetailId) {
return mesProductPlanDetailMapper.deleteMesProductPlanDetailByPlanDetailId(planDetailId);
}
/**
*
*
@ -105,12 +110,208 @@ public class MesProductPlanDetailServiceImpl implements IMesProductPlanDetailSer
* @return
*/
@Override
public int insertMesProductPlanDetails(MesProductPlanDetailVo mesProductPlanDetailVo)
{
// mesProductPlanDetail.setCreateTime(DateUtils.getNowDate());
// return mesProductPlanDetailMapper.insertMesProductPlanDetail(mesProductPlanDetail);
// MesProductPlan mesProductPlan
return 1;
public int insertMesProductPlanDetails(MesProductPlanDetailVo mesProductPlanDetailVo) {
Long planId = mesProductPlanDetailVo.getPlanId();
MesProductPlan mesProductPlan = mesProductPlanMapper.selectMesProductPlanByPlanId(planId);
MesProductPlanDetail queryProductPlanDetail = new MesProductPlanDetail();
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;
}
}

@ -200,8 +200,10 @@ public class MesProductPlanServiceImpl implements IMesProductPlanService {
*/
@Override
public List<MesProductPlan> selectMesProductPlanJoinList(MesProductPlan mesProductPlan) {
Long stationId = SecurityUtils.getStationd();
System.out.println("stationId: " + stationId);
Long stationId = SecurityUtils.getStationId();
stationId = 1L;
//todo stationId
mesProductPlan.setStationId(stationId);
return mesProductPlanMapper.selectMesProductPlanJoinList(mesProductPlan);
}

@ -23,6 +23,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="lastOutstockDate" column="last_outstock_date" />
<result property="planCode" column="plan_code" />
<result property="planDetailCode" column="plan_detail_code" />
<result property="saleOrderId" column="sale_order_id" />
<result property="saleorderCode" column="saleorder_code" />
<result property="projectNo" column="project_no" />
<result property="serialNumber" column="serial_number" />
@ -35,7 +36,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</resultMap>
<sql id="selectMesBaseBarcodeInfoVo">
select barcode_id, print_time, print_person, batch_flag, barcode_type, barcode_info, batch_code, pallet_info_code, material_id, manufacturer_id, amount, machine_name, po_no, production_date, accepted_date, last_outstock_date, plan_code, plan_detail_code, saleorder_code, project_no, serial_number, remark, bind_status, bind_by, bind_time, update_by, update_time from mes_base_barcode_info
select barcode_id, print_time, print_person, batch_flag, barcode_type, barcode_info, batch_code, pallet_info_code, material_id, manufacturer_id, amount, machine_name, po_no, production_date, accepted_date, last_outstock_date, plan_code, plan_detail_code, sale_order_id, saleorder_code, project_no, serial_number, remark, bind_status, bind_by, bind_time, update_by, update_time from mes_base_barcode_info
</sql>
<select id="selectMesBaseBarcodeInfoList" parameterType="MesBaseBarcodeInfo" resultMap="MesBaseBarcodeInfoResult">
@ -92,6 +93,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="lastOutstockDate != null">last_outstock_date,</if>
<if test="planCode != null">plan_code,</if>
<if test="planDetailCode != null">plan_detail_code,</if>
<if test="saleOrderId != null">sale_order_id,</if>
<if test="saleorderCode != null">saleorder_code,</if>
<if test="projectNo != null">project_no,</if>
<if test="serialNumber != null">serial_number,</if>
@ -120,6 +122,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="lastOutstockDate != null">#{lastOutstockDate},</if>
<if test="planCode != null">#{planCode},</if>
<if test="planDetailCode != null">#{planDetailCode},</if>
<if test="saleOrderId != null">#{saleOrderId},</if>
<if test="saleorderCode != null">#{saleorderCode},</if>
<if test="projectNo != null">#{projectNo},</if>
<if test="serialNumber != null">#{serialNumber},</if>

@ -223,4 +223,4 @@
#{productOrderId}
</foreach>
</delete>
</mapper>
</mapper>

@ -20,6 +20,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="createTime" column="create_time" />
<result property="updateBy" column="update_by" />
<result property="updateTime" column="update_time" />
<result property="stationId" column="station_id" />
</resultMap>
<sql id="selectMesProductPlanDetailVo">
@ -113,4 +114,23 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{planDetailId}
</foreach>
</delete>
<select id="selectNewestMesProductPlanDetail" parameterType="MesProductPlanDetail" resultMap="MesProductPlanDetailResult">
select plan_detail_id, plan_detail_code, plan_id, plan_code, user_id, user_name,
real_begin_time, real_end_time, plan_detail_status
from mes_product_plan_detail mppd
<where>
<if test="planId != null "> and plan_id = #{planId}</if>
<if test="planId == null "> and exists (select 1 from mes_product_plan mpp where mppd.plan_id=mpp.plan_id and mpp.station_id=#{stationId})</if>
</where>
order by plan_detail_id desc limit 1
</select>
</mapper>

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.hw.mes.mapper.MesProductPlanMapper">
<resultMap type="MesProductPlan" id="MesProductPlanResult">
@ -36,101 +36,62 @@
<result property="updateBy" column="update_by"/>
<result property="updateTime" column="update_time"/>
<result property="planDeliveryDate" column="plan_delivery_date"/>
<result property="materialCode" column="material_code" />
<result property="materialName" column="material_name"/>
<result property="processName" column="process_name"/>
<result property="stationName" column="station_name"/>
</resultMap>
<resultMap id="MesProductPlanMesProductPlanDetailResult" type="MesProductPlan" extends="MesProductPlanResult">
<collection property="mesProductPlanDetailList" notNullColumn="sub_plan_detail_id" javaType="java.util.List"
resultMap="MesProductPlanDetailResult"/>
<collection property="mesProductPlanDetailList" notNullColumn="sub_plan_detail_id" javaType="java.util.List" resultMap="MesProductPlanDetailResult" />
</resultMap>
<resultMap type="MesProductPlanDetail" id="MesProductPlanDetailResult">
<result property="planDetailId" column="sub_plan_detail_id"/>
<result property="planDetailCode" column="sub_plan_detail_code"/>
<result property="planId" column="sub_plan_id"/>
<result property="planCode" column="sub_plan_code"/>
<result property="userId" column="sub_user_id"/>
<result property="userName" column="sub_user_name"/>
<result property="realBeginTime" column="sub_real_begin_time"/>
<result property="realEndTime" column="sub_real_end_time"/>
<result property="planDetailStatus" column="sub_plan_detail_status"/>
<result property="isFlag" column="sub_is_flag"/>
<result property="remark" column="sub_remark"/>
<result property="createBy" column="sub_create_by"/>
<result property="createTime" column="sub_create_time"/>
<result property="updateBy" column="sub_update_by"/>
<result property="updateTime" column="sub_update_time"/>
<result property="planDetailId" column="sub_plan_detail_id" />
<result property="planDetailCode" column="sub_plan_detail_code" />
<result property="planId" column="sub_plan_id" />
<result property="planCode" column="sub_plan_code" />
<result property="userId" column="sub_user_id" />
<result property="userName" column="sub_user_name" />
<result property="realBeginTime" column="sub_real_begin_time" />
<result property="realEndTime" column="sub_real_end_time" />
<result property="planDetailStatus" column="sub_plan_detail_status" />
<result property="isFlag" column="sub_is_flag" />
<result property="remark" column="sub_remark" />
<result property="createBy" column="sub_create_by" />
<result property="createTime" column="sub_create_time" />
<result property="updateBy" column="sub_update_by" />
<result property="updateTime" column="sub_update_time" />
</resultMap>
<sql id="selectMesProductPlanVo">
select mpp.plan_id,
mpp.product_order_id,
po.order_code,
mpp.plan_code,
mpp.dispatch_code,
mpp.material_id,
mi.material_name,
mpp.material_bom_id,
concat(mb.material_name, '-', mb.material_bom_desc) materialBomName,
mpp.process_id,
bpi.process_name,
mpp.process_order,
mpp.last_process_id,
bp2.process_name lastProcessName,
mpp.station_id,
bsi.station_name,
mpp.user_id,
mpp.production_time,
mpp.plan_amount,
mpp.complete_amount,
mpp.plan_begin_time,
mpp.plan_end_time,
mpp.real_begin_time,
mpp.real_end_time,
mpp.attach_id,
mpp.plan_status,
mpp.is_flag,
mpp.remark,
mpp.create_by,
mpp.create_time,
mpp.update_by,
mpp.update_time
from mes_product_plan mpp
left join mes_base_process_info bpi on bpi.process_id = mpp.process_id
left join mes_base_station_info bsi on bsi.station_id = mpp.station_id
left join mes_base_material_info mi on mi.material_id = mpp.material_id
left join mes_material_bom mb on mb.material_bom_id = mpp.material_bom_id
left join mes_base_process_info bp2 on bp2.process_id = mpp.last_process_id
left join mes_product_order po on po.product_order_id = mpp.product_order_id
select plan_id, product_order_id, plan_code, dispatch_code, material_id, material_bom_id, process_id, process_order, last_process_id, station_id, user_id, production_time, plan_amount, complete_amount, plan_begin_time, plan_end_time, real_begin_time, real_end_time, attach_id, plan_status, is_flag, remark, create_by, create_time, update_by, update_time from mes_product_plan
</sql>
<select id="selectMesProductPlanList" parameterType="MesProductPlan" resultMap="MesProductPlanResult">
<include refid="selectMesProductPlanVo"/>
<where>
<if test="productOrderId != null ">and mpp.product_order_id = #{productOrderId}</if>
<if test="planCode != null and planCode != ''">and mpp.plan_code = #{planCode}</if>
<if test="dispatchCode != null and dispatchCode != ''">and mpp.dispatch_code = #{dispatchCode}</if>
<if test="materialId != null ">and mpp.material_id = #{materialId}</if>
<if test="materialBomId != null ">and mpp.material_bom_id = #{materialBomId}</if>
<if test="processId != null ">and mpp.process_id = #{processId}</if>
<if test="processOrder != null ">and mpp.process_order = #{processOrder}</if>
<if test="lastProcessId != null ">and mpp.last_process_id = #{lastProcessId}</if>
<if test="stationId != null ">and mpp.station_id = #{stationId}</if>
<if test="userId != null ">and mpp.user_id = #{userId}</if>
<if test="productionTime != null ">and mpp.production_time = #{productionTime}</if>
<if test="planAmount != null ">and mpp.plan_amount = #{planAmount}</if>
<if test="completeAmount != null ">and mpp.complete_amount = #{completeAmount}</if>
<if test="planBeginTime != null ">and mpp.plan_begin_time = #{planBeginTime}</if>
<if test="planEndTime != null ">and mpp.plan_end_time = #{planEndTime}</if>
<if test="realBeginTime != null ">and mpp.real_begin_time = #{realBeginTime}</if>
<if test="realEndTime != null ">and mpp.real_end_time = #{realEndTime}</if>
<if test="attachId != null and attachId != ''">and mpp.attach_id = #{attachId}</if>
<if test="planStatus != null and planStatus != ''">and mpp.plan_status = #{planStatus}</if>
<if test="isFlag != null and isFlag != ''">and mpp.is_flag = #{isFlag}</if>
<if test="productOrderId != null "> and product_order_id = #{productOrderId}</if>
<if test="planCode != null and planCode != ''"> and plan_code = #{planCode}</if>
<if test="dispatchCode != null and dispatchCode != ''"> and dispatch_code = #{dispatchCode}</if>
<if test="materialId != null "> and material_id = #{materialId}</if>
<if test="materialBomId != null "> and material_bom_id = #{materialBomId}</if>
<if test="processId != null "> and process_id = #{processId}</if>
<if test="processOrder != null "> and process_order = #{processOrder}</if>
<if test="lastProcessId != null "> and last_process_id = #{lastProcessId}</if>
<if test="stationId != null "> and station_id = #{stationId}</if>
<if test="userId != null "> and user_id = #{userId}</if>
<if test="productionTime != null "> and production_time = #{productionTime}</if>
<if test="planAmount != null "> and plan_amount = #{planAmount}</if>
<if test="completeAmount != null "> and complete_amount = #{completeAmount}</if>
<if test="planBeginTime != null "> and plan_begin_time = #{planBeginTime}</if>
<if test="planEndTime != null "> and plan_end_time = #{planEndTime}</if>
<if test="realBeginTime != null "> and real_begin_time = #{realBeginTime}</if>
<if test="realEndTime != null "> and real_end_time = #{realEndTime}</if>
<if test="attachId != null and attachId != ''"> and attach_id = #{attachId}</if>
<if test="planStatus != null and planStatus != ''"> and plan_status = #{planStatus}</if>
<if test="isFlag != null and isFlag != ''"> and is_flag = #{isFlag}</if>
</where>
order by mpp.dispatch_code
</select>
<select id="selectMesProductPlanByPlanId" parameterType="Long" resultMap="MesProductPlanMesProductPlanDetailResult">
@ -297,28 +258,33 @@
</delete>
<insert id="batchMesProductPlanDetail">
insert into mes_product_plan_detail( plan_detail_id, plan_detail_code, plan_id, plan_code, user_id, user_name,
real_begin_time, real_end_time, plan_detail_status, is_flag, remark, create_by, create_time, update_by,
update_time) values
<foreach item="item" index="index" collection="list" separator=",">
( #{item.planDetailId}, #{item.planDetailCode}, #{item.planId}, #{item.planCode}, #{item.userId},
#{item.userName}, #{item.realBeginTime}, #{item.realEndTime}, #{item.planDetailStatus}, #{item.isFlag},
#{item.remark}, #{item.createBy}, #{item.createTime}, #{item.updateBy}, #{item.updateTime})
insert into mes_product_plan_detail( plan_detail_id, plan_detail_code, plan_id, plan_code, user_id, user_name, real_begin_time, real_end_time, plan_detail_status, is_flag, remark, create_by, create_time, update_by, update_time) values
<foreach item="item" index="index" collection="list" separator=",">
( #{item.planDetailId}, #{item.planDetailCode}, #{item.planId}, #{item.planCode}, #{item.userId}, #{item.userName}, #{item.realBeginTime}, #{item.realEndTime}, #{item.planDetailStatus}, #{item.isFlag}, #{item.remark}, #{item.createBy}, #{item.createTime}, #{item.updateBy}, #{item.updateTime})
</foreach>
</insert>
<select id="selectMesProductPlanJoinList" parameterType="MesProductPlan" resultMap="MesProductPlanResult">
select mpp.plan_id, mpp.product_order_id, mpp.plan_code, mpp.dispatch_code, mpp.material_id,
mpp.material_bom_id, mpp.process_id, mpp.process_order, mpp.last_process_id,
mpp.station_id, mpp.plan_amount, mpp.complete_amount, mpp.plan_begin_time, mpp.plan_end_time,
mpp.real_begin_time, mpp.real_end_time,
mpp.attach_id, mpp.plan_status, mpo.plan_delivery_date,mbmi.material_name
from mes_product_plan mpp left join mes_product_order mpo on mpp.product_order_id = mpo.product_order_id
left join mes_base_material_info mbmi on mpp.material_id=mbmi.material_id
select mpp.plan_id, mpp.product_order_id, mpp.plan_code, mpp.dispatch_code, mpp.material_id, mpp.material_bom_id, mpp.process_id, mpp.process_order, mpp.last_process_id,
mpp.station_id, mpp.plan_amount, mpp.complete_amount, mpp.plan_begin_time, mpp.plan_end_time, mpp.real_begin_time, mpp.real_end_time,
mpp.attach_id, mpp.plan_status, mpo.plan_delivery_date,mbmi.material_code,mbmi.material_name
from mes_product_plan mpp left join mes_product_order mpo on mpp.product_order_id = mpo.product_order_id
left join mes_base_material_info mbmi on mpp.material_id=mbmi.material_id
<where>
<if test="stationId != null ">and mpp.station_id = #{stationId}</if>
<if test="planStatus != null and planStatus != ''">and mpp.plan_status = #{planStatus}</if>
<if test="stationId != null "> and mpp.station_id = #{stationId}</if>
<if test="planStatus != null and planStatus != ''"> and mpp.plan_status = #{planStatus}</if>
</where>
</select>

Loading…
Cancel
Save