luobang 2 سال پیش
والد
کامیت
20345250af

+ 6 - 4
src/main/java/com/steerinfo/dil/controller/TmsTruckQualityResultController.java

@@ -32,8 +32,10 @@ public class TmsTruckQualityResultController extends BaseRESTfulController {
     //    return success(tmsTruckQualityService.insertQualityResult());
     //}
 
-    //@GetMapping("/delete")
-    //public RESTfulResult deleteQualityResult(){
-    //    return success(tmsTruckQualityService.deleteQualityResult());
-    //}
+    @ApiModelProperty(value = "根据总实绩去重质检实绩")
+    @GetMapping("/distinct")
+    public RESTfulResult distinct() throws IOException, DocumentException {
+        return success(tmsTruckQualityService.distinct());
+    }
+
 }

+ 3 - 1
src/main/java/com/steerinfo/dil/mapper/TmstrainQualityResultMapper.java

@@ -10,7 +10,9 @@ import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Select;
 
 @Mapper
-public interface TmstrainQualityResultMapper extends IBaseMapper<TmstrainQualityResult, Short> {
+public interface TmstrainQualityResultMapper extends IBaseMapper<TmstrainQualityResult, BigDecimal> {
+
+    List<TmstrainQualityResult> selectAll();
    //查看未质检的火车实绩
     List<Map<String, Object>> selectWzInputId();
 

+ 2 - 2
src/main/java/com/steerinfo/dil/mapper/TmstruckQualityResultMapper.java

@@ -1,6 +1,5 @@
 package com.steerinfo.dil.mapper;
 
-import com.steerinfo.dil.model.TmstruckQualityResult;
 import com.steerinfo.dil.model.TmstruckQualityResult;
 import com.steerinfo.framework.mapper.IBaseMapper;
 import java.math.*;
@@ -13,6 +12,8 @@ import org.apache.ibatis.annotations.Select;
 @Mapper
 public interface TmstruckQualityResultMapper extends IBaseMapper<TmstruckQualityResult, BigDecimal> {
 
+    List<TmstruckQualityResult> selectAll();
+
     int updateQuality(Map<String, Object> map1);
 
     BigDecimal selectSamplePlaceId(String samplePlaceName);
@@ -22,6 +23,5 @@ public interface TmstruckQualityResultMapper extends IBaseMapper<TmstruckQuality
     BigDecimal qualityId();
 
 
-    List<Map<String, Object>> selectRepeatResult();
 
 }

+ 2 - 1
src/main/java/com/steerinfo/dil/service/ITmsTruckQualityResultService.java

@@ -14,5 +14,6 @@ import java.util.Map;
 public interface ITmsTruckQualityResultService {
     int insertQualityResult() throws IOException, DocumentException;
 
-    //int deleteQualityResult();
+    int distinct();
+
 }

+ 21 - 8
src/main/java/com/steerinfo/dil/service/impl/TmsTruckQualityService.java

@@ -2,8 +2,10 @@ package com.steerinfo.dil.service.impl;
 
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
+import com.steerinfo.dil.mapper.TmstrainQualityResultMapper;
 import com.steerinfo.dil.mapper.TmstruckQualityResultMapper;
 import com.steerinfo.dil.mapper.TmstruckWeightResultMapper;
+import com.steerinfo.dil.model.TmstrainQualityResult;
 import com.steerinfo.dil.model.TmstruckQualityResult;
 import com.steerinfo.dil.service.ITmsTruckQualityResultService;
 import com.steerinfo.dil.util.DataChange;
@@ -35,6 +37,8 @@ public class TmsTruckQualityService implements ITmsTruckQualityResultService {
     TmstruckQualityResultMapper tmstruckQualityResultMapper;
     @Autowired
     TmstruckWeightResultMapper tmstruckWeightResultMapper;
+    @Autowired
+    TmstrainQualityResultMapper tmstrainQualityResultMapper;
     //定时访问质检系统,获取质检实绩
     @Scheduled(cron = "30 10 10 * * ?")
     public int insertQualityResult() throws IOException, DocumentException {
@@ -128,12 +132,21 @@ public class TmsTruckQualityService implements ITmsTruckQualityResultService {
         return 1;
     }
 
-    //@Override
-    //public int deleteQualityResult() {
-    //    //查询有重复的质检实绩
-    //    List<Map<String,Object>> mapList = tmstruckQualityResultMapper.selectRepeatResult();
-    //    for(Map<String,Object> map : mapList) {
-    //        tmstruckQualityResultMapper.deleteQualityResult()
-    //    }
-    //}
+    @Override
+    public int distinct() {
+        List<TmstruckQualityResult> trucks=tmstruckQualityResultMapper.selectAll();
+        List<TmstrainQualityResult> trains=tmstrainQualityResultMapper.selectAll();
+        for(int i=1;i<trucks.size();i++){
+            if(trucks.get(i).getTotalResultId().compareTo(trucks.get(i-1).getTotalResultId())==0){
+                tmstruckQualityResultMapper.deleteByPrimaryKey(trucks.get(i).getResultId());
+            }
+        }
+        for(int i=1;i<trains.size();i++){
+            if(trains.get(i).getResultTotalId().compareTo(trains.get(i-1).getResultTotalId())==0){
+                tmstrainQualityResultMapper.deleteByPrimaryKey(trains.get(i).getResultId());
+            }
+        }
+        return 0;
+    }
+
 }

+ 6 - 2
src/main/resources/com/steerinfo/dil/mapper/TmstrainQualityResultMapper.xml

@@ -197,7 +197,7 @@
       </if>
     </where>
   </sql>
-  <delete id="deleteByPrimaryKey" parameterType="java.lang.Short">
+  <delete id="deleteByPrimaryKey" parameterType="java.math.BigDecimal">
     delete from TMSTRAIN_QUALITY_RESULT
     where RESULT_ID = #{resultId,jdbcType=DECIMAL}
   </delete>
@@ -547,7 +547,7 @@
     </set>
     where RESULT_ID = #{resultId,jdbcType=DECIMAL}
   </update>
-  <select id="selectByPrimaryKey" parameterType="java.lang.Short" resultMap="BaseResultMap">
+  <select id="selectByPrimaryKey" parameterType="java.math.BigDecimal" resultMap="BaseResultMap">
     <include refid="select" />
     where RESULT_ID = #{resultId,jdbcType=DECIMAL}
   </select>
@@ -710,5 +710,9 @@
                      ON TQR.RESULT_TOTAL_ID = TTR.TOTAL_RESULT_ID
     WHERE  TQR.ISQUALITY IS  NULL AND TWR.RESULT_GROSS_WEIGHT_TIME IS NOT  NULL
   </select>
+  <select id="selectAll" resultMap="BaseResultMap">
+    <include refid="select" />
+    order by RESULT_TOTAL_ID
+  </select>
 
 </mapper>

+ 4 - 5
src/main/resources/com/steerinfo/dil/mapper/TmstruckQualityResultMapper.xml

@@ -493,9 +493,8 @@
   <select id="Count" resultType="java.math.BigDecimal">
     select max(tqr.RESULT_ID)+1 from TMSTRUCK_QUALITY_RESULT tqr
   </select>
-    <select id="selectRepeatResult" resultType="java.util.Map">
-      select * from (select count(TOTAL_RESULT_ID)-1 "totalResultCount" ,TOTAL_RESULT_ID "totalResultId" from TMSTRUCK_QUALITY_RESULT tqr
-      group by tqr.TOTAL_RESULT_ID )
-      where "totalResultCount" != 1
-    </select>
+  <select id="selectAll" resultMap="BaseResultMap">
+    <include refid="select" />
+    order by TOTAL_RESULT_ID
+  </select>
 </mapper>