|  |  | 
 |  |  | import com.core.common.DateUtils; | 
 |  |  | import com.core.common.R; | 
 |  |  | import com.zy.asrs.entity.WaitPakin; | 
 |  |  | import com.zy.asrs.entity.WrkDetl; | 
 |  |  | import com.zy.asrs.entity.WrkMast; | 
 |  |  | import com.zy.asrs.service.OrderDetlService; | 
 |  |  | import com.zy.asrs.service.WaitPakinService; | 
 |  |  | import com.zy.asrs.service.WrkMastService; | 
 |  |  | import com.zy.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.ArrayList; | 
 |  |  | 
 |  |  |  | 
 |  |  |     @Autowired | 
 |  |  |     private WaitPakinService waitPakinService; | 
 |  |  |     @Autowired | 
 |  |  |     private OrderDetlService orderDetlService; | 
 |  |  |     @Autowired | 
 |  |  |     private WrkMastService wrkMastService; | 
 |  |  |  | 
 |  |  |     @RequestMapping(value = "/waitPakin/{id}/auth") | 
 |  |  |     @ManagerAuth | 
 |  |  | 
 |  |  |         EntityWrapper<WaitPakin> wrapper = new EntityWrapper<>(); | 
 |  |  |         convert(param, wrapper); | 
 |  |  |         if (!Cools.isEmpty(orderByField)){wrapper.orderBy(humpToLine(orderByField), "asc".equals(orderByType));} | 
 |  |  |         else { | 
 |  |  |             wrapper.orderBy("modi_time", false); | 
 |  |  |         } | 
 |  |  |         return R.ok(waitPakinService.selectPage(new Page<>(curr, limit), wrapper)); | 
 |  |  |     } | 
 |  |  |  | 
 |  |  |     private void convert(Map<String, Object> map, EntityWrapper 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())); | 
 |  |  |                 wrapper.like(entry.getKey(), val); | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |     } | 
 |  |  | 
 |  |  |    @RequestMapping(value = "/waitPakin/update/auth") | 
 |  |  |    @ManagerAuth | 
 |  |  |     public R update(WaitPakin waitPakin){ | 
 |  |  |         if (Cools.isEmpty(waitPakin) || null==waitPakin.getId()){ | 
 |  |  |         if (Cools.isEmpty(waitPakin)){ | 
 |  |  |             return R.error(); | 
 |  |  |         } | 
 |  |  |         waitPakinService.updateById(waitPakin); | 
 |  |  | 
 |  |  |  | 
 |  |  |     @RequestMapping(value = "/waitPakin/delete/auth") | 
 |  |  |     @ManagerAuth | 
 |  |  |     @Transactional | 
 |  |  |     public R delete(@RequestParam String param){ | 
 |  |  |         List<WaitPakin> list = JSONArray.parseArray(param, WaitPakin.class); | 
 |  |  |         if (Cools.isEmpty(list)){ | 
 |  |  |             return R.error(); | 
 |  |  |             return R.error("数据为空"); | 
 |  |  |         } | 
 |  |  |         for (WaitPakin entity : list){ | 
 |  |  |             List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>().eq("barcode", entity.getZpallet())); | 
 |  |  |             if(!Cools.isEmpty(wrkMasts) || wrkMasts.size() > 0){ | 
 |  |  |                 return R.error("条码已生成入库工作档,禁止删除"); | 
 |  |  |             } | 
 |  |  |             waitPakinService.delete(new EntityWrapper<>(entity)); | 
 |  |  |             //订单关联,修改订单作业数量 | 
 |  |  |             if (!Cools.isEmpty(entity.getOrderNo())) { | 
 |  |  |                 if (!orderDetlService.decrease(entity.getOrderNo(), entity.getMatnr(), entity.getBatch(), entity.getAnfme())) { | 
 |  |  |                     return R.error("订单数据回滚失败"); | 
 |  |  |                 } | 
 |  |  |             } | 
 |  |  |         } | 
 |  |  |         return R.ok(); | 
 |  |  |     } | 
 |  |  | 
 |  |  |         List<Map<String, Object>> result = new ArrayList<>(); | 
 |  |  |         for (WaitPakin waitPakin : page.getRecords()){ | 
 |  |  |             Map<String, Object> map = new HashMap<>(); | 
 |  |  |             map.put("id", waitPakin.getId()); | 
 |  |  |             map.put("value", waitPakin.getId()); | 
 |  |  |             map.put("id", waitPakin.getZpallet()); | 
 |  |  |             map.put("value", waitPakin.getZpallet()); | 
 |  |  |             result.add(map); | 
 |  |  |         } | 
 |  |  |         return R.ok(result); |