| | |
| | | package zy.cloud.wms.manager.controller; |
| | | |
| | | 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.core.common.DateUtils; |
| | | import com.core.exception.CoolException; |
| | | import zy.cloud.wms.manager.entity.FlowStatus; |
| | | import zy.cloud.wms.manager.entity.Item; |
| | | import zy.cloud.wms.manager.entity.Node; |
| | | import zy.cloud.wms.manager.entity.ProjectPlan; |
| | | import zy.cloud.wms.manager.entity.*; |
| | | import zy.cloud.wms.manager.service.FlowStatusService; |
| | | import zy.cloud.wms.manager.service.ItemService; |
| | | import zy.cloud.wms.manager.service.ProjectPlanService; |
| | |
| | | return R.ok(projectPlanService.selectById(String.valueOf(id))); |
| | | } |
| | | |
| | | |
| | | |
| | | @RequestMapping(value = "/projectPlan/list/auth") |
| | | @ManagerAuth |
| | | public R list(@RequestParam(defaultValue = "1") Integer curr, |
| | |
| | | @RequestParam(required = false) String orderByType, |
| | | @RequestParam Map<String, Object> param) { |
| | | String target = (String) param.get("items"); |
| | | String search = (String) param.get("id"); |
| | | param.remove("items"); |
| | | param.remove("id"); |
| | | |
| | | EntityWrapper<ProjectPlan> wrapper = new EntityWrapper<>(); |
| | | wrapper.eq("item_id",target); |
| | | if (target != null && !target.equals("0")){ |
| | | wrapper.eq("item_id",target); |
| | | }else{ |
| | | List<Item> items = itemService.selectList(new EntityWrapper<Item>() |
| | | .eq("status", "2")); |
| | | for (Item item : items) { |
| | | wrapper.ne("item_id",item.getId()); |
| | | } |
| | | |
| | | } |
| | | excludeTrash(param); |
| | | convert(param, wrapper); |
| | | wrapper.orderBy("weight_num"); |
| | | // if (!Cools.isEmpty(orderByField)) { |
| | | // wrapper.orderBy(humpToLine(orderByField), "asc".equals(orderByType)); |
| | | // } |
| | | |
| | | wrapper.orderBy("item_id"); |
| | | return R.ok(projectPlanService.selectPage(new Page<>(curr, limit), wrapper)); |
| | | } |
| | | |
| | |
| | | if (!Cools.isEmpty(checkExist)) { |
| | | throw new CoolException("权重值冲突,请检查"); |
| | | } |
| | | |
| | | FlowStatus id = flowStatusService.selectOne(new EntityWrapper<FlowStatus>() |
| | | .eq("id", projectPlan.getFlowId())); |
| | | if (!Cools.isEmpty(id)) { |
| | |
| | | return R.error(); |
| | | } |
| | | |
| | | ProjectPlan checkExist = projectPlanService.selectOne(new EntityWrapper<ProjectPlan>() |
| | | .eq("item_id", projectPlan.getItemId()) |
| | | .eq("weight_num", projectPlan.getWeightNum())); |
| | | if (!Cools.isEmpty(checkExist)) { |
| | | throw new CoolException("权重值冲突,请检查"); |
| | | if (projectPlan.getDelay() < 0){ |
| | | throw new CoolException("延期天数不可为负数"); |
| | | } |
| | | FlowStatus id = flowStatusService.selectOne(new EntityWrapper<FlowStatus>() |
| | | .eq("id", projectPlan.getFlowId())); |
| | | if (!Cools.isEmpty(id)) { |
| | | projectPlan.setFlowName(id.getName()); |
| | | }else { |
| | | throw new CoolException("无法通过节点ID找到对应节点"); |
| | | } |
| | | |
| | | projectPlan.setModifyTime(new Date()); |
| | | projectPlan.setModifyId(getUserId()); |
| | | projectPlanService.update(projectPlan,new EntityWrapper<ProjectPlan>() |
| | | .eq("item_id",projectPlan.getItemId()) |
| | | .eq("weight_num",projectPlan.getWeightNum())); |
| | | // projectPlanService.updateById(projectPlan); |
| | | |
| | | projectPlanService.updateById(projectPlan); |
| | | return R.ok(); |
| | | } |
| | | |
| | |
| | | return R.ok(); |
| | | } |
| | | |
| | | |
| | | @RequestMapping("/projectPlan/allProjects") |
| | | public R allProjects() { |
| | | |
| | | List<Item> items = itemService.selectList(null); |
| | | List<Item> items = itemService.selectList(new EntityWrapper<Item>() |
| | | .ne("status","2")); |
| | | |
| | | List<Map<String, Object>> result = new ArrayList<>(); |
| | | for (Item item : items) { |
| | |
| | | |
| | | } |
| | | |
| | | /** |
| | | * 获取延期项目 |
| | | * @param curr |
| | | * @param limit |
| | | * @param orderByField |
| | | * @param orderByType |
| | | * @param param |
| | | * @return |
| | | */ |
| | | |
| | | @RequestMapping("/projectPlan/diffProjects") |
| | | public R diffProjects(@RequestParam(defaultValue = "1") Integer curr, |
| | | @RequestParam(defaultValue = "10") Integer limit, |
| | | @RequestParam(required = false) String orderByField, |
| | | @RequestParam(required = false) String orderByType, |
| | | @RequestParam Map<String, Object> param){ |
| | | String name = (String) param.get("id"); |
| | | |
| | | Wrapper<ProjectPlan> condition = new EntityWrapper<ProjectPlan>(); |
| | | if (!Cools.isEmpty(name)) { |
| | | Item targetItem = itemService.selectOne(new EntityWrapper<Item>() |
| | | .like("name", name)); |
| | | |
| | | if (!Cools.isEmpty(targetItem)) { |
| | | |
| | | condition |
| | | .eq("item_id",targetItem.getId()) |
| | | .and() |
| | | .gt("delay", 0) |
| | | .or() |
| | | .isNotNull("delay_reason") |
| | | .and() |
| | | .ne("delay_reason", "") |
| | | .and() |
| | | .eq("item_id",targetItem.getId()); |
| | | }else { |
| | | return R.ok(new Page<>(curr,limit)); |
| | | } |
| | | |
| | | }else { |
| | | condition |
| | | .gt("delay", 0) |
| | | .or() |
| | | .isNotNull("delay_reason") |
| | | .and() |
| | | .ne("delay_reason", ""); |
| | | } |
| | | Page<ProjectPlan> projectPlanPage = projectPlanService.selectPage(new Page<>(curr, limit), condition); |
| | | return R.ok(projectPlanPage); |
| | | } |
| | | |
| | | /** |
| | | * 打印方法 |
| | | * @param param |
| | | * @return |
| | | */ |
| | | @RequestMapping("/projectPlan/diffProjects/export") |
| | | public R diffExport(@RequestBody JSONObject param){ |
| | | |
| | | // EntityWrapper<ProjectPlan> wrapper = new EntityWrapper<>(); |
| | | // hostEq(wrapper); |
| | | List<String> fields = JSONObject.parseArray(param.getJSONArray("fields").toJSONString(), String.class); |
| | | // Map<String, Object> map = excludeTrash(param.getJSONObject("item")); |
| | | // convert(map, wrapper); |
| | | // List<ProjectPlan> projectPlans = projectPlanService.selectList(wrapper); |
| | | |
| | | Wrapper<ProjectPlan> condition = new EntityWrapper<ProjectPlan>() |
| | | .gt("delay", 0) |
| | | .or() |
| | | .isNotNull("delay_reason") |
| | | .and() |
| | | .ne("delay_reason", ""); |
| | | List<ProjectPlan> projectPlans = projectPlanService.selectList(condition); |
| | | return R.ok(exportSupport(projectPlans, fields)); |
| | | } |
| | | |
| | | /** |
| | | * 返回所有节点类型给小杨写的前端 |
| | | * @return |
| | | */ |
| | | @RequestMapping("/projectPlan/flowStatus") |
| | | public R flowStatus(){ |
| | | EntityWrapper<FlowStatus> wrapper = new EntityWrapper<>(); |
| | | wrapper.orderBy("weight_num"); |
| | | List<FlowStatus> flowStatuses = flowStatusService.selectList(wrapper); |
| | | |
| | | return R.ok().add(flowStatuses); |
| | | } |
| | | |
| | | /** |
| | | * 返回给小杨前端数据 |
| | | * @return |
| | | */ |
| | | @RequestMapping("/projectPlan/toFront") |
| | | public R toFront(){ |
| | | List<Item> items = itemService.selectList(new EntityWrapper<Item>() |
| | | .eq("status","1")); |
| | | List<ItemsDTO> itemsDTOs = new ArrayList<>(); |
| | | |
| | | for (Item item : items) { |
| | | |
| | | ItemsDTO itemsDTO = new ItemsDTO(); |
| | | List<FlowsDTO> flows = new ArrayList<>(); |
| | | itemsDTO.setId(item.getName()); |
| | | itemsDTO.setStartDay(item.getStartTime$()); |
| | | itemsDTO.setEndDay(item.getEndTime$()); |
| | | List<ProjectPlan> allPlans = projectPlanService.selectList(new EntityWrapper<ProjectPlan>() |
| | | .eq("item_id", item.getId())); |
| | | for (ProjectPlan projectPlan : allPlans) { |
| | | FlowsDTO flowsDTO = new FlowsDTO(); |
| | | flowsDTO.setName(projectPlan.getFlowId$()); |
| | | flowsDTO.setStartTime(projectPlan.getStartTime$()); |
| | | flowsDTO.setEndTime$(projectPlan.getEndTime$()); |
| | | flowsDTO.setRealStartTime$(projectPlan.getRealStartTime$()); |
| | | flowsDTO.setRealEndTime$(projectPlan.getRealEndTime$()); |
| | | flows.add(flowsDTO); |
| | | } |
| | | itemsDTO.setNodes(flows); |
| | | itemsDTOs.add(itemsDTO); |
| | | } |
| | | return R.ok().add(itemsDTOs); |
| | | } |
| | | |
| | | |
| | | |
| | | } |