<?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.chinaztt.mes.basic.mapper.LocationMapper">
|
|
<resultMap id="locationMap" type="com.chinaztt.mes.basic.entity.Location">
|
<id property="id" column="id"/>
|
<result property="factoryId" column="factory_id"/>
|
<result property="pType" column="p_type"/>
|
<result property="locNo" column="loc_no"/>
|
<result property="locName" column="loc_name"/>
|
<result property="locDesc" column="loc_desc"/>
|
<result property="locType" column="loc_type"/>
|
<result property="locAddr" column="loc_addr"/>
|
<result property="locMap" column="loc_map"/>
|
<result property="locStatus" column="loc_status"/>
|
<result property="locRemark" column="loc_remark"/>
|
<result property="createTime" column="create_time"/>
|
<result property="locGroup" column="loc_group"/>
|
<result property="factoryName" column="factory_name"/>
|
<result property="ifsLocation" column="ifs_location"/>
|
<result property="ifsLocationGroup" column="location_type_group"/>
|
<result property="transportLocationNo" column="transport_location_no"/>
|
</resultMap>
|
<resultMap id="locationMapDto" type="com.chinaztt.mes.basic.dto.LocationDTO">
|
<id property="id" column="id"/>
|
<result property="factoryId" column="factory_id"/>
|
<result property="pType" column="p_type"/>
|
<result property="locNo" column="loc_no"/>
|
<result property="locName" column="loc_name"/>
|
<result property="locDesc" column="loc_desc"/>
|
<result property="locType" column="loc_type"/>
|
<result property="locAddr" column="loc_addr"/>
|
<result property="locMap" column="loc_map"/>
|
<result property="locStatus" column="loc_status"/>
|
<result property="locRemark" column="loc_remark"/>
|
<result property="createTime" column="create_time"/>
|
<result property="locGroup" column="loc_group"/>
|
<result property="factoryName" column="factory_name"/>
|
<result property="disabled" column="disabled"/>
|
<result property="key" column="id"/>
|
<result property="label" column="loc_name"/>
|
<result property="value" column="id"/>
|
<result property="workstationId" column="workstation_id"/>
|
<result property="workstationName" column="workstation_name"/>
|
<result property="workstationNo" column="workstation_no"/>
|
<result property="partNo" column="part_no"/>
|
<result property="partName" column="part_name"/>
|
<result property="partBatchNo" column="part_batch_no"/>
|
<result property="ifsLocation" column="ifs_location"/>
|
<result property="ifsLocationGroup" column="location_type_group"/>
|
<result property="locationType" column="location_type"/>
|
<result property="transportLocationNo" column="transport_location_no"/>
|
</resultMap>
|
|
<select id="getLocationDtoPage" resultMap="locationMapDto">
|
select * from(<include refid="LocExt"/>) tempA
|
<if test="ew.emptyOfWhere == false">
|
${ew.customSqlSegment}
|
</if>
|
</select>
|
|
<select id="getLoc" resultMap="locationMap">
|
select * from(<include refid="Loc"/>) a
|
<if test="ew.emptyOfWhere == false">
|
<where>
|
${ew.SqlSegment}
|
</where>
|
</if>
|
</select>
|
|
<sql id="LocExt">
|
select
|
bf.factory_name,
|
bl."id",
|
bl.p_type,
|
bl.loc_no,
|
bl.loc_name,
|
bl.loc_desc,
|
bl.loc_type,
|
bl.loc_addr,
|
bl.loc_map,
|
bl.loc_status,
|
bl.loc_remark,
|
bl.create_time,
|
bl.loc_group,
|
bw.id workstation_id,
|
bw.workstation_no,
|
bwl.location_type
|
FROM basic_location bl
|
left join basic_factory bf on bf."id" = bl.factory_id
|
left join basic_workstation_location bwl on bwl.location_id = bl."id"
|
left join basic_workstation bw on bw.id = bwl.workstation_id
|
where bl.active = true
|
</sql>
|
|
<sql id="Loc">
|
select
|
bf.factory_name,
|
wl."id",
|
wl.p_type,
|
wl.loc_no,
|
wl.loc_name,
|
wl.loc_desc,
|
wl.loc_type,
|
wl.loc_addr,
|
wl.loc_map,
|
wl.loc_status,
|
wl.loc_remark,
|
wl.create_time,
|
wl.ifs_location,
|
wl.ifs_location_group,
|
wl.loc_group
|
FROM basic_location wl
|
left join basic_factory bf on wl.factory_id = bf."id"
|
where wl.active = true
|
</sql>
|
|
<update id="upLocationDate">
|
UPDATE basic_location
|
SET loc_no = null
|
where id in
|
<foreach item="item" index="index" collection="ids" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</update>
|
|
<select id="getNoWorkstationLocation" resultMap="locationMapDto">
|
SELECT FALSE disabled,
|
wl."id",
|
wl.loc_name
|
FROM
|
basic_location wl
|
WHERE
|
wl.active = TRUE
|
</select>
|
|
<select id="getPrepare" resultMap="locationMap">
|
SELECT wl.loc_name,wl.id,wl.loc_no
|
from basic_location wl
|
where wl.active = true
|
</select>
|
|
<select id="pdaList" resultType="com.alibaba.fastjson.JSONObject">
|
select distinct workstation_no "workstationNo",
|
workstation_name "workstationName",
|
loc_no "locNo",
|
loc_name "locName",
|
loc_type "locType"
|
from (
|
select bw.workstation_no,
|
bw."name" workstation_name,
|
bl.loc_no,
|
bl.loc_name,
|
sdi.label loc_type,
|
bp.part_no,
|
bp.part_name,
|
ws.part_batch_no
|
from basic_location bl
|
left join warehouse_stock ws on ws.location_id = bl."id"
|
left join basic_part bp on bp."id" = ws.part_id
|
left join basic_workstation_location bwl on bwl.location_id = bl."id"
|
left join basic_workstation bw on bw."id" = bwl.workstation_id
|
left join sys_dict_item sdi on sdi."value" = bl.loc_type and sdi.dict_id = 37
|
where bl.active = true
|
) tempA
|
<if test="ew.emptyOfWhere == false">
|
<where>
|
${ew.SqlSegment}
|
</where>
|
</if>
|
order by workstation_no
|
</select>
|
|
<select id="getLocationByLocationNo" resultMap="locationMap">
|
SELECT * FROM basic_location WHERE loc_no = #{locationNo} AND active = 't' LIMIT 1
|
</select>
|
|
|
<select id="getLocation4" resultType="com.chinaztt.mes.basic.entity.Location">
|
SELECT
|
bl.*
|
FROM
|
basic_location bl
|
LEFT JOIN basic_workstation_location bwl ON bl."id" = bwl.location_id
|
WHERE bwl.location_type = 4
|
AND bwl.workstation_id = #{workstationId}
|
</select>
|
|
<select id="getLocationByWorkstationId" resultType="com.chinaztt.mes.basic.entity.Location">
|
SELECT
|
bl.*
|
FROM
|
basic_location bl
|
LEFT JOIN basic_workstation_location bwl ON bl."id" = bwl.location_id
|
WHERE
|
bwl.workstation_id = #{workstationId}
|
AND bwl.location_type = #{locationType}
|
AND bl.active = true
|
AND bl.loc_status = 1
|
</select>
|
|
|
<select id="getLocationByGroups" resultType="java.util.Map">
|
SELECT id,loc_no as locNo from basic_location
|
where loc_group in
|
<foreach item="item" index="index" collection="localGroups" open="(" separator="," close=")">
|
#{item}
|
</foreach>
|
</select>
|
<select id="getReturnLocationByWorkstationId" resultType="com.chinaztt.mes.basic.entity.Location">
|
SELECT
|
bl.*
|
FROM
|
basic_location bl
|
LEFT JOIN basic_workstation_location bwl ON bl."id" = bwl.location_id
|
WHERE
|
bwl.workstation_id = #{workstationId}
|
AND bwl.location_type in
|
<foreach collection="locationTypeList" index="index" item="locationType" open="(" separator=","
|
close=")">
|
#{locationType}
|
</foreach>
|
AND bl.active = true
|
AND bl.loc_status = 1
|
order by bwl.location_type
|
</select>
|
</mapper>
|