Parcourir la source

distinct quality

liyg il y a 2 ans
Parent
commit
b7bdc05faf

+ 8 - 2
src/main/java/com/steerinfo/dil/controller/TmsTruckQualityResultController.java

@@ -22,12 +22,18 @@ import java.io.IOException;
 @RequestMapping("/${api.version}/tmsTruckQualityResult")
 public class TmsTruckQualityResultController extends BaseRESTfulController {
 
-    //@Autowired
-    //TmsTruckQualityService tmsTruckQualityService;
+    @Autowired
+    TmsTruckQualityService tmsTruckQualityService;
     //@ApiModelProperty(value = "发送磅单号,接收质检实绩信息")
     //@GetMapping("/insert")
     ////@Transactional
     //public RESTfulResult addQualityResult() throws IOException, DocumentException {
     //    return success(tmsTruckQualityService.insertQualityResult());
     //}
+
+    @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();
 

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

@@ -1,9 +1,9 @@
 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.*;
+import java.util.List;
 import java.util.Map;
 
 import org.apache.ibatis.annotations.Mapper;
@@ -12,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);

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

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

+ 20 - 0
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,4 +132,20 @@ public class TmsTruckQualityService implements ITmsTruckQualityResultService {
         return 1;
     }
 
+    @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 - 0
src/main/resources/com/steerinfo/dil/mapper/TmstruckQualityResultMapper.xml

@@ -493,4 +493,8 @@
   <select id="Count" resultType="java.math.BigDecimal">
     select max(tqr.RESULT_ID)+1 from TMSTRUCK_QUALITY_RESULT tqr
   </select>
+  <select id="selectAll" resultMap="BaseResultMap">
+    <include refid="select" />
+    order by TOTAL_RESULT_ID
+  </select>
 </mapper>