MES:
-生产派工:在派工前校验是否有用户有派工冲突情况,派工数量输入完善
master
xs 3 months ago
parent 2c8623c7e5
commit 89c90a7151

@ -140,6 +140,18 @@ public class MesProductPlanController extends BaseController {
} }
/**
* List
*/
@RequiresPermissions("mes:productplan:add")
@PostMapping("/checkAddMesProductPlanList")
public AjaxResult checkAddMesProductPlanList(@RequestBody MesProductPlanEditVo productPlanEditVo) {
return success(mesProductPlanService.checkAddMesProductPlanList(productPlanEditVo));
}
/** /**
* List * List
*/ */

@ -192,6 +192,8 @@ public class MesProductPlan extends BaseEntity
private Long processProductionTime; private Long processProductionTime;
private String nickName;
public Long getSaleOrderId() { public Long getSaleOrderId() {
return saleOrderId; return saleOrderId;
} }
@ -557,6 +559,14 @@ public class MesProductPlan extends BaseEntity
this.processProductionTime = processProductionTime; this.processProductionTime = processProductionTime;
} }
public String getNickName() {
return nickName;
}
public void setNickName(String nickName) {
this.nickName = nickName;
}
@Override @Override
public String toString() { public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)

@ -135,4 +135,14 @@ public interface MesProductPlanMapper
*/ */
public List<MesProductPlan> selectOnlyMesProductPlans(MesProductPlan mesProductPlan); public List<MesProductPlan> selectOnlyMesProductPlans(MesProductPlan mesProductPlan);
/**
* ID
*
* @param mesProductPlan
* @return
*/
public List<MesProductPlan> selectOnlyConflictMesProductPlans(MesProductPlan mesProductPlan);
} }

@ -96,6 +96,15 @@ public interface IMesProductPlanService
*/ */
public String getDispatchCode(); public String getDispatchCode();
/**
*
* @param productPlanEditVo
* @return
*/
public String checkAddMesProductPlanList(MesProductPlanEditVo productPlanEditVo);
/** /**
* List * List
* *

@ -382,7 +382,7 @@ public class MesProductOrderServiceImpl implements IMesProductOrderService {
List<MesMaterialBom> mesMaterialBoms = new ArrayList<>(); List<MesMaterialBom> mesMaterialBoms = new ArrayList<>();
standardCountMap.forEach((groupBy, sum) -> { standardCountMap.forEach((groupBy, sum) -> {
System.out.println("groupBy: " + groupBy + ", Sum of values: " + sum); // System.out.println("groupBy: " + groupBy + ", Sum of values: " + sum);
MesMaterialBom mesMaterialBom = new MesMaterialBom(); MesMaterialBom mesMaterialBom = new MesMaterialBom();
String[] groupByArr = groupBy.split("-"); String[] groupByArr = groupBy.split("-");
mesMaterialBom.setMaterialId(Long.valueOf(groupByArr[0])); mesMaterialBom.setMaterialId(Long.valueOf(groupByArr[0]));

@ -219,54 +219,34 @@ public class MesProductPlanServiceImpl implements IMesProductPlanService {
} }
// /** /**
// * 在生产派工时校验库存信息 *
// * @param mesProductOrder *
// */ * @param productPlanEditVo
// @Override * @return
// public int checkProductPlanUserConflictAndRawStock(MesProductOrder mesProductOrder) { */
// String saleType = mesProductOrder.getSaleType(); @Override
// MesProductOrder queryProductOrder = new MesProductOrder(); public String checkAddMesProductPlanList(MesProductPlanEditVo productPlanEditVo) {
// if (saleType.equals(MesConstants.MES_PRODUCT_ORDER_SALE)) {//外部销售 List<MesProductPlan> mesProductPlanList = productPlanEditVo.getMesProductPlanList();
// Long materialId = mesProductOrder.getMaterialId(); List<MesProductPlan> toInsertedProductPlanList = mesProductPlanList.stream().filter(p ->
// queryProductOrder.setMaterialId(materialId); p.getPlanId() == null
// } else {//对内生产 ).collect(Collectors.toList());
// Long produceMaterialId = mesProductOrder.getProduceMaterialId(); StringBuffer returnMsgBuffer = new StringBuffer();
// queryProductOrder.setProduceMaterialId(produceMaterialId); int i=1;
// } for (MesProductPlan toInsertedProductPlan : toInsertedProductPlanList) {
// queryProductOrder.setSaleOrderId(mesProductOrder.getSaleOrderId()); List<MesProductPlan> conflictProductPlans = mesProductPlanMapper.selectOnlyConflictMesProductPlans(toInsertedProductPlan);
// List<MesProductOrder> mesProductOrders = mesProductOrderMapper.selectMesProductOrderList(queryProductOrder); if (conflictProductPlans != null && !conflictProductPlans.isEmpty()) {
// //工单状态0-待发布1-已发布2-已完成3-已开始4-暂停8-已撤回9-已删除 conflictProductPlans.forEach(cp -> {
// //找到派工数量大于0并且状态是已发布或者已开始的或者暂停的 returnMsgBuffer.append(i).append(".").append(cp.getNickName()).append(":").append("计划时间")
// List<MesProductOrder> filterProductOrders = mesProductOrders.stream().filter(p -> .append(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS,cp.getPlanBeginTime()))
// (p.getDispatchAmount().compareTo(BigDecimal.ONE) >= 0) && .append("-").append(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS,cp.getPlanEndTime())).append(";");
// (p.getOrderStatus().equals(MesConstants.PUBLISHED) || p.getOrderStatus().equals(MesConstants.BEGIN) || p.getOrderStatus().equals(MesConstants.PAUSE)) });
// ).collect(Collectors.toList()); }
// }
// //先根据saleorderid和安全库存查询总库存和已出库的数量
// //查询各生产任务需要物料的数量 return returnMsgBuffer.toString();
// List<List<MesMaterialBom>> materialBomAllList = new ArrayList<>(); }
// for (MesProductOrder filterProductOrder : filterProductOrders) {
// Long materialBomId = filterProductOrder.getMaterialBomId();
// MesMaterialBom queryMaterialBom = new MesMaterialBom();
// queryMaterialBom.setParentId(materialBomId);
// List<MesMaterialBom> materialBomList = mesMaterialBomMapper.selectMesMaterialBomJoinList(queryMaterialBom);
// materialBomAllList.add(materialBomList);
// }
//
// // 使用流处理合并所有列表并计数(计算每个物料需要的数量)
// Map<Long, BigDecimal> standardCountMap = materialBomAllList.stream()
// .flatMap(List::stream) // 将所有列表扁平化为一个流
// .collect(Collectors.groupingBy(
// MesMaterialBom::getMaterialId,
// Collectors.reducing(BigDecimal.ZERO, MesMaterialBom::getStandardAmount, BigDecimal::add)));
//
// standardCountMap.forEach((id, sum) -> System.out.println("ID: " + id + ", Sum of values: " + sum));
//
//// select * from wms_stock_total wst left join wms_raw_outstock wro on wst.stock_total_id=wro.stock_total_id
//// and wst.sale_order_id=0;
// return 1;
// }
/** /**
* List * List
@ -307,7 +287,7 @@ public class MesProductPlanServiceImpl implements IMesProductPlanService {
BigDecimal planAmount = mesProductOrder.getPlanAmount(); BigDecimal planAmount = mesProductOrder.getPlanAmount();
BigDecimal updateDispatchAmount = dispatchedAmount.add(mesProductPlanEditVo.getDispatchAmount()); BigDecimal updateDispatchAmount = dispatchedAmount.add(mesProductPlanEditVo.getDispatchAmount());
if (updateDispatchAmount.compareTo(planAmount) > 0) { if (updateDispatchAmount.compareTo(planAmount) > 0) {
throw new ServiceException("派工数量大于计划数量,请重新派工"); throw new ServiceException("派工数量不能大于计划数量,请重新派工");
} }
@ -794,5 +774,55 @@ public class MesProductPlanServiceImpl implements IMesProductPlanService {
// } catch (ExecutionException e) { // } catch (ExecutionException e) {
// throw new RuntimeException(e); // throw new RuntimeException(e);
// } // }
// }
// /**
// * 在生产派工时校验库存信息
// * @param mesProductOrder
// */
// @Override
// public int checkProductPlanUserConflictAndRawStock(MesProductOrder mesProductOrder) {
// String saleType = mesProductOrder.getSaleType();
// MesProductOrder queryProductOrder = new MesProductOrder();
// if (saleType.equals(MesConstants.MES_PRODUCT_ORDER_SALE)) {//外部销售
// Long materialId = mesProductOrder.getMaterialId();
// queryProductOrder.setMaterialId(materialId);
// } else {//对内生产
// Long produceMaterialId = mesProductOrder.getProduceMaterialId();
// queryProductOrder.setProduceMaterialId(produceMaterialId);
// }
// queryProductOrder.setSaleOrderId(mesProductOrder.getSaleOrderId());
// List<MesProductOrder> mesProductOrders = mesProductOrderMapper.selectMesProductOrderList(queryProductOrder);
// //工单状态0-待发布1-已发布2-已完成3-已开始4-暂停8-已撤回9-已删除
// //找到派工数量大于0并且状态是已发布或者已开始的或者暂停的
// List<MesProductOrder> filterProductOrders = mesProductOrders.stream().filter(p ->
// (p.getDispatchAmount().compareTo(BigDecimal.ONE) >= 0) &&
// (p.getOrderStatus().equals(MesConstants.PUBLISHED) || p.getOrderStatus().equals(MesConstants.BEGIN) || p.getOrderStatus().equals(MesConstants.PAUSE))
// ).collect(Collectors.toList());
//
// //先根据saleorderid和安全库存查询总库存和已出库的数量
// //查询各生产任务需要物料的数量
// List<List<MesMaterialBom>> materialBomAllList = new ArrayList<>();
// for (MesProductOrder filterProductOrder : filterProductOrders) {
// Long materialBomId = filterProductOrder.getMaterialBomId();
// MesMaterialBom queryMaterialBom = new MesMaterialBom();
// queryMaterialBom.setParentId(materialBomId);
// List<MesMaterialBom> materialBomList = mesMaterialBomMapper.selectMesMaterialBomJoinList(queryMaterialBom);
// materialBomAllList.add(materialBomList);
// }
//
// // 使用流处理合并所有列表并计数(计算每个物料需要的数量)
// Map<Long, BigDecimal> standardCountMap = materialBomAllList.stream()
// .flatMap(List::stream) // 将所有列表扁平化为一个流
// .collect(Collectors.groupingBy(
// MesMaterialBom::getMaterialId,
// Collectors.reducing(BigDecimal.ZERO, MesMaterialBom::getStandardAmount, BigDecimal::add)));
//
// standardCountMap.forEach((id, sum) -> System.out.println("ID: " + id + ", Sum of values: " + sum));
//
//// select * from wms_stock_total wst left join wms_raw_outstock wro on wst.stock_total_id=wro.stock_total_id
//// and wst.sale_order_id=0;
// return 1;
// } // }
} }

@ -51,14 +51,14 @@ export function getDispatchCode() {
}) })
} }
// 生产派工校验 //生产派工校验
// export function checkProductPlanUserConflictAndRawStock(data) { export function checkAddMesProductPlanList(data) {
// return request({ return request({
// url: '/mes/productplan/checkProductPlanUserConflictAndRawStock', url: '/mes/productplan/checkAddMesProductPlanList',
// method: 'post', method: 'post',
// data: data data: data
// }) })
// } }
// 生产工单新增生产派工List // 生产工单新增生产派工List

@ -524,6 +524,7 @@
<el-table-column label="需要数量" align="center" prop="standardAmount" width="100"/> <el-table-column label="需要数量" align="center" prop="standardAmount" width="100"/>
<el-table-column label="已使用数量" align="center" prop="outstockAmount" width="100"/> <el-table-column label="已使用数量" align="center" prop="outstockAmount" width="100"/>
<el-table-column label="库存总数量" align="center" prop="totalAmount" width="100"/> <el-table-column label="库存总数量" align="center" prop="totalAmount" width="100"/>
<el-table-column label="占用数量" align="center" prop="occupyAmount" width="100"/>
<el-table-column label="库存可用数量" align="center" prop="availableAmount" width="100"/> <el-table-column label="库存可用数量" align="center" prop="availableAmount" width="100"/>
</el-table> </el-table>
@ -1033,7 +1034,7 @@ export default {
const productOrderId = row.productOrderId || this.ids[0]; const productOrderId = row.productOrderId || this.ids[0];
const orderCode = row.orderCode; const orderCode = row.orderCode;
const params = {queryParams: this.queryParams}; const params = {queryParams: this.queryParams};
this.$tab.closeOpenPage(router.currentRoute); // this.$tab.closeOpenPage(router.currentRoute);
this.$tab.openPage("工单[" + orderCode + "]生产派工", '/mes/product-plan/index/' + productOrderId, params); this.$tab.openPage("工单[" + orderCode + "]生产派工", '/mes/product-plan/index/' + productOrderId, params);
}, },
/** 排产 */ /** 排产 */

@ -50,20 +50,25 @@
border border
default-expand-all default-expand-all
> >
<el-table-column label="序号" type="index" align="center">
</el-table-column>
<el-table-column <el-table-column
width="80" width="80"
label="删除"
type="" type=""
> >
<template slot-scope="scope"> <template slot-scope="scope">
<el-button type="danger" icon="el-icon-delete" @click="handleDeleteMesProductPlan(scope)" <el-button type="danger" icon="el-icon-delete" @click="handleDeleteMesProductPlan(scope)"
v-if="scope.row.deleteFlag != null && scope.row.deleteFlag === '1'"></el-button> v-if="scope.row.firstFlag != null && scope.row.firstFlag === '1'"></el-button>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column <el-table-column
width="80" width="80"
type="" type=""
label="添加"
> >
<template slot-scope="scope" v-if=""> <template slot-scope="scope" v-if="">
<el-button type="primary" icon="el-icon-plus" @click="addProcessUser(scope)" <el-button type="primary" icon="el-icon-plus" @click="addProcessUser(scope)"
@ -106,7 +111,9 @@
<el-table-column align="center" label="派工数量" prop="dispatchAmount" width="100"> <el-table-column align="center" label="派工数量" prop="dispatchAmount" width="100">
<template slot-scope="scope"> <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"/> v-if="scope.row.children != null && scope.row.children !== undefined
&& scope.row.firstFlag != null && scope.row.firstFlag === '1'"
/>
</template> </template>
</el-table-column> </el-table-column>
@ -377,6 +384,7 @@ import {
deleteProductPlansByDispatchCode, deleteProductPlansByDispatchCode,
getDispatchCode, getDispatchDrawingList, getDispatchSOPAttachList, getDispatchCode, getDispatchDrawingList, getDispatchSOPAttachList,
selectProductPlans, selectProductPlans,
checkAddMesProductPlanList,
orderAddMesProductPlanList, orderAddMesProductPlanList,
getBaseRouteProcesses, getBaseRouteProcesses,
getProcessUsers, getProcessUsers,
@ -605,7 +613,7 @@ export default {
let dispatchCode = dispatchCodeProcessId.split("-")[0]; let dispatchCode = dispatchCodeProcessId.split("-")[0];
if (!firstDispatch[dispatchCode]) { if (!firstDispatch[dispatchCode]) {
firstDispatch[dispatchCode] = "1"; firstDispatch[dispatchCode] = "1";
obj.deleteFlag = "1"; obj.firstFlag = "1";
} }
obj.id = this.id obj.id = this.id
@ -742,6 +750,7 @@ export default {
let dataList = this.mesProductPlanList; let dataList = this.mesProductPlanList;
let toUpdatedProductPlans = []; let toUpdatedProductPlans = [];
let undispathDesc; let undispathDesc;
let currentDispatchAmount = 0;
for (let i = 0; i < dataList.length; i++) { for (let i = 0; i < dataList.length; i++) {
let e = dataList[i]; let e = dataList[i];
@ -753,13 +762,18 @@ export default {
return; return;
} }
for (let j = 0; j < e.children.length; j++) { for (let j = 0; j < e.children.length; j++) {
let processUser = e.children[j]; let processUser = e.children[j];
let toUpdatedProductPlan = deepClone(e); let toUpdatedProductPlan = deepClone(e);
if (processUser.userId && processUser.userId !== '') { if (processUser.userId && processUser.userId !== '') {
toUpdatedProductPlan.userId = processUser.userId; toUpdatedProductPlan.userId = processUser.userId;
if(processUser.planBeginTime && processUser.planBeginTime!=='' &&
processUser.planEndTime && processUser.planEndTime!=='' &&
processUser.planBeginTime >= processUser.planEndTime){
this.$modal.msgError("序号"+(parseInt(e.index)+1)+":计划开始时间须小于计划结束时间");
return;
}
toUpdatedProductPlan.planBeginTime = processUser.planBeginTime; toUpdatedProductPlan.planBeginTime = processUser.planBeginTime;
toUpdatedProductPlan.planEndTime = processUser.planEndTime; toUpdatedProductPlan.planEndTime = processUser.planEndTime;
toUpdatedProductPlan.planId = processUser.planId; toUpdatedProductPlan.planId = processUser.planId;
@ -776,7 +790,7 @@ export default {
dispatchFlag = true; dispatchFlag = true;
} else { } else {
this.$modal.msgError(undispathDesc); this.$modal.msgError(undispathDesc);
return;
} }
} }
} else { } else {
@ -788,67 +802,54 @@ export default {
return; return;
} }
} if(e.firstFlag && e.firstFlag==="1"){//
// ( + <= ) let dispatchAmount = e.dispatchAmount;
// processIdplanAmountplanAmount
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); const numericAmount = parseInt(dispatchAmount, 10);
if (!this.isPositiveInteger(numericAmount) || numericAmount <= 0) { if (!this.isPositiveInteger(numericAmount) || numericAmount <= 0) {
dispatchAmountErrorMsg = "派工数量须为大于等于0的正整数"; this.$modal.msgError( "派工数量须为大于等于0的正整数");
return;
} }
if (!result[processId]) {
result[processId] = 0; if (e.newFlag && e.newFlag === "1") {
currentDispatchAmount += numericAmount;
} }
result[processId] = (result[processId] || 0) + numericAmount;
} }
return result; }
}, {});
if (dispatchAmountErrorMsg !== "") { //
this.$modal.msgError(dispatchAmountErrorMsg); let dispatchedAmount = this.form.dispatchAmount + currentDispatchAmount;//
if (dispatchedAmount > this.form.planAmount) {
this.$modal.msgError("派工数量之和需小于等于该生产任务计划数量!");
return; return;
} }
//,()
const uniqueSum = new Set(Object.values(sumList));
let currentDispatchAmount = 0; checkAddMesProductPlanList(
if (uniqueSum.size === 1) { {
const finalSum = Array.from(uniqueSum)[0]; productOrderId: this.form.productOrderId,
currentDispatchAmount = finalSum; dispatchAmount: currentDispatchAmount,
let dispatchedAmount = this.form.dispatchAmount + finalSum;// saleOrderId: this.form.saleOrderId,
if (dispatchedAmount > this.form.planAmount) { mesProductPlanList: toUpdatedProductPlans,
this.$modal.msgError("每个工序的派工数量之和需小于等于该工单计划数量!"); })
return; .then(res => {
} if (res?.msg && res.msg !== '') {
} else if (uniqueSum.size > 1) { this.$modal.confirm('有以下用户派工冲突,请确认是否继续派工?' + res.msg).then(function () {
this.$modal.msgError("每个工序的派工数量之和需相等!"); orderAddMesProductPlanList(currentDispatchAmount, toUpdatedProductPlans);
return; return true;
} }).then(() => {
}).catch(() => {
});
} else {
this.orderAddMesProductPlanList(currentDispatchAmount, toUpdatedProductPlans);
}
});
// console.log(JSON.stringify(toUpdatedProductPlans));
// alert(this.toDeletedPlanIds)
// return;
// checkProductPlanUserConflictAndRawStock(
// {
// productOrderId: this.form.productOrderId,
// dispatchAmount: currentDispatchAmount,
// saleOrderId: this.form.saleOrderId
// })
// .then(res => {
// this.$modal.msgSuccess(res.msg);
// this.close();
// });
return; },
orderAddMesProductPlanList(currentDispatchAmount, toUpdatedProductPlans) {
orderAddMesProductPlanList( orderAddMesProductPlanList(
{ {
productOrderId: this.form.productOrderId, productOrderId: this.form.productOrderId,
@ -956,7 +957,7 @@ export default {
res.data.forEach((e, index) => { res.data.forEach((e, index) => {
let obj = {}; let obj = {};
if (i === 0) { if (i === 0) {
obj.deleteFlag = "1";// obj.firstFlag = "1";//
i++; i++;
} }
obj.id = this.id obj.id = this.id

Loading…
Cancel
Save