修正算法BUG

This commit is contained in:
刘名喜 2024-12-18 11:24:38 +08:00
parent 43bb62dbdc
commit a17bd18444
2 changed files with 327 additions and 143 deletions

View File

@ -165,7 +165,7 @@ public class WmStorageLocationServiceImpl implements IWmStorageLocationService {
// 获取库位列表 // 获取库位列表
WmStorageArea wmStorageAreaQuery = new WmStorageArea(); WmStorageArea wmStorageAreaQuery = new WmStorageArea();
wmStorageAreaQuery.setLocationId(wmStorageLocationByCode.getLocationId()); wmStorageAreaQuery.setLocationId(wmStorageLocationByCode.getLocationId());
if (isBig) wmStorageAreaQuery.setAttr3(1L); wmStorageAreaQuery.setAttr3(isBig ? 1L : 0L);
List<WmStorageArea> wmStorageAreaList = this.wmStorageAreaMapper.selectWmStorageAreaList(wmStorageAreaQuery).stream() List<WmStorageArea> wmStorageAreaList = this.wmStorageAreaMapper.selectWmStorageAreaList(wmStorageAreaQuery).stream()
// 过滤掉全部存在物品的库位 // 过滤掉全部存在物品的库位
.filter(it -> !selectNotEmptyAreaCodeList.contains(it.getAreaCode())) .filter(it -> !selectNotEmptyAreaCodeList.contains(it.getAreaCode()))

View File

@ -1,190 +1,373 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper <!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" 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.ktg.mes.wm.mapper.WmStorageAreaMapper"> <mapper namespace="com.ktg.mes.wm.mapper.WmStorageAreaMapper">
<resultMap type="WmStorageArea" id="WmStorageAreaResult"> <resultMap type="WmStorageArea" id="WmStorageAreaResult">
<result property="areaId" column="area_id" /> <result property="areaId" column="area_id"/>
<result property="areaCode" column="area_code" /> <result property="areaCode" column="area_code"/>
<result property="areaName" column="area_name" /> <result property="areaName" column="area_name"/>
<result property="locationId" column="location_id" /> <result property="locationId" column="location_id"/>
<result property="area" column="area" /> <result property="area" column="area"/>
<result property="maxLoa" column="max_loa" /> <result property="maxLoa" column="max_loa"/>
<result property="positionX" column="position_x" /> <result property="positionX" column="position_x"/>
<result property="positionY" column="position_y" /> <result property="positionY" column="position_y"/>
<result property="positionZ" column="position_z" /> <result property="positionZ" column="position_z"/>
<result property="enableFlag" column="enable_flag" /> <result property="enableFlag" column="enable_flag"/>
<result property="frozenFlag" column="frozen_flag" /> <result property="frozenFlag" column="frozen_flag"/>
<result property="remark" column="remark" /> <result property="remark" column="remark"/>
<result property="attr1" column="attr1" /> <result property="attr1" column="attr1"/>
<result property="attr2" column="attr2" /> <result property="attr2" column="attr2"/>
<result property="attr3" column="attr3" /> <result property="attr3" column="attr3"/>
<result property="attr4" column="attr4" /> <result property="attr4" column="attr4"/>
<result property="createBy" column="create_by" /> <result property="createBy" column="create_by"/>
<result property="createTime" column="create_time" /> <result property="createTime" column="create_time"/>
<result property="updateBy" column="update_by" /> <result property="updateBy" column="update_by"/>
<result property="updateTime" column="update_time" /> <result property="updateTime" column="update_time"/>
</resultMap> </resultMap>
<resultMap type="AreaVo" id="WmStorageAreaVoResult"> <resultMap type="AreaVo" id="WmStorageAreaVoResult">
<result property="areaId" column="area_id" /> <result property="areaId" column="area_id"/>
<result property="areaCode" column="area_code" /> <result property="areaCode" column="area_code"/>
<result property="locationName" column="location_name" /> <result property="locationName" column="location_name"/>
<result property="areaName" column="area_name" /> <result property="areaName" column="area_name"/>
<result property="locationId" column="location_id" /> <result property="locationId" column="location_id"/>
<result property="area" column="area" /> <result property="area" column="area"/>
<result property="maxLoa" column="max_loa" /> <result property="maxLoa" column="max_loa"/>
<result property="positionX" column="position_x" /> <result property="positionX" column="position_x"/>
<result property="positionY" column="position_y" /> <result property="positionY" column="position_y"/>
<result property="positionZ" column="position_z" /> <result property="positionZ" column="position_z"/>
<result property="enableFlag" column="enable_flag" /> <result property="enableFlag" column="enable_flag"/>
<result property="frozenFlag" column="frozen_flag" /> <result property="frozenFlag" column="frozen_flag"/>
<result property="remark" column="remark" /> <result property="remark" column="remark"/>
<result property="attr1" column="attr1" /> <result property="attr1" column="attr1"/>
<result property="attr2" column="attr2" /> <result property="attr2" column="attr2"/>
<result property="attr3" column="attr3" /> <result property="attr3" column="attr3"/>
<result property="attr4" column="attr4" /> <result property="attr4" column="attr4"/>
<result property="createBy" column="create_by" /> <result property="createBy" column="create_by"/>
<result property="createTime" column="create_time" /> <result property="createTime" column="create_time"/>
<result property="updateBy" column="update_by" /> <result property="updateBy" column="update_by"/>
<result property="updateTime" column="update_time" /> <result property="updateTime" column="update_time"/>
</resultMap> </resultMap>
<sql id="selectWmStorageAreaVo"> <sql id="selectWmStorageAreaVo">
select area_id, area_code, area_name, location_id, area, max_loa, position_x, position_y, position_z, enable_flag, frozen_flag, remark, attr1, attr2, attr3, attr4, create_by, create_time, update_by, update_time from wm_storage_area select area_id,
area_code,
area_name,
location_id,
area,
max_loa,
position_x,
position_y,
position_z,
enable_flag,
frozen_flag,
remark,
attr1,
attr2,
attr3,
attr4,
create_by,
create_time,
update_by,
update_time
from wm_storage_area
</sql> </sql>
<select id="selectWmStorageAreaList" parameterType="WmStorageArea" resultMap="WmStorageAreaResult"> <select id="selectWmStorageAreaList" parameterType="WmStorageArea" resultMap="WmStorageAreaResult">
<include refid="selectWmStorageAreaVo"/> <include refid="selectWmStorageAreaVo"/>
<where> <where>
<if test="areaCode != null and areaCode != ''"> and area_code like concat('%', #{areaCode}, '%') </if> <if test="areaCode != null and areaCode != ''">
<if test="areaName != null and areaName != ''"> and area_name like concat('%', #{areaName}, '%')</if> and area_code like concat('%', #{areaCode}, '%')
<if test="locationId != null "> and location_id like concat('%', #{locationId}, '%') </if> </if>
<if test="area != null "> and like concat('%',#{area}, '%') </if> <if test="areaName != null and areaName != ''">
<if test="maxLoa != null "> and max_loa = #{maxLoa}</if> and area_name like concat('%', #{areaName}, '%')
<if test="positionX != null and positionX !=0 "> and position_x = #{positionX}</if> </if>
<if test="positionY != null and positionY !=0"> and position_y = #{positionY}</if> <if test="locationId != null">
<if test="positionZ != null and positionZ !=0"> and position_z = #{positionZ}</if> and location_id like concat('%', #{locationId}, '%')
<if test="enableFlag != null and enableFlag != ''"> and enable_flag = #{enableFlag}</if> </if>
and IS_DELETE = 0 <if test="area != null">
</where> and like concat('%', #{area}, '%')
ORDER BY AREA_CODE ASC </if>
</select> <if test="maxLoa != null">
and max_loa = #{maxLoa}
</if>
<if test="attr3 != null">
and attr3 = #{attr3}
</if>
<if test="positionX != null and positionX != 0">
and position_x = #{positionX}
</if>
<if test="positionY != null and positionY != 0">
and position_y = #{positionY}
</if>
<if test="positionZ != null and positionZ != 0">
and position_z = #{positionZ}
</if>
<if test="enableFlag != null and enableFlag != ''">
and enable_flag = #{enableFlag}
</if>
and IS_DELETE = 0
</where>
ORDER BY AREA_CODE ASC
</select>
<select id="selectWmStorageAreaListVo" parameterType="AreaVo" resultMap="WmStorageAreaVoResult"> <select id="selectWmStorageAreaListVo" parameterType="AreaVo" resultMap="WmStorageAreaVoResult">
select w.*,l.location_name from wm_storage_area w join wm_storage_location l on w.location_id = l.location_id select w.*, l.location_name
from wm_storage_area w
join wm_storage_location l on w.location_id = l.location_id
<where> <where>
<if test="areaCode != null and areaCode != ''"> and w.area_code like concat('%', #{areaCode}, '%') </if> <if test="areaCode != null and areaCode != ''">
<if test="areaName != null and areaName != ''"> and w.area_name like concat('%', #{areaName}, '%')</if> and w.area_code like concat('%', #{areaCode}, '%')
<if test="locationId != null "> and w.location_id like concat('%', #{locationId}, '%') </if> </if>
<if test="area != null "> and like concat('%',#{area}, '%') </if> <if test="areaName != null and areaName != ''">
<if test="maxLoa != null "> and max_loa = #{maxLoa}</if> and w.area_name like concat('%', #{areaName}, '%')
<if test="positionX != null and positionX !=0 "> and w.position_x = #{positionX}</if> </if>
<if test="positionY != null and positionY !=0"> and w.position_y = #{positionY}</if> <if test="locationId != null">
<if test="positionZ != null and positionZ !=0"> and w.position_z = #{positionZ}</if> and w.location_id like concat('%', #{locationId}, '%')
<if test="enableFlag != null and enableFlag != ''"> and w.enable_flag = #{enableFlag}</if> </if>
<if test="area != null">
and like concat('%', #{area}, '%')
</if>
<if test="maxLoa != null">
and max_loa = #{maxLoa}
</if>
<if test="positionX != null and positionX != 0">
and w.position_x = #{positionX}
</if>
<if test="positionY != null and positionY != 0">
and w.position_y = #{positionY}
</if>
<if test="positionZ != null and positionZ != 0">
and w.position_z = #{positionZ}
</if>
<if test="enableFlag != null and enableFlag != ''">
and w.enable_flag = #{enableFlag}
</if>
and w.IS_DELETE = 0 and w.IS_DELETE = 0
</where> </where>
</select> </select>
<select id="selectWmStorageAreaByAreaId" parameterType="Long" resultMap="WmStorageAreaResult"> <select id="selectWmStorageAreaByAreaId" parameterType="Long" resultMap="WmStorageAreaResult">
<include refid="selectWmStorageAreaVo"/> <include refid="selectWmStorageAreaVo"/>
where area_id = #{areaId} and IS_DELETE = 0 where area_id = #{areaId}
and IS_DELETE = 0
</select> </select>
<select id="selectWmStorageAreaByAreaIdVo" parameterType="Long" resultMap="WmStorageAreaVoResult"> <select id="selectWmStorageAreaByAreaIdVo" parameterType="Long" resultMap="WmStorageAreaVoResult">
select w.*,l.location_name from wm_storage_area w join wm_storage_location l on w.location_id = l.location_id select w.*, l.location_name
where area_id = #{areaId} and w.IS_DELETE = 0 from wm_storage_area w
join wm_storage_location l on w.location_id = l.location_id
where area_id = #{areaId}
and w.IS_DELETE = 0
</select> </select>
<select id="selectWmStorageAreaByAreaCode" parameterType="String" resultMap="WmStorageAreaResult"> <select id="selectWmStorageAreaByAreaCode" parameterType="String" resultMap="WmStorageAreaResult">
<include refid="selectWmStorageAreaVo"/> <include refid="selectWmStorageAreaVo"/>
where area_code = #{areaCode} and IS_DELETE = 0 where area_code = #{areaCode}
and IS_DELETE = 0
</select> </select>
<select id="getAll" resultType="com.ktg.mes.wm.domain.WmStorageArea" resultMap="WmStorageAreaResult"> <select id="getAll" resultType="com.ktg.mes.wm.domain.WmStorageArea" resultMap="WmStorageAreaResult">
SELECT * FROM wm_storage_area where IS_DELETE = 0 SELECT *
FROM wm_storage_area
where IS_DELETE = 0
</select> </select>
<insert id="insertWmStorageArea" parameterType="WmStorageArea" useGeneratedKeys="true" keyProperty="areaId"> <insert id="insertWmStorageArea" parameterType="WmStorageArea" useGeneratedKeys="true" keyProperty="areaId">
insert into wm_storage_area insert into wm_storage_area
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">
<if test="areaCode != null and areaCode != ''">area_code,</if> <if test="areaCode != null and areaCode != ''">
<if test="areaName != null and areaName != ''">area_name,</if> area_code,
<if test="locationId != null">location_id,</if> </if>
<if test="area != null">area,</if> <if test="areaName != null and areaName != ''">
<if test="maxLoa != null">max_loa,</if> area_name,
<if test="positionX != null">position_x,</if> </if>
<if test="positionY != null">position_y,</if> <if test="locationId != null">
<if test="positionZ != null">position_z,</if> location_id,
<if test="enableFlag != null">enable_flag,</if> </if>
<if test="frozenFlag != null">frozen_flag,</if> <if test="area != null">
<if test="remark != null">remark,</if> area,
<if test="attr1 != null">attr1,</if> </if>
<if test="attr2 != null">attr2,</if> <if test="maxLoa != null">
<if test="attr3 != null">attr3,</if> max_loa,
<if test="attr4 != null">attr4,</if> </if>
<if test="createBy != null">create_by,</if> <if test="positionX != null">
<if test="createTime != null">create_time,</if> position_x,
<if test="updateBy != null">update_by,</if> </if>
<if test="updateTime != null">update_time,</if> <if test="positionY != null">
</trim> position_y,
</if>
<if test="positionZ != null">
position_z,
</if>
<if test="enableFlag != null">
enable_flag,
</if>
<if test="frozenFlag != null">
frozen_flag,
</if>
<if test="remark != null">
remark,
</if>
<if test="attr1 != null">
attr1,
</if>
<if test="attr2 != null">
attr2,
</if>
<if test="attr3 != null">
attr3,
</if>
<if test="attr4 != null">
attr4,
</if>
<if test="createBy != null">
create_by,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="updateBy != null">
update_by,
</if>
<if test="updateTime != null">
update_time,
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="areaCode != null and areaCode != ''">#{areaCode},</if> <if test="areaCode != null and areaCode != ''">
<if test="areaName != null and areaName != ''">#{areaName},</if> #{areaCode},
<if test="locationId != null">#{locationId},</if> </if>
<if test="area != null">#{area},</if> <if test="areaName != null and areaName != ''">
<if test="maxLoa != null">#{maxLoa},</if> #{areaName},
<if test="positionX != null">#{positionX},</if> </if>
<if test="positionY != null">#{positionY},</if> <if test="locationId != null">
<if test="positionZ != null">#{positionZ},</if> #{locationId},
<if test="enableFlag != null">#{enableFlag},</if> </if>
<if test="frozenFlag != null">#{frozenFlag},</if> <if test="area != null">
<if test="remark != null">#{remark},</if> #{area},
<if test="attr1 != null">#{attr1},</if> </if>
<if test="attr2 != null">#{attr2},</if> <if test="maxLoa != null">
<if test="attr3 != null">#{attr3},</if> #{maxLoa},
<if test="attr4 != null">#{attr4},</if> </if>
<if test="createBy != null">#{createBy},</if> <if test="positionX != null">
<if test="createTime != null">#{createTime},</if> #{positionX},
<if test="updateBy != null">#{updateBy},</if> </if>
<if test="updateTime != null">#{updateTime},</if> <if test="positionY != null">
</trim> #{positionY},
</if>
<if test="positionZ != null">
#{positionZ},
</if>
<if test="enableFlag != null">
#{enableFlag},
</if>
<if test="frozenFlag != null">
#{frozenFlag},
</if>
<if test="remark != null">
#{remark},
</if>
<if test="attr1 != null">
#{attr1},
</if>
<if test="attr2 != null">
#{attr2},
</if>
<if test="attr3 != null">
#{attr3},
</if>
<if test="attr4 != null">
#{attr4},
</if>
<if test="createBy != null">
#{createBy},
</if>
<if test="createTime != null">
#{createTime},
</if>
<if test="updateBy != null">
#{updateBy},
</if>
<if test="updateTime != null">
#{updateTime},
</if>
</trim>
</insert> </insert>
<update id="updateWmStorageArea" parameterType="WmStorageArea"> <update id="updateWmStorageArea" parameterType="WmStorageArea">
update wm_storage_area update wm_storage_area
<trim prefix="SET" suffixOverrides=","> <trim prefix="SET" suffixOverrides=",">
<if test="areaCode != null and areaCode != ''">area_code = #{areaCode},</if> <if test="areaCode != null and areaCode != ''">
<if test="areaName != null and areaName != ''">area_name = #{areaName},</if> area_code = #{areaCode},
<if test="locationId != null">location_id = #{locationId},</if> </if>
<if test="area != null">area = #{area},</if> <if test="areaName != null and areaName != ''">
<if test="maxLoa != null">max_loa = #{maxLoa},</if> area_name = #{areaName},
<if test="positionX != null">position_x = #{positionX},</if> </if>
<if test="positionY != null">position_y = #{positionY},</if> <if test="locationId != null">
<if test="positionZ != null">position_z = #{positionZ},</if> location_id = #{locationId},
<if test="enableFlag != null">enable_flag = #{enableFlag},</if> </if>
<if test="frozenFlag != null">frozen_flag = #{frozenFlag},</if> <if test="area != null">
<if test="remark != null">remark = #{remark},</if> area = #{area},
<if test="attr1 != null">attr1 = #{attr1},</if> </if>
<if test="attr2 != null">attr2 = #{attr2},</if> <if test="maxLoa != null">
<if test="attr3 != null">attr3 = #{attr3},</if> max_loa = #{maxLoa},
<if test="attr4 != null">attr4 = #{attr4},</if> </if>
<if test="createBy != null">create_by = #{createBy},</if> <if test="positionX != null">
<if test="createTime != null">create_time = #{createTime},</if> position_x = #{positionX},
<if test="updateBy != null">update_by = #{updateBy},</if> </if>
<if test="updateTime != null">update_time = #{updateTime},</if> <if test="positionY != null">
position_y = #{positionY},
</if>
<if test="positionZ != null">
position_z = #{positionZ},
</if>
<if test="enableFlag != null">
enable_flag = #{enableFlag},
</if>
<if test="frozenFlag != null">
frozen_flag = #{frozenFlag},
</if>
<if test="remark != null">
remark = #{remark},
</if>
<if test="attr1 != null">
attr1 = #{attr1},
</if>
<if test="attr2 != null">
attr2 = #{attr2},
</if>
<if test="attr3 != null">
attr3 = #{attr3},
</if>
<if test="attr4 != null">
attr4 = #{attr4},
</if>
<if test="createBy != null">
create_by = #{createBy},
</if>
<if test="createTime != null">
create_time = #{createTime},
</if>
<if test="updateBy != null">
update_by = #{updateBy},
</if>
<if test="updateTime != null">
update_time = #{updateTime},
</if>
</trim> </trim>
where area_id = #{areaId} where area_id = #{areaId}
</update> </update>
<update id="deleteWmStorageAreaByAreaId" parameterType="Long"> <update id="deleteWmStorageAreaByAreaId" parameterType="Long">
update wm_storage_area set IS_DELETE =1 update wm_storage_area
set IS_DELETE =1
where area_id = #{areaId} where area_id = #{areaId}
</update> </update>
<update id="deleteWmStorageAreaByAreaIds" parameterType="String"> <update id="deleteWmStorageAreaByAreaIds" parameterType="String">
update wm_storage_area set IS_DELETE = 1 update wm_storage_area
set IS_DELETE = 1
where area_id in where area_id in
<foreach item="areaId" collection="array" open="(" separator="," close=")"> <foreach item="areaId" collection="array" open="(" separator="," close=")">
#{areaId} #{areaId}
@ -192,13 +375,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</update> </update>
<update id="deleteByWarehouseId" parameterType="Long"> <update id="deleteByWarehouseId" parameterType="Long">
update wm_storage_area set IS_DELETE =1 update wm_storage_area
where location_id in ( select location_id from wm_storage_location where warehouse_id = #{warehouseId}) set IS_DELETE =1
where location_id in (select location_id from wm_storage_location where warehouse_id = #{warehouseId})
</update> </update>
<update id="deleteByLocationId" parameterType="Long"> <update id="deleteByLocationId" parameterType="Long">
update wm_storage_area set IS_DELETE = 1 update wm_storage_area
set IS_DELETE = 1
where location_id = #{locationId} where location_id = #{locationId}
</update> </update>
</mapper> </mapper>