发票批量导入改成定时任务执行

This commit is contained in:
xiang2lin 2025-05-23 16:23:55 +08:00
parent a73e35f006
commit fdad19b0cc
5 changed files with 242 additions and 176 deletions

View File

@ -20,6 +20,10 @@ public class CInvoiceImportHEntity extends BaseEntity {
private String yd_result; private String yd_result;
//发起时间 //发起时间
private String start_date; private String start_date;
//推送状态
private String push_status;
//推送字段
private String push_field;
public String getTab_name() { public String getTab_name() {
return tab_name; return tab_name;
@ -68,4 +72,20 @@ public class CInvoiceImportHEntity extends BaseEntity {
public void setStart_date(String start_date) { public void setStart_date(String start_date) {
this.start_date = 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;
}
} }

View File

@ -7,6 +7,8 @@
<result property="yd_res_field" column="yd_res_field" /> <result property="yd_res_field" column="yd_res_field" />
<result property="bill_type" column="bill_type" /> <result property="bill_type" column="bill_type" />
<result property="bill_code" column="bill_code" /> <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" /> <result property="start_date" column="start_date" />
</resultMap> </resultMap>
@ -16,10 +18,16 @@
<trim prefix="where" prefixOverrides="and"> <trim prefix="where" prefixOverrides="and">
<if test="id != null and id != ''">f.id = #{id}</if> <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> <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> </trim>
</select> </select>
<update id="entity_update" parameterType="com.hzya.frame.plugin.cinvoice.entity.CInvoiceImportHEntity"> <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 ${tab_name} set ${yd_res_field} = #{yd_result} where id = #{id}
</update> </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> </mapper>

View File

@ -26,4 +26,11 @@ public interface ICInvoiceImportHService extends IBaseService<CInvoiceImportHEnt
* @return * @return
*/ */
int updateResultId(CInvoiceImportHEntity entity); int updateResultId(CInvoiceImportHEntity entity);
/**
* 更新推送标记
* @param entity
* @return
*/
int updateStatus(CInvoiceImportHEntity entity);
} }

View File

@ -61,4 +61,22 @@ public class CInvoiceImportHServiceImpl extends BaseService<CInvoiceImportHEntit
} }
return 0; 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;
}
} }

View File

@ -59,6 +59,7 @@ public class CInvoiceImportPluginServiceImpl implements ICInvoiceImportPluginSer
private IIntegrationTaskLivingDetailsService taskLivingDetailsService; private IIntegrationTaskLivingDetailsService taskLivingDetailsService;
@Value("${zt.url:}") @Value("${zt.url:}")
private String url; private String url;
/** /**
* 发票导入 * 发票导入
* *
@ -72,61 +73,62 @@ public class CInvoiceImportPluginServiceImpl implements ICInvoiceImportPluginSer
//1 查OA主表 //1 查OA主表
String dataSourceCode = requestJson.getString("sourceCode"); String dataSourceCode = requestJson.getString("sourceCode");
if (StrUtil.isEmpty(dataSourceCode)){ if (StrUtil.isEmpty(dataSourceCode)) {
dataSourceCode = requestJson.getString("apiDataSourceCode"); dataSourceCode = requestJson.getString("apiDataSourceCode");
} }
String id = requestJson.getString("id");//主表id String id = requestJson.getString("id");//主表id 测试的时候用
if (StrUtil.isEmpty(id)){
throw new BaseSystemException("id不能为空");
}
CInvoiceImportHEntity importHEntity = new CInvoiceImportHEntity(); CInvoiceImportHEntity importHEntity = new CInvoiceImportHEntity();
importHEntity.setDataSourceCode(dataSourceCode); importHEntity.setDataSourceCode(dataSourceCode);
importHEntity.setId(id); importHEntity.setId(id);
List<CInvoiceImportHEntity> cInvoiceImportHList = cInvoiceImportHService.queryInvoiceList(importHEntity); List<CInvoiceImportHEntity> cInvoiceImportHList = cInvoiceImportHService.queryInvoiceList(importHEntity);
if (CollectionUtils.isNotEmpty(cInvoiceImportHList)){ if (CollectionUtils.isNotEmpty(cInvoiceImportHList)) {
ParamAssembler assembler = null; ParamAssembler assembler = null;
CInvoiceImportHEntity cInvoiceH = cInvoiceImportHList.get(0); CInvoiceImportHEntity cInvoiceH = cInvoiceImportHList.get(0);
cInvoiceH.setDataSourceCode(dataSourceCode);
//2 查OA明细表 //2 查OA明细表
//3 查迈瑞思发票表 //3 查迈瑞思发票表
//迈锐思发票公共信息表 //迈锐思发票公共信息表
LexmisPublicinfoEntity lexmisPublicinfoEntity = new LexmisPublicinfoEntity(cInvoiceH.getId(),dataSourceCode); LexmisPublicinfoEntity lexmisPublicinfoEntity = new LexmisPublicinfoEntity(cInvoiceH.getId(), dataSourceCode);
//lexmisPublicinfoEntity.setPI_ID("6952494198841691018"); //lexmisPublicinfoEntity.setPI_ID("6952494198841691018");
List<LexmisPublicinfoEntity> lexmisPublicinfoEntityList = lexmisPublicinfoService.query(lexmisPublicinfoEntity); List<LexmisPublicinfoEntity> lexmisPublicinfoEntityList = lexmisPublicinfoService.query(lexmisPublicinfoEntity);
if (CollectionUtils.isNotEmpty(lexmisPublicinfoEntityList)){ if (CollectionUtils.isNotEmpty(lexmisPublicinfoEntityList)) {
cInvoiceH.setPush_status("1");
cInvoiceImportHService.updateStatus(cInvoiceH);
//税务接口每次最多传50张发票 //税务接口每次最多传50张发票
int size = lexmisPublicinfoEntityList.size(); int size = lexmisPublicinfoEntityList.size();
int batchSize = 50; int batchSize = 50;
for (int i = 0; i < size; i += batchSize){ for (int i = 0; i < size; i += batchSize) {
try {
int no = 1;//序号 int no = 1;//序号
//4 根据发票类型组装不同参数 //4 根据发票类型组装不同参数
JSONObject head = new JSONObject(); JSONObject head = new JSONObject();
JSONArray inputInfos = new JSONArray(); JSONArray inputInfos = new JSONArray();
head.put("inputInfos",inputInfos);//发票录入信息单次最大50张 head.put("inputInfos", inputInfos);//发票录入信息单次最大50张
// 获取当前批次的子列表 // 获取当前批次的子列表
List<LexmisPublicinfoEntity> batchList = lexmisPublicinfoEntityList.subList(i, Math.min(i + batchSize, size)); List<LexmisPublicinfoEntity> batchList = lexmisPublicinfoEntityList.subList(i, Math.min(i + batchSize, size));
//使用stream方式 publicinfoList PI_TABLENAME分组 //使用stream方式 publicinfoList PI_TABLENAME分组
Map<String, List<LexmisPublicinfoEntity>> groupedByPiTablename = batchList.stream() Map<String, List<LexmisPublicinfoEntity>> groupedByPiTablename = batchList.stream()
.collect(Collectors.groupingBy(LexmisPublicinfoEntity::getPI_TABLENAME)); .collect(Collectors.groupingBy(LexmisPublicinfoEntity::getPI_TABLENAME));
for (Map.Entry<String,List<LexmisPublicinfoEntity>> entry : groupedByPiTablename.entrySet()){ for (Map.Entry<String, List<LexmisPublicinfoEntity>> entry : groupedByPiTablename.entrySet()) {
String key = entry.getKey();//对应发票类型的表名 String key = entry.getKey();//对应发票类型的表名
List<LexmisPublicinfoEntity> publicinfoList = entry.getValue(); List<LexmisPublicinfoEntity> publicinfoList = entry.getValue();
for (LexmisPublicinfoEntity info : publicinfoList){ for (LexmisPublicinfoEntity info : publicinfoList) {
JSONObject inputInfo = new JSONObject(); JSONObject inputInfo = new JSONObject();
inputInfos.add(inputInfo); inputInfos.add(inputInfo);
inputInfo.put("no",no);//编号 inputInfo.put("no", no);//编号
inputInfo.put("systemName","4");//来源系统 默认写4 代表OA inputInfo.put("systemName", "4");//来源系统 默认写4 代表OA
inputInfo.put("businessNo",cInvoiceH.getBill_code());//业务单据号 inputInfo.put("businessNo", cInvoiceH.getBill_code());//业务单据号
inputInfo.put("bookkeepingStatus","1");//记账状态默认传1 inputInfo.put("bookkeepingStatus", "1");//记账状态默认传1
inputInfo.put("customFlag","2");//业务流转状态默认传2 inputInfo.put("customFlag", "2");//业务流转状态默认传2
JSONObject invoiceInfo = new JSONObject();//票面信息 JSONObject invoiceInfo = new JSONObject();//票面信息
inputInfo.put("invoiceInfo", invoiceInfo); inputInfo.put("invoiceInfo", invoiceInfo);
JSONObject baseInfo = new JSONObject();//发票基本信息 JSONObject baseInfo = new JSONObject();//发票基本信息
JSONObject contentInfo = new JSONObject();//发票内容 JSONObject contentInfo = new JSONObject();//发票内容
JSONArray taxturnsInfos = new JSONArray();//进项转出信息 JSONArray taxturnsInfos = new JSONArray();//进项转出信息
invoiceInfo.put("taxturnsInfos",taxturnsInfos); invoiceInfo.put("taxturnsInfos", taxturnsInfos);
switch (key){ switch (key) {
case "LEXMISCIV_INVOICEMAIN"://增值税发票 case "LEXMISCIV_INVOICEMAIN"://增值税发票
zzsInvoice(dataSourceCode, info, invoiceInfo, baseInfo); zzsInvoice(dataSourceCode, info, invoiceInfo, baseInfo);
break; break;
@ -145,27 +147,27 @@ public class CInvoiceImportPluginServiceImpl implements ICInvoiceImportPluginSer
} }
no++; no++;
} }
head.put("taxNo",publicinfoList.get(0).getPI_TAXNO());//当前企业税号 head.put("taxNo", publicinfoList.get(0).getPI_TAXNO());//当前企业税号
} }
logger.info("调用有度发票批量导入接口请求参数:{}",head.toString()); logger.info("调用有度发票批量导入接口请求参数:{}", head.toString());
//调用税务接口 //调用税务接口
Map<String, String> headerMap = MapBuilder.<String, String>create(true) Map<String, String> headerMap = MapBuilder.<String, String>create(true)
.put("apiCode", "8000600005")//有度发票导入接口 .put("apiCode", "8000600005")//有度发票导入接口
.put("publicKey","ZJYA7f8FzV219otH8zhkReiyyWpXswpbY/+StvC2em0hf59Ce7eDIk+3zDUT+v578prj")//发起方应用 .put("publicKey", "ZJYA7f8FzV219otH8zhkReiyyWpXswpbY/+StvC2em0hf59Ce7eDIk+3zDUT+v578prj")//发起方应用
.put("secretKey","xJ9J1Ev2F0faiJ/nQnCNklskAgtQp3QSm+ihO21uY/H0UADj0tSDPxmIhFfC4v6Fj3JzOP8MtA1LSGvL+2BWG8c/o7DKi92S4mr3zcGearA=")//发起方应用 .put("secretKey", "xJ9J1Ev2F0faiJ/nQnCNklskAgtQp3QSm+ihO21uY/H0UADj0tSDPxmIhFfC4v6Fj3JzOP8MtA1LSGvL+2BWG8c/o7DKi92S4mr3zcGearA=")//发起方应用
.put("appId","800060") .put("appId", "800060")
.build(); .build();
String body = HttpRequest.post(url).addHeaders(headerMap).body(head.toString()).timeout(60000).execute().body(); String body = HttpRequest.post(url).addHeaders(headerMap).body(head.toString()).timeout(60000).execute().body();
//String body = null; //String body = null;
logger.info("调用有度发票批量导入接口响应参数:{}",body); logger.info("调用有度发票批量导入接口响应参数:{}", body);
//保存操作日志 //保存操作日志
if (StrUtil.isNotEmpty(body)){ if (StrUtil.isNotEmpty(body)) {
JSONObject jsonObject = JSONObject.parseObject(body); JSONObject jsonObject = JSONObject.parseObject(body);
Boolean flag = jsonObject.getBoolean("flag"); Boolean flag = jsonObject.getBoolean("flag");
JSONObject resObj = jsonObject.getJSONObject("attribute"); JSONObject resObj = jsonObject.getJSONObject("attribute");
if (null != resObj && "0".equals(resObj.getString("code"))){ if (null != resObj && "0".equals(resObj.getString("code"))) {
String result = resObj.getString("result"); String result = resObj.getString("result");
if (StrUtil.isNotEmpty(result)){ if (StrUtil.isNotEmpty(result)) {
cInvoiceH.setDataSourceCode(dataSourceCode); cInvoiceH.setDataSourceCode(dataSourceCode);
cInvoiceH.setYd_result(result); cInvoiceH.setYd_result(result);
cInvoiceImportHService.updateResultId(cInvoiceH); cInvoiceImportHService.updateResultId(cInvoiceH);
@ -181,11 +183,16 @@ public class CInvoiceImportPluginServiceImpl implements ICInvoiceImportPluginSer
taskLivingDetail.setRootAppNewData(head.toString()); taskLivingDetail.setRootAppNewData(head.toString());
taskLivingDetail.setNewTransmitInfo(body); taskLivingDetail.setNewTransmitInfo(body);
taskLivingDetail.setNewPushDate(new Date()); taskLivingDetail.setNewPushDate(new Date());
this.saveLog(id,flag,taskLivingDetail); this.saveLog(id, flag, taskLivingDetail);
} }
return body; } catch (Exception e) {
logger.error("发票批量导入有度系统循环中出错:{}", e.getMessage());
} }
} }
}else {
cInvoiceH.setPush_status("未查询到有效数据不推送");
cInvoiceImportHService.updateStatus(cInvoiceH);
}
} }
@ -193,39 +200,41 @@ public class CInvoiceImportPluginServiceImpl implements ICInvoiceImportPluginSer
} }
/** /**
* 保存日志 * 保存日志
*
* @param integration_task_living_details_id * @param integration_task_living_details_id
* @param flag * @param flag
* @param taskLivingDetail * @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 { try {
//判断成功调用这个方法 //判断成功调用这个方法
if (StrUtil.isEmpty(integration_task_living_details_id)){ if (StrUtil.isEmpty(integration_task_living_details_id)) {
if (flag){ if (flag) {
taskLivingDetailsService.saveLogToSuccess(taskLivingDetail); taskLivingDetailsService.saveLogToSuccess(taskLivingDetail);
}else { } else {
//失败 调用这个方法 //失败 调用这个方法
taskLivingDetailsService.saveLogToFail(taskLivingDetail); taskLivingDetailsService.saveLogToFail(taskLivingDetail);
} }
}else { } else {
taskLivingDetail.setId(integration_task_living_details_id); taskLivingDetail.setId(integration_task_living_details_id);
if (flag){ if (flag) {
//如果是重试 成功调这个方法 //如果是重试 成功调这个方法
taskLivingDetailsService.saveLogFailToSuccess(taskLivingDetail); taskLivingDetailsService.saveLogFailToSuccess(taskLivingDetail);
}else { } else {
//如果是重试 失败调这个方法 //如果是重试 失败调这个方法
taskLivingDetailsService.updateLogFailToSuccess(taskLivingDetail); taskLivingDetailsService.updateLogFailToSuccess(taskLivingDetail);
} }
} }
}catch (Exception e){ } catch (Exception e) {
logger.error("保存日志出错:{}",e); logger.error("保存日志出错:{}", e);
} }
} }
/** /**
* 机票 * 机票
*
* @param dataSourceCode * @param dataSourceCode
* @param info * @param info
* @param invoiceInfo * @param invoiceInfo
@ -236,16 +245,16 @@ public class CInvoiceImportPluginServiceImpl implements ICInvoiceImportPluginSer
JSONObject contentInfo; JSONObject contentInfo;
ParamAssembler assembler; ParamAssembler assembler;
LexmiscivPlaneticketEntity planeticketH = lexmiscivPlaneticketService.queryOne(new LexmiscivPlaneticketEntity(info.getPI_DATAKEY(), dataSourceCode)); LexmiscivPlaneticketEntity planeticketH = lexmiscivPlaneticketService.queryOne(new LexmiscivPlaneticketEntity(info.getPI_DATAKEY(), dataSourceCode));
if (null != planeticketH){ if (null != planeticketH) {
String fplx = "a4"; String fplx = "a4";
LexmiscivPlaneticketsEntity planeticketB = new LexmiscivPlaneticketsEntity(planeticketH.getPT_ID(), dataSourceCode); LexmiscivPlaneticketsEntity planeticketB = new LexmiscivPlaneticketsEntity(planeticketH.getPT_ID(), dataSourceCode);
//飞机行程单子表 //飞机行程单子表
List<LexmiscivPlaneticketsEntity> planeticketBList = lexmiscivPlaneticketsService.query(planeticketB); List<LexmiscivPlaneticketsEntity> planeticketBList = lexmiscivPlaneticketsService.query(planeticketB);
JSONObject planeObj = new JSONObject(); JSONObject planeObj = new JSONObject();
planeObj.put("planeticketH",JSONObject.toJSONString(planeticketH)); planeObj.put("planeticketH", JSONObject.toJSONString(planeticketH));
planeObj.put("planeticketBList",JSONObject.toJSONString(planeticketBList)); planeObj.put("planeticketBList", JSONObject.toJSONString(planeticketBList));
//1表示电子行程单 先不区分试试策略类内部判断来实现区分 //1表示电子行程单 先不区分试试策略类内部判断来实现区分
if ("1".equals(planeticketH.getPT_ELECTRONICMARK())){ if ("1".equals(planeticketH.getPT_ELECTRONICMARK())) {
//assembler = new ElecFlightInvoiceAssembler(planeObj); //assembler = new ElecFlightInvoiceAssembler(planeObj);
fplx = "400"; fplx = "400";
} }
@ -255,24 +264,25 @@ public class CInvoiceImportPluginServiceImpl implements ICInvoiceImportPluginSer
assembler = new ElecFlightInvoiceAssembler(planeObj); assembler = new ElecFlightInvoiceAssembler(planeObj);
context = new ParamAssemblerContext(assembler); context = new ParamAssemblerContext(assembler);
contentInfo = context.assemble(); contentInfo = context.assemble();
baseInfo.put("fphm",planeticketH.getPT_FPHM());//发票号码 baseInfo.put("fphm", planeticketH.getPT_FPHM());//发票号码
baseInfo.put("fpdm","");//发票代码 baseInfo.put("fpdm", "");//发票代码
baseInfo.put("fplx",fplx);//发票类型 baseInfo.put("fplx", fplx);//发票类型
baseInfo.put("kprq",planeticketH.getPT_MAKEDATE());//开票日期 baseInfo.put("kprq", planeticketH.getPT_MAKEDATE());//开票日期
baseInfo.put("bhszje",planeticketH.getPT_NOTAXAMOUNT());//不含税总金额 baseInfo.put("bhszje", planeticketH.getPT_NOTAXAMOUNT());//不含税总金额
baseInfo.put("jym",planeticketH.getPT_VALIDCODE());//校验码 baseInfo.put("jym", planeticketH.getPT_VALIDCODE());//校验码
baseInfo.put("bxje",planeticketH.getPT_NOTAXAMOUNT());//不含税实际报销金额 baseInfo.put("bxje", planeticketH.getPT_NOTAXAMOUNT());//不含税实际报销金额
baseInfo.put("jsse","");//有效计算税额 baseInfo.put("jsse", "");//有效计算税额
baseInfo.put("jsdkzq","");//计算抵扣账期 baseInfo.put("jsdkzq", "");//计算抵扣账期
baseInfo.put("signPerson","");//签收人 baseInfo.put("signPerson", "");//签收人
baseInfo.put("signStatus","1");//签收状态默认传1 baseInfo.put("signStatus", "1");//签收状态默认传1
invoiceInfo.put("baseInfo", baseInfo); invoiceInfo.put("baseInfo", baseInfo);
invoiceInfo.put("contentInfo",contentInfo); invoiceInfo.put("contentInfo", contentInfo);
} }
} }
/** /**
* 火车票发票 * 火车票发票
*
* @param dataSourceCode * @param dataSourceCode
* @param inputInfos * @param inputInfos
* @param info * @param info
@ -287,34 +297,34 @@ public class CInvoiceImportPluginServiceImpl implements ICInvoiceImportPluginSer
LexmiscivTrainticketEntity trainticketEntity = new LexmiscivTrainticketEntity(info.getPI_DATAKEY(), dataSourceCode); LexmiscivTrainticketEntity trainticketEntity = new LexmiscivTrainticketEntity(info.getPI_DATAKEY(), dataSourceCode);
trainticketEntity.setTT_BUSINESSTYPE(1);//1售票 2退票 3售票换开 4退票换开3和4没遇到过先查1 trainticketEntity.setTT_BUSINESSTYPE(1);//1售票 2退票 3售票换开 4退票换开3和4没遇到过先查1
LexmiscivTrainticketEntity trainticket = lexmiscivTrainticketService.queryOne(trainticketEntity); LexmiscivTrainticketEntity trainticket = lexmiscivTrainticketService.queryOne(trainticketEntity);
if (null != trainticket){ if (null != trainticket) {
JSONObject trainObj = new JSONObject(); JSONObject trainObj = new JSONObject();
trainObj.put("trainInvoice",JSONObject.toJSONString(trainticket)); trainObj.put("trainInvoice", JSONObject.toJSONString(trainticket));
trainObj.put("publicInvoice",JSONObject.toJSONString(info)); trainObj.put("publicInvoice", JSONObject.toJSONString(info));
String fplx = "a2"; String fplx = "a2";
//1是电子票 //1是电子票
if ("1".equals(trainticket.getTT_ELECTRONIC())){ if ("1".equals(trainticket.getTT_ELECTRONIC())) {
assembler = new ElecTrainInvoiceAssembler(trainObj); assembler = new ElecTrainInvoiceAssembler(trainObj);
fplx = "200"; fplx = "200";
}else { } else {
assembler = new TrainInvoiceAssembler(trainObj); assembler = new TrainInvoiceAssembler(trainObj);
} }
context = new ParamAssemblerContext(assembler); context = new ParamAssemblerContext(assembler);
contentInfo = context.assemble(); contentInfo = context.assemble();
baseInfo.put("fphm",trainticket.getTT_CODE());//发票号码 baseInfo.put("fphm", trainticket.getTT_CODE());//发票号码
baseInfo.put("fpdm","");//发票代码 火车票不用传 baseInfo.put("fpdm", "");//发票代码 火车票不用传
baseInfo.put("fplx",fplx);//发票类型 baseInfo.put("fplx", fplx);//发票类型
baseInfo.put("kprq",DateUtil.format(trainticket.getTT_DATE(),"yyyy-MM-dd"));//开票日期 baseInfo.put("kprq", DateUtil.format(trainticket.getTT_DATE(), "yyyy-MM-dd"));//开票日期
baseInfo.put("bhszje",trainticket.getTT_NOTAXAMOUNT());//不含税总金额 baseInfo.put("bhszje", trainticket.getTT_NOTAXAMOUNT());//不含税总金额
baseInfo.put("jym","");//校验码 baseInfo.put("jym", "");//校验码
baseInfo.put("bxje",trainticket.getTT_NOTAXAMOUNT());//不含税实际报销金额 baseInfo.put("bxje", trainticket.getTT_NOTAXAMOUNT());//不含税实际报销金额
baseInfo.put("jsse","");//有效计算税额 baseInfo.put("jsse", "");//有效计算税额
baseInfo.put("jsdkzq","");//计算抵扣账期 baseInfo.put("jsdkzq", "");//计算抵扣账期
baseInfo.put("signPerson","");//签收人 baseInfo.put("signPerson", "");//签收人
baseInfo.put("signStatus","1");//签收状态默认传1 baseInfo.put("signStatus", "1");//签收状态默认传1
invoiceInfo.put("baseInfo", baseInfo); invoiceInfo.put("baseInfo", baseInfo);
invoiceInfo.put("contentInfo",contentInfo); invoiceInfo.put("contentInfo", contentInfo);
}else { } else {
inputInfos.remove(inputInfo); inputInfos.remove(inputInfo);
logger.info("根据pi_datakey没有查到火车票发票信息:{},发票号:{}", info.getPI_DATAKEY()); logger.info("根据pi_datakey没有查到火车票发票信息:{},发票号:{}", info.getPI_DATAKEY());
} }
@ -322,6 +332,7 @@ public class CInvoiceImportPluginServiceImpl implements ICInvoiceImportPluginSer
/** /**
* 增值税发票 * 增值税发票
*
* @param dataSourceCode 数据源编码 * @param dataSourceCode 数据源编码
* @param info 发票公共表 * @param info 发票公共表
* @param invoiceInfo 发票信息对象 * @param invoiceInfo 发票信息对象
@ -335,28 +346,29 @@ public class CInvoiceImportPluginServiceImpl implements ICInvoiceImportPluginSer
//增值税发票表体 //增值税发票表体
List<LexmiscivInvoicedetailEntity> zzsInvoiceBList = lexmiscivInvoicedetailService.query(new LexmiscivInvoicedetailEntity(zzsInvoiceH.getIM_ID(), dataSourceCode)); List<LexmiscivInvoicedetailEntity> zzsInvoiceBList = lexmiscivInvoicedetailService.query(new LexmiscivInvoicedetailEntity(zzsInvoiceH.getIM_ID(), dataSourceCode));
JSONObject zzs = new JSONObject(); JSONObject zzs = new JSONObject();
zzs.put("zzsInvoiceH",JSONObject.toJSONString(zzsInvoiceH)); zzs.put("zzsInvoiceH", JSONObject.toJSONString(zzsInvoiceH));
zzs.put("zzsInvoiceBList",JSONObject.toJSONString(zzsInvoiceBList)); zzs.put("zzsInvoiceBList", JSONObject.toJSONString(zzsInvoiceBList));
assembler = new ZzsInvoiceAssembler(zzs); assembler = new ZzsInvoiceAssembler(zzs);
context = new ParamAssemblerContext(assembler); context = new ParamAssemblerContext(assembler);
contentInfo = context.assemble(); contentInfo = context.assemble();
baseInfo.put("fphm",zzsInvoiceH.getIM_FPHM());//发票号码 baseInfo.put("fphm", zzsInvoiceH.getIM_FPHM());//发票号码
baseInfo.put("fpdm",zzsInvoiceH.getIM_FPDM());//发票代码 baseInfo.put("fpdm", zzsInvoiceH.getIM_FPDM());//发票代码
baseInfo.put("fplx",convertZzsFplx(zzsInvoiceH.getIM_TYPE()));//发票类型 baseInfo.put("fplx", convertZzsFplx(zzsInvoiceH.getIM_TYPE()));//发票类型
baseInfo.put("kprq",DateUtil.format(zzsInvoiceH.getIM_DATE(),"yyyy-MM-dd"));//开票日期 baseInfo.put("kprq", DateUtil.format(zzsInvoiceH.getIM_DATE(), "yyyy-MM-dd"));//开票日期
baseInfo.put("bhszje",zzsInvoiceH.getIM_NOTAXAMOUNT());//不含税总金额 baseInfo.put("bhszje", zzsInvoiceH.getIM_NOTAXAMOUNT());//不含税总金额
baseInfo.put("jym",zzsInvoiceH.getIM_CHECKCODE());//校验码 baseInfo.put("jym", zzsInvoiceH.getIM_CHECKCODE());//校验码
baseInfo.put("bxje",zzsInvoiceH.getIM_NOTAXAMOUNT());//不含税实际报销金额 baseInfo.put("bxje", zzsInvoiceH.getIM_NOTAXAMOUNT());//不含税实际报销金额
baseInfo.put("jsse","");//有效计算税额 baseInfo.put("jsse", "");//有效计算税额
baseInfo.put("jsdkzq","");//计算抵扣账期 baseInfo.put("jsdkzq", "");//计算抵扣账期
baseInfo.put("signPerson","");//签收人 baseInfo.put("signPerson", "");//签收人
baseInfo.put("signStatus","1");//签收状态默认传1 baseInfo.put("signStatus", "1");//签收状态默认传1
invoiceInfo.put("baseInfo", baseInfo); invoiceInfo.put("baseInfo", baseInfo);
invoiceInfo.put("contentInfo",contentInfo); invoiceInfo.put("contentInfo", contentInfo);
} }
/** /**
* 客运汽车 * 客运汽车
*
* @param dataSourceCode 数据源编码 * @param dataSourceCode 数据源编码
* @param info 发票公共表嘻嘻 * @param info 发票公共表嘻嘻
* @param invoiceInfo 发票参数对象 * @param invoiceInfo 发票参数对象
@ -366,39 +378,40 @@ public class CInvoiceImportPluginServiceImpl implements ICInvoiceImportPluginSer
ParamAssemblerContext context;//策略上下文类 ParamAssemblerContext context;//策略上下文类
JSONObject contentInfo; JSONObject contentInfo;
ParamAssembler assembler; ParamAssembler assembler;
LexmiscivBusinvoiceEntity businvoiceEntity = lexmiscivBusinvoiceService.queryOne(new LexmiscivBusinvoiceEntity(info.getPI_DATAKEY(),dataSourceCode)); LexmiscivBusinvoiceEntity businvoiceEntity = lexmiscivBusinvoiceService.queryOne(new LexmiscivBusinvoiceEntity(info.getPI_DATAKEY(), dataSourceCode));
if (null != businvoiceEntity){ if (null != businvoiceEntity) {
JSONObject busObj = new JSONObject(); JSONObject busObj = new JSONObject();
busObj.put("busInvoice",JSONObject.toJSONString(businvoiceEntity)); busObj.put("busInvoice", JSONObject.toJSONString(businvoiceEntity));
busObj.put("publicInfoice",JSONObject.toJSONString(info)); busObj.put("publicInfoice", JSONObject.toJSONString(info));
assembler = new BusInvoiceAssembler(busObj); assembler = new BusInvoiceAssembler(busObj);
context = new ParamAssemblerContext(assembler); context = new ParamAssemblerContext(assembler);
contentInfo = context.assemble(); contentInfo = context.assemble();
baseInfo.put("fphm", businvoiceEntity.getBI_FPHM());//发票号码 baseInfo.put("fphm", businvoiceEntity.getBI_FPHM());//发票号码
baseInfo.put("fpdm",businvoiceEntity.getBI_FPDM());//发票代码 baseInfo.put("fpdm", businvoiceEntity.getBI_FPDM());//发票代码
baseInfo.put("fplx","a3");//发票类型 baseInfo.put("fplx", "a3");//发票类型
baseInfo.put("kprq",DateUtil.format(businvoiceEntity.getBI_DATE(),"yyyy-MM-dd"));//开票日期 baseInfo.put("kprq", DateUtil.format(businvoiceEntity.getBI_DATE(), "yyyy-MM-dd"));//开票日期
baseInfo.put("bhszje",businvoiceEntity.getBI_NOTAXAMOUNT());//不含税总金额 baseInfo.put("bhszje", businvoiceEntity.getBI_NOTAXAMOUNT());//不含税总金额
baseInfo.put("jym","");//校验码 baseInfo.put("jym", "");//校验码
baseInfo.put("bxje",businvoiceEntity.getBI_NOTAXAMOUNT());//不含税金额 baseInfo.put("bxje", businvoiceEntity.getBI_NOTAXAMOUNT());//不含税金额
baseInfo.put("jsse","");//有效计算税额 baseInfo.put("jsse", "");//有效计算税额
baseInfo.put("jsdkzq","");//计算抵扣账期 baseInfo.put("jsdkzq", "");//计算抵扣账期
baseInfo.put("signPerson","");//签收人 baseInfo.put("signPerson", "");//签收人
baseInfo.put("signStatus","1");//签收状态默认传1 baseInfo.put("signStatus", "1");//签收状态默认传1
invoiceInfo.put("baseInfo", baseInfo); invoiceInfo.put("baseInfo", baseInfo);
invoiceInfo.put("contentInfo",contentInfo); invoiceInfo.put("contentInfo", contentInfo);
} }
} }
/** /**
* 迈锐思增值税类发票类型转换成有度发票类型 * 迈锐思增值税类发票类型转换成有度发票类型
*
* @param fplx 迈锐思发票类型 * @param fplx 迈锐思发票类型
* @return * @return
*/ */
private String convertZzsFplx(String fplx){ private String convertZzsFplx(String fplx) {
if (StrUtil.isNotEmpty(fplx)){ if (StrUtil.isNotEmpty(fplx)) {
String youduFplx = null; String youduFplx = null;
switch (fplx){ switch (fplx) {
case "01"://增值税专用发票 case "01"://增值税专用发票
youduFplx = "01"; youduFplx = "01";
break; break;