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
*/

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

@ -135,4 +135,14 @@ public interface MesProductPlanMapper
*/
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();
/**
*
* @param productPlanEditVo
* @return
*/
public String checkAddMesProductPlanList(MesProductPlanEditVo productPlanEditVo);
/**
* List
*

@ -382,7 +382,7 @@ public class MesProductOrderServiceImpl implements IMesProductOrderService {
List<MesMaterialBom> mesMaterialBoms = new ArrayList<>();
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();
String[] groupByArr = groupBy.split("-");
mesMaterialBom.setMaterialId(Long.valueOf(groupByArr[0]));

@ -219,54 +219,34 @@ public class MesProductPlanServiceImpl implements IMesProductPlanService {
}
// /**
// * 在生产派工时校验库存信息
// * @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;
// }
/**
*
*
* @param productPlanEditVo
* @return
*/
@Override
public String checkAddMesProductPlanList(MesProductPlanEditVo productPlanEditVo) {
List<MesProductPlan> mesProductPlanList = productPlanEditVo.getMesProductPlanList();
List<MesProductPlan> toInsertedProductPlanList = mesProductPlanList.stream().filter(p ->
p.getPlanId() == null
).collect(Collectors.toList());
StringBuffer returnMsgBuffer = new StringBuffer();
int i=1;
for (MesProductPlan toInsertedProductPlan : toInsertedProductPlanList) {
List<MesProductPlan> conflictProductPlans = mesProductPlanMapper.selectOnlyConflictMesProductPlans(toInsertedProductPlan);
if (conflictProductPlans != null && !conflictProductPlans.isEmpty()) {
conflictProductPlans.forEach(cp -> {
returnMsgBuffer.append(i).append(".").append(cp.getNickName()).append(":").append("计划时间")
.append(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS,cp.getPlanBeginTime()))
.append("-").append(DateUtils.parseDateToStr(DateUtils.YYYY_MM_DD_HH_MM_SS,cp.getPlanEndTime())).append(";");
});
}
}
return returnMsgBuffer.toString();
}
/**
* List
@ -307,7 +287,7 @@ public class MesProductPlanServiceImpl implements IMesProductPlanService {
BigDecimal planAmount = mesProductOrder.getPlanAmount();
BigDecimal updateDispatchAmount = dispatchedAmount.add(mesProductPlanEditVo.getDispatchAmount());
if (updateDispatchAmount.compareTo(planAmount) > 0) {
throw new ServiceException("派工数量大于计划数量,请重新派工");
throw new ServiceException("派工数量不能大于计划数量,请重新派工");
}
@ -794,5 +774,55 @@ public class MesProductPlanServiceImpl implements IMesProductPlanService {
// } catch (ExecutionException 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) {
// return request({
// url: '/mes/productplan/checkProductPlanUserConflictAndRawStock',
// method: 'post',
// data: data
// })
// }
//生产派工校验
export function checkAddMesProductPlanList(data) {
return request({
url: '/mes/productplan/checkAddMesProductPlanList',
method: 'post',
data: data
})
}
// 生产工单新增生产派工List

@ -524,6 +524,7 @@
<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="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>
@ -1033,7 +1034,7 @@ export default {
const productOrderId = row.productOrderId || this.ids[0];
const orderCode = row.orderCode;
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);
},
/** 排产 */

@ -50,20 +50,25 @@
border
default-expand-all
>
<el-table-column label="序号" type="index" align="center">
</el-table-column>
<el-table-column
width="80"
label="删除"
type=""
>
<template slot-scope="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>
</el-table-column>
<el-table-column
width="80"
type=""
label="添加"
>
<template slot-scope="scope" v-if="">
<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">
<template slot-scope="scope">
<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>
</el-table-column>
@ -377,6 +384,7 @@ import {
deleteProductPlansByDispatchCode,
getDispatchCode, getDispatchDrawingList, getDispatchSOPAttachList,
selectProductPlans,
checkAddMesProductPlanList,
orderAddMesProductPlanList,
getBaseRouteProcesses,
getProcessUsers,
@ -605,7 +613,7 @@ export default {
let dispatchCode = dispatchCodeProcessId.split("-")[0];
if (!firstDispatch[dispatchCode]) {
firstDispatch[dispatchCode] = "1";
obj.deleteFlag = "1";
obj.firstFlag = "1";
}
obj.id = this.id
@ -742,6 +750,7 @@ export default {
let dataList = this.mesProductPlanList;
let toUpdatedProductPlans = [];
let undispathDesc;
let currentDispatchAmount = 0;
for (let i = 0; i < dataList.length; i++) {
let e = dataList[i];
@ -753,13 +762,18 @@ export default {
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;
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.planEndTime = processUser.planEndTime;
toUpdatedProductPlan.planId = processUser.planId;
@ -776,7 +790,7 @@ export default {
dispatchFlag = true;
} else {
this.$modal.msgError(undispathDesc);
return;
}
}
} else {
@ -788,67 +802,54 @@ export default {
return;
}
}
// ( + <= )
// 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;
if(e.firstFlag && e.firstFlag==="1"){//
let dispatchAmount = e.dispatchAmount;
const numericAmount = parseInt(dispatchAmount, 10);
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;
}
//,()
const uniqueSum = new Set(Object.values(sumList));
let currentDispatchAmount = 0;
if (uniqueSum.size === 1) {
const finalSum = Array.from(uniqueSum)[0];
currentDispatchAmount = finalSum;
let dispatchedAmount = this.form.dispatchAmount + finalSum;//
if (dispatchedAmount > this.form.planAmount) {
this.$modal.msgError("每个工序的派工数量之和需小于等于该工单计划数量!");
return;
}
} else if (uniqueSum.size > 1) {
this.$modal.msgError("每个工序的派工数量之和需相等!");
return;
}
checkAddMesProductPlanList(
{
productOrderId: this.form.productOrderId,
dispatchAmount: currentDispatchAmount,
saleOrderId: this.form.saleOrderId,
mesProductPlanList: toUpdatedProductPlans,
})
.then(res => {
if (res?.msg && res.msg !== '') {
this.$modal.confirm('有以下用户派工冲突,请确认是否继续派工?' + res.msg).then(function () {
orderAddMesProductPlanList(currentDispatchAmount, toUpdatedProductPlans);
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(
{
productOrderId: this.form.productOrderId,
@ -956,7 +957,7 @@ export default {
res.data.forEach((e, index) => {
let obj = {};
if (i === 0) {
obj.deleteFlag = "1";//
obj.firstFlag = "1";//
i++;
}
obj.id = this.id

Loading…
Cancel
Save