ShipmentDetailMapper.xml 12.7 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.shipment.shipmentDetail.mapper.ShipmentDetailMapper">
  <resultMap id="BaseResultMap" type="com.huaheng.pc.shipment.shipmentDetail.domain.ShipmentDetail">
    <!--@mbg.generated-->
    <id column="id" jdbcType="INTEGER" property="id" />
    <result column="shipmentId" jdbcType="INTEGER" property="shipmentId" />
    <result column="warehouseCode" jdbcType="VARCHAR" property="warehouseCode" />
    <result column="companyCode" jdbcType="VARCHAR" property="companyCode" />
    <result column="shipmentCode" jdbcType="VARCHAR" property="shipmentCode" />
    <result column="referCode" jdbcType="VARCHAR" property="referCode" />
    <result column="referId" jdbcType="INTEGER" property="referId" />
    <result column="referLineNum" jdbcType="VARCHAR" property="referLineNum" />
    <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="shipQty" jdbcType="INTEGER" property="shipQty" />
    <result column="shipWeight" jdbcType="DECIMAL" property="shipWeight" />
    <result column="unitId1Qty" jdbcType="DECIMAL" property="unitId1Qty" />
    <result column="unitId2Qty" jdbcType="DECIMAL" property="unitId2Qty" />
    <result column="unitId1" jdbcType="VARCHAR" property="unitId1" />
    <result column="unitId2" jdbcType="VARCHAR" property="unitId2" />
    <result column="multiple" jdbcType="DOUBLE" property="multiple" />
    <result column="requestQty" jdbcType="INTEGER" property="requestQty" />
    <result column="requestWeight" jdbcType="INTEGER" property="requestWeight" />
    <result column="allocationRule" jdbcType="VARCHAR" property="allocationRule" />
    <result column="replenishmentRule" jdbcType="VARCHAR" property="replenishmentRule" />
    <result column="pickLocs" jdbcType="VARCHAR" property="pickLocs" />
    <result column="attribute1" jdbcType="VARCHAR" property="attribute1" />
    <result column="attribute2" jdbcType="VARCHAR" property="attribute2" />
    <result column="attribute3" jdbcType="VARCHAR" property="attribute3" />
    <result column="attribute4" jdbcType="VARCHAR" property="attribute4" />
    <result column="batch" jdbcType="VARCHAR" property="batch" />
    <result column="lot" jdbcType="VARCHAR" property="lot" />
    <result column="projectNo" jdbcType="VARCHAR" property="projectNo" />
    <result column="manufactureDate" jdbcType="DATE" property="manufactureDate" />
    <result column="expirationDate" jdbcType="DATE" property="expirationDate" />
    <result column="agingDate" jdbcType="DATE" property="agingDate" />
    <result column="inventorySts" jdbcType="VARCHAR" property="inventorySts" />
    <result column="dockLoc" jdbcType="VARCHAR" property="dockLoc" />
    <result column="packingClass" jdbcType="VARCHAR" property="packingClass" />
    <result column="status" jdbcType="INTEGER" property="status" />
    <result column="waveId" jdbcType="INTEGER" property="waveId" />
    <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="version" jdbcType="INTEGER" property="version" />
    <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="orderNo" jdbcType="VARCHAR" property="orderNo" />
    <result column="treatmentQuality" jdbcType="DECIMAL" property="treatmentQuality" />
      <result column="batteryPackageCode" jdbcType="VARCHAR" property="batteryPackageCode" />
<!--      <result column="enterpriseCode" jdbcType="VARCHAR" property="enterpriseCode" />-->
<!--      <result column="enterpriseName" jdbcType="VARCHAR" property="enterpriseName" />-->
      <result column="shipmentDate" jdbcType="DATE" property="shipmentDate" />
<!--      <result column="echelonPacketCode" jdbcType="VARCHAR" property="echelonPacketCode" />-->
      <result column="echelonApplicationField" jdbcType="VARCHAR" property="echelonApplicationField" />
      <result column="otherContent" jdbcType="VARCHAR" property="otherContent" />
<!--      <result column="echelonEnterpriseName" jdbcType="VARCHAR" property="echelonEnterpriseName" />-->
<!--      <result column="echelonEnterpriseCode" jdbcType="VARCHAR" property="echelonEnterpriseCode" />-->
      <result column="framework" jdbcType="VARCHAR" property="framework" />
      <result column="customerName" jdbcType="VARCHAR" property="customerName" />
      <result column="customerIDNumber" jdbcType="VARCHAR" property="customerIDNumber" />
<!--      <result column="originPackage" jdbcType="VARCHAR" property="originPackage" />-->
<!--      <result column="echelonModuleCode" jdbcType="VARCHAR" property="echelonModuleCode" />-->
<!--      <result column="originModule" jdbcType="VARCHAR" property="originModule" />-->
<!--      <result column="echelonMonomerCode" jdbcType="VARCHAR" property="echelonMonomerCode" />-->
<!--      <result column="originEchelon" jdbcType="VARCHAR" property="originEchelon" />-->
      <result column="batteryType" jdbcType="VARCHAR" property="batteryType" />
      <result column="batteryCode" jdbcType="VARCHAR" property="batteryCode" />
      <result column="shipQuality" jdbcType="DECIMAL" property="shipQuality" />
      <result column="treatmentQuality" jdbcType="DECIMAL" property="treatmentQuality" />
      <result column="regenerateDate" jdbcType="DATE" property="regenerateDate" />
      <result column="wasteDestination" jdbcType="VARCHAR" property="wasteDestination" />
      <result column="batteryQty" jdbcType="DECIMAL" property="batteryQty" />
      <result column="batteryPageCode" jdbcType="VARCHAR" property="batteryPageCode" />
      <result column="regenerateSubstanceName" jdbcType="VARCHAR" property="regenerateSubstanceName" />
      <result column="regenerateUtilizationRate" jdbcType="DECIMAL" property="regenerateUtilizationRate" />
      <result column="substanceRegenerateQuality" jdbcType="DECIMAL" property="substanceRegenerateQuality" />
      <result column="countryCode" jdbcType="VARCHAR" property="countryCode" />
    <result column="electricQuantity" jdbcType="DECIMAL" property="electricQuantity" />
    <result column="poundNumber" jdbcType="VARCHAR" property="poundNumber" />
    <result column="grossWeight" jdbcType="DECIMAL" property="grossWeight" />
    <result column="tareWeight" jdbcType="DECIMAL" property="tareWeight" />
    <result column="shipmentType" jdbcType="VARCHAR" property="shipmentType" />
    <result column="materialIsBattery" jdbcType="INTEGER" property="materialIsBattery" />
    <result column="echelonCode" jdbcType="VARCHAR" property="echelonCode" />
    <result column="echelonName" jdbcType="VARCHAR" property="echelonName" />
    <result column="storageType" jdbcType="VARCHAR" property="storageType" />

  </resultMap>
  <sql id="Base_Column_List">
    <!--@mbg.generated-->
    id, shipmentId, warehouseCode, companyCode, shipmentCode, referCode, referId, referLineNum, shipWeight,orderNo,
    materialCode, materialName, materialSpec, materialUnit, shipQty, requestQty, allocationRule, requestWeight,
    replenishmentRule, pickLocs, attribute1, attribute2, attribute3, attribute4, batch,unitId1Qty,unitId2Qty,
    lot, projectNo, manufactureDate, expirationDate, agingDate, inventorySts, dockLoc,unitId1,unitId2,multiple,
    packingClass, `enable`, waveId, created, createdBy, lastUpdated, lastUpdatedBy, version,regenerateUtilizationRate,substanceRegenerateQuality,
    treatmentQuality,batteryPackageCode,shipmentDate,echelonApplicationField,otherContent,
--     enterpriseCode,enterpriseName,echelonEnterpriseName,echelonEnterpriseCode,echelonModuleCode,originModule,originEchelon,echelonMonomerCode,originPackage,
--     echelonPacketCode
    framework,customerName,customerIDNumber,batteryType,batteryCode,shipQuality,treatmentQuality,regenerateDate,wasteDestination,batteryQty,batteryPageCode,regenerateSubstanceName,
    userDef1, userDef2, userDef3,processStamp,countryCode,electricQuantity,poundNumber,grossWeight,tareWeight,shipmentType,echelonCode,echelonName,storageType
  </sql>


  <select id="SelectFirstStatus" resultType="java.util.Map">
        SELECT h.id, h.firstStatus, h.lastStatus
        FROM shipment_header h
        INNER JOIN shipment_detail d ON h.id = d.shipmentId AND d.id IN (#{ids})
        GROUP BY h.id,h.firstStatus
    </select>

  <delete id="batchDelete">
    DELETE FROM shipment_detail WHERE id IN
    <foreach item="idItem" collection="array" open="(" separator="," close=")">
      #{idItem}
    </foreach>
  </delete>

  <select id="StatisticalByReceiptId" resultType="java.util.Map">
       SELECT count(*) as 'totalLines',sum(shipQty) as 'totalQty'
       FROM shipment_detail
       WHERE shipmentId=#{headerId}
    </select>

  <select id="countUnCompleted" resultType="java.lang.Integer">
         SELECT COUNT(*) FROM shipment_detail WHERE shipmentId=#{shipmentId} AND shipQty>requestQty
    </select>

  <select id="selectStatus" resultType="java.util.Map">
       SELECT max(status) maxStatus,min(status) minStatus
       FROM shipment_detail
       WHERE shipmentId=#{id}
    </select>

  <select id="getShipmentQtyLast7Days" resultType="com.huaheng.pc.task.taskDetail.domain.TaskDetail">
SELECT
	a.click_date AS lastUpdated,
	ifnull( b.taskQty, 0 ) AS qty
FROM
	(
	SELECT
		curdate( ) AS click_date UNION ALL
	SELECT
		date_sub( curdate( ), INTERVAL 1 DAY ) AS click_date UNION ALL
	SELECT
		date_sub( curdate( ), INTERVAL 2 DAY ) AS click_date UNION ALL
	SELECT
		date_sub( curdate( ), INTERVAL 3 DAY ) AS click_date UNION ALL
	SELECT
		date_sub( curdate( ), INTERVAL 4 DAY ) AS click_date UNION ALL
	SELECT
		date_sub( curdate( ), INTERVAL 5 DAY ) AS click_date UNION ALL
	SELECT
		date_sub( curdate( ), INTERVAL 6 DAY ) AS click_date
	) a
	LEFT JOIN (
	SELECT
		DATE( r.lastUpdated ) AS date,
		SUM( r.qty ) AS taskQty
	FROM
		task_detail r
	WHERE
	    r.taskType = 200 and
		r.lastUpdated >= DATE_SUB( CURDATE( ), INTERVAL 7 DAY )
		AND r.status> 90
	GROUP BY
		DATE(r.lastUpdated )
	) b ON a.click_date = b.date
ORDER BY
	a.click_date;
    </select>


  <select id="getWarehouseShipment" resultType="com.huaheng.pc.task.taskDetail.domain.TaskDetail">
    SELECT ifnull(sum(r.qty),0) as qty,w.name as warehouseName  from warehouse w
    left JOIN task_detail r on r.warehouseCode=w.code and r.status>90 and r.taskType =200
    and date(r.lastUpdated)=CURDATE()  group by w.code
    </select>


  <select id="getCompanyShipment" resultType="com.huaheng.pc.task.taskDetail.domain.TaskDetail">
    SELECT ifnull(sum(r.qty),0) as qty,c.name as companyName  from company c
    left JOIN task_detail r on r.companyCode=c.code and r.status>90 and r.taskType =200
    and date(r.lastUpdated)=CURDATE()  group by c.code
    </select>

  <insert id="insertDetails">
    insert into shipment_detail(
    shipmentId, warehouseCode, companyCode, shipmentCode, referCode, referId, referLineNum,
    materialCode, materialName, materialSpec, materialUnit, shipQty, allocationRule,unitId1Qty,unitId2Qty,
    replenishmentRule, pickLocs, attribute1, attribute2, attribute3, attribute4, batch,unitId1,unitId2,multiple,
    lot, projectNo, manufactureDate, expirationDate, agingDate, inventorySts, dockLoc,
    packingClass, waveId, created, createdBy, lastUpdatedBy,shipmentType
    )
    values
    <foreach collection="shipmentDetails" item="item" index="index" separator=",">
    (
      #{item.shipmentId}, #{item.warehouseCode}, #{item.companyCode}, #{item.shipmentCode}, #{item.referCode},
      #{item.referId}, #{item.referLineNum},#{item.materialCode}, #{item.materialName}, #{item.materialSpec},
      #{item.materialUnit}, #{item.shipQty}, #{item.allocationRule},#{item.unitId1Qty},#{item.unitId2Qty},#{item.replenishmentRule},
      #{item.pickLocs}, #{item.attribute1}, #{item.attribute2}, #{item.attribute3}, #{item.attribute4}, #{item.batch},#{item.unitId1},#{item.unitId2},#{item.multiple},
      #{item.lot}, #{item.projectNo}, #{item.manufactureDate}, #{item.expirationDate}, #{item.agingDate},
      #{item.inventorySts}, #{item.dockLoc},#{item.packingClass}, #{item.waveId}, #{item.created}, #{item.createdBy},
      #{item.lastUpdatedBy}, #{item.shipmentType},
    )
    </foreach>
  </insert>
</mapper>