|  |  |  | 
|---|
|  |  |  | import com.core.common.DateUtils; | 
|---|
|  |  |  | import com.core.common.R; | 
|---|
|  |  |  | import com.zy.asrs.entity.WaitPakin; | 
|---|
|  |  |  | import com.zy.asrs.entity.WrkMast; | 
|---|
|  |  |  | import com.zy.asrs.service.OrderDetlPakinService; | 
|---|
|  |  |  | 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 OrderDetlPakinService orderDetlPakinService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private WrkMastService wrkMastService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @RequestMapping(value = "/waitPakin/{id}/auth") | 
|---|
|  |  |  | @ManagerAuth | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @RequestMapping(value = "/waitPakin/list/auth") | 
|---|
|  |  |  | @ManagerAuth | 
|---|
|  |  |  | public R list(@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){ | 
|---|
|  |  |  | public R list(@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) { | 
|---|
|  |  |  | excludeTrash(param); | 
|---|
|  |  |  | EntityWrapper<WaitPakin> wrapper = new EntityWrapper<>(); | 
|---|
|  |  |  | convert(param, wrapper); | 
|---|
|  |  |  | if (!Cools.isEmpty(orderByField)){wrapper.orderBy(humpToLine(orderByField), "asc".equals(orderByType));} | 
|---|
|  |  |  | 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()))); | 
|---|
|  |  |  | private void convert(Map<String, Object> map, EntityWrapper wrapper) { | 
|---|
|  |  |  | for (Map.Entry<String, Object> entry : map.entrySet()) { | 
|---|
|  |  |  | 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); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | return R.ok(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @RequestMapping(value = "/waitPakin/update/auth") | 
|---|
|  |  |  | @ManagerAuth | 
|---|
|  |  |  | public R update(WaitPakin waitPakin){ | 
|---|
|  |  |  | if (Cools.isEmpty(waitPakin) || null==waitPakin.getId()){ | 
|---|
|  |  |  | @RequestMapping(value = "/waitPakin/update/auth") | 
|---|
|  |  |  | @ManagerAuth | 
|---|
|  |  |  | public R update(WaitPakin waitPakin) { | 
|---|
|  |  |  | if (Cools.isEmpty(waitPakin)) { | 
|---|
|  |  |  | return R.error(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | waitPakinService.updateById(waitPakin); | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @RequestMapping(value = "/waitPakin/delete/auth") | 
|---|
|  |  |  | @ManagerAuth | 
|---|
|  |  |  | public R delete(@RequestParam String param){ | 
|---|
|  |  |  | @Transactional | 
|---|
|  |  |  | public R delete(@RequestParam String param) { | 
|---|
|  |  |  | List<WaitPakin> list = JSONArray.parseArray(param, WaitPakin.class); | 
|---|
|  |  |  | if (Cools.isEmpty(list)){ | 
|---|
|  |  |  | return R.error(); | 
|---|
|  |  |  | if (Cools.isEmpty(list)) { | 
|---|
|  |  |  | return R.error("数据为空"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | for (WaitPakin entity : list){ | 
|---|
|  |  |  | 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 (!orderDetlPakinService.decrease(entity.getOrderNo(), entity.getMatnr(), entity.getBatch(), entity.getAnfme())) { | 
|---|
|  |  |  | return R.error("订单数据回滚失败"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return R.ok(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @RequestMapping(value = "/waitPakin/export/auth") | 
|---|
|  |  |  | @ManagerAuth | 
|---|
|  |  |  | public R export(@RequestBody JSONObject param){ | 
|---|
|  |  |  | public R export(@RequestBody JSONObject param) { | 
|---|
|  |  |  | List<String> fields = JSONObject.parseArray(param.getJSONArray("fields").toJSONString(), String.class); | 
|---|
|  |  |  | EntityWrapper<WaitPakin> wrapper = new EntityWrapper<>(); | 
|---|
|  |  |  | Map<String, Object> map = excludeTrash(param.getJSONObject("waitPakin")); | 
|---|
|  |  |  | 
|---|
|  |  |  | wrapper.like("id", condition); | 
|---|
|  |  |  | Page<WaitPakin> page = waitPakinService.selectPage(new Page<>(0, 10), wrapper); | 
|---|
|  |  |  | List<Map<String, Object>> result = new ArrayList<>(); | 
|---|
|  |  |  | for (WaitPakin waitPakin : page.getRecords()){ | 
|---|
|  |  |  | 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); | 
|---|
|  |  |  | 
|---|
|  |  |  | @ManagerAuth | 
|---|
|  |  |  | public R query(@RequestBody JSONObject param) { | 
|---|
|  |  |  | Wrapper<WaitPakin> wrapper = new EntityWrapper<WaitPakin>().eq(humpToLine(String.valueOf(param.get("key"))), param.get("val")); | 
|---|
|  |  |  | if (null != waitPakinService.selectOne(wrapper)){ | 
|---|
|  |  |  | if (null != waitPakinService.selectOne(wrapper)) { | 
|---|
|  |  |  | return R.parse(BaseRes.REPEAT).add(getComment(WaitPakin.class, String.valueOf(param.get("key")))); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return R.ok(); | 
|---|