| | |
| | | package com.zy.asrs.controller; |
| | | |
| | | import com.alibaba.excel.EasyExcel; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.mapper.Wrapper; |
| | |
| | | import com.zy.asrs.entity.param.OrderDomainParam; |
| | | |
| | | import com.zy.asrs.entity.result.WrkTraceVo; |
| | | import com.zy.asrs.importexcle.ImportOrderDto; |
| | | import com.zy.asrs.importexcle.ImportOrderListener; |
| | | import com.zy.asrs.mapper.OrderDetlMapper; |
| | | import com.zy.asrs.service.*; |
| | | import com.zy.asrs.utils.FileSaveExampleUtil; |
| | | import com.zy.common.model.DetlDto; |
| | | import com.zy.common.web.BaseController; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.springframework.beans.BeanUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.http.MediaType; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.io.IOException; |
| | | import java.util.*; |
| | | |
| | | @RestController |
| | |
| | | private WrkMastService wrkMastService; |
| | | @Autowired |
| | | private WrkMastLogService wrkMastLogService; |
| | | |
| | | @Resource |
| | | private OrderDetlMapper orderDetlMapper; |
| | | |
| | | @PostMapping("/importOrder") |
| | | @ManagerAuth(memo = "单据导入") |
| | | @ApiOperation(value = "单据导入", produces = MediaType.APPLICATION_JSON_VALUE) |
| | | public R importOrderData(@RequestParam("file") MultipartFile multipartFile) { |
| | | try { |
| | | importOrder(multipartFile); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return R.error(e.getMessage()); |
| | | } |
| | | return R.ok("导入成功"); |
| | | } |
| | | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void importOrder(MultipartFile multipartFile) throws IOException { |
| | | // 考核数据的判重使用order_id,check_type的组合唯一索引解决 |
| | | EasyExcel.read(multipartFile.getInputStream(), ImportOrderDto.class, |
| | | new ImportOrderListener(orderService, orderDetlMapper,docTypeService, snowflakeIdWorker,getUserId())).sheet().doReadSync(); |
| | | } |
| | | |
| | | @RequestMapping(value = "/order/nav/list/auth") |
| | | @ManagerAuth |
| | |
| | | double totalQty = 0; |
| | | double wrkQty = 0; |
| | | double lackQty = 0; |
| | | double endQty = 0; |
| | | for (OrderDetl orderDetl : orderDetls) { |
| | | totalQty = totalQty + orderDetl.getAnfme(); |
| | | wrkQty = wrkQty + orderDetl.getQty(); |
| | | double issued = Optional.of(orderDetl.getAnfme() - orderDetl.getQty()).orElse(0.0D); |
| | | wrkQty = wrkQty + orderDetl.getWorkQty(); |
| | | endQty = endQty + orderDetl.getQty(); |
| | | double issued = Optional.of(orderDetl.getAnfme() - orderDetl.getWorkQty()).orElse(0.0D); |
| | | if (issued > 0.0) { |
| | | List<LocDetl> locDetls = locDetlService.queryStock(orderDetl.getMatnr(), orderDetl.getBatch(), orderDetl.getOrigin(), null); |
| | | for (LocDetl locDetl : locDetls) { |
| | |
| | | WrkMast wrkMast = wrkMastService.selectOne(new EntityWrapper<WrkMast>().eq("wrk_no", wrkDetl.getWrkNo()).eq("io_time", wrkDetl.getIoTime())); |
| | | if (wrkMast == null) { |
| | | WrkMastLog wrkMastLog = wrkMastLogService.selectOne(new EntityWrapper<WrkMastLog>().eq("wrk_no", wrkDetl.getWrkNo()).eq("io_time", wrkDetl.getIoTime())); |
| | | if (wrkMastLog.getIoType()==103){ |
| | | wrkMastLog = wrkMastLogService.selectOne(new EntityWrapper<WrkMastLog>().eq("wrk_no", wrkDetl.getWrkNo()).eq("io_time", wrkDetl.getIoTime()).eq("io_type",53)); |
| | | } |
| | | if (wrkMastLog != null) { |
| | | wrkMast = new WrkMast(); |
| | | BeanUtils.copyProperties(wrkMastLog, wrkMast); |
| | |
| | | .add("totalQty", totalQty) |
| | | .add("wrkQty", wrkQty) |
| | | .add("lackQty", lackQty) |
| | | .add("endQty",endQty) |
| | | ); |
| | | } |
| | | |
| | |
| | | return R.ok(); |
| | | } |
| | | |
| | | @RequestMapping(value = "/order/insert/labelUp/file/auth") |
| | | // @ManagerAuth |
| | | public R insertLabelUpFile(@RequestParam("orderId") String orderId,@RequestParam MultipartFile file){ |
| | | String[] split = orderId.split("-"); |
| | | int id = Integer.parseInt(split[1]); |
| | | System.out.println("---开始---"); |
| | | String savePath = "D:/order/labelUp/file/"+id+"/"; // 指定保存文件的路径 |
| | | try{ |
| | | FileSaveExampleUtil.saveFile(file, savePath); |
| | | }catch (Exception e){ |
| | | return R.error(); |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | @RequestMapping(value = "/order/view/labelUp/file/auth") |
| | | // @ManagerAuth |
| | | public R viewLabelUpFile(@RequestParam("orderId") Long orderId){ |
| | | // int id = Integer.parseInt(orderId); |
| | | String savePath = "D:/order/labelUp/file/"+orderId+"/"; // 指定保存文件的路径 |
| | | try{ |
| | | List<FileSaveExampleUtil.FileDTO> fileDTOS = FileSaveExampleUtil.viewFileList(savePath); |
| | | return R.ok(fileDTOS); |
| | | }catch (Exception e){ |
| | | return R.error(); |
| | | } |
| | | } |
| | | |
| | | } |