|
@@ -0,0 +1,121 @@
|
|
|
|
|
+package com.github.zuihou.business.controller.productionReadyCenter;
|
|
|
|
|
+
|
|
|
|
|
+import cn.hutool.core.bean.BeanUtil;
|
|
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
|
|
+import com.github.zuihou.base.R;
|
|
|
|
|
+import com.github.zuihou.base.controller.SuperController;
|
|
|
|
|
+import com.github.zuihou.base.request.PageParams;
|
|
|
|
|
+import com.github.zuihou.business.productionReadyCenter.dto.TrayPageDTO;
|
|
|
|
|
+import com.github.zuihou.business.productionReadyCenter.dto.TraySaveDTO;
|
|
|
|
|
+import com.github.zuihou.business.productionReadyCenter.dto.TrayUpdateDTO;
|
|
|
|
|
+import com.github.zuihou.business.productionReadyCenter.entity.Tray;
|
|
|
|
|
+import com.github.zuihou.business.productionReadyCenter.entity.TrayPosition;
|
|
|
|
|
+import com.github.zuihou.business.productionReadyCenter.service.TrayPositionService;
|
|
|
|
|
+import com.github.zuihou.business.productionReadyCenter.service.TrayService;
|
|
|
|
|
+import com.github.zuihou.database.mybatis.conditions.Wraps;
|
|
|
|
|
+import com.github.zuihou.database.mybatis.conditions.query.LbqWrapper;
|
|
|
|
|
+import com.github.zuihou.database.mybatis.conditions.query.QueryWrap;
|
|
|
|
|
+import io.swagger.annotations.Api;
|
|
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
+import org.springframework.validation.annotation.Validated;
|
|
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
|
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
+
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
|
+import java.util.HashMap;
|
|
|
|
|
+import java.util.List;
|
|
|
|
|
+import java.util.Map;
|
|
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * <p>
|
|
|
|
|
+ * 前端控制器
|
|
|
|
|
+ * 托盘
|
|
|
|
|
+ * </p>
|
|
|
|
|
+ *
|
|
|
|
|
+ * @author imcs
|
|
|
|
|
+ * @date 2020-12-12
|
|
|
|
|
+ */
|
|
|
|
|
+@Slf4j
|
|
|
|
|
+@Validated
|
|
|
|
|
+@RestController
|
|
|
|
|
+@RequestMapping("/tray")
|
|
|
|
|
+@Api(value = "Tray", tags = "托盘")
|
|
|
|
|
+public class MMeterialReceiveLogController extends SuperController<TrayService, Long, Tray, TrayPageDTO, TraySaveDTO, TrayUpdateDTO> {
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private TrayPositionService trayPositionService;
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public void query(PageParams<TrayPageDTO> params, IPage<Tray> page, Long defSize) {
|
|
|
|
|
+ TrayPageDTO data = params.getModel();
|
|
|
|
|
+ QueryWrap<Tray> wrap = handlerWrapper(null, params);
|
|
|
|
|
+ LbqWrapper<Tray> wrapper = wrap.lambda();
|
|
|
|
|
+ Tray tray = BeanUtil.toBean(data, Tray.class);
|
|
|
|
|
+
|
|
|
|
|
+ wrapper.like(Tray::getName, tray.getName())
|
|
|
|
|
+ .like(Tray::getSpecification, tray.getSpecification())
|
|
|
|
|
+ .eq(Tray::getBrand,tray.getBrand());
|
|
|
|
|
+
|
|
|
|
|
+ IPage<Tray> list= baseService.pageList(page, wrapper);
|
|
|
|
|
+ //取出分页里面得数据
|
|
|
|
|
+ List<Tray> l = list.getRecords();
|
|
|
|
|
+ //取出IDList
|
|
|
|
|
+ List<Long> idList = l.stream().map(p -> p.getId()).collect(Collectors.toList());
|
|
|
|
|
+ //根据IDList取出明细
|
|
|
|
|
+ List<TrayPosition> detailList = trayPositionService.list(Wraps.<TrayPosition>lbQ().in(TrayPosition::getTrayId, idList));
|
|
|
|
|
+ Map<Long,List<TrayPosition>>map = new HashMap<Long,List<TrayPosition>>();
|
|
|
|
|
+ for(TrayPosition ms:detailList){
|
|
|
|
|
+ if(map.containsKey(ms.getTrayId())){
|
|
|
|
|
+ map.get(ms.getTrayId()).add(ms);
|
|
|
|
|
+ }else{
|
|
|
|
|
+ List a = new ArrayList<TrayPosition>();
|
|
|
|
|
+ a.add(ms);
|
|
|
|
|
+ map.put(ms.getTrayId(),a);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ for(Tray m:l){
|
|
|
|
|
+ if(map.containsKey(m.getId())){
|
|
|
|
|
+ m.setPositionList(map.get(m.getId()));
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @ApiOperation(value = "查询托盘", notes = "查询托盘")
|
|
|
|
|
+ @PostMapping("/all")
|
|
|
|
|
+ public R<List<Tray>> list() {
|
|
|
|
|
+ return success(baseService.list());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public R<Tray> handlerSave(TraySaveDTO model) {
|
|
|
|
|
+ Tray tray = baseService.save(model);
|
|
|
|
|
+ return success(tray);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @ApiOperation(value = "删除托盘管理", notes = "删除托盘管理")
|
|
|
|
|
+ @PostMapping("/delete")
|
|
|
|
|
+ public R<Boolean> delete(@RequestBody Tray model) {
|
|
|
|
|
+ // 这个操作相当的危险,请谨慎操作!!!
|
|
|
|
|
+ return success(baseService.delete(model));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @ApiOperation(value = "修改托盘管理", notes = "修改托盘管理")
|
|
|
|
|
+ @PostMapping("/update")
|
|
|
|
|
+ public R<Tray> update(@RequestBody TrayUpdateDTO model) {
|
|
|
|
|
+ Tray tray = baseService.update(model);
|
|
|
|
|
+ return success(tray);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @ApiOperation(value = "修改状态", notes = "修改状态")
|
|
|
|
|
+ @PostMapping("/updateStatus")
|
|
|
|
|
+ public R<Tray> updateStatus(@RequestBody TrayUpdateDTO model) {
|
|
|
|
|
+ Tray tray = baseService.updateStatus(model);
|
|
|
|
|
+ return success(tray);
|
|
|
|
|
+ }
|
|
|
|
|
+}
|