|
|
@@ -0,0 +1,686 @@
|
|
|
+package com.huyi.service.cost.controller;
|
|
|
+
|
|
|
+import com.alibaba.csp.sentinel.log.Logger;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.huyi.service.base.entity.SysCompany;
|
|
|
+import com.huyi.service.base.entity.ZcChargeInf;
|
|
|
+import com.huyi.service.base.entity.ZcInvoiceAddress;
|
|
|
+import com.huyi.service.base.service.ISysCompanyService;
|
|
|
+import com.huyi.service.base.service.IZcChargeInfService;
|
|
|
+import com.huyi.service.base.service.IZcInvoiceAddressService;
|
|
|
+import com.huyi.service.conmany.service.IOwnCompanyManageService;
|
|
|
+import com.huyi.service.cost.service.IOwnCostManageService;
|
|
|
+import com.keao.tianhu.starter.mybatis.plus.entity.QueryRequest;
|
|
|
+import com.tianhu.common.core.constant.SalaryConstants;
|
|
|
+import com.tianhu.common.core.domain.R;
|
|
|
+import com.tianhu.common.core.utils.CommonUtil;
|
|
|
+import com.tianhu.common.core.utils.DateUtils;
|
|
|
+import com.tianhu.common.core.utils.IdUtils;
|
|
|
+import com.tianhu.common.core.utils.file.ExcelFileUtils;
|
|
|
+import com.tianhu.common.core.web.controller.BaseController;
|
|
|
+import com.tianhu.common.log.annotation.Log;
|
|
|
+import com.tianhu.common.log.enums.BusinessType;
|
|
|
+import com.tianhu.common.redis.common.RedisUtils;
|
|
|
+import com.tianhu.common.redis.domain.SysDictData;
|
|
|
+import com.tianhu.common.security.annotation.PreAuthorize;
|
|
|
+import com.tianhu.common.security.service.TokenService;
|
|
|
+import com.tianhu.system.api.model.LoginUser;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
|
|
+import org.checkerframework.checker.units.qual.C;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+import java.io.IOException;
|
|
|
+import java.io.OutputStream;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.regex.Matcher;
|
|
|
+import java.util.regex.Pattern;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 费用Controller
|
|
|
+ *
|
|
|
+ * @author keao
|
|
|
+ * @date 2020-12-16
|
|
|
+ */
|
|
|
+@Slf4j
|
|
|
+@RestController
|
|
|
+@RequestMapping("/cost")
|
|
|
+public class OwnCostManageController extends BaseController
|
|
|
+{
|
|
|
+ @Autowired
|
|
|
+ private IOwnCostManageService iOwnCostManageService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ISysCompanyService iSysCompanyService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IZcInvoiceAddressService iZcInvoiceAddressService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IZcChargeInfService iZcChargeInfService;
|
|
|
+
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private TokenService tokenService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 申请开票
|
|
|
+ */
|
|
|
+ private String CONFIRM_STATE = "01";
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 发票作废
|
|
|
+ */
|
|
|
+ private String DELETE_STATE = "99";
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询费用列表
|
|
|
+ * @param zfrNumber 融资编号
|
|
|
+ * @param zciStatus 费用状态
|
|
|
+ * @param zciInvoiceStatus 发票状态
|
|
|
+ * @param request
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+@PreAuthorize(hasPermi = "service:cost:list")
|
|
|
+@GetMapping("/list")
|
|
|
+public R list(String zfrNumber, String zciStatus, String zciInvoiceStatus,
|
|
|
+ @RequestParam(required = false) Map dateRange,String zfrStatus,
|
|
|
+ QueryRequest request)
|
|
|
+{
|
|
|
+ String beginTime = CommonUtil.objToString(dateRange.get("params[beginTime]"));
|
|
|
+ String endTime = CommonUtil.objToString(dateRange.get("params[endTime]"));
|
|
|
+ //获取当前操作员
|
|
|
+ LoginUser user = tokenService.getLoginUser();
|
|
|
+ String companyId = user.getSysUser().getCompanyId();
|
|
|
+ String userId = String.valueOf(user.getSysUser().getUserId());
|
|
|
+ IPage<Map> list = null;
|
|
|
+ Map map = new HashMap();
|
|
|
+ //融资编号
|
|
|
+ if(CommonUtil.isNotEmpty(zfrNumber)){
|
|
|
+ map.put("zfrNumber", zfrNumber);
|
|
|
+ }
|
|
|
+ //费用状态
|
|
|
+ if(CommonUtil.isNotEmpty(zciStatus)) {
|
|
|
+ map.put("zciStatus", zciStatus);
|
|
|
+ }
|
|
|
+ //融资状态
|
|
|
+ if(CommonUtil.isNotEmpty(zfrStatus)){
|
|
|
+ map.put("zfrStatus", zfrStatus);
|
|
|
+ }
|
|
|
+ //发票状态
|
|
|
+ if(CommonUtil.isNotEmpty(zciInvoiceStatus)){
|
|
|
+ map.put("zciInvoiceStatus",zciInvoiceStatus);
|
|
|
+ }
|
|
|
+ //创建时间区间
|
|
|
+ map.put("beginTime", beginTime);
|
|
|
+ map.put("endTime", endTime);
|
|
|
+ if (SalaryConstants.OPEX.equals(companyId)) {
|
|
|
+ list = iOwnCostManageService.selectAdminCost(request, map);
|
|
|
+ }else {
|
|
|
+ //融资企业Id
|
|
|
+ map.put("companyId",companyId);
|
|
|
+ list = iOwnCostManageService.selectCost(request, map);
|
|
|
+ }
|
|
|
+ return R.ok(list);
|
|
|
+}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询开票列表
|
|
|
+ * @param zfrNumber 融资编号
|
|
|
+ * @param zciStatus 费用状态
|
|
|
+ * @param zciInvoiceStatus 发票状态
|
|
|
+ * @param request
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @PreAuthorize(hasPermi = "service:cost:list")
|
|
|
+ @GetMapping("/listInvoice")
|
|
|
+ public R listInvoice(String zfrNumber, String zciStatus, String zciInvoiceStatus,
|
|
|
+ @RequestParam(required = false) Map dateInvoiceRange, String zfrStatus,
|
|
|
+ QueryRequest request)
|
|
|
+ {
|
|
|
+ String beginInvoiceTime = CommonUtil.objToString(dateInvoiceRange.get("params[beginTime]"));
|
|
|
+ String endInvoiceTime = CommonUtil.objToString(dateInvoiceRange.get("params[endTime]"));
|
|
|
+ //获取当前操作员
|
|
|
+ LoginUser user = tokenService.getLoginUser();
|
|
|
+ Map map = new HashMap();
|
|
|
+ //融资编号
|
|
|
+ if(CommonUtil.isNotEmpty(zfrNumber)){
|
|
|
+ map.put("zfrNumber", zfrNumber);
|
|
|
+ }
|
|
|
+ //费用状态
|
|
|
+ if(CommonUtil.isNotEmpty(zciStatus)) {
|
|
|
+ map.put("zciStatus", zciStatus);
|
|
|
+ }
|
|
|
+ //发票状态
|
|
|
+ if(CommonUtil.isNotEmpty(zciInvoiceStatus)){
|
|
|
+ map.put("zciInvoiceStatus",zciInvoiceStatus);
|
|
|
+ }
|
|
|
+ //融资状态
|
|
|
+ if(CommonUtil.isNotEmpty(zfrStatus)){
|
|
|
+ map.put("zfrStatus", zfrStatus);
|
|
|
+ }
|
|
|
+ //创建时间区间
|
|
|
+ map.put("beginInvoiceTime", beginInvoiceTime);
|
|
|
+ map.put("endInvoiceTime", endInvoiceTime);
|
|
|
+ IPage<Map> list = iOwnCostManageService.selectAdminInvoice(request, map);
|
|
|
+ return R.ok(list);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询开票地址信息
|
|
|
+ */
|
|
|
+ @GetMapping("/invoiceList/{scyId}/{zciId}")
|
|
|
+ @Log(title = "查询发票地址信息列表", businessType = BusinessType.OTHER)
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public R invoiceList(@PathVariable("scyId") String scyId, @PathVariable("zciId") String zciId)throws Exception {
|
|
|
+ Map map = new HashMap();
|
|
|
+ map.put("companyId",scyId);
|
|
|
+ //查询企业发票信息
|
|
|
+ List<Map> list = iOwnCostManageService.selectInvoiceList(map);
|
|
|
+ //获取当前费用的快递单号
|
|
|
+ ZcChargeInf zcChargeInf = iZcChargeInfService.getById(zciId);
|
|
|
+ String zciExpressNo = zcChargeInf.getZciExpressNo();
|
|
|
+ //合并数据
|
|
|
+ for (Map listMap : list){
|
|
|
+ listMap.put("zciExpressNo",zciExpressNo);
|
|
|
+ }
|
|
|
+
|
|
|
+ return R.ok(list);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 申请开票
|
|
|
+ */
|
|
|
+ @PreAuthorize(hasPermi = "service:cost:apply")
|
|
|
+ @Log(title = "申请开票", businessType = BusinessType.UPDATE)
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ @PutMapping("/applyInvoice")
|
|
|
+ public R applyInvoice(@RequestBody Map<String,Object> map) throws Exception {
|
|
|
+ //获取当前操作员
|
|
|
+ LoginUser user = tokenService.getLoginUser();
|
|
|
+ String userId = String.valueOf(user.getSysUser().getUserId());
|
|
|
+
|
|
|
+ //费用Id
|
|
|
+ String zciId = CommonUtil.objToString(map.get("zciId"));
|
|
|
+ if(CommonUtil.isEmpty(zciId)){
|
|
|
+ throw new Exception("申请开票的费用数据不能为空");
|
|
|
+ }
|
|
|
+ //企业名称
|
|
|
+ String scyName = CommonUtil.objToString(map.get("scyName"));
|
|
|
+ //统一社会信用代码
|
|
|
+ String scySocialCode = CommonUtil.objToString(map.get("scySocialCode"));
|
|
|
+ //企业Id
|
|
|
+ String scyId = "";
|
|
|
+ LambdaQueryWrapper<SysCompany> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ queryWrapper.eq(SysCompany::getScyName,scyName);
|
|
|
+ queryWrapper.eq(SysCompany::getScySocialCode,scySocialCode);
|
|
|
+ List<SysCompany> list = iSysCompanyService.findSysCompanys(queryWrapper);
|
|
|
+ if(list.size() > 0){
|
|
|
+ scyId = list.get(0).getScyId();
|
|
|
+ }
|
|
|
+ //收件人
|
|
|
+ String ziaContacts = CommonUtil.objToString(map.get("ziaContacts"));
|
|
|
+ if(CommonUtil.isEmpty(ziaContacts)){
|
|
|
+ throw new Exception("收件人不能为空");
|
|
|
+ }
|
|
|
+ if(ziaContacts.length() > 30){
|
|
|
+ throw new Exception("收件人过长");
|
|
|
+ }
|
|
|
+ //收件人电话
|
|
|
+ String ziaContactsPhone = CommonUtil.objToString(map.get("ziaContactsPhone"));
|
|
|
+ if(CommonUtil.isNotEmpty(ziaContactsPhone)) {
|
|
|
+ if(ziaContactsPhone.length() > 11){
|
|
|
+ throw new Exception("收件人电话不能超过11位");
|
|
|
+ }
|
|
|
+ String checkPhone = "^1[3|4|5|6|7|8|9][0-9]\\d{8}$";
|
|
|
+ Pattern regePhone = Pattern.compile(checkPhone);
|
|
|
+ Matcher matcherPhone = regePhone.matcher(ziaContactsPhone);
|
|
|
+ boolean isMatPhone = matcherPhone.matches();
|
|
|
+ if (!isMatPhone) {
|
|
|
+ throw new Exception("收件人电话格式不正确");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //邮寄地址
|
|
|
+ String ziaAddress = CommonUtil.objToString(map.get("ziaAddress"));
|
|
|
+ if(CommonUtil.isNotEmpty(ziaAddress)) {
|
|
|
+ if(ziaAddress.length() > 30){
|
|
|
+ throw new Exception("邮寄地址不能超过30位");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //判断企业否存在开票信息
|
|
|
+ LambdaQueryWrapper<ZcInvoiceAddress> zcInvoice = new LambdaQueryWrapper<>();
|
|
|
+ zcInvoice.eq(ZcInvoiceAddress::getZiaCompanyId,scyId);
|
|
|
+ List<ZcInvoiceAddress> addressList = iZcInvoiceAddressService.findZcInvoiceAddresss(zcInvoice);
|
|
|
+ if(addressList.size() > 0){
|
|
|
+ //如果企业存在开票信息则修改信息
|
|
|
+ ZcInvoiceAddress zcInvoiceAddress = new ZcInvoiceAddress();
|
|
|
+ //主键
|
|
|
+ zcInvoiceAddress.setZiaId(addressList.get(0).getZiaId());
|
|
|
+ //企业Id
|
|
|
+ zcInvoiceAddress.setZiaCompanyId(scyId);
|
|
|
+ //收件地址
|
|
|
+ zcInvoiceAddress.setZiaAddress(ziaAddress);
|
|
|
+ //收件人
|
|
|
+ zcInvoiceAddress.setZiaContacts(ziaContacts);
|
|
|
+ //收件人电话
|
|
|
+ zcInvoiceAddress.setZiaContactsPhone(ziaContactsPhone);
|
|
|
+ //修改人
|
|
|
+ zcInvoiceAddress.setUpdateBy(userId);
|
|
|
+ //修改时间
|
|
|
+ zcInvoiceAddress.setUpdateTime(DateUtils.getNowDate());
|
|
|
+ //执行
|
|
|
+ iZcInvoiceAddressService.updateById(zcInvoiceAddress);
|
|
|
+ }else {
|
|
|
+ //如果企业不存在开票信息则新增开票信息
|
|
|
+ ZcInvoiceAddress zcInvoiceAddress = new ZcInvoiceAddress();
|
|
|
+ //创建主键
|
|
|
+ String scrId = IdUtils.fastSimpleUUID();
|
|
|
+ zcInvoiceAddress.setZiaId(scrId);
|
|
|
+ //企业Id
|
|
|
+ zcInvoiceAddress.setZiaCompanyId(scyId);
|
|
|
+ //收件地址
|
|
|
+ zcInvoiceAddress.setZiaAddress(ziaAddress);
|
|
|
+ //收件人
|
|
|
+ zcInvoiceAddress.setZiaContacts(ziaContacts);
|
|
|
+ //收件电话
|
|
|
+ zcInvoiceAddress.setZiaContactsPhone(ziaContactsPhone);
|
|
|
+ //创建人
|
|
|
+ zcInvoiceAddress.setCreateBy(userId);
|
|
|
+ //创建时间
|
|
|
+ zcInvoiceAddress.setCreateTime(DateUtils.getNowDate());
|
|
|
+ //执行
|
|
|
+ iZcInvoiceAddressService.createZcInvoiceAddress(zcInvoiceAddress);
|
|
|
+ }
|
|
|
+ //执行申请开票
|
|
|
+ ZcChargeInf zcChargeInf = new ZcChargeInf();
|
|
|
+ //费用Id
|
|
|
+ zcChargeInf.setZciId(zciId);
|
|
|
+ //开票状态(01:申请开票)
|
|
|
+ zcChargeInf.setZciInvoiceStatus("1");
|
|
|
+ //修改人
|
|
|
+ zcChargeInf.setUpdateBy(userId);
|
|
|
+ //修改时间
|
|
|
+ zcChargeInf.setUpdateTime(DateUtils.getNowDate());
|
|
|
+ //执行
|
|
|
+ iZcChargeInfService.updateById(zcChargeInf);
|
|
|
+ return R.ok();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 开票或冲红或修改快递单号
|
|
|
+ * @param map
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @PreAuthorize(hasPermi = "service:cost:update")
|
|
|
+ @Log(title = "开票或冲红或修改快递单号", businessType = BusinessType.UPDATE)
|
|
|
+ @PutMapping("/invoicing")
|
|
|
+ public R invoicing(@RequestBody Map<String,Object> map) throws Exception
|
|
|
+ {
|
|
|
+ //获取当前操作员
|
|
|
+ LoginUser user = tokenService.getLoginUser();
|
|
|
+ String userId = String.valueOf(user.getSysUser().getUserId());
|
|
|
+ //开票状态
|
|
|
+ String zciInvoiceStatus = CommonUtil.objToString(map.get("zciInvoiceStatus"));
|
|
|
+ //费用Id
|
|
|
+ String zciId = CommonUtil.objToString(map.get("zciId"));
|
|
|
+ if(CommonUtil.isEmpty(zciId)){
|
|
|
+ throw new Exception("开票的费用数据不能为空");
|
|
|
+ }
|
|
|
+ //快递单号
|
|
|
+ String zciExpressNo = CommonUtil.objToString(map.get("zciExpressNo"));
|
|
|
+ //判断开票或冲红
|
|
|
+ if(CommonUtil.isNotEmpty(zciInvoiceStatus)){
|
|
|
+ if("2".equals(zciInvoiceStatus) || "4".equals(zciInvoiceStatus)) {
|
|
|
+ if (CommonUtil.isEmpty(zciExpressNo)) {
|
|
|
+ throw new Exception("快递单号不能为空");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if(CommonUtil.isNotEmpty(zciExpressNo)){
|
|
|
+ //快递单号正则校验
|
|
|
+ String regex = "[^\\u4e00-\\u9fa5]+";
|
|
|
+ Pattern regeExpressNo = Pattern.compile(regex);
|
|
|
+ Matcher matcherExpressNo = regeExpressNo.matcher(zciExpressNo);
|
|
|
+ boolean isMatExpressNo = matcherExpressNo.matches();
|
|
|
+ if(!isMatExpressNo){
|
|
|
+ throw new Exception("快递单号格式不正确");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //执行
|
|
|
+ ZcChargeInf zcChargeInf = new ZcChargeInf();
|
|
|
+ //费用Id
|
|
|
+ zcChargeInf.setZciId(zciId);
|
|
|
+ //快递单号
|
|
|
+ if(CommonUtil.isNotEmpty(zciExpressNo)) {
|
|
|
+ zcChargeInf.setZciExpressNo(zciExpressNo);
|
|
|
+ }
|
|
|
+ //开票状态
|
|
|
+ if(CommonUtil.isNotEmpty(zciInvoiceStatus)) {
|
|
|
+ zcChargeInf.setZciInvoiceStatus(zciInvoiceStatus);
|
|
|
+ }
|
|
|
+ //修改人
|
|
|
+ zcChargeInf.setUpdateBy(userId);
|
|
|
+ //修改时间
|
|
|
+ zcChargeInf.setUpdateTime(DateUtils.getNowDate());
|
|
|
+ iZcChargeInfService.updateById(zcChargeInf);
|
|
|
+ return R.ok();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 开票作废
|
|
|
+ * @param zciId
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @PreAuthorize(hasPermi = "service:cost:delete")
|
|
|
+ @Log(title = "开票", businessType = BusinessType.DELETE)
|
|
|
+ @DeleteMapping("/{zciId}")
|
|
|
+ public R daleteInvoice(@PathVariable String zciId) throws Exception
|
|
|
+ {
|
|
|
+ //获取当前操作员
|
|
|
+ LoginUser user = tokenService.getLoginUser();
|
|
|
+ String userId = String.valueOf(user.getSysUser().getUserId());
|
|
|
+ //修改信息
|
|
|
+ ZcChargeInf zcChargeInf = new ZcChargeInf();
|
|
|
+ //主键
|
|
|
+ zcChargeInf.setZciId(zciId);
|
|
|
+ //作废状态
|
|
|
+ zcChargeInf.setZciInvoiceStatus(DELETE_STATE);
|
|
|
+ //清空快递单号
|
|
|
+ zcChargeInf.setZciExpressNo("");
|
|
|
+ //修改人
|
|
|
+ zcChargeInf.setUpdateBy(userId);
|
|
|
+ //修改时间
|
|
|
+ zcChargeInf.setUpdateTime(DateUtils.getNowDate());
|
|
|
+ //执行修改
|
|
|
+ iZcChargeInfService.updateById(zcChargeInf);
|
|
|
+ return R.ok();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 导出费用列表
|
|
|
+ * @param response
|
|
|
+ * @param zfrNumber 融资编号
|
|
|
+ * @param zciStatus 费用状态
|
|
|
+ * @param zciInvoiceStatus 发票状态
|
|
|
+ * @param dateRange 时间范围
|
|
|
+ */
|
|
|
+ @PreAuthorize(hasPermi = "service:cost:export")
|
|
|
+ @Log(title = "导出费用", businessType = BusinessType.EXPORT)
|
|
|
+ @PostMapping("/export")
|
|
|
+ public void export(HttpServletResponse response,String zfrNumber,
|
|
|
+ String zciStatus, String zciInvoiceStatus,String zfrStatus,
|
|
|
+ @RequestParam(required = false) Map dateRange){
|
|
|
+ //时间范围
|
|
|
+ String beginTime = CommonUtil.objToString(dateRange.get("0"));
|
|
|
+ String endTime = CommonUtil.objToString(dateRange.get("1"));
|
|
|
+ //获取当前操作员
|
|
|
+ LoginUser user = tokenService.getLoginUser();
|
|
|
+ String companyId = user.getSysUser().getCompanyId();
|
|
|
+ String userId = String.valueOf(user.getSysUser().getUserId());
|
|
|
+ //定义结果集合
|
|
|
+ List<Map> list = null;
|
|
|
+ //查询map条件
|
|
|
+ Map map = new HashMap();
|
|
|
+ //融资编号
|
|
|
+ if(CommonUtil.isNotEmpty(zfrNumber)){
|
|
|
+ map.put("zfrNumber", zfrNumber);
|
|
|
+ }
|
|
|
+ //费用状态
|
|
|
+ if(CommonUtil.isNotEmpty(zciStatus)) {
|
|
|
+ map.put("zciStatus", zciStatus);
|
|
|
+ }
|
|
|
+ //发票状态
|
|
|
+ if(CommonUtil.isNotEmpty(zciInvoiceStatus)){
|
|
|
+ map.put("zciInvoiceStatus",zciInvoiceStatus);
|
|
|
+ }
|
|
|
+ //融资状态
|
|
|
+ if(CommonUtil.isNotEmpty(zfrStatus)){
|
|
|
+ map.put("zfrStatus",zfrStatus);
|
|
|
+ }
|
|
|
+ //创建时间区间
|
|
|
+ map.put("beginTime", beginTime);
|
|
|
+ map.put("endTime", endTime);
|
|
|
+ if("1".equals(userId)){
|
|
|
+ list = iOwnCostManageService.selectAdminCost(map);
|
|
|
+ }else {
|
|
|
+ //融资企业Id
|
|
|
+ map.put("companyId",companyId);
|
|
|
+ list = iOwnCostManageService.selectCost(map);
|
|
|
+ }
|
|
|
+
|
|
|
+ //处理字典数据
|
|
|
+// List<SysDictData> state = RedisUtils.getDictCache("ser_zci_status");
|
|
|
+// //状态遍历
|
|
|
+// Map<String,String> zciStatusMap = new HashMap();
|
|
|
+// for (Object object : state) {
|
|
|
+// if (object instanceof SysDictData) {
|
|
|
+// SysDictData dictData = (SysDictData)object;
|
|
|
+// zciStatusMap.put(dictData.getDictValue(),dictData.getDictLabel());
|
|
|
+// } else if (object instanceof JSONObject) {
|
|
|
+// JSONObject dictData = (JSONObject)object;
|
|
|
+// zciStatusMap.put(String.valueOf(dictData.get("dictValue")),String.valueOf(dictData.get("dictLabel")));
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+// List<SysDictData> invoiceStatus = RedisUtils.getDictCache("ser_zci_invoice_status");
|
|
|
+// //遍历方式
|
|
|
+// Map<String,String> zciInvoiceStatusMap = new HashMap();
|
|
|
+// for (Object object : invoiceStatus) {
|
|
|
+// if (object instanceof SysDictData) {
|
|
|
+// SysDictData dictData = (SysDictData)object;
|
|
|
+// zciInvoiceStatusMap.put(dictData.getDictValue(),dictData.getDictLabel());
|
|
|
+// } else if (object instanceof JSONObject) {
|
|
|
+// JSONObject dictData = (JSONObject)object;
|
|
|
+// zciInvoiceStatusMap.put(String.valueOf(dictData.get("dictValue")),String.valueOf(dictData.get("dictLabel")));
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+// List<SysDictData> zfr = RedisUtils.getDictCache("ser_zfr_status");
|
|
|
+// //遍历方式
|
|
|
+// Map<String,String> zfrStatusMap = new HashMap();
|
|
|
+// for (Object object : zfr) {
|
|
|
+// if (object instanceof SysDictData) {
|
|
|
+// SysDictData dictData = (SysDictData)object;
|
|
|
+// zfrStatusMap.put(dictData.getDictValue(),dictData.getDictLabel());
|
|
|
+// } else if (object instanceof JSONObject) {
|
|
|
+// JSONObject dictData = (JSONObject)object;
|
|
|
+// zfrStatusMap.put(String.valueOf(dictData.get("dictValue")),String.valueOf(dictData.get("dictLabel")));
|
|
|
+// }
|
|
|
+// }
|
|
|
+// System.out.println("zciStatusMap====>"+zciStatusMap);
|
|
|
+// System.out.println("zciInvoiceStatusMap====>"+zciInvoiceStatusMap);
|
|
|
+// System.out.println("zfrStatusMap====>"+zfrStatusMap);
|
|
|
+// for (Map maps : list) {
|
|
|
+// //费用状态
|
|
|
+// zciStatus = String.valueOf(maps.get("zciStatus"));
|
|
|
+// maps.put("zciStatus", zciStatusMap.get(zciStatus));
|
|
|
+// //费用发票状态
|
|
|
+// zciInvoiceStatus = String.valueOf(maps.get("zciInvoiceStatus"));
|
|
|
+// maps.put("zciInvoiceStatus", zciInvoiceStatusMap.get(zciInvoiceStatus));
|
|
|
+// //融资状态
|
|
|
+// zfrStatus = String.valueOf(maps.get("zfrStatus"));
|
|
|
+// maps.put("zfrStatus", zfrStatusMap.get(zfrStatus));
|
|
|
+// }
|
|
|
+
|
|
|
+ String fileName = "费用信息";
|
|
|
+ //查询表头
|
|
|
+ List<String> columnName = new ArrayList<>();
|
|
|
+ columnName.add("融资编号#zfrNumber");
|
|
|
+ columnName.add("融资企业#supScyName");
|
|
|
+ columnName.add("开立企业#coreScyName");
|
|
|
+ columnName.add("融资产品#zfpName");
|
|
|
+ columnName.add("融资金额#zfrAmount");
|
|
|
+ columnName.add("融资状态#zfrStatus");
|
|
|
+ columnName.add("费用状态#zciStatus");
|
|
|
+ columnName.add("创建时间#createTime");
|
|
|
+ columnName.add("手续费#zciAmount");
|
|
|
+ columnName.add("发票状态#zciInvoiceStatus");
|
|
|
+ columnName.add("快递单号#zciExpressNo");
|
|
|
+ try {
|
|
|
+ HSSFWorkbook wb = ExcelFileUtils.export(response, fileName, columnName, list);
|
|
|
+ response.setCharacterEncoding("UTF-8");
|
|
|
+ // 设置contentType为excel格式
|
|
|
+ response.setContentType("application/vnd.ms-excel;charset=utf-8");
|
|
|
+ //默认Excel名称
|
|
|
+ response.setHeader("Content-disposition", "attachment;filename=" + "费用信息.xls");
|
|
|
+ response.flushBuffer();
|
|
|
+ OutputStream outputStream = response.getOutputStream();
|
|
|
+ wb.write(outputStream);
|
|
|
+ if (outputStream != null) {
|
|
|
+ try {
|
|
|
+ outputStream.close();
|
|
|
+ } catch (IOException var20) {
|
|
|
+ var20.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception var22) {
|
|
|
+ log.error("导出Excel异常{}", var22.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 导出费用发票列表
|
|
|
+ * @param response
|
|
|
+ * @param zfrNumber 融资编号
|
|
|
+ * @param zciStatus 费用状态
|
|
|
+ * @param zciInvoiceStatus 发票状态
|
|
|
+ * @param dateInvoiceRange 时间范围
|
|
|
+ */
|
|
|
+ @PreAuthorize(hasPermi = "service:cost:exportInvoice")
|
|
|
+ @Log(title = "导出费用发票列表", businessType = BusinessType.EXPORT)
|
|
|
+ @PostMapping("/exportInvoice")
|
|
|
+ public void exportInvoice(HttpServletResponse response,String zfrNumber, String zciStatus,
|
|
|
+ String zciInvoiceStatus, String zfrStatus,
|
|
|
+ @RequestParam(required = false) Map dateInvoiceRange){
|
|
|
+ //时间范围
|
|
|
+ String beginInvoiceTime = CommonUtil.objToString(dateInvoiceRange.get("0"));
|
|
|
+ String endInvoiceTime = CommonUtil.objToString(dateInvoiceRange.get("1"));
|
|
|
+ //查询map条件
|
|
|
+ Map map = new HashMap();
|
|
|
+ //融信编号
|
|
|
+ if(CommonUtil.isNotEmpty(zfrNumber)){
|
|
|
+ map.put("zfrNumber", zfrNumber);
|
|
|
+ }
|
|
|
+ //费用状态
|
|
|
+ if(CommonUtil.isNotEmpty(zciStatus)) {
|
|
|
+ map.put("zciStatus", zciStatus);
|
|
|
+ }
|
|
|
+ //发票状态
|
|
|
+ if(CommonUtil.isNotEmpty(zciInvoiceStatus)){
|
|
|
+ map.put("zciInvoiceStatus",zciInvoiceStatus);
|
|
|
+ }
|
|
|
+ //融资状态
|
|
|
+ if(CommonUtil.isNotEmpty(zfrStatus)){
|
|
|
+ map.put("zfrStatus",zfrStatus);
|
|
|
+ }
|
|
|
+ //创建时间区间
|
|
|
+ map.put("beginInvoiceTime", beginInvoiceTime);
|
|
|
+ map.put("endInvoiceTime", endInvoiceTime);
|
|
|
+ List<Map> list = iOwnCostManageService.selectAdminInvoice(map);
|
|
|
+
|
|
|
+ //处理字典数据
|
|
|
+// List<SysDictData> state = RedisUtils.getDictCache("ser_zci_status");
|
|
|
+// //状态遍历
|
|
|
+// Map<String,String> zciStatusMap = new HashMap();
|
|
|
+// for (Object object : state) {
|
|
|
+// if (object instanceof SysDictData) {
|
|
|
+// SysDictData dictData = (SysDictData)object;
|
|
|
+// zciStatusMap.put(dictData.getDictValue(),dictData.getDictLabel());
|
|
|
+// } else if (object instanceof JSONObject) {
|
|
|
+// JSONObject dictData = (JSONObject)object;
|
|
|
+// zciStatusMap.put(String.valueOf(dictData.get("dictValue")),String.valueOf(dictData.get("dictLabel")));
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+// List<SysDictData> invoiceStatus = RedisUtils.getDictCache("ser_zci_invoice_status");
|
|
|
+// //遍历方式
|
|
|
+// Map<String,String> zciInvoiceStatusMap = new HashMap();
|
|
|
+// for (Object object : invoiceStatus) {
|
|
|
+// if (object instanceof SysDictData) {
|
|
|
+// SysDictData dictData = (SysDictData)object;
|
|
|
+// zciInvoiceStatusMap.put(dictData.getDictValue(),dictData.getDictLabel());
|
|
|
+// } else if (object instanceof JSONObject) {
|
|
|
+// JSONObject dictData = (JSONObject)object;
|
|
|
+// zciInvoiceStatusMap.put(String.valueOf(dictData.get("dictValue")),String.valueOf(dictData.get("dictLabel")));
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+// List<SysDictData> zfr = RedisUtils.getDictCache("ser_zfr_status");
|
|
|
+// //遍历方式
|
|
|
+// Map<String,String> zfrStatusMap = new HashMap();
|
|
|
+// for (Object object : zfr) {
|
|
|
+// if (object instanceof SysDictData) {
|
|
|
+// SysDictData dictData = (SysDictData)object;
|
|
|
+// zfrStatusMap.put(dictData.getDictValue(),dictData.getDictLabel());
|
|
|
+// } else if (object instanceof JSONObject) {
|
|
|
+// JSONObject dictData = (JSONObject)object;
|
|
|
+// zfrStatusMap.put(String.valueOf(dictData.get("dictValue")),String.valueOf(dictData.get("dictLabel")));
|
|
|
+// }
|
|
|
+// }
|
|
|
+// System.out.println("zciStatusMap====>"+zciStatusMap);
|
|
|
+// System.out.println("zciInvoiceStatusMap====>"+zciInvoiceStatusMap);
|
|
|
+// System.out.println("zfrStatusMap====>"+zfrStatusMap);
|
|
|
+// for (Map maps : list) {
|
|
|
+// //费用状态
|
|
|
+// zciStatus = String.valueOf(maps.get("zciStatus"));
|
|
|
+// maps.put("zciStatus", zciStatusMap.get(zciStatus));
|
|
|
+// //费用发票状态
|
|
|
+// zciInvoiceStatus = String.valueOf(maps.get("zciInvoiceStatus"));
|
|
|
+// maps.put("zciInvoiceStatus", zciInvoiceStatusMap.get(zciInvoiceStatus));
|
|
|
+// //融资状态
|
|
|
+// zfrStatus = String.valueOf(maps.get("zfrStatus"));
|
|
|
+// maps.put("zfrStatus", zfrStatusMap.get(zfrStatus));
|
|
|
+// }
|
|
|
+
|
|
|
+ String fileName = "费用信息";
|
|
|
+ //查询表头
|
|
|
+ List<String> columnName = new ArrayList<>();
|
|
|
+ columnName.add("融资编号#zfrNumber");
|
|
|
+ columnName.add("融资企业#supScyName");
|
|
|
+ columnName.add("开立企业#coreScyName");
|
|
|
+ columnName.add("融资产品#zfpName");
|
|
|
+ columnName.add("融资金额#zfrAmount");
|
|
|
+ columnName.add("融资状态#zfrStatus");
|
|
|
+ columnName.add("费用状态#zciStatus");
|
|
|
+ columnName.add("创建时间#createTime");
|
|
|
+ columnName.add("手续费#zciAmount");
|
|
|
+ columnName.add("发票状态#zciInvoiceStatus");
|
|
|
+ columnName.add("快递单号#zciExpressNo");
|
|
|
+ try {
|
|
|
+ HSSFWorkbook wb = ExcelFileUtils.export(response, fileName, columnName, list);
|
|
|
+ response.setCharacterEncoding("UTF-8");
|
|
|
+ // 设置contentType为excel格式
|
|
|
+ response.setContentType("application/vnd.ms-excel;charset=utf-8");
|
|
|
+ //默认Excel名称
|
|
|
+ response.setHeader("Content-disposition", "attachment;filename=" + "费用信息.xls");
|
|
|
+ response.flushBuffer();
|
|
|
+ OutputStream outputStream = response.getOutputStream();
|
|
|
+ wb.write(outputStream);
|
|
|
+ if (outputStream != null) {
|
|
|
+ try {
|
|
|
+ outputStream.close();
|
|
|
+ } catch (IOException var20) {
|
|
|
+ var20.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception var22) {
|
|
|
+ log.error("导出Excel异常{}", var22.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}
|