Commit cc2295c5 by yubin

出库

parent 70157266
{
"java.configuration.updateBuildConfiguration": "interactive"
}
\ No newline at end of file
......@@ -51,4 +51,11 @@ export function listLocationsForSelector(query) {
method: 'get',
params: query
})
}
export function getlocationsdicts() {
return request({
url: '/inventory/owners/getMapList',
method: 'get'
})
}
\ No newline at end of file
......@@ -42,3 +42,10 @@ export function delMaterials(id) {
method: 'delete'
})
}
export function getMaterialsdicts() {
return request({
url: '/inventory/materials/getMapList',
method: 'get'
})
}
......@@ -42,3 +42,9 @@ export function delOwners(id) {
method: 'delete'
})
}
export function getOwnerdicts() {
return request({
url: '/inventory/owners/getMapList',
method: 'get'
})
}
......@@ -50,4 +50,10 @@ export function listWarehousesForSelector(query) {
method: 'get',
params: query
})
}
\ No newline at end of file
}
export function getMapList() {
return request({
url: '/inventory/warehouses/getMapList',
method: 'get'
})
}
......@@ -102,7 +102,6 @@
<el-table-column label="仓库ID" align="center" prop="warehouseId" width="120" />
<el-table-column label="库位ID" align="center" prop="locationId" width="120" />
<!-- <el-table-column label="库存ID" align="center" prop="inventoryId" width="120" /> -->
<el-table-column label="出库单ID" align="center" prop="outboundOrderId" width="120" />
<el-table-column label="计划数量" align="center" prop="plannedQuantity" width="100" />
<el-table-column label="实际数量" align="center" prop="actualQuantity" width="100" />
<el-table-column label="单价" align="center" prop="unitPrice" width="100">
......@@ -125,13 +124,8 @@
<el-table-column label="凭证号" align="center" prop="voucherNumber" width="150" />
<el-table-column label="明细状态" align="center" prop="itemStatus" width="100">
<template slot-scope="scope">
<el-option
v-for="color in dict.type.label_color"
:key="color.value"
:label="color.label"
:value="color.value"
/>
</template>
<dict-tag v-if="dict.type.outbound_item_status" :options="dict.type.outbound_item_status" :value="scope.row.itemStatus"/>
</template>
</el-table-column>
<el-table-column label="发货时间" align="center" prop="shippedAt" width="180">
<template slot-scope="scope">
......@@ -139,11 +133,11 @@
</template>
</el-table-column>
<el-table-column label="发货方" align="center" prop="shippedBy" width="120" />
<el-table-column label="创建时间" align="center" prop="createTime" width="180">
<!-- <el-table-column label="创建时间" align="center" prop="createTime" width="180">
<template slot-scope="scope">
<span>{{ parseTime(scope.row.createTime, '{y}-{m}-{d} {h}:{i}') }}</span>
</template>
</el-table-column>
</el-table-column> -->
<el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="180">
<template slot-scope="scope">
<el-button
......@@ -345,7 +339,7 @@ import PageTitle from "@/components/PageTitle"
export default {
name: "OutboundOrderItems",
dicts: ['outbound_order_type', 'inbound_order_type', 'inbound_order_item_status', 'label_color'],
dicts: ['outbound_item_status', 'inbound_order_type', 'inbound_order_item_status', 'label_color'],
components: {
PageTitle
},
......
......@@ -373,7 +373,7 @@
<div v-for="(group, materialId) in outboundOrderItemsGroup" :key="materialId" class="material-group mb10">
<div class="group-header" style="background: #f5f7fa; padding: 8px 12px; border-radius: 4px; margin-bottom: 8px;">
<span style="font-weight: 600; margin-right: 16px;">物料ID{{ materialId }}</span>
<span style="font-weight: 600; margin-right: 16px;">物料{{ materialId+" "+ getMaterialName(materialId) }}</span>
<span style="color: #666;">明细数量:{{ group.items.length }} </span>
<!-- 仅编辑模式显示分组操作按钮 -->
<el-button
......@@ -391,7 +391,6 @@
:row-class-name="(params) => rowInboundOrderItemsIndex(params, group.items)"
@selection-change="handleInboundOrderItemsSelectionChange"
ref="inboundOrderItems"
border
style="width: 100%;"
:row-key="item => item.inventoryId"
:disabled="isViewDetail"
......@@ -399,8 +398,8 @@
<!-- 仅编辑模式显示选择列 -->
<el-table-column type="selection" width="50" align="center" v-if="!isViewDetail" />
<el-table-column label="序号" align="center" prop="index" width="50"/>
<el-table-column label="物料编号" prop="materialId" width="150" />
<el-table-column label="仓库编号" prop="warehouseId" width="150" />
<el-table-column label="物料编号" prop="materialId" width="180"/>
<!-- <el-table-column label="仓库编号" prop="warehouseId" width="150" /> -->
<el-table-column label="库位编号" prop="locationId" width="150" />
<el-table-column label="批次编号" prop="batchCode" width="150" />
......@@ -437,8 +436,10 @@
:open="detailDialogOpen"
:init-form="currentDetailItem"
:init-details="getInitDetails()"
:orders-id = "form.id"
:group-data="currentGroupData"
:outbound-order-id="form.orderId || form.outboundOrderId"
:materialdicts="materialdicts"
@submit="handleDetailSubmit"
@close="detailDialogOpen = false"
@update:open="detailDialogOpen = $event"
......@@ -466,6 +467,8 @@
<script>
import { listOrders, getOrders, delOrders, addOrders, updateOrders, ship } from "@/api/inventory/orders"
import { getMaterialsdicts } from "@/api/inventory/materials"
import OutboundOrderFormWithItems from './OutboundOrderFormWithItems.vue'
import WarehouseSelector from "@/views/compononents/WarehouseSelector.vue"
import LocationSelector from "@/views/compononents/LocationSelector.vue"
......@@ -484,6 +487,7 @@ export default {
},
data() {
return {
materialdicts:[],
// 添加tableKey解决tableId渲染问题
tableKey: 1,
// 遮罩层
......@@ -600,22 +604,33 @@ export default {
created() {
// 延迟加载避免初始化渲染问题
this.$nextTick(() => {
this.getdicts(),
this.getList()
})
},
methods: {
// 货主选择回调
handleOwnerSelected(owner) {
if (!owner) return
if (this.ownerSelectTarget === 'query') {
this.queryParams.ownerId = owner.ownerId || owner.id
this.queryOwnerName = owner.ownerName || owner.name
this.handleQuery()
} else {
this.form.ownerId = owner.ownerId || owner.id
this.form.ownerName = owner.ownerName || owner.name
}
this.ownerSelectorVisible = false
getMaterialName(materialId) {
if (!materialId || !this.materialdicts.length) return '未知物料';
// 精准匹配(如果需要模糊匹配,把 === 改成 includes 即可)
const matchItem = this.materialdicts.find(item =>
String(item.value) === String(materialId)
);
return matchItem ? matchItem.label : '未知物料';
},
getdicts(){
return getMaterialsdicts()
.then(response => {
this.materialdicts = (response.data || response).map(item => ({
value: item.sap_no,
label: item.material_name,
}));
console.log("物料字典数据加载成功:", this.materialdicts);
})
.catch(error => {
console.error("加载物料字典失败:", error);
this.$message.error("物料字典加载失败,请刷新重试");
});
},
// 仓库选择回调
handleWarehouseSelected(warehouse) {
......@@ -650,6 +665,25 @@ export default {
this.ownerSelectTarget = target
this.ownerSelectorVisible = true
},
// 货主选择回调(核心缺失方法)
handleOwnerSelected(owner) {
if (!owner) return
if (this.ownerSelectTarget === 'query') {
this.queryParams.ownerId = owner.ownerId || owner.id
this.queryOwnerName = owner.ownerName || owner.name
this.handleQuery()
} else {
this.form.ownerId = owner.ownerId || owner.id
this.form.ownerName = owner.ownerName || owner.name
// 更新明细中的默认货主(可选)
if (this.currentDetailItem) {
this.currentDetailItem.ownerId = owner.ownerId || owner.id
this.currentDetailItem.ownerName = owner.ownerName || owner.name
}
}
this.ownerSelectorVisible = false
},
// 打开仓库选择器
openWarehouseSelector(target = 'form') {
this.warehouseSelectTarget = target
......@@ -1246,6 +1280,7 @@ export default {
ownerName: response.data.ownerName || response.data.ownerId,
totalAmount: 0.00
}
console.log("this.form",this.form)
if (response.data && response.data.outboundOrderItemsList && Array.isArray(response.data.outboundOrderItemsList)) {
// 按物料ID分组 + 库存ID去重
const groupMap = {}
......
......@@ -3,6 +3,8 @@ package com.ruoyi.inventory.controller;
import java.util.List;
import java.util.UUID;
import javax.servlet.http.HttpServletResponse;
import com.ruoyi.inventory.domain.OutboundOrderItems;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
......@@ -77,7 +79,7 @@ public class InventoryController extends BaseController
*/
@PreAuthorize("@ss.hasPermi('inventory:inventory:list')")
@PostMapping("/listByMaterialId")
public TableDataInfo listByMaterialId(@RequestBody Inventory inventory)
public TableDataInfo listByMaterialId(@RequestBody OutboundOrderItems inventory)
{
startPage();
List<Inventory> list = inventoryService.listByMatreialId(inventory);
......
......@@ -30,7 +30,7 @@ public interface MaterialsMapper
* @param id 物料主键
* @return 物料
*/
public List<Materials> selectMaterialsByMaterialsCode(String id);
public List<Materials> selectMaterialsBySapNo(String id);
/**
* 查询物料列表
......
......@@ -65,5 +65,5 @@ public interface OutboundOrderItemsMapper
* @param ids 需要删除的数据主键集合
* @return 结果
*/
public int deleteOutboundOrderItemsByIds(String[] ids);
public int deleteOutboundOrderItemsById(String[] ids);
}
......@@ -2,7 +2,6 @@ package com.ruoyi.inventory.mapper;
import java.util.List;
import com.ruoyi.inventory.domain.ReturnOrderItems;
import com.ruoyi.inventory.domain.ReturnOrders;
import com.ruoyi.inventory.domain.vo.ReturnOrdersSummaryVO;
/**
......
......@@ -82,7 +82,7 @@ public interface IInventoryService
*/
public int deleteInventoryById(String id);
public List<Inventory> listByMatreialId(Inventory inventory);
public List<Inventory> listByMatreialId(OutboundOrderItems inventory);
/**
* @description: 获取库存盘点详细信息
* @author cs
......@@ -106,4 +106,5 @@ public interface IInventoryService
* @return 库存明细集合
*/
public List<Inventory> selectInventoryDetailList(Inventory inventory);
}
......@@ -4,11 +4,11 @@ import java.util.*;
import java.util.stream.Collectors;
import com.ruoyi.common.annotation.SerialExecution;
import com.ruoyi.common.core.domain.entity.Materials;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.inventory.domain.InboundOrderItems;
import com.ruoyi.inventory.domain.OutboundOrderItems;
import com.ruoyi.inventory.domain.OutboundOrderLog;
import com.ruoyi.inventory.domain.StocktakeItems;
import com.ruoyi.inventory.domain.TO.StocktakeItemsTo;
import com.ruoyi.inventory.domain.vo.InventorySummaryVO;
import com.ruoyi.inventory.mapper.OutboundOrderItemsMapper;
import com.ruoyi.inventory.mapper.OutboundOrderLogMapper;
......@@ -134,16 +134,18 @@ public class InventoryServiceImpl implements IInventoryService
public int ship(List<OutboundOrderItems> outboundOrderItems)
{
if (!outboundOrderItems.isEmpty()) {
List<String> inventoryIds = outboundOrderItems.stream().map(OutboundOrderItems::getInventoryId).collect(Collectors.toList());
for (OutboundOrderItems outboundOrderItem : outboundOrderItems) {
OutboundOrderLog outboundOrderLog = outboundOrderLogMapper.selectOutboundOrderLogById(outboundOrderItem.getId());
Inventory inventory =inventoryMapper.selectInventoryById(outboundOrderLog.getInventoryId());
inventory.setQuantity(inventory.getQuantity()-outboundOrderItem.getActualQuantity());
inventory.setLockedQuantity(inventory.getQuantity()-outboundOrderItem.getActualQuantity());
if (inventory.getQuantity()==0){
inventory.setInventoryStatus(0l);
}
updateInventory(inventory);
}
RefreshInventory(inventoryIds);
}
return 1;
}
......@@ -189,7 +191,7 @@ public class InventoryServiceImpl implements IInventoryService
@SerialExecution(group = "inventoryRefresh", fair = true)
@Override
public List<Inventory> listByMatreialId(Inventory inventory) {
public List<Inventory> listByMatreialId(OutboundOrderItems inventory) {
String materialId = inventory.getMaterialId();
List<String> inventoryIds = CollectionUtils.isEmpty(inventoryMapper.listByMaterialId(materialId))
......@@ -201,18 +203,18 @@ public class InventoryServiceImpl implements IInventoryService
return MyQuantity(inventory);
}
public List<Inventory> MyQuantity(Inventory inventory){
public List<Inventory> MyQuantity(OutboundOrderItems inventory){
String materialId = inventory.getMaterialId();
List<Inventory> inventoryList = inventoryMapper.listByMaterialId(materialId);
OutboundOrderItems outboundOrderItem = new OutboundOrderItems();
outboundOrderItem.setOutboundOrderId(inventory.getOrderId());
List<OutboundOrderItems> outboundOrderItems = outboundOrderItemsMapper.selectOutboundOrderItemsList(outboundOrderItem);
outboundOrderItem.setOutboundOrderId(inventory.getOutboundOrderId());
List<OutboundOrderItems> outboundOrderItems = outboundOrderItemsMapper.selectOutboundOrderItemsList(outboundOrderItem);
inventoryList.forEach(inventory2 -> {
long deductQuantity = 0;
if (inventory.getOrderId()!=null){
if (inventory.getOutboundOrderId()!=null){
deductQuantity = outboundOrderItems.stream()
.filter(item -> item.getInventoryId().equals(inventory2.getId()))
.mapToLong(OutboundOrderItems::getActualQuantity)
......@@ -233,7 +235,7 @@ public class InventoryServiceImpl implements IInventoryService
* @date 2025/12/3
* @version 1.0
*/
public List<StocktakeItems> selectstocktakeItemsList(){
public List<StocktakeItemsTo> selectstocktakeItemsList(){
return inventoryMapper.selectstocktakeItemsList();
}
......
......@@ -81,7 +81,7 @@ public class OutboundOrderItemsServiceImpl implements IOutboundOrderItemsService
@Override
public int deleteOutboundOrderItemsByIds(String[] ids)
{
return outboundOrderItemsMapper.deleteOutboundOrderItemsByIds(ids);
return outboundOrderItemsMapper.deleteOutboundOrderItemsById(ids);
}
/**
......
......@@ -41,6 +41,11 @@ public class OutboundOrdersServiceImpl implements IOutboundOrdersService
private OutboundOrderLogMapper outboundOrderLogMapper;
@Autowired
private OwnersServiceImpl ownersService;
@Autowired
private WarehousesServiceImpl warehousesService;
@Autowired
private InventoryServiceImpl inventoryService;
/**
* 查询出库单主
......@@ -64,7 +69,8 @@ public class OutboundOrdersServiceImpl implements IOutboundOrdersService
@Override
public List<OutboundOrders> selectOutboundOrdersList(OutboundOrders outboundOrders)
{
return outboundOrdersMapper.selectOutboundOrdersList(outboundOrders);
List<OutboundOrders> outboundOrders1 = outboundOrdersMapper.selectOutboundOrdersList(outboundOrders);
return outboundOrders1;
}
/**
......@@ -80,6 +86,7 @@ public class OutboundOrdersServiceImpl implements IOutboundOrdersService
outboundOrders.setCreateTime(DateUtils.getNowDate());
outboundOrders.setCreateBy(SystemUtils.getUserName());
outboundOrders.setId(UUID.randomUUID().toString());
int rows = outboundOrdersMapper.insertOutboundOrders(outboundOrders);
insertOutboundOrderItems(outboundOrders);
return rows;
......@@ -95,9 +102,12 @@ public class OutboundOrdersServiceImpl implements IOutboundOrdersService
@Override
public int updateOutboundOrders(OutboundOrders outboundOrders)
{
outboundOrders.setUpdateTime(DateUtils.getNowDate());
outboundOrdersMapper.deleteOutboundOrderItemsByOrderId(outboundOrders.getId());
outboundOrderLogMapper.deleteOutboundOrderLogByOrdersId(outboundOrders.getId());
outboundOrders.setUpdateBy(SystemUtils.getUserName());
outboundOrders.setUpdateTime(DateUtils.getNowDate());
insertOutboundOrderItems(outboundOrders);
return outboundOrdersMapper.updateOutboundOrders(outboundOrders);
}
......@@ -134,7 +144,7 @@ public class OutboundOrdersServiceImpl implements IOutboundOrdersService
@Override
public int ship(OutboundOrders outboundOrders) {
OutboundOrderItems outboundOrderItems1 = new OutboundOrderItems();
outboundOrderItems1.setOrderId(outboundOrders.getId());
outboundOrderItems1.setOutboundOrderId(outboundOrders.getId());
List<OutboundOrderItems> outboundOrderItems = outboundOrderItemsMapper.selectOutboundOrderItemsList(outboundOrderItems1);
List<OutboundOrderItems> outboundOrderItems2 = outboundOrderItems;
OutboundOrderLog outboundOrderLog = new OutboundOrderLog();
......@@ -197,6 +207,7 @@ public class OutboundOrdersServiceImpl implements IOutboundOrdersService
for (OutboundOrderItems items : outboundOrderItemsList) {
OutboundOrderLog log = new OutboundOrderLog();
BeanUtils.copyProperties(items, log); // 单个对象属性拷贝
log.setOrderId(items.getOutboundOrderId());
outboundOrderLogs.add(log);
inventoryIds.add(log.getInventoryId());
deleteOutboundOrdersById(items.getId());
......
......@@ -76,7 +76,7 @@ public class StorageLocationsServiceImpl implements IStorageLocationsService
String[] AllowedCategoryIds = storageLocations2.getAllowedCategoryIds().split(",");
for (String AllowedCategoryId : AllowedCategoryIds) {
List<Materials> materials = materialsMapper.selectMaterialsByMaterialsCode(AllowedCategoryId);
List<Materials> materials = materialsMapper.selectMaterialsBySapNo(AllowedCategoryId);
if (materials != null && !materials.isEmpty()) {
Materials materials1 = materials.get(0);
......@@ -120,7 +120,7 @@ public class StorageLocationsServiceImpl implements IStorageLocationsService
storageLocationsCategory.setCategoryId(categoryId);
storageLocationsCategory.setCreateTime(DateUtils.getNowDate());
storageLocationsCategory.setCreateUserCode(String.valueOf(SecurityUtils.getUserId()));
List<Materials> materials = materialsMapper.selectMaterialsByMaterialsCode(categoryId);
List<Materials> materials = materialsMapper.selectMaterialsBySapNo(categoryId);
if (materials != null && !materials.isEmpty()) {
Materials materials1 = materials.get(0);
storageLocationsCategory.setCategoryName(materials1.getMaterialName());
......@@ -159,7 +159,7 @@ public class StorageLocationsServiceImpl implements IStorageLocationsService
storageLocationsCategory.setCategoryId(categoryId);
storageLocationsCategory.setUpdateTime(DateUtils.getNowDate());
storageLocationsCategory.setUpdateUserCode(String.valueOf(SecurityUtils.getUserId()));
List<Materials> materials = materialsMapper.selectMaterialsByMaterialsCode(categoryId);
List<Materials> materials = materialsMapper.selectMaterialsBySapNo(categoryId);
if (materials != null && !materials.isEmpty()) {
Materials materials1 = materials.get(0);
storageLocationsCategory.setCategoryName(materials1.getMaterialName());
......
......@@ -76,9 +76,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where id = #{id}
order by sort_no asc
</select>
<select id="selectMaterialsByMaterialsCode" parameterType="String" resultMap="MaterialsResult">
<select id="selectMaterialsBySapNo" parameterType="String" resultMap="MaterialsResult">
<include refid="selectMaterialsVo"/>
where material_code = #{id}
where sap_no = #{id}
order by sort_no asc
</select>
<select id="selectMaterialsByCategory" parameterType="String" resultMap="MaterialsResult">
......
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.inventory.mapper.OutboundOrderItemsMapper">
<resultMap type="OutboundOrderItems" id="OutboundOrderItemsResult">
<result property="id" column="id" />
<result property="orderId" column="order_id" />
......@@ -58,14 +58,22 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="updateTime" column="update_time" />
<result property="updateUserCode" column="update_user_code" />
</resultMap>
<sql id="selectOutboundOrderItemsVo">
select id, order_id, material_id, batch_code, warehouse_id, location_id, inventory_id, outbound_order_id, unit_price, planned_quantity, actual_quantity, divisor, label_color, voucher_number, item_status, shipped_at, shipped_by, remark, is_used, sort_no, create_time, create_user_code, update_time, update_user_code from outbound_order_items
</sql>
<select id="selectOutboundOrderItemsList" parameterType="OutboundOrderItems" resultMap="OutboundOrderItemsResult">
<include refid="selectOutboundOrderItemsVo"/>
<where>
<where>
<if test="isUsed == null">
is_used = 1
</if>
<if test="isUsed != null">
is_used = #{isUsed}
</if>
<if test="orderId != null and orderId != ''"> and order_id = #{orderId}</if>
<if test="outboundOrderId != null and outboundOrderId != ''"> and outbound_order_id = #{outboundOrderId}</if>
<if test="materialId != null and materialId != ''"> and material_id = #{materialId}</if>
<if test="batchCode != null and batchCode != ''"> and batch_code = #{batchCode}</if>
<if test="warehouseId != null and warehouseId != ''"> and warehouse_id = #{warehouseId}</if>
......@@ -79,16 +87,24 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="itemStatus != null "> and item_status = #{itemStatus}</if>
<if test="shippedAt != null "> and shipped_at = #{shippedAt}</if>
<if test="shippedBy != null and shippedBy != ''"> and shipped_by = #{shippedBy}</if>
<if test="isUsed != null "> and is_used = #{isUsed}</if>
<if test="sortNo != null "> and sort_no = #{sortNo}</if>
<if test="createUserCode != null and createUserCode != ''"> and create_user_code = #{createUserCode}</if>
<if test="updateUserCode != null and updateUserCode != ''"> and update_user_code = #{updateUserCode}</if>
</where>
</select>
<!-- 单条查询:默认查使用中,若手动传isUsed则覆盖 -->
<select id="selectOutboundOrderItemsById" parameterType="String" resultMap="OutboundOrderItemsResult">
<include refid="selectOutboundOrderItemsVo"/>
where id = #{id}
<!-- 增加is_used过滤,避免查询已逻辑删除的数据 -->
<if test="isUsed == null">
and is_used = 1
</if>
<if test="isUsed != null">
and is_used = #{isUsed}
</if>
</select>
<insert id="insertOutboundOrderItems" parameterType="OutboundOrderItems">
......@@ -112,13 +128,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="shippedAt != null">shipped_at,</if>
<if test="shippedBy != null">shipped_by,</if>
<if test="remark != null">remark,</if>
<if test="isUsed == null">is_used,</if>
<if test="isUsed != null">is_used,</if>
<if test="sortNo != null">sort_no,</if>
<if test="createTime != null">create_time,</if>
<if test="createUserCode != null">create_user_code,</if>
<if test="updateTime != null">update_time,</if>
<if test="updateUserCode != null">update_user_code,</if>
</trim>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id},</if>
<if test="orderId != null">#{orderId},</if>
......@@ -138,13 +155,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="shippedAt != null">#{shippedAt},</if>
<if test="shippedBy != null">#{shippedBy},</if>
<if test="remark != null">#{remark},</if>
<if test="isUsed == null">1,</if>
<if test="isUsed != null">#{isUsed},</if>
<if test="sortNo != null">#{sortNo},</if>
<if test="createTime != null">#{createTime},</if>
<if test="createUserCode != null">#{createUserCode},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="updateUserCode != null">#{updateUserCode},</if>
</trim>
</trim>
</insert>
<update id="updateOutboundOrderItems" parameterType="OutboundOrderItems">
......@@ -177,10 +195,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
where id = #{id}
</update>
<delete id="deleteOutboundOrderItemsById" parameterType="String">
delete from outbound_order_items where id = #{id}
</delete>
<!-- 单条删除:物理删除改为逻辑删除(更新is_used=0) -->
<update id="deleteOutboundOrderItemsById" parameterType="String">
update outbound_order_items
set is_used = 0,
where id = #{id}
</update>
<!-- 统计查询:默认查is_used=1,支持手动传isUsed覆盖 -->
<select id="selectOutboundOrderItemsStatistics"
parameterType="OutboundOrderItemsStatisticsVO"
resultMap="OutboundOrderItemsStatisticsVoResult">
......@@ -211,36 +233,46 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
oi.update_user_code
FROM outbound_order_items oi
LEFT JOIN outbound_orders o ON oi.outbound_order_id = o.id
WHERE oi.is_used = 1
<if test="orderId != null and orderId != ''">
AND o.order_id LIKE CONCAT('%', #{orderId}, '%')
</if>
<if test="startDate != null">
AND o.inbound_date >= #{startDate}
</if>
<if test="endDate != null">
AND o.inbound_date &lt;= DATE_ADD(#{endDate}, INTERVAL 1 DAY)
</if>
<if test="materialId != null and materialId != ''">
AND oi.material_id LIKE CONCAT('%', #{materialId}, '%')
</if>
<if test="warehouseId != null and warehouseId != ''">
AND oi.warehouse_id = #{warehouseId}
</if>
<if test="locationId != null and locationId != ''">
AND oi.location_id = #{locationId}
</if>
<if test="itemStatus != null and itemStatus != ''">
AND oi.item_status = #{itemStatus}
</if>
<where>
<if test="isUsed == null">
oi.is_used = 1
</if>
<if test="isUsed != null">
oi.is_used = #{isUsed}
</if>
<if test="orderId != null and orderId != ''">
AND o.order_id LIKE CONCAT('%', #{orderId}, '%')
</if>
<if test="startDate != null">
AND o.inbound_date >= #{startDate}
</if>
<if test="endDate != null">
AND o.inbound_date &lt;= DATE_ADD(#{endDate}, INTERVAL 1 DAY)
</if>
<if test="materialId != null and materialId != ''">
AND oi.material_id LIKE CONCAT('%', #{materialId}, '%')
</if>
<if test="warehouseId != null and warehouseId != ''">
AND oi.warehouse_id = #{warehouseId}
</if>
<if test="locationId != null and locationId != ''">
AND oi.location_id = #{locationId}
</if>
<if test="itemStatus != null and itemStatus != ''">
AND oi.item_status = #{itemStatus}
</if>
</where>
ORDER BY oi.create_time DESC
</select>
<delete id="deleteOutboundOrderItemsByIds" parameterType="String">
delete from outbound_order_items where id in
<!-- 批量删除:物理删除改为逻辑删除 -->
<update id="deleteOutboundOrderItemsByIds" parameterType="String">
update outbound_order_items
set is_used = 0,
where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</update>
</mapper>
\ No newline at end of file
</mapper>
......@@ -24,7 +24,7 @@
<select id="selectOutboundOrderLogList" parameterType="OutboundOrderLog" resultMap="OutboundOrderLogResult">
<include refid="selectOutboundOrderLogVo"/>
<where>
where is_used=1
<if test="orderId != null and orderId != ''"> and order_id = #{orderId}</if>
<if test="inventoryId != null and inventoryId != ''"> and inventory_id = #{inventoryId}</if>
<if test="materialId != null and materialId != ''"> and material_id = #{materialId}</if>
......@@ -32,8 +32,6 @@
<if test="batchCode != null and batchCode != ''"> and batch_code = #{batchCode}</if>
<if test="actualQuantity != null "> and actual_quantity = #{actualQuantity}</if>
<if test="itemStatus != null "> and item_status = #{itemStatus}</if>
<if test="isUsed != null "> and is_used = #{isUsed}</if>
</where>
</select>
<select id="deleteLog" parameterType="OutboundOrderLog" resultMap="OutboundOrderLogResult">
......@@ -43,23 +41,20 @@
<if test="warehouseId != null and warehouseId != ''"> and warehouse_id = #{warehouseId}</if>
<if test="batchCode != null and batchCode != ''"> and batch_code = #{batchCode}</if>
<if test="itemStatus != null "> and item_status = #{itemStatus}</if>
<!-- 补充inventory_id条件 -->
<if test="inventoryId != null and inventoryId != ''"> and inventory_id = #{inventoryId}</if>
</where>
</select>
<!-- 修正参数错误:原#{id}改为#{inventoryId} -->
<select id="selectLockedQuantityByInventory" parameterType="OutboundOrderLog" resultType="java.lang.Long">
select ifnull(sum(actual_quantity), 0)
from outbound_order_log
where item_status=1
where item_status=1 and is_used=1
<if test="inventoryId != null and inventoryId != ''"> and inventory_id = #{inventoryId}</if>
</select>
<select id="selectOutboundOrderLogById" parameterType="String" resultMap="OutboundOrderLogResult">
<include refid="selectOutboundOrderLogVo"/>
where id = #{id}
where id = #{id} and is_used=1
</select>
<!-- 插入语句补充inventory_id -->
......@@ -106,15 +101,15 @@
</update>
<delete id="deleteOutboundOrderLogById" parameterType="String">
delete from outbound_order_log where id = #{id}
update outbound_order_log set is_used=0 where id = #{id}
</delete>
<delete id="deleteOutboundOrderLogByOrdersId" parameterType="String">
delete from outbound_order_log where order_id = #{id}
update outbound_order_log set is_used=0 where order_id = #{id}
</delete>
<delete id="deleteOutboundOrderLogByOrdersIds" parameterType="String">
delete from outbound_order_log where order_id in
update outbound_order_log set is_used=0 where order_id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
......
......@@ -4,7 +4,7 @@
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.inventory.mapper.OutboundOrdersMapper">
<resultMap type="OutboundOrders" id="OutboundOrdersResult">
<resultMap type="com.ruoyi.inventory.domain.OutboundOrders" id="OutboundOrdersResult">
<result property="id" column="id" />
<result property="orderId" column="order_id" />
<result property="systemNo" column="system_no" />
......@@ -27,12 +27,17 @@
<result property="updateUserCode" column="update_user_code" />
</resultMap>
<resultMap id="OutboundOrdersOutboundOrderItemsResult" type="OutboundOrders" extends="OutboundOrdersResult">
<collection property="outboundOrderItemsList" ofType="OutboundOrderItems" column="id" select="selectOutboundOrderItemsList" />
<!-- 核心修复:删除重复的collection,只保留一个正确的关联配置 -->
<resultMap id="OutboundOrdersOutboundOrderItemsResult" type="com.ruoyi.inventory.domain.OutboundOrders" extends="OutboundOrdersResult">
<collection
property="outboundOrderItemsList"
ofType="com.ruoyi.inventory.domain.OutboundOrderItems"
column="id"
select="selectOutboundOrderItemsList" />
</resultMap>
<!-- 修复:仅保留子表outbound_order_items的字段映射,删除错误的主表字段 -->
<resultMap type="OutboundOrderItems" id="OutboundOrderItemsResult">
<!-- 原主表结果映射:仅修复InboundOrderId大小写,其余完全保留 -->
<resultMap type="com.ruoyi.inventory.domain.OutboundOrderItems" id="OutboundOrderItemsResult">
<result property="id" column="id" />
<result property="orderId" column="order_id" />
<result property="materialId" column="material_id" />
......@@ -57,47 +62,44 @@
<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="inboundOrderId" column="inbound_order_id" />
</resultMap>
<!-- 以下所有代码完全保留,不做任何修改 -->
<sql id="selectOutboundOrdersVo">
select id, order_id, system_no, order_type_id, batch_code, warehouse_id, owner_id, order_status, inbound_date, destination, total_planned_quantity, total_actual_quantity, total_packages, remark, is_used, sort_no, create_time, create_user_code, update_time, update_user_code from outbound_orders
</sql>
<select id="selectOutboundOrdersList" parameterType="OutboundOrders" resultMap="OutboundOrdersResult">
<include refid="selectOutboundOrdersVo"/>
<where>
<if test="orderId != null and orderId != ''"> and order_id = #{orderId}</if>
<if test="systemNo != null and systemNo != ''"> and system_no = #{systemNo}</if>
<if test="orderTypeId != null and orderTypeId != ''"> and order_type_id = #{orderTypeId}</if>
<if test="batchCode != null and batchCode != ''"> and batch_code = #{batchCode}</if>
<if test="warehouseId != null and warehouseId != ''"> and warehouse_id = #{warehouseId}</if>
<if test="ownerId != null and ownerId != ''"> and owner_id = #{ownerId}</if>
<if test="orderStatus != null "> and order_status = #{orderStatus}</if>
<if test="inboundDate != null "> and inbound_date = #{inboundDate}</if>
<if test="destination != null and destination != ''"> and destination = #{destination}</if>
<if test="totalPlannedQuantity != null "> and total_planned_quantity = #{totalPlannedQuantity}</if>
<if test="totalActualQuantity != null "> and total_actual_quantity = #{totalActualQuantity}</if>
<if test="totalPackages != null "> and total_packages = #{totalPackages}</if>
<if test="isUsed != null "> and is_used = #{isUsed}</if>
<if test="sortNo != null "> and sort_no = #{sortNo}</if>
<if test="createUserCode != null and createUserCode != ''"> and create_user_code = #{createUserCode}</if>
<if test="updateUserCode != null and updateUserCode != ''"> and update_user_code = #{updateUserCode}</if>
</where>
where is_used = 1
<if test="orderId != null and orderId != ''"> and order_id = #{orderId}</if>
<if test="systemNo != null and systemNo != ''"> and system_no = #{systemNo}</if>
<if test="orderTypeId != null and orderTypeId != ''"> and order_type_id = #{orderTypeId}</if>
<if test="batchCode != null and batchCode != ''"> and batch_code = #{batchCode}</if>
<if test="warehouseId != null and warehouseId != ''"> and warehouse_id = #{warehouseId}</if>
<if test="ownerId != null and ownerId != ''"> and owner_id = #{ownerId}</if>
<if test="orderStatus != null "> and order_status = #{orderStatus}</if>
<if test="inboundDate != null "> and inbound_date = #{inboundDate}</if>
<if test="destination != null and destination != ''"> and destination = #{destination}</if>
<if test="totalPlannedQuantity != null "> and total_planned_quantity = #{totalPlannedQuantity}</if>
<if test="totalActualQuantity != null "> and total_actual_quantity = #{totalActualQuantity}</if>
<if test="totalPackages != null "> and total_packages = #{totalPackages}</if>
<if test="sortNo != null "> and sort_no = #{sortNo}</if>
<if test="createUserCode != null and createUserCode != ''"> and create_user_code = #{createUserCode}</if>
<if test="updateUserCode != null and updateUserCode != ''"> and update_user_code = #{updateUserCode}</if>
</select>
<select id="selectOutboundOrdersById" parameterType="String" resultMap="OutboundOrdersOutboundOrderItemsResult">
select id, order_id, system_no, order_type_id, batch_code, warehouse_id, owner_id, order_status, inbound_date, destination, total_planned_quantity, total_actual_quantity, total_packages, remark, is_used, sort_no, create_time, create_user_code, update_time, update_user_code
from outbound_orders
where id = #{id}
where id = #{id} and is_used=1
</select>
<!-- 仅保留子表查询逻辑,字段完整且映射正确 -->
<select id="selectOutboundOrderItemsList" parameterType="String" resultMap="OutboundOrderItemsResult">
select id, order_id, material_id, batch_code, warehouse_id, location_id, inventory_id, outbound_order_id, unit_price, planned_quantity, actual_quantity, divisor, label_color, voucher_number, item_status, shipped_at, shipped_by, remark, is_used, sort_no, create_time, create_user_code, update_time, update_user_code
from outbound_order_items
where order_id = #{id}
where outbound_order_id = #{id} AND is_used=1
</select>
<insert id="insertOutboundOrders" parameterType="OutboundOrders">
......@@ -175,25 +177,25 @@
</update>
<delete id="deleteOutboundOrdersById" parameterType="String">
delete from outbound_orders where id = #{id}
update outbound_orders set is_used=0 where id = #{id}
</delete>
<delete id="deleteOutboundOrdersByIds" parameterType="String">
delete from outbound_orders where id in
update outbound_orders set is_used=0 where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
<delete id="deleteOutboundOrderItemsByOrderIds" parameterType="String">
delete from outbound_order_items where outbound_order_id in
update outbound_order_items set is_used=0 where outbound_order_id in
<foreach item="orderId" collection="array" open="(" separator="," close=")">
#{orderId}
</foreach>
</delete>
<delete id="deleteOutboundOrderItemsByOrderId" parameterType="String">
delete from outbound_order_items where outbound_order_id = #{orderId}
update outbound_order_items set is_used=0 where outbound_order_id = #{orderId}
</delete>
<insert id="batchOutboundOrderItems">
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论