Procházet zdrojové kódy

Merge remote-tracking branch 'origin/dev' into dev

guq před 7 roky
rodič
revize
bec91e5087

+ 22 - 20
applications/device/device-client/src/main/java/com/usoftchina/smartschool/device/client/service/IcCardService.java

@@ -57,7 +57,7 @@ public class IcCardService {
             + "from XF_AccTransDetail_push left join XF_AccHead on XF_AccTransDetail_push.AccNo=XF_AccHead.AccNo left join Tx_EmpCard on Tx_EmpCard.CardID=XF_AccHead.CardID "
             + "left join RS_EMP ON RS_EMP.EmpSysID=XF_AccHead.EmpSysID where XF_AccTransDetail_push.SendStatus=? order by AccTransDay desc";
 
-    private static final String updateSql = "update XF_AccTransDetail_push set SendStatus = ? where GUID in (?)";
+    private static final String updateSql = "update XF_AccTransDetail_push set SendStatus = ? where GUID in (";
 
     public IcCard find() {
         return icCardRepository.find();
@@ -94,27 +94,29 @@ public class IcCardService {
         jdbcTemplate.execute(insertSql);
         //2.获取本次传输的数据
         List<AccTransDetail> resultList = jdbcTemplate.query(getDataSql, new BeanPropertyRowMapper<>(AccTransDetail.class), "待上传");
-        //3.传输
-        HttpHeaders headers = new HttpHeaders();
-        headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
-        MultiValueMap<String, String> requestEntity = new LinkedMultiValueMap<>();
-        requestEntity.add("data", JSON.toJSONString(resultList));
-        requestEntity.add("school", schoolName);
-        HttpEntity<MultiValueMap<String, String>> httpEntity = new HttpEntity<>(requestEntity, headers);
-        ResponseEntity<Result> response = restTemplate.postForEntity(targetURL, httpEntity, Result.class);
-        if (response.getStatusCode() == HttpStatus.OK) {
-            Result<String> result = response.getBody();
-            if (!result.isSuccess()) {
-                ExceptionCode.ERROR_UNKNOWN.occur(result.getMessage());
-            }else {
-                //更新发送的数据
-                String ids = result.getData();
-                if (!StringUtils.isEmpty(ids)){
-                    jdbcTemplate.update(updateSql, "已上传", ids);
+        if (resultList.size() > 0) {
+            //3.传输
+            HttpHeaders headers = new HttpHeaders();
+            headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
+            MultiValueMap<String, String> requestEntity = new LinkedMultiValueMap<>();
+            requestEntity.add("data", JSON.toJSONString(resultList));
+            requestEntity.add("school", schoolName);
+            HttpEntity<MultiValueMap<String, String>> httpEntity = new HttpEntity<>(requestEntity, headers);
+            ResponseEntity<Result> response = restTemplate.postForEntity(targetURL, httpEntity, Result.class);
+            if (response.getStatusCode() == HttpStatus.OK) {
+                Result<String> result = response.getBody();
+                if (!result.isSuccess()) {
+                    ExceptionCode.ERROR_UNKNOWN.occur(result.getMessage());
+                } else {
+                    //更新发送的数据
+                    String ids = result.getData();
+                    if (!StringUtils.isEmpty(ids)) {
+                        jdbcTemplate.update(updateSql + ids + ")", "已上传");
+                    }
                 }
+            } else {
+                ExceptionCode.ERROR_UNKNOWN.occur("IC卡消费记录发送失败");
             }
-        } else {
-            ExceptionCode.ERROR_UNKNOWN.occur("IC卡消费记录发送失败");
         }
     }
 }