| | |
| | | package com.zy.asrs.controller; |
| | | |
| | | import com.alibaba.excel.EasyExcel; |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.baomidou.mybatisplus.mapper.Wrapper; |
| | | import com.baomidou.mybatisplus.plugins.Page; |
| | | import com.zy.asrs.entity.BasCrnError; |
| | | import com.zy.asrs.service.BasCrnErrorService; |
| | | import com.zy.common.web.BaseController; |
| | | import com.core.annotations.ManagerAuth; |
| | | import com.core.common.BaseRes; |
| | | import com.core.common.Cools; |
| | | import com.core.common.DateUtils; |
| | | import com.core.common.R; |
| | | import com.zy.asrs.entity.BasCrnError; |
| | | import com.zy.asrs.importexcle.ImportCrnErrDto; |
| | | import com.zy.asrs.importexcle.ImportCrnErrListener; |
| | | import com.zy.asrs.service.BasCrnErrorService; |
| | | import com.zy.common.web.BaseController; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | | import java.io.IOException; |
| | | import java.util.*; |
| | | |
| | | @RestController |
| | |
| | | @ManagerAuth |
| | | public R get(@PathVariable("id") Long id) { |
| | | return R.ok(basCrnErrorService.selectById(String.valueOf(id))); |
| | | } |
| | | |
| | | @PostMapping("/importCrnErr") |
| | | @ManagerAuth(memo = "导入堆垛机异常表") |
| | | public R importCrnErr(@RequestParam("file") MultipartFile multipartFile) { |
| | | try { |
| | | importCrnErrExec(multipartFile); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | return R.error(e.getMessage()); |
| | | } |
| | | return R.ok("导入成功"); |
| | | } |
| | | |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void importCrnErrExec(MultipartFile multipartFile) throws IOException { |
| | | EasyExcel.read(multipartFile.getInputStream(), ImportCrnErrDto.class, |
| | | new ImportCrnErrListener(basCrnErrorService)).sheet().doReadSync(); |
| | | } |
| | | |
| | | @RequestMapping(value = "/basCrnError/list/auth") |
| | |
| | | return R.ok(basCrnErrorService.selectPage(new Page<>(curr, limit), wrapper)); |
| | | } |
| | | |
| | | private void convert(Map<String, Object> map, EntityWrapper wrapper){ |
| | | private <T> void convert(Map<String, Object> map, EntityWrapper<T> wrapper){ |
| | | for (Map.Entry<String, Object> entry : map.entrySet()){ |
| | | if (entry.getKey().endsWith(">")) { |
| | | wrapper.ge(Cools.deleteChar(entry.getKey()), DateUtils.convert(String.valueOf(entry.getValue()))); |
| | | } else if (entry.getKey().endsWith("<")) { |
| | | wrapper.le(Cools.deleteChar(entry.getKey()), DateUtils.convert(String.valueOf(entry.getValue()))); |
| | | String val = String.valueOf(entry.getValue()); |
| | | if (val.contains(RANGE_TIME_LINK)){ |
| | | String[] dates = val.split(RANGE_TIME_LINK); |
| | | wrapper.ge(entry.getKey(), DateUtils.convert(dates[0])); |
| | | wrapper.le(entry.getKey(), DateUtils.convert(dates[1])); |
| | | } else { |
| | | wrapper.eq(entry.getKey(), String.valueOf(entry.getValue())); |
| | | wrapper.like(entry.getKey(), val); |
| | | } |
| | | } |
| | | } |
| | | |
| | | @RequestMapping(value = "/basCrnError/add/auth") |
| | | @ManagerAuth(memo = "堆垛机异常码添加") |
| | | public R add(BasCrnError basCrnError) { |