| <?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.zy.acs.manager.manager.mapper.LocMapper"> | 
|   | 
|     <!-- 关联查询sql --> | 
|     <sql id="selectSql"> | 
|         SELECT a.* | 
|         FROM man_loc a | 
|         <where> | 
|             AND a.deleted = 0 | 
|             <if test="param.id != null"> | 
|                 AND a.id = #{param.id} | 
|             </if> | 
|             <if test="param.locNo != null"> | 
|                 AND a.loc_no = #{param.locNo} | 
|             </if> | 
|             <if test="param.row != null"> | 
|                 AND a.row = #{param.row} | 
|             </if> | 
|             <if test="param.bay != null"> | 
|                 AND a.bay = #{param.bay} | 
|             </if> | 
|             <if test="param.lev != null"> | 
|                 AND a.lev = #{param.lev} | 
|             </if> | 
|             <if test="param.status != null"> | 
|                 AND a.status = #{param.status} | 
|             </if> | 
|             <if test="param.uuid != null"> | 
|                 AND a.id = #{param.uuid} | 
|             </if> | 
|             <if test="param.locType != null"> | 
|                 AND a.loc_type = #{param.locType} | 
|             </if> | 
|             <if test="param.locSts != null"> | 
|                 AND a.loc_sts = #{param.locSts} | 
|             </if> | 
|             <if test="param.keywords != null"> | 
|                 AND ( | 
|                 a.memo LIKE CONCAT('%', #{param.keywords}, '%') | 
|                 OR a.memo LIKE CONCAT('%', #{param.keywords}, '%') | 
|                 ) | 
|             </if> | 
|         </where> | 
|     </sql> | 
|   | 
|     <select id="selectCountGroupByLocSts" resultType="java.util.Map"> | 
|         SELECT | 
|             mls.uuid AS sts, | 
|             mls.name AS name, | 
|             COUNT(ml.loc_sts) AS count | 
|         FROM man_loc_sts mls | 
|         LEFT JOIN man_loc ml ON ml.loc_sts = mls.id | 
|         GROUP BY mls.id, mls.uuid, mls.name | 
|     </select> | 
|   | 
|     <select id="selectDigitalLocWhichNeedShow" resultType="java.util.Map"> | 
|         SELECT | 
|         DISTINCT ml.loc_no AS locNo, | 
|         ml.row, | 
|         ml.bay, | 
|         ml.lev, | 
|         ml.loc_sts AS locSts | 
|         FROM man_loc ml | 
|         LEFT JOIN man_task mt ON mt.dest_loc = ml.id OR mt.ori_loc = ml.id | 
|         LEFT JOIN man_action ma ON ma.task_id = mt.id | 
|         WHERE | 
|         ( | 
|             ml.loc_sts = (SELECT id FROM man_loc_sts WHERE UUID = 'STOCK') | 
|         ) | 
|         OR | 
|         ( | 
|             ml.loc_sts = (SELECT id FROM man_loc_sts WHERE UUID = 'PAKIN') | 
|             AND mt.task_sts IN | 
|             ( | 
|                 (SELECT id FROM man_task_sts WHERE UUID = 'INIT'), | 
|                 (SELECT id FROM man_task_sts WHERE UUID = 'WAITING'), | 
|                 (SELECT id FROM man_task_sts WHERE UUID = 'ASSIGN'), | 
|                 (SELECT id FROM man_task_sts WHERE UUID = 'PROGRESS') | 
|             ) | 
|             AND ma.action_type = (SELECT id FROM man_action_type WHERE UUID = 'ReadyReleaseToShelvesLoc') | 
|             AND ma.action_sts = (SELECT id FROM man_action_sts WHERE UUID = 'FINISH') | 
|         ) | 
|         OR | 
|         ( | 
|             ml.loc_sts = (SELECT id FROM man_loc_sts WHERE UUID = 'PAKOUT') | 
|             AND mt.task_sts IN ( | 
|                 (SELECT id FROM man_task_sts WHERE UUID = 'INIT'), | 
|                 (SELECT id FROM man_task_sts WHERE UUID = 'WAITING'), | 
|                 (SELECT id FROM man_task_sts WHERE UUID = 'ASSIGN'), | 
|                 (SELECT id FROM man_task_sts WHERE UUID = 'PROGRESS') | 
|             ) | 
|             AND ma.action_type = (SELECT id FROM man_action_type WHERE UUID = 'ReadyTakeFromShelvesLoc') | 
|             AND ma.action_sts != (SELECT id FROM man_action_sts WHERE UUID = 'FINISH') | 
|         ) | 
|     </select> | 
|   | 
| </mapper> |