add:物料打印;手工组盘入库支持无工单入库
This commit is contained in:
@@ -82,6 +82,9 @@ public class InboundPdaServiceImpl implements InboundPdaService {
|
||||
@Autowired
|
||||
private IMdPbGroupplateService iMdPbGroupplateService;
|
||||
|
||||
@Autowired
|
||||
private IMdPbStoragevehicleinfoService iMdPbStoragevehicleinfoService;
|
||||
|
||||
@Resource
|
||||
private IStructattrService iStructattrService;
|
||||
@Autowired
|
||||
@@ -735,6 +738,7 @@ public class InboundPdaServiceImpl implements InboundPdaService {
|
||||
if (dto.getItems().isEmpty()){
|
||||
throw new BadRequestException("组盘物料为空");
|
||||
}
|
||||
iMdPbStoragevehicleinfoService.chackAndInsert(dto.getVehicle_code());
|
||||
Structattr structattr = iStructattrService.getByCode(dto.getLocation_code());
|
||||
BsrealStorattr storattrIn = storattrService.findByCode(structattr.getStor_code());
|
||||
if (!StringUtils.isEmpty(structattr.getStoragevehicle_code())){
|
||||
@@ -774,7 +778,8 @@ public class InboundPdaServiceImpl implements InboundPdaService {
|
||||
ioStorInvIn.setIs_upload(BaseDataEnum.IS_YES_NOT.code("是"));
|
||||
dto.getItems().forEach(item -> {
|
||||
BigDecimal qty = item.getQty();
|
||||
WorkOrderDao workOrder = workOrderService.getWorkOrder(item.getOrder_code());
|
||||
boolean hasWorkOrder = StringUtils.isNotBlank(item.getOrder_code());
|
||||
WorkOrderDao workOrder = hasWorkOrder ? workOrderService.getWorkOrder(item.getOrder_code()) : null;
|
||||
MdMeMaterialbase material = iMdMeMaterialbaseService.getByCode(item.getMaterial_code());
|
||||
|
||||
final IOStorInvDtl ioStorInvDtl = new IOStorInvDtl();
|
||||
@@ -790,8 +795,10 @@ public class InboundPdaServiceImpl implements InboundPdaService {
|
||||
ioStorInvDtl.setAssign_qty(qty);
|
||||
ioStorInvDtl.setPlan_qty(qty);
|
||||
ioStorInvDtl.setUnassign_qty(BigDecimal.ZERO);
|
||||
ioStorInvDtl.setSource_bill_code(workOrder.getOrder_code());
|
||||
ioStorInvDtl.setSource_bill_type("work_order");
|
||||
if (hasWorkOrder) {
|
||||
ioStorInvDtl.setSource_bill_code(workOrder.getOrder_code());
|
||||
ioStorInvDtl.setSource_bill_type("work_order");
|
||||
}
|
||||
ioStorInvDtls.add(ioStorInvDtl);
|
||||
// 分配
|
||||
final IOStorInvDis ioStorInvDis = new IOStorInvDis();
|
||||
@@ -801,7 +808,7 @@ public class InboundPdaServiceImpl implements InboundPdaService {
|
||||
ioStorInvDis.setSeq_no("1"); // 直接用 int,不需要 String
|
||||
ioStorInvDis.setMaterial_id(material.getMaterial_id());
|
||||
ioStorInvDis.setMaterial_code(material.getMaterial_code()); // 直接使用变量
|
||||
ioStorInvDis.setSect_code(workOrder.getDefault_warehouse_code());
|
||||
ioStorInvDis.setSect_code(hasWorkOrder ? workOrder.getDefault_warehouse_code() : structattr.getSect_code());
|
||||
ioStorInvDis.setStruct_code(structattr.getStruct_code());
|
||||
ioStorInvDis.setPcsn("1");
|
||||
ioStorInvDis.setStoragevehicle_code(structattr.getStoragevehicle_code());
|
||||
@@ -818,7 +825,9 @@ public class InboundPdaServiceImpl implements InboundPdaService {
|
||||
addParam.setStoragevehicleCode(dto.getVehicle_code());
|
||||
addParam.setUnitName(material.getQty_unit_name());
|
||||
addParam.setUnitId(material.getQty_unit_id());
|
||||
addParam.setExtCode(workOrder.getOrder_code());
|
||||
if (hasWorkOrder) {
|
||||
addParam.setExtCode(workOrder.getOrder_code());
|
||||
}
|
||||
addParam.setQty(qty);
|
||||
addInvParams.add(addParam);
|
||||
|
||||
@@ -832,35 +841,36 @@ public class InboundPdaServiceImpl implements InboundPdaService {
|
||||
inFinishParam.setSectCode(structattr.getSect_code());
|
||||
inFinishParam.setStructCode(structattr.getStruct_code());
|
||||
inFinishParams.add(inFinishParam);
|
||||
//保存生产入库回传单定时回传
|
||||
JSONObject callbackInData = new JSONObject();
|
||||
callbackInData.put("method", "DealSCRKBill");
|
||||
callbackInData.put("type", "MES");
|
||||
// 组装data节点
|
||||
JSONObject dataIn = new JSONObject();
|
||||
dataIn.put("orgno", workOrder.getOrg_code());//库存组织
|
||||
dataIn.put("billno", workOrder.getOrder_code()); // 单据编号
|
||||
dataIn.put("biztype", "390");
|
||||
dataIn.put("invscheme", "001");
|
||||
dataIn.put("transtype", "024");
|
||||
dataIn.put("biztime", LocalDate.now());
|
||||
JSONArray entrysIn = new JSONArray();
|
||||
JSONObject entry = new JSONObject();
|
||||
entry.put("srcbillno", workOrder.getOrder_code());
|
||||
entry.put("srcbillid", workOrder.getOrder_id()); // 数量
|
||||
entry.put("srcbillentryid", workOrder.getOrder_id());
|
||||
entry.put("qty", item.getQty());
|
||||
entry.put("materialno", item.getMaterial_code());
|
||||
entrysIn.add(entry);
|
||||
dataIn.put("entrys", entrysIn);
|
||||
callbackInData.put("data", dataIn);
|
||||
PmStockReturn stockReturnIn = new PmStockReturn();
|
||||
stockReturnIn.setRequest_Id(workOrder.getOrder_code());
|
||||
stockReturnIn.setRequest_type(IOSEnum.BILL_TYPE.code("生产入库"));
|
||||
stockReturnIn.setStatus(StockReturnStatusEnum.TODO.getCode()); // 0-处理中
|
||||
stockReturnIn.setCreate_time(now);
|
||||
stockReturnIn.setRequest_data(callbackInData.toString());
|
||||
iPmStockReturnService.save(stockReturnIn);
|
||||
if (hasWorkOrder) {
|
||||
// 有工单时才创建生产入库回传任务。
|
||||
JSONObject callbackInData = new JSONObject();
|
||||
callbackInData.put("method", "DealSCRKBill");
|
||||
callbackInData.put("type", "MES");
|
||||
JSONObject dataIn = new JSONObject();
|
||||
dataIn.put("orgno", workOrder.getOrg_code());
|
||||
dataIn.put("billno", workOrder.getOrder_code());
|
||||
dataIn.put("biztype", "390");
|
||||
dataIn.put("invscheme", "001");
|
||||
dataIn.put("transtype", "024");
|
||||
dataIn.put("biztime", LocalDate.now());
|
||||
JSONArray entrysIn = new JSONArray();
|
||||
JSONObject entry = new JSONObject();
|
||||
entry.put("srcbillno", workOrder.getOrder_code());
|
||||
entry.put("srcbillid", workOrder.getOrder_id());
|
||||
entry.put("srcbillentryid", workOrder.getOrder_id());
|
||||
entry.put("qty", item.getQty());
|
||||
entry.put("materialno", item.getMaterial_code());
|
||||
entrysIn.add(entry);
|
||||
dataIn.put("entrys", entrysIn);
|
||||
callbackInData.put("data", dataIn);
|
||||
PmStockReturn stockReturnIn = new PmStockReturn();
|
||||
stockReturnIn.setRequest_Id(workOrder.getOrder_code());
|
||||
stockReturnIn.setRequest_type(IOSEnum.BILL_TYPE.code("生产入库"));
|
||||
stockReturnIn.setStatus(StockReturnStatusEnum.TODO.getCode());
|
||||
stockReturnIn.setCreate_time(now);
|
||||
stockReturnIn.setRequest_data(callbackInData.toString());
|
||||
iPmStockReturnService.save(stockReturnIn);
|
||||
}
|
||||
});
|
||||
ioStorInvMapper.insert(ioStorInvIn);
|
||||
ioStorInvDtlMapper.batchInsert(ioStorInvDtls);
|
||||
|
||||
@@ -21,6 +21,17 @@
|
||||
</el-row>
|
||||
<!--如果想在工具栏加入更多按钮,可以使用插槽方式, slot = 'left' or 'right'-->
|
||||
<crudOperation>
|
||||
<el-button
|
||||
slot="right"
|
||||
class="filter-item"
|
||||
type="primary"
|
||||
icon="el-icon-printer"
|
||||
size="mini"
|
||||
:disabled="!crud.selections || crud.selections.length === 0"
|
||||
@click="openPrintDialog"
|
||||
>
|
||||
物料打印
|
||||
</el-button>
|
||||
<el-button
|
||||
slot="right"
|
||||
class="filter-item"
|
||||
@@ -128,6 +139,7 @@
|
||||
style="width: 100%;"
|
||||
@selection-change="crud.selectionChangeHandler"
|
||||
>
|
||||
<el-table-column type="selection" width="55" />
|
||||
<el-table-column prop="material_code" label="物料编码" width="160" />
|
||||
<el-table-column prop="material_name" label="物料名称" width="160" show-overflow-tooltip />
|
||||
<el-table-column prop="material_spec" label="物料规格" width="160" show-overflow-tooltip />
|
||||
@@ -168,6 +180,30 @@
|
||||
<pagination />
|
||||
</div>
|
||||
<UploadDialog :dialog-show.sync="uploadShow" />
|
||||
<el-dialog title="物料打印" :visible.sync="printDialogVisible" width="420px" :close-on-click-modal="false">
|
||||
<el-form label-width="90px" label-suffix=":" size="mini">
|
||||
<el-form-item label="物料编码"><span>{{ printRow.material_code }}</span></el-form-item>
|
||||
<el-form-item label="仓库编码"><el-input v-model.trim="printForm.warehouseCode" placeholder="请输入仓库编码" /></el-form-item>
|
||||
<el-form-item label="打印数量"><el-input-number v-model="printForm.quantity" :min="1" :max="999999" :step="1" controls-position="right" /></el-form-item>
|
||||
<el-form-item label="打印方式">
|
||||
<el-radio-group v-model="printForm.mode">
|
||||
<el-radio label="batch">批次打印</el-radio>
|
||||
<el-radio label="all">全部打印</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<span slot="footer" class="dialog-footer">
|
||||
<el-button size="mini" @click="printDialogVisible = false">取消</el-button>
|
||||
<el-button type="primary" size="mini" @click="createPrintPreview">生成打印预览</el-button>
|
||||
</span>
|
||||
</el-dialog>
|
||||
<el-dialog title="物料标签打印预览" :visible.sync="printPreviewVisible" width="700px" :close-on-click-modal="false" @close="closePrintPreview">
|
||||
<iframe ref="printIframe" src="about:blank" style="width: 100%; height: 500px; border: 1px solid #ddd;" />
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button size="mini" @click="printPreviewVisible = false">取消</el-button>
|
||||
<el-button type="primary" size="mini" @click="doPrint">打印</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
@@ -179,6 +215,7 @@ import crudOperation from '@crud/CRUD.operation'
|
||||
import udOperation from '@crud/UD.operation'
|
||||
import pagination from '@crud/Pagination'
|
||||
import UploadDialog from './UploadDialog'
|
||||
import QRCode from 'qrcode'
|
||||
|
||||
const defaultForm = {
|
||||
material_id: null,
|
||||
@@ -241,6 +278,10 @@ export default {
|
||||
measure_unit: [],
|
||||
productSeries: [],
|
||||
permission: {},
|
||||
printDialogVisible: false,
|
||||
printPreviewVisible: false,
|
||||
printRow: {},
|
||||
printForm: { warehouseCode: '', quantity: 1, mode: 'batch' },
|
||||
rules: {
|
||||
material_id: [
|
||||
{ required: true, message: '不能为空', trigger: 'blur' }
|
||||
@@ -282,6 +323,98 @@ export default {
|
||||
this.crud.notify('同步成功!', CRUD.NOTIFICATION_TYPE.SUCCESS)
|
||||
})
|
||||
},
|
||||
openPrintDialog() {
|
||||
const selections = this.crud.selections || []
|
||||
if (selections.length !== 1) {
|
||||
this.$message.info('请选择一条物料记录打印')
|
||||
return
|
||||
}
|
||||
this.printRow = selections[0]
|
||||
this.printForm = { warehouseCode: localStorage.getItem('materialPrintWarehouseCode') || '', quantity: 1, mode: 'batch' }
|
||||
this.printDialogVisible = true
|
||||
},
|
||||
createPrintPreview() {
|
||||
const quantity = Number(this.printForm.quantity)
|
||||
if (!this.printForm.warehouseCode) {
|
||||
this.$message.warning('请输入仓库编码')
|
||||
return
|
||||
}
|
||||
if (!Number.isInteger(quantity) || quantity < 1) {
|
||||
this.$message.warning('请输入大于0的整数数量')
|
||||
return
|
||||
}
|
||||
localStorage.setItem('materialPrintWarehouseCode', this.printForm.warehouseCode)
|
||||
const labels = this.printForm.mode === 'all'
|
||||
? [{ serial: 'ALL', quantity }]
|
||||
: Array.from({ length: quantity }, (_, index) => ({ serial: index + 1, quantity }))
|
||||
this.printDialogVisible = false
|
||||
this.printPreviewVisible = true
|
||||
this.$nextTick(() => this.renderPrintContent(labels))
|
||||
},
|
||||
escapePrintValue(value) {
|
||||
return String(value === undefined || value === null ? '' : value)
|
||||
.replace(/&/g, '&')
|
||||
.replace(/</g, '<')
|
||||
.replace(/>/g, '>')
|
||||
.replace(/"/g, '"')
|
||||
.replace(/'/g, ''')
|
||||
},
|
||||
async renderPrintContent(labels) {
|
||||
const iframe = this.$refs.printIframe
|
||||
if (!iframe) return
|
||||
const doc = iframe.contentDocument || (iframe.contentWindow && iframe.contentWindow.document)
|
||||
if (!doc) {
|
||||
setTimeout(() => this.renderPrintContent(labels), 100)
|
||||
return
|
||||
}
|
||||
const materialCode = this.printRow.material_code || ''
|
||||
const materialName = this.printRow.material_name || ''
|
||||
const warehouseCode = this.printForm.warehouseCode
|
||||
const date = this.formatPrintDate(new Date())
|
||||
let html = '<!DOCTYPE html><html><head><meta charset="utf-8"><style>'
|
||||
html += '*{margin:0;padding:0;box-sizing:border-box}'
|
||||
html += 'body{font-family:"Microsoft YaHei",Arial,sans-serif;padding:10px}'
|
||||
html += '.label{page-break-after:always;padding:10px;text-align:center}'
|
||||
html += '.label:last-child{page-break-after:auto}'
|
||||
html += 'h3{text-align:center;font-size:14px;margin-bottom:6px}'
|
||||
html += 'table{width:463px;border-collapse:collapse;margin:0 auto;min-height:224px}'
|
||||
html += 'td{padding:5px;border:2px solid #333;font-size:16px;line-height:1.3}'
|
||||
html += '.lbl{width:25%;text-align:right;background:#f9f9f9}'
|
||||
html += '.val{width:45%;text-align:left;word-break:break-all}'
|
||||
html += '.qr{width:30%;text-align:center;vertical-align:middle}'
|
||||
html += '@media print{@page{size:auto;margin:5mm}}'
|
||||
html += '</style></head><body>'
|
||||
for (const label of labels) {
|
||||
const qrText = materialCode + ':' + label.quantity + ':' + label.serial + ':' + warehouseCode
|
||||
const imgSrc = await QRCode.toDataURL(qrText, { width: 300 })
|
||||
html += '<div class="label"><h3>物料标签</h3><table>'
|
||||
html += '<tr><td class="lbl">物料编码</td><td class="val">' + this.escapePrintValue(materialCode) + '</td><td class="qr" rowspan="6"><img src="' + imgSrc + '" width="150" height="150"></td></tr>'
|
||||
html += '<tr><td class="lbl">物料名称</td><td class="val">' + this.escapePrintValue(materialName) + '</td></tr>'
|
||||
html += '<tr><td class="lbl">数量</td><td class="val">' + this.escapePrintValue(label.quantity) + '</td></tr>'
|
||||
html += '<tr><td class="lbl">序号</td><td class="val">' + this.escapePrintValue(label.serial) + '</td></tr>'
|
||||
html += '<tr><td class="lbl">日期</td><td class="val">' + date + '</td></tr>'
|
||||
html += '<tr><td class="lbl">仓库编码</td><td class="val">' + this.escapePrintValue(warehouseCode) + '</td></tr>'
|
||||
html += '</table></div>'
|
||||
}
|
||||
html += '</body></html>'
|
||||
doc.open()
|
||||
doc.write(html)
|
||||
doc.close()
|
||||
},
|
||||
formatPrintDate(date) {
|
||||
const month = String(date.getMonth() + 1).padStart(2, '0')
|
||||
const day = String(date.getDate()).padStart(2, '0')
|
||||
return date.getFullYear() + '-' + month + '-' + day
|
||||
},
|
||||
doPrint() {
|
||||
const iframe = this.$refs.printIframe
|
||||
if (!iframe) return
|
||||
iframe.contentWindow.focus()
|
||||
iframe.contentWindow.print()
|
||||
},
|
||||
closePrintPreview() {
|
||||
this.printPreviewVisible = false
|
||||
},
|
||||
// 改变状态
|
||||
changeEnabled(data, val) {
|
||||
this.$confirm('此操作将 "' + this.dict.label.is_used[val] + '" ' + data.material_name + ', 是否继续?', '提示', {
|
||||
|
||||
Reference in New Issue
Block a user