|
|
@@ -0,0 +1,541 @@
|
|
|
+package com.jpsoft.enterprise.modules.base.controller;
|
|
|
+
|
|
|
+import com.github.pagehelper.Page;
|
|
|
+import com.github.pagehelper.util.StringUtil;
|
|
|
+import com.jpsoft.enterprise.config.OSSConfig;
|
|
|
+import com.jpsoft.enterprise.modules.base.dto.BillDetailDTO;
|
|
|
+import com.jpsoft.enterprise.modules.base.entity.BillDetailInfo;
|
|
|
+import com.jpsoft.enterprise.modules.base.entity.BillInfo;
|
|
|
+import com.jpsoft.enterprise.modules.base.entity.CompanyInfo;
|
|
|
+import com.jpsoft.enterprise.modules.base.entity.OrderInfo;
|
|
|
+import com.jpsoft.enterprise.modules.base.service.BillDetailInfoService;
|
|
|
+import com.jpsoft.enterprise.modules.base.service.BillInfoService;
|
|
|
+import com.jpsoft.enterprise.modules.base.service.CompanyInfoService;
|
|
|
+import com.jpsoft.enterprise.modules.base.service.OrderInfoService;
|
|
|
+import com.jpsoft.enterprise.modules.common.dto.MessageResult;
|
|
|
+import com.jpsoft.enterprise.modules.common.dto.Sort;
|
|
|
+import com.jpsoft.enterprise.modules.common.utils.OSSUtil;
|
|
|
+import com.jpsoft.enterprise.modules.common.utils.POIUtils;
|
|
|
+import com.jpsoft.enterprise.modules.common.utils.PojoUtils;
|
|
|
+import com.jpsoft.enterprise.modules.sys.entity.User;
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import io.swagger.annotations.ApiImplicitParam;
|
|
|
+import io.swagger.annotations.ApiImplicitParams;
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
+import net.sf.json.JSONObject;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.apache.poi.ss.usermodel.Sheet;
|
|
|
+import org.apache.poi.ss.usermodel.Workbook;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
+
|
|
|
+import java.io.ByteArrayInputStream;
|
|
|
+import java.io.ByteArrayOutputStream;
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.util.*;
|
|
|
+
|
|
|
+@RestController
|
|
|
+@RequestMapping("/base/billDetail")
|
|
|
+@Api(description = "billDetail")
|
|
|
+public class BillDetailController {
|
|
|
+ private Logger logger = LoggerFactory.getLogger(getClass());
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private BillInfoService billInfoService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private BillDetailInfoService billDetailInfoService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private CompanyInfoService companyInfoService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private OrderInfoService orderInfoService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private OSSConfig ossConfig;
|
|
|
+
|
|
|
+ @ApiOperation(value="创建空记录")
|
|
|
+ @GetMapping("create")
|
|
|
+ public MessageResult<BillDetailInfo> create(){
|
|
|
+ MessageResult<BillDetailInfo> msgResult = new MessageResult<>();
|
|
|
+
|
|
|
+ BillDetailInfo billDetailInfo = new BillDetailInfo();
|
|
|
+
|
|
|
+ msgResult.setData(billDetailInfo);
|
|
|
+ msgResult.setResult(true);
|
|
|
+
|
|
|
+ return msgResult;
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value="添加信息")
|
|
|
+ @PostMapping("add")
|
|
|
+ public MessageResult<BillDetailInfo> add(@RequestBody BillDetailInfo billDetailInfo, @RequestAttribute String subject){
|
|
|
+ MessageResult<BillDetailInfo> msgResult = new MessageResult<>();
|
|
|
+
|
|
|
+ try {
|
|
|
+ billDetailInfo.setId(UUID.randomUUID().toString());
|
|
|
+ billDetailInfo.setDelFlag(false);
|
|
|
+ billDetailInfo.setCreateBy(subject);
|
|
|
+ billDetailInfo.setCreateTime(new Date());
|
|
|
+
|
|
|
+ int affectCount = billDetailInfoService.insert(billDetailInfo);
|
|
|
+
|
|
|
+ if (affectCount > 0) {
|
|
|
+ msgResult.setResult(true);
|
|
|
+ msgResult.setData(billDetailInfo);
|
|
|
+ } else {
|
|
|
+ msgResult.setResult(false);
|
|
|
+ msgResult.setMessage("数据库添加失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch(Exception ex){
|
|
|
+ logger.error(ex.getMessage(),ex);
|
|
|
+
|
|
|
+ msgResult.setResult(false);
|
|
|
+ msgResult.setMessage(ex.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ return msgResult;
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value="获取信息")
|
|
|
+ @GetMapping("edit/{id}")
|
|
|
+ public MessageResult<BillDetailDTO> edit(@PathVariable("id") String id){
|
|
|
+ MessageResult<BillDetailDTO> msgResult = new MessageResult<>();
|
|
|
+
|
|
|
+ try {
|
|
|
+ BillDetailInfo billDetailInfo = billDetailInfoService.get(id);
|
|
|
+
|
|
|
+ if (billDetailInfo != null) {
|
|
|
+ BillDetailDTO dto = new BillDetailDTO();
|
|
|
+ dto.setId(billDetailInfo.getId());
|
|
|
+
|
|
|
+ CompanyInfo companyInfo = companyInfoService.get(billDetailInfo.getCompanyId());
|
|
|
+ if(companyInfo!=null){
|
|
|
+ dto.setCompanyName(companyInfo.getCompanyName());
|
|
|
+ }
|
|
|
+
|
|
|
+ String billDetailStr ="";
|
|
|
+ String billDetail = billDetailInfo.getBillDetail();
|
|
|
+
|
|
|
+ List<Map<String,String>> list = new ArrayList<>();
|
|
|
+
|
|
|
+ if(StringUtil.isNotEmpty(billDetail)) {
|
|
|
+ JSONObject jsonObject = JSONObject.fromObject(billDetail);
|
|
|
+ Set<String> set = jsonObject.keySet();
|
|
|
+ for (String key:set) {
|
|
|
+ String val = jsonObject.getString(key);
|
|
|
+ billDetailStr+= key + ":" + val + ",";
|
|
|
+
|
|
|
+ Map<String,String> map = new HashMap();
|
|
|
+ map.put("key",key);
|
|
|
+ map.put("val",val);
|
|
|
+ list.add(map);
|
|
|
+ }
|
|
|
+ dto.setBillDetailList(list);
|
|
|
+ }
|
|
|
+ if(StringUtil.isNotEmpty(billDetailStr)){
|
|
|
+ billDetailStr = billDetailStr.substring(0,billDetailStr.lastIndexOf(","));
|
|
|
+ }
|
|
|
+ dto.setBillDetail(billDetailStr);
|
|
|
+
|
|
|
+ if(StringUtil.isNotEmpty(billDetailInfo.getOrderId())) {
|
|
|
+ OrderInfo orderInfo = orderInfoService.get(billDetailInfo.getOrderId());
|
|
|
+ if(orderInfo!=null){
|
|
|
+ dto.setPayStatus(orderInfo.getPayStatus());
|
|
|
+ if(orderInfo.getPayStatus()==10){
|
|
|
+ dto.setPayStatusN("未支付");
|
|
|
+ }
|
|
|
+ else if(orderInfo.getPayStatus()==20){
|
|
|
+ dto.setPayStatusN("已支付");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ dto.setRushStatus(billDetailInfo.getRushStatus());
|
|
|
+
|
|
|
+ msgResult.setResult(true);
|
|
|
+ msgResult.setData(dto);
|
|
|
+ } else {
|
|
|
+ msgResult.setResult(false);
|
|
|
+ msgResult.setMessage("数据库不存在该记录!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch(Exception ex){
|
|
|
+ logger.error(ex.getMessage(),ex);
|
|
|
+
|
|
|
+ msgResult.setResult(false);
|
|
|
+ msgResult.setMessage(ex.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ return msgResult;
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value="更新用户")
|
|
|
+ @PostMapping("update")
|
|
|
+ public MessageResult<BillDetailInfo> update(@RequestBody BillDetailDTO billDetailDTO,@RequestAttribute String subject){
|
|
|
+ MessageResult<BillDetailInfo> msgResult = new MessageResult<>();
|
|
|
+
|
|
|
+ try {
|
|
|
+
|
|
|
+ BillDetailInfo billDetailInfo = billDetailInfoService.get(billDetailDTO.getId());
|
|
|
+
|
|
|
+ if(billDetailInfo!=null){
|
|
|
+ List<Map<String,String>> list = billDetailDTO.getBillDetailList();
|
|
|
+
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
+
|
|
|
+ BigDecimal totalFee = BigDecimal.ZERO;
|
|
|
+
|
|
|
+ for (Map<String,String> map:list) {
|
|
|
+ String key = map.get("key");
|
|
|
+ String val = map.get("val");
|
|
|
+
|
|
|
+ jsonObject.put(key,val);
|
|
|
+
|
|
|
+ if(StringUtil.isNotEmpty(val)){
|
|
|
+ BigDecimal tempFee = BigDecimal.valueOf(Double.parseDouble(val));
|
|
|
+ totalFee = totalFee.add(tempFee);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ String billDetail = jsonObject.toString();
|
|
|
+
|
|
|
+ billDetailInfo.setBillDetail(billDetail);
|
|
|
+ billDetailInfo.setUpdateBy(subject);
|
|
|
+ billDetailInfo.setUpdateTime(new Date());
|
|
|
+
|
|
|
+ int affectCount = billDetailInfoService.updateAndOrderInfo(billDetailInfo,totalFee);
|
|
|
+
|
|
|
+ if (affectCount > 0) {
|
|
|
+ msgResult.setResult(true);
|
|
|
+ msgResult.setData(billDetailInfo);
|
|
|
+ } else {
|
|
|
+ msgResult.setResult(false);
|
|
|
+ msgResult.setMessage("数据库更新失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ msgResult.setResult(false);
|
|
|
+ msgResult.setMessage("该数据不存在!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch(Exception ex){
|
|
|
+ logger.error(ex.getMessage(),ex);
|
|
|
+
|
|
|
+ msgResult.setResult(false);
|
|
|
+ msgResult.setMessage(ex.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ return msgResult;
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value="删除")
|
|
|
+ @PostMapping("delete/{id}")
|
|
|
+ public MessageResult<Integer> delete(@PathVariable("id") String id,@RequestAttribute String subject){
|
|
|
+ MessageResult<Integer> msgResult = new MessageResult<>();
|
|
|
+
|
|
|
+ try {
|
|
|
+ BillDetailInfo billDetailInfo = billDetailInfoService.get(id);
|
|
|
+ billDetailInfo.setDelFlag(true);
|
|
|
+ billDetailInfo.setUpdateBy(subject);
|
|
|
+ billDetailInfo.setUpdateTime(new Date());
|
|
|
+
|
|
|
+ int affectCount = billDetailInfoService.updateDelOrderInfo(billDetailInfo);
|
|
|
+
|
|
|
+ if (affectCount > 0) {
|
|
|
+ msgResult.setResult(true);
|
|
|
+ msgResult.setData(affectCount);
|
|
|
+ } else {
|
|
|
+ msgResult.setResult(false);
|
|
|
+ msgResult.setMessage("删除失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch(Exception ex){
|
|
|
+ logger.error(ex.getMessage(),ex);
|
|
|
+
|
|
|
+ msgResult.setResult(false);
|
|
|
+ msgResult.setMessage(ex.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ return msgResult;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @ApiOperation(value="推送账单消息")
|
|
|
+ @PostMapping("pushMessage/{billId}")
|
|
|
+ public MessageResult<Integer> pushMessage(@PathVariable("billId") String billId,@RequestAttribute String subject){
|
|
|
+ MessageResult<Integer> msgResult = new MessageResult<>();
|
|
|
+
|
|
|
+ try {
|
|
|
+
|
|
|
+ List<BillDetailInfo> list = billDetailInfoService.findByBillId(billId);
|
|
|
+
|
|
|
+ int affectCount = 0;
|
|
|
+
|
|
|
+ for (BillDetailInfo billDetailInfo:list) {
|
|
|
+ billDetailInfo.setRushStatus("1");
|
|
|
+ billDetailInfo.setUpdateBy(subject);
|
|
|
+ billDetailInfo.setUpdateTime(new Date());
|
|
|
+
|
|
|
+ affectCount += billDetailInfoService.update(billDetailInfo);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ if (affectCount > 0) {
|
|
|
+ msgResult.setResult(true);
|
|
|
+ msgResult.setData(affectCount);
|
|
|
+ } else {
|
|
|
+ msgResult.setResult(false);
|
|
|
+ msgResult.setMessage("消息推送失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ catch(Exception ex){
|
|
|
+ logger.error(ex.getMessage(),ex);
|
|
|
+
|
|
|
+ msgResult.setResult(false);
|
|
|
+ msgResult.setMessage(ex.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ return msgResult;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @ApiOperation(value="批量删除")
|
|
|
+ @PostMapping("batchDelete")
|
|
|
+ public MessageResult<Integer> batchDelete(@RequestBody List<String> idList, @RequestAttribute String subject){
|
|
|
+ MessageResult<Integer> msgResult = new MessageResult<>();
|
|
|
+
|
|
|
+ try {
|
|
|
+ int affectCount = 0;
|
|
|
+
|
|
|
+ for (String id : idList) {
|
|
|
+ BillDetailInfo billDetailInfo = billDetailInfoService.get(id);
|
|
|
+ billDetailInfo.setDelFlag(true);
|
|
|
+ billDetailInfo.setUpdateBy(subject);
|
|
|
+ billDetailInfo.setUpdateTime(new Date());
|
|
|
+
|
|
|
+ affectCount += billDetailInfoService.update(billDetailInfo);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (affectCount > 0) {
|
|
|
+ msgResult.setResult(true);
|
|
|
+ msgResult.setData(affectCount);
|
|
|
+ } else {
|
|
|
+ msgResult.setResult(false);
|
|
|
+ msgResult.setMessage("删除失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch(Exception ex){
|
|
|
+ logger.error(ex.getMessage(),ex);
|
|
|
+
|
|
|
+ msgResult.setResult(false);
|
|
|
+ msgResult.setMessage(ex.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ return msgResult;
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value="列表")
|
|
|
+ @RequestMapping(value = "pageList",method = RequestMethod.POST)
|
|
|
+ public MessageResult<Map> pageList(
|
|
|
+ String billId,
|
|
|
+ @RequestParam(value="pageIndex",defaultValue="1") int pageIndex,
|
|
|
+ @RequestParam(value="pageSize",defaultValue="20") int pageSize,
|
|
|
+ @RequestAttribute String subject){
|
|
|
+
|
|
|
+ //当前用户ID
|
|
|
+ System.out.println(subject);
|
|
|
+
|
|
|
+ MessageResult<Map> msgResult = new MessageResult<>();
|
|
|
+
|
|
|
+ Map<String,Object> searchParams = new HashMap<>();
|
|
|
+
|
|
|
+ List<Sort> sortList = new ArrayList<>();
|
|
|
+ sortList.add(new Sort("create_time","desc"));
|
|
|
+
|
|
|
+ searchParams.put("billId",billId);
|
|
|
+
|
|
|
+ Page<BillDetailInfo> page = billDetailInfoService.pageSearch(searchParams,pageIndex,pageSize,true,sortList);
|
|
|
+
|
|
|
+
|
|
|
+ Page<BillDetailDTO> pageDto = new Page<>();
|
|
|
+
|
|
|
+ for (BillDetailInfo billDetailInfo:page) {
|
|
|
+ BillDetailDTO dto = new BillDetailDTO();
|
|
|
+ dto.setId(billDetailInfo.getId());
|
|
|
+
|
|
|
+ CompanyInfo companyInfo = companyInfoService.get(billDetailInfo.getCompanyId());
|
|
|
+ if(companyInfo!=null){
|
|
|
+ dto.setCompanyName(companyInfo.getCompanyName());
|
|
|
+ }
|
|
|
+
|
|
|
+ String billDetailStr ="";
|
|
|
+ String billDetail = billDetailInfo.getBillDetail();
|
|
|
+
|
|
|
+ if(StringUtil.isNotEmpty(billDetail)) {
|
|
|
+ JSONObject jsonObject = JSONObject.fromObject(billDetail);
|
|
|
+ Set<String> set = jsonObject.keySet();
|
|
|
+ for (String key:set) {
|
|
|
+ String val = jsonObject.getString(key);
|
|
|
+ billDetailStr+= key + ":" + val + ",";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(StringUtil.isNotEmpty(billDetailStr)){
|
|
|
+ billDetailStr = billDetailStr.substring(0,billDetailStr.lastIndexOf(","));
|
|
|
+ }
|
|
|
+ dto.setBillDetail(billDetailStr);
|
|
|
+
|
|
|
+ if(StringUtil.isNotEmpty(billDetailInfo.getOrderId())) {
|
|
|
+ OrderInfo orderInfo = orderInfoService.get(billDetailInfo.getOrderId());
|
|
|
+ if(orderInfo!=null){
|
|
|
+ dto.setPayStatus(orderInfo.getPayStatus());
|
|
|
+ if(orderInfo.getPayStatus()==10){
|
|
|
+ dto.setPayStatusN("未支付");
|
|
|
+ }
|
|
|
+ else if(orderInfo.getPayStatus()==20){
|
|
|
+ dto.setPayStatusN("已支付");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ dto.setRushStatus(billDetailInfo.getRushStatus());
|
|
|
+
|
|
|
+ pageDto.add(dto);
|
|
|
+ }
|
|
|
+
|
|
|
+ pageDto.setPageSize(page.getPageSize());
|
|
|
+ pageDto.setTotal(page.getTotal());
|
|
|
+ pageDto.setPageNum(page.getPageNum());
|
|
|
+
|
|
|
+ msgResult.setResult(true);
|
|
|
+ msgResult.setData(PojoUtils.pageWrapper(pageDto));
|
|
|
+
|
|
|
+ return msgResult;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ @ApiOperation(value="导入企业")
|
|
|
+ @PostMapping("importXls")
|
|
|
+ @ApiImplicitParams({
|
|
|
+ @ApiImplicitParam(name = "uploadFile",value = "上传文件", required = true,paramType="form", dataType = "__file")
|
|
|
+ })
|
|
|
+ public MessageResult<String> importXls(MultipartFile uploadFile,String billId,
|
|
|
+ @RequestAttribute String subject){
|
|
|
+
|
|
|
+ MessageResult<String> msgResult = new MessageResult<>();
|
|
|
+
|
|
|
+ try {
|
|
|
+ POIUtils poiUtils = new POIUtils(uploadFile.getInputStream());
|
|
|
+ int sheetIndex = 0;
|
|
|
+ Sheet sheet1 = poiUtils.getSheetAt(sheetIndex);
|
|
|
+
|
|
|
+ int affectCount = 0;
|
|
|
+ int failCount = 0;
|
|
|
+ int validateColIndex = 10;
|
|
|
+
|
|
|
+ int num = poiUtils.getColumnNum(sheetIndex);
|
|
|
+
|
|
|
+ for(int rowIndex=1 ; rowIndex<=sheet1.getLastRowNum(); rowIndex++){
|
|
|
+ try {
|
|
|
+ String sort = (String)poiUtils.getCellValue(sheetIndex,rowIndex,0).toString().replace(" ","");
|
|
|
+
|
|
|
+ String name = (String)poiUtils.getCellValue(sheetIndex,rowIndex,1).toString().replace(" ","");
|
|
|
+
|
|
|
+ if(StringUtils.isEmpty(name)){
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ CompanyInfo companyInfo = companyInfoService.findByName(name);
|
|
|
+
|
|
|
+ if(companyInfo==null){
|
|
|
+ sheet1.getRow(rowIndex).createCell(validateColIndex).setCellValue("企业不存在!");
|
|
|
+ failCount++;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ BillDetailInfo billDetailInfo = new BillDetailInfo();
|
|
|
+ billDetailInfo.setId(UUID.randomUUID().toString());
|
|
|
+ billDetailInfo.setBillId(billId);
|
|
|
+ billDetailInfo.setCompanyId(companyInfo.getId());
|
|
|
+
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
+
|
|
|
+ BigDecimal totalFee = BigDecimal.ZERO;
|
|
|
+
|
|
|
+ String body="";
|
|
|
+
|
|
|
+ for(int i=2;i<num;i++){
|
|
|
+ String key = (String)poiUtils.getCellValue(sheetIndex,0,i).toString().replace(" ","");
|
|
|
+ String val = (String)poiUtils.getCellValue(sheetIndex,rowIndex,i).toString().replace(" ","");
|
|
|
+
|
|
|
+ String newKey = key.replace("(必填项)","");
|
|
|
+
|
|
|
+ jsonObject.put(newKey,val);
|
|
|
+
|
|
|
+ if(StringUtil.isNotEmpty(val)){
|
|
|
+ BigDecimal tempFee = BigDecimal.valueOf(Double.parseDouble(val));
|
|
|
+ totalFee = totalFee.add(tempFee);
|
|
|
+ }
|
|
|
+
|
|
|
+ body += newKey+",";
|
|
|
+ }
|
|
|
+
|
|
|
+ if(jsonObject.size()>0){
|
|
|
+ billDetailInfo.setBillDetail(jsonObject.toString());
|
|
|
+ body = body.substring(0,body.lastIndexOf(","));
|
|
|
+ }
|
|
|
+
|
|
|
+ billDetailInfo.setRushStatus("0");
|
|
|
+ billDetailInfo.setDelFlag(false);
|
|
|
+ billDetailInfo.setCreateBy(subject);
|
|
|
+ billDetailInfo.setCreateTime(new Date());
|
|
|
+
|
|
|
+ billDetailInfoService.insertAndOrderInfo(billDetailInfo,totalFee,body);
|
|
|
+ affectCount++;
|
|
|
+
|
|
|
+ }
|
|
|
+ catch(Exception innerEx){
|
|
|
+ logger.error(innerEx.getMessage(),innerEx);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (failCount>0){
|
|
|
+ //有导入失败的记录
|
|
|
+ msgResult.setResult(false);
|
|
|
+ msgResult.setMessage("数据成功导入" + affectCount + "条,有" + failCount + "条数据未导入成功,错误原因请查看报表。");
|
|
|
+
|
|
|
+ //todo 只保留错误数据的sheet
|
|
|
+ Workbook wb = poiUtils.exportErrorXls(sheetIndex,validateColIndex,1 + affectCount + failCount);
|
|
|
+
|
|
|
+ //todo 将wb保存到oss
|
|
|
+ ByteArrayOutputStream output = new ByteArrayOutputStream();
|
|
|
+ wb.write(output);
|
|
|
+
|
|
|
+ byte[] buffer = output.toByteArray();
|
|
|
+ ByteArrayInputStream input = new ByteArrayInputStream(buffer);
|
|
|
+
|
|
|
+ String downloadUrl = OSSUtil.upload(ossConfig,"import","error.xls",input);
|
|
|
+
|
|
|
+ //todo 返回导入失败报表下载链接
|
|
|
+ msgResult.setData(downloadUrl);
|
|
|
+ }
|
|
|
+ else{
|
|
|
+ msgResult.setResult(true);
|
|
|
+ msgResult.setMessage("数据成功导入" + affectCount + "条");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ catch(Exception ex){
|
|
|
+ logger.error(ex.getMessage(),ex);
|
|
|
+
|
|
|
+ msgResult.setResult(false);
|
|
|
+ msgResult.setMessage(ex.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ return msgResult;
|
|
|
+ }
|
|
|
+}
|