parent
d31dc80ec8
commit
212e6721fe
@ -0,0 +1,72 @@ |
||||
package com.bweb.excel.listener; |
||||
|
||||
import com.alibaba.excel.context.AnalysisContext; |
||||
import com.alibaba.excel.event.AnalysisEventListener; |
||||
import com.bweb.excel.model.ImportCompleteGasOrderReceiptModel; |
||||
import com.hfkj.entity.BsGasOrderReceipt; |
||||
import com.hfkj.service.gas.BsGasOrderReceiptService; |
||||
import com.hfkj.sysenum.gas.GasOrderReceiptStatusEnum; |
||||
import org.apache.commons.lang3.StringUtils; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* @Auther: 胡锐 |
||||
* @Description: 导入监听器 |
||||
* @Date: 2021/3/20 21:03 |
||||
*/ |
||||
public class ImportCompleteGasOrderReceiptListener extends AnalysisEventListener<ImportCompleteGasOrderReceiptModel> { |
||||
List<ImportCompleteGasOrderReceiptModel> errorData = new ArrayList<>(); |
||||
List<BsGasOrderReceipt> successData = new ArrayList<>(); |
||||
private BsGasOrderReceiptService gasOrderReceiptService; |
||||
|
||||
/** |
||||
* @Author 胡锐 |
||||
* @Description 解析到的每一条数据都会调用此方法 |
||||
* @Date 2021/3/20 21:08 |
||||
**/ |
||||
@Override |
||||
public void invoke(ImportCompleteGasOrderReceiptModel model, AnalysisContext analysisContext) { |
||||
if (StringUtils.isBlank(model.getApplyNo())) { |
||||
model.setErrorMessage("请填写申请单号"); |
||||
errorData.add(model); |
||||
return; |
||||
} |
||||
// 订单开票
|
||||
BsGasOrderReceipt receipt = gasOrderReceiptService.getDetail(model.getApplyNo()); |
||||
if (receipt == null) { |
||||
model.setErrorMessage("未找到申请单号数据"); |
||||
errorData.add(model); |
||||
return; |
||||
} |
||||
if (!receipt.getStatus().equals(GasOrderReceiptStatusEnum.status1.getStatus())) { |
||||
model.setErrorMessage("开票不处于待开票状态"); |
||||
errorData.add(model); |
||||
return; |
||||
} |
||||
receipt.setStatus(GasOrderReceiptStatusEnum.status2.getStatus()); |
||||
successData.add(receipt); |
||||
} |
||||
|
||||
/** |
||||
* @Author 胡锐 |
||||
* @Description 所有数据解析完成了 都会来调用此方法 |
||||
* @Date 2021/3/20 21:08 |
||||
**/ |
||||
@Override |
||||
public void doAfterAllAnalysed(AnalysisContext analysisContext) { |
||||
if (!successData.isEmpty()) { |
||||
gasOrderReceiptService.batchInsert(successData); |
||||
} |
||||
this.successData.clear(); |
||||
} |
||||
|
||||
public List<ImportCompleteGasOrderReceiptModel> getErrorData() { |
||||
return errorData; |
||||
} |
||||
|
||||
public void initData(BsGasOrderReceiptService gasOrderReceiptService) { |
||||
this.gasOrderReceiptService = gasOrderReceiptService; |
||||
} |
||||
} |
@ -0,0 +1,20 @@ |
||||
package com.bweb.excel.model; |
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty; |
||||
import lombok.Data; |
||||
|
||||
/** |
||||
* 导入完成开票订单模型 |
||||
* @author hurui |
||||
*/ |
||||
@Data |
||||
public class ImportCompleteGasOrderReceiptModel { |
||||
|
||||
@ExcelProperty("申请单号") |
||||
private String applyNo; |
||||
/** |
||||
* 错误消息 |
||||
*/ |
||||
private String errorMessage; |
||||
|
||||
} |
@ -1,7 +1,60 @@ |
||||
package com.hfkj.dao; |
||||
|
||||
import com.hfkj.entity.BsGasOrderReceipt; |
||||
import org.apache.ibatis.annotations.Insert; |
||||
import org.apache.ibatis.annotations.Options; |
||||
import org.apache.ibatis.annotations.Param; |
||||
|
||||
import java.util.List; |
||||
|
||||
/** |
||||
* mapper扩展类 |
||||
*/ |
||||
public interface BsGasOrderReceiptMapperExt { |
||||
} |
||||
|
||||
@Insert({ |
||||
"<script>" + |
||||
" insert into bs_gas_order_receipt (apply_no, user_receipt_id, ", |
||||
" company_name, tax_no, ", |
||||
" contacts_phone, email, ", |
||||
" agent_id, agent_name, ", |
||||
" agent_staff_id, agent_staff_name, ", |
||||
" mer_no, mer_name, ", |
||||
" order_no, order_child_no, ", |
||||
" oil_no, amount, `status`, ", |
||||
" fail_remark, create_time, ", |
||||
" update_time, ext_1, ", |
||||
" ext_2, ext_3)", |
||||
" values " + |
||||
" <foreach collection='list' item='item' index='index' separator=','>" + |
||||
" (" + |
||||
" #{item.applyNo,jdbcType=VARCHAR}, " + |
||||
" #{item.userReceiptId,jdbcType=BIGINT}, ", |
||||
" #{item.companyName,jdbcType=VARCHAR}," + |
||||
" #{item.taxNo,jdbcType=VARCHAR}, ", |
||||
" #{item.contactsPhone,jdbcType=VARCHAR}," + |
||||
" #{item.email,jdbcType=VARCHAR}, ", |
||||
" #{item.agentId,jdbcType=BIGINT}, " + |
||||
" #{item.agentName,jdbcType=VARCHAR}, ", |
||||
" #{item.agentStaffId,jdbcType=BIGINT}," + |
||||
" #{item.agentStaffName,jdbcType=VARCHAR}, ", |
||||
" #{item.merNo,jdbcType=VARCHAR}, " + |
||||
" #{item.merName,jdbcType=VARCHAR}, ", |
||||
" #{item.orderNo,jdbcType=VARCHAR}, " + |
||||
" #{item.orderChildNo,jdbcType=VARCHAR}, ", |
||||
" #{item.oilNo,jdbcType=VARCHAR}," + |
||||
" #{item.amount,jdbcType=DECIMAL}, " + |
||||
" #{item.status,jdbcType=INTEGER}, ", |
||||
" #{item.failRemark,jdbcType=VARCHAR}," + |
||||
" #{item.createTime,jdbcType=TIMESTAMP}, ", |
||||
" #{item.updateTime,jdbcType=TIMESTAMP}," + |
||||
" #{item.ext1,jdbcType=VARCHAR}, ", |
||||
" #{item.ext2,jdbcType=VARCHAR}," + |
||||
" #{item.ext3,jdbcType=VARCHAR}" + |
||||
" )" + |
||||
" </foreach>" + |
||||
"</script>" |
||||
}) |
||||
@Options(useGeneratedKeys=true, keyProperty="id") |
||||
void batchInsert(@Param("list") List<BsGasOrderReceipt> data); |
||||
} |
||||
|
Loading…
Reference in new issue