MES:
1、采购订单绑定销售订单时判断物料信息有没有设置绑定标识,并且绑定标识为是的才能绑定;
2、原材料条码生成时判断物料信息绑定标识逻辑
master
xins 6 months ago
parent 8e4aa6f469
commit 63b54ecbb3

@ -102,4 +102,8 @@ public class MesConstants {
/**生产工单销售类型*/
public static final String MES_PRODUCT_ORDER_SALE = "1";//外部销售
public static final String MES_PRODUCT_ORDER_INTERNAL = "2";//对内生产
/**物料信息绑定标识,是否需要采购订单明细绑定销售订单*/
public static final String MES_MATERIAL_BIND_FLAG_YES = "1";//是
}

@ -134,4 +134,15 @@ public class MesPurchaseOrderController extends BaseController
return toAjax(mesPurchaseOrderService.bindOrder(mesPurchaseOrder));
}
/**
* ,
*/
@RequiresPermissions("mes:purchaseOrder:query")
@GetMapping(value = "/getCheckedPurchaseOrder/{purchaseOrderId}")
public AjaxResult getCheckedPurchaseOrder(@PathVariable("purchaseOrderId") Long purchaseOrderId)
{
return success(mesPurchaseOrderService.selectCheckedPurchaseOrderByPurchaseOrderId(purchaseOrderId));
}
}

@ -131,6 +131,9 @@ public class MesPurchaseOrder extends BaseEntity {
/** 采购销售订单绑定信息信息 */
private List<MesOrderBind> mesOrderBindList;
/**判断是否需要绑定*/
private String bindFlag;
public void setPurchaseOrderId(Long purchaseOrderId)
{
this.purchaseOrderId = purchaseOrderId;
@ -376,6 +379,14 @@ public class MesPurchaseOrder extends BaseEntity {
this.mesOrderBindList = mesOrderBindList;
}
public String getBindFlag() {
return bindFlag;
}
public void setBindFlag(String bindFlag) {
this.bindFlag = bindFlag;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)

@ -68,4 +68,12 @@ public interface IMesPurchaseOrderService
*/
public int bindOrder(MesPurchaseOrder mesPurchaseOrder);
/**
* ,
*
* @param purchaseOrderId
* @return
*/
public MesPurchaseOrder selectCheckedPurchaseOrderByPurchaseOrderId(Long purchaseOrderId);
}

@ -13,18 +13,16 @@ import com.hw.common.core.utils.StringUtils;
import com.hw.common.core.utils.uuid.Seq;
import com.hw.common.security.utils.SecurityUtils;
import com.hw.mes.api.domain.MesBaseBarcodeInfo;
import com.hw.mes.api.domain.MesBaseMaterialInfo;
import com.hw.mes.domain.MesBasePalletInfo;
import com.hw.mes.domain.MesOrderBind;
import com.hw.mes.domain.MesProductOrder;
import com.hw.mes.domain.vo.MesBindBarcodeVo;
import com.hw.mes.mapper.MesBasePalletInfoMapper;
import com.hw.mes.mapper.MesOrderBindMapper;
import com.hw.mes.mapper.MesProductOrderMapper;
import com.hw.mes.mapper.*;
import com.hw.mes.service.IMesOrderBindService;
import com.hw.printer.api.RemotePrinterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.hw.mes.mapper.MesBaseBarcodeInfoMapper;
import com.hw.mes.service.IMesBaseBarcodeInfoService;
import org.springframework.transaction.annotation.Transactional;
@ -51,6 +49,9 @@ public class MesBaseBarcodeInfoServiceImpl implements IMesBaseBarcodeInfoService
@Autowired
private MesBasePalletInfoMapper mesBasePalletInfoMapper;
@Autowired
private MesBaseMaterialInfoMapper mesBaseMaterialInfoMapper;
/**
*
*
@ -95,6 +96,34 @@ public class MesBaseBarcodeInfoServiceImpl implements IMesBaseBarcodeInfoService
@Override
@Transactional(rollbackFor = Exception.class)
public int insertMesBaseBarcodeInfo(MesBaseBarcodeInfo mesBaseBarcodeInfo) {
// 生成原材料条码
if (mesBaseBarcodeInfo.getBarcodeType().equals(MesConstants.MES_BARCODE_TYPE_RAW)) {
generateRawBarcode(mesBaseBarcodeInfo);
}
// 生成成品条码
else if (mesBaseBarcodeInfo.getBarcodeType().equals(MesConstants.MES_BARCODE_TYPE_PRODUCT)) {
Date currentDate = new Date();
String userName = SecurityUtils.getUsername();
// 批次代码 == 条码内容
int frequency = mesBaseBarcodeInfo.getAmount().intValue();
for (int i = 0; i < frequency; i++) {
String code = Seq.getId(Seq.mesCompBarcodeSeqType, Seq.mesCompBarcodeCode);
mesBaseBarcodeInfo.setBatchCode(code);
mesBaseBarcodeInfo.setBarcodeInfo(code);
mesBaseBarcodeInfo.setAmount(new BigDecimal(1));
mesBaseBarcodeInfo.setCreateTime(currentDate);
mesBaseBarcodeInfo.setCreateBy(userName);
mesBaseBarcodeInfoMapper.insertMesBaseBarcodeInfo(mesBaseBarcodeInfo);
}
}
return 1;
}
public void generateRawBarcode(MesBaseBarcodeInfo mesBaseBarcodeInfo) {
Date currentDate = new Date();
String userName = SecurityUtils.getUsername();
Long purchaseOrderId = mesBaseBarcodeInfo.getPurchaseOrderId();
MesBaseBarcodeInfo queryBaseBarcodeInfo = new MesBaseBarcodeInfo();
queryBaseBarcodeInfo.setPurchaseOrderId(purchaseOrderId);
@ -103,22 +132,31 @@ public class MesBaseBarcodeInfoServiceImpl implements IMesBaseBarcodeInfoService
throw new ServiceException("此采购订单已经生成条码,无需重复生成");
}
BigDecimal barcodeAmount = mesBaseBarcodeInfo.getBarcodeAmount();
MesOrderBind queryOrderBind = new MesOrderBind();
queryOrderBind.setPurchaseOrderId(purchaseOrderId);
List<MesOrderBind> mesOrderBinds = mesOrderBindMapper.selectMesOrderBindList(queryOrderBind);
if (mesOrderBinds == null || mesOrderBinds.isEmpty()) {
throw new ServiceException("此采购订单还未绑定销售订单,不能生成条码");
Long materialId = mesBaseBarcodeInfo.getMaterialId();
MesBaseMaterialInfo mesBaseMaterialInfo = mesBaseMaterialInfoMapper.selectMesBaseMaterialInfoByMaterialId(materialId);
if (mesBaseMaterialInfo == null) {
throw new ServiceException("物料信息不存在");
}
BigDecimal totalBindAmount = mesOrderBinds.stream().map(MesOrderBind::getBindAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
if (barcodeAmount.compareTo(totalBindAmount) != 0) {
throw new ServiceException("采购订单还未完全绑定到销售订单");
if (mesBaseMaterialInfo.getBindFlag() == null) {
throw new ServiceException("请先设置此物料信息[物料编码:" + mesBaseBarcodeInfo.getMaterialCode()
+ ",物料名称:" + mesBaseBarcodeInfo.getMaterialName() + "]的绑定标识");
}
mesBaseBarcodeInfo.setCreateTime(DateUtils.getNowDate());
// 生成原材料条码
if (mesBaseBarcodeInfo.getBarcodeType().equals(MesConstants.MES_BARCODE_TYPE_RAW)) {
//如果物料信息需要绑定,则判断是否有绑定的信息
BigDecimal barcodeAmount = mesBaseBarcodeInfo.getBarcodeAmount();
if (mesBaseMaterialInfo.getBindFlag().equals(MesConstants.MES_MATERIAL_BIND_FLAG_YES)) {
MesOrderBind queryOrderBind = new MesOrderBind();
queryOrderBind.setPurchaseOrderId(purchaseOrderId);
List<MesOrderBind> mesOrderBinds = mesOrderBindMapper.selectMesOrderBindList(queryOrderBind);
if (mesOrderBinds == null || mesOrderBinds.isEmpty()) {
throw new ServiceException("此采购订单还未绑定销售订单,不能生成条码");
}
BigDecimal totalBindAmount = mesOrderBinds.stream().map(MesOrderBind::getBindAmount).reduce(BigDecimal.ZERO, BigDecimal::add);
if (barcodeAmount.compareTo(totalBindAmount) != 0) {
throw new ServiceException("采购订单还未完全绑定到销售订单");
}
String batchCode = Seq.getId(Seq.mesBatchCodeSeqType, Seq.mesBatchCodeCode);
MesBaseBarcodeInfo toInsertedBarcodeInfo;
@ -126,51 +164,55 @@ public class MesBaseBarcodeInfoServiceImpl implements IMesBaseBarcodeInfoService
BigDecimal bindAmount = mesOrderBind.getBindAmount();
for (int i = 0; i < bindAmount.intValue(); i++) {
// 生成数量条的不同条码内容
toInsertedBarcodeInfo = new MesBaseBarcodeInfo();
//同一批次的批次代码相同
toInsertedBarcodeInfo.setBatchCode(batchCode);
toInsertedBarcodeInfo.setPurchaseOrderId(purchaseOrderId);
toInsertedBarcodeInfo.setPoNo(mesBaseBarcodeInfo.getPoNo());
toInsertedBarcodeInfo.setBarcodeType(MesConstants.MES_BARCODE_TYPE_RAW);
toInsertedBarcodeInfo.setBarcodeInfo(Seq.getId(Seq.mesBarcodeSeqType, Seq.mesBarcodeCode));
toInsertedBarcodeInfo.setMaterialId(mesBaseBarcodeInfo.getMaterialId());
toInsertedBarcodeInfo.setProductionDate(mesBaseBarcodeInfo.getProductionDate());
toInsertedBarcodeInfo.setLastOutstockDate(mesBaseBarcodeInfo.getLastOutstockDate());
toInsertedBarcodeInfo.setProjectNo(mesBaseBarcodeInfo.getProjectNo());
toInsertedBarcodeInfo.setBatchFlag(mesBaseBarcodeInfo.getBatchFlag());
toInsertedBarcodeInfo = getInsertedBarcodeInfo(mesBaseBarcodeInfo, batchCode, userName, currentDate);
toInsertedBarcodeInfo.setSaleOrderId(mesOrderBind.getSaleOrderId());
toInsertedBarcodeInfo.setSaleorderCode(mesOrderBind.getSaleOrderCode());
toInsertedBarcodeInfo.setSafeFlag(mesOrderBind.getSafeFlag());
if (mesBaseBarcodeInfo.getBatchFlag().equals(MesConstants.NOT_IS_BATCH)) {
toInsertedBarcodeInfo.setAmount(new BigDecimal(1));
}
if (mesBaseBarcodeInfo.getBatchFlag().equals(MesConstants.IS_BATCH)) {
toInsertedBarcodeInfo.setAmount(mesBaseBarcodeInfo.getAmount());
}
mesBaseBarcodeInfoMapper.insertMesBaseBarcodeInfo(toInsertedBarcodeInfo);
}
}
} else {
MesBaseBarcodeInfo toInsertedBarcodeInfo;
String batchCode = Seq.getId(Seq.mesBatchCodeSeqType, Seq.mesBatchCodeCode);
for (long i = 0; i < barcodeAmount.intValue(); i++) {
// 生成数量条的不同条码内容
toInsertedBarcodeInfo = getInsertedBarcodeInfo(mesBaseBarcodeInfo, batchCode, userName, currentDate);
toInsertedBarcodeInfo.setSafeFlag(MesConstants.MES_ORDER_BIND_SAFE_FLAG_YES);
mesBaseBarcodeInfoMapper.insertMesBaseBarcodeInfo(toInsertedBarcodeInfo);
}
}
}
public MesBaseBarcodeInfo getInsertedBarcodeInfo(MesBaseBarcodeInfo mesBaseBarcodeInfo, String batchCode, String userName, Date currentDate) {
MesBaseBarcodeInfo toInsertedBarcodeInfo = new MesBaseBarcodeInfo();
//同一批次的批次代码相同
toInsertedBarcodeInfo.setBatchCode(batchCode);
toInsertedBarcodeInfo.setPurchaseOrderId(mesBaseBarcodeInfo.getPurchaseOrderId());
toInsertedBarcodeInfo.setPoNo(mesBaseBarcodeInfo.getPoNo());
toInsertedBarcodeInfo.setBarcodeType(MesConstants.MES_BARCODE_TYPE_RAW);
toInsertedBarcodeInfo.setBarcodeInfo(Seq.getId(Seq.mesBarcodeSeqType, Seq.mesBarcodeCode));
toInsertedBarcodeInfo.setMaterialId(mesBaseBarcodeInfo.getMaterialId());
toInsertedBarcodeInfo.setProductionDate(mesBaseBarcodeInfo.getProductionDate());
toInsertedBarcodeInfo.setLastOutstockDate(mesBaseBarcodeInfo.getLastOutstockDate());
toInsertedBarcodeInfo.setProjectNo(mesBaseBarcodeInfo.getProjectNo());
toInsertedBarcodeInfo.setBatchFlag(mesBaseBarcodeInfo.getBatchFlag());
if (mesBaseBarcodeInfo.getBatchFlag().equals(MesConstants.NOT_IS_BATCH)) {
toInsertedBarcodeInfo.setAmount(new BigDecimal(1));
}
// 生成成品条码
else if (mesBaseBarcodeInfo.getBarcodeType().equals(MesConstants.MES_BARCODE_TYPE_PRODUCT)) {
// 批次代码 == 条码内容
int frequency = mesBaseBarcodeInfo.getAmount().intValue();
for (int i = 0; i < frequency; i++) {
String code = Seq.getId(Seq.mesCompBarcodeSeqType, Seq.mesCompBarcodeCode);
mesBaseBarcodeInfo.setBatchCode(code);
mesBaseBarcodeInfo.setBarcodeInfo(code);
mesBaseBarcodeInfo.setAmount(new BigDecimal(1));
mesBaseBarcodeInfoMapper.insertMesBaseBarcodeInfo(mesBaseBarcodeInfo);
}
if (mesBaseBarcodeInfo.getBatchFlag().equals(MesConstants.IS_BATCH)) {
toInsertedBarcodeInfo.setAmount(mesBaseBarcodeInfo.getAmount());
}
return 1;
toInsertedBarcodeInfo.setCreateBy(userName);
toInsertedBarcodeInfo.setCreateTime(currentDate);
return toInsertedBarcodeInfo;
}
/**
*
*
@ -371,7 +413,7 @@ public class MesBaseBarcodeInfoServiceImpl implements IMesBaseBarcodeInfoService
MesBaseBarcodeInfo productBarcodeInfo = mesBaseBarcodeInfoMapper.selectMesBaseBarcodeInfoByBarcodeInfo(productBarcode);
if(productBarcodeInfo==null){
if (productBarcodeInfo == null) {
throw new ServiceException("成品条码不存在");
}
productBarcodeInfo.setPalletInfoCode("");

@ -9,7 +9,12 @@ import com.hw.common.core.exception.ServiceException;
import com.hw.common.core.utils.DateUtils;
import com.hw.common.core.utils.StringUtils;
import com.hw.common.security.utils.SecurityUtils;
import com.hw.mes.api.domain.MesBaseBarcodeInfo;
import com.hw.mes.api.domain.MesBaseMaterialInfo;
import com.hw.mes.domain.MesOrderBind;
import com.hw.mes.mapper.MesBaseBarcodeInfoMapper;
import com.hw.mes.mapper.MesBaseMaterialInfoMapper;
import com.hw.mes.service.IMesBaseMaterialInfoService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.hw.mes.mapper.MesPurchaseOrderMapper;
@ -28,6 +33,12 @@ public class MesPurchaseOrderServiceImpl implements IMesPurchaseOrderService {
@Autowired
private MesPurchaseOrderMapper mesPurchaseOrderMapper;
@Autowired
private MesBaseMaterialInfoMapper mesBaseMaterialInfoMapper;
@Autowired
private MesBaseBarcodeInfoMapper mesBaseBarcodeInfoMapper;
/**
*
*
@ -106,13 +117,34 @@ public class MesPurchaseOrderServiceImpl implements IMesPurchaseOrderService {
@Override
@Transactional
public int bindOrder(MesPurchaseOrder mesPurchaseOrder) {
//TODO:绑定前看看有没有生成的物料条码,或者判断采购订单状态是否已完成
Long erpMaterialId = mesPurchaseOrder.getMaterialId();
MesBaseMaterialInfo mesBaseMaterialInfo = mesBaseMaterialInfoMapper.selectMesBaseMaterialInfoByErpId(erpMaterialId);
if (mesBaseMaterialInfo == null) {
throw new ServiceException("物料信息不存在");
}
String bindFlag = mesBaseMaterialInfo.getBindFlag();
if (bindFlag == null) {
throw new ServiceException("请先设置物料信息的绑定标识");
}
if (!bindFlag.equals(MesConstants.MES_MATERIAL_BIND_FLAG_YES)) {
throw new ServiceException("此物料绑定标识为否,不需要绑定");
}
Long purchaseOrderId = mesPurchaseOrder.getPurchaseOrderId();
MesBaseBarcodeInfo queryBaseBarcodeInfo = new MesBaseBarcodeInfo();
queryBaseBarcodeInfo.setPurchaseOrderId(purchaseOrderId);
int mesBaseBarcodeInfoCount = mesBaseBarcodeInfoMapper.selectMesBaseBarcodeInfoCount(queryBaseBarcodeInfo);
if (mesBaseBarcodeInfoCount > 0) {
throw new ServiceException("此采购订单已经生成条码,不能再绑定");
}
mesPurchaseOrderMapper.deleteMesOrderBindByPurchaseOrderId(mesPurchaseOrder.getPurchaseOrderId());
Date currentDate = new Date();
String userName = SecurityUtils.getUsername();
Long purchaseOrderId = mesPurchaseOrder.getPurchaseOrderId();
Long erpMaterialId = mesPurchaseOrder.getMaterialId();
String materialCode = mesPurchaseOrder.getMaterialCode();
String materialName = mesPurchaseOrder.getMaterialName();
String poNo = mesPurchaseOrder.getPoNo();
@ -157,4 +189,24 @@ public class MesPurchaseOrderServiceImpl implements IMesPurchaseOrderService {
}
/**
* ,
*
* @param purchaseOrderId
* @return
*/
@Override
public MesPurchaseOrder selectCheckedPurchaseOrderByPurchaseOrderId(Long purchaseOrderId) {
MesPurchaseOrder mesPurchaseOrder = mesPurchaseOrderMapper.selectMesPurchaseOrderByPurchaseOrderId(purchaseOrderId);
Long erpMaterialId = mesPurchaseOrder.getMaterialId();
MesBaseMaterialInfo mesBaseMaterialInfo = mesBaseMaterialInfoMapper.selectMesBaseMaterialInfoByErpId(erpMaterialId);
if (mesBaseMaterialInfo == null) {
throw new ServiceException("物料信息不存在");
}
mesPurchaseOrder.setBindFlag(mesPurchaseOrder.getBindFlag());
return mesPurchaseOrder;
}
}

@ -50,12 +50,14 @@
bmi.material_type_id,
bmt.type_name material_type_name,
bmi.batch_flag,
bmi.batch_amount,
bmi.material_unit_id,
bmi.material_unit,
bmi.material_matkl,
bmi.material_spec,
bmi.net_weight,
bmi.gross_weight,
bmi.bind_flag,
bmi.factory_id,
bmi.create_org_id,
bmi.use_org_id,
@ -189,13 +191,15 @@
</if>
<if test="materialSubclass != null">material_subclass = #{materialSubclass},</if>
<if test="materialTypeId != null">material_type_id = #{materialTypeId},</if>
<if test="batchFlag != null">batch_flag = #{batchFlag},</if>
<if test="batchFlag != null and batchFlag != ''">batch_flag = #{batchFlag},</if>
<if test="batchAmount != null">batch_amount = #{batchAmount},</if>
<if test="materialUnitId != null">material_unit_id = #{materialUnitId},</if>
<if test="materialUnit != null">material_unit = #{materialUnit},</if>
<if test="materialMatkl != null">material_matkl = #{materialMatkl},</if>
<if test="materialSpec != null">material_spec = #{materialSpec},</if>
<if test="netWeight != null">net_weight = #{netWeight},</if>
<if test="grossWeight != null">gross_weight = #{grossWeight},</if>
<if test="bindFlag != null and bindFlag != ''">bind_flag = #{bindFlag},</if>
<if test="factoryId != null">factory_id = #{factoryId},</if>
<if test="createOrgId != null">create_org_id = #{createOrgId},</if>
<if test="useOrgId != null">use_org_id = #{useOrgId},</if>
@ -317,6 +321,7 @@
bmi.material_spec,
bmi.net_weight,
bmi.gross_weight,
bmi.bind_flag,
bmi.factory_id,
bmi.create_org_id,
bmi.use_org_id,

@ -324,7 +324,7 @@
<select id="selectMesProductPlanJoinList" parameterType="MesProductPlan" resultMap="MesProductPlanResult">
select mpp.plan_id, mpp.product_order_id, mpp.plan_code, mpp.dispatch_code, mpp.material_id,
select mpp.plan_id, mpp.product_order_id, mpp.sale_order_id,mpp.saleorder_code,mpp.plan_code, mpp.dispatch_code, mpp.material_id,
mpp.material_bom_id, mpp.process_id, mpp.process_order, mpp.last_process_id,
mpp.station_id, mpp.plan_amount, mpp.complete_amount, mpp.plan_begin_time, mpp.plan_end_time,
mpp.real_begin_time, mpp.real_end_time,

@ -65,3 +65,12 @@ export function bindOrder(data) {
})
}
// 查询采购订单信息详细,校验是否需要绑定
export function getCheckedPurchaseOrder(purchaseOrderId) {
return request({
url: '/mes/purchaseOrder/getCheckedPurchaseOrder/' + purchaseOrderId,
method: 'get'
})
}

@ -110,6 +110,11 @@
</el-table-column>
<el-table-column label="采购订单号" align="center" prop="poNo" v-if="columns[13].visible" width="100"/>
<el-table-column label="销售订单号" align="center" prop="saleorderCode" v-if="columns[29].visible" width="100"/>
<el-table-column label="安全库存" align="center" prop="safeFlag" v-if="columns[30].visible" width="100">
<template slot-scope="scope">
<dict-tag :options="dict.type.mes_safe_flag" :value="scope.row.safeFlag"/>
</template>
</el-table-column>
<el-table-column label="批次代码" align="center" prop="batchCode" v-if="columns[6].visible" width="100"/>
<el-table-column label="条码内容" align="center" prop="barcodeInfo" v-if="columns[5].visible" width="100"/>
@ -409,7 +414,7 @@ import addPurchaseOrder from '@//views/mes/purchaseOrder/addPurchaseOrder.vue';
export default {
name: "Barcode",
dicts: ['bind_status', 'active_flag', 'barcode_type'],
dicts: ['bind_status', 'active_flag', 'barcode_type','mes_safe_flag'],
components: {
'add-purchaseOrder': addPurchaseOrder
},
@ -521,6 +526,7 @@ export default {
{key: 27, label: `更新人`, visible: false},
{key: 28, label: `更新时间`, visible: false},
{key: 29, label: `销售订单号`, visible: true},
{key: 30, label: `安全库存`, visible: true},
],

Loading…
Cancel
Save