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

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;
/** /**
* 发票导入 * 发票导入
* *
@ -75,10 +76,7 @@ public class CInvoiceImportPluginServiceImpl implements ICInvoiceImportPluginSer
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);
@ -86,6 +84,7 @@ public class CInvoiceImportPluginServiceImpl implements ICInvoiceImportPluginSer
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 查迈瑞思发票表
//迈锐思发票公共信息表 //迈锐思发票公共信息表
@ -93,10 +92,13 @@ public class CInvoiceImportPluginServiceImpl implements ICInvoiceImportPluginSer
//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();
@ -183,9 +185,14 @@ public class CInvoiceImportPluginServiceImpl implements ICInvoiceImportPluginSer
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,9 +200,9 @@ 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
@ -224,8 +231,10 @@ public class CInvoiceImportPluginServiceImpl implements ICInvoiceImportPluginSer
logger.error("保存日志出错:{}", e); logger.error("保存日志出错:{}", e);
} }
} }
/** /**
* 机票 * 机票
*
* @param dataSourceCode * @param dataSourceCode
* @param info * @param info
* @param invoiceInfo * @param invoiceInfo
@ -273,6 +282,7 @@ public class CInvoiceImportPluginServiceImpl implements ICInvoiceImportPluginSer
/** /**
* 火车票发票 * 火车票发票
*
* @param dataSourceCode * @param dataSourceCode
* @param inputInfos * @param inputInfos
* @param info * @param info
@ -322,6 +332,7 @@ public class CInvoiceImportPluginServiceImpl implements ICInvoiceImportPluginSer
/** /**
* 增值税发票 * 增值税发票
*
* @param dataSourceCode 数据源编码 * @param dataSourceCode 数据源编码
* @param info 发票公共表 * @param info 发票公共表
* @param invoiceInfo 发票信息对象 * @param invoiceInfo 发票信息对象
@ -357,6 +368,7 @@ public class CInvoiceImportPluginServiceImpl implements ICInvoiceImportPluginSer
/** /**
* 客运汽车 * 客运汽车
*
* @param dataSourceCode 数据源编码 * @param dataSourceCode 数据源编码
* @param info 发票公共表嘻嘻 * @param info 发票公共表嘻嘻
* @param invoiceInfo 发票参数对象 * @param invoiceInfo 发票参数对象
@ -392,6 +404,7 @@ public class CInvoiceImportPluginServiceImpl implements ICInvoiceImportPluginSer
/** /**
* 迈锐思增值税类发票类型转换成有度发票类型 * 迈锐思增值税类发票类型转换成有度发票类型
*
* @param fplx 迈锐思发票类型 * @param fplx 迈锐思发票类型
* @return * @return
*/ */