commit
79b5343d98
@ -0,0 +1,65 @@ |
|||||||
|
package com.jianshui.invoice.domain.dto.yuande; |
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat; |
||||||
|
import com.jianshui.invoice.domain.yuande.Invoiceformitem; |
||||||
|
import lombok.Data; |
||||||
|
|
||||||
|
import java.io.Serializable; |
||||||
|
import java.math.BigDecimal; |
||||||
|
import java.util.Date; |
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
@Data |
||||||
|
public class YuandeInvoiceFormDTO implements Serializable { |
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L; |
||||||
|
|
||||||
|
//记录Id
|
||||||
|
private String id; |
||||||
|
|
||||||
|
//开票人(固定值)
|
||||||
|
private String[] owner = {"FSUID_5DCF10DE85AA29CF6ECF414C2F22F669"}; |
||||||
|
|
||||||
|
//对象名称(固定值)
|
||||||
|
private String dataObjectApiName = "Invoiceform__c"; |
||||||
|
|
||||||
|
//客户名称
|
||||||
|
private String customer__c; |
||||||
|
|
||||||
|
//订单编号
|
||||||
|
private String salesorderid__c; |
||||||
|
|
||||||
|
//发票抬头
|
||||||
|
private String fptt__c; |
||||||
|
|
||||||
|
//开户银行
|
||||||
|
private String fkdwkhyh__c; |
||||||
|
|
||||||
|
//银行账号
|
||||||
|
private String fkdwyhzh__c; |
||||||
|
|
||||||
|
//地址
|
||||||
|
private String fkdwdz__c; |
||||||
|
|
||||||
|
//电话
|
||||||
|
private String fkdwdh__c; |
||||||
|
|
||||||
|
//税号
|
||||||
|
private String tyshxydm__c; |
||||||
|
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd") |
||||||
|
//开票日期
|
||||||
|
private Date kprq__c; |
||||||
|
|
||||||
|
//发票号码
|
||||||
|
private String fphm__c; |
||||||
|
|
||||||
|
//备注
|
||||||
|
private String field_91Rds__c; |
||||||
|
|
||||||
|
//税率:百分比暂时
|
||||||
|
private BigDecimal taxrate__c; |
||||||
|
|
||||||
|
//关联明细表
|
||||||
|
private List<Invoiceformitem> invoiceformitems; |
||||||
|
} |
@ -0,0 +1,27 @@ |
|||||||
|
package com.jianshui.invoice.domain.yuande; |
||||||
|
|
||||||
|
import lombok.Data; |
||||||
|
|
||||||
|
import java.io.Serializable; |
||||||
|
|
||||||
|
@Data |
||||||
|
public class CorpBody implements Serializable { |
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L; |
||||||
|
/** 企业应用访问公司合法性凭证 */ |
||||||
|
private String corpAccessToken; |
||||||
|
|
||||||
|
/** 开放平台派发的公司帐号 */ |
||||||
|
private String corpId; |
||||||
|
|
||||||
|
/** 过期时间 */ |
||||||
|
private String expiresIn; |
||||||
|
|
||||||
|
/** 返回码 */ |
||||||
|
private String errorCode; |
||||||
|
|
||||||
|
/** 错误信息提示 */ |
||||||
|
private String errorMessage; |
||||||
|
|
||||||
|
private String traceId; |
||||||
|
} |
@ -0,0 +1,47 @@ |
|||||||
|
package com.jianshui.invoice.domain.yuande; |
||||||
|
|
||||||
|
import lombok.Data; |
||||||
|
|
||||||
|
import java.io.Serializable; |
||||||
|
import java.math.BigDecimal; |
||||||
|
|
||||||
|
@Data |
||||||
|
public class Invoiceformitem implements Serializable { |
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L; |
||||||
|
|
||||||
|
/** |
||||||
|
* 开票人(固定) |
||||||
|
*/ |
||||||
|
private String owner = "FSUID_5DCF10DE85AA29CF6ECF414C2F22F669"; |
||||||
|
|
||||||
|
/** |
||||||
|
* 数量 |
||||||
|
*/ |
||||||
|
private int quantity__c; |
||||||
|
|
||||||
|
/** |
||||||
|
* 开票单价 |
||||||
|
*/ |
||||||
|
private BigDecimal price__c; |
||||||
|
|
||||||
|
/** |
||||||
|
* 物料编码 |
||||||
|
*/ |
||||||
|
private String field_E01xD__c; |
||||||
|
|
||||||
|
/* |
||||||
|
* 开票单位 |
||||||
|
*/ |
||||||
|
private String unit__c; |
||||||
|
|
||||||
|
// private String id;
|
||||||
|
|
||||||
|
// private String name;
|
||||||
|
|
||||||
|
// private String InvoiceformId;
|
||||||
|
|
||||||
|
// private BigDecimal subTotal;
|
||||||
|
|
||||||
|
// private String remark;
|
||||||
|
} |
@ -0,0 +1,31 @@ |
|||||||
|
package com.jianshui.invoice.mapper.yuande; |
||||||
|
|
||||||
|
import com.jianshui.invoice.domain.yuande.Invoiceformitem; |
||||||
|
|
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
/*/** |
||||||
|
* @Author 一十七画生 |
||||||
|
* @Description 查询远得库开票信息明细 |
||||||
|
* @Date 2023/4/6 |
||||||
|
**/ |
||||||
|
public interface InvoiceFormItemMapper { |
||||||
|
/*/** |
||||||
|
* @Author 一十七画生 |
||||||
|
* @Description |
||||||
|
* @Date 2023/4/6 |
||||||
|
* @Param |
||||||
|
* @return 开票信息明细集合 |
||||||
|
**/ |
||||||
|
List<Invoiceformitem> findAllPushInfo(List<String> ids); |
||||||
|
|
||||||
|
/*/** |
||||||
|
* @Author 一十七画生 |
||||||
|
* @Description 跟据id查询远得系统内开票信息明细 |
||||||
|
* @Date 2023/4/7 |
||||||
|
* @Param |
||||||
|
* @return |
||||||
|
**/ |
||||||
|
List<Invoiceformitem> findAllPushInfoWithId(String id); |
||||||
|
|
||||||
|
} |
@ -0,0 +1,49 @@ |
|||||||
|
package com.jianshui.invoice.mapper.yuande; |
||||||
|
|
||||||
|
import com.jianshui.invoice.domain.dto.yuande.YuandeInvoiceFormDTO; |
||||||
|
import org.apache.ibatis.annotations.Param; |
||||||
|
|
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
/*/** |
||||||
|
* @Author 一十七画生 |
||||||
|
* @Description 查询远得系统数据库开票信息表 |
||||||
|
* @Date 2023/4/6 |
||||||
|
**/ |
||||||
|
public interface InvoiceFormMapper { |
||||||
|
|
||||||
|
/*/** |
||||||
|
* @Author 一十七画生 |
||||||
|
* @Description 查询总数 |
||||||
|
* @Date 2023/4/10 |
||||||
|
* @return |
||||||
|
**/ |
||||||
|
public long findTotal(@Param("date1") String date1,@Param("date2") String date2); |
||||||
|
|
||||||
|
/*/** |
||||||
|
* @Author 一十七画生 |
||||||
|
* @Description |
||||||
|
* @Date 2023/4/6 |
||||||
|
* @Param date1上一个日期,date2本次执行日期 |
||||||
|
* @return 开票信息集合 |
||||||
|
**/ |
||||||
|
public List<YuandeInvoiceFormDTO> findInvoiceFormListWithInvoiceFromItem(@Param("date1") String date1, @Param("date2") String date2); |
||||||
|
|
||||||
|
/*/** |
||||||
|
* @Author 一十七画生 |
||||||
|
* @Description |
||||||
|
* @Date 2023/4/6 |
||||||
|
* @Param date1上一个日期,date2本次执行日期 |
||||||
|
* @return 开票信息集合 |
||||||
|
**/ |
||||||
|
public List<YuandeInvoiceFormDTO> findInvoiceFormList(@Param("date1") String date1, @Param("date2") String date2); |
||||||
|
|
||||||
|
/*/** |
||||||
|
* @Author 一十七画生 |
||||||
|
* @Description |
||||||
|
* @Date 2023/4/6 |
||||||
|
* @Param date1上一个日期,date2本次执行日期 |
||||||
|
* @return 分页查询开票信息集合 |
||||||
|
**/ |
||||||
|
public List<YuandeInvoiceFormDTO> findInvoiceFormByPage(@Param("date1") String date1, @Param("date2") String date2, @Param("pageSize")int pageSize, @Param("currentPage")int currentPage); |
||||||
|
} |
@ -0,0 +1,195 @@ |
|||||||
|
package com.jianshui.invoice.service.impl.yuande; |
||||||
|
|
||||||
|
import cn.hutool.core.map.MapUtil; |
||||||
|
import com.alibaba.fastjson.JSONObject; |
||||||
|
import com.jianshui.invoice.domain.dto.yuande.YuandeInvoiceFormDTO; |
||||||
|
import com.jianshui.invoice.domain.yuande.CorpBody; |
||||||
|
import com.jianshui.invoice.domain.yuande.Invoiceformitem; |
||||||
|
import com.jianshui.invoice.mapper.yuande.InvoiceFormItemMapper; |
||||||
|
import com.jianshui.invoice.mapper.yuande.InvoiceFormMapper; |
||||||
|
import com.jianshui.invoice.service.yuande.IInvoiceFormService; |
||||||
|
import com.jianshui.invoice.utils.yuande.EntityToMap; |
||||||
|
import lombok.Data; |
||||||
|
import lombok.extern.slf4j.Slf4j; |
||||||
|
import org.apache.commons.lang3.ObjectUtils; |
||||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||||
|
import org.springframework.stereotype.Service; |
||||||
|
|
||||||
|
import java.text.DateFormat; |
||||||
|
import java.text.SimpleDateFormat; |
||||||
|
import java.util.*; |
||||||
|
import java.util.stream.Collectors; |
||||||
|
|
||||||
|
@Service |
||||||
|
@Slf4j |
||||||
|
@Data |
||||||
|
public class InvoiceFormServiceImpl implements IInvoiceFormService { |
||||||
|
@Autowired |
||||||
|
private InvoiceFormMapper invoiceFormMapper; |
||||||
|
@Autowired |
||||||
|
private InvoiceFormItemMapper invoiceFromItemMapper; |
||||||
|
|
||||||
|
/** 前一天日期 */ |
||||||
|
private static String date1; |
||||||
|
|
||||||
|
/** 后一天日期 */ |
||||||
|
private static String date2; |
||||||
|
|
||||||
|
/** |
||||||
|
* @Description 将所有信息封装一起 |
||||||
|
**/ |
||||||
|
@Override |
||||||
|
public JSONObject getPushInfo(CorpBody corpBody) { |
||||||
|
|
||||||
|
//判断参数是否为空
|
||||||
|
if (ObjectUtils.isEmpty(corpBody)){ |
||||||
|
return null; |
||||||
|
} |
||||||
|
//获取日期转换器
|
||||||
|
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); |
||||||
|
Date date = new Date(); |
||||||
|
//获取当天日期
|
||||||
|
date2 = dateFormat.format(date); |
||||||
|
//查询传输信息
|
||||||
|
List<YuandeInvoiceFormDTO> invoiceFormList = invoiceFormMapper.findInvoiceFormList(date1,date2); |
||||||
|
//date1转换为当天日期
|
||||||
|
date1 = date2; |
||||||
|
//获取所有开票信息的id集合
|
||||||
|
List<String> ids = invoiceFormList.stream().map(YuandeInvoiceFormDTO::getId).collect(Collectors.toList()); |
||||||
|
//将开票信息放入objectData
|
||||||
|
Map<String, Object> objectData = MapUtil.newHashMap(); |
||||||
|
objectData.put("object_data",invoiceFormList); |
||||||
|
//查询开票信息明细
|
||||||
|
List<Invoiceformitem> allPushInfo = invoiceFromItemMapper.findAllPushInfo(ids); |
||||||
|
//将开票信息明细放入到details
|
||||||
|
Map<String, Object> details = MapUtil.newHashMap(); |
||||||
|
details.put("Invoiceformitem__c",allPushInfo); |
||||||
|
//将objectData和details放入到data中
|
||||||
|
Map<String, Object> data = MapUtil.newHashMap(); |
||||||
|
data.put("object_data",objectData); |
||||||
|
data.put("details",details); |
||||||
|
//将信息放入到jsonobject中
|
||||||
|
JSONObject dataMap = new JSONObject(); |
||||||
|
dataMap.put("corpAccessToken",corpBody.getCorpAccessToken()); |
||||||
|
dataMap.put("corpId",corpBody.getCorpId()); |
||||||
|
dataMap.put("currentOpenUserId","FSUID_5DCF10DE85AA29CF6ECF414C2F22F669"); |
||||||
|
dataMap.put("data",data); |
||||||
|
//返回结果集
|
||||||
|
return dataMap; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* @Description 一条开票信息分装 |
||||||
|
**/ |
||||||
|
@Override |
||||||
|
public List<JSONObject> getPushInfos(CorpBody corpBody) { |
||||||
|
|
||||||
|
//判断参数是否为空
|
||||||
|
if (ObjectUtils.isEmpty(corpBody)){ |
||||||
|
log.info("传入应用授权参数为空"); |
||||||
|
return null; |
||||||
|
} |
||||||
|
//获取日期转换器
|
||||||
|
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); |
||||||
|
Date date = new Date(); |
||||||
|
//获取当天日期
|
||||||
|
date2 = dateFormat.format(date); |
||||||
|
//查询开票信息
|
||||||
|
List<YuandeInvoiceFormDTO> invoiceFormList = invoiceFormMapper.findInvoiceFormListWithInvoiceFromItem(date1,date2); |
||||||
|
//date1转换为当天日期
|
||||||
|
date1 = date2; |
||||||
|
if (Objects.isNull(invoiceFormList)){ |
||||||
|
log.info("查询到的开票信息表为空"); |
||||||
|
return null; |
||||||
|
} |
||||||
|
//创建一个list封装返回值
|
||||||
|
List<JSONObject> list = new ArrayList<>(); |
||||||
|
for (YuandeInvoiceFormDTO invoiceFromDTO : invoiceFormList) { |
||||||
|
|
||||||
|
//details信息封装
|
||||||
|
HashMap<String, Object> details = MapUtil.newHashMap(); |
||||||
|
details.put("Invoiceformitem__c",invoiceFromDTO.getInvoiceformitems()); |
||||||
|
|
||||||
|
//objectData封装
|
||||||
|
Map<String, Object> objectData = EntityToMap.toMap(invoiceFromDTO); |
||||||
|
objectData.remove("invoiceformitems"); |
||||||
|
//data数据封装
|
||||||
|
HashMap<String, Object> data = MapUtil.newHashMap(); |
||||||
|
data.put("object_data",objectData); |
||||||
|
data.put("details",details); |
||||||
|
//创建返回json
|
||||||
|
JSONObject dataMap = new JSONObject(); |
||||||
|
//添加认证信息
|
||||||
|
dataMap.put("corpAccessToken",corpBody.getCorpAccessToken()); |
||||||
|
dataMap.put("corpId",corpBody.getCorpId()); |
||||||
|
dataMap.put("currentOpenUserId","FSUID_5DCF10DE85AA29CF6ECF414C2F22F669"); |
||||||
|
dataMap.put("data",data); |
||||||
|
|
||||||
|
//将数据添加到集合
|
||||||
|
list.add(dataMap); |
||||||
|
} |
||||||
|
|
||||||
|
return list; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* @Description 分页进行封装 |
||||||
|
**/ |
||||||
|
@Override |
||||||
|
public List<JSONObject> getPushInfo(CorpBody corpBody, int pageSize) { |
||||||
|
|
||||||
|
//判断参数是否为空
|
||||||
|
if (ObjectUtils.isEmpty(corpBody)){ |
||||||
|
log.info("传入应用授权参数为空"); |
||||||
|
return null; |
||||||
|
} |
||||||
|
//获取日期转换器
|
||||||
|
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); |
||||||
|
Date date = new Date(); |
||||||
|
//获取当天日期
|
||||||
|
date2 = dateFormat.format(date); |
||||||
|
//查询信息总数
|
||||||
|
long total = invoiceFormMapper.findTotal(date1, date2); |
||||||
|
//计算总页数
|
||||||
|
int pageTotal = (int) (total % pageSize == 0 ? total / pageSize:total / pageSize+1); |
||||||
|
//当前页数
|
||||||
|
int currentPage = 1; |
||||||
|
//创建集合
|
||||||
|
List<JSONObject> list = new ArrayList<>(); |
||||||
|
for (int i = 0; i < pageTotal; i++) { |
||||||
|
//查询传输信息
|
||||||
|
List<YuandeInvoiceFormDTO> invoiceFormList = invoiceFormMapper.findInvoiceFormByPage(date1,date2,pageSize,(currentPage-1)*pageSize); |
||||||
|
//判断查询信息是否为空
|
||||||
|
if (ObjectUtils.isEmpty(invoiceFormList)) { |
||||||
|
log.info("查询到开票信息为空"); |
||||||
|
return null; |
||||||
|
} |
||||||
|
//获取开票信息id集合
|
||||||
|
List<String> ids = invoiceFormList.stream().map(YuandeInvoiceFormDTO::getId).collect(Collectors.toList()); |
||||||
|
//将开票信息放入objectData
|
||||||
|
Map<String, Object> objectData = MapUtil.newHashMap(); |
||||||
|
objectData.put("object_data",invoiceFormList); |
||||||
|
//查询开票信息明细
|
||||||
|
List<Invoiceformitem> invoiceformitems = invoiceFromItemMapper.findAllPushInfo(ids); |
||||||
|
//将开票信息明细放入到details
|
||||||
|
Map<String, Object> details = MapUtil.newHashMap(); |
||||||
|
details.put("Invoiceformitem__c",invoiceformitems); |
||||||
|
//将objectData和details放入到data中
|
||||||
|
Map<String, Object> data = MapUtil.newHashMap(); |
||||||
|
data.put("object_data",objectData); |
||||||
|
data.put("details",details); |
||||||
|
//将信息放入到jsonobject中
|
||||||
|
JSONObject dataMap = new JSONObject(); |
||||||
|
dataMap.put("corpAccessToken",corpBody.getCorpAccessToken()); |
||||||
|
dataMap.put("corpId",corpBody.getCorpId()); |
||||||
|
dataMap.put("currentOpenUserId","FSUID_5DCF10DE85AA29CF6ECF414C2F22F669"); |
||||||
|
dataMap.put("data",data); |
||||||
|
list.add(dataMap); |
||||||
|
//当前页进入下一页
|
||||||
|
currentPage++; |
||||||
|
} |
||||||
|
//date1转换为当天日期
|
||||||
|
date1 = date2; |
||||||
|
return list; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,36 @@ |
|||||||
|
package com.jianshui.invoice.service.yuande; |
||||||
|
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject; |
||||||
|
import com.jianshui.invoice.domain.yuande.CorpBody; |
||||||
|
|
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
public interface IInvoiceFormService { |
||||||
|
/*/** |
||||||
|
* @Author 一十七画生 |
||||||
|
* @Description |
||||||
|
* @Date 2023/4/6 |
||||||
|
* @Param cropBody |
||||||
|
* @return 封装 |
||||||
|
**/ |
||||||
|
JSONObject getPushInfo(CorpBody corpBody); |
||||||
|
|
||||||
|
/*/** |
||||||
|
* @Author 一十七画生 |
||||||
|
* @Description 将所需报文封装到list |
||||||
|
* @Date 2023/4/7 |
||||||
|
* @Param CorpBody |
||||||
|
* @return |
||||||
|
**/ |
||||||
|
List<JSONObject> getPushInfos(CorpBody corpBody); |
||||||
|
|
||||||
|
/*/** |
||||||
|
* @Author 一十七画生 |
||||||
|
* @Description 分页查询开票信息表 |
||||||
|
* @Date 2023/4/10 |
||||||
|
* @Param 认证授权参数,分页大小 |
||||||
|
* @return |
||||||
|
**/ |
||||||
|
List<JSONObject> getPushInfo(CorpBody corpBody, int pageSize); |
||||||
|
} |
@ -0,0 +1,128 @@ |
|||||||
|
package com.jianshui.invoice.task.yuande; |
||||||
|
|
||||||
|
import cn.hutool.http.HttpUtil; |
||||||
|
import cn.hutool.json.JSONUtil; |
||||||
|
import com.alibaba.fastjson.JSONObject; |
||||||
|
import com.jianshui.invoice.domain.yuande.CorpBody; |
||||||
|
import com.jianshui.invoice.service.yuande.IInvoiceFormService; |
||||||
|
import lombok.extern.slf4j.Slf4j; |
||||||
|
import org.springframework.beans.factory.annotation.Autowired; |
||||||
|
import org.springframework.stereotype.Component; |
||||||
|
|
||||||
|
import java.util.List; |
||||||
|
import java.util.Objects; |
||||||
|
|
||||||
|
@Component("yuanDeInformPushShuYuTask") |
||||||
|
@Slf4j |
||||||
|
public class YuanDeInformPushShuYuTask { |
||||||
|
|
||||||
|
@Autowired |
||||||
|
private IInvoiceFormService invoiceFormService; |
||||||
|
|
||||||
|
/** |
||||||
|
* @Author 路明慧 |
||||||
|
* @Description 将开票信息表一次性发送 |
||||||
|
* @Date 2023/4/10 |
||||||
|
**/ |
||||||
|
public void infoPushAllMap(){ |
||||||
|
//请求接口路径
|
||||||
|
String url= "https://open.fxiaoke.com/cgi/corpAccessToken/get/V2"; |
||||||
|
//请求参数封装
|
||||||
|
JSONObject paramMap = new JSONObject(); |
||||||
|
paramMap.put("appId","FSAID_131be20"); |
||||||
|
paramMap.put("appSecret","78db04ad63c645609d0b05127fe73715"); |
||||||
|
paramMap.put("permanentCode","C1A6DFC2DFDEC79CECC207D00658DBF3"); |
||||||
|
//发送请求
|
||||||
|
String respRaw = HttpUtil.createPost(url).body(paramMap.toString()).execute().body(); |
||||||
|
//返回报文封装实体
|
||||||
|
CorpBody corpBody = JSONUtil.toBean(respRaw, CorpBody.class); |
||||||
|
//获取要传输的报文信息
|
||||||
|
JSONObject pushInfo = invoiceFormService.getPushInfo(corpBody); |
||||||
|
//调用对方接口完成信息推送
|
||||||
|
String url1 = "https://open.fxiaoke.com/cgi/crm/custom/v2/data/create"; |
||||||
|
HttpUtil.createPost(url1).body(pushInfo.toString()).execute().body(); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* @Author 路明慧 |
||||||
|
* @Description 将开票信息表每次一条记录 |
||||||
|
* @Date 2023/4/10 |
||||||
|
**/ |
||||||
|
public void infoPush(){ |
||||||
|
log.info("开始执行推送远得数据的定时任务"); |
||||||
|
//请求接口路径
|
||||||
|
String url1= "https://open.fxiaoke.com/cgi/corpAccessToken/get/V2"; |
||||||
|
//请求参数封装
|
||||||
|
JSONObject paramMap = new JSONObject(); |
||||||
|
paramMap.put("appId","FSAID_131be20"); |
||||||
|
paramMap.put("appSecret","78db04ad63c645609d0b05127fe73715"); |
||||||
|
paramMap.put("permanentCode","C1A6DFC2DFDEC79CECC207D00658DBF3"); |
||||||
|
//发送请求
|
||||||
|
String respRaw = HttpUtil.createPost(url1).body(paramMap.toString()).execute().body(); |
||||||
|
//返回报文封装实体
|
||||||
|
CorpBody corpBody = JSONUtil.toBean(respRaw, CorpBody.class); |
||||||
|
if ("success".equals(corpBody.getErrorMessage())){ |
||||||
|
log.info("获取应用授权成功"); |
||||||
|
}else { |
||||||
|
log.info("获取应用授权失败:"+corpBody.getErrorMessage()); |
||||||
|
} |
||||||
|
//信息传输接口
|
||||||
|
String url2 = "https://open.fxiaoke.com/cgi/crm/custom/v2/data/create"; |
||||||
|
//获取要传输的报文信息
|
||||||
|
List<JSONObject> pushInfos = invoiceFormService.getPushInfos(corpBody); |
||||||
|
//判断参数是否为空
|
||||||
|
if (!Objects.isNull(pushInfos)){ |
||||||
|
for (int i = 0; i < pushInfos.size(); i++) { |
||||||
|
//调用对方接口完成信息推送
|
||||||
|
HttpUtil.createPost(url2).body(pushInfos.get(i).toString()).execute().body(); |
||||||
|
try { |
||||||
|
Thread.sleep(50); |
||||||
|
} catch (InterruptedException e) { |
||||||
|
e.printStackTrace(); |
||||||
|
log.info("线程休眠异常"); |
||||||
|
} |
||||||
|
} |
||||||
|
log.info("任务完成"); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
public void infoPushLimit(int pageSize){ |
||||||
|
log.info("开始执行推送远得数据的定时任务"); |
||||||
|
//获取应用授权的url
|
||||||
|
String url1 = "https://open.fxiaoke.com/cgi/corpAccessToken/get/V2"; |
||||||
|
//封装认证所需要的参数
|
||||||
|
JSONObject paramMap = new JSONObject(); |
||||||
|
paramMap.put("appId","FSAID_131be20"); |
||||||
|
paramMap.put("appSecret","78db04ad63c645609d0b05127fe73715"); |
||||||
|
paramMap.put("permanentCode","C1A6DFC2DFDEC79CECC207D00658DBF3"); |
||||||
|
//获取应用授权
|
||||||
|
String respRaw = HttpUtil.createPost(url1).body(paramMap.toString()).execute().body(); |
||||||
|
//反序列化为实体
|
||||||
|
CorpBody corpBody = JSONUtil.toBean(respRaw, CorpBody.class); |
||||||
|
if ("success".equals(corpBody.getErrorMessage())){ |
||||||
|
log.info("获取应用授权成功"); |
||||||
|
}else { |
||||||
|
log.info("获取应用授权失败:"+corpBody.getErrorMessage()); |
||||||
|
} |
||||||
|
//获取推送信息集合
|
||||||
|
List<JSONObject> jsonObjects = invoiceFormService.getPushInfo(corpBody, pageSize); |
||||||
|
//判断是否为空
|
||||||
|
if (!jsonObjects.isEmpty()) { |
||||||
|
log.info("任务开始执行"); |
||||||
|
//信息传输接口
|
||||||
|
String url2 = "https://open.fxiaoke.com/cgi/crm/custom/v2/data/create"; |
||||||
|
for (JSONObject jsonObject: jsonObjects) { |
||||||
|
//调用对方接口完成信息推送
|
||||||
|
HttpUtil.createPost(url2).body(jsonObject.toString()).execute().body(); |
||||||
|
try { |
||||||
|
Thread.sleep(1000); |
||||||
|
} catch (InterruptedException e) { |
||||||
|
e.printStackTrace(); |
||||||
|
log.info("线程休眠异常"); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
log.info("任务完成"); |
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -0,0 +1,25 @@ |
|||||||
|
package com.jianshui.invoice.utils.yuande; |
||||||
|
|
||||||
|
import java.lang.reflect.Field; |
||||||
|
import java.util.HashMap; |
||||||
|
import java.util.Map; |
||||||
|
|
||||||
|
public class EntityToMap { |
||||||
|
|
||||||
|
//将实体转化成map
|
||||||
|
public static Map<String,Object> toMap(Object object){ |
||||||
|
Map<String, Object> map = new HashMap<>(); |
||||||
|
for (Field field : object.getClass().getDeclaredFields()) { |
||||||
|
try { |
||||||
|
boolean flag = field.isAccessible(); |
||||||
|
field.setAccessible(true); |
||||||
|
Object o = field.get(object); |
||||||
|
map.put(field.getName(), o); |
||||||
|
field.setAccessible(flag); |
||||||
|
} catch (Exception e) { |
||||||
|
e.printStackTrace(); |
||||||
|
} |
||||||
|
} |
||||||
|
return map; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,35 @@ |
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?> |
||||||
|
<!DOCTYPE mapper |
||||||
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" |
||||||
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||||
|
<mapper namespace="com.jianshui.invoice.mapper.yuande.InvoiceFormItemMapper"> |
||||||
|
|
||||||
|
<resultMap id="invoiceFromItem" type="com.jianshui.invoice.domain.yuande.Invoiceformitem"> |
||||||
|
<result column="quantity" property="quantity__c"></result> |
||||||
|
<result column="price" property="price__c"></result> |
||||||
|
<result column="unit" property="unit__c"></result> |
||||||
|
<result column="product" property="field_E01xD__c"></result> |
||||||
|
</resultMap> |
||||||
|
<!-- 查询所有--> |
||||||
|
<select id="findAllPushInfo" resultMap="invoiceFromItem" parameterType="list"> |
||||||
|
select quantity, |
||||||
|
price, |
||||||
|
unit, |
||||||
|
product |
||||||
|
from invoiceformitem |
||||||
|
where invoiceformid in |
||||||
|
<foreach collection="invoiceformids" item="invoiceformid" separator="," close=")" open="("> |
||||||
|
#{invoiceformid} |
||||||
|
</foreach> |
||||||
|
</select> |
||||||
|
|
||||||
|
<!-- 跟据invoiceformid查询所有--> |
||||||
|
<select id="findAllPushInfoWithId" parameterType="string" resultMap="invoiceFromItem"> |
||||||
|
select quantity, |
||||||
|
price, |
||||||
|
unit, |
||||||
|
product |
||||||
|
from invoiceformitem |
||||||
|
where invoiceformid = #{id} |
||||||
|
</select> |
||||||
|
</mapper> |
@ -0,0 +1,143 @@ |
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?> |
||||||
|
<!DOCTYPE mapper |
||||||
|
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" |
||||||
|
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
||||||
|
<mapper namespace="com.jianshui.invoice.mapper.yuande.InvoiceFormMapper"> |
||||||
|
|
||||||
|
<!--两表联查--> |
||||||
|
<resultMap id="invoiceFromVoWithItem" type="com.jianshui.invoice.domain.dto.yuande.YuandeInvoiceFormDTO"> |
||||||
|
<result property="customer__c" column="customer"></result> |
||||||
|
<result property="salesorderid__c" column="salesorderid"></result> |
||||||
|
<result property="fptt__c" column="fptt"></result> |
||||||
|
<result property="fkdwkhyh__c" column="fkdwkhyh"></result> |
||||||
|
<result property="fkdwyhzh__c" column="fkdwyhzh"></result> |
||||||
|
<result property="fkdwdz__c" column="fkdwdz"></result> |
||||||
|
<result property="fkdwdh__c" column="fkdwdh"></result> |
||||||
|
<result property="tyshxydm__c" column="tyshxydm"></result> |
||||||
|
<result property="kprq__c" column="kprq"></result> |
||||||
|
<result property="fphm__c" column="fphm"></result> |
||||||
|
<result property="field_91Rds__c" column="bz"></result> |
||||||
|
<result property="taxrate__c" column="taxrate"></result> |
||||||
|
<collection property="invoiceformitems" ofType="com.jianshui.invoice.domain.yuande.Invoiceformitem"> |
||||||
|
<result property="quantity__c" column="quantity"></result> |
||||||
|
<result property="price__c" column="price"></result> |
||||||
|
<result property="field_E01xD__c" column="product"></result> |
||||||
|
<result property="unit__c" column="unit"></result> |
||||||
|
</collection> |
||||||
|
</resultMap> |
||||||
|
<select id="findInvoiceFormListWithInvoiceFromItem" resultMap="invoiceFromVoWithItem"> |
||||||
|
select |
||||||
|
invoiceform.customer customer, |
||||||
|
invoiceform.salesorderid salesorderid, |
||||||
|
invoiceform.fptt fptt, |
||||||
|
invoiceform.fkdwkhyh fkdwkhyh, |
||||||
|
invoiceform.fkdwyhzh fkdwyhzh, |
||||||
|
invoiceform.fkdwdz fkdwdz, |
||||||
|
invoiceform.fkdwdh fkdwdh, |
||||||
|
invoiceform.tyshxydm tyshxydm, |
||||||
|
invoiceform.kprq kprq, |
||||||
|
invoiceform.fphm fphm, |
||||||
|
invoiceform.bz bz, |
||||||
|
invoiceform.taxrate taxrate, |
||||||
|
invoiceformitem.quantity quantity, |
||||||
|
invoiceformitem.price price, |
||||||
|
invoiceformitem.product product, |
||||||
|
invoiceformitem.unit unit |
||||||
|
from invoiceform left join invoiceformitem |
||||||
|
on invoiceform.id = invoiceformitem.id |
||||||
|
<where> |
||||||
|
<if test="date1 != null || date1 != ''"> |
||||||
|
and DATE(invoiceform.kprq) > #{date1} |
||||||
|
</if> |
||||||
|
<if test="date2 != null || date2 != ''"> |
||||||
|
and #{date2} >= DATE(invoiceform.kprq) |
||||||
|
</if> |
||||||
|
and LENGTH(invoiceform.customer)>=3 |
||||||
|
and invoiceform.tyshxydm is not null |
||||||
|
</where> |
||||||
|
</select> |
||||||
|
|
||||||
|
<!-- 单表查询开票信息表--> |
||||||
|
<resultMap id="invoiceFrom" type="com.jianshui.invoice.domain.dto.yuande.YuandeInvoiceFormDTO"> |
||||||
|
<result property="customer__c" column="customer"></result> |
||||||
|
<result property="salesorderid__c" column="salesorderid"></result> |
||||||
|
<result property="fptt__c" column="fptt"></result> |
||||||
|
<result property="fkdwkhyh__c" column="fkdwkhyh"></result> |
||||||
|
<result property="fkdwyhzh__c" column="fkdwyhzh"></result> |
||||||
|
<result property="fkdwdz__c" column="fkdwdz"></result> |
||||||
|
<result property="fkdwdh__c" column="fkdwdh"></result> |
||||||
|
<result property="tyshxydm__c" column="tyshxydm"></result> |
||||||
|
<result property="kprq__c" column="kprq"></result> |
||||||
|
<result property="fphm__c" column="fphm"></result> |
||||||
|
<result property="field_91Rds__c" column="bz"></result> |
||||||
|
<result property="taxrate__c" column="taxrate"></result> |
||||||
|
</resultMap> |
||||||
|
<select id="findInvoiceFormList" resultMap="invoiceFrom"> |
||||||
|
select |
||||||
|
customer, |
||||||
|
salesorderid, |
||||||
|
fptt, |
||||||
|
fkdwkhyh, |
||||||
|
fkdwyhzh, |
||||||
|
fkdwdz, |
||||||
|
fkdwdh, |
||||||
|
tyshxydm, |
||||||
|
kprq, |
||||||
|
fphm, |
||||||
|
bz, |
||||||
|
taxrate |
||||||
|
from invoiceform |
||||||
|
<where> |
||||||
|
<if test="date1 != null || date1 != ''"> |
||||||
|
and DATE(invoiceform.kprq) > #{date1} |
||||||
|
</if> |
||||||
|
<if test="date2 != null || date2 != ''"> |
||||||
|
and #{date2} >= DATE(invoiceform.kprq) |
||||||
|
</if> |
||||||
|
and LENGTH(invoiceform.customer)>=3 |
||||||
|
and invoiceform.tyshxydm is not null |
||||||
|
</where> |
||||||
|
</select> |
||||||
|
<!-- 分页查询--> |
||||||
|
<select id="findInvoiceFormByPage" resultMap="invoiceFrom"> |
||||||
|
select |
||||||
|
customer, |
||||||
|
salesorderid, |
||||||
|
fptt, |
||||||
|
fkdwkhyh, |
||||||
|
fkdwyhzh, |
||||||
|
fkdwdz, |
||||||
|
fkdwdh, |
||||||
|
tyshxydm, |
||||||
|
kprq, |
||||||
|
fphm, |
||||||
|
bz, |
||||||
|
taxrate |
||||||
|
from invoiceform |
||||||
|
<where> |
||||||
|
<if test="date1 != null || date1 != ''"> |
||||||
|
and DATE(invoiceform.kprq) > #{date1} |
||||||
|
</if> |
||||||
|
<if test="date2 != null || date2 != ''"> |
||||||
|
and #{date2} >= DATE(invoiceform.kprq) |
||||||
|
</if> |
||||||
|
and LENGTH(invoiceform.customer)>=3 |
||||||
|
and invoiceform.tyshxydm is not null |
||||||
|
</where> |
||||||
|
limit #{currentPage},#{pageSize} |
||||||
|
</select> |
||||||
|
<!-- 查询总数--> |
||||||
|
<select id="findTotal" resultType="long"> |
||||||
|
select count(*) from invoiceform |
||||||
|
<where> |
||||||
|
<if test="date1 != null || date1 != ''"> |
||||||
|
and DATE(invoiceform.kprq) > #{date1} |
||||||
|
</if> |
||||||
|
<if test="date2 != null || date2 != ''"> |
||||||
|
and #{date2} >= DATE(invoiceform.kprq) |
||||||
|
</if> |
||||||
|
and LENGTH(invoiceform.customer)>=3 |
||||||
|
and invoiceform.tyshxydm is not null |
||||||
|
</where> |
||||||
|
</select> |
||||||
|
</mapper> |
Loading…
Reference in new issue