mes:
生产派工:从按工位派工改为按照人来派工,整体逻辑完全修改
master
xs 7 months ago
parent 1bac66fa52
commit acce22d755

@ -12,5 +12,7 @@ public class PrinterVo {
public String printType;
public List<List<PrintContentVo>> printContents;
// public List<List<PrintContentVo>> printContents;
public List<PrintContentVo> printContentVos;
}

@ -1,12 +1,15 @@
package com.hw.mes.controller;
import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;
import com.hw.common.core.constant.MesConstants;
import com.hw.mes.domain.MesBaseRouteProcess;
import com.hw.mes.domain.MesProductOrder;
import com.hw.mes.service.IMesProductOrderService;
import com.hw.mes.domain.vo.MesProductPlanDeleteVo;
import com.hw.mes.domain.vo.MesProductPlanEditVo;
import com.hw.mes.service.IMesBaseProcessInfoService;
import com.hw.mes.service.IMesBaseRouteProcessService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
@ -39,6 +42,12 @@ public class MesProductPlanController extends BaseController
@Autowired
private IMesProductPlanService mesProductPlanService;
@Autowired
private IMesBaseProcessInfoService mesBaseProcessInfoService;
@Autowired
private IMesBaseRouteProcessService mesBaseRouteProcessService;
/**
*
*/
@ -56,10 +65,10 @@ public class MesProductPlanController extends BaseController
* @param mesProductPlan
* @return
*/
@GetMapping("/getProductPlan")
public AjaxResult getProductPlan(MesProductPlan mesProductPlan)
@GetMapping("/selectProductPlans")
public AjaxResult selectProductPlans(MesProductPlan mesProductPlan)
{
List<MesProductPlan> list = mesProductPlanService.selectMesProductPlanList(mesProductPlan);
List<MesProductPlan> list = mesProductPlanService.selectMesProductPlanJoinProcessList(mesProductPlan);
return success(list);
}
@ -135,9 +144,9 @@ public class MesProductPlanController extends BaseController
@RequiresPermissions("mes:productplan:add")
@Log(title = "生产派工", businessType = BusinessType.INSERT)
@PostMapping("/orderAddMesProductPlanList")
public AjaxResult orderAddMesProductPlanList(@RequestBody List<MesProductPlan> mesProductPlanList)
public AjaxResult orderAddMesProductPlanList(@RequestBody MesProductPlanEditVo productPlanEditVo)
{
return toAjax(mesProductPlanService.orderAddMesProductPlanList(mesProductPlanList));
return toAjax(mesProductPlanService.orderAddMesProductPlanList(productPlanEditVo));
}
/**
@ -171,4 +180,38 @@ public class MesProductPlanController extends BaseController
return toAjax(mesProductPlanService.productOrderRecall(mesProductOrder));
}
/**
*
* @param mesBaseRouteProcess
* @return
*/
@GetMapping(value = "/getBaseRouteProcesses")
public AjaxResult getBaseRouteProcesses(MesBaseRouteProcess mesBaseRouteProcess)
{
return success(mesBaseRouteProcessService.selectMesBaseRouteProcessJoinList(mesBaseRouteProcess));
}
/**
* 线
* @param routeId 线ID
* @return
*/
@GetMapping(value = "/getProcessUsers/{routeId}")
public AjaxResult getProcessUsers(@PathVariable("routeId") Long routeId)
{
return success(mesBaseProcessInfoService.getProcessUsersByRouteId(routeId));
}
/**
*
* @param mesProductPlanDeleteVo VO
* @return
*/
@PostMapping(value = "/deleteProductPlansByDispatchCode")
public AjaxResult deleteProductPlansByDispatchCode(@RequestBody MesProductPlanDeleteVo mesProductPlanDeleteVo)
{
return success(mesProductPlanService.deleteProductPlansByDispatchCode(mesProductPlanDeleteVo));
}
}

@ -51,6 +51,8 @@ public class MesBaseProcessInfo extends BaseEntity {
@Excel(name = "激活标识")
private String activeFlag;
private Long processOrder;
/**
* 线
*/
@ -123,6 +125,14 @@ public class MesBaseProcessInfo extends BaseEntity {
this.mesBaseProcessProdlineList = mesBaseProcessProdlineList;
}
public Long getProcessOrder() {
return processOrder;
}
public void setProcessOrder(Long processOrder) {
this.processOrder = processOrder;
}
@Override
public String toString() {
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)

@ -25,6 +25,9 @@ public class MesBaseProcessUser extends BaseEntity
@Excel(name = "用户名称")
private String userName;
private Long routeId;
public void setProcessId(Long processId)
{
this.processId = processId;
@ -53,6 +56,14 @@ public class MesBaseProcessUser extends BaseEntity
return userName;
}
public Long getRouteId() {
return routeId;
}
public void setRouteId(Long routeId) {
this.routeId = routeId;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)

@ -37,6 +37,13 @@ public class MesBaseRouteProcess extends BaseEntity {
@Excel(name = "工艺路线顺序")
private Long processOrder;
private String processName;
private String processType;
private Long productionTime;
public void setRouteProcessId(Long routeProcessId) {
this.routeProcessId = routeProcessId;
}
@ -69,6 +76,30 @@ public class MesBaseRouteProcess extends BaseEntity {
return processOrder;
}
public String getProcessName() {
return processName;
}
public void setProcessName(String processName) {
this.processName = processName;
}
public String getProcessType() {
return processType;
}
public void setProcessType(String processType) {
this.processType = processType;
}
public Long getProductionTime() {
return productionTime;
}
public void setProductionTime(Long productionTime) {
this.productionTime = productionTime;
}
@Override
public String toString() {
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)

@ -3,6 +3,8 @@ package com.hw.mes.domain;
import java.math.BigDecimal;
import java.util.List;
import java.util.Date;
import java.util.Objects;
import com.fasterxml.jackson.annotation.JsonFormat;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
@ -94,6 +96,9 @@ public class MesProductPlan extends BaseEntity
@Excel(name = "用户ID")
private Long userId;
private String userName;
/** 单位生产时间(单位s) */
@Excel(name = "单位生产时间(单位s)")
private Long productionTime;
@ -171,6 +176,8 @@ public class MesProductPlan extends BaseEntity
private BigDecimal dispatchedAmount;
private String processType;
public Long getSaleOrderId() {
return saleOrderId;
@ -345,6 +352,15 @@ public class MesProductPlan extends BaseEntity
{
return userId;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public void setProductionTime(Long productionTime)
{
this.productionTime = productionTime;
@ -479,6 +495,14 @@ public class MesProductPlan extends BaseEntity
this.materialName = materialName;
}
public String getProcessType() {
return processType;
}
public void setProcessType(String processType) {
this.processType = processType;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
@ -511,4 +535,17 @@ public class MesProductPlan extends BaseEntity
.append("mesProductPlanDetailList", getMesProductPlanDetailList())
.toString();
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
MesProductPlan that = (MesProductPlan) o;
return Objects.equals(planId, that.planId);
}
@Override
public int hashCode() {
return Objects.hash(planId);
}
}

@ -0,0 +1,33 @@
package com.hw.mes.domain.vo;
import com.hw.mes.domain.MesProductPlan;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.util.List;
/**
* @Description: VO
* @ClassName: ProductPlanDeleteVo
* @Author : xins
* @Date :2024-07-12 15:04
* @Version :1.0
*/
@Data
public class MesProductPlanDeleteVo {
//派工数量
@NotNull(message = "生产工单ID必须输入")
private Long productOrderId;
//派工单号
@NotBlank(message = "派工单号必须输入")
private String dispatchCode;
//派工数量
@NotNull(message = "派工数量必须输入")
private BigDecimal dispatchAmount;
}

@ -0,0 +1,34 @@
package com.hw.mes.domain.vo;
import com.hw.mes.domain.MesProductPlan;
import lombok.Data;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
import java.util.List;
/**
* @Description: VO
* @ClassName: ProductPlanEditVo
* @Author : xins
* @Date :2024-07-11 10:18
* @Version :1.0
*/
@Data
public class MesProductPlanEditVo {
//生产工单ID
@NotNull(message = "生产工单Id必须输入")
private Long productOrderId;
//此次生产派工数量
private BigDecimal dispatchAmount;
//保存的生产计划
@NotNull(message = "没有修改的生产派工提交")
private List<MesProductPlan> mesProductPlanList;
//待删除的生产计划ID
private Long[] toDeletedPlanIds;
}

@ -0,0 +1,61 @@
package com.hw.mes.mapper;
import java.util.List;
import com.hw.mes.domain.MesBaseProcessUser;
/**
* Mapper
*
* @author xins
* @date 2024-07-09
*/
public interface MesBaseProcessUserMapper
{
/**
*
*
* @param processId
* @return
*/
public MesBaseProcessUser selectMesBaseProcessUserByProcessId(Long processId);
/**
*
*
* @param mesBaseProcessUser
* @return
*/
public List<MesBaseProcessUser> selectMesBaseProcessUserList(MesBaseProcessUser mesBaseProcessUser);
/**
*
*
* @param mesBaseProcessUser
* @return
*/
public int insertMesBaseProcessUser(MesBaseProcessUser mesBaseProcessUser);
/**
*
*
* @param mesBaseProcessUser
* @return
*/
public int updateMesBaseProcessUser(MesBaseProcessUser mesBaseProcessUser);
/**
*
*
* @param processId
* @return
*/
public int deleteMesBaseProcessUserByProcessId(Long processId);
/**
*
*
* @param processIds
* @return
*/
public int deleteMesBaseProcessUserByProcessIds(Long[] processIds);
}

@ -58,4 +58,14 @@ public interface MesBaseRouteProcessMapper
* @return
*/
public int deleteMesBaseRouteProcessByRouteProcessIds(Long[] routeProcessIds);
/**
* 线Join mes_base_process_info
*
* @param mesBaseRouteProcess 线
* @return 线
*/
public List<MesBaseRouteProcess> selectMesBaseRouteProcessJoinList(MesBaseRouteProcess mesBaseRouteProcess);
}

@ -104,4 +104,26 @@ public interface MesProductPlanMapper
* @return
*/
public MesProductPlan selectOnlyMesProductPlanByPlanCode(String planCode);
/**
* ,Join process
*
* @param mesProductPlan
* @return
*/
public List<MesProductPlan> selectMesProductPlanJoinProcessList(MesProductPlan mesProductPlan);
/**
*
*
* @param dispatchCode
* @return
*/
public int deleteMesProductPlanByDispatchCode(String dispatchCode);
}

@ -53,6 +53,12 @@ public interface IMesBaseBarcodeInfoService
*/
public int generateNoPurchaseRawBarcode(MesBaseBarcodeInfo mesBaseBarcodeInfo);
/**
*
* @param mesBaseBarcodeInfo
*/
public int generateRegularRawBarcode(MesBaseBarcodeInfo mesBaseBarcodeInfo);
/**
*
*

@ -2,6 +2,8 @@ package com.hw.mes.service;
import java.util.List;
import com.hw.mes.domain.MesBaseProcessInfo;
import com.hw.mes.domain.MesBaseProcessUser;
import org.springframework.transaction.annotation.Transactional;
/**
* Service
@ -73,4 +75,12 @@ public interface IMesBaseProcessInfoService
* @return
*/
public int deleteMesBaseProcessInfoByProcessId(Long processId);
/**
* 线ID
*
* @param routeId
*/
public List<MesBaseProcessUser> getProcessUsersByRouteId(Long routeId);
}

@ -58,4 +58,13 @@ public interface IMesBaseRouteProcessService
* @return
*/
public int deleteMesBaseRouteProcessByRouteProcessId(Long routeProcessId);
/**
* 线,Join mes_base_process
*
* @param mesBaseRouteProcess 线
* @return 线
*/
public List<MesBaseRouteProcess> selectMesBaseRouteProcessJoinList(MesBaseRouteProcess mesBaseRouteProcess);
}

@ -9,6 +9,8 @@ import com.hw.mes.domain.MesProductOrder;
import com.hw.mes.domain.MesProductPlan;
import com.hw.mes.domain.vo.MesAssignTaskVo;
import com.hw.mes.domain.vo.MesMaterialScanVo;
import com.hw.mes.domain.vo.MesProductPlanDeleteVo;
import com.hw.mes.domain.vo.MesProductPlanEditVo;
import org.springframework.transaction.annotation.Transactional;
/**
@ -35,6 +37,16 @@ public interface IMesProductPlanService
*/
public List<MesProductPlan> selectMesProductPlanList(MesProductPlan mesProductPlan);
/**
* ,join process
*
* @param mesProductPlan
* @return
*/
public List<MesProductPlan> selectMesProductPlanJoinProcessList(MesProductPlan mesProductPlan);
/**
*
*
@ -86,10 +98,10 @@ public interface IMesProductPlanService
/**
* List
*
* @param mesProductPlanList
* @return
* @param mesProductPlanEditVo VO
* @return
*/
public int orderAddMesProductPlanList(List<MesProductPlan> mesProductPlanList);
public int orderAddMesProductPlanList(MesProductPlanEditVo mesProductPlanEditVo);
/**
@ -137,4 +149,13 @@ public interface IMesProductPlanService
* @return
*/
List<HashMap<String, Object>> selectMaterialInstallationCircumstance(Map hashMap);
/**
*
*
* @param mesProductPlanDeleteVo VO
* @return
*/
public int deleteProductPlansByDispatchCode(MesProductPlanDeleteVo mesProductPlanDeleteVo);
}

@ -5,38 +5,45 @@ import java.util.List;
import com.hw.common.core.exception.ServiceException;
import com.hw.common.core.utils.DateUtils;
import com.hw.common.security.utils.SecurityUtils;
import com.hw.mes.domain.MesBaseProcessUser;
import com.hw.mes.domain.*;
import com.hw.mes.mapper.MesBaseProcessUserMapper;
import com.hw.mes.mapper.MesBaseRouteProcessMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import com.hw.common.core.utils.StringUtils;
import org.springframework.transaction.annotation.Transactional;
import com.hw.mes.domain.MesBaseProcessProdline;
import com.hw.mes.mapper.MesBaseProcessInfoMapper;
import com.hw.mes.domain.MesBaseProcessInfo;
import com.hw.mes.service.IMesBaseProcessInfoService;
/**
* Service
*
*
* @author Yinq
* @date 2024-01-24
*/
@Service
public class MesBaseProcessInfoServiceImpl implements IMesBaseProcessInfoService
{
public class MesBaseProcessInfoServiceImpl implements IMesBaseProcessInfoService {
@Autowired
private MesBaseProcessInfoMapper mesBaseProcessInfoMapper;
@Autowired
private MesBaseRouteProcessMapper mesBaseRouteProcessMapper;
@Autowired
private MesBaseProcessUserMapper mesBaseProcessUserMapper;
/**
*
*
*
* @param processId
* @return
*/
@Override
public MesBaseProcessInfo selectMesBaseProcessInfoByProcessId(Long processId)
{
public MesBaseProcessInfo selectMesBaseProcessInfoByProcessId(Long processId) {
return mesBaseProcessInfoMapper.selectMesBaseProcessInfoByProcessId(processId);
}
@ -47,33 +54,30 @@ public class MesBaseProcessInfoServiceImpl implements IMesBaseProcessInfoService
* @return
*/
@Override
public MesBaseProcessInfo selectMesBaseProcessInfoUserByProcessId(Long processId)
{
public MesBaseProcessInfo selectMesBaseProcessInfoUserByProcessId(Long processId) {
return mesBaseProcessInfoMapper.selectMesBaseProcessInfoUserByProcessId(processId);
}
/**
*
*
*
* @param mesBaseProcessInfo
* @return
*/
@Override
public List<MesBaseProcessInfo> selectMesBaseProcessInfoList(MesBaseProcessInfo mesBaseProcessInfo)
{
public List<MesBaseProcessInfo> selectMesBaseProcessInfoList(MesBaseProcessInfo mesBaseProcessInfo) {
return mesBaseProcessInfoMapper.selectMesBaseProcessInfoList(mesBaseProcessInfo);
}
/**
*
*
*
* @param mesBaseProcessInfo
* @return
*/
@Transactional
@Override
public int insertMesBaseProcessInfo(MesBaseProcessInfo mesBaseProcessInfo)
{
public int insertMesBaseProcessInfo(MesBaseProcessInfo mesBaseProcessInfo) {
mesBaseProcessInfo.setCreateTime(DateUtils.getNowDate());
int rows = mesBaseProcessInfoMapper.insertMesBaseProcessInfo(mesBaseProcessInfo);
//insertMesBaseProcessProdline(mesBaseProcessInfo);
@ -82,14 +86,13 @@ public class MesBaseProcessInfoServiceImpl implements IMesBaseProcessInfoService
/**
*
*
*
* @param mesBaseProcessInfo
* @return
*/
@Transactional
@Override
public int updateMesBaseProcessInfo(MesBaseProcessInfo mesBaseProcessInfo)
{
public int updateMesBaseProcessInfo(MesBaseProcessInfo mesBaseProcessInfo) {
mesBaseProcessInfo.setUpdateTime(DateUtils.getNowDate());
mesBaseProcessInfoMapper.deleteMesBaseProcessProdlineByProcessId(mesBaseProcessInfo.getProcessId());
try {
@ -108,8 +111,7 @@ public class MesBaseProcessInfoServiceImpl implements IMesBaseProcessInfoService
*/
@Transactional
@Override
public int updateMesBaseProcessInfoUser(MesBaseProcessInfo mesBaseProcessInfo)
{
public int updateMesBaseProcessInfoUser(MesBaseProcessInfo mesBaseProcessInfo) {
mesBaseProcessInfo.setUpdateTime(DateUtils.getNowDate());
mesBaseProcessInfoMapper.deleteMesBaseProcessUserByProcessId(mesBaseProcessInfo.getProcessId());
try {
@ -122,53 +124,47 @@ public class MesBaseProcessInfoServiceImpl implements IMesBaseProcessInfoService
/**
*
*
*
* @param processIds
* @return
*/
@Transactional
@Override
public int deleteMesBaseProcessInfoByProcessIds(Long[] processIds)
{
public int deleteMesBaseProcessInfoByProcessIds(Long[] processIds) {
mesBaseProcessInfoMapper.deleteMesBaseProcessProdlineByProcessIds(processIds);
return mesBaseProcessInfoMapper.deleteMesBaseProcessInfoByProcessIds(processIds);
}
/**
*
*
*
* @param processId
* @return
*/
@Transactional
@Override
public int deleteMesBaseProcessInfoByProcessId(Long processId)
{
public int deleteMesBaseProcessInfoByProcessId(Long processId) {
mesBaseProcessInfoMapper.deleteMesBaseProcessProdlineByProcessId(processId);
return mesBaseProcessInfoMapper.deleteMesBaseProcessInfoByProcessId(processId);
}
/**
* 线
*
*
* @param mesBaseProcessInfo
*/
public void insertMesBaseProcessProdline(MesBaseProcessInfo mesBaseProcessInfo)
{
public void insertMesBaseProcessProdline(MesBaseProcessInfo mesBaseProcessInfo) {
List<MesBaseProcessProdline> mesBaseProcessProdlineList = mesBaseProcessInfo.getMesBaseProcessProdlineList();
Long processId = mesBaseProcessInfo.getProcessId();
if (StringUtils.isNotNull(mesBaseProcessProdlineList))
{
if (StringUtils.isNotNull(mesBaseProcessProdlineList)) {
List<MesBaseProcessProdline> list = new ArrayList<MesBaseProcessProdline>();
for (MesBaseProcessProdline mesBaseProcessProdline : mesBaseProcessProdlineList)
{
for (MesBaseProcessProdline mesBaseProcessProdline : mesBaseProcessProdlineList) {
mesBaseProcessProdline.setProcessId(processId);
mesBaseProcessProdline.setCreateBy(SecurityUtils.getUsername());
mesBaseProcessProdline.setCreateTime(DateUtils.getNowDate());
list.add(mesBaseProcessProdline);
}
if (list.size() > 0)
{
if (list.size() > 0) {
mesBaseProcessInfoMapper.batchMesBaseProcessProdline(list);
}
}
@ -179,22 +175,34 @@ public class MesBaseProcessInfoServiceImpl implements IMesBaseProcessInfoService
*
* @param mesBaseProcessInfo
*/
public void insertMesBaseProcessUser(MesBaseProcessInfo mesBaseProcessInfo)
{
public void insertMesBaseProcessUser(MesBaseProcessInfo mesBaseProcessInfo) {
List<MesBaseProcessUser> mesBaseProcessUserList = mesBaseProcessInfo.getMesBaseProcessUserList();
Long processId = mesBaseProcessInfo.getProcessId();
if (StringUtils.isNotNull(mesBaseProcessUserList))
{
if (StringUtils.isNotNull(mesBaseProcessUserList)) {
List<MesBaseProcessUser> list = new ArrayList<>();
for (MesBaseProcessUser mesBaseProcessUser : mesBaseProcessUserList)
{
for (MesBaseProcessUser mesBaseProcessUser : mesBaseProcessUserList) {
mesBaseProcessUser.setProcessId(processId);
list.add(mesBaseProcessUser);
}
if (list.size() > 0)
{
if (list.size() > 0) {
mesBaseProcessInfoMapper.batchMesBaseProcessUser(list);
}
}
}
/**
* 线ID
*
* @param routeId
*/
@Override
public List<MesBaseProcessUser> getProcessUsersByRouteId(Long routeId) {
MesBaseProcessUser queryBaseProcessUser = new MesBaseProcessUser();
queryBaseProcessUser.setRouteId(routeId);
return mesBaseProcessUserMapper.selectMesBaseProcessUserList(queryBaseProcessUser);
}
}

@ -93,4 +93,18 @@ public class MesBaseRouteProcessServiceImpl implements IMesBaseRouteProcessServi
{
return mesBaseRouteProcessMapper.deleteMesBaseRouteProcessByRouteProcessId(routeProcessId);
}
/**
* 线,Join mes_base_process
*
* @param mesBaseRouteProcess 线
* @return 线
*/
@Override
public List<MesBaseRouteProcess> selectMesBaseRouteProcessJoinList(MesBaseRouteProcess mesBaseRouteProcess)
{
return mesBaseRouteProcessMapper.selectMesBaseRouteProcessJoinList(mesBaseRouteProcess);
}
}

@ -17,6 +17,8 @@ import com.hw.mes.config.MesConfig;
import com.hw.mes.domain.*;
import com.hw.mes.domain.vo.MesAssignTaskVo;
import com.hw.mes.domain.vo.MesMaterialScanVo;
import com.hw.mes.domain.vo.MesProductPlanDeleteVo;
import com.hw.mes.domain.vo.MesProductPlanEditVo;
import com.hw.mes.mapper.*;
import com.hw.mes.service.IMesBaseAttachInfoService;
import com.hw.mes.service.IMesProductOrderService;
@ -63,6 +65,9 @@ public class MesProductPlanServiceImpl implements IMesProductPlanService {
@Autowired
private MesMaterialAssignInfoMapper mesMaterialAssignInfoMapper;
@Autowired
private MesProductOrderMapper mesProductOrderMapper;
@Autowired
private MesConfig mesConfig;
@ -88,6 +93,32 @@ public class MesProductPlanServiceImpl implements IMesProductPlanService {
return mesProductPlanMapper.selectMesProductPlanList(mesProductPlan);
}
/**
* ,join process
*
* @param mesProductPlan
* @return
*/
@Override
public List<MesProductPlan> selectMesProductPlanJoinProcessList(MesProductPlan mesProductPlan) {
return mesProductPlanMapper.selectMesProductPlanJoinProcessList(mesProductPlan);
}
/**
*
*
* @param mesProductPlan
* @return
*/
// @Override
// public List<MesProductPlan> selectMesProductPlanGroupList(MesProductPlan mesProductPlan) {
// List<MesProductPlan> productPlans = mesProductPlanMapper.selectMesProductPlanList(mesProductPlan);
// return "";
// }
/**
*
*
@ -98,24 +129,12 @@ public class MesProductPlanServiceImpl implements IMesProductPlanService {
@Override
public int insertMesProductPlan(MesProductPlan mesProductPlan) {
if (mesProductPlan.getDispatchAmount().compareTo(BigDecimal.ZERO) > 0) {
if (mesProductPlan.getProcessId().equals(42L)) {//折弯工序,计划数量可以跟派工数量不相同
if (mesProductPlan.getPlanAmount() == null) {
throw new ServiceException("四楼折弯工序请输入计划数量");
}
} else {//非折弯工序,计划数量需与派工数量相同
mesProductPlan.setPlanAmount(mesProductPlan.getDispatchAmount());
}
mesProductPlan.setPlanAmount(mesProductPlan.getDispatchAmount());
mesProductPlan.setCreateBy(SecurityUtils.getUsername());
mesProductPlan.setCreateTime(DateUtils.getNowDate());
mesProductPlan.setPlanCode(Seq.getId(Seq.planCodeSeqType, Seq.planCodeCode));
int rows = mesProductPlanMapper.insertMesProductPlan(mesProductPlan);
//更新工单已派工数量
MesProductOrder mesProductOrder = new MesProductOrder();
mesProductOrder.setProductOrderId(mesProductPlan.getProductOrderId());
mesProductOrder.setDispatchAmount(mesProductPlan.getDispatchedAmount());
mesProductOrderService.updateMesProductOrder(mesProductOrder);
// insertMesProductPlanDetail(mesProductPlan);
return rows;
}
return 0;
@ -197,15 +216,55 @@ public class MesProductPlanServiceImpl implements IMesProductPlanService {
/**
* List
*
* @param mesProductPlanList
* @param mesProductPlanEditVo VO
* @return
*/
@Override
@Transactional(rollbackFor = Exception.class)
public int orderAddMesProductPlanList(List<MesProductPlan> mesProductPlanList) {
public int orderAddMesProductPlanList(MesProductPlanEditVo mesProductPlanEditVo) {
String userName = SecurityUtils.getUsername();
Date currentDate = new Date();
List<MesProductPlan> mesProductPlanList = mesProductPlanEditVo.getMesProductPlanList();
Long[] toDeletedPlanIds = mesProductPlanEditVo.getToDeletedPlanIds();
if (toDeletedPlanIds != null && toDeletedPlanIds.length > 0) {
for (Long toDeletedPlanId : toDeletedPlanIds) {
MesProductPlan toDeletedProductPlan = mesProductPlanMapper.selectMesProductPlanByPlanId(toDeletedPlanId);
if (!toDeletedProductPlan.getPlanStatus().equals(MesConstants.MES_PRODUCT_PLAN_STATUS_TO_DISPATCH)
&& !toDeletedProductPlan.getPlanStatus().equals(MesConstants.MES_PRODUCT_PLAN_STATUS_DISPATCHED)) {
throw new ServiceException("有派工已经开始,不能删除");
}
}
mesProductPlanMapper.deleteMesProductPlanByPlanIds(toDeletedPlanIds);
}
for (MesProductPlan mesProductPlan : mesProductPlanList) {
this.insertMesProductPlan(mesProductPlan);
Long planId = mesProductPlan.getPlanId();
if (planId != null) {
mesProductPlan.setUpdateBy(userName);
mesProductPlan.setUpdateTime(currentDate);
mesProductPlanMapper.updateMesProductPlan(mesProductPlan);
} else {
mesProductPlan.setPlanAmount(mesProductPlan.getDispatchAmount());
mesProductPlan.setCreateBy(SecurityUtils.getUsername());
mesProductPlan.setCreateTime(DateUtils.getNowDate());
mesProductPlan.setPlanCode(Seq.getId(Seq.planCodeSeqType, Seq.planCodeCode));
mesProductPlanMapper.insertMesProductPlan(mesProductPlan);
}
}
//更新工单已派工数量
MesProductOrder mesProductOrder = mesProductOrderMapper.selectMesProductOrderByProductOrderId(mesProductPlanEditVo.getProductOrderId());
BigDecimal dispatchedAmount = mesProductOrder.getDispatchAmount() == null ? BigDecimal.ZERO : mesProductOrder.getDispatchAmount();
BigDecimal planAmount = mesProductOrder.getPlanAmount();
BigDecimal updateDispatchAmount = dispatchedAmount.add(mesProductPlanEditVo.getDispatchAmount());
if (updateDispatchAmount.compareTo(planAmount) > 0) {
throw new ServiceException("派工数量大于计划数量,请重新派工");
}
mesProductOrder.setDispatchAmount(updateDispatchAmount);
mesProductOrder.setUpdateTime(currentDate);
mesProductOrder.setUpdateBy(userName);
mesProductOrderService.updateMesProductOrder(mesProductOrder);
return 1;
}
@ -361,7 +420,7 @@ public class MesProductPlanServiceImpl implements IMesProductPlanService {
}
String barcodeType = baseBarcodeInfo.getBarcodeType();
if(!barcodeType.equals(MesConstants.MES_BARCODE_TYPE_RAW)){
if (!barcodeType.equals(MesConstants.MES_BARCODE_TYPE_RAW)) {
throw new ServiceException("此条码为非原材料条码");
}
@ -498,6 +557,42 @@ public class MesProductPlanServiceImpl implements IMesProductPlanService {
}
/**
*
*
* @param mesProductPlanDeleteVo VO
* @return
*/
@Override
@Transactional(rollbackFor = Exception.class)
public int deleteProductPlansByDispatchCode(MesProductPlanDeleteVo mesProductPlanDeleteVo) {
String dispatchCode = mesProductPlanDeleteVo.getDispatchCode();
BigDecimal dispatchAmount = mesProductPlanDeleteVo.getDispatchAmount();
MesProductPlan queryProductPlan = new MesProductPlan();
queryProductPlan.setDispatchCode(dispatchCode);
List<MesProductPlan> mesProductPlans = mesProductPlanMapper.selectMesProductPlanList(queryProductPlan);
if (mesProductPlans == null || mesProductPlans.isEmpty()) {
throw new ServiceException("此派工单已经删除");
}
List<MesProductPlan> filterProductPlans = mesProductPlans.stream().filter
(mesProductPlan -> !mesProductPlan.getPlanStatus().equals(MesConstants.MES_PRODUCT_PLAN_STATUS_TO_DISPATCH) &&
!mesProductPlan.getPlanStatus().equals(MesConstants.MES_PRODUCT_PLAN_STATUS_DISPATCHED)).collect(Collectors.toList());
if (!filterProductPlans.isEmpty()) {
throw new ServiceException("此派工单已经有工序开始,不能删除");
}
mesProductPlanMapper.deleteMesProductPlanByDispatchCode(dispatchCode);
MesProductOrder mesProductOrder = mesProductOrderService.selectMesProductOrderByProductOrderId(mesProductPlanDeleteVo.getProductOrderId());
BigDecimal dispatchedAmount = mesProductOrder.getDispatchAmount();
mesProductOrder.setDispatchAmount(dispatchedAmount.subtract(dispatchAmount));
mesProductOrder.setUpdateBy(SecurityUtils.getUsername());
mesProductOrder.setUpdateTime(new Date());
return mesProductOrderMapper.updateMesProductOrder(mesProductOrder);
}
// public String executeAssignTaskResultTask() {
// ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor();
// boolean running = true;

@ -119,6 +119,7 @@
<if test="bindTime != null ">and bbi.bind_time = #{bindTime}</if>
<if test="updateBy != null and updateBy != ''">and bbi.update_by = #{updateBy}</if>
<if test="updateTime != null ">and bbi.update_time = #{updateTime}</if>
<if test="barcodeTypeStr != null and barcodeTypeStr != ''">and bbi.barcode_type in (${barcodeTypeStr})</if>
</where>
order by bbi.barcode_id desc
</select>

@ -0,0 +1,73 @@
<?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">
<mapper namespace="com.hw.mes.mapper.MesBaseProcessUserMapper">
<resultMap type="MesBaseProcessUser" id="MesBaseProcessUserResult">
<result property="processId" column="process_id" />
<result property="userId" column="user_id" />
<result property="userName" column="user_name" />
<result property="createBy" column="create_by" />
<result property="createTime" column="create_time" />
<result property="routeId" column="route_id" />
</resultMap>
<sql id="selectMesBaseProcessUserVo">
select process_id, user_id, user_name, create_by, create_time from mes_base_process_user mbpu
</sql>
<select id="selectMesBaseProcessUserList" parameterType="MesBaseProcessUser" resultMap="MesBaseProcessUserResult">
<include refid="selectMesBaseProcessUserVo"/>
<where>
<if test="userName != null and userName != ''"> and user_name like concat('%', #{userName}, '%')</if>
<if test="routeId != null "> and exists (select 1 from mes_base_route_process mbrp where mbrp.process_id=mbpu.process_id and mbrp.route_id = #{routeId} )</if>
</where>
</select>
<select id="selectMesBaseProcessUserByProcessId" parameterType="Long" resultMap="MesBaseProcessUserResult">
<include refid="selectMesBaseProcessUserVo"/>
where process_id = #{processId}
</select>
<insert id="insertMesBaseProcessUser" parameterType="MesBaseProcessUser">
insert into mes_base_process_user
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="processId != null">process_id,</if>
<if test="userId != null">user_id,</if>
<if test="userName != null and userName != ''">user_name,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="processId != null">#{processId},</if>
<if test="userId != null">#{userId},</if>
<if test="userName != null and userName != ''">#{userName},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
</trim>
</insert>
<update id="updateMesBaseProcessUser" parameterType="MesBaseProcessUser">
update mes_base_process_user
<trim prefix="SET" suffixOverrides=",">
<if test="userId != null">user_id = #{userId},</if>
<if test="userName != null and userName != ''">user_name = #{userName},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
</trim>
where process_id = #{processId}
</update>
<delete id="deleteMesBaseProcessUserByProcessId" parameterType="Long">
delete from mes_base_process_user where process_id = #{processId}
</delete>
<delete id="deleteMesBaseProcessUserByProcessIds" parameterType="String">
delete from mes_base_process_user where process_id in
<foreach item="processId" collection="array" open="(" separator="," close=")">
#{processId}
</foreach>
</delete>
</mapper>

@ -14,6 +14,10 @@ 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="processName" column="process_name" />
<result property="processType" column="process_type" />
<result property="productionTime" column="production_time" />
</resultMap>
<sql id="selectMesBaseRouteProcessVo">
@ -88,4 +92,22 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{routeProcessId}
</foreach>
</delete>
<select id="selectMesBaseRouteProcessJoinList" parameterType="MesBaseRouteProcess" resultMap="MesBaseRouteProcessResult">
select mbrp.route_process_id, mbrp.route_id, mbrp.process_id, mbrp.process_order,
mbpi.process_name,mbpi.process_type,mbpi.production_time
from mes_base_route_process mbrp left join mes_base_process_info mbpi on mbrp.process_id=mbpi.process_id
<where>
<if test="routeId != null "> and mbrp.route_id = #{routeId}</if>
<if test="processId != null "> and mbrp.process_id = #{processId}</if>
<if test="processOrder != null "> and mbrp.process_order = #{processOrder}</if>
<if test="remark != null and remark != ''"> and rmbrp.emark = #{remark}</if>
</where>
</select>
</mapper>

@ -21,6 +21,7 @@
<result property="lastProcessName" column="lastProcessName"/>
<result property="stationId" column="station_id"/>
<result property="userId" column="user_id"/>
<result property="userName" column="user_name"/>
<result property="productionTime" column="production_time"/>
<result property="dispatchAmount" column="dispatch_amount"/>
<result property="planAmount" column="plan_amount"/>
@ -41,6 +42,7 @@
<result property="materialCode" column="material_code"/>
<result property="materialName" column="material_name"/>
<result property="processName" column="process_name"/>
<result property="processType" column="process_type"/>
<result property="stationName" column="station_name"/>
<result property="sopId" column="sop_id"/>
<result property="orderCode" column="order_code"/>
@ -381,4 +383,76 @@
where a.plan_code = #{planCode}
</select>
<select id="selectMesProductPlanJoinProcessList" 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,
bpi.process_name,
bpi.process_type,
mpp.process_order,
mpp.last_process_id,
mpp.final_process_flag,
mpp.station_id,
mpp.user_id,
mpp.user_name,
mpp.production_time,
mpp.dispatch_amount,
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.sop_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
<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>
</where>
</select>
<delete id="deleteMesProductPlanByDispatchCode" parameterType="String">
delete
from mes_product_plan
where dispatch_code = #{dispatchCode}
</delete>
</mapper>

@ -481,7 +481,8 @@ public class WmsRawOutstockServiceImpl implements IWmsRawOutstockService {
/**
*
*
* stock_total
* wms_raw_stockstock_totalwms_raw_stockwms_raw_stock
* wms_raw_outstock_detail
*
* @param wmsRawOutstock
@ -941,6 +942,9 @@ public class WmsRawOutstockServiceImpl implements IWmsRawOutstockService {
/**todo需要最终确认一下。在申请领柜体后wcs会调度agv将对应库位的柜体运输到柜体拆分区然后更新rawoutstock的materialbatch为其物料条码*/
String bindBarcode = baseBarcodeInfo.getBindBarcode();
if (StringUtils.isEmpty(bindBarcode)) {
throw new ServiceException("此柜体还未绑定");
}
WmsRawOutstock queryRawOutstock = new WmsRawOutstock();
queryRawOutstock.setMaterialBatch(bindBarcode);
List<WmsRawOutstock> wmsRawOutstocks = wmsRawOutstockMapper.selectWmsRawOutstockList(queryRawOutstock);

@ -138,3 +138,13 @@ export function addNoPurchaseBarcode(data) {
data: data
})
}
// 新增固定原材料条码信息
export function addRegularBarcode(data) {
return request({
url: '/mes/barcode/addRegularBarcode',
method: 'post',
data: data
})
}

@ -61,9 +61,9 @@ export function orderAddMesProductPlanList(data) {
}
// 查询生产派工列表
export function getProductPlan(query) {
export function selectProductPlans(query) {
return request({
url: '/mes/productplan/getProductPlan',
url: '/mes/productplan/selectProductPlans',
method: 'get',
params: query
})
@ -96,3 +96,32 @@ export function getDispatchSOPAttachList(planId) {
method: 'get'
})
}
// 获取工艺路线的所有工艺步骤
export function getBaseRouteProcesses(query) {
return request({
url: '/mes/productplan/getBaseRouteProcesses' ,
method: 'get',
params: query
})
}
// 获取工艺路线所有工序及关联生产人员信息
export function getProcessUsers(routeId) {
return request({
url: '/mes/productplan/getProcessUsers/' + routeId,
method: 'get'
})
}
// 删除生产派工
export function deleteProductPlansByDispatchCode(data) {
return request({
url: '/mes/productplan/deleteProductPlansByDispatchCode/',
method: 'post',
data: data
})
}

@ -10,7 +10,11 @@
<el-form-item label="成品编码:">{{ form.materialCode }}</el-form-item>
<el-form-item label="计划开始时间:">{{ parseTime(form.planBeginTime) }}</el-form-item>
<el-form-item label="计划数量/已派工数量/完成数量:" label-width="220px">
{{ form.planAmount }}/{{ form.dispatchAmount }}/{{ form.completeAmount }}
{{
form.planAmount
}}/{{
form.dispatchAmount == null || form.dispatchAmount === undefined ? 0 : form.dispatchAmount
}}/{{ form.completeAmount }}
</el-form-item>
</el-col>
<el-col :span="12">
@ -28,65 +32,112 @@
<el-button icon="el-icon-plus" size="mini" type="primary" @click="handleAddMesProductPlan">
</el-button>
</el-col>
<el-col :span="1.5">
<el-button type="danger" icon="el-icon-delete" size="mini" @click="handleDeleteMesProductPlan"
:disabled="single">删除
</el-button>
</el-col>
</el-row>
<el-table ref="mesProductPlan" :data="mesProductPlanList"
:row-class-name="rowMesProductPlanIndex" @selection-change="handleMesProductPlanSelectionChange">
<el-table-column align="center" type="selection" width="50"/>
<el-table-column align="center" label="序号" prop="index" width="50" v-if="false"/>
<el-table-column align="center" label="派工单号" prop="dispatchCode" width="290">
:row-class-name="rowMesProductPlanIndex" @selection-change="handleMesProductPlanSelectionChange"
:tree-props="{children: 'children'}"
style="width: 100%;margin-bottom: 20px;"
row-key="id"
border
default-expand-all
>
<el-table-column
width="80"
type=""
>
<template slot-scope="scope">
<el-input v-model="scope.row.dispatchCode" :disabled="true"/>
<el-button type="danger" icon="el-icon-delete" @click="handleDeleteMesProductPlan(scope)"
v-if="scope.row.deleteFlag != null && scope.row.deleteFlag == '1'"></el-button>
</template>
</el-table-column>
<el-table-column align="center" label="工序" prop="processName" width="140">
<el-table-column
width="80"
type=""
>
<template slot-scope="scope">
<el-input v-model="scope.row.processName" :disabled="true"/>
<el-button type="primary" icon="el-icon-plus" @click="addProcessUser(scope)"
v-if="scope.row.children != null && scope.row.children !== undefined"></el-button>
</template>
</el-table-column>
<el-table-column align="center" label="步骤" prop="processOrder">
<el-table-column
width="50"
>
<!-- <template slot-scope="scope">-->
<!-- <el-button type="primary" icon="el-icon-plus" @click="add(scope)"></el-button>-->
<!-- </template>-->
</el-table-column>
<el-table-column align="center" label="派工单号" prop="dispatchCode" width="230">
<template slot-scope="scope">
<el-input v-model="scope.row.dispatchCode" :disabled="true"
v-if="scope.row.children != null && scope.row.children !== undefined"/>
</template>
</el-table-column>
<el-table-column align="center" label="工序" prop="processName" width="140">
<template slot-scope="scope">
<el-input v-model="scope.row.processOrder" :disabled="true"/>
<el-input v-model="scope.row.processName" :disabled="true"
v-if="scope.row.children != null && scope.row.children !== undefined"/>
</template>
</el-table-column>
<el-table-column align="center" label="工位" prop="stationName" width="140">
<el-table-column align="center" label="步骤" prop="processOrder">
<template slot-scope="scope">
<el-input v-model="scope.row.stationName" :disabled="true"/>
<el-input v-model="scope.row.processOrder" :disabled="true"
v-if="scope.row.children != null && scope.row.children !== undefined"/>
</template>
</el-table-column>
<el-table-column align="center" label="派工数量" prop="dispatchAmount" width="100">
<template slot-scope="scope">
<el-input v-model="scope.row.dispatchAmount" :disabled="scope.row.oldRowFlag"/>
<el-input v-model="scope.row.dispatchAmount" :disabled="scope.row.oldRowFlag"
v-if="scope.row.children != null && scope.row.children !== undefined"/>
</template>
</el-table-column>
<el-table-column align="center" label="计划数量" prop="planAmount" width="100">
<el-table-column align="center" label="用户" prop="userId" width="140">
<template slot-scope="scope">
<el-input v-model="scope.row.planAmount" :disabled="scope.row.oldRowFlag || scope.row.processId!==PROCESS_ID.BENDING_PROCESS_ID"/>
<el-select v-model="scope.row.userId" placeholder="请选择用户"
v-if="scope.row.children == null || scope.row.children === undefined"
:disabled="scope.row.planId != null && scope.row.planId !== undefined && scope.row.planId !== ''"
>
<el-option
v-for="item in processUsers[scope.row.processId]"
:key="item.userId"
:label="item.userName"
:value="item.userId"
></el-option>
</el-select>
</template>
</el-table-column>
<el-table-column align="center" label="派工标准工时" prop="productionTime" width="100">
<el-table-column align="center" label="派工标准工时(小时)" prop="productionTime" width="180">
<template slot-scope="scope">
<el-input v-model="scope.row.productionTime" :disabled="scope.row.oldRowFlag"/>
<el-input-number style="width:150px;" :min="0" v-model="scope.row.productionTime" :disabled="scope.row.children != null && scope.row.children !== undefined"/>
</template>
</el-table-column>
<el-table-column align="center" label="计划开始时间" prop="planBeginTime" width="230">
<template slot-scope="scope">
<el-date-picker v-model="scope.row.planBeginTime" :disabled="scope.row.oldRowFlag" clearable
<el-date-picker v-model="scope.row.planBeginTime" style="width:200px;"
:disabled="scope.row.children != null && scope.row.children !== undefined"
clearable
placeholder="请选择计划开始时间"
type="datetime" value-format="yyyy-MM-dd HH:mm:ss"/>
type="datetime" value-format="yyyy-MM-dd HH:mm:ss"
/>
</template>
</el-table-column>
<el-table-column align="center" label="计划完成时间" prop="planEndTime" width="230">
<template slot-scope="scope">
<el-date-picker v-model="scope.row.planEndTime" :disabled="scope.row.oldRowFlag" clearable
<el-date-picker v-model="scope.row.planEndTime" style="width:200px;"
:disabled="scope.row.children != null && scope.row.children !== undefined"
clearable
placeholder="请选择计划完成时间"
type="datetime" value-format="yyyy-MM-dd HH:mm:ss"/>
</template>
</el-table-column>
<el-table-column align="center" label="状态" prop="planStatus" width="150">
<template slot-scope="scope">
<el-select v-model="scope.row.planStatus" :disabled="true" placeholder="请选择状态">
@ -99,6 +150,8 @@
</el-select>
</template>
</el-table-column>
<el-table-column align="center" class-name="small-padding fixed-width" label="操作" width="100">
<template slot-scope="scope">
<el-button
@ -106,6 +159,7 @@
size="mini"
type="primary"
@click="handleDrawing(scope.row)"
v-if="scope.row.children != null && scope.row.children !== undefined"
>图纸
</el-button>
<el-button
@ -113,10 +167,25 @@
size="mini"
type="success"
@click="handleSOP(scope.row)"
v-if="scope.row.children != null && scope.row.children !== undefined"
>SOP
</el-button>
<el-button
icon="el-icon-delete"
size="mini"
type="danger"
@click="handleDeleteDispatchUser(scope.row)"
v-if="(scope.row.children == null || scope.row.children == undefined)
&& (scope.row.planStatus === PLAN_STATUS.STARTED || scope.row.planStatus === PLAN_STATUS.DISPATCHED)"
>删除
</el-button>
</template>
</el-table-column>
</el-table>
</el-form>
<el-form label-width="100px">
@ -179,7 +248,7 @@
<!-- 上传提示 -->
<div class="el-upload__tip" slot="tip" v-if="isShowTip">
请上传
<template v-if="fileSize"> <b style="color: #f56c6c">{{ fileSize }}MB</b></template>
<template v-if="fileSize"> <b style="color: #f67c7c">{{ fileSize }}MB</b></template>
<template v-if="fileType"> <b style="color: #f56c6c">{{ fileType.join("/") }}</b></template>
的文件
</div>
@ -268,19 +337,43 @@
<script>
import {getProductOrder, updateProductOrder} from "@//api/mes/productOrder";
import {
delProductplan,
deleteProductPlansByDispatchCode,
getDispatchCode, getDispatchDrawingList, getDispatchSOPAttachList,
getProductPlan,
selectProductPlans,
orderAddMesProductPlanList,
updateProductplan,
getBaseRouteProcesses,
getProcessUsers,
uploadFile
} from "@//api/mes/productplan";
import {getStationByRouteId} from "@//api/mes/baseRoute";
import {deepClone} from "@//utils/index";
import {getToken} from "@//utils/auth";
let id = 0
let deepSearch = (arr, target) => {
let results = []
arr.forEach(element => {
console.log(element)
id = Math.max(id, element.id)
if (element.id === target) {
results.push(element)
} else if (Array.isArray(element.children)) {
results = results.concat(deepSearch(element.children, target))
}
// if (Array.isArray(element.children)) {
// results = results.concat(deepSearch(element.children, target))
// } else if (element.id === target) {
// results.push(element)
// }
})
return results
}
export default {
name: "productPlanEdit",
dicts: ['product_status'],
dicts: ['product_status', 'mes_dispatch_flag'],
props: {
value: [String, Object, Array, Number],
//
@ -326,6 +419,9 @@ export default {
columns: [],
//
mesProductPlanList: [],
//ID
toDeletedPlanIds: [],
//
info: {},
//
@ -368,7 +464,22 @@ export default {
},
PROCESS_ID: {
BENDING_PROCESS_ID: 42
}
},
PROCESS_TYPE: {
MANUAL: '1',
AUTO: '3',
},
PLAN_STATUS: {
TO_DISPATCH: '0',//
DISPATCHED: '1',//
STARTED: '2',//
FINISHED: '3' //
},
id: 1,
processUsers: []
};
},
created() {
@ -377,17 +488,143 @@ export default {
//
getProductOrder(productOrderId).then(res => {
this.form = res.data;
this.getProcessUsers(productOrderId);
});
getProductPlan({productOrderId: productOrderId}).then(res => {
res.data.forEach(e => {
// false=true=
e.oldRowFlag = true;
this.mesProductPlanList.push(e);
})
})
}
},
methods: {
getProcessUsers(productOrderId) {
getProcessUsers(this.form.dispatchId).then(res => {
res.data.forEach(processUser => {
if (!this.processUsers[processUser.processId]) {
this.processUsers[processUser.processId] = [];
}
this.processUsers[processUser.processId].push(processUser);
});
selectProductPlans({productOrderId: productOrderId}).then(res => {
this.groupProductPlans(res.data)
// res.data.forEach(e => {
// // false=true=
// e.oldRowFlag = true;
// this.mesProductPlanList.push(e);
// })
})
});
},
groupProductPlans(productPlans) {
const groupedProductPlans = {};
productPlans.forEach(productPlan => {
const key = `${productPlan.dispatchCode}-${productPlan.processId}`;
if (!groupedProductPlans[key]) {
groupedProductPlans[key] = [];
}
groupedProductPlans[key].push(productPlan);
});
let firstDispatch = {};
for (let dispatchCodeProcessId in groupedProductPlans) {
let productPlansByDispatch = groupedProductPlans[dispatchCodeProcessId];
// console.log(processId + ": " + JSON.stringify(groupedProductPlans[processId]));
let obj = {};
let dispatchCode = dispatchCodeProcessId.split("-")[0];
if(!firstDispatch[dispatchCode]){
firstDispatch[dispatchCode] = "1";
obj.deleteFlag = "1";
}
obj.id = this.id
this.id = this.id + 1;
let i = 0;
productPlansByDispatch.forEach(groupedProductPlan => {
groupedProductPlan.id = this.id;
groupedProductPlan.productionTime = groupedProductPlan.productionTime/60/60;
this.id = this.id + 1;
if (i === 0) {
obj.dispatchCode = groupedProductPlan.dispatchCode;
obj.dispatchAmount = groupedProductPlan.dispatchAmount;
obj.processId = groupedProductPlan.processId;
obj.processName = groupedProductPlan.processName;
obj.lastProcessId = groupedProductPlan.lastProcessId;
obj.processType = groupedProductPlan.processType;
obj.processOrder = groupedProductPlan.processOrder;
obj.planBeginTime = this.form.planBeginTime;
obj.planEndTime = this.form.planEndTime;
obj.planStatus = groupedProductPlan.planStatus;
// obj.dispatchAmount = this.form.planAmount - this.form.dispatchAmount;
obj.materialId = this.form.materialId;
obj.materialBomId = this.form.materialBomId;
obj.productOrderId = this.form.productOrderId;
obj.saleOrderId = this.form.saleOrderId;
obj.saleorderCode = this.form.saleorderCode;
// false=true=
obj.oldRowFlag = true;
i++;
}
});
obj.children = productPlansByDispatch;
this.mesProductPlanList.push(obj);
}
// console.log(JSON.stringify(this.mesProductPlanList))
this.getId(this.mesProductPlanList);
},
getId(arr) {
arr.forEach(element => {
this.id = this.id + 1;
if (Array.isArray(element.children)) {
this.getId(element.children)
}
})
},
addProcessUser(scope) {
let data = deepSearch(this.mesProductPlanList, scope.row.id)?.[0]
let id = this.id + 1
this.id += 1;
if (Array.isArray(data.children)) {
this.$set(data.children, data.children.length, {
id: id,
processId: scope.row.processId,
planStatus: this.PLAN_STATUS.DISPATCHED,
userId: ""
})
} else {
this.$set(data, 'children', [
{
id: id,
processId: scope.row.processId,
planStatus: this.PLAN_STATUS.DISPATCHED,
userId: "",
}
])
}
this.id += 1
// this.show = false
// this.show = true
},
isAssetTypeAnImage(ext) {
let suffix = ext.lastIndexOf(".");
let name = ext.substr(suffix + 1);
@ -395,90 +632,146 @@ export default {
},
/** 提交按钮 */
submitForm() {
let dataList = this.mesProductPlanList.filter(plan => !plan.oldRowFlag);
if (dataList.length === 0) {
this.close();
// let dataList = this.mesProductPlanList.filter(plan => !plan.oldRowFlag);
// if (dataList.length === 0) {
// this.close();
// return;
// }
let dataList = this.mesProductPlanList;
let toUpdatedProductPlans = [];
let undispathDesc;
for (let i = 0; i < dataList.length; i++) {
let e = dataList[i];
let dispatchFlag = false;
undispathDesc = "派工单号为[" + e.dispatchCode + "],工序为[" + e.processName + "],请选择用户派工";
if (!e.children || e.children.length <= 0) {
this.$modal.msgError(undispathDesc);
return;
}
for (let j = 0; j < e.children.length; j++) {
let processUser = e.children[j];
let toUpdatedProductPlan = deepClone(e);
if (processUser.userId && processUser.userId !== '') {
toUpdatedProductPlan.userId = processUser.userId;
toUpdatedProductPlan.planBeginTime = processUser.planBeginTime;
toUpdatedProductPlan.planEndTime = processUser.planEndTime;
toUpdatedProductPlan.planId = processUser.planId;
toUpdatedProductPlan.children = null;
let productionTimeHour = processUser.productionTime;
let productionTimeSecond = productionTimeHour*60*60;
toUpdatedProductPlan.productionTime = productionTimeSecond;
toUpdatedProductPlans.push(toUpdatedProductPlan);
dispatchFlag = true;
} else {
this.$modal.msgError(undispathDesc);
return;
}
}
}
if (toUpdatedProductPlans.length <= 0) {
this.$modal.msgError("无派工信息提交");
return;
}
// ( + <= )
// processIdplanAmountplanAmount
const sumList = dataList.reduce((result, {processId, dispatchAmount}) => {
const numericAmount = parseInt(dispatchAmount, 10);
if (!this.isPositiveInteger(numericAmount)) {
this.$modal.msgError("派工数量须为大于等于0的正整数");
return;
let dispatchAmountErrorMsg = "";
const sumList = dataList.reduce((result, planData) => {
let processId = planData.processId;
let newFlag = planData.newFlag;
let dispatchAmount = planData.dispatchAmount;
if(newFlag && newFlag === "1"){
dispatchAmount = dispatchAmount == null || dispatchAmount === '' ? 0 : dispatchAmount;
const numericAmount = parseInt(dispatchAmount, 10);
if (!this.isPositiveInteger(numericAmount) || numericAmount <= 0) {
dispatchAmountErrorMsg = "派工数量须为大于等于0的正整数";
}
if (!result[processId]) {
result[processId] = 0;
}
result[processId] = (result[processId] || 0) + numericAmount;
}
result[processId] = (result[processId] || 0) + numericAmount;
return result;
}, {});
if (dispatchAmountErrorMsg !== "") {
this.$modal.msgError(dispatchAmountErrorMsg);
return;
}
//,()
const uniqueSum = new Set(Object.values(sumList));
let currentDispatchAmount = 0;
if (uniqueSum.size === 1) {
const finalSum = Array.from(uniqueSum)[0];
let dispatchedAmount = this.form.dispatchAmount + finalSum;
currentDispatchAmount = finalSum;
let dispatchedAmount = this.form.dispatchAmount + finalSum;//
if (dispatchedAmount > this.form.planAmount) {
this.$modal.msgError("每个工序的派工数量之和需小于等于该工单计划数量!");
return;
}
dataList.forEach(e => {
e.dispatchedAmount = dispatchedAmount;
}
)
} else {
} else if(uniqueSum.size >1){
this.$modal.msgError("每个工序的派工数量之和需相等!");
return;
}
orderAddMesProductPlanList(dataList).then(res => {
this.$modal.msgSuccess(res.msg);
this.close();
});
// console.log(JSON.stringify(toUpdatedProductPlans));
// alert(this.toDeletedPlanIds)
// return;
orderAddMesProductPlanList(
{productOrderId:this.form.productOrderId,dispatchAmount:currentDispatchAmount,mesProductPlanList: toUpdatedProductPlans, toDeletedPlanIds: this.toDeletedPlanIds})
.then(res => {
this.$modal.msgSuccess(res.msg);
this.close();
});
},
/** 删除按钮操作 */
handleDeleteMesProductPlan() {
let productPlan = this.checkedMesProductPlanList[0];
this.$modal.confirm('是否确认删除生产派工编号为"' + productPlan.dispatchCode + '"的数据项?').then(function () {
handleDeleteMesProductPlan(scope) {
let dispatchCode = scope.row.dispatchCode;
this.$modal.confirm('是否确认删除生产派工单号为"' + dispatchCode + '"的数据项?').then(function () {
return true;
}).then(() => {
if (productPlan.planId === undefined || productPlan.planId === null) {
if (scope.row.newFlag != null || scope.row.newFlag === '1') {
//
const mesProductPlanDetailList = this.mesProductPlanList;
this.mesProductPlanList = mesProductPlanDetailList.filter(function (item) {
return productPlan.dispatchCode !== item.dispatchCode
this.mesProductPlanList = this.mesProductPlanList.filter(function (item) {
return scope.row.dispatchCode !== item.dispatchCode
});
} else {
//
const delList = this.mesProductPlanList;
let dispatchSum = 0;
let dispatchSum = 0; //
try {
const planIds = delList.filter(function (item) {
return productPlan.dispatchCode === item.dispatchCode
const planIds = this.mesProductPlanList.filter(function (item) {
return scope.row.dispatchCode === item.dispatchCode
}).map(item => {
if (item.planStatus !== '1') {
throw Error("只能删除未派工状态的生产派工单!");
}
if (item.processId === productPlan.processId) {
dispatchSum = dispatchSum + item.planAmount;
if (item.planStatus !== this.PLAN_STATUS.DISPATCHED && item.planStatus!== this.PLAN_STATUS.TO_DISPATCH) {
throw Error("只能删除还未开始过状态的生产派工单!");
}
dispatchSum = item.dispatchAmount;//
return item.planId;
});
dispatchSum = this.form.dispatchAmount - dispatchSum;
delProductplan(planIds).then(res => {
//
updateProductOrder({
productOrderId: this.form.productOrderId,
dispatchAmount: dispatchSum
})
getProductOrder(this.form.productOrderId).then(res => {
this.form = res.data;
deleteProductPlansByDispatchCode({productOrderId:this.form.productOrderId,dispatchCode:dispatchCode,dispatchAmount:dispatchSum}).then(res => {
this.mesProductPlanList = this.mesProductPlanList.filter(function (item) {
return dispatchCode !== item.dispatchCode
});
this.form.dispatchAmount = this.form.dispatchAmount - dispatchSum;
this.$modal.msgSuccess("删除成功");
});
const mesProductPlanDetailList = this.mesProductPlanList;
this.mesProductPlanList = mesProductPlanDetailList.filter(function (item) {
return productPlan.dispatchCode !== item.dispatchCode
});
this.$modal.msgSuccess("删除成功");
} catch (e) {
this.$modal.msgError(e);
}
@ -545,34 +838,56 @@ export default {
let dispatchCode = "";
getDispatchCode().then(res => {
dispatchCode = res.msg;
getStationByRouteId(this.form.dispatchId).then(res => {
if (res.data.length === 0) {
this.$modal.msgError("工艺路线未维护工位信息!");
}
getBaseRouteProcesses({routeId: this.form.dispatchId}).then(res => {
// if (res.data.length === 0) {
// this.$modal.msgError("线");
// }
let lastProcessId = null;
let i = 0;
res.data.forEach((e, index) => {
let obj = {};
if(i===0){
obj.deleteFlag = "1";
i++;
}
obj.id = this.id
this.id = this.id + 1;
obj.dispatchCode = dispatchCode;
obj.processId = e.processId;
obj.processName = e.processName;
obj.processType = e.processType;
obj.processOrder = e.processOrder;
obj.stationId = e.stationId;
obj.stationName = e.stationName;
obj.productionTime = 0;
obj.planBeginTime = this.form.planBeginTime;
obj.planEndTime = this.form.planEndTime;
obj.planStatus = '1';
// multiStationFlag
if (e.multiStationFlag > 1) {
obj.dispatchAmount = 0;//productplanobj.planAmountplanamount=dispatchamountthis.form.planAmountorderthis.form.dispatchAmountorder
} else {
obj.dispatchAmount = this.form.planAmount - this.form.dispatchAmount;
}
// obj.dispatchAmount = this.form.planAmount - this.form.dispatchAmount;
obj.dispatchFlag = null;
obj.materialId = this.form.materialId;
obj.materialBomId = this.form.materialBomId;
obj.productOrderId = this.form.productOrderId;
obj.saleOrderId = this.form.saleOrderId;
obj.saleorderCode = this.form.saleorderCode;
obj.newFlag = "1";//
// e.mesBaseProcessUserList.forEach((mesBaseProcessUser, index) => {
// mesBaseProcessUser.id = this.id + 1;
// mesBaseProcessUser.dispatchFlag = null;
// mesBaseProcessUser.planBeginTime = null;
// mesBaseProcessUser.planEndTime = null;
// this.id = this.id + 1;
// });
obj.children = [{
id: this.id,
processId: obj.processId,
planStatus: this.PLAN_STATUS.DISPATCHED
}]
this.id += 1;
// ID
if (lastProcessId == null) {
obj.lastProcessId = 0;
@ -586,9 +901,13 @@ export default {
obj.oldRowFlag = false;
this.mesProductPlanList.push(obj);
})
this.getId(this.mesProductPlanList)
})
})
},
isPositiveInteger(value) {
// 使
return /^[0-9]\d*$/.test(value);
@ -724,7 +1043,19 @@ export default {
handleExceed() {
this.$modal.msgError(`上传文件数量不能超过 ${this.limit} !`);
},
},
handleDeleteDispatchUser(row) {
this.mesProductPlanList.forEach(mesProductPlan => {
mesProductPlan.children = mesProductPlan.children.filter(item => item.id !== row.id);
});
if (row.planId != null && row.planId !== '') {
this.toDeletedPlanIds.push(row.planId);
}
},
}
,
mounted() {
}

Loading…
Cancel
Save