| | |
| | | import com.zy.common.model.Shelves; |
| | | import com.zy.common.web.BaseController; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.beans.factory.annotation.Value; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.util.*; |
| | |
| | | private LocMastService locMastService; |
| | | @Autowired |
| | | private LocDetlService locDetlService; |
| | | @Value("${channel.equipmentRow}") |
| | | private Integer equipmentRow; |
| | | @Value("${channel.quietRow}") |
| | | private Integer quietRow; |
| | | @Value("${channel.equipmentCount}") |
| | | private Integer equipmentCount; |
| | | @Value("${channel.channelMax}") |
| | | private Integer channelMax; |
| | | |
| | | @RequestMapping(value = "/locMast/init/pwd") |
| | | public R locMastInitPwd(@RequestParam(required = false) String pwd) { |
| | |
| | | return R.ok(locMastService.selectPage(new Page<>(curr, limit), wrapper)); |
| | | } |
| | | |
| | | private void convert(Map<String, Object> map, EntityWrapper wrapper){ |
| | | private <T> void convert(Map<String, Object> map, EntityWrapper<T> wrapper){ |
| | | for (Map.Entry<String, Object> entry : map.entrySet()){ |
| | | if (entry.getKey().endsWith(">")) { |
| | | wrapper.ge(Cools.deleteChar(entry.getKey()), DateUtils.convert(String.valueOf(entry.getValue()))); |
| | | } else if (entry.getKey().endsWith("<")) { |
| | | wrapper.le(Cools.deleteChar(entry.getKey()), DateUtils.convert(String.valueOf(entry.getValue()))); |
| | | 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(), String.valueOf(entry.getValue())); |
| | | if (entry.getKey().equals("loc_type1")){ |
| | | wrapper.eq(entry.getKey(), val); |
| | | }else { |
| | | wrapper.like(entry.getKey(), val); |
| | | } |
| | | } |
| | | } |
| | | } |
| | |
| | | return R.error(); |
| | | } |
| | | LocMast oldLocMast = locMastService.selectById(locMast.getLocNo()); |
| | | if (locMast.getLocSts().equals("F") && (oldLocMast.getLocSts().equals("D") || oldLocMast.getLocSts().equals("O"))) { |
| | | return R.error("当前操作已被阻止,请联系管理员"); |
| | | } |
| | | // 有物料时修改为空库位或者空板库位,则删除库存明细 |
| | | if (oldLocMast.getLocType().equals("R") || oldLocMast.getLocType().equals("F")) { |
| | | if (locMast.getLocType().equals("O") || locMast.getLocType().equals("D")) { |
| | | if (oldLocMast.getLocSts().equals("R") || oldLocMast.getLocSts().equals("F")) { |
| | | if (locMast.getLocSts().equals("O") || locMast.getLocSts().equals("D")) { |
| | | locDetlService.delete(new EntityWrapper<LocDetl>().eq("loc_no", locMast.getLocNo())); |
| | | } |
| | | } |
| | |
| | | break; |
| | | } |
| | | } |
| | | Date now = new Date(); |
| | | LocMast locMast = new LocMast(); |
| | | locMast.setLocNo(locNo); |
| | | locMast.setLocType("O"); |
| | | locMast.setLocSts("O"); |
| | | locMast.setRow1(r); // 排 |
| | | locMast.setBay1(b); // 列 |
| | | locMast.setLev1(l); // 层 |
| | | locMast.setCrnNo(crnNo); // 堆垛机 |
| | | if (null != param.getWhsType()) { |
| | | locMast.setWhsType(Long.valueOf(param.getWhsType())); |
| | | } |
| | | locMast.setLocType1((short)0); |
| | | locMast.setLocType2((short)0); |
| | | locMast.setLocType3((short)0); |
| | | locMast.setAppeUser(getUserId()); |
| | | locMast.setAppeTime(new Date()); |
| | | locMast.setAppeTime(now); |
| | | locMast.setModiUser(getUserId()); |
| | | locMast.setModiTime(new Date()); |
| | | locMast.setModiTime(now); |
| | | if (r==equipmentRow && b<3){ |
| | | locMast.setChannel(l+(b-2)*param.getEndLev()); |
| | | locMast.setLocType1((short)1); |
| | | int i = (locMast.getChannel() - 1) / (channelMax / equipmentCount) + 1; |
| | | locMast.setLocType2((short)i); |
| | | } |
| | | if (r==quietRow && b<3){ |
| | | locMast.setLocType1((short)2); |
| | | } |
| | | list.add(locMast); |
| | | } |
| | | } |
| | |
| | | locMastService.insertBatch(list); |
| | | return R.ok("初始化成功"); |
| | | } |
| | | @RequestMapping(value = "/locMast/disableALL/auth") |
| | | @ManagerAuth(memo = "禁用指定设备号库位") |
| | | public R disableALL(@RequestParam String param){ |
| | | return updateAll(param,"O"); |
| | | } |
| | | @RequestMapping(value = "/locMast/openAll/auth") |
| | | @ManagerAuth(memo = "打开指定设备号库位") |
| | | public R openAll(@RequestParam String param){ |
| | | return updateAll(param,"X"); |
| | | } |
| | | |
| | | private R updateAll(String param,String locSts){ |
| | | List<LocMast> locMasts = JSONArray.parseArray(param, LocMast.class); |
| | | if (Cools.isEmpty(locMasts)){ |
| | | return R.error(); |
| | | } |
| | | int locType2=99; |
| | | for (LocMast locMast : locMasts){ |
| | | if (Cools.isEmpty(locMast.getLocType2()) || locMast.getLocType2() == 0){ |
| | | return R.error("请选择测试库位"); |
| | | }else if (!locMast.getLocSts().equals(locSts)){ |
| | | if (locSts.equals("O")){ |
| | | return R.error("此设备下有库位非空,库位号:"+locMast.getLocNo()+"\t请查看库位"); |
| | | }else if (locSts.equals("X")){ |
| | | return R.error("此设备下有库位非禁用状态,库位号:"+locMast.getLocNo()+"\t请查看库位"); |
| | | } |
| | | }else if (locType2==99){ |
| | | locType2 = locMast.getLocType2(); |
| | | }else if(locType2 != locMast.getLocType2()){ |
| | | return R.error("请选择同一设备号下的库位"); |
| | | } |
| | | } |
| | | if (locSts.equals("O")){ |
| | | locSts="X"; |
| | | }else if (locSts.equals("X")){ |
| | | locSts="O"; |
| | | } |
| | | for (LocMast locMast : locMasts){ |
| | | if (Cools.isEmpty(locMast) || null==locMast.getLocNo()){ |
| | | return R.error("库位号为空:"+locMast); |
| | | } |
| | | locMast.setModiUser(getUserId()); |
| | | locMast.setModiTime(new Date()); |
| | | locMast.setLocSts(locSts); |
| | | locMastService.updateById(locMast); |
| | | } |
| | | return R.ok(); |
| | | } |
| | | } |