LocationMapper.xml 9.24 KB
<?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">
<mapper namespace="com.huaheng.pc.general.location.mapper.LocationMapper">


    <select id="getEmptyContainerInLocation" resultType="com.huaheng.pc.general.location.domain.Location">
        SELECT id, code, warehouseId, warehouseCode, row, line, layer, rowIndex, roadway, type, containerId, containerCode, zoneId, zoneCode, status, lastCycleCountDate, created, createdBy, lastUpdated, lastUpdatedBy, enable, deleted, userDef1, userDef2, userDef3, userDef4, userDef5
        FROM location t
        <where>
            t.warehouseId = #{warehouseId} AND t.status='empty' AND t.containerCode !='' AND t.containerCode is not NULL
            AND t.`code` NOT in (SELECT b.locationCode FROM inventory b WHERE b.warehouseId = #{warehouseId} )
            <if test="containerCode != null and containerCode !=''">
                <bind name="temp1" value="'%' + containerCode + '%'" />
                and t.containerCode like #{temp1}
            </if>
            <if test="locationCode != null and locationCode !=''">
                <bind name="temp2" value="'%' + locationCode + '%'" />
                and t.`code` like #{temp2}
            </if>
        </where>
    </select>

	<update id="updateStatus">
        UPDATE location set `status`=#{status} WHERE warehouseCode=#{warehouseCode} AND `code`=#{code}
    </update>

    <update id="updateContainerCodeAndStatus">
        UPDATE location set `status`=#{status},containerCode=#{containerCode} WHERE warehouseCode=#{warehouseCode} AND `code`=#{locationCode}
    </update>

    <update id="updateContainerCode">
        UPDATE location set containerCode=#{containerCode} WHERE warehouseCode=#{warehouseCode} AND `code`=#{locationCode}
    </update>

    <select id="getEmptyLocation" resultType="com.huaheng.pc.general.location.domain.Location">
        select * from location l
        <where>
            l.containerCode = "" AND l.warehouseId = #{warehouseId} AND l.deleted = #{deleted} AND l.status = #{status}
            <if test="locationCode != null and locationCode !=''">
                <bind name="temp2" value="'%' + locationCode + '%'" />
                and l.`code` like #{temp2}
            </if>
        </where>
    </select>
    <select id="getAllLocation" resultType="com.huaheng.pc.general.location.domain.Location">
        select  max(row) as row,max(line) as line,max(layer) as layer from location l where l.warehouseCode= #{warehouseCode} AND l.type=#{type}
    </select>

	<select id="selectSSPLocation" resultType="com.huaheng.pc.general.location.domain.Location">
    SELECT id, code, warehouseId, warehouseCode, row, line, layer, rowIndex, roadway, type, containerId, containerCode, zoneId, zoneCode, status, lastCycleCountDate, created, createdBy, lastUpdated, lastUpdatedBy, enable, deleted, userDef1, userDef2, userDef3, userDef4, userDef5
     FROM `location`  WHERE zoneCode = 'QG' AND `status` = 'empty'  ORDER BY `row` LIMIT 1
    </select>

    <select id="getAllLocationCode" resultType="java.lang.String">
        SELECT  code
        FROM location
        <where>
            <if test="id != null">
                AND id = #{id}
            </if>
            <if test="code != null">
                AND code = #{code}
            </if>
            <if test="warehouseId != null">
                AND warehouseId = #{warehouseId}
            </if>
            <if test="warehouseCode != null">
                AND warehouseCode = #{warehouseCode}
            </if>
            <if test="row != null">
                AND row = #{row}
            </if>
            <if test="line != null">
                AND line = #{line}
            </if>
            <if test="layer != null">
                AND layer = #{layer}
            </if>
            <if test="grid != null">
                AND grid = #{grid}
            </if>
            <if test="rowIndex != null">
                AND rowIndex = #{rowIndex}
            </if>
            <if test="roadway != null">
                AND roadway = #{roadway}
            </if>
            <if test="type != null">
                AND type = #{type}
            </if>
            <if test="containerId != null">
                AND containerId = #{containerId}
            </if>
            <if test="containerCode != null">
                AND containerCode = #{containerCode}
            </if>
            <if test="zoneId != null">
                AND zoneId = #{zoneId}
            </if>
            <if test="zoneCode != null">
                AND zoneCode = #{zoneCode}
            </if>
            <if test="status != null">
                AND status = #{status}
            </if>
            <if test="lastCycleCountDate != null">
                AND lastCycleCountDate = #{lastCycleCountDate}
            </if>
            <if test="created != null">
                AND created = #{created}
            </if>
            <if test="createdBy != null">
                AND createdBy = #{createdBy}
            </if>
            <if test="lastUpdated != null">
                AND lastUpdated = #{lastUpdated}
            </if>
            <if test="lastUpdatedBy != null">
                AND lastUpdatedBy = #{lastUpdatedBy}
            </if>
            <if test="enable != null">
                AND enable = #{enable}
            </if>
            <if test="deleted != null">
                AND deleted = #{deleted}
            </if>
            <if test="userDef1 != null">
                AND userDef1 = #{userDef1}
            </if>
            <if test="userDef2 != null">
                AND userDef2 = #{userDef2}
            </if>
            <if test="userDef3 != null">
                AND userDef3 = #{userDef3}
            </if>
            <if test="userDef4 != null">
                AND userDef4 = #{userDef4}
            </if>
            <if test="userDef5 != null">
                AND userDef5 = #{userDef5}
            </if>
        </where>
    </select>

    <select id="selectAddress" resultType="com.huaheng.pc.general.location.domain.Location">
      SELECT max(row)  AS row,max(line)  AS line FROM location where type='A' and warehouseCode=#{warehouseCode}
    </select>

    <!--<select id="selectIntY" resultType="java.util.HashMap">-->
      <!--SELECT distinct(line) FROM location where type='A' group by line asc-->
    <!--</select>-->

    <select id="selectLocationPosition" resultType="com.huaheng.pc.general.location.domain.LocationPosition">
      SELECT intX,intY FROM location_position where locationCode=#{locationCode} and warehouseCode=#{warehouseCode}
    </select>

    <!--<select id="selectList" resultType="com.huaheng.pc.general.location.domain.LocationPosition">-->
      <!--SELECT locationCode FROM location_position where warehouseCode=#{warehouseCode} and intX=#{intX} and intY=#{intY}-->
    <!--</select>-->

    <update id="updateContainer">
        UPDATE location l
        inner join location_position p on l.code=p.locationCode
        inner join container c on substr(c.code,5,1)=substr(p.locationCode,9,1) and substr(c.code,6,1)=substr(p.locationCode,12,1) and c.warehouseCode=p.warehouseCode
        set l.containerCode=c.code where c.warehouseCode=#{container.warehouseCode} and c.type=#{container.type} and c.code like CONCAT(#{container.code},'%')
        and p.warehouseCode=#{locationPosition.warehouseCode} and p.intX=#{locationPosition.intX} and p.intY=#{locationPosition.intY}
    </update>

    <select id="selectEmptyAddress" resultType="com.huaheng.pc.general.location.domain.Location">
      SELECT DISTINCT l.row,l.line from location l
      inner join location_position i on i.warehouseCode=l.warehouseCode and l.code=i.locationCode
      inner join points p on i.warehouseCode=p.warehouseCode and i.intX=p.intX and i.intY=p.intY and p.isLocked=#{isLocked} and p.warehouseCode=#{warehouseCode}
    </select>

    <select id="getLocationProp"  resultType="java.util.LinkedHashMap">
      SELECT w.name warehouseName,ifnull(convert(a.num1/(b.num2+a.num1),decimal(15,2)),0) '有货',ifnull(convert(b.num2/(b.num2+a.num1),decimal(15,2)),0) '无货'  from warehouse w
      left join
      (SELECT count(1) num1,warehouseCode FROM location WHERE containerCode!='' GROUP BY warehouseCode) a on a.warehouseCode=w.code
      LEFT JOIN
      (SELECT count(1) num2,warehouseCode FROM location WHERE containerCode ='' GROUP BY warehouseCode) b on b.warehouseCode=w.code
    </select>
	<select id="getLocationCode" resultType="com.huaheng.pc.general.location.domain.Location">
    SELECT id, code, warehouseId, warehouseCode, row, line, layer, rowIndex, roadway, type, containerId, containerCode, zoneId, zoneCode, status, lastCycleCountDate, created, createdBy, lastUpdated, lastUpdatedBy, enable, deleted, userDef1, userDef2, userDef3, userDef4, userDef5
    FROM location WHERE code = #{locationCode}
    </select>
	 <select id="pickLocation" resultType="com.huaheng.pc.general.location.domain.Location">
        SELECT id, code, warehouseId, warehouseCode, row, line, layer, rowIndex, roadway, type, containerId, containerCode, zoneId, zoneCode, status, lastCycleCountDate, created, createdBy, lastUpdated, lastUpdatedBy, enable, deleted, userDef1, userDef2, userDef3, userDef4, userDef5
         FROM location
        WHERE containerCode != '' and status = "empty"
    </select>
</mapper>