|
|
@@ -0,0 +1,65 @@
|
|
|
+package com.uas.erp.schedular.finance.task;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.uas.api.crypto.util.FlexJsonUtils;
|
|
|
+import com.uas.erp.schedular.finance.domain.*;
|
|
|
+import com.uas.erp.schedular.task.support.Method;
|
|
|
+import com.uas.erp.schedular.task.support.Role;
|
|
|
+import com.uas.erp.schedular.task.support.TaskMapping;
|
|
|
+import com.uas.erp.schedular.web.ResultWrap;
|
|
|
+import org.springframework.stereotype.Component;
|
|
|
+import org.springframework.ui.ModelMap;
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
+import org.springframework.util.StringUtils;
|
|
|
+
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
+
|
|
|
+/**
|
|
|
+ * 应收账款转让下载
|
|
|
+ * created by shicr on 2018/1/29
|
|
|
+ **/
|
|
|
+@Component
|
|
|
+@TaskMapping(title = "金融服务", role = Role.SELLER)
|
|
|
+public class AccountApplyTask extends AbstractTask {
|
|
|
+
|
|
|
+ @TaskMapping(title = "下载买方客户的应收账款", fixedDelay = 60000, method = Method.DOWNLOAD)
|
|
|
+ public void downloadAccountApply() {
|
|
|
+ String jsonStr = getForObject("/erp/accountapply", String.class);
|
|
|
+ if (!StringUtils.isEmpty(jsonStr)) {
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(jsonStr);
|
|
|
+ String accountapply = jsonObject.getString("accountapply");
|
|
|
+ String custname = jsonObject.getString("custname");
|
|
|
+ String uu = jsonObject.getString("uu");
|
|
|
+ String faid = jsonObject.getString("faid");
|
|
|
+ List<AccountApply> applies = FlexJsonUtils.fromJsonArray(accountapply, AccountApply.class);
|
|
|
+ if (!CollectionUtils.isEmpty(applies)) {
|
|
|
+ for (AccountApply apply : applies) {
|
|
|
+ String url = "/openapi/applicant/AccountApplyFromB2B.action";
|
|
|
+ List<FsSale> fsSales = apply.getFsSaleList();
|
|
|
+ List<Receipt> receipts = apply.getReceipts();
|
|
|
+ List<AccountApplyAttach> attaches = apply.getAttaches();
|
|
|
+ ResultWrap<String> wrap = postForEntityAccountApply(url, new ModelMap("apply", FlexJsonUtils.toJsonDeep(new AccountApplyInfo(apply)))
|
|
|
+ .addAttribute("fsSales", FlexJsonUtils.toJsonDeep(fsSales))
|
|
|
+ .addAttribute("receipts", FlexJsonUtils.toJsonDeep(receipts))
|
|
|
+ .addAttribute("attaches", FlexJsonUtils.toJsonDeep(attaches))
|
|
|
+ .addAttribute("custname", custname)
|
|
|
+ .addAttribute("uu", uu)
|
|
|
+ .addAttribute("faid", faid));
|
|
|
+ downloadSuccess(apply);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 更新已下载数据的下载状态
|
|
|
+ */
|
|
|
+ private void downloadSuccess(AccountApply apply) {
|
|
|
+ JSONObject object = new JSONObject();
|
|
|
+ object.put("id", apply.getId());
|
|
|
+ String j = com.alibaba.fastjson.JSON.toJSONString(object);
|
|
|
+ post("/erp/accountapply/back", dataWrap(j));
|
|
|
+ }
|
|
|
+
|
|
|
+}
|