发票批量导入改成定时任务执行
This commit is contained in:
parent
a73e35f006
commit
fdad19b0cc
|
@ -20,6 +20,10 @@ public class CInvoiceImportHEntity extends BaseEntity {
|
|||
private String yd_result;
|
||||
//发起时间
|
||||
private String start_date;
|
||||
//推送状态
|
||||
private String push_status;
|
||||
//推送字段
|
||||
private String push_field;
|
||||
|
||||
public String getTab_name() {
|
||||
return tab_name;
|
||||
|
@ -68,4 +72,20 @@ public class CInvoiceImportHEntity extends BaseEntity {
|
|||
public void setStart_date(String start_date) {
|
||||
this.start_date = start_date;
|
||||
}
|
||||
|
||||
public String getPush_status() {
|
||||
return push_status;
|
||||
}
|
||||
|
||||
public void setPush_status(String push_status) {
|
||||
this.push_status = push_status;
|
||||
}
|
||||
|
||||
public String getPush_field() {
|
||||
return push_field;
|
||||
}
|
||||
|
||||
public void setPush_field(String push_field) {
|
||||
this.push_field = push_field;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
<result property="yd_res_field" column="yd_res_field" />
|
||||
<result property="bill_type" column="bill_type" />
|
||||
<result property="bill_code" column="bill_code" />
|
||||
<result property="push_status" column="push_status" />
|
||||
<result property="push_field" column="push_field" />
|
||||
<result property="start_date" column="start_date" />
|
||||
|
||||
</resultMap>
|
||||
|
@ -16,10 +18,16 @@
|
|||
<trim prefix="where" prefixOverrides="and">
|
||||
<if test="id != null and id != ''">f.id = #{id}</if>
|
||||
<if test="bill_code != null and bill_code != ''">and f.bill_code = #{bill_code}</if>
|
||||
and push_status is null
|
||||
and start_date >= '2025-05-26'
|
||||
</trim>
|
||||
</select>
|
||||
|
||||
<update id="entity_update" parameterType="com.hzya.frame.plugin.cinvoice.entity.CInvoiceImportHEntity">
|
||||
update ${tab_name} set ${yd_res_field} = #{yd_result} where id = #{id}
|
||||
</update>
|
||||
|
||||
<update id="entity_update_status" parameterType="com.hzya.frame.plugin.cinvoice.entity.CInvoiceImportHEntity">
|
||||
update ${tab_name} set ${push_field} = '1' where id = #{id}
|
||||
</update>
|
||||
</mapper>
|
||||
|
|
|
@ -26,4 +26,11 @@ public interface ICInvoiceImportHService extends IBaseService<CInvoiceImportHEnt
|
|||
* @return
|
||||
*/
|
||||
int updateResultId(CInvoiceImportHEntity entity);
|
||||
|
||||
/**
|
||||
* 更新推送标记
|
||||
* @param entity
|
||||
* @return
|
||||
*/
|
||||
int updateStatus(CInvoiceImportHEntity entity);
|
||||
}
|
||||
|
|
|
@ -61,4 +61,22 @@ public class CInvoiceImportHServiceImpl extends BaseService<CInvoiceImportHEntit
|
|||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新推送标记
|
||||
*
|
||||
* @param entity
|
||||
* @return
|
||||
*/
|
||||
@DS("#entity.dataSourceCode")
|
||||
@Override
|
||||
public int updateStatus(CInvoiceImportHEntity entity) {
|
||||
if (null != entity
|
||||
&& StrUtil.isNotEmpty(entity.getTab_name())
|
||||
&& StrUtil.isNotEmpty(entity.getPush_field())){
|
||||
int updateRows = cInvoiceImportHDao.update("com.hzya.frame.plugin.cinvoice.dao.impl.CInvoiceImportHDaoImpl.entity_update_status", entity);
|
||||
return updateRows;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,6 +59,7 @@ public class CInvoiceImportPluginServiceImpl implements ICInvoiceImportPluginSer
|
|||
private IIntegrationTaskLivingDetailsService taskLivingDetailsService;
|
||||
@Value("${zt.url:}")
|
||||
private String url;
|
||||
|
||||
/**
|
||||
* 发票导入
|
||||
*
|
||||
|
@ -72,119 +73,125 @@ public class CInvoiceImportPluginServiceImpl implements ICInvoiceImportPluginSer
|
|||
|
||||
//1、 查OA主表
|
||||
String dataSourceCode = requestJson.getString("sourceCode");
|
||||
if (StrUtil.isEmpty(dataSourceCode)){
|
||||
if (StrUtil.isEmpty(dataSourceCode)) {
|
||||
dataSourceCode = requestJson.getString("apiDataSourceCode");
|
||||
}
|
||||
String id = requestJson.getString("id");//主表id
|
||||
if (StrUtil.isEmpty(id)){
|
||||
throw new BaseSystemException("id不能为空");
|
||||
}
|
||||
String id = requestJson.getString("id");//主表id 测试的时候用
|
||||
CInvoiceImportHEntity importHEntity = new CInvoiceImportHEntity();
|
||||
importHEntity.setDataSourceCode(dataSourceCode);
|
||||
importHEntity.setId(id);
|
||||
List<CInvoiceImportHEntity> cInvoiceImportHList = cInvoiceImportHService.queryInvoiceList(importHEntity);
|
||||
if (CollectionUtils.isNotEmpty(cInvoiceImportHList)){
|
||||
if (CollectionUtils.isNotEmpty(cInvoiceImportHList)) {
|
||||
ParamAssembler assembler = null;
|
||||
CInvoiceImportHEntity cInvoiceH = cInvoiceImportHList.get(0);
|
||||
cInvoiceH.setDataSourceCode(dataSourceCode);
|
||||
//2、 查OA明细表
|
||||
//3、 查迈瑞思发票表
|
||||
//迈锐思发票公共信息表
|
||||
LexmisPublicinfoEntity lexmisPublicinfoEntity = new LexmisPublicinfoEntity(cInvoiceH.getId(),dataSourceCode);
|
||||
LexmisPublicinfoEntity lexmisPublicinfoEntity = new LexmisPublicinfoEntity(cInvoiceH.getId(), dataSourceCode);
|
||||
//lexmisPublicinfoEntity.setPI_ID("6952494198841691018");
|
||||
List<LexmisPublicinfoEntity> lexmisPublicinfoEntityList = lexmisPublicinfoService.query(lexmisPublicinfoEntity);
|
||||
if (CollectionUtils.isNotEmpty(lexmisPublicinfoEntityList)){
|
||||
if (CollectionUtils.isNotEmpty(lexmisPublicinfoEntityList)) {
|
||||
cInvoiceH.setPush_status("1");
|
||||
cInvoiceImportHService.updateStatus(cInvoiceH);
|
||||
//税务接口每次最多传50张发票
|
||||
int size = lexmisPublicinfoEntityList.size();
|
||||
int batchSize = 50;
|
||||
for (int i = 0; i < size; i += batchSize){
|
||||
int no = 1;//序号
|
||||
//4、 根据发票类型,组装不同参数
|
||||
JSONObject head = new JSONObject();
|
||||
JSONArray inputInfos = new JSONArray();
|
||||
head.put("inputInfos",inputInfos);//发票录入信息,单次最大50张
|
||||
// 获取当前批次的子列表
|
||||
List<LexmisPublicinfoEntity> batchList = lexmisPublicinfoEntityList.subList(i, Math.min(i + batchSize, size));
|
||||
//使用stream方式 publicinfoList 按 PI_TABLENAME分组
|
||||
Map<String, List<LexmisPublicinfoEntity>> groupedByPiTablename = batchList.stream()
|
||||
.collect(Collectors.groupingBy(LexmisPublicinfoEntity::getPI_TABLENAME));
|
||||
for (Map.Entry<String,List<LexmisPublicinfoEntity>> entry : groupedByPiTablename.entrySet()){
|
||||
String key = entry.getKey();//对应发票类型的表名
|
||||
List<LexmisPublicinfoEntity> publicinfoList = entry.getValue();
|
||||
for (LexmisPublicinfoEntity info : publicinfoList){
|
||||
for (int i = 0; i < size; i += batchSize) {
|
||||
try {
|
||||
int no = 1;//序号
|
||||
//4、 根据发票类型,组装不同参数
|
||||
JSONObject head = new JSONObject();
|
||||
JSONArray inputInfos = new JSONArray();
|
||||
head.put("inputInfos", inputInfos);//发票录入信息,单次最大50张
|
||||
// 获取当前批次的子列表
|
||||
List<LexmisPublicinfoEntity> batchList = lexmisPublicinfoEntityList.subList(i, Math.min(i + batchSize, size));
|
||||
//使用stream方式 publicinfoList 按 PI_TABLENAME分组
|
||||
Map<String, List<LexmisPublicinfoEntity>> groupedByPiTablename = batchList.stream()
|
||||
.collect(Collectors.groupingBy(LexmisPublicinfoEntity::getPI_TABLENAME));
|
||||
for (Map.Entry<String, List<LexmisPublicinfoEntity>> entry : groupedByPiTablename.entrySet()) {
|
||||
String key = entry.getKey();//对应发票类型的表名
|
||||
List<LexmisPublicinfoEntity> publicinfoList = entry.getValue();
|
||||
for (LexmisPublicinfoEntity info : publicinfoList) {
|
||||
|
||||
JSONObject inputInfo = new JSONObject();
|
||||
inputInfos.add(inputInfo);
|
||||
inputInfo.put("no",no);//编号
|
||||
inputInfo.put("systemName","4");//来源系统 默认写4 代表OA
|
||||
inputInfo.put("businessNo",cInvoiceH.getBill_code());//业务单据号
|
||||
inputInfo.put("bookkeepingStatus","1");//记账状态,默认传1
|
||||
inputInfo.put("customFlag","2");//业务流转状态,默认传2
|
||||
JSONObject invoiceInfo = new JSONObject();//票面信息
|
||||
inputInfo.put("invoiceInfo", invoiceInfo);
|
||||
JSONObject baseInfo = new JSONObject();//发票基本信息
|
||||
JSONObject contentInfo = new JSONObject();//发票内容
|
||||
JSONArray taxturnsInfos = new JSONArray();//进项转出信息
|
||||
invoiceInfo.put("taxturnsInfos",taxturnsInfos);
|
||||
JSONObject inputInfo = new JSONObject();
|
||||
inputInfos.add(inputInfo);
|
||||
inputInfo.put("no", no);//编号
|
||||
inputInfo.put("systemName", "4");//来源系统 默认写4 代表OA
|
||||
inputInfo.put("businessNo", cInvoiceH.getBill_code());//业务单据号
|
||||
inputInfo.put("bookkeepingStatus", "1");//记账状态,默认传1
|
||||
inputInfo.put("customFlag", "2");//业务流转状态,默认传2
|
||||
JSONObject invoiceInfo = new JSONObject();//票面信息
|
||||
inputInfo.put("invoiceInfo", invoiceInfo);
|
||||
JSONObject baseInfo = new JSONObject();//发票基本信息
|
||||
JSONObject contentInfo = new JSONObject();//发票内容
|
||||
JSONArray taxturnsInfos = new JSONArray();//进项转出信息
|
||||
invoiceInfo.put("taxturnsInfos", taxturnsInfos);
|
||||
|
||||
switch (key){
|
||||
case "LEXMISCIV_INVOICEMAIN"://增值税发票
|
||||
zzsInvoice(dataSourceCode, info, invoiceInfo, baseInfo);
|
||||
break;
|
||||
case "LEXMISCIV_TRAINTICKET"://火车票
|
||||
trainInvoice(dataSourceCode, inputInfos, info, inputInfo, invoiceInfo, baseInfo);
|
||||
break;
|
||||
case "LEXMISCIV_PLANETICKET"://飞机行程单
|
||||
planeInvoice(dataSourceCode, info, invoiceInfo, baseInfo);
|
||||
break;
|
||||
case "LEXMISCIV_BUSINVOICE"://客运汽车票
|
||||
busInvoice(dataSourceCode, info, invoiceInfo, baseInfo);
|
||||
break;
|
||||
default:
|
||||
logger.info("没有匹配到类型");
|
||||
break;
|
||||
switch (key) {
|
||||
case "LEXMISCIV_INVOICEMAIN"://增值税发票
|
||||
zzsInvoice(dataSourceCode, info, invoiceInfo, baseInfo);
|
||||
break;
|
||||
case "LEXMISCIV_TRAINTICKET"://火车票
|
||||
trainInvoice(dataSourceCode, inputInfos, info, inputInfo, invoiceInfo, baseInfo);
|
||||
break;
|
||||
case "LEXMISCIV_PLANETICKET"://飞机行程单
|
||||
planeInvoice(dataSourceCode, info, invoiceInfo, baseInfo);
|
||||
break;
|
||||
case "LEXMISCIV_BUSINVOICE"://客运汽车票
|
||||
busInvoice(dataSourceCode, info, invoiceInfo, baseInfo);
|
||||
break;
|
||||
default:
|
||||
logger.info("没有匹配到类型");
|
||||
break;
|
||||
}
|
||||
no++;
|
||||
}
|
||||
no++;
|
||||
head.put("taxNo", publicinfoList.get(0).getPI_TAXNO());//当前企业税号
|
||||
}
|
||||
head.put("taxNo",publicinfoList.get(0).getPI_TAXNO());//当前企业税号
|
||||
}
|
||||
logger.info("调用有度发票批量导入接口请求参数:{}",head.toString());
|
||||
//调用税务接口
|
||||
Map<String, String> headerMap = MapBuilder.<String, String>create(true)
|
||||
.put("apiCode", "8000600005")//有度发票导入接口
|
||||
.put("publicKey","ZJYA7f8FzV219otH8zhkReiyyWpXswpbY/+StvC2em0hf59Ce7eDIk+3zDUT+v578prj")//发起方应用
|
||||
.put("secretKey","xJ9J1Ev2F0faiJ/nQnCNklskAgtQp3QSm+ihO21uY/H0UADj0tSDPxmIhFfC4v6Fj3JzOP8MtA1LSGvL+2BWG8c/o7DKi92S4mr3zcGearA=")//发起方应用
|
||||
.put("appId","800060")
|
||||
.build();
|
||||
String body = HttpRequest.post(url).addHeaders(headerMap).body(head.toString()).timeout(60000).execute().body();
|
||||
//String body = null;
|
||||
logger.info("调用有度发票批量导入接口响应参数:{}",body);
|
||||
//保存操作日志
|
||||
if (StrUtil.isNotEmpty(body)){
|
||||
JSONObject jsonObject = JSONObject.parseObject(body);
|
||||
Boolean flag = jsonObject.getBoolean("flag");
|
||||
JSONObject resObj = jsonObject.getJSONObject("attribute");
|
||||
if (null != resObj && "0".equals(resObj.getString("code"))){
|
||||
String result = resObj.getString("result");
|
||||
if (StrUtil.isNotEmpty(result)){
|
||||
cInvoiceH.setDataSourceCode(dataSourceCode);
|
||||
cInvoiceH.setYd_result(result);
|
||||
cInvoiceImportHService.updateResultId(cInvoiceH);
|
||||
logger.info("调用有度发票批量导入接口请求参数:{}", head.toString());
|
||||
//调用税务接口
|
||||
Map<String, String> headerMap = MapBuilder.<String, String>create(true)
|
||||
.put("apiCode", "8000600005")//有度发票导入接口
|
||||
.put("publicKey", "ZJYA7f8FzV219otH8zhkReiyyWpXswpbY/+StvC2em0hf59Ce7eDIk+3zDUT+v578prj")//发起方应用
|
||||
.put("secretKey", "xJ9J1Ev2F0faiJ/nQnCNklskAgtQp3QSm+ihO21uY/H0UADj0tSDPxmIhFfC4v6Fj3JzOP8MtA1LSGvL+2BWG8c/o7DKi92S4mr3zcGearA=")//发起方应用
|
||||
.put("appId", "800060")
|
||||
.build();
|
||||
String body = HttpRequest.post(url).addHeaders(headerMap).body(head.toString()).timeout(60000).execute().body();
|
||||
//String body = null;
|
||||
logger.info("调用有度发票批量导入接口响应参数:{}", body);
|
||||
//保存操作日志
|
||||
if (StrUtil.isNotEmpty(body)) {
|
||||
JSONObject jsonObject = JSONObject.parseObject(body);
|
||||
Boolean flag = jsonObject.getBoolean("flag");
|
||||
JSONObject resObj = jsonObject.getJSONObject("attribute");
|
||||
if (null != resObj && "0".equals(resObj.getString("code"))) {
|
||||
String result = resObj.getString("result");
|
||||
if (StrUtil.isNotEmpty(result)) {
|
||||
cInvoiceH.setDataSourceCode(dataSourceCode);
|
||||
cInvoiceH.setYd_result(result);
|
||||
cInvoiceImportHService.updateResultId(cInvoiceH);
|
||||
}
|
||||
}
|
||||
//保存日志
|
||||
IntegrationTaskLivingDetailsEntity taskLivingDetail = new IntegrationTaskLivingDetailsEntity();
|
||||
taskLivingDetail.setCreate_time(new Date());
|
||||
taskLivingDetail.setModify_time(new Date());
|
||||
taskLivingDetail.setRootAppPk(cInvoiceH.getId());
|
||||
taskLivingDetail.setRootAppBill(cInvoiceH.getBill_code());
|
||||
taskLivingDetail.setPluginId("CInvoiceImportPluginInitializer");
|
||||
taskLivingDetail.setRootAppNewData(head.toString());
|
||||
taskLivingDetail.setNewTransmitInfo(body);
|
||||
taskLivingDetail.setNewPushDate(new Date());
|
||||
this.saveLog(id, flag, taskLivingDetail);
|
||||
}
|
||||
//保存日志
|
||||
IntegrationTaskLivingDetailsEntity taskLivingDetail = new IntegrationTaskLivingDetailsEntity();
|
||||
taskLivingDetail.setCreate_time(new Date());
|
||||
taskLivingDetail.setModify_time(new Date());
|
||||
taskLivingDetail.setRootAppPk(cInvoiceH.getId());
|
||||
taskLivingDetail.setRootAppBill(cInvoiceH.getBill_code());
|
||||
taskLivingDetail.setPluginId("CInvoiceImportPluginInitializer");
|
||||
taskLivingDetail.setRootAppNewData(head.toString());
|
||||
taskLivingDetail.setNewTransmitInfo(body);
|
||||
taskLivingDetail.setNewPushDate(new Date());
|
||||
this.saveLog(id,flag,taskLivingDetail);
|
||||
} catch (Exception e) {
|
||||
logger.error("发票批量导入有度系统循环中出错:{}", e.getMessage());
|
||||
}
|
||||
return body;
|
||||
}
|
||||
}else {
|
||||
cInvoiceH.setPush_status("未查询到有效数据不推送");
|
||||
cInvoiceImportHService.updateStatus(cInvoiceH);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -193,39 +200,41 @@ public class CInvoiceImportPluginServiceImpl implements ICInvoiceImportPluginSer
|
|||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 保存日志
|
||||
*
|
||||
* @param integration_task_living_details_id
|
||||
* @param flag
|
||||
* @param taskLivingDetail
|
||||
*/
|
||||
public void saveLog(String integration_task_living_details_id, Boolean flag, IntegrationTaskLivingDetailsEntity taskLivingDetail){
|
||||
public void saveLog(String integration_task_living_details_id, Boolean flag, IntegrationTaskLivingDetailsEntity taskLivingDetail) {
|
||||
try {
|
||||
//判断,成功调用这个方法
|
||||
if (StrUtil.isEmpty(integration_task_living_details_id)){
|
||||
if (flag){
|
||||
if (StrUtil.isEmpty(integration_task_living_details_id)) {
|
||||
if (flag) {
|
||||
taskLivingDetailsService.saveLogToSuccess(taskLivingDetail);
|
||||
}else {
|
||||
} else {
|
||||
//失败 调用这个方法
|
||||
taskLivingDetailsService.saveLogToFail(taskLivingDetail);
|
||||
}
|
||||
}else {
|
||||
} else {
|
||||
taskLivingDetail.setId(integration_task_living_details_id);
|
||||
if (flag){
|
||||
if (flag) {
|
||||
//如果是重试 成功调这个方法
|
||||
taskLivingDetailsService.saveLogFailToSuccess(taskLivingDetail);
|
||||
}else {
|
||||
} else {
|
||||
//如果是重试 失败调这个方法
|
||||
taskLivingDetailsService.updateLogFailToSuccess(taskLivingDetail);
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
logger.error("保存日志出错:{}",e);
|
||||
} catch (Exception e) {
|
||||
logger.error("保存日志出错:{}", e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 机票
|
||||
*
|
||||
* @param dataSourceCode
|
||||
* @param info
|
||||
* @param invoiceInfo
|
||||
|
@ -236,43 +245,44 @@ public class CInvoiceImportPluginServiceImpl implements ICInvoiceImportPluginSer
|
|||
JSONObject contentInfo;
|
||||
ParamAssembler assembler;
|
||||
LexmiscivPlaneticketEntity planeticketH = lexmiscivPlaneticketService.queryOne(new LexmiscivPlaneticketEntity(info.getPI_DATAKEY(), dataSourceCode));
|
||||
if (null != planeticketH){
|
||||
if (null != planeticketH) {
|
||||
String fplx = "a4";
|
||||
LexmiscivPlaneticketsEntity planeticketB = new LexmiscivPlaneticketsEntity(planeticketH.getPT_ID(), dataSourceCode);
|
||||
//飞机行程单子表
|
||||
List<LexmiscivPlaneticketsEntity> planeticketBList = lexmiscivPlaneticketsService.query(planeticketB);
|
||||
JSONObject planeObj = new JSONObject();
|
||||
planeObj.put("planeticketH",JSONObject.toJSONString(planeticketH));
|
||||
planeObj.put("planeticketBList",JSONObject.toJSONString(planeticketBList));
|
||||
planeObj.put("planeticketH", JSONObject.toJSONString(planeticketH));
|
||||
planeObj.put("planeticketBList", JSONObject.toJSONString(planeticketBList));
|
||||
//1表示电子行程单 先不区分试试,策略类内部判断来实现区分
|
||||
if ("1".equals(planeticketH.getPT_ELECTRONICMARK())){
|
||||
//assembler = new ElecFlightInvoiceAssembler(planeObj);
|
||||
fplx = "400";
|
||||
}
|
||||
if ("1".equals(planeticketH.getPT_ELECTRONICMARK())) {
|
||||
//assembler = new ElecFlightInvoiceAssembler(planeObj);
|
||||
fplx = "400";
|
||||
}
|
||||
// else {
|
||||
// assembler = new FlightInvoiceAssembler(planeObj);
|
||||
// }
|
||||
assembler = new ElecFlightInvoiceAssembler(planeObj);
|
||||
context = new ParamAssemblerContext(assembler);
|
||||
contentInfo = context.assemble();
|
||||
baseInfo.put("fphm",planeticketH.getPT_FPHM());//发票号码
|
||||
baseInfo.put("fpdm","");//发票代码
|
||||
baseInfo.put("fplx",fplx);//发票类型
|
||||
baseInfo.put("kprq",planeticketH.getPT_MAKEDATE());//开票日期
|
||||
baseInfo.put("bhszje",planeticketH.getPT_NOTAXAMOUNT());//不含税总金额
|
||||
baseInfo.put("jym",planeticketH.getPT_VALIDCODE());//校验码
|
||||
baseInfo.put("bxje",planeticketH.getPT_NOTAXAMOUNT());//不含税实际报销金额
|
||||
baseInfo.put("jsse","");//有效计算税额
|
||||
baseInfo.put("jsdkzq","");//计算抵扣账期
|
||||
baseInfo.put("signPerson","");//签收人
|
||||
baseInfo.put("signStatus","1");//签收状态,默认传1
|
||||
baseInfo.put("fphm", planeticketH.getPT_FPHM());//发票号码
|
||||
baseInfo.put("fpdm", "");//发票代码
|
||||
baseInfo.put("fplx", fplx);//发票类型
|
||||
baseInfo.put("kprq", planeticketH.getPT_MAKEDATE());//开票日期
|
||||
baseInfo.put("bhszje", planeticketH.getPT_NOTAXAMOUNT());//不含税总金额
|
||||
baseInfo.put("jym", planeticketH.getPT_VALIDCODE());//校验码
|
||||
baseInfo.put("bxje", planeticketH.getPT_NOTAXAMOUNT());//不含税实际报销金额
|
||||
baseInfo.put("jsse", "");//有效计算税额
|
||||
baseInfo.put("jsdkzq", "");//计算抵扣账期
|
||||
baseInfo.put("signPerson", "");//签收人
|
||||
baseInfo.put("signStatus", "1");//签收状态,默认传1
|
||||
invoiceInfo.put("baseInfo", baseInfo);
|
||||
invoiceInfo.put("contentInfo",contentInfo);
|
||||
invoiceInfo.put("contentInfo", contentInfo);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 火车票发票
|
||||
*
|
||||
* @param dataSourceCode
|
||||
* @param inputInfos
|
||||
* @param info
|
||||
|
@ -287,34 +297,34 @@ public class CInvoiceImportPluginServiceImpl implements ICInvoiceImportPluginSer
|
|||
LexmiscivTrainticketEntity trainticketEntity = new LexmiscivTrainticketEntity(info.getPI_DATAKEY(), dataSourceCode);
|
||||
trainticketEntity.setTT_BUSINESSTYPE(1);//1售票 2退票 3售票换开 4退票换开,3和4没遇到过,先查1
|
||||
LexmiscivTrainticketEntity trainticket = lexmiscivTrainticketService.queryOne(trainticketEntity);
|
||||
if (null != trainticket){
|
||||
if (null != trainticket) {
|
||||
JSONObject trainObj = new JSONObject();
|
||||
trainObj.put("trainInvoice",JSONObject.toJSONString(trainticket));
|
||||
trainObj.put("publicInvoice",JSONObject.toJSONString(info));
|
||||
trainObj.put("trainInvoice", JSONObject.toJSONString(trainticket));
|
||||
trainObj.put("publicInvoice", JSONObject.toJSONString(info));
|
||||
String fplx = "a2";
|
||||
//1是电子票
|
||||
if ("1".equals(trainticket.getTT_ELECTRONIC())){
|
||||
if ("1".equals(trainticket.getTT_ELECTRONIC())) {
|
||||
assembler = new ElecTrainInvoiceAssembler(trainObj);
|
||||
fplx = "200";
|
||||
}else {
|
||||
} else {
|
||||
assembler = new TrainInvoiceAssembler(trainObj);
|
||||
}
|
||||
context = new ParamAssemblerContext(assembler);
|
||||
contentInfo = context.assemble();
|
||||
baseInfo.put("fphm",trainticket.getTT_CODE());//发票号码
|
||||
baseInfo.put("fpdm","");//发票代码 火车票不用传
|
||||
baseInfo.put("fplx",fplx);//发票类型
|
||||
baseInfo.put("kprq",DateUtil.format(trainticket.getTT_DATE(),"yyyy-MM-dd"));//开票日期
|
||||
baseInfo.put("bhszje",trainticket.getTT_NOTAXAMOUNT());//不含税总金额
|
||||
baseInfo.put("jym","");//校验码
|
||||
baseInfo.put("bxje",trainticket.getTT_NOTAXAMOUNT());//不含税实际报销金额
|
||||
baseInfo.put("jsse","");//有效计算税额
|
||||
baseInfo.put("jsdkzq","");//计算抵扣账期
|
||||
baseInfo.put("signPerson","");//签收人
|
||||
baseInfo.put("signStatus","1");//签收状态,默认传1
|
||||
baseInfo.put("fphm", trainticket.getTT_CODE());//发票号码
|
||||
baseInfo.put("fpdm", "");//发票代码 火车票不用传
|
||||
baseInfo.put("fplx", fplx);//发票类型
|
||||
baseInfo.put("kprq", DateUtil.format(trainticket.getTT_DATE(), "yyyy-MM-dd"));//开票日期
|
||||
baseInfo.put("bhszje", trainticket.getTT_NOTAXAMOUNT());//不含税总金额
|
||||
baseInfo.put("jym", "");//校验码
|
||||
baseInfo.put("bxje", trainticket.getTT_NOTAXAMOUNT());//不含税实际报销金额
|
||||
baseInfo.put("jsse", "");//有效计算税额
|
||||
baseInfo.put("jsdkzq", "");//计算抵扣账期
|
||||
baseInfo.put("signPerson", "");//签收人
|
||||
baseInfo.put("signStatus", "1");//签收状态,默认传1
|
||||
invoiceInfo.put("baseInfo", baseInfo);
|
||||
invoiceInfo.put("contentInfo",contentInfo);
|
||||
}else {
|
||||
invoiceInfo.put("contentInfo", contentInfo);
|
||||
} else {
|
||||
inputInfos.remove(inputInfo);
|
||||
logger.info("根据pi_datakey没有查到火车票发票信息:{},发票号:{}", info.getPI_DATAKEY());
|
||||
}
|
||||
|
@ -322,10 +332,11 @@ public class CInvoiceImportPluginServiceImpl implements ICInvoiceImportPluginSer
|
|||
|
||||
/**
|
||||
* 增值税发票
|
||||
*
|
||||
* @param dataSourceCode 数据源编码
|
||||
* @param info 发票公共表
|
||||
* @param invoiceInfo 发票信息对象
|
||||
* @param baseInfo 发票基本数据对象
|
||||
* @param info 发票公共表
|
||||
* @param invoiceInfo 发票信息对象
|
||||
* @param baseInfo 发票基本数据对象
|
||||
*/
|
||||
private void zzsInvoice(String dataSourceCode, LexmisPublicinfoEntity info, JSONObject invoiceInfo, JSONObject baseInfo) {
|
||||
ParamAssemblerContext context;//策略上下文类
|
||||
|
@ -335,70 +346,72 @@ public class CInvoiceImportPluginServiceImpl implements ICInvoiceImportPluginSer
|
|||
//增值税发票表体
|
||||
List<LexmiscivInvoicedetailEntity> zzsInvoiceBList = lexmiscivInvoicedetailService.query(new LexmiscivInvoicedetailEntity(zzsInvoiceH.getIM_ID(), dataSourceCode));
|
||||
JSONObject zzs = new JSONObject();
|
||||
zzs.put("zzsInvoiceH",JSONObject.toJSONString(zzsInvoiceH));
|
||||
zzs.put("zzsInvoiceBList",JSONObject.toJSONString(zzsInvoiceBList));
|
||||
zzs.put("zzsInvoiceH", JSONObject.toJSONString(zzsInvoiceH));
|
||||
zzs.put("zzsInvoiceBList", JSONObject.toJSONString(zzsInvoiceBList));
|
||||
assembler = new ZzsInvoiceAssembler(zzs);
|
||||
context = new ParamAssemblerContext(assembler);
|
||||
contentInfo = context.assemble();
|
||||
baseInfo.put("fphm",zzsInvoiceH.getIM_FPHM());//发票号码
|
||||
baseInfo.put("fpdm",zzsInvoiceH.getIM_FPDM());//发票代码
|
||||
baseInfo.put("fplx",convertZzsFplx(zzsInvoiceH.getIM_TYPE()));//发票类型
|
||||
baseInfo.put("kprq",DateUtil.format(zzsInvoiceH.getIM_DATE(),"yyyy-MM-dd"));//开票日期
|
||||
baseInfo.put("bhszje",zzsInvoiceH.getIM_NOTAXAMOUNT());//不含税总金额
|
||||
baseInfo.put("jym",zzsInvoiceH.getIM_CHECKCODE());//校验码
|
||||
baseInfo.put("bxje",zzsInvoiceH.getIM_NOTAXAMOUNT());//不含税实际报销金额
|
||||
baseInfo.put("jsse","");//有效计算税额
|
||||
baseInfo.put("jsdkzq","");//计算抵扣账期
|
||||
baseInfo.put("signPerson","");//签收人
|
||||
baseInfo.put("signStatus","1");//签收状态,默认传1
|
||||
baseInfo.put("fphm", zzsInvoiceH.getIM_FPHM());//发票号码
|
||||
baseInfo.put("fpdm", zzsInvoiceH.getIM_FPDM());//发票代码
|
||||
baseInfo.put("fplx", convertZzsFplx(zzsInvoiceH.getIM_TYPE()));//发票类型
|
||||
baseInfo.put("kprq", DateUtil.format(zzsInvoiceH.getIM_DATE(), "yyyy-MM-dd"));//开票日期
|
||||
baseInfo.put("bhszje", zzsInvoiceH.getIM_NOTAXAMOUNT());//不含税总金额
|
||||
baseInfo.put("jym", zzsInvoiceH.getIM_CHECKCODE());//校验码
|
||||
baseInfo.put("bxje", zzsInvoiceH.getIM_NOTAXAMOUNT());//不含税实际报销金额
|
||||
baseInfo.put("jsse", "");//有效计算税额
|
||||
baseInfo.put("jsdkzq", "");//计算抵扣账期
|
||||
baseInfo.put("signPerson", "");//签收人
|
||||
baseInfo.put("signStatus", "1");//签收状态,默认传1
|
||||
invoiceInfo.put("baseInfo", baseInfo);
|
||||
invoiceInfo.put("contentInfo",contentInfo);
|
||||
invoiceInfo.put("contentInfo", contentInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 客运汽车
|
||||
*
|
||||
* @param dataSourceCode 数据源编码
|
||||
* @param info 发票公共表嘻嘻
|
||||
* @param invoiceInfo 发票参数对象
|
||||
* @param baseInfo 发票base参数对象
|
||||
* @param info 发票公共表嘻嘻
|
||||
* @param invoiceInfo 发票参数对象
|
||||
* @param baseInfo 发票base参数对象
|
||||
*/
|
||||
private void busInvoice(String dataSourceCode, LexmisPublicinfoEntity info, JSONObject invoiceInfo, JSONObject baseInfo) {
|
||||
ParamAssemblerContext context;//策略上下文类
|
||||
JSONObject contentInfo;
|
||||
ParamAssembler assembler;
|
||||
LexmiscivBusinvoiceEntity businvoiceEntity = lexmiscivBusinvoiceService.queryOne(new LexmiscivBusinvoiceEntity(info.getPI_DATAKEY(),dataSourceCode));
|
||||
if (null != businvoiceEntity){
|
||||
LexmiscivBusinvoiceEntity businvoiceEntity = lexmiscivBusinvoiceService.queryOne(new LexmiscivBusinvoiceEntity(info.getPI_DATAKEY(), dataSourceCode));
|
||||
if (null != businvoiceEntity) {
|
||||
JSONObject busObj = new JSONObject();
|
||||
busObj.put("busInvoice",JSONObject.toJSONString(businvoiceEntity));
|
||||
busObj.put("publicInfoice",JSONObject.toJSONString(info));
|
||||
busObj.put("busInvoice", JSONObject.toJSONString(businvoiceEntity));
|
||||
busObj.put("publicInfoice", JSONObject.toJSONString(info));
|
||||
assembler = new BusInvoiceAssembler(busObj);
|
||||
context = new ParamAssemblerContext(assembler);
|
||||
contentInfo = context.assemble();
|
||||
baseInfo.put("fphm", businvoiceEntity.getBI_FPHM());//发票号码
|
||||
baseInfo.put("fpdm",businvoiceEntity.getBI_FPDM());//发票代码
|
||||
baseInfo.put("fplx","a3");//发票类型
|
||||
baseInfo.put("kprq",DateUtil.format(businvoiceEntity.getBI_DATE(),"yyyy-MM-dd"));//开票日期
|
||||
baseInfo.put("bhszje",businvoiceEntity.getBI_NOTAXAMOUNT());//不含税总金额
|
||||
baseInfo.put("jym","");//校验码
|
||||
baseInfo.put("bxje",businvoiceEntity.getBI_NOTAXAMOUNT());//不含税金额
|
||||
baseInfo.put("jsse","");//有效计算税额
|
||||
baseInfo.put("jsdkzq","");//计算抵扣账期
|
||||
baseInfo.put("signPerson","");//签收人
|
||||
baseInfo.put("signStatus","1");//签收状态,默认传1
|
||||
baseInfo.put("fpdm", businvoiceEntity.getBI_FPDM());//发票代码
|
||||
baseInfo.put("fplx", "a3");//发票类型
|
||||
baseInfo.put("kprq", DateUtil.format(businvoiceEntity.getBI_DATE(), "yyyy-MM-dd"));//开票日期
|
||||
baseInfo.put("bhszje", businvoiceEntity.getBI_NOTAXAMOUNT());//不含税总金额
|
||||
baseInfo.put("jym", "");//校验码
|
||||
baseInfo.put("bxje", businvoiceEntity.getBI_NOTAXAMOUNT());//不含税金额
|
||||
baseInfo.put("jsse", "");//有效计算税额
|
||||
baseInfo.put("jsdkzq", "");//计算抵扣账期
|
||||
baseInfo.put("signPerson", "");//签收人
|
||||
baseInfo.put("signStatus", "1");//签收状态,默认传1
|
||||
invoiceInfo.put("baseInfo", baseInfo);
|
||||
invoiceInfo.put("contentInfo",contentInfo);
|
||||
invoiceInfo.put("contentInfo", contentInfo);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 迈锐思增值税类发票类型转换成有度发票类型
|
||||
*
|
||||
* @param fplx 迈锐思发票类型
|
||||
* @return
|
||||
*/
|
||||
private String convertZzsFplx(String fplx){
|
||||
if (StrUtil.isNotEmpty(fplx)){
|
||||
private String convertZzsFplx(String fplx) {
|
||||
if (StrUtil.isNotEmpty(fplx)) {
|
||||
String youduFplx = null;
|
||||
switch (fplx){
|
||||
switch (fplx) {
|
||||
case "01"://增值税专用发票
|
||||
youduFplx = "01";
|
||||
break;
|
||||
|
@ -418,8 +431,8 @@ public class CInvoiceImportPluginServiceImpl implements ICInvoiceImportPluginSer
|
|||
youduFplx = "32";
|
||||
break;
|
||||
case "14"://电子发票(通行费)
|
||||
youduFplx = "14";
|
||||
break;
|
||||
youduFplx = "14";
|
||||
break;
|
||||
}
|
||||
return youduFplx;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue