|
|
@ -1,10 +1,11 @@ |
|
|
|
package com.yxt.anrui.fin.biz.finvehicleinvoice; |
|
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil; |
|
|
|
import com.yxt.anrui.fin.api.finvehicleinvoice.*; |
|
|
|
import com.yxt.common.base.config.component.FileUploadComponent; |
|
|
|
import com.yxt.common.base.utils.ExportExcelUtils; |
|
|
|
import com.yxt.common.base.utils.StringUtils; |
|
|
|
import com.yxt.common.core.query.PagerQuery; |
|
|
|
import com.yxt.common.core.result.FileUploadResult; |
|
|
|
import com.yxt.common.core.result.ResultBean; |
|
|
|
import com.yxt.common.core.vo.PagerVo; |
|
|
|
import io.swagger.annotations.Api; |
|
|
@ -12,7 +13,6 @@ import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.web.bind.annotation.RequestBody; |
|
|
|
import org.springframework.web.bind.annotation.RequestMapping; |
|
|
|
import org.springframework.web.bind.annotation.RestController; |
|
|
|
import org.springframework.web.multipart.MultipartFile; |
|
|
|
|
|
|
|
import javax.annotation.Resource; |
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
@ -20,6 +20,7 @@ import java.io.UnsupportedEncodingException; |
|
|
|
import java.net.URLEncoder; |
|
|
|
import java.text.ParseException; |
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.Date; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
@ -41,198 +42,187 @@ import java.util.List; |
|
|
|
@RequestMapping("v1/finvehicleinvoice") |
|
|
|
public class FinVehicleInvoiceRest implements FinVehicleInvoiceFeign { |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private FinVehicleInvoiceService finVehicleInvoiceService; |
|
|
|
|
|
|
|
@Resource |
|
|
|
private FileUploadComponent fileUploadComponent; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private HttpServletResponse response; |
|
|
|
|
|
|
|
private List<FinVehicleInvoiceVo> setVo(List<FinVehicleInvoiceVo> list) { |
|
|
|
for (FinVehicleInvoiceVo finVehicleInvoiceVo : list) { |
|
|
|
if (StringUtils.isNotBlank(finVehicleInvoiceVo.getState())) { |
|
|
|
String state = finVehicleInvoiceVo.getState(); |
|
|
|
if (state.equals("0")) { |
|
|
|
finVehicleInvoiceVo.setState("未开票"); |
|
|
|
}else if (state.equals("1")) { |
|
|
|
finVehicleInvoiceVo.setState("已开票"); |
|
|
|
}else if (state.equals("2")) { |
|
|
|
finVehicleInvoiceVo.setState("作废"); |
|
|
|
} |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(finVehicleInvoiceVo.getInvoiceState())) { |
|
|
|
String invoiceState = finVehicleInvoiceVo.getInvoiceState(); |
|
|
|
if (invoiceState.equals("0")) { |
|
|
|
finVehicleInvoiceVo.setInvoiceState("未移交"); |
|
|
|
} else if (invoiceState.equals("1")) { |
|
|
|
finVehicleInvoiceVo.setInvoiceState("已移交"); |
|
|
|
} |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(finVehicleInvoiceVo.getFilePath())) { |
|
|
|
String filePath = finVehicleInvoiceVo.getFilePath(); |
|
|
|
String urlPrefix = fileUploadComponent.getUrlPrefix(); |
|
|
|
filePath = urlPrefix + filePath; |
|
|
|
finVehicleInvoiceVo.setFilePath(filePath); |
|
|
|
} |
|
|
|
} |
|
|
|
return list; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public ResultBean<PagerVo<FinVehicleInvoiceVo>> listPage(@RequestBody PagerQuery<FinVehicleInvoiceQuery> pq){ |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
PagerVo<FinVehicleInvoiceVo> pv = finVehicleInvoiceService.listPageVo(pq); |
|
|
|
List<FinVehicleInvoiceVo> records = pv.getRecords(); |
|
|
|
List<FinVehicleInvoiceVo> finVehicleInvoiceVos = setVo(records); |
|
|
|
pv.setRecords(finVehicleInvoiceVos); |
|
|
|
return rb.success().setData(pv); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public ResultBean<List<FinVehicleInvoiceVo>> listAll(@RequestBody FinVehicleInvoiceQuery query){ |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
List<FinVehicleInvoiceVo> list = finVehicleInvoiceService.listAllVo(query); |
|
|
|
List<FinVehicleInvoiceVo> finVehicleInvoiceVos = setVo(list); |
|
|
|
return rb.success().setData(finVehicleInvoiceVos); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public ResultBean<List<FinVehicleInvoiceVo>> list(){ |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
List<FinVehicleInvoiceVo> list = finVehicleInvoiceService.listVo(); |
|
|
|
List<FinVehicleInvoiceVo> finVehicleInvoiceVos = setVo(list); |
|
|
|
return rb.success().setData(finVehicleInvoiceVos); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public ResultBean save(FinVehicleInvoiceDto dto){ |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
finVehicleInvoiceService.saveOrUpdateDto(dto); |
|
|
|
return rb.success(); |
|
|
|
} |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private FinVehicleInvoiceService finVehicleInvoiceService; |
|
|
|
|
|
|
|
@Resource |
|
|
|
private FileUploadComponent fileUploadComponent; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private HttpServletResponse response; |
|
|
|
|
|
|
|
private List<FinVehicleInvoiceVo> setVo(List<FinVehicleInvoiceVo> list) { |
|
|
|
for (FinVehicleInvoiceVo finVehicleInvoiceVo : list) { |
|
|
|
if (StringUtils.isNotBlank(finVehicleInvoiceVo.getFilePath())) { |
|
|
|
String filePath = finVehicleInvoiceVo.getFilePath(); |
|
|
|
List<String> filePaths = new ArrayList<>(); |
|
|
|
String array[] = filePath.split(","); |
|
|
|
for (int i = 0; i < array.length; i++) { |
|
|
|
String urlPrefix = fileUploadComponent.getUrlPrefix(); |
|
|
|
filePath = urlPrefix + array[i]; |
|
|
|
filePaths.add(filePath); |
|
|
|
finVehicleInvoiceVo.setFilePaths(filePaths); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
return list; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public ResultBean<PagerVo<FinVehicleInvoiceVo>> listPage(@RequestBody PagerQuery<FinVehicleInvoiceQuery> pq) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
PagerVo<FinVehicleInvoiceVo> pv = finVehicleInvoiceService.listPageVo(pq); |
|
|
|
List<FinVehicleInvoiceVo> records = pv.getRecords(); |
|
|
|
List<FinVehicleInvoiceVo> finVehicleInvoiceVos = setVo(records); |
|
|
|
pv.setRecords(finVehicleInvoiceVos); |
|
|
|
return rb.success().setData(pv); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public ResultBean<List<FinVehicleInvoiceVo>> listAll(@RequestBody FinVehicleInvoiceQuery query) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
List<FinVehicleInvoiceVo> list = finVehicleInvoiceService.listAllVo(query); |
|
|
|
List<FinVehicleInvoiceVo> finVehicleInvoiceVos = setVo(list); |
|
|
|
return rb.success().setData(finVehicleInvoiceVos); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public ResultBean<List<FinVehicleInvoiceVo>> list() { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
List<FinVehicleInvoiceVo> list = finVehicleInvoiceService.listVo(); |
|
|
|
List<FinVehicleInvoiceVo> finVehicleInvoiceVos = setVo(list); |
|
|
|
return rb.success().setData(finVehicleInvoiceVos); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public ResultBean update(FinVehicleInvoiceDto dto,String sid){ |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
finVehicleInvoiceService.updateBySid(dto.toMap(),sid); |
|
|
|
return rb.success(); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public ResultBean del(String ids){ |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
finVehicleInvoiceService.delByIds(ids); |
|
|
|
return rb.success(); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public ResultBean<FinVehicleInvoiceVo> fetch(String id){ |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
FinVehicleInvoiceVo vo = finVehicleInvoiceService.fetchByIdVo(id); |
|
|
|
return rb.success().setData(vo); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public ResultBean<FinVehicleInvoiceDetailsVo> fetchBySid(String sid){ |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
FinVehicleInvoiceDetailsVo vo = finVehicleInvoiceService.getInvoiceDetailsBySid(sid); |
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); |
|
|
|
if (StringUtils.isNotBlank(vo.getState())) { |
|
|
|
String state = vo.getState(); |
|
|
|
if (state.equals("0")) { |
|
|
|
vo.setState("未开票"); |
|
|
|
}else if (state.equals("1")) { |
|
|
|
vo.setState("已开票"); |
|
|
|
}else if (state.equals("2")) { |
|
|
|
vo.setState("作废"); |
|
|
|
} |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(vo.getCreateTime())) { |
|
|
|
String createTime = vo.getCreateTime(); |
|
|
|
try { |
|
|
|
Date date = sdf.parse(createTime); |
|
|
|
String createTimeBySdf = sdf.format(date); |
|
|
|
vo.setCreateTime(createTimeBySdf); |
|
|
|
} catch (ParseException e) { |
|
|
|
e.printStackTrace(); |
|
|
|
} |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(vo.getFilePath())) { |
|
|
|
String filePath = vo.getFilePath(); |
|
|
|
String urlPrefix = fileUploadComponent.getUrlPrefix(); |
|
|
|
filePath = urlPrefix + filePath; |
|
|
|
vo.setFilePath(filePath); |
|
|
|
} |
|
|
|
return rb.success().setData(vo); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void exportExcel(FinVehicleInvoiceQuery query) { |
|
|
|
//得到所有要导出的数据
|
|
|
|
List<FinVehicleInvoiceExportVo> invoiceExportVoList = finVehicleInvoiceService.listExcel(query); |
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); |
|
|
|
for (FinVehicleInvoiceExportVo invoiceExportVo : invoiceExportVoList) { |
|
|
|
if (StringUtils.isNotBlank(invoiceExportVo.getState())) { |
|
|
|
String state = invoiceExportVo.getState(); |
|
|
|
if (state.equals("0")) { |
|
|
|
invoiceExportVo.setState("未开票"); |
|
|
|
}else if (state.equals("1")) { |
|
|
|
invoiceExportVo.setState("已开票"); |
|
|
|
}else if (state.equals("2")) { |
|
|
|
invoiceExportVo.setState("作废"); |
|
|
|
} |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(invoiceExportVo.getInvoiceState())) { |
|
|
|
String invoiceState = invoiceExportVo.getInvoiceState(); |
|
|
|
if (invoiceState.equals("0")) { |
|
|
|
invoiceExportVo.setInvoiceState("未移交"); |
|
|
|
} else if (invoiceState.equals("1")) { |
|
|
|
invoiceExportVo.setInvoiceState("已移交"); |
|
|
|
} |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(invoiceExportVo.getCreateTime())) { |
|
|
|
String createTime = invoiceExportVo.getCreateTime(); |
|
|
|
try { |
|
|
|
Date date = sdf.parse(createTime); |
|
|
|
String createTimeBySdf = sdf.format(date); |
|
|
|
invoiceExportVo.setCreateTime(createTimeBySdf); |
|
|
|
} catch (ParseException e) { |
|
|
|
e.printStackTrace(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
//定义导出的excel名字
|
|
|
|
String excelName = "车辆发票信息列表"; |
|
|
|
String fileNameURL = ""; |
|
|
|
try { |
|
|
|
fileNameURL = URLEncoder.encode(excelName, "UTF-8"); |
|
|
|
} catch (UnsupportedEncodingException e) { |
|
|
|
e.printStackTrace(); |
|
|
|
} |
|
|
|
//导出车辆管理列表
|
|
|
|
ExportExcelUtils.export(fileNameURL, invoiceExportVoList, FinVehicleInvoiceExportVo.class, response); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public ResultBean pictureUpload(String sid,MultipartFile file) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
if (file == null || file.isEmpty()) { |
|
|
|
return rb.setMsg("文件为空"); |
|
|
|
} |
|
|
|
rb = fileUploadComponent.uploadFile(file); |
|
|
|
FileUploadResult data = (FileUploadResult) rb.getData(); |
|
|
|
FinVehicleInvoiceDetailsVo invoice= finVehicleInvoiceService.getInvoiceDetailsBySid(sid); |
|
|
|
invoice.setFilePath(data.getFilePath()); |
|
|
|
String filePath = invoice.getFilePath(); |
|
|
|
invoice.setState("1"); |
|
|
|
String state = invoice.getState(); |
|
|
|
Boolean isSuccess = finVehicleInvoiceService.updatePictureBySid(state,filePath,sid); |
|
|
|
if (isSuccess) { |
|
|
|
return rb.success().setMsg("上传成功"); |
|
|
|
}else { |
|
|
|
return rb.fail().setMsg("上传失败"); |
|
|
|
} |
|
|
|
} |
|
|
|
public ResultBean save(FinVehicleInvoiceDto dto) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
finVehicleInvoiceService.saveOrUpdateDto(dto); |
|
|
|
return rb.success(); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public ResultBean saveOrUpdate(FinVehicleInvoiceDto dto) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
String sid = dto.getSid(); |
|
|
|
if (StringUtils.isNotEmpty(sid)) { |
|
|
|
StringBuilder sb = new StringBuilder(); |
|
|
|
String urlPrefix = fileUploadComponent.getUrlPrefix(); |
|
|
|
if (null != dto.getFilePaths()) { |
|
|
|
for (String filePath : dto.getFilePaths()) { |
|
|
|
String[] split = filePath.split(urlPrefix); |
|
|
|
String s = split[1]; |
|
|
|
sb.append(s).append(","); |
|
|
|
} |
|
|
|
sb.delete(sb.length() - 1, sb.length()); |
|
|
|
dto.setFilePath(sb.toString()); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(dto.getFilePath())) { |
|
|
|
dto.setBillingStateKey("002"); |
|
|
|
dto.setBillingState("已开票"); |
|
|
|
} |
|
|
|
if (StringUtils.isNotEmpty(dto.getVinNo())) { |
|
|
|
String VIN = dto.getVinNo(); |
|
|
|
dto.setVIN(VIN); |
|
|
|
} |
|
|
|
finVehicleInvoiceService.updateBySid(dto, sid); |
|
|
|
} else { |
|
|
|
FinVehicleInvoice finVehicleInvoice = new FinVehicleInvoice(); |
|
|
|
String sidAdd = finVehicleInvoice.getSid(); |
|
|
|
BeanUtil.copyProperties(dto, finVehicleInvoice); |
|
|
|
finVehicleInvoice.setSid(sidAdd); |
|
|
|
StringBuilder sb = new StringBuilder(); |
|
|
|
String urlPrefix = fileUploadComponent.getUrlPrefix(); |
|
|
|
if (null != dto.getFilePaths()) { |
|
|
|
for (String filePath : dto.getFilePaths()) { |
|
|
|
String[] split = filePath.split(urlPrefix); |
|
|
|
String s = split[1]; |
|
|
|
sb.append(s).append(","); |
|
|
|
} |
|
|
|
sb.delete(sb.length() - 1, sb.length()); |
|
|
|
finVehicleInvoice.setFilePath(sb.toString()); |
|
|
|
finVehicleInvoice.setBillingStateKey("002"); |
|
|
|
finVehicleInvoice.setBillingState("已开票"); |
|
|
|
} |
|
|
|
if (StringUtils.isNotEmpty(dto.getVinNo())) { |
|
|
|
String VIN = dto.getVinNo(); |
|
|
|
finVehicleInvoice.setVIN(VIN); |
|
|
|
} |
|
|
|
finVehicleInvoiceService.save(finVehicleInvoice); |
|
|
|
} |
|
|
|
return rb.success(); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public ResultBean del(String ids) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
finVehicleInvoiceService.delByIds(ids); |
|
|
|
return rb.success(); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public ResultBean<FinVehicleInvoiceVo> fetch(String id) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
FinVehicleInvoiceVo vo = finVehicleInvoiceService.fetchByIdVo(id); |
|
|
|
return rb.success().setData(vo); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public ResultBean<FinVehicleInvoiceDetailsVo> fetchBySid(String sid) { |
|
|
|
ResultBean rb = ResultBean.fireFail(); |
|
|
|
FinVehicleInvoiceDetailsVo vo = finVehicleInvoiceService.getInvoiceDetailsBySid(sid); |
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); |
|
|
|
if (StringUtils.isNotBlank(vo.getCreateTime())) { |
|
|
|
String createTime = vo.getCreateTime(); |
|
|
|
try { |
|
|
|
Date date = sdf.parse(createTime); |
|
|
|
String createTimeBySdf = sdf.format(date); |
|
|
|
vo.setCreateTime(createTimeBySdf); |
|
|
|
} catch (ParseException e) { |
|
|
|
e.printStackTrace(); |
|
|
|
} |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(vo.getFilePath())) { |
|
|
|
String filePath = vo.getFilePath(); |
|
|
|
List<String> filePaths = new ArrayList<>(); |
|
|
|
String array[] = filePath.split(","); |
|
|
|
for (int i = 0; i < array.length; i++) { |
|
|
|
String urlPrefix = fileUploadComponent.getUrlPrefix(); |
|
|
|
filePath = urlPrefix + array[i]; |
|
|
|
filePaths.add(filePath); |
|
|
|
vo.setFilePaths(filePaths); |
|
|
|
} |
|
|
|
} |
|
|
|
return rb.success().setData(vo); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void exportExcel(FinVehicleInvoiceQuery query) { |
|
|
|
//得到所有要导出的数据
|
|
|
|
List<FinVehicleInvoiceExportVo> invoiceExportVoList = finVehicleInvoiceService.listExcel(query); |
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); |
|
|
|
for (FinVehicleInvoiceExportVo invoiceExportVo : invoiceExportVoList) { |
|
|
|
if (StringUtils.isNotBlank(invoiceExportVo.getCreateTime())) { |
|
|
|
String createTime = invoiceExportVo.getCreateTime(); |
|
|
|
try { |
|
|
|
Date date = sdf.parse(createTime); |
|
|
|
String createTimeBySdf = sdf.format(date); |
|
|
|
invoiceExportVo.setCreateTime(createTimeBySdf); |
|
|
|
} catch (ParseException e) { |
|
|
|
e.printStackTrace(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
//定义导出的excel名字
|
|
|
|
String excelName = "车辆发票信息列表"; |
|
|
|
String fileNameURL = ""; |
|
|
|
try { |
|
|
|
fileNameURL = URLEncoder.encode(excelName, "UTF-8"); |
|
|
|
} catch (UnsupportedEncodingException e) { |
|
|
|
e.printStackTrace(); |
|
|
|
} |
|
|
|
//导出车辆管理列表
|
|
|
|
ExportExcelUtils.export(fileNameURL, invoiceExportVoList, FinVehicleInvoiceExportVo.class, response); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|