Commit 120e5df6 by yangxiujun

fix:上传工单修改问题

1 parent 95b8f085
...@@ -19,6 +19,10 @@ public enum RedisKeyGroup { ...@@ -19,6 +19,10 @@ public enum RedisKeyGroup {
* 资源信息 * 资源信息
*/ */
resourceKey, resourceKey,
/**
* 错误模版
*/
errorTemplate,
/** /**
* 坐标距离信息 * 坐标距离信息
......
...@@ -42,7 +42,7 @@ public class ContractsListener implements ReadListener<OrderInfoExcelDTO> { ...@@ -42,7 +42,7 @@ public class ContractsListener implements ReadListener<OrderInfoExcelDTO> {
*/ */
private OrderCreateService orderCreateService; private OrderCreateService orderCreateService;
private ThreadLocal local = new ThreadLocal(); private ThreadLocal local = new ThreadLocal();
private HttpServletResponse response;
private String token; private String token;
...@@ -56,13 +56,10 @@ public class ContractsListener implements ReadListener<OrderInfoExcelDTO> { ...@@ -56,13 +56,10 @@ public class ContractsListener implements ReadListener<OrderInfoExcelDTO> {
* *
* @param contractsService * @param contractsService
*/ */
public ContractsListener(OrderCreateService contractsService, String token, HttpServletResponse response) { public ContractsListener(OrderCreateService contractsService, String token) {
this.orderCreateService = contractsService; this.orderCreateService = contractsService;
this.token = token; this.token = token;
this.response = response;
} }
...@@ -147,6 +144,14 @@ public class ContractsListener implements ReadListener<OrderInfoExcelDTO> { ...@@ -147,6 +144,14 @@ public class ContractsListener implements ReadListener<OrderInfoExcelDTO> {
return; return;
} }
if (StringUtils.isBlank(data.getOrderTags())) {
OrderInfoErrorExcelDTO orderInfoError = new OrderInfoErrorExcelDTO();
BeanUtil.copyProperties(data, orderInfoError);
orderInfoError.setError("工单标签不能为空");
errorList.add(orderInfoError);
return;
}
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm"); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm");
if (StringUtils.isBlank(data.getExpectTimeBegin())) { if (StringUtils.isBlank(data.getExpectTimeBegin())) {
OrderInfoErrorExcelDTO orderInfoError = new OrderInfoErrorExcelDTO(); OrderInfoErrorExcelDTO orderInfoError = new OrderInfoErrorExcelDTO();
...@@ -212,7 +217,7 @@ public class ContractsListener implements ReadListener<OrderInfoExcelDTO> { ...@@ -212,7 +217,7 @@ public class ContractsListener implements ReadListener<OrderInfoExcelDTO> {
*/ */
private void saveData() { private void saveData() {
log.info("{}条数据,开始存储数据库!", cachedDataList.size()); log.info("{}条数据,开始存储数据库!", cachedDataList.size());
orderCreateService.saveBatch(cachedDataList, token, local, response); orderCreateService.saveBatch(cachedDataList, token, local);
log.info("存储数据库成功!"); log.info("存储数据库成功!");
} }
} }
\ No newline at end of file
...@@ -71,9 +71,7 @@ public class RedisService { ...@@ -71,9 +71,7 @@ public class RedisService {
public boolean set(final String key, String value, Long expireTime) { public boolean set(final String key, String value, Long expireTime) {
boolean result = false; boolean result = false;
try { try {
ValueOperations<String, String> operations = redisTemplate.opsForValue(); redisTemplate.opsForValue().set(key, value, expireTime, TimeUnit.MINUTES);
operations.set(key, value);
redisTemplate.expire(key, expireTime, TimeUnit.MILLISECONDS);
result = true; result = true;
} catch (Exception e) { } catch (Exception e) {
log.error("[set]---------->redis存值失败, key为: {}, 失败原因:{}", key, e.getMessage(), e); log.error("[set]---------->redis存值失败, key为: {}, 失败原因:{}", key, e.getMessage(), e);
...@@ -94,4 +92,15 @@ public class RedisService { ...@@ -94,4 +92,15 @@ public class RedisService {
return result; return result;
} }
/**
*删除缓存
*
* @param key
* @return
*/
public void del(final String key) {
redisTemplate.delete(key);
}
} }
...@@ -82,7 +82,7 @@ public class FileController { ...@@ -82,7 +82,7 @@ public class FileController {
} }
EasyExcel.read(file.getInputStream(), OrderInfoExcelDTO.class EasyExcel.read(file.getInputStream(), OrderInfoExcelDTO.class
, new ContractsListener(orderCreateService, token, response)).sheet().doRead(); , new ContractsListener(orderCreateService, token)).sheet().doRead();
long l1 = System.currentTimeMillis(); long l1 = System.currentTimeMillis();
System.out.println("全部时间"+(l1-l)); System.out.println("全部时间"+(l1-l));
...@@ -102,26 +102,54 @@ public class FileController { ...@@ -102,26 +102,54 @@ public class FileController {
if (StringUtils.isBlank(token)) { if (StringUtils.isBlank(token)) {
throw new BusinessException("用户未登录"); throw new BusinessException("用户未登录");
} }
FileRateDTO rate = orderCreateService.getsuccessRate(token); FileRateDTO rate = orderCreateService.orderRate(token);
if (rate != null && (rate.getSuccessCount() == rate.getTotalCount())) {
//上传成功,删除上传的进度条
orderCreateService.delRate(token);
}
if (rate != null && (rate.getTotalCount() == rate.getErrorCount())) {
//上传成功,删除上传的进度条
orderCreateService.delRate(token);
}
if (rate == null) { if (rate == null) {
rate = new FileRateDTO(); rate = new FileRateDTO();
rate.setRate("100%"); rate.setRate("100%");
return Result.success(rate); return Result.success(rate);
} }
rate.setErrorExcelDTOList(null);
return Result.success(rate); return Result.success(rate);
} }
/** /**
* 错误模版下载
*
* @param request
* @return
* @throws IOException
*/
@GetMapping("/file/errorTemplate")
public void errorTemplate(HttpServletRequest request,HttpServletResponse response) throws IOException {
String token = request.getHeader(HttpHeaders.AUTHORIZATION);
if (StringUtils.isBlank(token)) {
throw new BusinessException("用户未登录");
}
FileRateDTO rate = orderCreateService.orderRate(token);
try {
response.setContentType("application/vnd.ms-excel");
response.setCharacterEncoding("utf-8");
String fileName = URLEncoder.encode("ORDER-ERROR-" + new SimpleDateFormat("yyyyMMddHHmmss").format(new Date()), "UTF-8").replaceAll("\\+", "%20");
response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx");
orderCreateService.delRate(token);
EasyExcel.write(response.getOutputStream(), OrderInfoErrorExcelDTO.class)
.registerWriteHandler(ExcelUtil.getDefaultWriteHandler())
//注入原生 或 自定义转换器
.registerConverter(new DateStringConverter())
.registerConverter(new BigDecimalStringConverter())
.sheet("工单错误列表").doWrite(rate.getErrorExcelDTOList());
} catch (Exception e) {
throw new BusinessException("工单错误列表下载异常");
}
}
/**
* 订单批量模版下载 * 订单批量模版下载
* *
* @param * @param
......
...@@ -2,6 +2,9 @@ package com.dituhui.pea.order.dto; ...@@ -2,6 +2,9 @@ package com.dituhui.pea.order.dto;
import lombok.Data; import lombok.Data;
import java.util.ArrayList;
import java.util.List;
/** /**
* 文件上传列表比例查询 * 文件上传列表比例查询
*/ */
...@@ -23,4 +26,17 @@ public class FileRateDTO { ...@@ -23,4 +26,17 @@ public class FileRateDTO {
* 比列 * 比列
*/ */
private String rate; private String rate;
private List<OrderInfoErrorExcelDTO> errorExcelDTOList ;
/**
* 错误模版添加数据
* @param orderInfoErrorExcelDTO
*/
public void addErrorData(OrderInfoErrorExcelDTO orderInfoErrorExcelDTO) {
if (errorExcelDTOList == null){
errorExcelDTOList =new ArrayList<OrderInfoErrorExcelDTO>();
}
errorExcelDTOList.add(orderInfoErrorExcelDTO);
}
} }
...@@ -10,6 +10,7 @@ import org.springframework.format.annotation.DateTimeFormat; ...@@ -10,6 +10,7 @@ import org.springframework.format.annotation.DateTimeFormat;
import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotBlank;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
import java.util.List;
@Data @Data
@Builder @Builder
...@@ -93,6 +94,13 @@ public class OrderInfoExcelDTO { ...@@ -93,6 +94,13 @@ public class OrderInfoExcelDTO {
private String description; private String description;
/** /**
* 服务单标签列表
*/
@ExcelProperty(value = "工单标签")
@ColumnWidth(value = 20)
private String orderTags;
/**
* 省份 * 省份
*/ */
@ExcelIgnore @ExcelIgnore
......
...@@ -18,6 +18,7 @@ package com.dituhui.pea.order.service; ...@@ -18,6 +18,7 @@ package com.dituhui.pea.order.service;
import com.dituhui.pea.common.BusinessException; import com.dituhui.pea.common.BusinessException;
import com.dituhui.pea.common.Result; import com.dituhui.pea.common.Result;
import com.dituhui.pea.order.dto.FileRateDTO;
import com.dituhui.pea.order.dto.OrderInfoExcelDTO; import com.dituhui.pea.order.dto.OrderInfoExcelDTO;
import com.dituhui.pea.order.dto.param.OrderDTO; import com.dituhui.pea.order.dto.param.OrderDTO;
...@@ -40,6 +41,9 @@ public interface OrderCreateService { ...@@ -40,6 +41,9 @@ public interface OrderCreateService {
*/ */
OrderDTO.StageResult orderStage(String orderId); OrderDTO.StageResult orderStage(String orderId);
void saveBatch(List<OrderInfoExcelDTO> cachedDataList, String token, ThreadLocal local , HttpServletResponse response); void saveBatch(List<OrderInfoExcelDTO> cachedDataList, String token, ThreadLocal local);
FileRateDTO orderRate(String token);
void delRate(String token);
} }
...@@ -15,6 +15,7 @@ import lombok.extern.slf4j.Slf4j; ...@@ -15,6 +15,7 @@ import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.*; import org.springframework.http.*;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap; import org.springframework.util.MultiValueMap;
...@@ -37,6 +38,7 @@ public class CommonServiceImpl implements CommonService { ...@@ -37,6 +38,7 @@ public class CommonServiceImpl implements CommonService {
private PubParamsDao pubParamsDao; private PubParamsDao pubParamsDao;
@Async
public OrderEventEntity addOrderEvent(String orderId, String subOrderId, String source, String operator, String event, String content, String memo) { public OrderEventEntity addOrderEvent(String orderId, String subOrderId, String source, String operator, String event, String content, String memo) {
OrderEventEntity entity = new OrderEventEntity(); OrderEventEntity entity = new OrderEventEntity();
if (StringUtils.isBlank(source)) { if (StringUtils.isBlank(source)) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!