李旭东
2023-12-08 7efc6ed86025b610cab109a2e9f83362740d8ed4
hd/pipe/materialsManage/src/main/resources/mapping/MinXingPlantMapper.xml
@@ -1,125 +1,110 @@
<?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.thhy.materials.modules.biz.mixingstationstorage.mapper.MinXingPlantMapper">
  <resultMap id="BaseResultMap" type="com.thhy.materials.modules.biz.mixingstationstorage.entity.MinXingPlantVo">
    <id column="mixing_plant_id" jdbcType="VARCHAR" property="mixingPlantId" />
    <result column="dict_id" jdbcType="VARCHAR" property="dictId" />
    <result column="stock_type" jdbcType="INTEGER" property="stockType" />
    <result column="create_time" jdbcType="TIMESTAMP" property="createTime" />
    <result column="change_stock" jdbcType="DOUBLE" property="changeStock" />
    <result column="supplier_id" jdbcType="VARCHAR" property="supplierId" />
    <result column="is_use" jdbcType="INTEGER" property="isUse" />
    <result column="company_id" jdbcType="VARCHAR" property="companyId" />
    <result column="car_name" jdbcType="VARCHAR" property="carName" />
    <result column="pro_id" jdbcType="VARCHAR" property="proId" />
    <result column="create_user" jdbcType="VARCHAR" property="createUser" />
    <result column="by_id" jdbcType="INTEGER" property="byId" />
  </resultMap>
  <insert id="insert" >
    insert into t_minxing_plant
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="mixingPlantId != null">
        mixing_plant_id,
      </if>
      <if test="dictId != null">
        dict_id,
      </if>
      <if test="stockType != null">
        stock_type,
      </if>
      <if test="createTime != null">
        create_time,
      </if>
      <if test="changeStock != null">
        change_stock,
      </if>
      <if test="supplierId != null">
        supplier_id,
      </if>
      <if test="isUse != null">
        is_use,
      </if>
      <if test="companyId != null">
        company_id,
      </if>
      <if test="carName != null">
        car_name,
      </if>
      <if test="proId != null">
        pro_id,
      </if>
      <if test="createUser != null">
        create_user,
      </if>
      <if test="byId != null">
        by_id,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="mixingPlantId != null">
        #{mixingPlantId},
      </if>
      <if test="dictId != null">
        #{dictId},
      </if>
      <if test="stockType != null">
        #{stockType},
      </if>
      <if test="createTime != null">
        #{createTime},
      </if>
      <if test="changeStock != null">
        #{changeStock},
      </if>
      <if test="supplierId != null">
        #{supplierId},
      </if>
      <if test="isUse != null">
        #{isUse},
      </if>
      <if test="companyId != null">
        #{companyId},
      </if>
      <if test="carName != null">
        #{carName},
      </if>
      <if test="proId != null">
        #{proId},
      </if>
      <if test="createUser != null">
        #{createUser},
      </if>
      <if test="byId != null">
        #{byId},
      </if>
    </trim>
      insert into t_material_stock_record
      <trim prefix="(" suffix=")" suffixOverrides=",">
          <if test="id != null">
              id,
          </if>
          <if test="createDate != null">
              create_date,
          </if>
          <if test="type != null">
              type,
          </if>
          <if test="opType != null">
              op_type,
          </if>
          <if test="dictId != null">
              material_name,
          </if>
          <if test="materialValue != null">
              material_value,
          </if>
          <if test="beforeStock != null">
              before_stock,
          </if>
          <if test="afterStock != null">
              after_stock,
          </if>
          <if test="companyId != null">
              company_id,
          </if>
          <if test="remark != null">
              remark,
          </if>
          <if test="createUser != null">
              create_user,
          </if>
          <if test="supplierName != null">
              supplier_name,
          </if>
      </trim>
      <trim prefix="values (" suffix=")" suffixOverrides=",">
          <if test="id != null">
              #{id},
          </if>
          <if test="createDate != null">
              #{createDate},
          </if>
          <if test="type != null">
              #{type},
          </if>
          <if test="opType != null">
              #{opType},
          </if>
          <if test="dictId != null">
              #{dictId},
          </if>
          <if test="materialValue != null">
              #{materialValue},
          </if>
          <if test="beforeStock != null">
              #{beforeStock},
          </if>
          <if test="afterStock != null">
              #{afterStock},
          </if>
          <if test="companyId != null">
              #{companyId},
          </if>
          <if test="remark != null">
              #{remark},
          </if>
          <if test="createUser != null">
              #{createUser},
          </if>
          <if test="supplierName != null">
              #{supplierName},
          </if>
      </trim>
  </insert>
  <select id="selectAllList" parameterType="com.thhy.materials.modules.biz.mixingstationstorage.dto.MinXingPlantDto" resultType="com.thhy.materials.modules.biz.mixingstationstorage.entity.MinXingPlantVo">
    SELECT
            DATE_FORMAT(a.create_time, '%Y-%m-%d %H:%i:%S') createDate,
            c.supplier_name supplierName,
            b.dict_name dictName,
            a.change_stock changeStock,
            d.real_name username,
            '吨' unit
    FROM t_minxing_plant a
                 LEFT JOIN sys_dict b ON b.dict_id = a.dict_id
                 LEFT JOIN sys_supplier c ON c.id = a.supplier_id
                 LEFT JOIN sys_users d ON d.user_id = a.create_user
    WHERE a.is_use = 1 and company_id = #{companyId}
    <if test="dictId != null and dictId != ''">
      AND a.dict_id = #{dictId}
    </if>
    <if test="supplierId != null and supplierId != ''">
      AND a.supplier_id = #{supplierId}
    </if>
    <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
      AND a.create_time BETWEEN #{startTime} AND #{endTime}
    </if>
    order by a.create_time desc
      SELECT
          DATE_FORMAT(a.create_date, '%Y-%m-%d %H:%i:%S') createDate,
          b.dict_name dictName,
          a.material_value changeStock,
          d.real_name username,
          '吨' unit,
          a.supplier_name supplierName
      FROM t_material_stock_record a
      LEFT JOIN sys_dict b ON b.dict_id = a.material_name
      LEFT JOIN sys_users d ON d.user_id = a.create_user
      where
      a.op_type =1  and a.company_id = #{companyId}
      <if test="dictId != null and dictId != ''">
          AND a.material_name = #{dictId}
      </if>
      <if test="supplierName != null and supplierName != ''">
          AND a.supplier_name regexp #{supplierName}
      </if>
      <if test="startTime != null and startTime != '' and endTime != null and endTime != ''">
          AND a.create_date BETWEEN #{startTime} AND #{endTime}
      </if>
      order by a.create_date desc
  </select>
  <!--  库存管理 -->
@@ -189,6 +174,9 @@
      <if test="createUser != null">
        create_user,
      </if>
      <if test="supplierName != null">
        supplier_name,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="id != null">
@@ -224,6 +212,9 @@
      <if test="createUser != null">
        #{createUser},
      </if>
      <if test="supplierName != null">
        #{supplierName},
      </if>
    </trim>
  </insert>
  <select id="selectInventoryRecordList" parameterType="com.thhy.materials.modules.biz.mixingstationstorage.dto.TMaterialStockRecordDto" resultType="com.thhy.materials.modules.biz.mixingstationstorage.entity.TMaterialStockRecordVo">