| package com.zy.asrs.controller; | 
|   | 
| 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.core.common.DateUtils; | 
| import com.zy.asrs.entity.BasJar; | 
| import com.zy.asrs.entity.vo.JarStateTableVo; | 
| import com.zy.asrs.service.BasJarService; | 
| import com.core.annotations.ManagerAuth; | 
| import com.core.common.BaseRes; | 
| import com.core.common.Cools; | 
| import com.core.common.R; | 
| import com.zy.common.model.enums.JarStatusType; | 
| import com.zy.common.web.BaseController; | 
| import org.springframework.beans.factory.annotation.Autowired; | 
| import org.springframework.web.bind.annotation.*; | 
|   | 
| import java.util.*; | 
|   | 
| @RestController | 
| public class BasJarController extends BaseController { | 
|   | 
|     @Autowired | 
|     private BasJarService basJarService; | 
|   | 
|     @RequestMapping(value = "/basJar/{id}/auth") | 
|     @ManagerAuth | 
|     public R get(@PathVariable("id") String id) { | 
|         return R.ok(basJarService.selectById(String.valueOf(id))); | 
|     } | 
|   | 
|     @RequestMapping(value = "/basJar/list/auth") | 
|     @ManagerAuth | 
|     public R list(@RequestParam(defaultValue = "1")Integer curr, | 
|                   @RequestParam(defaultValue = "10")Integer limit, | 
|                   @RequestParam(required = false)String orderByField, | 
|                   @RequestParam(required = false)String orderByType, | 
|                   @RequestParam(required = false)String condition, | 
|                   @RequestParam Map<String, Object> param){ | 
|         EntityWrapper<BasJar> wrapper = new EntityWrapper<>(); | 
|         excludeTrash(param); | 
|         convert(param, wrapper); | 
|         allLike(BasJar.class, param.keySet(), wrapper, condition); | 
|         if (!Cools.isEmpty(orderByField)){wrapper.orderBy(humpToLine(orderByField), "asc".equals(orderByType));} | 
|         return R.ok(basJarService.selectPage(new Page<>(curr, limit), wrapper)); | 
|     } | 
|   | 
|     private <T> void convert(Map<String, Object> map, EntityWrapper<T> wrapper){ | 
|         for (Map.Entry<String, Object> entry : map.entrySet()){ | 
|             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.like(entry.getKey(), val); | 
|             } | 
|         } | 
|     } | 
|   | 
|     @RequestMapping(value = "/basJar/add/auth") | 
|     @ManagerAuth(memo = "新增硫化罐") | 
|     public R add(BasJar basJar) { | 
|         basJarService.insert(basJar); | 
|         return R.ok(); | 
|     } | 
|   | 
|     @RequestMapping(value = "/basJar/update/auth") | 
|     @ManagerAuth(memo = "修改硫化罐") | 
|     public R update(BasJar basJar){ | 
|         if (Cools.isEmpty(basJar) || null==basJar.getJarNo()){ | 
|             return R.error(); | 
|         } | 
|         basJarService.updateById(basJar); | 
|         return R.ok(); | 
|     } | 
|   | 
|     @RequestMapping(value = "/basJar/delete/auth") | 
|     @ManagerAuth(memo = "删除硫化罐") | 
|     public R delete(@RequestParam(value="ids[]") Long[] ids){ | 
|          for (Long id : ids){ | 
|             basJarService.deleteById(id); | 
|         } | 
|         return R.ok(); | 
|     } | 
|   | 
|     @RequestMapping(value = "/basJar/export/auth") | 
|     @ManagerAuth(memo = "导出硫化罐基础信息") | 
|     public R export(@RequestBody JSONObject param){ | 
|         EntityWrapper<BasJar> wrapper = new EntityWrapper<>(); | 
|         List<String> fields = JSONObject.parseArray(param.getJSONArray("fields").toJSONString(), String.class); | 
|         Map<String, Object> map = excludeTrash(param.getJSONObject("basJar")); | 
|         convert(map, wrapper); | 
|         List<BasJar> list = basJarService.selectList(wrapper); | 
|         return R.ok(exportSupport(list, fields)); | 
|     } | 
|   | 
|     @RequestMapping(value = "/basJarQuery/auth") | 
|     @ManagerAuth | 
|     public R query(String condition) { | 
|         EntityWrapper<BasJar> wrapper = new EntityWrapper<>(); | 
|         wrapper.like("jar_no", condition); | 
|         Page<BasJar> page = basJarService.selectPage(new Page<>(0, 10), wrapper); | 
|         List<Map<String, Object>> result = new ArrayList<>(); | 
|         for (BasJar basJar : page.getRecords()){ | 
|             Map<String, Object> map = new HashMap<>(); | 
|             map.put("id", basJar.getJarNo()); | 
|             map.put("value", basJar.getJarNo()); | 
|             result.add(map); | 
|         } | 
|         return R.ok(result); | 
|     } | 
|   | 
|     @RequestMapping(value = "/basJar/check/column/auth") | 
|     @ManagerAuth | 
|     public R query(@RequestBody JSONObject param) { | 
|         Wrapper<BasJar> wrapper = new EntityWrapper<BasJar>().eq(humpToLine(String.valueOf(param.get("key"))), param.get("val")); | 
|         if (null != basJarService.selectOne(wrapper)){ | 
|             return R.parse(BaseRes.REPEAT).add(getComment(BasJar.class, String.valueOf(param.get("key")))); | 
|         } | 
|         return R.ok(); | 
|     } | 
|   | 
|   | 
|   | 
|     @PostMapping("/table/jar/state") | 
|     @ManagerAuth(memo = "RGV信息表") | 
|     public R rgvStateTable(){ | 
|         List<JarStateTableVo> list = new ArrayList<>(); | 
|         List<BasJar> jars = basJarService.selectList(new EntityWrapper<BasJar>().orderBy("jar_no")); | 
|         for (BasJar basJar : jars) { | 
|             // 表格行 | 
|             JarStateTableVo vo = new JarStateTableVo(); | 
|             vo.setJarNo(basJar.getJarNo());   //  RGV号 | 
|             list.add(vo); | 
|   | 
|             vo.setJarMode(basJar.getJarMode() == 1?"联机":"脱机" );   //  模式状态 | 
|             vo.setJarStatus(JarStatusType.get(basJar.getJarMode()).desc);     //  状态 | 
|             vo.setJarNo(basJar.getJarNo());  //  工位1任务号 | 
|             vo.setRegion(basJar.getRegion()); | 
|             vo.setJarCode(basJar.getJarCode()); | 
|             vo.setJarErr(basJar.getJarErr()); | 
|   | 
|         } | 
|         return R.ok().add(list); | 
|     } | 
|   | 
|   | 
| } |