Просмотр исходного кода

修改上传作废打样申请单信息传到平台查询ID的方法

hejq 8 лет назад
Родитель
Сommit
1a44eb68a4

+ 18 - 0
src/main/java/com/uas/erp/schedular/b2b/domain/IdObject.java

@@ -0,0 +1,18 @@
+package com.uas.erp.schedular.b2b.domain;
+
+/**
+ * 只查询id信息
+ *
+ * Created by hejq on 2018-04-16.
+ */
+public class IdObject {
+    private Long id;
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+}

+ 2 - 2
src/main/java/com/uas/erp/schedular/b2b/task/PurchaseSampleTask.java

@@ -202,10 +202,10 @@ public class PurchaseSampleTask extends AbstractTask {
 
     @TaskMapping(title = "上传作废打样申请单信息传到平台", fixedDelay = 60000)
     public void invalidateSaleSampleSend() {
-        List<Long> sampleIds = jdbcTemplate.queryForBeanList("select productsample.ps_id from productsample left join employee" +
+        List<Long> sampleIds = jdbcTemplate.queryIdList("select productsample.ps_id from productsample left join employee" +
                 " on productsample.ps_appmanid = em_id where ps_sendstatus = '已上传' and ps_status='已作废' and exists (select 1 from productsampledetail left" +
                 " join vendor on pd_vendcode=ve_code where pd_psid=ps_id and ve_uu is not null and nvl(ve_b2benable,0)=1) order by ps_code",
-                Long.class);
+                IdObject.class);
         if (!CollectionUtils.isEmpty(sampleIds)) {
             ContextHolder.setDataSize(sampleIds.size());
             String idStr = StringUtils.collectionToCommaDelimitedString(sampleIds);

+ 13 - 1
src/main/java/com/uas/erp/schedular/database/RestJdbcTemplate.java

@@ -2,9 +2,9 @@ package com.uas.erp.schedular.database;
 
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.TypeReference;
+import com.uas.erp.schedular.b2b.domain.IdObject;
 import com.uas.erp.schedular.service.SettingService;
 import com.uas.erp.schedular.util.BeanUtil;
-import com.uas.erp.schedular.util.CollectionUtil;
 import com.uas.erp.schedular.web.ResultListWrap;
 import com.uas.erp.schedular.web.ResultWrap;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -277,4 +277,16 @@ public class RestJdbcTemplate {
         return null == code ? null : code.toString();
     }
 
+    public <T> List<Long> queryIdList(String sql, Class<T> elementType) {
+        HttpEntity request = new HttpEntity<Executable>(Executable.query(sql, BeanUtil.getProperties(elementType), null));
+        String resultStr = restTemplate.postForObject(getUrl() + "/v1/exec", request, String.class);
+        ResultListWrap<IdObject> result = JSON.parseObject(resultStr, new TypeReference<ResultListWrap<IdObject>>(elementType){});
+        List<Long> list = new ArrayList<>();
+        if (!CollectionUtils.isEmpty(result.getContent())) {
+            for (IdObject object : result.getContent()) {
+                list.add(object.getId());
+            }
+        }
+        return list;
+    }
 }