<?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.production.mapper.ArtificialInformationMapper">
|
|
<resultMap id="dtoResultMap" type="com.chinaztt.mes.production.dto.ArtificialInformationDTO">
|
<id property="id" column="id"/>
|
<result property="productionPersonId" column="production_person_id"/>
|
<result property="workingHours" column="working_hours"/>
|
<result property="personNumber" column="person_number"/>
|
<result property="remark" column="remark"/>
|
<result property="handymanTypeId" column="handyman_type_id"/>
|
<result property="personOutput" column="person_output"/>
|
<result property="staffName" column="staff_name"/>
|
<result property="staffId" column="staff_id"/>
|
<result property="handymanName" column="handyman_name"/>
|
<result property="handymanNo" column="handyman_no"/>
|
<result property="conversionCoefficient" column="conversion_coefficient"/>
|
<result property="processed" column="processed"/>
|
<result property="settlement" column="settlement"/>
|
<result property="totalSettlement" column="total_settlement"/>
|
<result property="handymanWage" column="handyman_wage"/>
|
<result property="dutyNo" column="duty_no"/>
|
<result property="shiftName" column="shift_name"/>
|
<result property="nowDutyDate" column="now_duty_date"/>
|
</resultMap>
|
|
<select id="getArtificialInformationByDutyRecordId" resultMap="dtoResultMap">
|
select pai."id",pai.production_person_id,pai.working_hours,pai.person_number,
|
pai.remark,bs.staff_name,pht.handyman_name,pht.handyman_no,pht.conversion_coefficient,
|
pai.handyman_type_id,pai.person_output,pdr.duty_no,pdr.now_duty_date,bst.name as shift_name
|
from production_artificial_information pai
|
left join production_person_board pb on pb."id"=pai.production_person_id
|
left join basic_staff bs on bs."id"=pb.staff_id
|
left join production_handyman_type pht on pht."id"=pai.handyman_type_id
|
left join production_duty_record pdr on pdr."id"=pai.duty_record_id
|
left join basic_shift bst on bst.id = pdr.shift_id
|
where pai.duty_record_id in
|
<foreach collection="dutyRecordIdList" item="dutyRecordId" index="index" open="(" close=")" separator=",">
|
#{dutyRecordId}
|
</foreach>
|
order by pai."id"
|
</select>
|
|
<select id="getComputationArtificialInformation" resultMap="dtoResultMap">
|
select pai.*,
|
bs.staff_name,ppb.staff_id,pc.labor_cost settlement,coalesce(pht.standard_hour_wage,0) * coalesce(working_hours,0) * 88 as handyman_wage,
|
case when pc."id" is not null then '是' else '否' end "processed"
|
from production_artificial_information pai
|
left join production_computation pc on pai."id"=pc.artificial_information_id and pc.active=true
|
left join production_person_board ppb on ppb."id"=pai.production_person_id
|
left join basic_staff bs on bs."id"=ppb.staff_id
|
left join production_handyman_type pht on pai.handyman_type_id = pht."id"
|
<where>
|
<if test="param.handymanTypeId != null and param.handymanTypeId != ''">
|
and pai.handyman_type_id=#{param.handymanTypeId}
|
</if>
|
<if test="param.dutyRecordId != null and param.dutyRecordId != ''">
|
and pai.duty_record_id=#{param.dutyRecordId}
|
</if>
|
</where>
|
order by ppb.staff_id,pai.handyman_type_id
|
</select>
|
|
<select id="getComputationArtificialInformationByList" resultMap="dtoResultMap">
|
select pai.*,
|
bs.staff_name,ppb.staff_id,pc.labor_cost settlement,coalesce(pht.standard_hour_wage,0) * coalesce(working_hours,0) * 88 as handyman_wage,
|
pdr.duty_no,pdr.now_duty_date,bst.name as shift_name,
|
case when pc."id" is not null then '是' else '否' end "processed"
|
from production_artificial_information pai
|
left join production_computation pc on pai."id"=pc.artificial_information_id and pc.active=true
|
left join production_person_board ppb on ppb."id"=pai.production_person_id
|
left join basic_staff bs on bs."id"=ppb.staff_id
|
left join production_handyman_type pht on pai.handyman_type_id = pht."id"
|
left join production_duty_record pdr on pdr."id"=pai.duty_record_id
|
left join basic_shift bst on bst.id = pdr.shift_id
|
<where>
|
pai.duty_record_id in
|
<foreach collection="dutyRecordIdList" item="dutyRecordId" index="index" open="(" close=")" separator=",">
|
#{dutyRecordId}
|
</foreach>
|
<if test="handymanTypeId != null and handymanTypeId != ''">
|
and pai.handyman_type_id=#{handymanTypeId}
|
</if>
|
</where>
|
order by ppb.staff_id,pai.handyman_type_id
|
</select>
|
|
|
|
|
<insert id="backArtificialInformationById">
|
insert into production_artificial_information_back(production_person_id,working_hours,person_number,remark,handyman_type_id,duty_record_id,
|
person_output,output_id,artificial_information_id,operator,operating_time,type)
|
select production_person_id,working_hours,person_number,remark,handyman_type_id,duty_record_id,person_output,
|
output_id,id,update_user,now(),#{type} from production_artificial_information where id=#{id}
|
</insert>
|
<insert id="backDeleteArtificialInformationByIds">
|
insert into production_artificial_information_back(artificial_information_id,operator,operating_time,type)
|
values(#{id},#{operator},now(),'删除')
|
</insert>
|
|
<select id="selectDtoById" resultType="com.chinaztt.mes.production.dto.ArtificialInformationDTO">
|
select pai.*,ppb.staff_id,bs.staff_name,pdr.duty_time,pdr.now_duty_date
|
from production_artificial_information pai
|
left join production_person_board ppb on ppb."id"=pai.production_person_id
|
left join basic_staff bs on bs."id"=ppb.staff_id
|
left join production_duty_record pdr on pdr."id"=pai.duty_record_id
|
where pai."id"=#{id}
|
</select>
|
<select id="selectTotalWorkTime" resultType="java.math.BigDecimal">
|
select coalesce(sum(coalesce(pai.working_hours,0)),0) total_working_hours
|
from production_artificial_information pai
|
where pai.production_person_id=#{param.productionPersonId} and pai."id"!=#{param.id}
|
</select>
|
<select id="selectTotalDayWorkTime" resultType="java.math.BigDecimal">
|
select coalesce(sum(coalesce(pai.working_hours,0)),0) total_day_working_hours
|
from production_artificial_information pai
|
left join production_person_board ppb on ppb."id"=pai.production_person_id
|
left join production_duty_record pdr on pdr."id"=ppb.duty_record_id
|
where pdr.now_duty_date=#{param.nowDutyDate} and ppb.staff_id=#{param.staffId} and pai."id"!=#{param.id}
|
</select>
|
|
<insert id="batchInsert" parameterType="map">
|
<!--@mbg.generated-->
|
insert into production_artificial_information
|
(production_person_id, working_hours, person_number, remark, handyman_type_id,
|
duty_record_id, person_output, output_id, create_time, update_time, create_user,
|
update_user)
|
values
|
<foreach collection="list" item="item" separator=",">
|
(#{item.productionPersonId,jdbcType=BIGINT}, #{item.workingHours,jdbcType=NUMERIC},
|
#{item.personNumber,jdbcType=NUMERIC}, #{item.remark,jdbcType=VARCHAR}, #{item.handymanTypeId,jdbcType=BIGINT},
|
#{item.dutyRecordId,jdbcType=BIGINT}, #{item.personOutput,jdbcType=NUMERIC}, #{item.outputId,jdbcType=BIGINT},
|
#{item.createTime,jdbcType=TIMESTAMP}, #{item.updateTime,jdbcType=TIMESTAMP}, #{item.createUser,jdbcType=VARCHAR},
|
#{item.updateUser,jdbcType=VARCHAR})
|
</foreach>
|
</insert>
|
</mapper>
|