| | |
| | | package com.zy.asrs.controller; |
| | | |
| | | import com.alibaba.excel.EasyExcel; |
| | | import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.plugins.Page; |
| | | import com.core.annotations.ManagerAuth; |
| | |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.io.IOException; |
| | | import java.util.Date; |
| | | import java.util.Map; |
| | | import java.net.URLEncoder; |
| | | import java.util.*; |
| | | |
| | | @RestController |
| | | public class ReviewController extends BaseController { |
| | |
| | | |
| | | @Resource |
| | | private ReviewDetlMapper reviewDetlMapper; |
| | | |
| | | @Resource |
| | | private HttpServletResponse response; |
| | | |
| | | |
| | | @RequestMapping("/exportReview") |
| | | public synchronized void exportReview(String ids) throws IOException { |
| | | if (Cools.isEmpty(ids)) { |
| | | return; |
| | | } |
| | | String[] idsArr = ids.split(","); |
| | | Set set = new HashSet<Long>(); |
| | | for (String id : idsArr) { |
| | | if (!Cools.isEmpty(id)) { |
| | | set.add(Long.parseLong(id)); |
| | | } |
| | | } |
| | | List<ReviewDetl> reviewDetls = reviewDetlService.selectList(new EntityWrapper<ReviewDetl>().in("order_id", set)); |
| | | |
| | | response.setContentType("application/vnd.ms-excel"); |
| | | response.setCharacterEncoding("utf-8"); |
| | | String fileName = URLEncoder.encode("单据复核明细表", "UTF-8"); |
| | | response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx"); |
| | | EasyExcel.write(response.getOutputStream(), ReviewDetl.class) |
| | | .registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()) |
| | | .sheet("表1") |
| | | .doWrite(reviewDetls); |
| | | } |
| | | |
| | | @PostMapping("/importReview") |
| | | @ManagerAuth(memo = "单据导入") |
| | |
| | | public void importOrder(MultipartFile multipartFile) throws IOException { |
| | | // 考核数据的判重使用order_id,check_type的组合唯一索引解决 |
| | | EasyExcel.read(multipartFile.getInputStream(), ImportReviewDto.class, |
| | | new ImportReviewListener(transactionManager,reviewService, reviewDetlService, snowflakeIdWorker, getUserId())).sheet().doReadSync(); |
| | | new ImportReviewListener(transactionManager, reviewService, reviewDetlService, snowflakeIdWorker, getUserId())).sheet().doReadSync(); |
| | | } |
| | | |
| | | |
| | |
| | | @RequestMapping(value = "/review/delete/auth") |
| | | @ManagerAuth(memo = "手动删除订单") |
| | | @Transactional |
| | | public R delete(@RequestParam Long orderId){ |
| | | public R delete(@RequestParam Long orderId) { |
| | | Review review = reviewService.selectById(orderId); |
| | | reviewDetlService.delete(new EntityWrapper<ReviewDetl>().eq("order_id", orderId)); |
| | | reviewService.deleteById(orderId); |