|
|
|
@ -1,5 +1,6 @@ |
|
|
|
|
package com.bweb.controller; |
|
|
|
|
|
|
|
|
|
import com.alibaba.excel.EasyExcel; |
|
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
|
import com.github.pagehelper.PageHelper; |
|
|
|
|
import com.github.pagehelper.PageInfo; |
|
|
|
@ -8,14 +9,19 @@ import com.hfkj.common.exception.ErrorHelp; |
|
|
|
|
import com.hfkj.common.exception.SysCode; |
|
|
|
|
import com.hfkj.common.security.UserCenter; |
|
|
|
|
import com.hfkj.common.utils.ResponseMsgUtil; |
|
|
|
|
import com.hfkj.config.CommonSysConst; |
|
|
|
|
import com.hfkj.entity.BsAgentMer; |
|
|
|
|
import com.hfkj.entity.BsGasOrderReceipt; |
|
|
|
|
import com.hfkj.model.AgentMerAllot; |
|
|
|
|
import com.hfkj.model.ResponseData; |
|
|
|
|
import com.hfkj.model.SecUserSessionObject; |
|
|
|
|
import com.hfkj.model.UserSessionObject; |
|
|
|
|
import com.hfkj.model.order.ExportGasOrderModel; |
|
|
|
|
import com.hfkj.model.order.ExportGasOrderReceiptModel; |
|
|
|
|
import com.hfkj.service.agent.BsAgentMerService; |
|
|
|
|
import com.hfkj.service.gas.BsGasOrderReceiptService; |
|
|
|
|
import com.hfkj.sysenum.SecUserObjectTypeEnum; |
|
|
|
|
import com.hfkj.sysenum.gas.GasOrderReceiptStatusEnum; |
|
|
|
|
import io.swagger.annotations.Api; |
|
|
|
|
import io.swagger.annotations.ApiOperation; |
|
|
|
|
import org.apache.commons.collections4.MapUtils; |
|
|
|
@ -26,6 +32,7 @@ import org.springframework.stereotype.Controller; |
|
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
|
import java.io.File; |
|
|
|
|
import java.util.*; |
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
import java.util.stream.IntStream; |
|
|
|
@ -127,4 +134,70 @@ public class BsGasOrderReceiptController { |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@RequestMapping(value="/export",method = RequestMethod.GET) |
|
|
|
|
@ResponseBody |
|
|
|
|
@ApiOperation(value = "导出") |
|
|
|
|
public ResponseData export(@RequestParam(name = "orderNo", required = false) String orderNo, |
|
|
|
|
@RequestParam(name = "merName", required = false) String merName, |
|
|
|
|
@RequestParam(name = "contactsPhone", required = false) String contactsPhone, |
|
|
|
|
@RequestParam(name = "status", required = false) Integer status, |
|
|
|
|
@RequestParam(name = "createTimeS", required = false) Long createTimeS, |
|
|
|
|
@RequestParam(name = "createTimeE", required = false) Long createTimeE) { |
|
|
|
|
try { |
|
|
|
|
Map<String,Object> param = new HashMap<>(); |
|
|
|
|
SecUserSessionObject sessionObject = userCenter.getSessionModel(SecUserSessionObject.class); |
|
|
|
|
if (sessionObject.getAccount().getObjectType().equals(SecUserObjectTypeEnum.type1.getCode())) { |
|
|
|
|
|
|
|
|
|
} else if (sessionObject.getAccount().getObjectType().equals(SecUserObjectTypeEnum.type4.getCode())) { |
|
|
|
|
param.put("agentId", sessionObject.getAccount().getObjectId()); |
|
|
|
|
|
|
|
|
|
} else if (sessionObject.getAccount().getObjectType().equals(SecUserObjectTypeEnum.type5.getCode())) { |
|
|
|
|
param.put("agentStaffId", sessionObject.getAccount().getObjectId()); |
|
|
|
|
} else { |
|
|
|
|
throw ErrorHelp.genException(SysCode.System, ErrorCode.ROLE_NOT_PERMISSIONS, ""); |
|
|
|
|
} |
|
|
|
|
param.put("orderNo", orderNo); |
|
|
|
|
param.put("merName", merName); |
|
|
|
|
param.put("contactsPhone", contactsPhone); |
|
|
|
|
param.put("status", status); |
|
|
|
|
param.put("createTimeS", createTimeS); |
|
|
|
|
param.put("createTimeE", createTimeE); |
|
|
|
|
|
|
|
|
|
// 查询数据
|
|
|
|
|
List<BsGasOrderReceipt> dataList = gasOrderReceiptService.getList(param); |
|
|
|
|
List<ExportGasOrderReceiptModel> exportList = new ArrayList<>(); |
|
|
|
|
ExportGasOrderReceiptModel exportModel; |
|
|
|
|
for (BsGasOrderReceipt data : dataList) { |
|
|
|
|
exportModel = new ExportGasOrderReceiptModel(); |
|
|
|
|
exportModel.setOrderNo(data.getOrderNo()); |
|
|
|
|
exportModel.setMerName(data.getMerName()); |
|
|
|
|
exportModel.setOilNo(data.getOilNo()); |
|
|
|
|
exportModel.setCompanyName(data.getCompanyName()); |
|
|
|
|
exportModel.setTaxNo(data.getTaxNo()); |
|
|
|
|
exportModel.setAmount(data.getAmount()); |
|
|
|
|
exportModel.setContactsPhone(data.getContactsPhone()); |
|
|
|
|
exportModel.setEmail(data.getEmail()); |
|
|
|
|
exportModel.setCreateTime(data.getCreateTime()); |
|
|
|
|
exportModel.setStatus(GasOrderReceiptStatusEnum.getNameByType(data.getStatus()).getManageName()); |
|
|
|
|
exportList.add(exportModel); |
|
|
|
|
} |
|
|
|
|
String fileUrl = CommonSysConst.getSysConfig().getFilesystem() + "/temporary/"; |
|
|
|
|
String pathName = System.currentTimeMillis()+".xlsx"; |
|
|
|
|
File file = new File(fileUrl); |
|
|
|
|
if (!file.exists()) { |
|
|
|
|
file.mkdirs(); |
|
|
|
|
} |
|
|
|
|
EasyExcel.write(fileUrl+pathName) |
|
|
|
|
.head(ExportGasOrderReceiptModel.class) |
|
|
|
|
.sheet("加油订单开票") |
|
|
|
|
.doWrite(exportList); |
|
|
|
|
return ResponseMsgUtil.success(pathName); |
|
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.error("error!",e); |
|
|
|
|
return ResponseMsgUtil.exception(e); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|