Merge remote-tracking branch 'origin/master'

master
夜笙歌 3 months ago
commit 60a6319c23

@ -182,5 +182,14 @@ public class MesProductOrderController extends BaseController {
return getDataTable(list);
}
/**
* 使
*/
// @RequiresPermissions("mes:productplan:add")
@GetMapping("/getMaterialUsages")
public AjaxResult getMaterialUsages(MesProductOrder mesProductOrder) {
return success(mesProductOrderService.getMaterialUsages(mesProductOrder));
}
}

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

@ -2,6 +2,7 @@ package com.hw.mes.domain;
import java.math.BigDecimal;
import com.hw.common.core.utils.StringUtils;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.hw.common.core.annotation.Excel;
@ -80,6 +81,8 @@ public class MesMaterialBom extends TreeEntity {
*/
private String materialNameDesc;
private String materialSpec;
/**
*
*/
@ -182,6 +185,21 @@ public class MesMaterialBom extends TreeEntity {
this.materialCode = materialCode;
}
public String getMaterialSpec() {
return materialSpec;
}
public void setMaterialSpec(String materialSpec) {
this.materialSpec = materialSpec;
}
public String getGroupBy() {
String materialCode = StringUtils.isEmpty(this.materialCode) ? " " : this.materialCode;
String materialName = StringUtils.isEmpty(this.materialName) ? " " : this.materialName;
String materialSpec = StringUtils.isEmpty(this.materialSpec) ? " " : this.materialSpec;
return this.materialId + "-" + materialCode + "-" + materialName + "-" + materialSpec;
}
@Override
public String toString() {
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)

@ -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);
}

@ -1,6 +1,8 @@
package com.hw.mes.service;
import java.util.List;
import com.hw.mes.domain.MesMaterialBom;
import com.hw.mes.domain.MesProductOrder;
/**
@ -103,4 +105,9 @@ public interface IMesProductOrderService
*/
public int batchEditingProductOrder(List<MesProductOrder> productOrderList);
/**
*
* @param mesProductOrder
*/
public List<MesMaterialBom> getMaterialUsages(MesProductOrder mesProductOrder);
}

@ -5,6 +5,7 @@ import java.util.List;
import java.util.Map;
import com.hw.mes.domain.MesBaseAttachInfo;
import com.hw.mes.domain.MesMaterialBom;
import com.hw.mes.domain.MesProductOrder;
import com.hw.mes.domain.MesProductPlan;
import com.hw.mes.domain.vo.MesAssignTaskVo;
@ -95,6 +96,15 @@ public interface IMesProductPlanService
*/
public String getDispatchCode();
/**
*
* @param productPlanEditVo
* @return
*/
public String checkAddMesProductPlanList(MesProductPlanEditVo productPlanEditVo);
/**
* List
*

@ -1,10 +1,8 @@
package com.hw.mes.service.impl;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.*;
import java.util.stream.Collectors;
import com.hw.common.core.constant.MesConstants;
import com.hw.common.core.exception.ServiceException;
@ -14,6 +12,7 @@ import com.hw.common.core.utils.uuid.Seq;
import com.hw.common.security.utils.SecurityUtils;
import com.hw.mes.domain.MesMaterialBom;
import com.hw.mes.domain.MesProductPlan;
import com.hw.mes.mapper.MesMaterialBomMapper;
import com.hw.mes.mapper.MesProductPlanMapper;
import com.hw.mes.service.IMesMaterialBomService;
import org.apache.commons.lang3.time.DateFormatUtils;
@ -42,6 +41,9 @@ public class MesProductOrderServiceImpl implements IMesProductOrderService {
@Autowired
private MesProductPlanMapper mesProductPlanMapper;
@Autowired
private MesMaterialBomMapper mesMaterialBomMapper;
/**
*
*
@ -333,6 +335,70 @@ public class MesProductOrderServiceImpl implements IMesProductOrderService {
return result;
}
/**
*
* @param mesProductOrder
*/
@Override
public List<MesMaterialBom> getMaterialUsages(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<String, BigDecimal> standardCountMap = materialBomAllList.stream()
.flatMap(List::stream) // 将所有列表扁平化为一个流
.collect(Collectors.groupingBy(
MesMaterialBom::getGroupBy,
Collectors.reducing(BigDecimal.ZERO, MesMaterialBom::getStandardAmount, BigDecimal::add)));
List<MesMaterialBom> mesMaterialBoms = new ArrayList<>();
standardCountMap.forEach((groupBy, sum) -> {
// System.out.println("groupBy: " + groupBy + ", Sum of values: " + sum);
MesMaterialBom mesMaterialBom = new MesMaterialBom();
String[] groupByArr = groupBy.split("-");
mesMaterialBom.setMaterialId(Long.valueOf(groupByArr[0]));
mesMaterialBom.setMaterialCode(groupByArr[1]);
mesMaterialBom.setMaterialName(groupByArr[2]);
mesMaterialBom.setMaterialSpec(groupByArr[3]);
mesMaterialBom.setStandardAmount(sum);
mesMaterialBoms.add(mesMaterialBom);
});
// 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 mesMaterialBoms;
}
// 递归查找最顶级节点
private MesProductOrder findTopLevelOrder(Long productOrderId) {
MesProductOrder currentOrder = mesProductOrderMapper.selectMesProductOrderByProductOrderId(productOrderId);

@ -218,6 +218,36 @@ public class MesProductPlanServiceImpl implements IMesProductPlanService {
return Seq.getId(Seq.dispatchCodeSeqType, Seq.dispatchCodeCode);
}
/**
*
*
* @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
*
@ -257,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("派工数量不能大于计划数量,请重新派工");
}
@ -744,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;
// }
}

@ -24,6 +24,8 @@
<result property="materialBomDesc" column="material_bom_desc"/>
<result property="materialNameDesc" column="materialNameDesc"/>
<result property="assembleTime" column="assemble_time"/>
<result property="materialSpec" column="material_spec"/>
</resultMap>
<sql id="selectMesMaterialBomVo">
@ -151,7 +153,7 @@
<select id="selectMesMaterialBomJoinList" parameterType="MesMaterialBom" resultMap="MesMaterialBomResult">
select mmb.material_id,mbmi.material_code,mbmi.material_name,mmb.standard_amount
select mmb.material_id,mbmi.material_code,mbmi.material_name,mbmi.material_spec,mmb.standard_amount
from mes_material_bom mmb left join mes_base_material_info mbmi on mmb.material_id=mbmi.material_id
<where>
<if test="parentId != null ">and mmb.parent_id = #{parentId}</if>

@ -2,6 +2,8 @@ package com.hw.wms.controller;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import com.alibaba.fastjson2.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
@ -101,4 +103,16 @@ public class WmsStockTotalController extends BaseController
{
return toAjax(wmsStockTotalService.deleteWmsStockTotalByStockTotalIds(stockTotalIds));
}
/**
* with wms_raw_outstock
*/
// @RequiresPermissions("wms:stocktotal:list")
@GetMapping("/getStockTotalWithRawOutstocks")
public AjaxResult getStockTotalWithRawOutstocks(WmsStockTotal wmsStockTotal)
{
JSONObject returnObj = wmsStockTotalService.selectWmsStockTotalJoinRealListBySaleOrder(wmsStockTotal);
return success(returnObj);
}
}

@ -65,11 +65,19 @@ public interface WmsStockTotalMapper
/**
* ()
* (plancodeplandetailcode)
*
* @param wmsStockTotal
* @return
*/
public List<WmsStockTotal> selectWmsStockTotalJoinListBySaleOrder(WmsStockTotal wmsStockTotal);
/**
* ()
*
* @param wmsStockTotal
* @return
*/
public List<WmsStockTotal> selectWmsStockTotalJoinRealListBySaleOrder(WmsStockTotal wmsStockTotal);
}

@ -1,6 +1,10 @@
package com.hw.wms.service;
import java.math.BigDecimal;
import java.util.List;
import java.util.Map;
import com.alibaba.fastjson2.JSONObject;
import com.hw.wms.domain.WmsStockTotal;
/**
@ -67,4 +71,12 @@ public interface IWmsStockTotalService
* @return
*/
public List<WmsStockTotal> selectWmsStockTotalJoinListBySaleOrder(WmsStockTotal wmsStockTotal);
/**
* (()),Join material
*
* @param wmsStockTotal
* @return
*/
public JSONObject selectWmsStockTotalJoinRealListBySaleOrder(WmsStockTotal wmsStockTotal);
}

@ -1276,8 +1276,6 @@ public class WmsRawOutstockServiceImpl implements IWmsRawOutstockService {
wcsAgvCompleteUrl, entity, WcsReturnMsgVo.class);
WcsReturnMsgVo wcsReturnMsgVo = response.getBody();
// System.out.println("Response Status: " + response.getStatusCode());
// System.out.println("Response Status: " + wcsReturnMsgVo);
if (response.getStatusCodeValue() != 200) {
throw new ServiceException("调度异常,请重试");
}

@ -1,6 +1,12 @@
package com.hw.wms.service.impl;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import com.alibaba.fastjson2.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.hw.wms.mapper.WmsStockTotalMapper;
@ -98,7 +104,7 @@ public class WmsStockTotalServiceImpl implements IWmsStockTotalService
/**
* (),Join material
* (plancodeplandetailcode),Join material
*
* @param wmsStockTotal
* @return
@ -109,4 +115,45 @@ public class WmsStockTotalServiceImpl implements IWmsStockTotalService
return wmsStockTotalMapper.selectWmsStockTotalJoinListBySaleOrder(wmsStockTotal);
}
/**
* (()),Join material
*
* @param wmsStockTotal
* @return
*/
@Override
public JSONObject selectWmsStockTotalJoinRealListBySaleOrder(WmsStockTotal wmsStockTotal)
{
List<WmsStockTotal> wmsStockTotals = wmsStockTotalMapper.selectWmsStockTotalJoinRealListBySaleOrder(wmsStockTotal);
// 使用流处理合并所有列表并计数(计算每个物料总库存数量)
Map<Long, BigDecimal> totalAmountMap = wmsStockTotals.stream().filter(w->w.getTotalAmount()!=null)
.collect(Collectors.groupingBy(
WmsStockTotal::getMaterialId, // 根据id分组
Collectors.reducing(BigDecimal.ZERO, // 初始化求和值为0
WmsStockTotal::getTotalAmount, BigDecimal::add)));
// 使用流处理合并所有列表并计数(计算每个物料总占用数量)
Map<Long, BigDecimal> occupyAmountMap = wmsStockTotals.stream().filter(w->w.getOccupyAmount()!=null)
.collect(Collectors.groupingBy(
WmsStockTotal::getMaterialId, // 根据id分组
Collectors.reducing(BigDecimal.ZERO, // 初始化求和值为0
WmsStockTotal::getOccupyAmount, BigDecimal::add)));
// 使用流处理合并所有列表并计数(计算每个物料总使用数量)
Map<Long, BigDecimal> realOutstockAmountMap = wmsStockTotals.stream().filter(w->w.getOutstockAmount()!=null)
.collect(Collectors.groupingBy(
WmsStockTotal::getMaterialId, // 根据id分组
Collectors.reducing(BigDecimal.ZERO, // 初始化求和值为0
WmsStockTotal::getOutstockAmount, BigDecimal::add)));
JSONObject returnObj = new JSONObject();
returnObj.put("totalAmountMap",totalAmountMap);
returnObj.put("occupyAmountMap",occupyAmountMap);
returnObj.put("outstockAmountMap",realOutstockAmountMap);
return returnObj;
}
}

@ -140,7 +140,7 @@
<select id="selectWmsStockTotalJoinListBySaleOrder" parameterType="WmsStockTotal" resultMap="WmsStockTotalResult">
select wst.stock_total_id, wst.warehouse_id, wst.warehouse_floor, wst.stock_type, wst.material_id,
wst.total_amount, wst.frozen_amount, wst.occupy_amount,wst.safe_flag,
wst.total_amount, wst.frozen_amount, wst.occupy_amount,wst.safe_flag,wst.sale_order_id,
mbmi.material_code,mbmi.material_name,mbmi.material_spec,
(select sum(wro.outstock_amount) from wms_raw_outstock wro where wro.stock_total_id=wst.stock_total_id and
wro.plan_code=#{planCode} and wro.plan_detail_code=#{planDetailCode}) outstock_amount
@ -165,4 +165,33 @@
</where>
</select>
<select id="selectWmsStockTotalJoinRealListBySaleOrder" parameterType="WmsStockTotal" resultMap="WmsStockTotalResult">
select wst.stock_total_id, wst.warehouse_id, wst.warehouse_floor, wst.stock_type, wst.material_id,
wst.total_amount, wst.frozen_amount, wst.occupy_amount,wst.safe_flag,wst.sale_order_id,
mbmi.material_code,mbmi.material_name,mbmi.material_spec,
(select sum(wro.real_outstock_amount) from wms_raw_outstock wro where wro.stock_total_id=wst.stock_total_id
and (wro.execute_status='0' or wro.execute_status='1')) outstock_amount
from wms_stock_total wst left join mes_base_material_info mbmi on wst.material_id = mbmi.material_id
<where>
and wst.total_amount>=0
<if test="warehouseId != null ">and wst.warehouse_id = #{warehouseId}</if>
<if test="warehouseFloor != null ">and wst.warehouse_floor = #{warehouseFloor}</if>
<if test="stockType != null and stockType != ''">and wst.stock_type = #{stockType}</if>
<if test="materialId != null ">and wst.material_id = #{materialId}</if>
<if test="materialName != null and materialName != ''">and mbmi.material_name like concat('%',
#{materialName},
'%')
</if>
<if test="saleOrderId != null ">and (wst.sale_order_id = #{saleOrderId} or wst.sale_order_id=0)</if>
<if test="saleOrderId == null ">and wst.safe_flag='1'</if>
<if test="materialCodeNameSpec != null and materialCodeNameSpec != ''">and (mbmi.material_code like concat('%',
#{materialCodeNameSpec},'%') or mbmi.material_name like concat('%',#{materialCodeNameSpec},'%')
or mbmi.material_spec like concat('%',#{materialCodeNameSpec},'%'))
</if>
</where>
</select>
</mapper>

@ -114,3 +114,21 @@ export function batchEditingProductOrder(data) {
data: data
})
}
// 获取生产成品需要的物料 不分页
export function getMaterialUsages(query) {
return request({
url: '/mes/productOrder/getMaterialUsages',
method: 'get',
params: query
})
}
// 获取库存使用情况 不分页
export function getStockTotalWithRawOutstocks(query) {
return request({
url: '/wms/stocktotal/getStockTotalWithRawOutstocks',
method: 'get',
params: query
})
}

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

@ -262,6 +262,13 @@
@click="handleDispatch(scope.row)"
>生产派工
</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-right"
@click="handleMaterialUsage(scope.row)"
>库存使用
</el-button>
</template>
</el-table-column>
</el-table>
@ -505,6 +512,23 @@
</div>
</el-dialog>
<el-dialog title="库存使用信息" :visible.sync="materialUsageOpen" width="1000px" append-to-body>
<el-table v-loading="loading" :data="materialUsageList">
<!--el-table-column label="库存ID" align="center" prop="stockTotalId"/>
<el-table-column label="物料ID" align="center" prop="materialId"/>
<el-table-column label="物料编码" align="center" prop="materialCode"/-->
<el-table-column label="物料名称" align="center" prop="materialName"/>
<el-table-column label="物料规格" align="center" prop="materialSpec"/>
<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>
</el-dialog>
</div>
</template>
@ -515,6 +539,7 @@ import {
delProductOrder,
addProductOrder,
updateProductOrder,
getMaterialUsages, getStockTotalWithRawOutstocks,
getOrderCode, productOrderLockInventory, productOrderPublish, productOrderRecall
} from "@/api/mes/productOrder";
import addSaleOrder from '@//views/mes/productOrder/addSaleOrder.vue';
@ -565,6 +590,10 @@ export default {
selectType: "",
//
productOrderOpen: false,
materialUsageOpen: false,
materialUsageList: [],
//
queryParams: {
pageNum: 1,
@ -1005,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);
},
/** 排产 */
@ -1016,6 +1045,34 @@ export default {
this.$tab.closeOpenPage(router.currentRoute);
this.$tab.openPage("工单[" + orderCode + "]排产", '/mes/production-scheduling/index/' + productOrderId, params);
},
handleMaterialUsage(row) {
this.materialUsageOpen = true;
this.materialUsageList = [];
getMaterialUsages(row).then(response => {
let materialUsageList = response.data;
getStockTotalWithRawOutstocks({saleOrderId: row.saleOrderId}).then(response => {
let stockMapJson = response.data;
let totalAmountMap = stockMapJson.totalAmountMap;
let occupyAmountMap = stockMapJson.occupyAmountMap;
let outstockAmountMap = stockMapJson.outstockAmountMap;
// console.log(stocks)
// const stockMap = new Map(stocks.map(obj => [obj.materialId + "-" + obj.saleOrderId, obj]));
materialUsageList.map(objA => {
objA.totalAmount = totalAmountMap[objA.materialId];
objA.outstockAmount = outstockAmountMap[objA.materialId];
objA.occupyAmount = occupyAmountMap[objA.materialId];
objA.availableAmount = objA.totalAmount -objA.occupyAmount;
// return returnObj; //
});
this.materialUsageList = materialUsageList;
// console.log(this.materialUsageList)
})
})
},
/** 销售订单新增提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {

@ -50,27 +50,32 @@
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)"
v-if="(scope.row.children != null && scope.row.children !== undefined)
&& scope.row.processType!== PROCESS_TYPE.AUTO && scope.row.displayFlag !== DISPLAY_FLAG.NO"
:disabled="scope.row.addFlag !=='1'
|| form.orderStatus===ORDER_STATUS.FINISHED || form.orderStatus===ORDER_STATUS.RECALLED || form.orderStatus===ORDER_STATUS.DELETED" >
:disabled="scope.row.addFlag !=='1'
|| form.orderStatus===ORDER_STATUS.FINISHED || form.orderStatus===ORDER_STATUS.RECALLED || form.orderStatus===ORDER_STATUS.DELETED">
</el-button>
</template>
@ -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>
@ -206,7 +213,7 @@
type="danger"
@click="handleDeleteDispatchUser(scope.row)"
v-if="(scope.row.children == null || false) "
:disabled = "(scope.row.planStatus !== PLAN_STATUS.TO_DISPATCH && scope.row.planStatus !== PLAN_STATUS.DISPATCHED) || form.orderStatus===ORDER_STATUS.FINISHED || form.orderStatus===ORDER_STATUS.RECALLED || form.orderStatus===ORDER_STATUS.DELETED"
:disabled="(scope.row.planStatus !== PLAN_STATUS.TO_DISPATCH && scope.row.planStatus !== PLAN_STATUS.DISPATCHED) || form.orderStatus===ORDER_STATUS.FINISHED || form.orderStatus===ORDER_STATUS.RECALLED || form.orderStatus===ORDER_STATUS.DELETED"
>删除
</el-button>
@ -377,6 +384,7 @@ import {
deleteProductPlansByDispatchCode,
getDispatchCode, getDispatchDrawingList, getDispatchSOPAttachList,
selectProductPlans,
checkAddMesProductPlanList,
orderAddMesProductPlanList,
getBaseRouteProcesses,
getProcessUsers,
@ -409,7 +417,7 @@ let deepSearch = (arr, target) => {
export default {
name: "productPlanEdit",
dicts: ['plan_status','product_status', 'mes_dispatch_flag'],
dicts: ['plan_status', 'product_status', 'mes_dispatch_flag'],
components: {
'apply-raw-outstock': applyRawOutstock,
},
@ -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
@ -614,7 +622,7 @@ export default {
let i = 0;
let processType;
productPlansByDispatch.forEach(groupedProductPlan => {
if(groupedProductPlan.planStatus !== this.PLAN_STATUS.FINISHED){
if (groupedProductPlan.planStatus !== this.PLAN_STATUS.FINISHED) {
obj.addFlag = "1";
}
@ -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,56 +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;
},
orderAddMesProductPlanList(currentDispatchAmount, toUpdatedProductPlans) {
orderAddMesProductPlanList(
{
productOrderId: this.form.productOrderId,
@ -858,18 +870,18 @@ export default {
this.$modal.confirm('是否确认删除生产派工单号为"' + dispatchCode + '"的数据项?').then(function () {
return true;
}).then(() => {
if(this.form.orderStatus === this.ORDER_STATUS.RECALLED){
this.$modal.msgError("此生产任务已经撤回,不能删除") ;
if (this.form.orderStatus === this.ORDER_STATUS.RECALLED) {
this.$modal.msgError("此生产任务已经撤回,不能删除");
return;
}
if(this.form.orderStatus === this.ORDER_STATUS.FINISHED){
this.$modal.msgError("此生产任务已经完成,不能删除") ;
if (this.form.orderStatus === this.ORDER_STATUS.FINISHED) {
this.$modal.msgError("此生产任务已经完成,不能删除");
return;
}
if(this.form.orderStatus === this.ORDER_STATUS.DELETED){
this.$modal.msgError("此生产任务已经删除,不能删除") ;
if (this.form.orderStatus === this.ORDER_STATUS.DELETED) {
this.$modal.msgError("此生产任务已经删除,不能删除");
return;
}
@ -945,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