仓库信息模块优化

This commit is contained in:
2025-10-30 11:01:07 +08:00
parent db8e6c514c
commit 845f2fd59a
10 changed files with 360 additions and 153 deletions

View File

@@ -24,10 +24,11 @@ public class PcdeDetail extends BaseEntity {
private String pcode; private String pcode;
/** 所属场景 */ /** 所属场景 */
@Excel(name = "所属场景名称") @Excel(name = "所属场景编号")
private String scene; private String scene;
/** 所属场景名称 */ /** 所属场景名称 */
@Excel(name = "所属场景名称")
private String sceneName; private String sceneName;
/** 所属仓库 */ /** 所属仓库 */

View File

@@ -26,6 +26,14 @@ public class SceneMapping extends BaseEntity
@Excel(name = "场景名称") @Excel(name = "场景名称")
private String sceneName; private String sceneName;
/** 所属仓库编码 */
@Excel(name = "所属仓库编码")
private String warehouseCode;
/** 所属仓库名称(查询时通过关联 warehouse_info 返回) */
@Excel(name = "所属仓库名称")
private String warehouseName;
public void setId(Long id) public void setId(Long id)
{ {
this.id = id; this.id = id;
@@ -56,12 +64,35 @@ public class SceneMapping extends BaseEntity
return sceneName; return sceneName;
} }
public void setWarehouseCode(String warehouseCode)
{
this.warehouseCode = warehouseCode;
}
public String getWarehouseCode()
{
return warehouseCode;
}
public void setWarehouseName(String warehouseName)
{
this.warehouseName = warehouseName;
}
public String getWarehouseName()
{
return warehouseName;
}
@Override @Override
public String toString() { public String toString()
{
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId()) .append("id", getId())
.append("sceneCode", getSceneCode()) .append("sceneCode", getSceneCode())
.append("sceneName", getSceneName()) .append("sceneName", getSceneName())
.append("warehouseCode", getWarehouseCode())
.append("warehouseName", getWarehouseName())
.toString(); .toString();
} }
} }

View File

@@ -32,8 +32,16 @@ public class WarehouseInfo extends BaseEntity
@Excel(name = "仓库地址") @Excel(name = "仓库地址")
private String address; private String address;
/** 所属大仓编码 */
@Excel(name = "所属大仓编码")
private String parentWarehouseCode;
/** 所属大仓名称 */
@Excel(name = "所属大仓名称")
private String parentWarehouseName;
/** 状态1=启用0=禁用) */ /** 状态1=启用0=禁用) */
@Excel(name = "状态", readConverterExp = "1==启用0=禁用") @Excel(name = "状态", readConverterExp = "1=启用,0=禁用")
private Long status; private Long status;
/** 排序值 */ /** 排序值 */
@@ -50,6 +58,8 @@ public class WarehouseInfo extends BaseEntity
@Excel(name = "更新时间", width = 30, dateFormat = "yyyy-MM-dd") @Excel(name = "更新时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date updatedAt; private Date updatedAt;
// ===================== Getter / Setter =====================
public void setId(Long id) public void setId(Long id)
{ {
this.id = id; this.id = id;
@@ -90,6 +100,26 @@ public class WarehouseInfo extends BaseEntity
return address; return address;
} }
public void setParentWarehouseCode(String parentWarehouseCode)
{
this.parentWarehouseCode = parentWarehouseCode;
}
public String getParentWarehouseCode()
{
return parentWarehouseCode;
}
public void setParentWarehouseName(String parentWarehouseName)
{
this.parentWarehouseName = parentWarehouseName;
}
public String getParentWarehouseName()
{
return parentWarehouseName;
}
public void setStatus(Long status) public void setStatus(Long status)
{ {
this.status = status; this.status = status;
@@ -131,12 +161,15 @@ public class WarehouseInfo extends BaseEntity
} }
@Override @Override
public String toString() { public String toString()
{
return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE) return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId()) .append("id", getId())
.append("warehouseCode", getWarehouseCode()) .append("warehouseCode", getWarehouseCode())
.append("warehouseName", getWarehouseName()) .append("warehouseName", getWarehouseName())
.append("address", getAddress()) .append("address", getAddress())
.append("parentWarehouseCode", getParentWarehouseCode())
.append("parentWarehouseName", getParentWarehouseName())
.append("status", getStatus()) .append("status", getStatus())
.append("sort", getSort()) .append("sort", getSort())
.append("remark", getRemark()) .append("remark", getRemark())

View File

@@ -74,4 +74,11 @@ public interface PcdeDetailMapper
* @return * @return
*/ */
String selectEncodedIdByPcode(@Param("pcode") String pcode);; String selectEncodedIdByPcode(@Param("pcode") String pcode);;
/**
* 批量插入(忽略已存在的)
* @param slice
* @return
*/
int batchInsertIgnore(List<PcdeDetail> slice);
} }

View File

@@ -1,15 +1,13 @@
package com.zg.project.information.service.impl; package com.zg.project.information.service.impl;
import java.util.ArrayList; import java.util.*;
import java.util.Collections;
import java.util.List;
import java.util.TimerTask;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.zg.common.exception.ServiceException; import com.zg.common.exception.ServiceException;
import com.zg.common.utils.DateUtils; import com.zg.common.utils.DateUtils;
import com.zg.common.utils.StringUtils;
import com.zg.framework.manager.AsyncManager; import com.zg.framework.manager.AsyncManager;
import com.zg.project.wisdom.mapper.RkInfoMapper; import com.zg.project.wisdom.mapper.RkInfoMapper;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@@ -157,55 +155,62 @@ public class PcdeDetailServiceImpl implements IPcdeDetailService
throw new ServiceException("导入数据不能为空!"); throw new ServiceException("导入数据不能为空!");
} }
AtomicInteger successNum = new AtomicInteger(0); final Date now = DateUtils.getNowDate();
AtomicInteger failureNum = new AtomicInteger(0);
List<String> failureMsgs = Collections.synchronizedList(new ArrayList<>());
for (PcdeDetail detail : pcdeList) { // 1) 清洗 + 本地生成 encodedId逐字符→Unicode→HEX大写→拼接
TimerTask task = new TimerTask() { List<PcdeDetail> cleaned = new ArrayList<>(pcdeList.size());
@Override for (PcdeDetail d : pcdeList) {
public void run() { if (d == null) continue;
try { String p = d.getPcode() == null ? null : d.getPcode().trim();
PcdeDetail exist = pcdeDetailMapper.selectByPcode(detail.getPcode()); if (StringUtils.isEmpty(p)) {
if (exist == null) { // 跳过空 pcode
detail.setCreateBy(operName); continue;
detail.setCreateTime(DateUtils.getNowDate());
pcdeDetailMapper.insertPcdeDetail(detail);
successNum.incrementAndGet();
} else {
failureNum.incrementAndGet();
failureMsgs.add("库位编号 = " + detail.getPcode() + " 已存在");
} }
} catch (Exception e) { d.setPcode(p);
failureNum.incrementAndGet(); d.setEncodedId(toHexStringFromPcode(p));
failureMsgs.add("库位编号 = " + detail.getPcode() + " 导入失败:" + e.getMessage());
}
}
};
// ✅ 使用自定义线程池工具类提交任务 // 审计字段与你实体保持一致createdBy/createdAt/updatedBy/updatedAt
AsyncManager.me().execute(task); d.setCreatedBy(operName);
d.setCreatedAt(now);
d.setUpdatedBy(operName);
d.setUpdatedAt(now);
// 业务兜底
if (d.getIsDelete() == null) d.setIsDelete("0");
cleaned.add(d);
} }
// ❗此处无法精确等待全部线程完成,只做简单延时(如需精确等待建议用 CountDownLatch if (cleaned.isEmpty()) {
try { throw new ServiceException("有效的库位编号为空,请检查导入文件!");
Thread.sleep(2000); // 根据量级可调,比如 100 条记录等 1~2 秒
} catch (InterruptedException e) {
Thread.currentThread().interrupt();
} }
if (failureNum.get() > 0) { // 2) 批量写库(分片,避免 SQL 过大;配合 uk_pcode + INSERT IGNORE 实现幂等忽略)
StringBuilder msg = new StringBuilder(); final int batchSize = 1000;
msg.append("很抱歉,导入失败!共 ").append(failureNum.get()).append(" 条数据有误,错误如下:"); int totalTried = cleaned.size();
for (String fail : failureMsgs) { int totalInserted = 0;
msg.append("<br/>").append(fail);
} for (int i = 0; i < cleaned.size(); i += batchSize) {
throw new ServiceException(msg.toString()); int end = Math.min(i + batchSize, cleaned.size());
} else { List<PcdeDetail> slice = cleaned.subList(i, end);
return "恭喜您,数据已全部导入成功!共 " + successNum.get() + " 条。"; int affected = pcdeDetailMapper.batchInsertIgnore(slice);
} totalInserted += affected;
} }
int skipped = totalTried - totalInserted;
return String.format("导入完成:共读取 %d 条,成功导入 %d 条,跳过(可能重复) %d 条。",
totalTried, totalInserted, skipped);
}
/** 将 pcode 按字符转大写十六进制(与新增接口保持一致) */
private String toHexStringFromPcode(String pcode) {
StringBuilder hex = new StringBuilder(pcode.length() * 2);
for (int i = 0; i < pcode.length(); i++) {
char c = pcode.charAt(i);
hex.append(Integer.toHexString(c).toUpperCase());
}
return hex.toString();
}
/** /**
* 获取未被入库单据使用的库位列表 * 获取未被入库单据使用的库位列表

View File

@@ -7,9 +7,9 @@ spring:
# 主库数据源 # 主库数据源
master: master:
# url: jdbc:mysql://101.132.133.142:3306/wisdom?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 # url: jdbc:mysql://101.132.133.142:3306/wisdom?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
# url: jdbc:mysql://192.168.1.20:3306/wisdom?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 url: jdbc:mysql://192.168.1.20:3306/wisdom?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
# url: jdbc:mysql://192.168.1.192:3306/wisdom?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 # url: jdbc:mysql://192.168.1.192:3306/wisdom?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
url: jdbc:mysql://192.168.1.251:3306/wisdom?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 # url: jdbc:mysql://192.168.1.251:3306/wisdom?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
# url: jdbc:mysql://localhost:3306/wisdom?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8 # url: jdbc:mysql://localhost:3306/wisdom?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
username: root username: root
password: shzg password: shzg

View File

@@ -69,8 +69,8 @@ spring:
redis: redis:
# 地址 # 地址
# host: 101.132.133.142 # host: 101.132.133.142
# host: 192.168.1.20 host: 192.168.1.20
host: 192.168.1.251 # host: 192.168.1.251
# host: localhost # host: localhost
# 端口默认为6379 # 端口默认为6379
port: 6379 port: 6379

View File

@@ -131,6 +131,32 @@
where id = #{id} where id = #{id}
</update> </update>
<insert id="batchInsertIgnore">
INSERT IGNORE INTO pcde_detail
(pcode, scene, scene_name, warehouse, warehouse_name,
encoded_id, tag, remark, is_delete,
created_by, created_at, updated_by, updated_at)
VALUES
<foreach collection="list" item="item" separator=",">
(
#{item.pcode},
#{item.scene},
#{item.sceneName},
#{item.warehouse},
#{item.warehouseName},
#{item.encodedId},
#{item.tag},
#{item.remark},
#{item.isDelete},
#{item.createdBy},
#{item.createdAt},
#{item.updatedBy},
#{item.updatedAt}
)
</foreach>
</insert>
<delete id="deletePcdeDetailById" parameterType="Long"> <delete id="deletePcdeDetailById" parameterType="Long">
delete from pcde_detail where id = #{id} delete from pcde_detail where id = #{id}
</delete> </delete>

View File

@@ -4,58 +4,100 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.zg.project.information.mapper.SceneMappingMapper"> <mapper namespace="com.zg.project.information.mapper.SceneMappingMapper">
<resultMap type="SceneMapping" id="SceneMappingResult"> <!-- ====== 实体映射 ====== -->
<resultMap id="SceneMappingResult" type="SceneMapping">
<result property="id" column="id"/> <result property="id" column="id"/>
<result property="sceneCode" column="scene_code"/> <result property="sceneCode" column="scene_code"/>
<result property="sceneName" column="scene_name"/> <result property="sceneName" column="scene_name"/>
<result property="warehouseCode" column="warehouse_code"/>
<result property="warehouseName" column="warehouse_name"/>
</resultMap> </resultMap>
<!-- ====== 通用查询列(含连表字段) ====== -->
<sql id="selectSceneMappingVo"> <sql id="selectSceneMappingVo">
select id, scene_code, scene_name from scene_mapping SELECT
sm.id,
sm.scene_code,
sm.scene_name,
sm.warehouse_code,
wi.warehouse_name AS warehouse_name
FROM scene_mapping sm
LEFT JOIN warehouse_info wi
ON wi.warehouse_code = sm.warehouse_code
</sql> </sql>
<!-- ====== 列表查询 ====== -->
<select id="selectSceneMappingList" parameterType="SceneMapping" resultMap="SceneMappingResult"> <select id="selectSceneMappingList" parameterType="SceneMapping" resultMap="SceneMappingResult">
<include refid="selectSceneMappingVo"/> <include refid="selectSceneMappingVo"/>
<where> <where>
<if test="sceneCode != null and sceneCode != ''"> and scene_code = #{sceneCode}</if> <if test="sceneCode != null and sceneCode != ''">
<if test="sceneName != null and sceneName != ''"> and scene_name like concat('%', #{sceneName}, '%')</if> AND sm.scene_code = #{sceneCode}
</if>
<if test="sceneName != null and sceneName != ''">
AND sm.scene_name LIKE CONCAT('%', #{sceneName}, '%')
</if>
<if test="warehouseCode != null and warehouseCode != ''">
AND sm.warehouse_code = #{warehouseCode}
</if>
<if test="warehouseName != null and warehouseName != ''">
AND wi.warehouse_name LIKE CONCAT('%', #{warehouseName}, '%')
</if>
</where> </where>
</select> </select>
<!-- ====== 主键查询 ====== -->
<select id="selectSceneMappingById" parameterType="Long" resultMap="SceneMappingResult"> <select id="selectSceneMappingById" parameterType="Long" resultMap="SceneMappingResult">
<include refid="selectSceneMappingVo"/> <include refid="selectSceneMappingVo"/>
where id = #{id} WHERE sm.id = #{id}
</select> </select>
<!-- ====== 新增 ====== -->
<insert id="insertSceneMapping" parameterType="SceneMapping" useGeneratedKeys="true" keyProperty="id"> <insert id="insertSceneMapping" parameterType="SceneMapping" useGeneratedKeys="true" keyProperty="id">
insert into scene_mapping INSERT INTO scene_mapping
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">
<if test="sceneCode != null and sceneCode != ''">scene_code,</if> <if test="sceneCode != null and sceneCode != ''">scene_code,</if>
<if test="sceneName != null and sceneName != ''">scene_name,</if> <if test="sceneName != null and sceneName != ''">scene_name,</if>
<if test="warehouseCode != null and warehouseCode != ''">warehouse_code,</if>
<if test="warehouseName != null and warehouseName != ''">warehouse_name,</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="VALUES (" suffix=")" suffixOverrides=",">
<if test="sceneCode != null and sceneCode != ''">#{sceneCode},</if> <if test="sceneCode != null and sceneCode != ''">#{sceneCode},</if>
<if test="sceneName != null and sceneName != ''">#{sceneName},</if> <if test="sceneName != null and sceneName != ''">#{sceneName},</if>
<if test="warehouseCode != null and warehouseCode != ''">#{warehouseCode},</if>
<if test="warehouseName != null and warehouseName != ''">#{warehouseName},</if>
</trim> </trim>
</insert> </insert>
<!-- ====== 更新(可修改所属仓库编码 + 名称) ====== -->
<update id="updateSceneMapping" parameterType="SceneMapping"> <update id="updateSceneMapping" parameterType="SceneMapping">
update scene_mapping UPDATE scene_mapping
<trim prefix="SET" suffixOverrides=","> <trim prefix="SET" suffixOverrides=",">
<if test="sceneCode != null and sceneCode != ''">scene_code = #{sceneCode},</if> <if test="sceneCode != null and sceneCode != ''">
<if test="sceneName != null and sceneName != ''">scene_name = #{sceneName},</if> scene_code = #{sceneCode},
</if>
<if test="sceneName != null and sceneName != ''">
scene_name = #{sceneName},
</if>
<if test="warehouseCode != null and warehouseCode != ''">
warehouse_code = #{warehouseCode},
</if>
<if test="warehouseName != null and warehouseName != ''">
warehouse_name = #{warehouseName},
</if>
</trim> </trim>
where id = #{id} WHERE id = #{id}
</update> </update>
<!-- ====== 删除 ====== -->
<delete id="deleteSceneMappingById" parameterType="Long"> <delete id="deleteSceneMappingById" parameterType="Long">
delete from scene_mapping where id = #{id} DELETE FROM scene_mapping WHERE id = #{id}
</delete> </delete>
<delete id="deleteSceneMappingByIds" parameterType="String"> <delete id="deleteSceneMappingByIds" parameterType="String">
delete from scene_mapping where id in DELETE FROM scene_mapping WHERE id IN
<foreach item="id" collection="array" open="(" separator="," close=")"> <foreach item="id" collection="array" open="(" separator="," close=")">
#{id} #{id}
</foreach> </foreach>
</delete> </delete>
</mapper> </mapper>

View File

@@ -4,11 +4,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.zg.project.information.mapper.WarehouseInfoMapper"> <mapper namespace="com.zg.project.information.mapper.WarehouseInfoMapper">
<resultMap type="WarehouseInfo" id="WarehouseInfoResult"> <!-- ========= 映射 ========= -->
<resultMap id="WarehouseInfoResult" type="WarehouseInfo">
<result property="id" column="id"/> <result property="id" column="id"/>
<result property="warehouseCode" column="warehouse_code"/> <result property="warehouseCode" column="warehouse_code"/>
<result property="warehouseName" column="warehouse_name"/> <result property="warehouseName" column="warehouse_name"/>
<result property="address" column="address"/> <result property="address" column="address"/>
<!-- 新增:所属大仓 -->
<result property="parentWarehouseCode" column="parent_warehouse_code"/>
<result property="parentWarehouseName" column="parent_warehouse_name"/>
<result property="status" column="status"/> <result property="status" column="status"/>
<result property="sort" column="sort"/> <result property="sort" column="sort"/>
<result property="remark" column="remark"/> <result property="remark" column="remark"/>
@@ -16,44 +22,93 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="updatedAt" column="updated_at"/> <result property="updatedAt" column="updated_at"/>
</resultMap> </resultMap>
<!-- ========= 通用列 ========= -->
<sql id="selectWarehouseInfoVo"> <sql id="selectWarehouseInfoVo">
select id, warehouse_code, warehouse_name, address, status, sort, remark, created_at, updated_at from warehouse_info SELECT
id,
warehouse_code,
warehouse_name,
address,
parent_warehouse_code,
parent_warehouse_name,
status,
sort,
remark,
created_at,
updated_at
FROM warehouse_info
</sql> </sql>
<!-- ========= 列表查询 ========= -->
<select id="selectWarehouseInfoList" parameterType="WarehouseInfo" resultMap="WarehouseInfoResult"> <select id="selectWarehouseInfoList" parameterType="WarehouseInfo" resultMap="WarehouseInfoResult">
<include refid="selectWarehouseInfoVo"/> <include refid="selectWarehouseInfoVo"/>
<where> <where>
<if test="warehouseCode != null and warehouseCode != ''"> and warehouse_code = #{warehouseCode}</if> <if test="warehouseCode != null and warehouseCode != ''">
<if test="warehouseName != null and warehouseName != ''"> and warehouse_name like concat('%', #{warehouseName}, '%')</if> AND warehouse_code = #{warehouseCode}
<if test="address != null and address != ''"> and address = #{address}</if> </if>
<if test="status != null "> and status = #{status}</if> <if test="warehouseName != null and warehouseName != ''">
<if test="sort != null "> and sort = #{sort}</if> AND warehouse_name LIKE concat('%', #{warehouseName}, '%')
<if test="createdAt != null "> and created_at = #{createdAt}</if> </if>
<if test="updatedAt != null "> and updated_at = #{updatedAt}</if> <if test="address != null and address != ''">
AND address = #{address}
</if>
<!-- 新增:按所属大仓筛选 -->
<if test="parentWarehouseCode != null and parentWarehouseCode != ''">
AND parent_warehouse_code = #{parentWarehouseCode}
</if>
<if test="parentWarehouseName != null and parentWarehouseName != ''">
AND parent_warehouse_name LIKE concat('%', #{parentWarehouseName}, '%')
</if>
<if test="status != null">
AND status = #{status}
</if>
<if test="sort != null">
AND sort = #{sort}
</if>
<if test="createdAt != null">
AND created_at = #{createdAt}
</if>
<if test="updatedAt != null">
AND updated_at = #{updatedAt}
</if>
</where> </where>
</select> </select>
<!-- ========= 主键查询 ========= -->
<select id="selectWarehouseInfoById" parameterType="Long" resultMap="WarehouseInfoResult"> <select id="selectWarehouseInfoById" parameterType="Long" resultMap="WarehouseInfoResult">
<include refid="selectWarehouseInfoVo"/> <include refid="selectWarehouseInfoVo"/>
where id = #{id} WHERE id = #{id}
</select> </select>
<!-- ========= 新增 ========= -->
<insert id="insertWarehouseInfo" parameterType="WarehouseInfo" useGeneratedKeys="true" keyProperty="id"> <insert id="insertWarehouseInfo" parameterType="WarehouseInfo" useGeneratedKeys="true" keyProperty="id">
insert into warehouse_info INSERT INTO warehouse_info
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">
<if test="warehouseCode != null and warehouseCode != ''">warehouse_code,</if> <if test="warehouseCode != null and warehouseCode != ''">warehouse_code,</if>
<if test="warehouseName != null and warehouseName != ''">warehouse_name,</if> <if test="warehouseName != null and warehouseName != ''">warehouse_name,</if>
<if test="address != null">address,</if> <if test="address != null">address,</if>
<!-- 新增:所属大仓 -->
<if test="parentWarehouseCode != null and parentWarehouseCode != ''">parent_warehouse_code,</if>
<if test="parentWarehouseName != null and parentWarehouseName != ''">parent_warehouse_name,</if>
<if test="status != null">status,</if> <if test="status != null">status,</if>
<if test="sort != null">sort,</if> <if test="sort != null">sort,</if>
<if test="remark != null">remark,</if> <if test="remark != null">remark,</if>
<if test="createdAt != null">created_at,</if> <if test="createdAt != null">created_at,</if>
<if test="updatedAt != null">updated_at,</if> <if test="updatedAt != null">updated_at,</if>
</trim> </trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="VALUES (" suffix=")" suffixOverrides=",">
<if test="warehouseCode != null and warehouseCode != ''">#{warehouseCode},</if> <if test="warehouseCode != null and warehouseCode != ''">#{warehouseCode},</if>
<if test="warehouseName != null and warehouseName != ''">#{warehouseName},</if> <if test="warehouseName != null and warehouseName != ''">#{warehouseName},</if>
<if test="address != null">#{address},</if> <if test="address != null">#{address},</if>
<!-- 新增:所属大仓 -->
<if test="parentWarehouseCode != null and parentWarehouseCode != ''">#{parentWarehouseCode},</if>
<if test="parentWarehouseName != null and parentWarehouseName != ''">#{parentWarehouseName},</if>
<if test="status != null">#{status},</if> <if test="status != null">#{status},</if>
<if test="sort != null">#{sort},</if> <if test="sort != null">#{sort},</if>
<if test="remark != null">#{remark},</if> <if test="remark != null">#{remark},</if>
@@ -62,27 +117,34 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</trim> </trim>
</insert> </insert>
<!-- ========= 更新 ========= -->
<update id="updateWarehouseInfo" parameterType="WarehouseInfo"> <update id="updateWarehouseInfo" parameterType="WarehouseInfo">
update warehouse_info UPDATE warehouse_info
<trim prefix="SET" suffixOverrides=","> <trim prefix="SET" suffixOverrides=",">
<if test="warehouseCode != null and warehouseCode != ''">warehouse_code = #{warehouseCode},</if> <if test="warehouseCode != null and warehouseCode != ''">warehouse_code = #{warehouseCode},</if>
<if test="warehouseName != null and warehouseName != ''">warehouse_name = #{warehouseName},</if> <if test="warehouseName != null and warehouseName != ''">warehouse_name = #{warehouseName},</if>
<if test="address != null">address = #{address},</if> <if test="address != null">address = #{address},</if>
<!-- 新增:所属大仓 -->
<if test="parentWarehouseCode != null and parentWarehouseCode != ''">parent_warehouse_code = #{parentWarehouseCode},</if>
<if test="parentWarehouseName != null and parentWarehouseName != ''">parent_warehouse_name = #{parentWarehouseName},</if>
<if test="status != null">status = #{status},</if> <if test="status != null">status = #{status},</if>
<if test="sort != null">sort = #{sort},</if> <if test="sort != null">sort = #{sort},</if>
<if test="remark != null">remark = #{remark},</if> <if test="remark != null">remark = #{remark},</if>
<if test="createdAt != null">created_at = #{createdAt},</if> <if test="createdAt != null">created_at = #{createdAt},</if>
<if test="updatedAt != null">updated_at = #{updatedAt},</if> <if test="updatedAt != null">updated_at = #{updatedAt},</if>
</trim> </trim>
where id = #{id} WHERE id = #{id}
</update> </update>
<!-- ========= 删除 ========= -->
<delete id="deleteWarehouseInfoById" parameterType="Long"> <delete id="deleteWarehouseInfoById" parameterType="Long">
delete from warehouse_info where id = #{id} DELETE FROM warehouse_info WHERE id = #{id}
</delete> </delete>
<delete id="deleteWarehouseInfoByIds" parameterType="String"> <delete id="deleteWarehouseInfoByIds" parameterType="String">
delete from warehouse_info where id in DELETE FROM warehouse_info WHERE id IN
<foreach item="id" collection="array" open="(" separator="," close=")"> <foreach item="id" collection="array" open="(" separator="," close=")">
#{id} #{id}
</foreach> </foreach>