| | |
| | | import com.alibaba.fastjson.JSONArray; |
| | | import com.alibaba.fastjson.JSONObject; |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.zy.asrs.common.wms.entity.Mat; |
| | | import com.zy.asrs.common.wms.entity.WaitPakin; |
| | | import com.zy.asrs.common.wms.entity.WrkMast; |
| | | import com.zy.asrs.common.wms.service.OrderDetlService; |
| | | import com.zy.asrs.common.wms.service.WaitPakinService; |
| | | import com.zy.asrs.common.wms.service.WrkMastService; |
| | | import com.zy.asrs.framework.annotations.ManagerAuth; |
| | | import com.zy.asrs.framework.common.Cools; |
| | | import com.zy.asrs.framework.common.R; |
| | |
| | | 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 WaitPakinService waitPakinService; |
| | | @Autowired |
| | | private WrkMastService wrkMastService; |
| | | @Autowired |
| | | private OrderDetlService orderDetlService; |
| | | |
| | | @RequestMapping(value = "/waitPakin/forBarcode/auth") |
| | | @ManagerAuth |
| | |
| | | @RequestParam(required = false) String condition, |
| | | @RequestParam(required = false) String timeRange, |
| | | @RequestParam Map<String, Object> param) { |
| | | LambdaQueryWrapper<WaitPakin> wrapper = new LambdaQueryWrapper<>(); |
| | | wrapper.eq(WaitPakin::getHostId, getHostId()); |
| | | QueryWrapper<WaitPakin> wrapper = new QueryWrapper<>(); |
| | | wrapper.eq("host_id", getHostId()); |
| | | if (!Cools.isEmpty(condition)) { |
| | | wrapper.like(WaitPakin::getId, condition); |
| | | wrapper.like("id", condition); |
| | | } |
| | | convert(param,wrapper); |
| | | if (!Cools.isEmpty(timeRange)) { |
| | | String[] range = timeRange.split(RANGE_TIME_LINK); |
| | | wrapper.ge(WaitPakin::getAppeTime, DateUtils.convert(range[0])); |
| | | wrapper.le(WaitPakin::getAppeTime, DateUtils.convert(range[1])); |
| | | wrapper.ge("appe_time", DateUtils.convert(range[0])); |
| | | wrapper.le("appe_time", DateUtils.convert(range[1])); |
| | | } |
| | | return R.ok(waitPakinService.page(new Page<>(curr, limit), wrapper)); |
| | | } |
| | | |
| | | private <T> void convert(Map<String, Object> map, QueryWrapper<T> wrapper){ |
| | | for (Map.Entry<String, Object> entry : map.entrySet()){ |
| | | if(Cools.eq(entry.getKey(),"curr") || Cools.eq(entry.getKey(),"limit")){ |
| | | continue; |
| | | } |
| | | 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 { |
| | | if (entry.getKey().equals("locNo")) { |
| | | wrapper.eq("loc_no", String.valueOf(entry.getValue())); |
| | | } else { |
| | | wrapper.like(entry.getKey(), String.valueOf(entry.getValue())); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | |
| | | return R.ok(); |
| | | } |
| | | |
| | | // @RequestMapping(value = "/waitPakin/delete/auth") |
| | | // @ManagerAuth |
| | | // public R delete(@RequestParam(value="ids[]") Long[] ids){ |
| | | // for (Long id : ids){ |
| | | // waitPakinService.removeById(id); |
| | | // } |
| | | // return R.ok(); |
| | | // } |
| | | |
| | | @RequestMapping(value = "/waitPakin/delete/auth") |
| | | @ManagerAuth |
| | | public R delete(@RequestParam(value="ids[]") Long[] ids){ |
| | | for (Long id : ids){ |
| | | waitPakinService.removeById(id); |
| | | @Transactional |
| | | public R delete(@RequestParam String param){ |
| | | List<WaitPakin> list = JSONArray.parseArray(param, WaitPakin.class); |
| | | if (Cools.isEmpty(list)){ |
| | | return R.error("数据为空"); |
| | | } |
| | | for (WaitPakin entity : list){ |
| | | List<WrkMast> wrkMasts = wrkMastService.list(new QueryWrapper<WrkMast>().eq("barcode", entity.getZpallet())); |
| | | if(!Cools.isEmpty(wrkMasts) || wrkMasts.size() > 0){ |
| | | return R.error("条码已生成入库工作档,禁止删除"); |
| | | } |
| | | waitPakinService.removeById(entity.getId()); |
| | | //订单关联,修改订单作业数量 |
| | | if (!Cools.isEmpty(entity.getOrderNo())) { |
| | | if (!orderDetlService.decrease(entity.getOrderNo(),entity.getHostId(), entity.getMatnr(), entity.getBatch(), entity.getAnfme())) { |
| | | return R.error("订单数据回滚失败"); |
| | | } |
| | | } |
| | | } |
| | | return R.ok(); |
| | | } |