添加 机型 分销

This commit is contained in:
liuhanqing
2025-09-15 16:34:26 +08:00
parent 0dceed3906
commit c744fa94b6
7 changed files with 246 additions and 76 deletions

View File

@@ -0,0 +1,153 @@
package com.ruoyi.bas.BasProductCode.util;
import java.util.ArrayList;
import java.util.List;
public class ProcodeUtils {
// 定义密钥,与原始逻辑保持一致
private static final String KEY = "0";
/**
* 按照指定规则对输入字符串进行编码
* @param text 输入字符串,格式为"订单号@型号@机型@分销@序列号"
* @return 编码后的字符串
*/
public static String encode(String text) {
// 按@分割字符串
String[] parts = text.split("@");
// 验证输入格式是否正确
if (parts.length < 5) {
throw new IllegalArgumentException("输入格式不正确,应为\"订单号@型号@机型@分销@序列号\"");
}
// 构建中间字符串
String text1 = "@" + parts[1] + "@" + parts[2] + "@" + parts[3] + "@";
String str = KEY + text1;
// 处理每个字符为4位十六进制
StringBuilder hexBuilder = new StringBuilder();
for (int i = 0; i < str.length(); i++) {
char c = str.charAt(i);
// 获取Unicode编码并转换为4位十六进制
hexBuilder.append(String.format("%04X", (int) c));
}
// 反转字符串
String reversedHex = new StringBuilder(hexBuilder.toString()).reverse().toString();
// 替换操作
String replaced = reversedHex
.replace("100", "Q")
.replace("200", "R")
.replace("300", "S")
.replace("400", "T")
.replace("500", "U")
.replace("600", "V")
.replace("700", "W")
.replace("800", "X")
.replace("900", "Y")
.replace("00", "Z");
// 构建最终结果并反转
String result = parts[0] + "$" + replaced + "$" + parts[4];
return new StringBuilder(result).reverse().toString();
}
/**
* 解析编码后的字符串,还原原始信息
* @param encodedStr 编码后的字符串
* @return 原始信息数组,格式为[订单号, 型号, 机型, 分销, 序列号]
*/
public static String[] decode(String encodedStr) {
// 步骤1:整体反转字符串
String reversed = new StringBuilder(encodedStr).reverse().toString();
// 步骤2:按$分割为三部分
String[] parts = reversed.split("\\$");
if (parts.length != 3) {
throw new IllegalArgumentException("编码字符串格式不正确");
}
String orderNo = parts[0]; // 订单号
String encodedPart = parts[1]; // 编码的中间部分
String serialNo = parts[2]; // 序列号
// 步骤3:逆向替换操作,恢复十六进制片段
String replaced = encodedPart
.replace("Q", "100")
.replace("R", "200")
.replace("S", "300")
.replace("T", "400")
.replace("U", "500")
.replace("V", "600")
.replace("W", "700")
.replace("X", "800")
.replace("Y", "900")
.replace("Z", "00");
// 步骤4:再次反转,恢复十六进制顺序
String hexStr = new StringBuilder(replaced).reverse().toString();
// 步骤5:按4位分割,转换为字符
List<Character> chars = new ArrayList<>();
for (int i = 0; i < hexStr.length(); i += 4) {
int endIndex = Math.min(i + 4, hexStr.length());
String hexSegment = hexStr.substring(i, endIndex);
// 不足4位的补0
if (hexSegment.length() < 4) {
hexSegment = String.format("%-" + 4 + "s", hexSegment).replace(' ', '0');
}
// 十六进制转字符
try {
int code = Integer.parseInt(hexSegment, 16);
chars.add((char) code);
} catch (NumberFormatException e) {
throw new RuntimeException("解析十六进制时出错: " + hexSegment, e);
}
}
// 拼接字符得到原始中间字符串
StringBuilder middleStr = new StringBuilder();
for (char c : chars) {
middleStr.append(c);
}
// 步骤6:提取型号、机型、分销信息(去掉key和前后的@)
if (middleStr.length() < 1) {
throw new RuntimeException("解析中间信息失败,中间字符串为空");
}
String text1 = middleStr.substring(1); // 去掉key(第一个字符)
String[] infoParts = text1.split("@");
if (infoParts.length < 4) {
throw new RuntimeException("解析中间信息失败,格式不正确");
}
String model = infoParts[1]; // 型号
String machineType = infoParts[2]; // 机型
String distribution = infoParts[3]; // 分销
return new String[]{orderNo, model, machineType, distribution, serialNo};
}
// 测试方法
public static void main(String[] args) {
// 测试编码
String original = "123456789@M-221F@12@13@25318S7000F03";
System.out.println("原始字符串: " + original);
String encoded = encode(original);
System.out.println("编码结果: " + encoded);
// 测试解码
String[] decoded = decode("30F0007S81352$S0T0TDRDS2S2S1T6T0S1S2T0S1S3T0$654321");
System.out.println("解码结果:");
System.out.println("订单号: " + decoded[0]);
System.out.println("型号: " + decoded[1]);
System.out.println("机型: " + decoded[2]);
System.out.println("分销: " + decoded[3]);
System.out.println("序列号: " + decoded[4]);
}
}

View File

@@ -147,10 +147,13 @@ public class MydoJobDetail extends BaseEntity
@Excel(name = "毛重")
private String spare8;
/** 备用字段4 */
@Excel(name = "分销")
private String spare9;
/** 备用字段4 */
@Excel(name = "规格")
private String spec;
@Excel(name = "机型")
private String unit;
}

View File

@@ -38,6 +38,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="spare8" column="spare8" />
<result property="spare9" column="spare9" />
<result property="spec" column="spec" />
<result property="unit" column="unit" />
</resultMap>
@@ -75,7 +76,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
mjd.spare7,
mjd.spare8,
mjd.spare9,
mjd.spec
mjd.spec,
mjd.unit
from mydo_job_detail_finish mjd
left join bas_product bp on mjd.product_id = bp.product_id
<where>
@@ -142,7 +144,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
mjd.spare7,
mjd.spare8,
mjd.spare9,
mjd.spec
mjd.spec,
mjd.unit
from mydo_job_detail_finish mjd
left join bas_product bp on mjd.product_id = bp.product_id
where job_id = #{jobId}
@@ -182,7 +185,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
mjd.spare7,
mjd.spare8,
mjd.spare9,
mjd.spec
mjd.spec,
mjd.unit
from mydo_job_detail_finish mjd
left join bas_product bp on mjd.product_id = bp.product_id
where job_detail_id = #{jobDetailId}

View File

@@ -39,6 +39,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="spare8" column="spare8" />
<result property="spare9" column="spare9" />
<result property="spec" column="spec" />
<result property="unit" column="unit" />
</resultMap>
<select id="selectMydoJobDetailList" parameterType="MydoJobDetail" resultMap="MydoJobDetailResult">
@@ -76,7 +77,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
mjd.spare7,
mjd.spare8,
mjd.spare9,
mjd.spec
mjd.spec,
mjd.unit
from mydo_job_detail mjd
left join bas_product bp on mjd.product_id = bp.product_id
@@ -146,7 +148,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
mjd.spare7,
mjd.spare8,
mjd.spare9,
mjd.spec
mjd.spec,
mjd.unit
from mydo_job_detail mjd
left join bas_product bp on mjd.product_id = bp.product_id
@@ -187,7 +190,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
mjd.spare7,
mjd.spare8,
mjd.spare9,
mjd.spec
mjd.spec,
mjd.unit
from mydo_job_detail mjd
left join bas_product bp on mjd.product_id = bp.product_id

View File

@@ -10,14 +10,14 @@
</div>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-row :gutter="20">
<el-col
v-for="field in formFields"
:key="field.prop"
<el-col
v-for="field in formFields"
:key="field.prop"
:span="24"
>
<el-form-item :label="field.label" :prop="field.prop">
<el-input
v-model="form[field.prop]"
<el-input
v-model="form[field.prop]"
:placeholder="field.placeholder"
:disabled="loading"
/>
@@ -25,15 +25,15 @@
</el-col>
</el-row>
<el-form-item class="form-actions">
<el-button
type="warning"
<el-button
type="warning"
@click="handlePreview"
:loading="previewLoading"
icon="el-icon-view"
>
预览
</el-button>
<el-button
<el-button
@click="resetForm"
icon="el-icon-refresh"
>
@@ -45,7 +45,7 @@
</el-col>
<!-- 右侧预览区域 -->
<el-col :span="16">
<!-- 预览弹框 -->
@@ -99,10 +99,10 @@
</div>
<!-- 二维码区域 -->
<div class="qrcode-container">
<vue-qr
:text="qrCodeValue"
:size="180"
:margin="0"
<vue-qr
:text="qrCodeValue"
:size="180"
:margin="0"
:correctLevel="2"
error-correction-level="M"
/>
@@ -156,10 +156,10 @@
</div>
<!-- 二维码区域 -->
<div class="qrcode-container">
<vue-qr
:text="qrCodeValue"
:size="180"
:margin="0"
<vue-qr
:text="qrCodeValue"
:size="180"
:margin="0"
:correctLevel="2"
error-correction-level="M"
/>
@@ -173,14 +173,14 @@
<el-button type="primary" @click="submitForm" :loading="submitLoading">保存并打印</el-button>
</div>
</el-dialog>
<!-- 历史数据区域 -->
<div class="list-container" style="padding-bottom: 60px;">
<div class="section-header" style="margin-bottom: 40px;">
<h3>历史数据</h3>
<div class="header-actions">
<el-button
type="danger"
<el-button
type="danger"
size="small"
@click="handleBatchDelete"
:disabled="!hasSelection"
@@ -201,10 +201,10 @@
style="width: 100%;margin-bottom: 40px;height: 550px;"
>
<el-table-column type="selection" width="55" align="center"/>
<el-table-column
v-for="column in tableColumns"
<el-table-column
v-for="column in tableColumns"
:key="column.prop"
:label="column.label"
:label="column.label"
:prop="column.prop"
:width="column.width"
:formatter="column.formatter"
@@ -345,6 +345,7 @@ export default {
computed: {
// 二维码内容
qrCodeValue() {
console.log(this.previewData)
const text = `${this.previewData.spare1}@${this.previewData.model}@${this.previewData.spare2}@${this.previewData.spare3}@${this.previewData.serial}`
return this.procode(text)
},
@@ -914,17 +915,17 @@ export default {
margin: 0;
size: auto;
}
body {
margin: 0;
}
.preview-box {
border: none;
box-shadow: none;
position: relative;
}
.qrcode-container {
border: none;
position: absolute !important;

View File

@@ -134,11 +134,11 @@
<dict-tag :options="dict.type.mydo_job_status" :value="scope.row.status"/>
</template>
</el-table-column>
<el-table-column label="上线类型" align="left" prop="onLineType">
<template slot-scope="scope">
<dict-tag :options="dict.type.on_line_type" :value="scope.row.onLineType"/>
</template>
</el-table-column>
<!-- <el-table-column label="上线类型" align="left" prop="onLineType">-->
<!-- <template slot-scope="scope">-->
<!-- <dict-tag :options="dict.type.on_line_type" :value="scope.row.onLineType"/>-->
<!-- </template>-->
<!-- </el-table-column>-->
<el-table-column label="任务类型" align="left" prop="inOrOut">
<template slot-scope="scope">
<dict-tag :options="dict.type.in_job_type" :value="scope.row.inOrOut"/>
@@ -173,12 +173,14 @@
max-height="300"
>
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="任务明细ID" align="left" prop="jobDetailId" />
<el-table-column label="子任务ID" align="left" prop="jobDetailId" />
<el-table-column label="任务ID" align="left" prop="jobId" />
<el-table-column label="单据ID" align="left" prop="inOrOutId" />
<el-table-column label="子单据ID" align="left" prop="inOrOutDId" />
<el-table-column label="物料编码" align="left" prop="productId" />
<el-table-column label="物料名称" align="left" prop="productName" />
<el-table-column label="机型" align="left" prop="unit"/><!--机型-->
<el-table-column label="分销" align="left" prop="spare9"/><!--分销-->
<el-table-column label="规格" align="left" prop="spec"/><!--规格-->
<el-table-column label="型号" align="left" prop="spare1"/><!--型号-->
<el-table-column label="净重" align="left" prop="spare2"/><!--净重-->

View File

@@ -1,10 +1,10 @@
<template>
<div class="app-container">
<el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
<el-form-item label="入库订单ID" prop="stockinId"><!--入库订单ID-->
<el-form-item label="订单号" prop="erpBill"><!--入库订单ID-->
<el-input
v-model="queryParams.stockinId"
placeholder="请输入入库订单ID"
v-model="queryParams.erpBill"
placeholder="请输入订单号"
clearable
@keyup.enter.native="handleQuery"
/>
@@ -38,29 +38,29 @@
/>
</el-select>
</el-form-item>
<el-form-item label="仓库" prop="warehouseId"><!--仓库-->
<el-select
v-model="queryParams.warehouseId"
placeholder="请选择仓库"
clearable
@change="handleQuery"
>
<el-option
v-for="item in warehouseOptions"
:key="item.warehouseId"
:label="item.warehouseName"
:value="item.warehouseId"
/>
</el-select>
</el-form-item>
<el-form-item label="供应商编码" prop="supplierNo"><!--供应商编码-->
<el-input
v-model="queryParams.supplierNo"
placeholder="请输入供应商编码"
clearable
@keyup.enter.native="handleQuery"
/>
</el-form-item>
<!-- <el-form-item label="仓库" prop="warehouseId">&lt;!&ndash;仓库&ndash;&gt;-->
<!-- <el-select-->
<!-- v-model="queryParams.warehouseId"-->
<!-- placeholder="请选择仓库"-->
<!-- clearable-->
<!-- @change="handleQuery"-->
<!-- >-->
<!-- <el-option-->
<!-- v-for="item in warehouseOptions"-->
<!-- :key="item.warehouseId"-->
<!-- :label="item.warehouseName"-->
<!-- :value="item.warehouseId"-->
<!-- />-->
<!-- </el-select>-->
<!-- </el-form-item>-->
<!-- <el-form-item label="供应商编码" prop="supplierNo">&lt;!&ndash;供应商编码&ndash;&gt;-->
<!-- <el-input-->
<!-- v-model="queryParams.supplierNo"-->
<!-- placeholder="请输入供应商编码"-->
<!-- clearable-->
<!-- @keyup.enter.native="handleQuery"-->
<!-- />-->
<!-- </el-form-item>-->
<el-form-item>
<el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button><!--搜索-->
<el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button><!--重置-->
@@ -104,18 +104,18 @@
>单据确认<!--单据确认-->
</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="info"
plain
icon="el-icon-download"
size="mini"
:disabled="detailMultiple"
@click="handleBarcodePrinting"
v-hasPermi="['in:stockIn:barcodePrinting']"
>打印条码<!--打印条码-->
</el-button>
</el-col>
<!-- <el-col :span="1.5">-->
<!-- <el-button-->
<!-- type="info"-->
<!-- plain-->
<!-- icon="el-icon-download"-->
<!-- size="mini"-->
<!-- :disabled="detailMultiple"-->
<!-- @click="handleBarcodePrinting"-->
<!-- v-hasPermi="['in:stockIn:barcodePrinting']"-->
<!-- >打印条码&lt;!&ndash;打印条码&ndash;&gt;-->
<!-- </el-button>-->
<!-- </el-col>-->
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row>
@@ -124,6 +124,7 @@
<el-table-column type="selection" width="55" align="center"/>
<el-table-column label="GUID" align="center" prop="stockinGuid" v-if="false"/>
<el-table-column label="入库订单" align="left" prop="stockinId"/><!--入库订单-->
<el-table-column label="订单号" align="left" prop="erpBill"/><!--入库订单-->
<el-table-column label="入库类型" align="left" prop="inType"><!--入库类型-->
<template slot-scope="scope">
<dict-tag :options="dict.type.in_bill_type" :value="scope.row.inType"/>
@@ -157,6 +158,8 @@
<el-table-column label="物料编码" align="left" prop="productId"/><!--物料编码-->
<el-table-column label="物料名称" align="left" prop="productName"/><!--物料编码-->
<el-table-column label="批号" align="left" prop="lotNo"/><!--批号-->
<el-table-column label="机型" align="left" prop="unit"/><!--机型-->
<el-table-column label="分销" align="left" prop="spare9"/><!--分销-->
<el-table-column label="规格" align="left" prop="spec"/><!--规格-->
<el-table-column label="型号" align="left" prop="spare1"/><!--型号-->
<el-table-column label="净重" align="left" prop="spare2"/><!--净重-->