InventoryDetailMapper.xml 8.94 KB
<?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.huaheng.pc.inventory.inventoryDetail.mapper.InventoryDetailMapper">
  <resultMap id="BaseResultMap" type="com.huaheng.pc.inventory.inventoryDetail.domain.InventoryDetail">
    <!--@mbg.generated-->
    <id column="id" jdbcType="INTEGER" property="id" />
    <result column="inventoryHeaderId" jdbcType="INTEGER" property="inventoryHeaderId" />
    <result column="warehouseCode" jdbcType="VARCHAR" property="warehouseCode" />
    <result column="companyCode" jdbcType="VARCHAR" property="companyCode" />
    <result column="locationCode" jdbcType="VARCHAR" property="locationCode" />
    <result column="containerCode" jdbcType="VARCHAR" property="containerCode" />
    <result column="materialCode" jdbcType="VARCHAR" property="materialCode" />
    <result column="materialName" jdbcType="VARCHAR" property="materialName" />
    <result column="materialSpec" jdbcType="VARCHAR" property="materialSpec" />
    <result column="materialUnit" jdbcType="VARCHAR" property="materialUnit" />
    <result column="qty" jdbcType="DECIMAL" property="qty" />
    <result column="weights" jdbcType="DECIMAL" property="weights" />
    <result column="taskQty" jdbcType="DECIMAL" property="taskQty" />
    <result column="lockedQty" jdbcType="DECIMAL" property="lockedQty" />
    <result column="inventorySts" jdbcType="VARCHAR" property="inventorySts" />
    <result column="supplierCode" jdbcType="VARCHAR" property="supplierCode" />
    <result column="referCode" jdbcType="VARCHAR" property="referCode" />
    <result column="referDetailId" jdbcType="VARCHAR" property="referDetailId" />
    <result column="batch" jdbcType="VARCHAR" property="batch" />
    <result column="lot" jdbcType="VARCHAR" property="lot" />
    <result column="projectNo" jdbcType="VARCHAR" property="projectNo" />
    <result column="qcCheck" jdbcType="VARCHAR" property="qcCheck" />
    <result column="weight" jdbcType="VARCHAR" property="weight" />
    <result column="manufactureDate" jdbcType="DATE" property="manufactureDate" />
    <result column="expirationDate" jdbcType="DATE" property="expirationDate" />
    <result column="agingDate" jdbcType="DATE" property="agingDate" />
    <result column="attributeId" jdbcType="VARCHAR" property="attributeId" />
    <result column="attribute1" jdbcType="VARCHAR" property="attribute1" />
    <result column="attribute2" jdbcType="VARCHAR" property="attribute2" />
    <result column="attribute3" jdbcType="VARCHAR" property="attribute3" />
    <result column="lockCode" jdbcType="VARCHAR" property="lockCode" />
    <result column="lastCycleCountDate" jdbcType="TIMESTAMP" property="lastCycleCountDate" />
    <result column="created" jdbcType="TIMESTAMP" property="created" />
    <result column="createdBy" jdbcType="VARCHAR" property="createdBy" />
    <result column="lastUpdated" jdbcType="TIMESTAMP" property="lastUpdated" />
    <result column="lastUpdatedBy" jdbcType="VARCHAR" property="lastUpdatedBy" />
    <result column="userDef1" jdbcType="VARCHAR" property="userDef1" />
    <result column="userDef2" jdbcType="VARCHAR" property="userDef2" />
    <result column="userDef3" jdbcType="VARCHAR" property="userDef3" />
    <result column="processStamp" jdbcType="VARCHAR" property="processStamp" />
    <result column="receiptCode" jdbcType="VARCHAR" property="receiptCode" />
    <result column="receiptDetailId" jdbcType="INTEGER" property="receiptDetailId" />
    <result column="electricQuantity" jdbcType="DECIMAL" property="electricQuantity" />
      <result column="materialNetWeight" jdbcType="DECIMAL" property="materialNetWeight" />
      <result column="materialTareWeight" jdbcType="DECIMAL" property="materialTareWeight" />
      <result column="materialGrossWeight" jdbcType="DECIMAL" property="materialGrossWeight" />
      <result column="batteryQty" jdbcType="DECIMAL" property="batteryQty" />
      <result column="batteryPackType" jdbcType="VARCHAR" property="batteryPackType" />
      <result column="batteryTypes" jdbcType="VARCHAR" property="batteryTypes" />
      <result column="completeness" jdbcType="VARCHAR" property="completeness" />
      <result column="batteryPackTwoCode" jdbcType="VARCHAR" property="batteryPackTwoCode" />
      <result column="materialIsBattery" jdbcType="INTEGER" property="materialIsBattery" />
      <result column="barcodeDetailsCode" jdbcType="VARCHAR" property="barcodeDetailsCode" />

  </resultMap>
  <sql id="Base_Column_List">
    <!--@mbg.generated-->
    id, inventoryHeaderId, warehouseCode, companyCode, locationCode, containerCode, materialCode, 
    materialName, materialSpec, materialUnit, qty, taskQty, lockedQty, inventorySts, weights,
    supplierCode, referCode, referDetailId, batch, lot, projectNo, qcCheck, weight, manufactureDate, 
    expirationDate, agingDate, attributeId, attribute1, attribute2, attribute3, lockCode, 
    lastCycleCountDate, created, createdBy, lastUpdated, lastUpdatedBy, userDef1, userDef2, 
    userDef3, processStamp, receiptCode, receiptDetailId,electricQuantity,materialNetWeight,materialTareWeight,materialGrossWeight,barcodeDetailsCode
  </sql>


  <select id="selectBysql"  parameterType="String" resultType="com.huaheng.pc.inventory.inventoryDetail.domain.InventoryDetail">
        ${value}
    </select>


   <select id="getSumQty" resultType="java.math.BigDecimal">
      SELECT ifnull(sum(qty-taskQty),0) qty from inventory_detail where materialCode=#{materialCode} and warehouseCode=#{warehouseCode} and inventorySts=#{inventorySts}
        <if test="companyCode != null and companyCode != ''">
          and companyCode = #{companyCode}
        </if>
    </select>

  <select id="getWarehouseInventoryStatus"  resultType="java.lang.String">
        SELECT
        ifnull(
        CONVERT (
        ( SELECT count( 1 ) FROM inventory_detail WHERE TIMESTAMPDIFF( MONTH, created, CURDATE( ) ) >= #{a}
        and TIMESTAMPDIFF( MONTH, created, CURDATE( ) ) &lt;#{b}
        AND warehouseCode = #{warehouseCode} ) / ( SELECT count( 1 ) FROM inventory_detail WHERE warehouseCode = #{warehouseCode} ),
        DECIMAL ( 15, 2 )
        ),
        0
        ) scale
        FROM
        DUAL
    </select>

  <select id="getWarehouseInventoryStatuss"  resultType="java.lang.String">
        SELECT
        ifnull(
        CONVERT (
        ( SELECT count( 1 ) FROM inventory_detail WHERE TIMESTAMPDIFF( MONTH, created, CURDATE( ) ) >= #{a} AND warehouseCode = #{warehouseCode} ) / ( SELECT count( 1 ) FROM inventory_detail WHERE warehouseCode = #{warehouseCode} ),
        DECIMAL ( 15, 2 )
        ),
        0
        ) scale
        FROM
        DUAL
    </select>

    <select id="getCompanyInventoryStatus"  resultType="java.lang.String">
       SELECT
        ifnull(
        CONVERT (
        ( SELECT count( 1 ) FROM inventory_detail WHERE TIMESTAMPDIFF( MONTH, created, CURDATE( ) ) >= #{a}
        and TIMESTAMPDIFF( MONTH, created, CURDATE( ) ) &lt;#{b}
        AND companyCode = #{companyCode} ) / ( SELECT count( 1 ) FROM inventory_detail WHERE companyCode = #{companyCode} ),
        DECIMAL ( 15, 2 )
        ),
        0
        ) scale
        FROM
        DUAL
    </select>

    <select id="getCompanyInventoryStatuss"  resultType="java.lang.String">
       SELECT
        ifnull(
        CONVERT (
        ( SELECT count( 1 ) FROM inventory_detail WHERE TIMESTAMPDIFF( MONTH, created, CURDATE( ) ) >= #{a}
        AND companyCode = #{companyCode} ) / ( SELECT count( 1 ) FROM inventory_detail WHERE companyCode = #{companyCode} ),
        DECIMAL ( 15, 2 )
        ),
        0
        ) scale
        FROM
        DUAL
    </select>

    <select id="getWarehouseInventoryProp"  resultType="java.util.LinkedHashMap">
--     SELECT w.name,a.name,ifnull(a.total,0) total from warehouse w
--     left join
--     (SELECT m.name name,sum(i.qty) total,i.warehouseCode warehouseCode from inventory i
--     inner join material m on i.materialCode = m.`code` and i.warehouseId = m.warehouseId
--     GROUP BY m.name,i.warehouseCode) a on w.code=a.warehouseCode ORDER BY total desc
      SELECT m.name name,sum(i.qty) total from inventory_detail i
      inner join material m on i.materialCode = m.`code` and i.warehouseCode = m.warehouseCode and i.warehouseCode=#{warehouseCode}
      GROUP BY m.code ORDER BY total desc limit 10
    </select>

    <select id="getCompanyInventoryProp"  resultType="java.util.LinkedHashMap">
--     SELECT c.name,a.name,ifnull(a.total,0) total from company c
--       left join
--       (SELECT m.name name,sum(i.qty) total,i.companyId companyId from inventory i
--       inner join material m on i.materialCode = m.`code` and i.companyId = m.companyId
--       GROUP BY m.name,i.companyId) a on c.id=a.companyId ORDER BY total desc
      SELECT m.name name,sum(i.qty) total from inventory_detail i
      inner join material m on i.materialCode = m.`code` and i.companyCode = m.companyCode and i.companyCode=#{companyCode}
      GROUP BY m.code  ORDER BY total desc limit 10
    </select>


</mapper>