车间生产:
1、4楼装配工位开始、申请退库、条码逻辑完善
master
xs 7 months ago
parent 3cc7e0aae9
commit a8a4f9de4d

@ -1,5 +1,8 @@
package com.hw.common.core.constant;
import java.util.HashMap;
import java.util.Map;
/**
* @Description:
* @ProjectName:HwMes
@ -53,6 +56,19 @@ public class MesConstants {
/** 工单状态9-已删除 */
public static final String DELETE = "9";
public static final Map<String, String> ORDER_STATUS_PROMPT_MAP = new HashMap<>();
static {
ORDER_STATUS_PROMPT_MAP.put(UN_PUBLISH, "待发布");
ORDER_STATUS_PROMPT_MAP.put(PUBLISHED, "已发布");
ORDER_STATUS_PROMPT_MAP.put(FINISHED, "已完成");
ORDER_STATUS_PROMPT_MAP.put(BEGIN, "已开始");
ORDER_STATUS_PROMPT_MAP.put(PAUSE, "已暂停");
ORDER_STATUS_PROMPT_MAP.put(RECALL, "已撤回");
ORDER_STATUS_PROMPT_MAP.put(DELETE, "已删除");
// 初始化其他映射...
}
/*生产计划明细状态*/
public static final String MES_PRODUCT_PLAN_DETAIL_STATUS_TO_START = "1";//未开始
@ -111,4 +127,8 @@ public class MesConstants {
/**物料条码打印标识*/
public static final String MES_BARCODE_PRINT_FLAG_YES = "1";//是
public static final String MES_BARCODE_PRINT_FLAG_NO = "0";//否
}

@ -235,4 +235,8 @@ public class WmsConstants {
// public static final String WMS_INVENTORY_CHECK_DETAIL_STATUS_TO_INVENTORY = "0";//待盘点
public static final String WMS_INVENTORY_CHECK_DETAIL_STATUS_INVENTORYING = "1";//盘点中
public static final String WMS_INVENTORY_CHECK_DETAIL_STATUS_FINISH = "2";//盘点完成
//车间生产区域类型
public static final String MES_AREA_TYPE_FOUTHFLOOR_ASSEMBLE = "3";//四楼装配区域
}

@ -7,10 +7,7 @@ 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.domain.MesMaterialAssignInfo;
import com.hw.mes.domain.MesMaterialCheckResult;
import com.hw.mes.domain.MesProductPlan;
import com.hw.mes.domain.MesProductPlanDetail;
import com.hw.mes.domain.*;
import com.hw.mes.domain.vo.MesProductPlanDetailVo;
import com.hw.mes.mapper.*;
import com.hw.mes.service.IMesProductPlanDetailService;
@ -47,6 +44,9 @@ public class MesProductPlanDetailServiceImpl implements IMesProductPlanDetailSer
@Autowired
private MesMaterialAssignInfoMapper mesMaterialAssignInfoMapper;
@Autowired
private MesProductOrderMapper mesProductOrderMapper;
/**
*
*
@ -186,11 +186,29 @@ public class MesProductPlanDetailServiceImpl implements IMesProductPlanDetailSer
throw new ServiceException("此生产计划已结束");
}
//todo:在开始生产计划时,更新生产工单状态、开始时间
MesProductOrder productOrder = mesProductOrderMapper.selectMesProductOrderByProductOrderId(dbProductPlan.getProductOrderId());
if(productOrder==null){
throw new ServiceException("无此生产工单");
}
String orderStatus = productOrder.getOrderStatus();
if(!orderStatus.equals(MesConstants.BEGIN) && !orderStatus.equals(MesConstants.PUBLISHED)){
String orderStatusPrompt = MesConstants.ORDER_STATUS_PROMPT_MAP.get(orderStatus);
throw new ServiceException(String.format("此生产工单已经%s,不能开始!", orderStatusPrompt));
}
Date currentDate = new Date();
String userName = SecurityUtils.getUsername();
Long userId = SecurityUtils.getUserId();
if(orderStatus.equals(MesConstants.PUBLISHED)){
productOrder.setOrderStatus(MesConstants.BEGIN);
productOrder.setRealBeginTime(currentDate);
productOrder.setUpdateBy(userName);
productOrder.setUpdateTime(currentDate);
mesProductOrderMapper.updateMesProductOrder(productOrder);
}
if (planStatus.equals(MesConstants.MES_PRODUCT_PLAN_STATUS_DISPATCHED)) {
dbProductPlan.setRealBeginTime(currentDate);
dbProductPlan.setPlanStatus(MesConstants.MES_PRODUCT_PLAN_STATUS_STARTED);

@ -39,6 +39,11 @@ public class WmsConfig
*/
private Long fourthFloorPalteWarehouseId;
/**
* ID
*/
private Long fourthFloorPartsWarehouseId;
public String getFifthAssembleStationCode() {
return fifthAssembleStationCode;
@ -79,4 +84,12 @@ public class WmsConfig
public void setFourthFloorPalteWarehouseId(Long fourthFloorPalteWarehouseId) {
this.fourthFloorPalteWarehouseId = fourthFloorPalteWarehouseId;
}
public Long getFourthFloorPartsWarehouseId() {
return fourthFloorPartsWarehouseId;
}
public void setFourthFloorPartsWarehouseId(Long fourthFloorPartsWarehouseId) {
this.fourthFloorPartsWarehouseId = fourthFloorPartsWarehouseId;
}
}

@ -2,6 +2,7 @@ package com.hw.wms.controller;
import com.alibaba.fastjson2.JSONObject;
import com.hw.common.core.constant.WmsConstants;
import com.hw.common.core.utils.StringUtils;
import com.hw.common.core.web.controller.BaseController;
import com.hw.common.core.web.domain.AjaxResult;
import com.hw.common.core.web.page.TableDataInfo;

@ -182,6 +182,8 @@ public class WmsBaseWarehouse extends BaseEntity {
private String materialBarcode;
/**车间区域类型1、1楼生产工位2、四楼激光切割区域3、四楼装配区域*/
private String mesAreaType;
public void setWarehouseId(Long warehouseId) {
this.warehouseId = warehouseId;
@ -415,6 +417,14 @@ public class WmsBaseWarehouse extends BaseEntity {
this.materialBarcode = materialBarcode;
}
public String getMesAreaType() {
return mesAreaType;
}
public void setMesAreaType(String mesAreaType) {
this.mesAreaType = mesAreaType;
}
@Override
public String toString() {
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)

@ -1,7 +1,11 @@
package com.hw.wms.service.impl;
import java.util.List;
import com.hw.common.core.constant.WmsConstants;
import com.hw.common.core.utils.DateUtils;
import com.hw.common.core.utils.StringUtils;
import com.hw.wms.config.WmsConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.hw.wms.mapper.WmsBaseWarehouseMapper;
@ -20,6 +24,9 @@ public class WmsBaseWarehouseServiceImpl implements IWmsBaseWarehouseService
@Autowired
private WmsBaseWarehouseMapper wmsBaseWarehouseMapper;
@Autowired
private WmsConfig wmsConfig;
/**
*
*
@ -41,6 +48,11 @@ public class WmsBaseWarehouseServiceImpl implements IWmsBaseWarehouseService
@Override
public List<WmsBaseWarehouse> selectWmsBaseWarehouseList(WmsBaseWarehouse wmsBaseWarehouse)
{
if(StringUtils.isNotEmpty(wmsBaseWarehouse.getMesAreaType())){
if(wmsBaseWarehouse.getMesAreaType().equals(WmsConstants.MES_AREA_TYPE_FOUTHFLOOR_ASSEMBLE)){
wmsBaseWarehouse.setWarehouseId(wmsConfig.getFourthFloorPartsWarehouseId());
}
}
return wmsBaseWarehouseMapper.selectWmsBaseWarehouseList(wmsBaseWarehouse);
}

@ -344,7 +344,7 @@ public class WmsRawReturnServiceImpl implements IWmsRawReturnService {
Date currentDate = new Date();
String userName = SecurityUtils.getUsername();
//更新退库记录执行状态
wmsRawReturn.setExecuteStatus( WmsConstants.WMS_EXECUTE_STATUS_FINISH);
wmsRawReturn.setExecuteStatus(WmsConstants.WMS_EXECUTE_STATUS_FINISH);
wmsRawReturn.setLocationCode(locationCode);
wmsRawReturn.setReturnAmount(returnAmount);
wmsRawReturn.setUpdateDate(currentDate);
@ -465,67 +465,77 @@ public class WmsRawReturnServiceImpl implements IWmsRawReturnService {
@Transactional(rollbackFor = Exception.class)
@Override
public int applyRawReturn(List<WmsRawReturn> wmsRawReturns) {
//申请退库不指定库位,申请退库的多个物料生成多条退库记录
//申请退库不指定库位,申请退库的多个物料生成多条退库记录,目前按每个条码物料申请退库
//根据仓库ID分组获取总申请数量
Map<Long, List<WmsRawReturn>> rawReturnsMap = wmsRawReturns.stream()
.collect(Collectors.groupingBy(WmsRawReturn::getWarehouseId));
// Map<Long, List<WmsRawReturn>> rawReturnsMap = wmsRawReturns.stream()
// .collect(Collectors.groupingBy(WmsRawReturn::getWarehouseId));
WmsRawReturn firstWmsRawReturn = wmsRawReturns.get(0);
Long warehouseId = firstWmsRawReturn.getWarehouseId();
WmsBaseWarehouse baseWarehouse = wmsBaseWarehouseMapper.selectWmsBaseWarehouseByWarehouseId(warehouseId);
String warehouseType = baseWarehouse.getWarehouseType();
String returnRequirement = baseWarehouse.getReturnRequirement();
String operationType = WmsConstants.OPERATION_TYPE_MAP.get(warehouseType);
String auditStatus = "";
if (warehouseType.equals(WmsConstants.WMS_WAREHOUSE_TYPE_NORMAL)) {//如果是普通仓库,需要校验审核标识
if (returnRequirement.equals(WmsConstants.WMS_WAREHOUSE_RETURN_REQUIREMENT_APPLY_AUDIT)) {
auditStatus = WmsConstants.WMS_AUDIT_STATUS_TOAUDIT;
} else {
auditStatus = WmsConstants.WMS_AUDIT_STATUS_PASS;
}
} else {
auditStatus = WmsConstants.WMS_AUDIT_STATUS_PASS;
}
List<WmsRawReturn> toInsertedRawReturns = new ArrayList<>();
Date currentDate = new Date();
String userName = SecurityUtils.getUsername();
String taskCode = Seq.getId(Seq.rawReturnSeqType, Seq.rawReturnCode);
for (Long warehouseId : rawReturnsMap.keySet()) {
List<WmsRawReturn> rawReturnList = rawReturnsMap.get(warehouseId);
WmsBaseWarehouse baseWarehouse = wmsBaseWarehouseMapper.selectWmsBaseWarehouseByWarehouseId(warehouseId);
String warehouseType = baseWarehouse.getWarehouseType();
String returnRequirement = baseWarehouse.getReturnRequirement();
String operationType = WmsConstants.OPERATION_TYPE_MAP.get(warehouseType);
String auditStatus = "";
if (warehouseType.equals(WmsConstants.WMS_WAREHOUSE_TYPE_NORMAL)) {//如果是普通仓库,需要校验审核标识
if (returnRequirement.equals(WmsConstants.WMS_WAREHOUSE_RETURN_REQUIREMENT_APPLY_AUDIT)) {
auditStatus = WmsConstants.WMS_AUDIT_STATUS_TOAUDIT;
} else {
auditStatus = WmsConstants.WMS_AUDIT_STATUS_PASS;
}
} else {
auditStatus = WmsConstants.WMS_AUDIT_STATUS_PASS;
for (WmsRawReturn rawReturn : wmsRawReturns) {
BigDecimal planAmount = rawReturn.getPlanAmount();
if (planAmount.compareTo(BigDecimal.ZERO) <= 0) {
throw new ServiceException("数量需大于0");
}
for (WmsRawReturn rawReturn : rawReturnList) {
BigDecimal planAmount = rawReturn.getPlanAmount();
if (planAmount.compareTo(BigDecimal.ZERO) <= 0) {
throw new ServiceException("数量需大于0");
}
String materialBarcode = rawReturn.getMaterialBarcode();
R<MesBaseBarcodeInfo> baseBarcodeInfoR = remoteMesService.getBarcode(materialBarcode, SecurityConstants.INNER);
MesBaseBarcodeInfo baseBarcodeInfo = baseBarcodeInfoR.getData();
if (baseBarcodeInfo == null) {
throw new ServiceException("物料编码有误");
}
String batchFlag = baseBarcodeInfo.getBatchFlag();
if (!batchFlag.equals(MesConstants.IS_BATCH)) {
if (planAmount.compareTo(BigDecimal.ONE) != 0) {
throw new ServiceException("非批次物料数量需等于1");
}
String materialBarcode = rawReturn.getMaterialBarcode();
R<MesBaseBarcodeInfo> baseBarcodeInfoR = remoteMesService.getBarcode(materialBarcode, SecurityConstants.INNER);
if (baseBarcodeInfoR == null) {
throw new ServiceException("物料编码有误");
}
MesBaseBarcodeInfo baseBarcodeInfo = baseBarcodeInfoR.getData();
if (baseBarcodeInfo == null) {
throw new ServiceException("物料编码有误");
}
String batchFlag = baseBarcodeInfo.getBatchFlag();
if (!batchFlag.equals(MesConstants.IS_BATCH)) {
if (planAmount.compareTo(BigDecimal.ONE) != 0) {
throw new ServiceException("非批次物料数量需等于1");
}
}
if (!baseBarcodeInfo.getBarcodeType().equals(MesConstants.MES_BARCODE_TYPE_RAW)) {
throw new ServiceException("物料编码有误,此物料编码非原材料编码");
}
rawReturn.setTaskCode(taskCode);
rawReturn.setExecuteStatus(WmsConstants.WMS_EXECUTE_STATUS_TOEXECUTE);
rawReturn.setEndStationCode(baseWarehouse.getAgvPositionCode());
rawReturn.setOperationType(operationType);
rawReturn.setAuditStatus(auditStatus);
rawReturn.setReturnAmount(BigDecimal.ZERO);
rawReturn.setMaterialId(baseBarcodeInfo.getMaterialId());
rawReturn.setBatchCode(baseBarcodeInfo.getBatchCode());
rawReturn.setApplyBy(userName);
rawReturn.setApplyDate(currentDate);
toInsertedRawReturns.add(rawReturn);
WmsRawStock existedRawStock = wmsRawStockMapper.selectRawStockByBarcode(materialBarcode);
if (existedRawStock != null && existedRawStock.getTotalAmount().compareTo(BigDecimal.ZERO) > 0) {
throw new ServiceException("此物料条码在仓库中存在");
}
wmsRawReturnMapper.batchWmsRawReturn(toInsertedRawReturns);
rawReturn.setTaskCode(taskCode);
rawReturn.setExecuteStatus(WmsConstants.WMS_EXECUTE_STATUS_TOEXECUTE);
rawReturn.setEndStationCode(baseWarehouse.getAgvPositionCode());
rawReturn.setOperationType(operationType);
rawReturn.setAuditStatus(auditStatus);
rawReturn.setReturnAmount(BigDecimal.ZERO);
rawReturn.setMaterialId(baseBarcodeInfo.getMaterialId());
rawReturn.setBatchCode(baseBarcodeInfo.getBatchCode());
rawReturn.setApplyBy(userName);
rawReturn.setApplyDate(currentDate);
toInsertedRawReturns.add(rawReturn);
}
wmsRawReturnMapper.batchWmsRawReturn(toInsertedRawReturns);
return 1;
}

@ -82,6 +82,7 @@
<select id="selectWmsBaseWarehouseList" parameterType="WmsBaseWarehouse" resultMap="WmsBaseWarehouseResult">
<include refid="selectWmsBaseWarehouseVo"/>
<where>
<if test="warehouseId != null "> and warehouse_id = #{warehouseId}</if>
<if test="warehouseInstockType != null and warehouseInstockType != ''"> and warehouse_instock_type = #{warehouseInstockType}</if>
<if test="warehouseType != null and warehouseType != ''"> and warehouse_type = #{warehouseType}</if>
<if test="warehouseCode != null and warehouseCode != ''"> and warehouse_code = #{warehouseCode}</if>

@ -176,7 +176,7 @@
@click="returnMaterial(scope)"
v-if="scope.row.planDetailStatus !== PLAN_DETAIL_STATUS.TO_START"
>
退
退
</el-button>
<el-button
size="small"
@ -358,7 +358,7 @@
<el-button @click="cancelMaterialConfirm"> </el-button>
</div>
</el-dialog>
<el-dialog :visible.sync="returnModelVisible" title="退料" width="25%">
<el-dialog :visible.sync="returnModelVisible" title="申请退库" width="400">
<el-form ref="returnModelForm" :model="returnModelForm" label-width="80px" :rules="returnModelFormRules">
<el-form-item label="计划编号">
<el-input v-model="returnModelForm.planCode" autocomplete="off" disabled></el-input>
@ -366,26 +366,24 @@
<el-form-item label="明细编号">
<el-input v-model="returnModelForm.planDetailCode" autocomplete="off" disabled></el-input>
</el-form-item>
<el-form-item label="成品">
<!--el-form-item label="成品">
<el-input v-model="returnModelForm.materialName" autocomplete="off" disabled></el-input>
</el-form-item>
</el-form-item-->
<el-form-item label="物料条码">
<el-input placeholder="请输入内容" v-model="returnModelForm.materialBarcode" class="input-with-select"
@blur="setReturnModelForm">
<el-button slot="append" icon="el-icon-search"></el-button>
<el-input placeholder="请扫描或输入物料条码" v-model="returnModelForm.materialBarcode" suffix-icon="el-icon-camera">
</el-input>
</el-form-item>
<el-form-item label="仓库">
<el-select v-model="returnModelForm.warehouseId" placeholder="请选择仓库"
:disabled="!returnModelForm.materialBarcode">
style="width: 260px">
<el-option :label="i.label" :key="i.value" :value="i.value" v-for="i in WarehousesList"></el-option>
</el-select>
</el-form-item>
<el-form-item label="数量">
<el-input-number v-model="returnModelForm.planAmount" controls-position="right" :min="1"></el-input-number>
<el-form-item label="数量" prop="planAmount">
<el-input-number v-model="returnModelForm.planAmount" controls-position="right" :min="1" style="width: 260px"></el-input-number>
</el-form-item>
<el-form-item label="退库类型" prop="taskType">
<el-select v-model="returnModelForm.taskType" placeholder="请选择退库类型">
<el-select v-model="returnModelForm.taskType" placeholder="请选择退库类型" style="width: 260px">
<el-option :label="i.label" :key="i.value" :value="i.value"
v-for="i in dict.type.wms_raw_return_task_type"></el-option>
</el-select>
@ -486,6 +484,9 @@ export default {
taskType: [
{required: true, message: '请选择退库类型', trigger: 'change'}
],
planAmount: [
{required: true, message: '请输入数量', trigger: 'change'}
],
},
PLAN_DETAIL_STATUS:{
@ -493,7 +494,7 @@ export default {
STARTED : '2',
FINISHED : '3',
ABNORMAL_FINISHED : '9'
}
},
}
},
created() {
@ -1068,32 +1069,48 @@ export default {
returnMaterial(e) {
this.returnModelVisible = true
this.returnModelForm = e.row
this.setReturnModelForm();
if (!this.checkSerialConnected()) {
this.$confirm('请连接条码枪', '提示', {
confirmButtonText: '连接',
showClose: true,
showCancelButton: true,
type: 'warning'
}).then(() => {
console.log("dddd")
this.connectSerial(this.setSerialData);
}).catch(() => {
});
}
},
setReturnModelForm() {
getWarehouses({
warehouseFloor: 4,
materialBarcode: this.returnModelForm.materialBarcode
mesAreaType : 3, //4
//warehouseFloor: 4,
//materialBarcode: this.returnModelForm.materialBarcode
}).then(e => {
this.WarehousesList = e.data.map(v => {
return {
label: v.warehouseName,
value: v.warehouseId,
}
})
});
if(this.WarehousesList && this.WarehousesList.length>0){
this.returnModelForm.warehouseId = this.WarehousesList[0].value;
}
})
},
returnModelConfirm() {
this.$refs.returnModelForm.validate((valid) => {
if (valid) {
let data = {}
let keys = ['warehouseId', 'planCode', 'planDetailCode', 'productId', 'materialBarcode', 'planAmount', 'taskType', 'applyReason']
keys.forEach(v => {
data[v] = this.returnModelForm[v]
})
let data = [this.returnModelForm]
applyRawReturn(data).then(v => {
if (v.code === 200) {
this.$message({
message: '退库成功',
message: '申请退库成功',
type: 'success'
});
}
@ -1135,6 +1152,8 @@ export default {
this.materialConfirmForm.materialBarcode = this.serialData;
} else if (this.productInstockVisible) {
this.productInstockForm.materialBarcode = this.serialData;
} else if(this.returnModelVisible){
this.returnModelForm.materialBarcode = this.serialData;
}
// console.log(this.serialData)
}

Loading…
Cancel
Save