liyg 2 years ago
parent
commit
5038c8ad11

+ 3 - 0
src/main/java/com/steerinfo/dil/controller/TmstrainLoadingResultController.java

@@ -67,6 +67,9 @@ public class TmstrainLoadingResultController extends BaseRESTfulController {
         mapValue.put("resultType", resultType);
         mapValue.put("materialId",materialId);
         mapValue.put("supplierId",supplierId);
+        mapValue.put("pageNum",pageNum);
+        mapValue.put("pageSize",pageSize);
+        mapValue.put("con",con);
         PageHelper.startPage(pageNum, pageSize);
         List<Map<String, Object>> tmstrainWagonLoad1 = tmstrainLoadingResultService.getTmstrainWagonLoad(mapValue);
         PageListAdd pageList = columnDataUtil.tableColumnData(apiId, null, tmstrainWagonLoad1);

+ 1 - 0
src/main/java/com/steerinfo/dil/controller/TmstrainMeasureCommissionController.java

@@ -62,6 +62,7 @@ public class TmstrainMeasureCommissionController extends BaseRESTfulController {
     @ApiOperation(value = "批量新增计量委托")
     @PostMapping(value = "/batchSendMeasureCommission")
     public RESTfulResult batchSendMeasureCommission(@RequestBody(required = false) Map<String, Object> map) {
+        System.out.println(map);
         int i = tmstrainMeasureCommissionService.batchSendMeasureCommission(map);
         if (i==-1){
             return success("有委托发送失败,请联系技术人员");

+ 4 - 1
src/main/java/com/steerinfo/dil/mapper/TmstrainLoadingResultMapper.java

@@ -60,6 +60,9 @@ public interface TmstrainLoadingResultMapper extends IBaseMapper<TmstrainLoading
     //通过采购订单Id查询批次Id
     BigDecimal getBatchIdByPurOrderId(BigDecimal purchaseOrderId);
 
+    //通过采购订单Id查询批次、物资id、承运商id等补录信息
+    Map<String, Object> getRecordByPurOrderId(BigDecimal purchaseOrderId);
+
     //查询没有采购订单号的装车实绩
     List<Map<String, Object>> getNoPurOrderIdLoadResult(Map<String, Object> map);
 
@@ -72,6 +75,6 @@ public interface TmstrainLoadingResultMapper extends IBaseMapper<TmstrainLoading
     //添加发站
     Integer addSendStation(Map<String,Object> map);
 
-    //根据物资名和外轮船名查询采购订单号
+    //根据物资名或订单号和外轮船名查询采购订单号
     List<Map<String,Object>> getPurchaseOrderList(Map<String,Object> map);
 }

+ 10 - 0
src/main/java/com/steerinfo/dil/mapper/TmstrainLoadingTempMapper.java

@@ -0,0 +1,10 @@
+package com.steerinfo.dil.mapper;
+
+import com.steerinfo.dil.model.TmstrainLoadingTemp;
+import com.steerinfo.framework.mapper.IBaseMapper;
+import java.math.*;
+import org.apache.ibatis.annotations.Mapper;
+
+@Mapper
+public interface TmstrainLoadingTempMapper extends IBaseMapper<TmstrainLoadingTemp, BigDecimal> {
+}

+ 182 - 0
src/main/java/com/steerinfo/dil/model/TmstrainLoadingTemp.java

@@ -0,0 +1,182 @@
+package com.steerinfo.dil.model;
+
+import com.steerinfo.framework.model.IBasePO;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import java.math.BigDecimal;
+
+@ApiModel(value="这张表是用来保存导入装车excel的临时数据国产矿和进口矿的excel不一致")
+public class TmstrainLoadingTemp implements IBasePO<BigDecimal> {
+    /**
+     * 主键ID(RESULT_ID,DECIMAL,38)
+     */
+    @ApiModelProperty(value="主键ID",required=true)
+    private BigDecimal resultId;
+
+    /**
+     * 车皮号(RESULT_WAGON_NO,VARCHAR,20)
+     */
+    @ApiModelProperty(value="车皮号",required=false)
+    private String resultWagonNo;
+
+    /**
+     * 车皮标重(RESULT_BILLABLE_TONNAGE,DECIMAL,38)
+     */
+    @ApiModelProperty(value="车皮标重",required=false)
+    private BigDecimal resultBillableTonnage;
+
+    /**
+     * 物资名(MATERIAL_NAME,VARCHAR,100)
+     */
+    @ApiModelProperty(value="物资名",required=false)
+    private String materialName;
+
+    /**
+     * 发站名(SEND_STATION,VARCHAR,20)
+     */
+    @ApiModelProperty(value="发站名",required=false)
+    private String sendStation;
+
+    /**
+     * 到站名(ARRIVAL_STATION,VARCHAR,20)
+     */
+    @ApiModelProperty(value="到站名",required=false)
+    private String arrivalStation;
+
+    /**
+     * 发货单位名(SUPPLIER_NAME,VARCHAR,100)
+     */
+    @ApiModelProperty(value="发货单位名",required=false)
+    private String supplierName;
+
+    /**
+     * 发货日期(SEND_DATE,VARCHAR,20)
+     */
+    @ApiModelProperty(value="发货日期",required=false)
+    private String sendDate;
+
+    /**
+     * 制票日期(MAKE_DATE,VARCHAR,20)
+     */
+    @ApiModelProperty(value="制票日期",required=false)
+    private String makeDate;
+
+    /**
+     * 矿种(MINERAL,VARCHAR,100)
+     */
+    @ApiModelProperty(value="矿种",required=false)
+    private String mineral;
+
+    private static final long serialVersionUID = 1L;
+
+    @Override
+    public BigDecimal getId() {
+        return this.resultId;
+    }
+
+    @Override
+    public void setId(BigDecimal resultId) {
+        this.resultId = resultId;
+    }
+
+    public BigDecimal getResultId() {
+        return resultId;
+    }
+
+    public void setResultId(BigDecimal resultId) {
+        this.resultId = resultId;
+    }
+
+    public String getResultWagonNo() {
+        return resultWagonNo;
+    }
+
+    public void setResultWagonNo(String resultWagonNo) {
+        this.resultWagonNo = resultWagonNo == null ? null : resultWagonNo.trim();
+    }
+
+    public BigDecimal getResultBillableTonnage() {
+        return resultBillableTonnage;
+    }
+
+    public void setResultBillableTonnage(BigDecimal resultBillableTonnage) {
+        this.resultBillableTonnage = resultBillableTonnage;
+    }
+
+    public String getMaterialName() {
+        return materialName;
+    }
+
+    public void setMaterialName(String materialName) {
+        this.materialName = materialName == null ? null : materialName.trim();
+    }
+
+    public String getSendStation() {
+        return sendStation;
+    }
+
+    public void setSendStation(String sendStation) {
+        this.sendStation = sendStation == null ? null : sendStation.trim();
+    }
+
+    public String getArrivalStation() {
+        return arrivalStation;
+    }
+
+    public void setArrivalStation(String arrivalStation) {
+        this.arrivalStation = arrivalStation == null ? null : arrivalStation.trim();
+    }
+
+    public String getSupplierName() {
+        return supplierName;
+    }
+
+    public void setSupplierName(String supplierName) {
+        this.supplierName = supplierName == null ? null : supplierName.trim();
+    }
+
+    public String getSendDate() {
+        return sendDate;
+    }
+
+    public void setSendDate(String sendDate) {
+        this.sendDate = sendDate == null ? null : sendDate.trim();
+    }
+
+    public String getMakeDate() {
+        return makeDate;
+    }
+
+    public void setMakeDate(String makeDate) {
+        this.makeDate = makeDate == null ? null : makeDate.trim();
+    }
+
+    public String getMineral() {
+        return mineral;
+    }
+
+    public void setMineral(String mineral) {
+        this.mineral = mineral == null ? null : mineral.trim();
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder sb = new StringBuilder();
+        sb.append(getClass().getSimpleName());
+        sb.append(" [");
+        sb.append("Hash = ").append(hashCode());
+        sb.append(", resultId=").append(resultId);
+        sb.append(", resultWagonNo=").append(resultWagonNo);
+        sb.append(", resultBillableTonnage=").append(resultBillableTonnage);
+        sb.append(", materialName=").append(materialName);
+        sb.append(", sendStation=").append(sendStation);
+        sb.append(", arrivalStation=").append(arrivalStation);
+        sb.append(", supplierName=").append(supplierName);
+        sb.append(", sendDate=").append(sendDate);
+        sb.append(", makeDate=").append(makeDate);
+        sb.append(", mineral=").append(mineral);
+        sb.append(", serialVersionUID=").append(serialVersionUID);
+        sb.append("]");
+        return sb.toString();
+    }
+}

+ 46 - 25
src/main/java/com/steerinfo/dil/service/impl/TmstrainLoadingResultServiceImpl.java

@@ -2,13 +2,16 @@ package com.steerinfo.dil.service.impl;
 
 import com.steerinfo.dil.feign.WmshBoundFeign;
 import com.steerinfo.dil.mapper.TmstrainLoadingResultMapper;
+import com.steerinfo.dil.mapper.TmstrainLoadingTempMapper;
 import com.steerinfo.dil.mapper.TmstrainTotalResultMapper;
 import com.steerinfo.dil.mapper.TmstrainTruckTotalResultMapper;
 import com.steerinfo.dil.model.TmstrainLoadingResult;
+import com.steerinfo.dil.model.TmstrainLoadingTemp;
 import com.steerinfo.dil.model.TmstrainTotalResult;
 import com.steerinfo.dil.model.TmstrainTruckTotalResult;
 import com.steerinfo.dil.service.ITmstrainLoadingResultService;
 import com.steerinfo.dil.util.DataChange;
+import com.steerinfo.framework.service.pagehelper.PageHelper;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -35,6 +38,9 @@ public class TmstrainLoadingResultServiceImpl implements ITmstrainLoadingResultS
     @Autowired
     private TmstrainLoadingResultMapper tmstrainLoadingResultMapper;
 
+    @Autowired
+    private TmstrainLoadingTempMapper tmstrainLoadingTempMapper;
+
     @Autowired
     private WmshBoundFeign wmshBoundFeign;
 
@@ -132,22 +138,31 @@ public class TmstrainLoadingResultServiceImpl implements ITmstrainLoadingResultS
      * @return
      */
     public int addDomesticLoadResult(List<Map<String, Object>> list) throws Exception {
+        //装车临时list
+        List<TmstrainLoadingTemp> loadingTemps=new ArrayList<>();
         //装车实绩list
         List<TmstrainLoadingResult> loadingResults=new ArrayList<>();
         for(Map<String,Object> map:list){
-            TmstrainLoadingResult temp=new TmstrainLoadingResult();
+            TmstrainLoadingTemp temp=new TmstrainLoadingTemp();
+            TmstrainLoadingResult result=new TmstrainLoadingResult();
             //设置序列号主键
             BigDecimal maxId = tmstrainLoadingResultMapper.selectMaxId();
             temp.setResultId(maxId);
-            //从map中取值创建装车对象
-            temp.setArrivalStationId(new BigDecimal(map.get("arrivalStationId").toString()) );//到站id
-            temp.setMaterialId(new BigDecimal(map.get("materialId").toString()));//物资id
-            temp.setResultLoadingDate(new Date((Long)map.get("resultLoadingDate")));//装车日期
-            temp.setResultType(new BigDecimal(map.get("resultType").toString()));
-            temp.setSendUnitId(new BigDecimal(map.get("sendUnitId").toString()));//发货单位id
-            temp.setSendDate((String)map.get("sendDate").toString());
-            temp.setResultRemarks((String) map.get("resultRemarks"));
+            result.setResultId(maxId);
+            //处理临时表
+            temp.setSendStation(map.get("sendStation").toString());//发站
+            temp.setArrivalStation(map.get("arrivalStation").toString());//到站
+            temp.setMaterialName(map.get("materialName").toString());//物资
+            temp.setSupplierName(map.get("supplierName").toString());//发货单位
+            temp.setSendDate(map.get("sendDate").toString());//发货日期
             temp.setResultWagonNo((String) map.get("wagonNo"));//车皮号
+            temp.setResultBillableTonnage(new BigDecimal(map.get("weight").toString()));
+            //处理实绩表
+            result.setArrivalStationId(new BigDecimal(map.get("arrivalStationId").toString()));
+            result.setResultLoadingDate(new Date((Long)map.get("resultLoadingDate")));//装车日期
+            result.setResultType(new BigDecimal(map.get("resultType").toString()));//装车类型,国产矿应该为3
+            result.setResultRemarks((String) map.get("resultRemarks"));
+            result.setResultWagonNo((String) map.get("wagonNo"));//车皮号
             //取得发站名,查询是否存在该站台,如果存在则绑定,否则新增该站台再绑定
             String sendStationName=(String) map.get("sendStation");//发站名
             BigDecimal sendStationId=tmstrainLoadingResultMapper.getSendStationId(sendStationName);
@@ -163,21 +178,23 @@ public class TmstrainLoadingResultServiceImpl implements ITmstrainLoadingResultS
                     throw new Exception("添加发站失败");
                 }
             }
-            temp.setSendStationId(sendStationId);
+            result.setSendStationId(sendStationId);
             //添加常规字段
-            addRegularField(temp);
+            addRegularField(result);
             //通过车皮号计算车皮标重
-            temp.setResultBillableTonnage(new BigDecimal(calculateWagonWeight(temp.getResultWagonNo())));
+            result.setResultBillableTonnage(new BigDecimal(calculateWagonWeight(result.getResultWagonNo())));
             //通过到站ID匹配计量衡 如果是老区轨道衡或者是新区轨道衡 则匹配轨道衡
             //如果到站ID是老区轨道衡
-            BigDecimal arrivalStationId = temp.getArrivalStationId();
-            if(arrivalStationId.intValue() == 1){
-                temp.setTrainCalculateId(new BigDecimal(13)); //设置计量衡为 铁专线(老区)
-                temp.setSendRequest(new BigDecimal(1));
+            BigDecimal arrivalStationId = result.getArrivalStationId();
+            if(arrivalStationId!=null && arrivalStationId.intValue() == 1){
+                result.setTrainCalculateId(new BigDecimal(13)); //设置计量衡为 铁专线(老区)
+                result.setSendRequest(new BigDecimal(1));
             }
-            loadingResults.add(temp);
+            loadingTemps.add(temp);
+            loadingResults.add(result);
         }
         //批量插入
+        tmstrainLoadingTempMapper.batchInsert(loadingTemps);
         int count = tmstrainLoadingResultMapper.batchInsert(loadingResults);
         return count;
     }
@@ -193,22 +210,26 @@ public class TmstrainLoadingResultServiceImpl implements ITmstrainLoadingResultS
         TmstrainLoadingResult tmstrainLoadingResult = new TmstrainLoadingResult();
         BigDecimal purchaseOrderId = DataChange.dataToBigDecimal(map.get("purchaseOrderId"));
         if(purchaseOrderId.intValue() != 0){
-            //添加批次
-            BigDecimal batchId = tmstrainLoadingResultMapper.getBatchIdByPurOrderId(purchaseOrderId);
+            //查询补录信息
+            Map<String,Object> record=tmstrainLoadingResultMapper.getRecordByPurOrderId(purchaseOrderId);
+            BigDecimal materialId=DataChange.dataToBigDecimal(record.get("materialId"));
+            BigDecimal supplierId=DataChange.dataToBigDecimal(record.get("supplierId"));
+            BigDecimal batchId =DataChange.dataToBigDecimal(record.get("batchId"));
+            //设置补录字段
             tmstrainLoadingResult.setBatchId(batchId);
+            tmstrainLoadingResult.setMaterialId(materialId);
+            tmstrainLoadingResult.setSendUnitId(supplierId);
         }
         tmstrainLoadingResult.setPurchaseOrderRailPlanId(purchaseOrderId); //采购订单Id
-        Object insertUpdateRemark = map.get("insertUpdateRemark");
-        if(insertUpdateRemark != null) {
-            String remark = (String) insertUpdateRemark;
-            if(remark.length() != 0)
-                tmstrainLoadingResult.setInsertUpdateRemark(remark); //备注
-        }
         int count = 0;
+        //对每一个实绩id对应的记录修改字段
         for (Integer resultId : resultIdList) {
             tmstrainLoadingResult.setResultId(new BigDecimal(resultId)); //设置要补录的实绩主键
             count += tmstrainLoadingResultMapper.updateByPrimaryKeySelective(tmstrainLoadingResult);
         }
+        //全部补录成功,发送计量委托
+        if(resultIdList.size()-count==0)
+            System.out.println("发送计量委托");
         return count;
     }
 

+ 1 - 1
src/main/java/com/steerinfo/dil/service/impl/TmstrainMeasureCommissionServiceImpl.java

@@ -80,7 +80,7 @@ public class TmstrainMeasureCommissionServiceImpl  implements ITmstrainMeasureCo
         map.put("materialId", measureCommission.get("materialId"));
         map.put("resultTotalId", measureCommission.get("resultTotalId"));
         measureCommission.remove("resultTotalId");
-        //添加计量委托其他数据
+        //发送计量委托
         int i = sendMesToMeasure(measureCommission);
         if(i == 1){
             //添加计量委托实绩

+ 3 - 3
src/main/resources/application-dev.yml

@@ -10,10 +10,10 @@ spring:
 openfeign:
   #测试环境
   ColumnDataFeign:
-    url: ${COLUMNDATAFEIGN_URL:172.16.33.166:8083}
+    url: ${COLUMNDATAFEIGN_URL:172.16.33.161:8083}
   WmshBoundFeign:
-    url: ${WMSHBOUNDFEIGN_URL:localhost:8013}
+    url: ${WMSHBOUNDFEIGN_URL:172.16.33.166:8070}
 
 server:
 #测试环境
-  port: 8004
+  port: 8086

+ 59 - 152
src/main/resources/com/steerinfo/dil/mapper/TmstrainLoadingResultMapper.xml

@@ -818,78 +818,17 @@
     left join RMSTRAIN_ARRIVAL_SEND r_a_arrival
     on r_a_arrival.ARRIVAL_ID=t_load.ARRIVAL_STATION_ID
     where t_load.DELETED in (0, 2) and t_load.RESULT_TYPE = #{resultType}
-    )
-    <where>
-      <if test="purchaseOrderNo != null">
-        <foreach collection="purchaseOrderNo" item="item" open="(" separator="or" close=")">
-          "purchaseOrderNo" like '%${item}%'
-        </foreach>
-      </if>
-      <if test="resultWagonNo != null">
-        and
-        <foreach collection="resultWagonNo" item="item" open="(" separator="or" close=")">
-          "resultWagonNo" like '%${item}%'
-        </foreach>
-      </if>
-      <if test="resultLoadingDate != null">
-        and
-        <foreach collection="resultLoadingDate" item="item" open="(" separator="or" close=")">
-          "resultLoadingDate" like '%${item}%'
-        </foreach>
-      </if>
-      <if test="resultClass != null">
-        and
-        <foreach collection="resultClass" item="item" open="(" separator="or" close=")">
-          "resultClass" like '%${item}%'
-        </foreach>
-      </if>
-      <if test="resultForeignShipName != null">
-        and
-        <foreach collection="resultForeignShipName" item="item" open="(" separator="or" close=")">
-          "resultForeignShipName" like '%${item}%'
-        </foreach>
-      </if>
-      <if test="materialName != null">
-        and
-        <foreach collection="materialName" item="item" open="(" separator="or" close=")">
-          materialName like '%${item}%'
-        </foreach>
-      </if>
-      <if test="sendStationName != null">
-        and
-        <foreach collection="sendStationName" item="item" open="(" separator="or" close=")">
-          "sendStationName" like '%${item}%'
-        </foreach>
-      </if>
-      <if test="arrivalStationName != null">
-        and
-        <foreach collection="arrivalStationName" item="item" open="(" separator="or" close=")">
-          arrivalStationName like '%${item}%'
-        </foreach>
-      </if>
-      <if test="resultBillableTonnage != null">
-        and
-        <foreach collection="resultBillableTonnage" item="item" open="(" separator="or" close=")">
-          "resultBillableTonnage" like '%${item}%'
-        </foreach>
-      </if>
-      <if test="resultIsclear != null">
-        and
-        <foreach collection="resultIsclear" item="item" open="(" separator="or" close=")">
-          "resultIsclear" like '%${item}%'
-        </foreach>
-      </if>
-      <if test="resultRemarks != null">
-        and
-        <foreach collection="resultRemarks" item="item" open="(" separator="or" close=")">
-          "resultRemarks" like '%${item}%'
-        </foreach>
-      </if>
-    </where>
-    <include refid="orderBy"></include>
-    <if test="orderField == null  ">
-      order by "insertTime" desc
+    <if test="con !=null">
+      and (
+      a_order.PURCHASE_ORDER_NO like concat('%',concat(#{con},'%'))
+      or t_load.RESULT_WAGON_NO like concat('%',concat(#{con},'%'))
+      or r_material.MATERIAL_NAME like concat('%',concat(#{con},'%'))
+      or r_s_arrival.ARRIVAL_NAME like concat('%',concat(#{con},'%'))
+      or RS.SUPPLIER_NAME like concat('%',concat(#{con},'%'))
+      )
     </if>
+    order by t_load.RESULT_ID
+    )
   </select>
 
   <sql id="orderBy">
@@ -1259,6 +1198,29 @@
     where APO.PURCHASE_ORDER_ID = #{purchaseOrderId}
   </select>
 
+  <!-- 通过采购订单Id查询批次、物资id、承运商id等补录信息 -->
+  <select id="getRecordByPurOrderId" parameterType="java.math.BigDecimal" resultType="java.util.Map">
+    SELECT
+      apo.PURCHASE_ORDER_NO as "purchaseOrderNo",
+      rm.MATERIAL_NAME as "materialName",
+      rm.MATERIAL_ID  as "materialId",
+      rsu.SUPPLIER_NAME as "supplierName",
+      rsu.SUPPLIER_ID as "supplierId",
+      apo.PURCHASE_ORDER_ID as "purchaseOrderId"
+    FROM AMS_PURCHASE_ORDER apo
+           LEFT JOIN DIL_BATCH db
+                     ON apo.BATCH_ID = db.BATCH_ID
+           LEFT JOIN RMS_MATERIAL rm
+                     ON rm.MATERIAL_ID = db.MATERIAL_ID
+           LEFT JOIN RMS_SUPPLIER rsu
+                     ON apo.SUPPLIER_UNIT_ID = rsu.SUPPLIER_ID
+    where
+      apo.DELETED = 0
+      and  apo.PURCHASE_ORDER_ID=#{purchaseOrderId}
+      and rm.MATERIAL_ID is not null
+      and rsu.SUPPLIER_ID is not null
+  </select>
+
   <!-- 查询还没有采购订单的装车实绩 (补录) -->
   <select id="getNoPurOrderIdLoadResult" parameterType="map" resultType="java.util.Map">
     select * from(
@@ -1268,16 +1230,18 @@
     to_char(t_load.RESULT_LOADING_DATE, 'yyyy-mm-dd') "resultLoadingDate",
     t_load.RESULT_CLASS "resultClass",
     d_batch.RESULT_FOREIGN_SHIP_NAME "resultForeignShipName",
-    r_material.MATERIAL_NAME "materialName",
+    t_temp.MATERIAL_NAME "materialName",
     r_s_arrival.ARRIVAL_NAME "sendStationName",
     r_a_arrival.ARRIVAL_NAME "arrivalStationName",
     t_load.RESULT_BILLABLE_TONNAGE "resultBillableTonnage",
     t_load.RESULT_ISCLEAR "resultIsclear",
     t_load.RESULT_REMARKS "resultRemarks",
-    RS.SUPPLIER_NAME "supplierName",
+    t_temp.SUPPLIER_NAME "supplierName",
     t_load.INSERT_TIME "insertTime",
     t_load.SEND_DATE "sendDate"
     from TMSTRAIN_LOADING_RESULT t_load
+    left join TMSTRAIN_LOADING_TEMP t_temp
+    on t_load.RESULT_ID=t_temp.RESULT_ID
     left join AMS_PURCHASE_ORDER a_order
     on t_load.PURCHASE_ORDER_RAIL_PLAN_ID=a_order.PURCHASE_ORDER_ID
     left join RMS_SUPPLIER RS
@@ -1294,85 +1258,19 @@
       t_load.DELETED = 0
       and t_load.RESULT_TYPE = 3
       and t_load.PURCHASE_ORDER_RAIL_PLAN_ID is null
-      <if test="materialId !=null ">
-        and  r_material.MATERIAL_ID=#{materialId}
-      </if>
-      <if test="supplierId !=null ">
-        and  RS.SUPPLIER_ID=#{supplierId}
+      <if test="con !=null ">
+        and (
+        a_order.PURCHASE_ORDER_NO like concat(concat('%',#{con}),'%')
+        or t_load.RESULT_WAGON_NO like concat(concat('%',#{con}),'%')
+        or d_batch.RESULT_FOREIGN_SHIP_NAME like concat(concat('%',#{con}),'%')
+        or t_temp.MATERIAL_NAME like concat(concat('%',#{con}),'%')
+        or r_s_arrival.ARRIVAL_NAME like concat(concat('%',#{con}),'%')
+        or r_a_arrival.ARRIVAL_NAME like concat(concat('%',#{con}),'%')
+        )
       </if>
     </where>
     )
-    <where>
-      <if test="purchaseOrderNo != null">
-        <foreach collection="purchaseOrderNo" item="item" open="(" separator="or" close=")">
-          "purchaseOrderNo" like '%${item}%'
-        </foreach>
-      </if>
-      <if test="resultWagonNo != null">
-        and
-        <foreach collection="resultWagonNo" item="item" open="(" separator="or" close=")">
-          "resultWagonNo" like '%${item}%'
-        </foreach>
-      </if>
-      <if test="resultLoadingDate != null">
-        and
-        <foreach collection="resultLoadingDate" item="item" open="(" separator="or" close=")">
-          "resultLoadingDate" like '%${item}%'
-        </foreach>
-      </if>
-      <if test="resultClass != null">
-        and
-        <foreach collection="resultClass" item="item" open="(" separator="or" close=")">
-          "resultClass" like '%${item}%'
-        </foreach>
-      </if>
-      <if test="resultForeignShipName != null">
-        and
-        <foreach collection="resultForeignShipName" item="item" open="(" separator="or" close=")">
-          "resultForeignShipName" like '%${item}%'
-        </foreach>
-      </if>
-      <if test="materialName != null">
-        and
-        <foreach collection="materialName" item="item" open="(" separator="or" close=")">
-          materialName like '%${item}%'
-        </foreach>
-      </if>
-      <if test="sendStationName != null">
-        and
-        <foreach collection="sendStationName" item="item" open="(" separator="or" close=")">
-          "sendStationName" like '%${item}%'
-        </foreach>
-      </if>
-      <if test="arrivalStationName != null">
-        and
-        <foreach collection="arrivalStationName" item="item" open="(" separator="or" close=")">
-          arrivalStationName like '%${item}%'
-        </foreach>
-      </if>
-      <if test="resultBillableTonnage != null">
-        and
-        <foreach collection="resultBillableTonnage" item="item" open="(" separator="or" close=")">
-          "resultBillableTonnage" like '%${item}%'
-        </foreach>
-      </if>
-      <if test="resultIsclear != null">
-        and
-        <foreach collection="resultIsclear" item="item" open="(" separator="or" close=")">
-          "resultIsclear" like '%${item}%'
-        </foreach>
-      </if>
-      <if test="resultRemarks != null">
-        and
-        <foreach collection="resultRemarks" item="item" open="(" separator="or" close=")">
-          "resultRemarks" like '%${item}%'
-        </foreach>
-      </if>
-    </where>
-    <include refid="orderBy"></include>
-    <if test="orderField == null  ">
-      order by "insertTime" desc
-    </if>
+    order by "resultId"
   </select>
 
 <!--  根据发站名查发站id-->
@@ -1393,7 +1291,7 @@
         (ARRIVAL_ID,ARRIVAL_NAME,INSERT_TIME,UPDATE_TIME)
         VALUES(#{arrivalId}, #{arrivalName},#{insertTime},#{updateTime})
   </insert>
-<!--  根据物资名和外轮船名查询采购订单号-->
+<!--  根据物资名或订单号和外轮船名查询采购订单号,无条件不查询-->
   <select id="getPurchaseOrderList" parameterType="java.util.Map" resultType="java.util.Map">
     SELECT
     *
@@ -1432,11 +1330,20 @@
     and rm.MATERIAL_NAME is not null
     and db.RESULT_FOREIGN_SHIP_NAME is not null
     and rsu.SUPPLIER_NAME is not null
+    <if test="materialName==null
+    and materialName!=''.toString()
+    and resultForeignShipName==null
+    and resultForeignShipName!=''.toString()">
+    and  apo.PURCHASE_ORDER_NO is null
+    </if>
     <if test="materialName != null and materialName!=''.toString()" >
-      and rm.MATERIAL_NAME like concat(concat('%',#{materialName}),'%')
+    and (
+    apo.PURCHASE_ORDER_NO like concat(concat('%',#{materialName}),'%')
+    or rm.MATERIAL_NAME like concat(concat('%',#{materialName}),'%')
+    )
     </if>
     <if test="resultForeignShipName != null and resultForeignShipName!=''.toString()">
-      and db.RESULT_FOREIGN_SHIP_NAME like concat(concat('%',#{resultForeignShipName}),'%')
+    and db.RESULT_FOREIGN_SHIP_NAME like concat(concat('%',#{resultForeignShipName}),'%')
     </if>
     )
   </select>

+ 342 - 0
src/main/resources/com/steerinfo/dil/mapper/TmstrainLoadingTempMapper.xml

@@ -0,0 +1,342 @@
+<?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.steerinfo.dil.mapper.TmstrainLoadingTempMapper">
+  <resultMap id="BaseResultMap" type="com.steerinfo.dil.model.TmstrainLoadingTemp">
+    <id column="RESULT_ID" jdbcType="DECIMAL" property="resultId" />
+    <result column="RESULT_WAGON_NO" jdbcType="VARCHAR" property="resultWagonNo" />
+    <result column="RESULT_BILLABLE_TONNAGE" jdbcType="DECIMAL" property="resultBillableTonnage" />
+    <result column="MATERIAL_NAME" jdbcType="VARCHAR" property="materialName" />
+    <result column="SEND_STATION" jdbcType="VARCHAR" property="sendStation" />
+    <result column="ARRIVAL_STATION" jdbcType="VARCHAR" property="arrivalStation" />
+    <result column="SUPPLIER_NAME" jdbcType="VARCHAR" property="supplierName" />
+    <result column="SEND_DATE" jdbcType="VARCHAR" property="sendDate" />
+    <result column="MAKE_DATE" jdbcType="VARCHAR" property="makeDate" />
+    <result column="MINERAL" jdbcType="VARCHAR" property="mineral" />
+  </resultMap>
+  <sql id="columns">
+    RESULT_ID, RESULT_WAGON_NO, RESULT_BILLABLE_TONNAGE, MATERIAL_NAME, SEND_STATION, 
+    ARRIVAL_STATION, SUPPLIER_NAME, SEND_DATE, MAKE_DATE, MINERAL
+  </sql>
+  <sql id="columns_alias">
+    t.RESULT_ID, t.RESULT_WAGON_NO, t.RESULT_BILLABLE_TONNAGE, t.MATERIAL_NAME, t.SEND_STATION, 
+    t.ARRIVAL_STATION, t.SUPPLIER_NAME, t.SEND_DATE, t.MAKE_DATE, t.MINERAL
+  </sql>
+  <sql id="select">
+    SELECT <include refid="columns"/> FROM TMSTRAIN_LOADING_TEMP
+  </sql>
+  <sql id="select_alias">
+    SELECT <include refid="columns_alias"/> FROM TMSTRAIN_LOADING_TEMP t
+  </sql>
+  <sql id="where">
+    <where> 
+      <if test="resultId != null">
+        and RESULT_ID = #{resultId}
+      </if>
+      <if test="resultWagonNo != null and resultWagonNo != ''">
+        and RESULT_WAGON_NO = #{resultWagonNo}
+      </if>
+      <if test="resultBillableTonnage != null">
+        and RESULT_BILLABLE_TONNAGE = #{resultBillableTonnage}
+      </if>
+      <if test="materialName != null and materialName != ''">
+        and MATERIAL_NAME = #{materialName}
+      </if>
+      <if test="sendStation != null and sendStation != ''">
+        and SEND_STATION = #{sendStation}
+      </if>
+      <if test="arrivalStation != null and arrivalStation != ''">
+        and ARRIVAL_STATION = #{arrivalStation}
+      </if>
+      <if test="supplierName != null and supplierName != ''">
+        and SUPPLIER_NAME = #{supplierName}
+      </if>
+      <if test="sendDate != null and sendDate != ''">
+        and SEND_DATE = #{sendDate}
+      </if>
+      <if test="makeDate != null and makeDate != ''">
+        and MAKE_DATE = #{makeDate}
+      </if>
+      <if test="mineral != null and mineral != ''">
+        and MINERAL = #{mineral}
+      </if>
+    </where>
+  </sql>
+  <sql id="whereLike">
+    <where> 
+      <if test="resultId != null">
+        and RESULT_ID = #{resultId}
+      </if>
+      <if test="resultWagonNo != null and resultWagonNo != ''">
+        and RESULT_WAGON_NO LIKE '%${resultWagonNo}%'
+      </if>
+      <if test="resultBillableTonnage != null">
+        and RESULT_BILLABLE_TONNAGE = #{resultBillableTonnage}
+      </if>
+      <if test="materialName != null and materialName != ''">
+        and MATERIAL_NAME LIKE '%${materialName}%'
+      </if>
+      <if test="sendStation != null and sendStation != ''">
+        and SEND_STATION LIKE '%${sendStation}%'
+      </if>
+      <if test="arrivalStation != null and arrivalStation != ''">
+        and ARRIVAL_STATION LIKE '%${arrivalStation}%'
+      </if>
+      <if test="supplierName != null and supplierName != ''">
+        and SUPPLIER_NAME LIKE '%${supplierName}%'
+      </if>
+      <if test="sendDate != null and sendDate != ''">
+        and SEND_DATE LIKE '%${sendDate}%'
+      </if>
+      <if test="makeDate != null and makeDate != ''">
+        and MAKE_DATE LIKE '%${makeDate}%'
+      </if>
+      <if test="mineral != null and mineral != ''">
+        and MINERAL LIKE '%${mineral}%'
+      </if>
+    </where>
+  </sql>
+  <delete id="deleteByPrimaryKey" parameterType="java.math.BigDecimal">
+    delete from TMSTRAIN_LOADING_TEMP
+    where RESULT_ID = #{resultId,jdbcType=DECIMAL}
+  </delete>
+  <delete id="deleteBySelectiveElement" parameterType="java.util.HashMap">
+    delete from TMSTRAIN_LOADING_TEMP
+    where 1!=1 
+      <if test="resultWagonNo != null and resultWagonNo != ''">
+        or RESULT_WAGON_NO = #{resultWagonNo}
+      </if>
+      <if test="resultBillableTonnage != null">
+        or RESULT_BILLABLE_TONNAGE = #{resultBillableTonnage}
+      </if>
+      <if test="materialName != null and materialName != ''">
+        or MATERIAL_NAME = #{materialName}
+      </if>
+      <if test="sendStation != null and sendStation != ''">
+        or SEND_STATION = #{sendStation}
+      </if>
+      <if test="arrivalStation != null and arrivalStation != ''">
+        or ARRIVAL_STATION = #{arrivalStation}
+      </if>
+      <if test="supplierName != null and supplierName != ''">
+        or SUPPLIER_NAME = #{supplierName}
+      </if>
+      <if test="sendDate != null and sendDate != ''">
+        or SEND_DATE = #{sendDate}
+      </if>
+      <if test="makeDate != null and makeDate != ''">
+        or MAKE_DATE = #{makeDate}
+      </if>
+      <if test="mineral != null and mineral != ''">
+        or MINERAL = #{mineral}
+      </if>
+  </delete>
+  <insert id="insert" parameterType="com.steerinfo.dil.model.TmstrainLoadingTemp">
+    insert into TMSTRAIN_LOADING_TEMP (RESULT_ID, RESULT_WAGON_NO, RESULT_BILLABLE_TONNAGE, 
+      MATERIAL_NAME, SEND_STATION, ARRIVAL_STATION, 
+      SUPPLIER_NAME, SEND_DATE, MAKE_DATE, 
+      MINERAL)
+    values (#{resultId,jdbcType=DECIMAL}, #{resultWagonNo,jdbcType=VARCHAR}, #{resultBillableTonnage,jdbcType=DECIMAL}, 
+      #{materialName,jdbcType=VARCHAR}, #{sendStation,jdbcType=VARCHAR}, #{arrivalStation,jdbcType=VARCHAR}, 
+      #{supplierName,jdbcType=VARCHAR}, #{sendDate,jdbcType=VARCHAR}, #{makeDate,jdbcType=VARCHAR}, 
+      #{mineral,jdbcType=VARCHAR})
+  </insert>
+  <insert id="insertSelective" parameterType="com.steerinfo.dil.model.TmstrainLoadingTemp">
+    insert into TMSTRAIN_LOADING_TEMP
+    <trim prefix="(" suffix=")" suffixOverrides=",">
+      <if test="resultId != null">
+        RESULT_ID,
+      </if>
+      <if test="resultWagonNo != null">
+        RESULT_WAGON_NO,
+      </if>
+      <if test="resultBillableTonnage != null">
+        RESULT_BILLABLE_TONNAGE,
+      </if>
+      <if test="materialName != null">
+        MATERIAL_NAME,
+      </if>
+      <if test="sendStation != null">
+        SEND_STATION,
+      </if>
+      <if test="arrivalStation != null">
+        ARRIVAL_STATION,
+      </if>
+      <if test="supplierName != null">
+        SUPPLIER_NAME,
+      </if>
+      <if test="sendDate != null">
+        SEND_DATE,
+      </if>
+      <if test="makeDate != null">
+        MAKE_DATE,
+      </if>
+      <if test="mineral != null">
+        MINERAL,
+      </if>
+    </trim>
+    <trim prefix="values (" suffix=")" suffixOverrides=",">
+      <if test="resultId != null">
+        #{resultId,jdbcType=DECIMAL},
+      </if>
+      <if test="resultWagonNo != null">
+        #{resultWagonNo,jdbcType=VARCHAR},
+      </if>
+      <if test="resultBillableTonnage != null">
+        #{resultBillableTonnage,jdbcType=DECIMAL},
+      </if>
+      <if test="materialName != null">
+        #{materialName,jdbcType=VARCHAR},
+      </if>
+      <if test="sendStation != null">
+        #{sendStation,jdbcType=VARCHAR},
+      </if>
+      <if test="arrivalStation != null">
+        #{arrivalStation,jdbcType=VARCHAR},
+      </if>
+      <if test="supplierName != null">
+        #{supplierName,jdbcType=VARCHAR},
+      </if>
+      <if test="sendDate != null">
+        #{sendDate,jdbcType=VARCHAR},
+      </if>
+      <if test="makeDate != null">
+        #{makeDate,jdbcType=VARCHAR},
+      </if>
+      <if test="mineral != null">
+        #{mineral,jdbcType=VARCHAR},
+      </if>
+    </trim>
+  </insert>
+  <update id="updateByPrimaryKey" parameterType="com.steerinfo.dil.model.TmstrainLoadingTemp">
+    update TMSTRAIN_LOADING_TEMP
+    set RESULT_WAGON_NO = #{resultWagonNo,jdbcType=VARCHAR},
+      RESULT_BILLABLE_TONNAGE = #{resultBillableTonnage,jdbcType=DECIMAL},
+      MATERIAL_NAME = #{materialName,jdbcType=VARCHAR},
+      SEND_STATION = #{sendStation,jdbcType=VARCHAR},
+      ARRIVAL_STATION = #{arrivalStation,jdbcType=VARCHAR},
+      SUPPLIER_NAME = #{supplierName,jdbcType=VARCHAR},
+      SEND_DATE = #{sendDate,jdbcType=VARCHAR},
+      MAKE_DATE = #{makeDate,jdbcType=VARCHAR},
+      MINERAL = #{mineral,jdbcType=VARCHAR}
+    where RESULT_ID = #{resultId,jdbcType=DECIMAL}
+  </update>
+  <update id="updateByPrimaryKeySelective" parameterType="com.steerinfo.dil.model.TmstrainLoadingTemp">
+    update TMSTRAIN_LOADING_TEMP
+    <set>
+      <if test="resultWagonNo != null">
+        RESULT_WAGON_NO = #{resultWagonNo,jdbcType=VARCHAR},
+      </if>
+      <if test="resultBillableTonnage != null">
+        RESULT_BILLABLE_TONNAGE = #{resultBillableTonnage,jdbcType=DECIMAL},
+      </if>
+      <if test="materialName != null">
+        MATERIAL_NAME = #{materialName,jdbcType=VARCHAR},
+      </if>
+      <if test="sendStation != null">
+        SEND_STATION = #{sendStation,jdbcType=VARCHAR},
+      </if>
+      <if test="arrivalStation != null">
+        ARRIVAL_STATION = #{arrivalStation,jdbcType=VARCHAR},
+      </if>
+      <if test="supplierName != null">
+        SUPPLIER_NAME = #{supplierName,jdbcType=VARCHAR},
+      </if>
+      <if test="sendDate != null">
+        SEND_DATE = #{sendDate,jdbcType=VARCHAR},
+      </if>
+      <if test="makeDate != null">
+        MAKE_DATE = #{makeDate,jdbcType=VARCHAR},
+      </if>
+      <if test="mineral != null">
+        MINERAL = #{mineral,jdbcType=VARCHAR},
+      </if>
+    </set>
+    where RESULT_ID = #{resultId,jdbcType=DECIMAL}
+  </update>
+  <select id="selectByPrimaryKey" parameterType="java.math.BigDecimal" resultMap="BaseResultMap">
+    <include refid="select"/>
+    where RESULT_ID = #{resultId,jdbcType=DECIMAL}
+  </select>
+  <select id="selectByParameters" parameterType="java.util.HashMap" resultMap="BaseResultMap">
+    <include refid="select"/>
+    <include refid="where"/>
+  </select>
+  <select id="selectLikeByParameters" parameterType="java.util.HashMap" resultMap="BaseResultMap">
+    <include refid="select"/>
+    <include refid="whereLike"/>
+  </select>
+  <insert id="batchInsert" parameterType="java.util.List">
+    insert into TMSTRAIN_LOADING_TEMP 
+      (RESULT_ID, 
+      RESULT_WAGON_NO, RESULT_BILLABLE_TONNAGE, 
+      MATERIAL_NAME, SEND_STATION, ARRIVAL_STATION, 
+      SUPPLIER_NAME, SEND_DATE, MAKE_DATE, 
+      MINERAL)
+    ( <foreach collection="list" item="item" separator="union all"> 
+   select  
+      #{item.resultId,jdbcType=DECIMAL}, 
+      #{item.resultWagonNo,jdbcType=VARCHAR}, #{item.resultBillableTonnage,jdbcType=DECIMAL}, 
+      #{item.materialName,jdbcType=VARCHAR}, #{item.sendStation,jdbcType=VARCHAR}, #{item.arrivalStation,jdbcType=VARCHAR}, 
+      #{item.supplierName,jdbcType=VARCHAR}, #{item.sendDate,jdbcType=VARCHAR}, #{item.makeDate,jdbcType=VARCHAR}, 
+      #{item.mineral,jdbcType=VARCHAR} from dual  
+   </foreach> )
+  </insert>
+  <update id="batchUpdate" parameterType="java.util.List">
+     update TMSTRAIN_LOADING_TEMP
+     set
+       RESULT_ID=
+       <foreach collection="list" item="item" index="index" separator=" " open="case RESULT_ID" close="end">
+          when #{item.resultId,jdbcType=DECIMAL} then #{item.resultId,jdbcType=DECIMAL}
+       </foreach>
+       ,RESULT_WAGON_NO=
+       <foreach collection="list" item="item" index="index" separator=" " open="case RESULT_ID" close="end">
+          when #{item.resultId,jdbcType=DECIMAL} then #{item.resultWagonNo,jdbcType=VARCHAR}
+       </foreach>
+       ,RESULT_BILLABLE_TONNAGE=
+       <foreach collection="list" item="item" index="index" separator=" " open="case RESULT_ID" close="end">
+          when #{item.resultId,jdbcType=DECIMAL} then #{item.resultBillableTonnage,jdbcType=DECIMAL}
+       </foreach>
+       ,MATERIAL_NAME=
+       <foreach collection="list" item="item" index="index" separator=" " open="case RESULT_ID" close="end">
+          when #{item.resultId,jdbcType=DECIMAL} then #{item.materialName,jdbcType=VARCHAR}
+       </foreach>
+       ,SEND_STATION=
+       <foreach collection="list" item="item" index="index" separator=" " open="case RESULT_ID" close="end">
+          when #{item.resultId,jdbcType=DECIMAL} then #{item.sendStation,jdbcType=VARCHAR}
+       </foreach>
+       ,ARRIVAL_STATION=
+       <foreach collection="list" item="item" index="index" separator=" " open="case RESULT_ID" close="end">
+          when #{item.resultId,jdbcType=DECIMAL} then #{item.arrivalStation,jdbcType=VARCHAR}
+       </foreach>
+       ,SUPPLIER_NAME=
+       <foreach collection="list" item="item" index="index" separator=" " open="case RESULT_ID" close="end">
+          when #{item.resultId,jdbcType=DECIMAL} then #{item.supplierName,jdbcType=VARCHAR}
+       </foreach>
+       ,SEND_DATE=
+       <foreach collection="list" item="item" index="index" separator=" " open="case RESULT_ID" close="end">
+          when #{item.resultId,jdbcType=DECIMAL} then #{item.sendDate,jdbcType=VARCHAR}
+       </foreach>
+       ,MAKE_DATE=
+       <foreach collection="list" item="item" index="index" separator=" " open="case RESULT_ID" close="end">
+          when #{item.resultId,jdbcType=DECIMAL} then #{item.makeDate,jdbcType=VARCHAR}
+       </foreach>
+       ,MINERAL=
+       <foreach collection="list" item="item" index="index" separator=" " open="case RESULT_ID" close="end">
+          when #{item.resultId,jdbcType=DECIMAL} then #{item.mineral,jdbcType=VARCHAR}
+       </foreach>
+     where RESULT_ID in 
+     <foreach collection="list" index="index" item="item" separator="," open="(" close=")">
+    #{item.resultId,jdbcType=DECIMAL}
+     </foreach> 
+  </update>
+  <delete id="batchDelete" parameterType="java.util.List">
+    delete from TMSTRAIN_LOADING_TEMP
+    where RESULT_ID in 
+    <foreach collection="list" item="id" open="(" close=")" separator=",">
+      #{id}
+    </foreach>
+  </delete>
+  <!-- 友情提示!!!-->
+  <!-- 请将自己写的代码放在此标签之下,方便以后粘贴复制。-->
+  
+</mapper>