Commit 4d6ba55f by wangchunyang
parents 696c8784 14445f3b
......@@ -7,19 +7,43 @@
:limit="1"
accept=".xlsx, .xls"
:headers="upload.headers"
:action="upload.url + '?updateSupport=' + upload.updateSupport"
:action="upload.url"
:disabled="upload.isUploading"
:on-progress="handleFileUploadProgress"
:on-success="handleFileSuccess"
:auto-upload="false"
:data="getUploadData()"
drag
>
<i class="el-icon-upload"></i>
<div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
<div class="el-upload__tip text-center" slot="tip">
<div class="el-upload__tip" slot="tip">
<el-checkbox v-model="upload.updateSupport" />是否更新已经存在的数据
<div
class="order-type-radio"
v-if="showTrdcCheckbox && dict.type.inbound_outbound_type.length"
style="margin-bottom: 8px; text-align: left; padding-left: 20px;"
>
<el-radio-group v-model="upload.orderType">
<el-radio
v-for="item in dict.type.inbound_outbound_type"
:key="item.value"
:label="item.value"
style="margin-right: 20px;"
>
{{ item.label }}
</el-radio>
</el-radio-group>
</div>
<!-- 加载中提示 -->
<div
v-else-if="showTrdcCheckbox && !dict.type.inbound_outbound_type.length"
style="margin-bottom: 8px; text-align: left; padding-left: 20px;"
>
<i class="el-icon-loading" style="font-size: 14px;"></i> 加载入库类型...
</div>
<!-- <div class="el-upload__tip" slot="tip">
<el-checkbox v-model="upload.updateSupport" />是否更新已经存在的数据
</div> -->
<span>仅允许导入xls、xlsx格式文件。</span>
<el-link
type="primary"
......@@ -42,6 +66,7 @@ import { getToken } from "@/utils/auth"
export default {
name: "ImportExcel",
dicts: ['inbound_outbound_type'],
props: {
// 导入标题
title: {
......@@ -62,6 +87,15 @@ export default {
templateName: {
type: String,
default: "template"
},
showTrdcCheckbox: {
type: Boolean,
default: false
},
// 新增:是否要求orderType为必传项
orderTypeRequired: {
type: Boolean,
default: false
}
},
data() {
......@@ -79,7 +113,26 @@ export default {
// 设置上传的请求头部
headers: { Authorization: "Bearer " + getToken() },
// 上传的地址
url: ""
url: "",
// 入库类型字段
orderType: ""
}
}
},
watch: {
// 监听orderType变化,实时传递给父组件
"upload.orderType": {
handler(newVal) {
this.$emit("orderTypeChange", newVal)
},
immediate: true
},
// 监听弹窗打开,设置单选框默认值
"upload.open"(val) {
if (val && this.showTrdcCheckbox) {
// 取字典第一个作为默认值
const defaultType = this.dict.type.inbound_outbound_type[0]?.value || ""
this.upload.orderType = defaultType
}
}
},
......@@ -89,6 +142,12 @@ export default {
this.upload.title = this.title
this.upload.url = process.env.VUE_APP_BASE_API + this.importUrl
this.upload.open = true
// 恢复原有重置
this.upload.updateSupport = 0
// 重置入库类型
this.upload.orderType = this.showTrdcCheckbox
? (this.dict.type.inbound_outbound_type[0]?.value || "")
: ""
},
/** 下载模板操作 */
importTemplate() {
......@@ -111,7 +170,21 @@ export default {
{ dangerouslyUseHTMLString: true }
)
// 触发父组件的成功回调
this.$emit("success")
this.$emit("success", {
orderType: this.upload.orderType,
updateSupport: this.upload.updateSupport
})
},
// 返回要追加到FormData的参数
getUploadData() {
const data = {
updateSupport: this.upload.updateSupport
};
// 如果显示单选框,追加orderType到FormData
if (this.showTrdcCheckbox) {
data.orderType = this.upload.orderType;
}
return data;
},
// 提交上传文件
submitFileForm() {
......@@ -125,6 +198,14 @@ export default {
this.$modal.msgError("请选择后缀为 “xls”或“xlsx”的文件。")
return
}
// 校验orderType(如果是必传项)
if (this.showTrdcCheckbox && this.orderTypeRequired && !this.upload.orderType) {
this.$modal.msgError("请选择入库/出库类型!")
return
}
// 提交前通知父组件
this.$emit("orderTypeChange", this.upload.orderType)
// 提交上传
this.$refs.upload.submit()
}
}
......@@ -132,4 +213,5 @@ export default {
</script>
<style scoped>
</style>
......@@ -23,9 +23,9 @@
@search="handleQuery"
@reset="resetQuery"
>
<el-form-item label="物料SAPNO" prop="materialId">
<el-form-item label="物料SAPNO" prop="sapNo">
<el-input
v-model="queryParams.materialId"
v-model="queryParams.sapNo"
placeholder="请输入物料SAPNO"
clearable
@keyup.enter.native="handleQuery"
......@@ -112,7 +112,7 @@
@selection-change="handleSelectionChange"
:row-key="(row) => row.materialId + '_' + row.orderId"
>
<el-table-column label="物料SAPNO" align="center" prop="materialId" width="200"/>
<el-table-column label="物料SAPNO" align="center" prop="sapNo" width="200"/>
<el-table-column label="物料名称" align="center" prop="materialName" width="200"/>
<el-table-column label="关联入库单ID" align="center" prop="orderId" :show-overflow-tooltip="true" width="200"/>
<el-table-column label="批次ID" align="center" prop="batchId" :show-overflow-tooltip="true" width="200"/>
......
......@@ -88,7 +88,7 @@
<el-form-item label="入库类型" prop="orderTypeId">
<el-select v-model="queryParams.orderTypeId" placeholder="请选择入库类型" clearable>
<el-option
v-for="dict in dict.type.inbound_type"
v-for="dict in dict.type.inbound_outbound_type"
:key="dict.value"
:label="dict.label"
:value="dict.value"
......@@ -152,9 +152,9 @@
<el-table-column label="入库类型" align="center" prop="orderTypeId" :show-overflow-tooltip="true" width="200">
<template slot-scope="scope">
<el-tag
:type="getDictListClass('inbound_type',scope.row.orderTypeId)"
:type="getDictListClass('inbound_outbound_type',scope.row.orderTypeId)"
size="small">
{{ getDictLabel('inbound_type',scope.row.orderTypeId) }}
{{ getDictLabel('inbound_outbound_type',scope.row.orderTypeId) }}
</el-tag>
</template>
</el-table-column>
......@@ -162,9 +162,9 @@
<el-table-column label="订单类型" align="center" prop="orderType" :show-overflow-tooltip="true" width="200">
<template slot-scope="scope">
<el-tag
:type="getDictListClass('order_type',scope.row.orderTypeId)"
:type="getDictListClass('order_type',scope.row.orderType)"
size="small">
{{ getDictLabel('order_type',scope.row.orderTypeId) }}
{{ getDictLabel('order_type',scope.row.orderType) }}
</el-tag>
</template>
</el-table-column>
......@@ -252,7 +252,7 @@
<el-form-item label="入库类型" prop="orderTypeId">
<el-select v-model="form.orderTypeId" placeholder="请选择入库类型" clearable>
<el-option
v-for="dict in dict.type.inbound_type"
v-for="dict in dict.type.inbound_outbound_type"
:key="dict.value"
:label="dict.label"
:value="dict.value"
......@@ -384,13 +384,13 @@
<el-descriptions-item label="批次ID">{{ detailForm.batchId || '-' }}</el-descriptions-item>
<el-descriptions-item label="货主">{{ detailForm.ownerName || detailForm.ownerId || '-' }}</el-descriptions-item>
<el-descriptions-item label="入库类型">
{{ getDictLabel('inbound_type',detailForm.orderTypeId) }}
{{ getDictLabel('inbound_outbound_type',detailForm.orderTypeId) }}
</el-descriptions-item>
<el-descriptions-item label="订单类型">
{{ getDictLabel('order_type',detailForm.orderType) }}
</el-descriptions-item>
<el-descriptions-item label="入库日期">{{ detailForm.inboundDate || '-' }}</el-descriptions-item>
<el-descriptions-item label="负责人">{{ detailForm.opUserName || '-' }}</el-descriptions-item>
<!-- <el-descriptions-item label="负责人">{{ detailForm.opUserName || '-' }}</el-descriptions-item> -->
<el-descriptions-item label="计划量">{{ detailForm.totalPlannedQuantity || '-' }}</el-descriptions-item>
<el-descriptions-item label="实际量">{{ detailForm.totalActualQuantity || '-' }}</el-descriptions-item>
<!-- <el-descriptions-item label="总件数">{{ detailForm.totalPackages || '-' }}</el-descriptions-item> -->
......@@ -445,6 +445,9 @@
template-url="/inventory/inbound/importTemplate"
template-name="入库单导入模板"
@success="getList"
:show-trdc-checkbox="true"
@orderTypeChange="handleOrderTypeChange"
:orderTypeRequired="true"
/>
<OwnerSelector
v-model="ownerSelectorVisible"
......@@ -466,7 +469,7 @@
<script>
import { listInbound, getInbound, delInbound, addInbound, updateInbound } from "@/api/inventory/inbound"
import { listInbound_items } from "@/api/inventory/inbound_items"
import { listInbound_itemsAndMname } from "@/api/inventory/inbound_items"
import { batchAddInventory } from "@/api/inventory/inventory"
import InboundItems from "@/views/inventory/inbound_items/index.vue"
import PageTitle from "@/components/PageTitle" // 引入字典页面的标题组件
......@@ -479,7 +482,7 @@ import LocationSelector from "@/views/compononents/LocationSelector.vue"
export default {
name: "Inbound",
dicts: ['inbound_type','order_type','inbound_status'],
dicts: ['inbound_outbound_type','order_type','inbound_status'],
components: {
InboundItems,
PageTitle,
......@@ -621,6 +624,9 @@ export default {
this.loading = false
})
},
handleOrderTypeChange(selection) {
this.form.orderTypeId = selection
},
/** 获取状态样式类型 */
getStatusType(status) {
const item = this.inBoundStatusOptions.find(item => item.orderStatus === status)
......@@ -658,7 +664,7 @@ export default {
/** 重置按钮操作 */
resetQuery() {
this.$refs.queryForm?.resetFields()
// this.$refs.queryForm?.resetFields()
this.queryOwnerName = null
this.queryParams = {
pageNum: 1,
......@@ -674,7 +680,10 @@ export default {
orderStatus: null,
orderType: null
}
this.$nextTick(() => {
// 重新触发查询,加载默认数据
this.handleQuery()
})
},
/** 多选框选中数据 */
......@@ -845,13 +854,14 @@ export default {
// 将选中的物料添加到入库明细
this.selectedMaterials.forEach(material => {
// 检查是否已存在该物料,避免重复添加
const exists = this.form.inboundOrderItemsList.some(
item => item.materialId === material.sapNo
)
// const exists = this.form.inboundOrderItemsList.some(
// item => item.materialId === material.materialId
// )
const exists = false
if (!exists) {
this.form.inboundOrderItemsList.push({
materialId: material.sapNo, // 存储物料编码
materialId: material.id,
sapNo: material.sapNo,
materialName: material.materialName, // 仅用于展示
batchCode: null,
warehouseId: null,
......@@ -864,7 +874,7 @@ export default {
totalAmount: 0
})
} else {
this.$message.warning(`物料 ${material.materialName} 已存在,跳过添加`)
// this.$message.warning(`物料 ${material.materialName} 已存在,跳过添加`)
}
})
this.materialSelectOpen = false
......@@ -887,14 +897,25 @@ export default {
pageSize: 9999,
orderId: row.orderId
}
const response = await listInbound_items(queryForm)
row.inboundOrderItemsList = response.rows
const response = await listInbound_itemsAndMname(queryForm)
console.log(response.rows)
row.inboundOrderItemsList = response.rows.map(item => {
return {
...item,
inventoryType: row.orderTypeId,
warehousesId: item.warehouseId,
ownerId: row.ownerId,
quantity: item.actualQuantity,
unitWeight: item.unitWeight
};
})
console.log(row.inboundOrderItemsList)
// 第三步:确保数据存在后调用入库接口
if (!row.inboundOrderItemsList || row.inboundOrderItemsList.length === 0) {
this.$message.warning('暂无入库明细数据,无法确认入库')
return
}
await batchAddInventory(row.inboundOrderItemsList)
// 第四步:操作成功提示
......
......@@ -339,7 +339,7 @@ export default {
columns: {
type: Array,
default: () => [
{ prop: 'materialId', label: '货物ID', width: '150', editable: false },
{ prop: 'sapNo', label: 'SapNo', width: '150', editable: false },
{ prop: 'materialName', label: '货物名称', width: '150', editable: false },
{
prop: 'warehousesName',
......@@ -424,6 +424,8 @@ export default {
this.cachedData = JSON.parse(JSON.stringify(newVal || []))
this.displayData = (newVal || []).map(item => ({
...item,
sapNo: item.sapNo, // 确保sapNo字段被保存
materialName: item.materialName, // 确保materialName字段被保存
editable: false,
tempId: item.id || Date.now() + Math.random()
}))
......@@ -497,10 +499,9 @@ export default {
this.loading = true
this.queryParams.inboundOrderId = inboundOrderId
listInbound_itemsAndMname(this.queryParams).then(response => {
console.log(response.rows)
this.displayData = response.rows.map(item => ({
...item,
sapNo: item.sapNo,
materialName: item.materialName,
editable: false,
tempId: item.id || Date.now() + Math.random()
......@@ -590,7 +591,8 @@ export default {
const newItem = {
id: null,
orderId: this.orderId,
materialId: material.sapNo,
materialId: material.id,
sapNo: material.sapNo,
materialName: material.materialName,
batchId: null,
warehouseId: null,
......
......@@ -11,14 +11,7 @@ import com.ruoyi.inventory.domain.vo.InboundMaterialTotalVO;
import com.ruoyi.inventory.domain.vo.InboundTemplateVO;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
......@@ -129,12 +122,15 @@ public class InboundOrdersController extends BaseController
@PreAuthorize("@ss.hasPermi('inventory:inbound:import')")
@Log(title = "入库信息导入", businessType = BusinessType.IMPORT)
@PostMapping("/import")
public AjaxResult importTemplate(MultipartFile file , boolean updateSupport) throws Exception
public AjaxResult importTemplate(@RequestParam("file") MultipartFile file,
// 接收 true/false
@RequestParam("updateSupport") Integer updateSupport,
@RequestParam(value = "orderType", required = false) Integer orderType) throws Exception
{
ExcelUtil<InboundTemplateVO> util = new ExcelUtil<InboundTemplateVO>(InboundTemplateVO.class);
List<InboundTemplateVO> inboundOrders = util.importExcel(file.getInputStream());
String operName = getUsername();
String message = inboundOrdersService.importInboundOrders(inboundOrders, updateSupport, operName);
String message = inboundOrdersService.importInboundOrders(inboundOrders, updateSupport, operName, orderType);
return success(message);
}
......
......@@ -4,6 +4,7 @@ import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;
import com.alibaba.fastjson2.JSONObject;
import com.ruoyi.inventory.domain.Inventory;
import com.ruoyi.inventory.domain.vo.InboundTemplateVO;
import com.ruoyi.inventory.domain.vo.OutboundTemplateVO;
......@@ -123,7 +124,7 @@ public class OutboundOrdersController extends BaseController
@PostMapping("/outboundOrdersTopTenByQuantity")
public TableDataInfo outboundOrdersTopTenByQuantity(){
List<Map<String,String>> resultMap = outboundOrdersService.outboundOrdersTopTenByQuantity();
return getDataTable( resultMap);
return getDataTable(resultMap);
}
@PreAuthorize("@ss.hasPermi('inventory:orders:query')")
......@@ -136,7 +137,7 @@ public class OutboundOrdersController extends BaseController
@PreAuthorize("@ss.hasPermi('inventory:orders:query')")
@PostMapping("/outboundOrdersCount")
public AjaxResult outboundOrdersCount(){
String resultMap = outboundOrdersService.outboundOrdersCount();
Object resultMap = outboundOrdersService.outboundOrdersCount();
return AjaxResult.success(resultMap);
}
/**
......
......@@ -41,6 +41,9 @@ public class InboundOrderItems extends BaseEntity
@Excel(name = "库位ID")
private String locationId;
/** 收获库位 检索条件 */
private String receiptLocationId;
/** 计划数量 */
@Excel(name = "计划数量")
private Long plannedQuantity;
......@@ -85,6 +88,9 @@ public class InboundOrderItems extends BaseEntity
@Excel(name = "收货人")
private String receivedBy;
/** 贴标数量 */
private Long labelQuantity;
/** 应用数据1使用0删除 删除用 */
// @Excel(name = "应用数据")
private Long isUsed;
......@@ -319,6 +325,22 @@ public class InboundOrderItems extends BaseEntity
this.inboundOrderId = inboundOrderId;
}
public String getReceiptLocationId() {
return receiptLocationId;
}
public void setReceiptLocationId(String receiptLocationId) {
this.receiptLocationId = receiptLocationId;
}
public Long getLabelQuantity() {
return labelQuantity;
}
public void setLabelQuantity(Long labelQuantity) {
this.labelQuantity = labelQuantity;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
......@@ -347,6 +369,8 @@ public class InboundOrderItems extends BaseEntity
.append("updateTime", getUpdateTime())
.append("updateUserCode", getUpdateUserCode())
.append("inboundOrderId", getInboundOrderId())
.append("receiptLocationId", getReceiptLocationId())
.append("labelQuantity", getLabelQuantity())
.toString();
}
}
......@@ -27,9 +27,16 @@ public class InboundItemsAndMaterialName extends BaseEntity
private String inboundOrderId;
/** 货物ID 字典,检索条件 */
@Excel(name = "货物ID")
// @Excel(name = "货物ID")
private String materialId;
@Excel(name = "SapNo")
private String sapNo;
private String materialName;
private Double unitWeight;
/** 批次ID 检索条件 */
@Excel(name = "批次ID")
private String batchId;
......@@ -106,7 +113,7 @@ public class InboundItemsAndMaterialName extends BaseEntity
// @Excel(name = "排序号")
private String updateUserCode;
private String materialName;
public void setId(String id)
{
......@@ -350,6 +357,22 @@ public class InboundItemsAndMaterialName extends BaseEntity
this.locationName = locationName;
}
public String getSapNo() {
return sapNo;
}
public void setSapNo(String sapNo) {
this.sapNo = sapNo;
}
public Double getUnitWeight() {
return unitWeight;
}
public void setUnitWeight(Double unitWeight) {
this.unitWeight = unitWeight;
}
@Override
public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
......@@ -381,6 +404,8 @@ public class InboundItemsAndMaterialName extends BaseEntity
.append("inboundOrderId", getInboundOrderId())
.append("warehousesName", getWarehousesName())
.append("locationName", getLocationName())
.append("sapNo", getSapNo())
.append("unitWeight", getUnitWeight())
.toString();
}
}
......@@ -17,80 +17,70 @@ public class InboundTemplateVO extends BaseEntity {
/** 编号 */
private String id;
/** 入库单号 检索条件 */
@Excel(name = "入库单号")
private String orderId;
/** 系统编号 检索条件 */
@Excel(name = "系统编号")
private String systemNo;
/** 入库类型 字典,检索条件 */
@Excel(name = "入库类型")
private String orderTypeId;
/** 批次ID 检索条件 */
@Excel(name = "批次ID")
private String batchId;
/** 入库日期 日期无时间 */
@JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "入库日期", width = 30, dateFormat = "yyyy-MM-dd")
private Date inboundDate;
/** 订单类型 字典,检索条件 */
@Excel(name = "订单类型")
private String orderType;
/** 备注 */
@Excel(name = "备注")
private String remark;
/** 货主ID */
@Excel(name = "货主ID")
private String ownerId;
/** 仓库ID 暂无用 */
@Excel(name = "仓库ID")
private String warehouseId;
/** 库位ID 检索条件 */
@Excel(name = "库位ID")
private String locationId;
/** 货物ID 字典,检索条件 */
@Excel(name = "SAP")
@Excel(name = "SAP No")
private String sapNo;
/** 货物ID 字典,检索条件 */
@Excel(name = "货物名称")
/** 货物名称 */
@Excel(name = "物料名称")
private String materialName;
/** 负责人 暂无用 */
// @Excel(name = "负责人 暂无用")
private String opUserName;
/** 货物名称 */
@Excel(name = "TS Code")
private String tsCode;
/** 货主ID */
@Excel(name = "货主")
private String ownerId;
/** 批次ID 检索条件 */
@Excel(name = "批号")
private String batchId;
/** 计划数量 */
@Excel(name = "计划数量")
private Long plannedQuantity;
/** 实际数量 */
@Excel(name = "实际数量")
private Long actualQuantity;
/** 入库单号 检索条件 */
@Excel(name = "单号")
private String orderId;
/** 计划件数 暂无用 */
// @Excel(name = "计划件数")
private Long plannedPackages;
/** 系统编号 检索条件 */
@Excel(name = "系统编号")
private String systemNo;
/** 实际件数 */
@Excel(name = "实际件数")
private Long actualPackages;
/** 入库类型 字典,检索条件 */
// @Excel(name = "入库类型")
private String orderTypeId;
@Excel(name = "件重")
private Double unitWeight;
/** 约数 */
@Excel(name = "约数")
private Long divisor;
/** 实际件数 */
@Excel(name = "实际件数")
private Long actualPackages;
/** 实际数量 */
@Excel(name = "实发数量")
private Long actualQuantity;
/** 仓库ID 暂无用 */
@Excel(name = "仓库")
private String warehouseId;
/** 库位ID 检索条件 */
@Excel(name = "库位")
private String locationId;
/** 标签颜色 字典,检索条件 */
@Excel(name = "标签颜色")
private Long labelColor;
......@@ -103,6 +93,14 @@ public class InboundTemplateVO extends BaseEntity {
@Excel(name = "单价")
private Long unitPrice;
/** 备注 */
@Excel(name = "备注")
private String remark;
/** 订单类型 字典,检索条件 */
@Excel(name = "订单类型")
private String orderType;
/** 收货人 */
@Excel(name = "收货人")
private String receivedBy;
......@@ -111,6 +109,14 @@ public class InboundTemplateVO extends BaseEntity {
@Excel(name = "物料备注")
private String remark2;
/** 负责人 暂无用 */
// @Excel(name = "负责人 暂无用")
private String opUserName;
/** 计划件数 暂无用 */
// @Excel(name = "件数")
private Long plannedPackages;
/** 排序号 */
private Long sortNo;
......@@ -336,33 +342,54 @@ public class InboundTemplateVO extends BaseEntity {
this.sortNo = sortNo;
}
public String getTsCode() {
return tsCode;
}
public void setTsCode(String tsCode) {
this.tsCode = tsCode;
}
public Double getUnitWeight() {
return unitWeight;
}
public void setUnitWeight(Double unitWeight) {
this.unitWeight = unitWeight;
}
@Override
public String toString() {
return "InboundTemplateVO{" +
"id='" + id + '\'' +
", orderId='" + orderId + '\'' +
", systemNo='" + systemNo + '\'' +
", orderTypeId='" + orderTypeId + '\'' +
", batchId='" + batchId + '\'' +
", inboundDate=" + inboundDate +
", orderType='" + orderType + '\'' +
", remark1='" + remark + '\'' +
", ownerId='" + ownerId + '\'' +
", warehouseId='" + warehouseId + '\'' +
", locationId='" + locationId + '\'' +
", sapNo='" + sapNo + '\'' +
", materialName='" + materialName + '\'' +
", opUserName='" + opUserName + '\'' +
", tsCode='" + tsCode + '\'' +
", batchId='" + batchId + '\'' +
", plannedQuantity=" + plannedQuantity +
", actualQuantity=" + actualQuantity +
", plannedPackages=" + plannedPackages +
", actualPackages=" + actualPackages +
", orderId='" + orderId + '\'' +
", systemNo='" + systemNo + '\'' +
", orderTypeId='" + orderTypeId + '\'' +
", unitWeight=" + unitWeight +
", divisor=" + divisor +
", actualPackages=" + actualPackages +
", actualQuantity=" + actualQuantity +
", warehouseId='" + warehouseId + '\'' +
", locationId='" + locationId + '\'' +
", labelColor=" + labelColor +
", voucherNumber='" + voucherNumber + '\'' +
", unitPrice=" + unitPrice +
", remark='" + remark + '\'' +
", orderType='" + orderType + '\'' +
", receivedBy='" + receivedBy + '\'' +
", remark2='" + remark2 + '\'' +
", ownerId='" + ownerId + '\'' +
", opUserName='" + opUserName + '\'' +
", plannedPackages=" + plannedPackages +
", sortNo=" + sortNo +
", createUserCode='" + createUserCode + '\'' +
", updateUserCode='" + updateUserCode + '\'' +
'}';
}
}
......@@ -97,4 +97,11 @@ public interface MaterialsMapper
* @return 结果
*/
public int deleteMaterialsByIds(String[] ids);
/**
* 获取物料sap和id map字典
*
* @return 结果
*/
@MapKey("sap_no")
public Map<String,Map<String,String>> selectMaterialIdAndSapMap();
}
......@@ -29,7 +29,15 @@ public interface IInboundOrderItemsService
* @return 入库单明细集合
*/
public List<InboundOrderItems> selectInboundOrderItemsList(InboundOrderItems inboundOrderItems);
/**
* 查询入库单明细列表
*
* @param inboundOrderItems 入库单明细
* @return 入库单明细集合
*/
public List<InboundOrderItems> selectInboundOrderItemsListAndMaterialName(InboundOrderItems inboundOrderItems);
/**
* 新增入库单明细
*
......
......@@ -69,7 +69,7 @@ public interface IInboundOrdersService
* @param inboundOrders,isUpdateSupport,operName 入库单数据信息
* @return 结果
*/
public String importInboundOrders(List<InboundTemplateVO> inboundOrders, Boolean isUpdateSupport, String operName);
public String importInboundOrders(List<InboundTemplateVO> inboundOrders, Integer isUpdateSupport, String operName, Integer orderType);
/**
......
......@@ -109,7 +109,7 @@ public class InboundOrderItemsServiceImpl implements IInboundOrderItemsService
}
/**
* 导入入库单明细信息
* 导入入库单明细信息(暂无用)
*
* @param inboundOrderItemsList,isUpdateSupport,operName 入库单数据信息
* @return 结果
......
......@@ -6,6 +6,7 @@ import java.util.*;
import java.util.stream.Collectors;
import com.ruoyi.inventory.domain.vo.InboundMaterialTotalVO;
import com.ruoyi.inventory.mapper.MaterialsMapper;
import org.springframework.util.CollectionUtils;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.DateUtils;
......@@ -35,6 +36,9 @@ public class InboundOrdersServiceImpl implements IInboundOrdersService
{
@Autowired
private InboundOrdersMapper inboundOrdersMapper;
@Autowired
private MaterialsMapper materialsMapper;
private static final Logger log = LoggerFactory.getLogger(InboundOrdersServiceImpl.class);
/**
* 查询入库单主
......@@ -155,7 +159,7 @@ public class InboundOrdersServiceImpl implements IInboundOrdersService
*/
@Override
@Transactional(rollbackFor = Exception.class)
public String importInboundOrders(List<InboundTemplateVO> inboundOrdersList, Boolean isUpdateSupport, String operName) {
public String importInboundOrders(List<InboundTemplateVO> inboundOrdersList, Integer isUpdateSupport, String operName, Integer orderType) {
if (StringUtils.isNull(inboundOrdersList) || inboundOrdersList.size() == 0) {
throw new ServiceException("导入数据不能为空!");
}
......@@ -174,7 +178,7 @@ public class InboundOrdersServiceImpl implements IInboundOrdersService
Map<String, List<InboundTemplateVO>> orderGroupMap = inboundOrdersList.stream()
.filter(vo -> StringUtils.isNotBlank(vo.getOrderId())) // 过滤无入库单号的无效行
.collect(Collectors.groupingBy(InboundTemplateVO::getOrderId));
Map<String,Map<String,String>> sapAndIdMap = materialsMapper.selectMaterialIdAndSapMap();
// 4. 遍历每个入库单分组处理
for (Map.Entry<String, List<InboundTemplateVO>> entry : orderGroupMap.entrySet()) {
String orderId = entry.getKey();
......@@ -188,7 +192,7 @@ public class InboundOrdersServiceImpl implements IInboundOrdersService
// 检查入库单是否已存在
InboundOrders existMain = inboundOrdersMapper.selectInboundOrdersByOrderId(orderId);
if (existMain != null) {
if (!isUpdateSupport) {
if (isUpdateSupport == 0) {
// 不支持更新,跳过该入库单
totalMainFailure++;
failureMsg.append(String.format("入库单号【%s】已存在,且不支持更新,跳过导入;\n", orderId));
......@@ -202,6 +206,7 @@ public class InboundOrdersServiceImpl implements IInboundOrdersService
mainDO.setUpdateBy(operId);
mainDO.setUpdateTime(now);
mainDO.setUpdateUserCode(operId);
mainDO.setOrderTypeId(orderType+"");
// 更新主表
inboundOrdersMapper.updateInboundOrders(mainDO);
totalMainSuccess++;
......@@ -222,6 +227,7 @@ public class InboundOrdersServiceImpl implements IInboundOrdersService
mainDO.setUpdateBy(operId);
mainDO.setUpdateTime(now);
mainDO.setUpdateUserCode(operId);
mainDO.setOrderTypeId(orderType+"");
// 设置默认值
if (mainDO.getSortNo() == null) {
mainDO.setSortNo(0L);
......@@ -243,7 +249,8 @@ public class InboundOrdersServiceImpl implements IInboundOrdersService
"orderId", "systemNo", "orderTypeId", "batchId"); // 排除主表字段
// 填充明细必填字段
itemDO.setId(UUID.randomUUID().toString());
itemDO.setMaterialId(vo.getId());
Map<String,String> sapAndId = sapAndIdMap.get(vo.getSapNo());
itemDO.setMaterialId(sapAndId.get("id"));
itemDO.setOrderId(orderId); // 关联入库单号
itemDO.setBatchId(mainDO.getBatchId());
itemDO.setInboundOrderId(mainDO.getId()); // 关联主表ID(核心!)
......
......@@ -91,6 +91,7 @@ public class InventoryServiceImpl implements IInventoryService
for (Inventory inventory : inventoryList) {
inventory.setCreateTime(DateUtils.getNowDate());
inventory.setId(UUID.randomUUID().toString());
inventory.setCreateUserCode(SystemUtils.getUserName());
count = inventoryMapper.insertInventory(inventory);
}
return count;
......
......@@ -71,6 +71,39 @@
</select>
<resultMap type="com.ruoyi.inventory.domain.TO.InboundItemsAndMaterialName" id="InboundOrderItemsAndMnameResult">
<result property="id" column="id" />
<result property="orderId" column="order_id" />
<result property="materialId" column="material_id" />
<result property="sapNo" column="sap_no" />
<result property="materialName" column="material_name" />
<result property="unitWeight" column="unit_weight" />
<result property="batchId" column="batch_id" />
<result property="warehouseId" column="warehouse_id" />
<result property="warehousesName" column="warehouses_name" />
<result property="locationId" column="location_id" />
<result property="locationName" column="location_name" />
<result property="plannedQuantity" column="planned_quantity" />
<result property="actualQuantity" column="actual_quantity" />
<result property="plannedPackages" column="planned_packages" />
<result property="actualPackages" column="actual_packages" />
<result property="divisor" column="divisor" />
<result property="labelColor" column="label_color" />
<result property="voucherNumber" column="voucher_number" />
<result property="unitPrice" column="unit_price" />
<result property="itemStatus" column="item_status" />
<result property="receivedAt" column="received_at" />
<result property="receivedBy" column="received_by" />
<result property="remark" column="remark" />
<result property="isUsed" column="is_used" />
<result property="sortNo" column="sort_no" />
<result property="createTime" column="create_time" />
<result property="createUserCode" column="create_user_code" />
<result property="updateTime" column="update_time" />
<result property="updateUserCode" column="update_user_code" />
<result property="inboundOrderId" column="inbound_order_id" />
</resultMap>
<select id="selectInboundOrderItemsListAndMaterialName"
parameterType="com.ruoyi.inventory.domain.InboundOrderItems"
......@@ -79,6 +112,9 @@
ii.id,
ii.order_id,
ii.material_id,
m.material_name,
m.sap_no,
m.unit_weight,
ii.batch_id,
ii.warehouse_id,
w.warehouses_name,
......@@ -277,36 +313,6 @@
</foreach>
</delete>
<resultMap type="com.ruoyi.inventory.domain.TO.InboundItemsAndMaterialName" id="InboundOrderItemsAndMnameResult">
<result property="id" column="id" />
<result property="orderId" column="order_id" />
<result property="materialId" column="material_id" />
<result property="batchId" column="batch_id" />
<result property="warehouseId" column="warehouse_id" />
<result property="warehousesName" column="warehouses_name" />
<result property="locationId" column="location_id" />
<result property="locationName" column="location_name" />
<result property="plannedQuantity" column="planned_quantity" />
<result property="actualQuantity" column="actual_quantity" />
<result property="plannedPackages" column="planned_packages" />
<result property="actualPackages" column="actual_packages" />
<result property="divisor" column="divisor" />
<result property="labelColor" column="label_color" />
<result property="voucherNumber" column="voucher_number" />
<result property="unitPrice" column="unit_price" />
<result property="itemStatus" column="item_status" />
<result property="receivedAt" column="received_at" />
<result property="receivedBy" column="received_by" />
<result property="remark" column="remark" />
<result property="isUsed" column="is_used" />
<result property="sortNo" column="sort_no" />
<result property="createTime" column="create_time" />
<result property="createUserCode" column="create_user_code" />
<result property="updateTime" column="update_time" />
<result property="updateUserCode" column="update_user_code" />
<result property="inboundOrderId" column="inbound_order_id" />
<result property="materialName" column="material_name" />
</resultMap>
<resultMap id="InboundDetailsResultMap" type="com.ruoyi.inventory.domain.vo.InboundDetailsVO">
<!-- 基础字段映射 -->
......
......@@ -36,7 +36,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<resultMap type="com.ruoyi.inventory.domain.TO.InboundItemsAndMaterialName" id="InboundOrderItemsResult">
<result property="id" column="id" />
<result property="orderId" column="order_id" />
<result property="materialId" column="material_id" />
<result property="materialId" column="material_id"/>
<result property="sapNo" column="sap_no" />
<result property="materialName" column="material_name" />
<result property="batchId" column="batch_id" />
<result property="warehouseId" column="warehouse_id" />
......@@ -104,7 +105,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</select>
<select id="selectInboundOrderItemsList" resultMap="InboundOrderItemsResult">
select ioi.id, ioi.order_id, ioi.material_id, m.material_name, ioi.batch_id, ioi.warehouse_id, w.warehouses_name,
select ioi.id, ioi.order_id, ioi.material_id, m.sap_no, m.material_name, ioi.batch_id, ioi.warehouse_id, w.warehouses_name,
ioi.location_id, sl.location_name, ioi.planned_quantity, ioi.actual_quantity, ioi.planned_packages,
ioi.actual_packages, ioi.divisor, ioi.label_color, ioi.voucher_number, ioi.unit_price, ioi.item_status,
ioi.received_at, ioi.received_by, ioi.remark, ioi.is_used, ioi.sort_no, ioi.create_time, ioi.create_user_code,
......@@ -229,6 +230,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</foreach>
</insert>
<!-- 统计入库次数-->
<select id="countInboundOrders" resultType="int" parameterType="String">
select count(id)
......@@ -236,7 +239,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where DATE_FORMAT(inbound_date, '%Y-%m') = #{monthParam};
</select>
<!-- 统计入库物料数量Top10-->
<resultMap id="InboundMaterialTotalResultMap" type="com.ruoyi.inventory.domain.vo.InboundMaterialTotalVO">
<result column="material_name" property="materialName" jdbcType="VARCHAR"/>
......@@ -250,7 +252,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
inner join materials as m on ioi.material_id = m.id
where io.order_status = 2
group by m.id
order by total_quantity desc
order by total_quantity asc
</select>
<select id="countInboundMaterialMoney" resultMap="InboundMaterialTotalResultMap" parameterType="String">
select m.material_name,sum(ioi.actual_quantity * ioi.unit_price) as total_money
......@@ -259,6 +261,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
inner join materials as m on ioi.material_id = m.id
where io.order_status = 2
group by m.id
order by total_money desc
order by total_money asc
</select>
</mapper>
\ No newline at end of file
......@@ -33,6 +33,25 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="updateTime" column="update_time" />
<result property="updateUserCode" column="update_user_code" />
<result property="warehousesId" column="warehouses_id" />
<result property="materialName" column="material_name" />
<result property="minStockLevel" column="min_stock_level" jdbcType="BIGINT"/>
<result property="maxStockLevel" column="max_stock_level" jdbcType="BIGINT"/>
<result property="sapNo" column="sap_no" />
<result property="tsCode" column="ts_code" />
<result property="hazardId" column="hazard_id" />
<result property="specification" column="specification" />
<result property="materialUnit" column="material_unit" />
<result property="unitWeight" column="unit_weight" />
<result property="packageWeight" column="package_weight" />
<result property="totalWeight" column="total_weight" />
<result property="volume" column="volume" />
<result property="shelfLifeDays" column="shelf_life_days" />
<result property="storageTemperature" column="storage_temperature" />
<result property="specialRequirements" column="special_requirements" />
<result property="alterType" column="alterType" />
<result property="warehousesName" column="warehouses_name" />
<result property="locationName" column="location_name" />
<result property="ownerName" column="owner_name" />
</resultMap>
<resultMap type="com.ruoyi.inventory.domain.TO.StocktakeItemsTo" id="StocktakeItemsResult">
......
......@@ -206,4 +206,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
#{id}
</foreach>
</delete>
<!-- <resultMap id="SapAndIdMap" type="java.util.Map">-->
<!-- <result column="sap_no" property="key"/>-->
<!-- <result column="id" property="value"/>-->
<!-- </resultMap>-->
<select id="selectMaterialIdAndSapMap" resultType="java.util.Map">
select id,sap_no from materials where is_used = 1
</select>
</mapper>
\ No newline at end of file
......@@ -129,6 +129,7 @@
oo.order_type, -- 新增order_type字段查询
oo.batch_code,
oo.warehouse_id,
w.warehouses_name as warehouse_name,
oo.owner_id,
o.owner_name,
oo.order_status,
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论