张晓波
2023-12-11 0d0968ec2d1a39c21e15e447c4f2227f70d6a11b
hd/pipe/materialsManage/src/main/resources/mapping/TMaterialReleaseMapper.xml
@@ -146,5 +146,453 @@
    is_use=2
    where material_release_id=#{materialReleaseId}
  </update>
  <select id="pieceList" resultType="com.thhy.materials.modules.biz.concret.entity.dto.PieceDto">
    select by_id as byId,
      BldTim as bldTim,
      types as types
     from  t_piece
    where 1=1
    <if test="byId!=null and byId!='' ">
      and by_id=#{byId}
    </if>
    <if test="types!=null and types!=''">
        and types=#{types}
    </if>
    ORDER BY  by_id desc
  </select>
  <select id="materialRew" resultType="com.thhy.materials.modules.biz.concret.entity.TRawMaterial">
    select Storage as storage,
    Material as material,
    RecAmnt as recamnt,
    PlanAmnt as planamnt,
    FactAmnt as factamnt
     from  t_raw_material
    where  Piece=#{byId} and types=#{types}
  </select>
  <insert id="mixingInsert" >
    insert into t_mixing
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="mixingId != null">
        mixing_id,
      </if>
      <if test="material != null">
        material,
      </if>
      <if test="spec != null">
        spec,
      </if>
      <if test="producer != null">
        producer,
      </if>
      <if test="stove != null">
        stove,
      </if>
      <if test="inNum != null">
        in_num,
      </if>
      <if test="inDate != null">
        in_date,
      </if>
      <if test="inspectState != null">
        inspect_state,
      </if>
      <if test="reportNumber != null">
        report_number,
      </if>
      <if test="stata != null">
        stata,
      </if>
      <if test="siloId != null">
        silo_id,
      </if>
      <if test="percentage != null">
        percentage,
      </if>
      <if test="inspectDate != null">
        inspect_date,
      </if>
      <if test="types != null">
        types,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="mixingId != null">
        #{mixingId,jdbcType=VARCHAR},
      </if>
      <if test="material != null">
        #{material,jdbcType=VARCHAR},
      </if>
      <if test="spec != null">
        #{spec,jdbcType=VARCHAR},
      </if>
      <if test="producer != null">
        #{producer,jdbcType=VARCHAR},
      </if>
      <if test="stove != null">
        #{stove,jdbcType=VARCHAR},
      </if>
      <if test="inNum != null">
        #{inNum,jdbcType=VARCHAR},
      </if>
      <if test="inDate != null">
        #{inDate,jdbcType=VARCHAR},
      </if>
      <if test="inspectState != null">
        #{inspectState,jdbcType=INTEGER},
      </if>
      <if test="reportNumber != null">
        #{reportNumber,jdbcType=VARCHAR},
      </if>
      <if test="stata != null">
        #{stata},
      </if>
      <if test="siloId != null">
        #{siloId,jdbcType=VARCHAR},
      </if>
      <if test="percentage != null">
        #{percentage,jdbcType=VARCHAR},
      </if>
      <if test="inspectDate != null">
        #{inspectDate,jdbcType=VARCHAR},
      </if>
      <if test="types != null">
        #{types},
      </if>
    </trim>
  </insert>
  <select id="mixingList" resultType="com.thhy.materials.modules.biz.concret.entity.TMixing">
        select
        mixing_id as mixingId,
        material as material,
        spec as spec,
        producer as producer,
        stove as stove,
        in_num as inNum,
        in_date as inDate,
        inspect_state as inspectState,
        report_number as reportNumber,
        stata as stata,
        silo_id as siloId,
        percentage as percentage,
        inspect_date as inspectDate
        from t_mixing where silo_id=#{siloId}
        order by in_date desc limit 0,1
  </select>
  <select id="mixingLists" resultType="com.thhy.materials.modules.biz.concret.entity.TMixing">
        select
        mixing_id as mixingId,
        material as material,
        spec as spec,
        producer as producer,
        stove as stove,
        in_num as inNum,
        in_date as inDate,
        inspect_state as inspectState,
        report_number as reportNumber,
        stata as stata,
        silo_id as siloId,
        percentage as percentage,
        inspect_date as inspectDate
        from t_mixing where silo_id=#{siloId}
        and types=1
  </select>
  <select id="siloList" resultType="com.thhy.materials.modules.biz.concret.entity.TSilo">
    select
     silo_id as siloId,
     silo_name as siloName,
     types as types
     from t_silo where types=#{types}
  </select>
  <insert id="mixingConsumeIn" keyProperty="mixingSignboardId" useGeneratedKeys="true" parameterType="java.util.Map">
    insert into t_mixing_signboard
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="mixingSignboardId != null">
        mixing_signboard_id,
      </if>
      <if test="signboardName != null">
        signboard_name,
      </if>
      <if test="proId != null">
        pro_id,
      </if>
      <if test="mixingConsume != null">
        mixing_consume,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="mixingSignboardId != null">
        #{mixingSignboardId,jdbcType=VARCHAR},
      </if>
      <if test="signboardName != null">
        #{signboardName,jdbcType=VARCHAR},
      </if>
      <if test="proId != null">
        #{proId,jdbcType=VARCHAR},
      </if>
      <if test="mixingConsume != null">
        #{mixingConsume,jdbcType=VARCHAR},
      </if>
    </trim>
  </insert>
  <insert id="mixingConsumeInTwo" >
    insert into t_mixing_consume
    <trim prefix="(" suffix=")" suffixOverrides=",">
        mixing_consume_id,
      <if test="dictId != null">
        dict_id,
      </if>
      <if test="spec != null">
        spec,
      </if>
      <if test="manufacturer != null">
        manufacturer,
      </if>
      <if test="watFull != null">
        wat_full,
      </if>
      <if test="planAmnt != null">
        plan_amnt,
      </if>
      <if test="factAmnt != null">
        fact_amnt,
      </if>
      <if test="saveStamp != null">
        save_stamp,
      </if>
      <if test="construction != null">
        construction,
      </if>
      <if test="mixingSignboardId != null">
        mixing_signboard_id,
      </if>
      <if test="star != null">
        star,
      </if>
      <if test="constructionUnit != null">
          construction_unit,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
<!--      <if test="mixingConsumeId != null">-->
<!--        #{mixingConsumeId,jdbcType=VARCHAR},-->
<!--      </if>-->
      REPLACE(UUID(),'-',''),
      <if test="dictId != null">
        #{dictId,jdbcType=VARCHAR},
      </if>
      <if test="spec != null">
        #{spec,jdbcType=VARCHAR},
      </if>
      <if test="manufacturer != null">
        #{manufacturer,jdbcType=VARCHAR},
      </if>
      <if test="watFull != null">
        #{watFull,jdbcType=VARCHAR},
      </if>
      <if test="planAmnt != null">
        #{planAmnt,jdbcType=VARCHAR},
      </if>
      <if test="factAmnt != null">
        #{factAmnt,jdbcType=VARCHAR},
      </if>
      <if test="saveStamp != null">
        #{saveStamp,jdbcType=VARCHAR},
      </if>
      <if test="construction != null">
        #{construction,jdbcType=VARCHAR},
      </if>
      <if test="mixingSignboardId != null">
        #{mixingSignboardId,jdbcType=VARCHAR},
      </if>
      <if test="star != null">
        #{star},
      </if>
      <if test="constructionUnit != null">
        #{constructionUnit},
      </if>
    </trim>
  </insert>
  <select id="starInt" resultType="java.lang.Integer">
    select star from t_mixing_consume order by star desc limit 0,1
  </select>
  <select id="starIntSig" parameterType="java.lang.String" resultType="java.lang.Integer">
    select star from t_mixing_consume where  mixing_signboard_id=#{mixingSignboardId} order by star desc limit 0,1
  </select>
  <select id="mixingSignboardList" resultType="com.thhy.materials.modules.biz.concret.entity.TMixingSignboard">
    select tms.mixing_signboard_id as mixingSignboardId,
    tms.signboard_name as signboardName,
    tms.pro_id as proId,
    tms.mixing_consume as mixingConsume,
    sp.pro_name as proName,
    sp.construction_unit as constructionUnit
     from  t_mixing_signboard tms
     left join sys_project sp on tms.pro_id=sp.pro_id
    where  1=1
    <if test="signboardName!=null and signboardName!='' ">
        and  tms.signboard_name like concat('%',#{signboardName},'%')
    </if>
    <if test="mixingSignboardId !=null and mixingSignboardId !='' ">
        and tms.mixing_signboard_id=#{mixingSignboardId}
    </if>
  </select>
  <select id="mixingConsumes" resultType="com.thhy.materials.modules.biz.concret.entity.TMixingConsume">
    select
    mc.mixing_consume_id as mixingConsumeId,
    -- sd.dict_name as dictName,
    mc.dict_id as dictId,
    mc.spec as spec,
    mc.manufacturer as manufacturer,
    mc.wat_full as watFull,
    mc.plan_amnt as planAmnt,
    mc.fact_amnt as factAmnt,
    mc.save_stamp as saveStamp,
    mc.construction as construction,
    mc.mixing_signboard_id as mixingSignboardId,
    mc.star as star,
    mc.create_time as createTime,
    mc.construction_unit as constructionUnit
     from t_mixing_consume mc
    -- left join  sys_dict sd on mc.dict_id=sd.dict_id
     where mc.mixing_signboard_id=#{mixingSignboardId} and mc.star=#{star}
<!--     <if test="strTime!=null and strTime!='' and endTime !=null and endTime!=''">-->
<!--         and mc.create_time between #{strTime} and #{endTime}-->
<!--     </if>-->
  </select>
  <select id="mixingConsumePull" resultType="com.thhy.materials.modules.biz.concret.entity.TMixingSignboard">
    select
     tms.mixing_signboard_id as mixingSignboardId,
     tms.signboard_name as signboardName,
     sp.pro_name as proName,
     sp.construction_unit as constructionUnit
     from t_mixing_signboard tms left join sys_project sp
     on tms.pro_id=sp.pro_id
  </select>
  <select id="siloPull" resultType="com.thhy.materials.modules.biz.concret.entity.TSilo">
    select silo_id as siloId,
silo_name as siloName,
types
    from t_silo
  </select>
  <update id="mixingUpdateType"  parameterType="java.lang.String">
    update t_mixing set types=2 where silo_id=#{siloId}
  </update>
  <select id="siloMixingList" resultType="com.thhy.materials.modules.biz.concret.entity.TMixing">
        SELECT
        tm.mixing_id as mixingId,
        tm.material as material,
        tm.spec as spec,
        tm.producer as producer,
        tm.stove as stove,
        tm.in_num as inNum,
        tm.in_date as inDate,
        tm.inspect_state as inspectState,
        tm.report_number as reportNumber,
        tm.stata as stata,
        tm.silo_id as siloId,
        tm.percentage as percentage,
        tm.inspect_date as inspectDate,
        ts.silo_name as siloName,
        ts.types as types
FROM
   t_silo ts
   LEFT JOIN t_mixing tm ON ts.silo_id=tm.silo_id
   where  tm.types=1
    <if test="types!=null and types!='' ">
        and ts.types=#{types}
    </if>
    <if test="stata!=null and stata!='' ">
        and tm.stata=#{stata}
    </if>
    <if test="strTime!=null and strTime!=null and endTime!=null and endTime!='' ">
      and tm.in_date between #{strTime} and #{endTime}
    </if>
  </select>
  <update id="mixingUpdate" >
    update t_mixing
    <set>
      <if test="material != null">
        material = #{material,jdbcType=VARCHAR},
      </if>
      <if test="spec != null">
        spec = #{spec,jdbcType=VARCHAR},
      </if>
      <if test="producer != null">
        producer = #{producer,jdbcType=VARCHAR},
      </if>
      <if test="stove != null">
        stove = #{stove,jdbcType=VARCHAR},
      </if>
      <if test="inNum != null">
        in_num = #{inNum,jdbcType=VARCHAR},
      </if>
      <if test="inDate != null">
        in_date = #{inDate,jdbcType=VARCHAR},
      </if>
      <if test="inspectState != null">
        inspect_state = #{inspectState,jdbcType=INTEGER},
      </if>
      <if test="reportNumber != null">
        report_number = #{reportNumber,jdbcType=VARCHAR},
      </if>
      <if test="stata != null">
        stata = #{stata},
      </if>
      <if test="siloId != null">
        silo_id = #{siloId},
      </if>
      <if test="percentage != null">
        percentage = #{percentage},
      </if>
      <if test="inspectDate != null">
        inspect_date = #{inspectDate},
      </if>
    </set>
    where mixing_id = #{mixingId,jdbcType=VARCHAR}
  </update>
  <delete id="mixingDel" parameterType="java.lang.String">
    delete from  t_mixing where  mixing_id=#{mixingId}
  </delete>
  <update id="mixingConsumeUpTwo" >
    update t_mixing_consume
    <set>
      <if test="dictId != null">
        dict_id = #{dictId,jdbcType=VARCHAR},
      </if>
      <if test="spec != null">
        spec = #{spec,jdbcType=VARCHAR},
      </if>
      <if test="manufacturer != null">
        manufacturer = #{manufacturer,jdbcType=VARCHAR},
      </if>
      <if test="watFull != null">
        wat_full = #{watFull,jdbcType=VARCHAR},
      </if>
      <if test="planAmnt != null">
        plan_amnt = #{planAmnt,jdbcType=VARCHAR},
      </if>
      <if test="factAmnt != null">
        fact_amnt = #{factAmnt,jdbcType=VARCHAR},
      </if>
      <if test="saveStamp != null">
        save_stamp = #{saveStamp,jdbcType=VARCHAR},
      </if>
      <if test="construction != null">
        construction = #{construction,jdbcType=VARCHAR},
      </if>
      <if test="mixingSignboardId != null">
        mixing_signboard_id = #{mixingSignboardId,jdbcType=VARCHAR},
      </if>
      <if test="star != null">
        star = #{star},
      </if>
    </set>
    where mixing_consume_id = #{mixingConsumeId,jdbcType=VARCHAR}
  </update>
    <delete id="mixingConsumeDel" >
        delete from  t_mixing_consume where  mixing_consume_id=#{mixingConsumeId} and star=#{star}
    </delete>
    <delete id="mixingConsumeDelSign" >
        delete from  t_mixing_consume where  mixing_signboard_id=#{mixingSignboardId} and star=#{star}
    </delete>
</mapper>