Explorar el Código

发布应收账款下载轮询

scr hace 8 años
padre
commit
ec9bc2d391

+ 37 - 0
src/main/java/com/uas/erp/schedular/agent/v1/AbstractAgent.java

@@ -1,8 +1,12 @@
 package com.uas.erp.schedular.agent.v1;
 
 import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.TypeReference;
+import com.uas.api.crypto.util.FlexJsonUtils;
 import com.uas.erp.schedular.entity.Master;
+import com.uas.erp.schedular.finance.domain.AccountApply;
+import com.uas.erp.schedular.finance.domain.Apply;
 import com.uas.erp.schedular.service.SettingService;
 import com.uas.erp.schedular.util.ContextHolder;
 import com.uas.erp.schedular.util.HmacUtils;
@@ -18,6 +22,7 @@ import org.springframework.web.client.RestTemplate;
 
 import java.util.Map;
 
+
 /**
  * Created by Pro1 on 2017/9/4.
  */
@@ -63,4 +68,36 @@ public class AbstractAgent {
         return wrap.isSuccess();
     }
 
+    public ResultWrap<String> postForEntityFinance(String url, Map<String, Object> vars) {
+        Object o = vars.get("apply");
+        JSONObject object = JSON.parseObject((String) o);
+        Apply a = FlexJsonUtils.fromJson((String) o, Apply.class);
+        System.out.println(a.getId());
+        HttpHeaders headers = new HttpHeaders();
+        headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
+        headers.add("referer", getSignature());
+        MultiValueMap<String, Object> formData = new LinkedMultiValueMap<>();
+        formData.setAll(vars);
+        HttpEntity<MultiValueMap<String, Object>> request = new HttpEntity<>(formData, headers);
+        String returnStr = restTemplate.postForEntity(getUASUrl() + url, request, String.class).getBody();
+        ResultWrap<String> wrap = JSON.parseObject(returnStr, new TypeReference<ResultWrap<String>>() {
+        });
+        return wrap;
+    }
+
+    public ResultWrap<String> postForEntityAccountApply(String url,Map<String, Object> vars) {
+        Object o = vars.get("apply");
+        JSONObject object = JSON.parseObject((String) o);
+        AccountApply apply = FlexJsonUtils.fromJson((String) o, AccountApply.class);
+        HttpHeaders headers = new HttpHeaders();
+        headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
+        headers.add("referer", getSignature());
+        MultiValueMap<String, Object> formData = new LinkedMultiValueMap<>();
+        formData.setAll(vars);
+        HttpEntity<MultiValueMap<String, Object>> request = new HttpEntity<>(formData, headers);
+        String returnStr = restTemplate.postForEntity(getUASUrl() + url, request, String.class).getBody();
+        ResultWrap<String> wrap = JSON.parseObject(returnStr, new TypeReference<ResultWrap<String>>() {});
+        return wrap;
+    }
+
 }

+ 189 - 0
src/main/java/com/uas/erp/schedular/finance/domain/AccountApply.java

@@ -0,0 +1,189 @@
+package com.uas.erp.schedular.finance.domain;
+
+import java.util.List;
+
+/**
+ * 应收账款转让实体
+ * created by shicr on 2018/1/29
+ **/
+public class AccountApply {
+
+    /**
+     * 主键
+     */
+    private Long id;
+
+    /**
+     * 买方额度表id
+     */
+    private Long cqId;
+
+    /**
+     * 保理转让款
+     */
+    private Double aa_transferamount;
+
+    /**
+     * 保理首付款
+     */
+    private Double aa_dueamount;
+
+    /**
+     * 应收账款到期日
+     */
+    private String aa_maturitydate;
+
+    /**
+     * 合同总金额
+     */
+    private Double aa_saamount;
+
+    /**
+     * 开票总金额
+     */
+
+
+    /**
+     * 申请日期
+     */
+    private String indate;
+
+    /**
+     * 审核状态
+     */
+
+    /**
+     * ERP下载状态
+     */
+    private Integer erpstatus;
+    /**
+     * 还款状态
+     */
+    private String aa_iscloseoff;
+
+    /**
+     * 保理uu
+     */
+    private Long fauu;
+
+    /**
+     * 合同实体
+     */
+    private List<FsSale> fsSaleList;
+
+    /**
+     * 发票实体
+     */
+    private List<Receipt> receipts;
+
+    /**
+     * 附件
+     */
+    private List<AccountApplyAttach> attaches;
+
+    public List<AccountApplyAttach> getAttaches() {
+        return attaches;
+    }
+
+    public void setAttaches(List<AccountApplyAttach> attaches) {
+        this.attaches = attaches;
+    }
+
+    public Integer getErpstatus() {
+        return erpstatus;
+    }
+
+    public void setErpstatus(Integer erpstatus) {
+        this.erpstatus = erpstatus;
+    }
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public Double getAa_transferamount() {
+        return aa_transferamount;
+    }
+
+    public void setAa_transferamount(Double aa_transferamount) {
+        this.aa_transferamount = aa_transferamount;
+    }
+
+    public Double getAa_dueamount() {
+        return aa_dueamount;
+    }
+
+    public void setAa_dueamount(Double aa_dueamount) {
+        this.aa_dueamount = aa_dueamount;
+    }
+
+    public String getAa_maturitydate() {
+        return aa_maturitydate;
+    }
+
+    public void setAa_maturitydate(String aa_maturitydate) {
+        this.aa_maturitydate = aa_maturitydate;
+    }
+
+    public Double getAa_saamount() {
+        return aa_saamount;
+    }
+
+    public void setAa_saamount(Double aa_saamount) {
+        this.aa_saamount = aa_saamount;
+    }
+
+    public String getIndate() {
+        return indate;
+    }
+
+    public void setIndate(String indate) {
+        this.indate = indate;
+    }
+
+    public String getAa_iscloseoff() {
+        return aa_iscloseoff;
+    }
+
+    public void setAa_iscloseoff(String aa_iscloseoff) {
+        this.aa_iscloseoff = aa_iscloseoff;
+    }
+
+    public List<FsSale> getFsSaleList() {
+        return fsSaleList;
+    }
+
+    public void setFsSaleList(List<FsSale> fsSaleList) {
+        this.fsSaleList = fsSaleList;
+    }
+
+    public List<Receipt> getReceipts() {
+        return receipts;
+    }
+
+    public void setReceipts(List<Receipt> receipts) {
+        this.receipts = receipts;
+    }
+
+    public Long getCqId() {
+        return cqId;
+    }
+
+    public void setCqId(Long cqId) {
+        this.cqId = cqId;
+    }
+
+    public Long getFauu() {
+        return fauu;
+    }
+
+    public void setFauu(Long fauu) {
+        this.fauu = fauu;
+    }
+
+
+}

+ 118 - 0
src/main/java/com/uas/erp/schedular/finance/domain/AccountApplyAttach.java

@@ -0,0 +1,118 @@
+package com.uas.erp.schedular.finance.domain;
+
+import javax.persistence.*;
+import java.io.Serializable;
+
+/**
+ * 出账附件类
+ * created by shicr on 2018/1/27
+ **/
+public class AccountApplyAttach {
+
+
+    /**
+     * id
+     */
+    private Long id;
+
+    /**
+     * 附件名
+     */
+    private String name;
+
+    /**
+     * 附件路径
+     */
+    private String path;
+
+    /**
+     * 文件大小
+     */
+    private Long size;
+
+    /**
+     * 文件所属类别
+     */
+    private String type;
+
+
+    /**
+     * 附件所属的保理公司
+     */
+    private Long fauu;
+
+    /**
+     *附件删除id
+     */
+    private Long uid;
+
+    /**
+     * 出账所属的id
+     */
+    private Long aaid;
+
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+    public String getPath() {
+        return path;
+    }
+
+    public void setPath(String path) {
+        this.path = path;
+    }
+
+    public Long getSize() {
+        return size;
+    }
+
+    public void setSize(Long size) {
+        this.size = size;
+    }
+
+    public String getType() {
+        return type;
+    }
+
+    public void setType(String type) {
+        this.type = type;
+    }
+
+    public Long getAaid() {
+        return aaid;
+    }
+
+    public void setAaid(Long aaid) {
+        this.aaid = aaid;
+    }
+
+    public Long getFauu() {
+        return fauu;
+    }
+
+    public void setFauu(Long fauu) {
+        this.fauu = fauu;
+    }
+
+    public Long getUid() {
+        return uid;
+    }
+
+    public void setUid(Long uid) {
+        this.uid = uid;
+    }
+}

+ 158 - 0
src/main/java/com/uas/erp/schedular/finance/domain/AccountApplyInfo.java

@@ -0,0 +1,158 @@
+package com.uas.erp.schedular.finance.domain;
+
+/**
+ * 应付账款类(没有关联)
+ * created by shicr on 2018/1/30
+ **/
+public class AccountApplyInfo {
+    /**
+     * 主键
+     */
+    private Long id;
+
+    /**
+     * 买方额度表id
+     */
+    private Long cqId;
+
+    /**
+     * 保理转让款
+     */
+    private Double aa_transferamount;
+
+    /**
+     * 保理首付款
+     */
+    private Double aa_dueamount;
+
+    /**
+     * 应收账款到期日
+     */
+    private String aa_maturitydate;
+
+    /**
+     * 合同总金额
+     */
+    private Double aa_saamount;
+
+    /**
+     * 开票总金额
+     */
+
+
+    /**
+     * 申请日期
+     */
+    private String indate;
+
+    /**
+     * 审核状态
+     */
+
+    /**
+     * ERP下载状态
+     */
+    private Integer erpstatus;
+    /**
+     * 还款状态
+     */
+    private String aa_iscloseoff;
+
+    /**
+     * 保理uu
+     */
+    private Long fauu;
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public Long getCqId() {
+        return cqId;
+    }
+
+    public void setCqId(Long cqId) {
+        this.cqId = cqId;
+    }
+
+    public Double getAa_transferamount() {
+        return aa_transferamount;
+    }
+
+    public void setAa_transferamount(Double aa_transferamount) {
+        this.aa_transferamount = aa_transferamount;
+    }
+
+    public Double getAa_dueamount() {
+        return aa_dueamount;
+    }
+
+    public void setAa_dueamount(Double aa_dueamount) {
+        this.aa_dueamount = aa_dueamount;
+    }
+
+    public String getAa_maturitydate() {
+        return aa_maturitydate;
+    }
+
+    public void setAa_maturitydate(String aa_maturitydate) {
+        this.aa_maturitydate = aa_maturitydate;
+    }
+
+    public Double getAa_saamount() {
+        return aa_saamount;
+    }
+
+    public void setAa_saamount(Double aa_saamount) {
+        this.aa_saamount = aa_saamount;
+    }
+
+    public String getIndate() {
+        return indate;
+    }
+
+    public void setIndate(String indate) {
+        this.indate = indate;
+    }
+
+    public Integer getErpstatus() {
+        return erpstatus;
+    }
+
+    public void setErpstatus(Integer erpstatus) {
+        this.erpstatus = erpstatus;
+    }
+
+    public String getAa_iscloseoff() {
+        return aa_iscloseoff;
+    }
+
+    public void setAa_iscloseoff(String aa_iscloseoff) {
+        this.aa_iscloseoff = aa_iscloseoff;
+    }
+
+    public Long getFauu() {
+        return fauu;
+    }
+
+    public void setFauu(Long fauu) {
+        this.fauu = fauu;
+    }
+
+    public AccountApplyInfo(AccountApply accountApply) {
+        this.aa_dueamount = accountApply.getAa_dueamount();
+        this.aa_iscloseoff = accountApply.getAa_iscloseoff();
+        this.aa_maturitydate = accountApply.getAa_maturitydate();
+        this.aa_saamount = accountApply.getAa_saamount();
+        this.aa_transferamount = accountApply.getAa_transferamount();
+        this.cqId = accountApply.getCqId();
+        this.indate = accountApply.getIndate();
+        this.erpstatus = accountApply.getErpstatus();
+        this.fauu = accountApply.getFauu();
+        this.id = accountApply.getId();
+    }
+}

+ 107 - 0
src/main/java/com/uas/erp/schedular/finance/domain/FsSale.java

@@ -0,0 +1,107 @@
+package com.uas.erp.schedular.finance.domain;
+
+/**
+ * created by shicr on 2018/1/16
+ * 基础合同信息表
+ **/
+public class FsSale {
+
+    /**
+     * ID
+     */
+    private Long id;
+
+    /**
+     * 出账id
+     */
+    private Long aa_id;
+
+    /**
+     * 基础合同编号
+     */
+    private String sa_contractno;
+
+    /**
+     * 合同金额
+     */
+    private Double sa_contractamount;
+
+    /**
+     * 订单编号
+     */
+    private String sa_code;
+
+    /**
+     * 订单金额
+     */
+    private Double sa_total;
+
+    /**
+     * 收款方式
+     */
+    private String sa_payment;
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public Long getAa_id() {
+        return aa_id;
+    }
+
+    public void setAa_id(Long aa_id) {
+        this.aa_id = aa_id;
+    }
+
+    public String getSa_contractno() {
+        return sa_contractno;
+    }
+
+    public void setSa_contractno(String sa_contractno) {
+        this.sa_contractno = sa_contractno;
+    }
+
+    public Double getSa_contractamount() {
+        return sa_contractamount;
+    }
+
+    public void setSa_contractamount(Double sa_contractamount) {
+        this.sa_contractamount = sa_contractamount;
+    }
+
+    public String getSa_code() {
+        return sa_code;
+    }
+
+    public void setSa_code(String sa_code) {
+        this.sa_code = sa_code;
+    }
+
+    public Double getSa_total() {
+        return sa_total;
+    }
+
+    public void setSa_total(Double sa_total) {
+        this.sa_total = sa_total;
+    }
+
+    public String getSa_payment() {
+        return sa_payment;
+    }
+
+    public void setSa_payment(String sa_payment) {
+        this.sa_payment = sa_payment;
+    }
+
+  /*  public AccountApply getAccountApply() {
+        return accountApply;
+    }
+
+    public void setAccountApply(AccountApply accountApply) {
+        this.accountApply = accountApply;
+    }*/
+}

+ 90 - 0
src/main/java/com/uas/erp/schedular/finance/domain/Receipt.java

@@ -0,0 +1,90 @@
+package com.uas.erp.schedular.finance.domain;
+
+
+import javax.persistence.*;
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * created by shicr on 2018/1/25
+ * 基础发票信息
+ **/
+public class Receipt {
+
+    private Long id;
+
+    /**
+     * 关联出账表的外键
+     */
+    private Long aa_id;
+
+    /**
+     * 发票号码
+     */
+    private String aai_invoiceno;
+
+    /**
+     * 销售方纳税人识别号
+     */
+    private String aai_salesno;
+
+    /**
+     * 开票日期
+     */
+    private String aai_billdate;
+
+    /**
+     * 开票金额(元)
+     */
+    private Double aai_amount;
+
+
+    public Long getId() {
+        return id;
+    }
+
+    public void setId(Long id) {
+        this.id = id;
+    }
+
+    public String getAai_invoiceno() {
+        return aai_invoiceno;
+    }
+
+    public void setAai_invoiceno(String aai_invoiceno) {
+        this.aai_invoiceno = aai_invoiceno;
+    }
+
+    public String getAai_salesno() {
+        return aai_salesno;
+    }
+
+    public void setAai_salesno(String aai_salesno) {
+        this.aai_salesno = aai_salesno;
+    }
+
+    public String getAai_billdate() {
+        return aai_billdate;
+    }
+
+    public void setAai_billdate(String aai_billdate) {
+        this.aai_billdate = aai_billdate;
+    }
+
+    public Double getAai_amount() {
+        return aai_amount;
+    }
+
+    public void setAai_amount(Double aai_amount) {
+        this.aai_amount = aai_amount;
+    }
+
+    public Long getAa_id() {
+        return aa_id;
+    }
+
+    public void setAa_id(Long aa_id) {
+        this.aa_id = aa_id;
+    }
+
+}

+ 65 - 0
src/main/java/com/uas/erp/schedular/finance/task/AccountApplyTask.java

@@ -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));
+    }
+
+}