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.BasJarMast; import com.zy.asrs.entity.vo.JarStateTableVo; import com.zy.asrs.service.BasJarMastService; 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; @Autowired private BasJarMastService basJarMastService; @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 param){ EntityWrapper 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 void convert(Map map, EntityWrapper wrapper){ for (Map.Entry 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/update/uodate/jar/count/auth") @ManagerAuth(memo = "更新硫化罐最大储量") public R updateJarCount(Integer jarCount,Integer jarNo){ if (jarCount > 0 && jarCount < 8 && jarNo == 0){ return R.error("修改数量不合法"); } List basJarMasts = basJarMastService.selectList(new EntityWrapper().eq("jar_id", jarNo)); if (basJarMasts.size()>jarCount){ return R.error("硫化罐当前存在储量大于修改目标储量,不允许修改!!!"); } BasJar basJar = basJarService.selectById(jarNo); if (basJar.getJarStatus() == 2 || basJar.getJarStatus()>3){ return R.error("硫化罐处于当前状态时,不允许修改!!!"); } basJar.setJarCount(jarCount); 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 wrapper = new EntityWrapper<>(); List fields = JSONObject.parseArray(param.getJSONArray("fields").toJSONString(), String.class); Map map = excludeTrash(param.getJSONObject("basJar")); convert(map, wrapper); List list = basJarService.selectList(wrapper); return R.ok(exportSupport(list, fields)); } @RequestMapping(value = "/basJarQuery/auth") @ManagerAuth public R query(String condition) { EntityWrapper wrapper = new EntityWrapper<>(); wrapper.like("jar_no", condition); Page page = basJarService.selectPage(new Page<>(0, 10), wrapper); List> result = new ArrayList<>(); for (BasJar basJar : page.getRecords()){ Map 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 wrapper = new EntityWrapper().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 = "JAR信息表") public R rgvStateTable(){ List list = new ArrayList<>(); List jars = basJarService.selectList(new EntityWrapper().orderBy("jar_no")); for (BasJar basJar : jars) { if (basJar.getJarCode()>2) continue; // 表格行 JarStateTableVo vo = new JarStateTableVo(); vo.setJarNo(basJar.getJarNo()); // RGV号 list.add(vo); vo.setJarMode(basJar.getJarMode$()); // 模式状态 vo.setJarStatus(JarStatusType.get(basJar.getJarStatus()).desc); // 状态 vo.setJarNo(basJar.getJarNo()); // 工位1任务号 vo.setRegion(basJar.getRegion()); vo.setJarCode(basJar.getJarCode()); vo.setJarErr(basJar.getJarErr$()); vo.setJarTemperature(basJar.getJarTemperature()); vo.setJarTemperature$(basJar.getJarTemperature().toString()+"℃"); vo.setJarPressure(basJar.getJarPressure()); vo.setJarPressure$(basJar.getJarPressure().toString()+"MPa"); vo.setJarCount(basJar.getJarCount());//最大储量 vo.setJarCount$(basJar.getJarCount().toString()+"托");//最大储量 vo.setHoldingTime(DateUtils.convert(basJar.getHoldingTime()));//保温时间 vo.setOpenTime(DateUtils.convert(basJar.getOpenTime()));//开门时间 vo.setCloseTime(DateUtils.convert(basJar.getCloseTime()));//关门时间 vo.setLeftDoorOpen(basJar.getLeftDoorOpen()); vo.setLeftDoorClose(basJar.getLeftDoorClose()); vo.setRightDoorOpen(basJar.getRightDoorOpen()); vo.setRightDoorClose(basJar.getRightDoorClose()); /** * 左门(checkBox) */ vo.setLeftDoor(basJar.getLeftDoor().equals("N")? "关闭":"打开"); /** * 右门(checkBox) */ vo.setRightDoor(basJar.getRightDoor().equals("N")? "关闭":"打开"); /** * 左门可开(checkBox) */ vo.setLeftInEnable(basJar.getLeftInEnable()); /** * 左门可关(checkBox) */ vo.setLeftOutEnable(basJar.getLeftOutEnable()); /** * 右门可开(checkBox) */ vo.setRightInEnable(basJar.getRightInEnable()); /** * 右门可关(checkBox) */ vo.setRightOutEnable(basJar.getRightOutEnable()); } return R.ok().add(list); } }