|  |  | 
 |  |  | import com.alibaba.fastjson.JSONObject; | 
 |  |  | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; | 
 |  |  | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | 
 |  |  | import com.zy.asrs.common.domain.entity.Parameter; | 
 |  |  | import com.zy.asrs.common.domain.entity.Shelves; | 
 |  |  | import com.zy.asrs.common.domain.param.LocMastInitParam; | 
 |  |  | import com.zy.asrs.common.wms.entity.LocDetl; | 
 |  |  | import com.zy.asrs.common.wms.entity.LocMast; | 
 |  |  | import com.zy.asrs.common.wms.service.LocDetlService; | 
 |  |  | import com.zy.asrs.common.wms.service.LocMastService; | 
 |  |  | import com.zy.asrs.framework.annotations.ManagerAuth; | 
 |  |  | import com.zy.asrs.framework.common.Cools; | 
 |  |  | 
 |  |  | import com.zy.asrs.framework.common.DateUtils; | 
 |  |  | import com.zy.asrs.common.web.BaseController; | 
 |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
 |  |  | import org.springframework.transaction.annotation.Transactional; | 
 |  |  | import org.springframework.web.bind.annotation.*; | 
 |  |  |  | 
 |  |  | import java.util.*; | 
 |  |  | 
 |  |  |  | 
 |  |  |     @Autowired | 
 |  |  |     private LocMastService locMastService; | 
 |  |  |     @Autowired | 
 |  |  |     private LocDetlService locDetlService; | 
 |  |  |  | 
 |  |  |     @RequestMapping(value = "/locMast/{id}/auth") | 
 |  |  |     @ManagerAuth | 
 |  |  |     public R get(@PathVariable("id") String id) { | 
 |  |  |         return R.ok(locMastService.getById(String.valueOf(id))); | 
 |  |  |         return R.ok(locMastService.getOne(new LambdaQueryWrapper<LocMast>().eq(LocMast::getLocNo, id).eq(LocMast::getHostId, getHostId()))); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @RequestMapping(value = "/locMast/page/auth") | 
 |  |  | 
 |  |  |         return R.ok().add(vos); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @RequestMapping(value = "/locMast/init/pwd") | 
 |  |  |     public R locMastInitPwd(@RequestParam(required = false) String pwd) { | 
 |  |  |         if (Cools.isEmpty(pwd)) { | 
 |  |  |             return R.error("请输入口令"); | 
 |  |  |         } | 
 |  |  |         return R.ok().add(Parameter.get().getLocMastInitPwd().equals(pwd)); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     @RequestMapping(value = "/locMast/init/auth") | 
 |  |  |     @ManagerAuth(memo = "初始化库位") | 
 |  |  |     @Transactional | 
 |  |  |     public R init(LocMastInitParam param) { | 
 |  |  |         Long hostId = getHostId(); | 
 |  |  |         List<LocMast> list = new ArrayList<>(); | 
 |  |  |         for (int r=param.getStartRow(); r<=param.getEndRow(); r++){ | 
 |  |  |             for (int b=param.getStartBay(); b<=param.getEndBay(); b++) { | 
 |  |  |                 for (int l=param.getStartLev(); l<=param.getEndLev(); l++) { | 
 |  |  |                     // 获取库位号 | 
 |  |  |                     String locNo = String.format("%02d", r) + String.format("%03d", b) + String.format("%02d", l); | 
 |  |  |                     // 获取堆垛机号 | 
 |  |  |                     int crnNo = 0; | 
 |  |  |                     Shelves shelves = new Shelves(param.getEndRow() - param.getStartRow() + 1, param.getCrnAmount()); | 
 |  |  |                     for (List<Integer> node : shelves.nodes){ | 
 |  |  |                         if (node.contains(r)) { | 
 |  |  |                             crnNo = shelves.nodes.indexOf(node) + 1; | 
 |  |  |                             break; | 
 |  |  |                         } | 
 |  |  |                     } | 
 |  |  |                     LocMast locMast = new LocMast(); | 
 |  |  |                     locMast.setLocNo(locNo); | 
 |  |  |                     locMast.setLocSts("O"); | 
 |  |  |                     locMast.setRow1(r); // 排 | 
 |  |  |                     locMast.setBay1(b); // 列 | 
 |  |  |                     locMast.setLev1(l); // 层 | 
 |  |  |                     locMast.setCrnNo(crnNo); // 堆垛机 | 
 |  |  |                     locMast.setLocType1(param.getLocType1()); | 
 |  |  |                     locMast.setLocType2(param.getLocType2()); | 
 |  |  |                     locMast.setLocType3(param.getLocType3()); | 
 |  |  |                     locMast.setAppeUser(getUserId()); | 
 |  |  |                     locMast.setAppeTime(new Date()); | 
 |  |  |                     locMast.setModiUser(getUserId()); | 
 |  |  |                     locMast.setModiTime(new Date()); | 
 |  |  |                     locMast.setHostId(hostId); | 
 |  |  |                     list.add(locMast); | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |         locMastService.remove(new LambdaQueryWrapper<LocMast>().eq(LocMast::getHostId, hostId)); | 
 |  |  |         locDetlService.remove(new LambdaQueryWrapper<LocDetl>().eq(LocDetl::getHostId, hostId)); | 
 |  |  |         for (LocMast locMast : list) { | 
 |  |  |             locMastService.save(locMast); | 
 |  |  |         } | 
 |  |  |         return R.ok("初始化成功"); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  | } |