|  |  |  | 
|---|
|  |  |  | import com.zy.asrs.common.domain.dto.WrkTraceVo; | 
|---|
|  |  |  | import com.zy.asrs.common.domain.param.OrderDomainParam; | 
|---|
|  |  |  | import com.zy.asrs.common.wms.entity.*; | 
|---|
|  |  |  | import com.zy.asrs.common.wms.mapper.OrderDetlMapper; | 
|---|
|  |  |  | import com.zy.asrs.common.wms.service.*; | 
|---|
|  |  |  | 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 com.zy.asrs.framework.exception.CoolException; | 
|---|
|  |  |  | import org.apache.ibatis.annotations.Param; | 
|---|
|  |  |  | import org.springframework.beans.BeanUtils; | 
|---|
|  |  |  | import org.springframework.beans.factory.annotation.Autowired; | 
|---|
|  |  |  | import org.springframework.jdbc.core.JdbcTemplate; | 
|---|
|  |  |  | 
|---|
|  |  |  | private SnowflakeIdWorker snowflakeIdWorker; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private DocTypeService docTypeService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private LocInPrintMatService locInPrintMatService; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private MatService matService; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @RequestMapping(value = "/order/list/orderNo") | 
|---|
|  |  |  | public R orderListorderNo(@RequestParam String orderNo) { | 
|---|
|  |  |  | //数量修改成为完成数量 | 
|---|
|  |  |  | List<OrderDetl> orderDetl1=orderDetlService.list(new LambdaQueryWrapper<OrderDetl>().eq(OrderDetl::getOrderNo,orderNo)); | 
|---|
|  |  |  | List<OrderDetl> orderDetl1 = orderDetlService.list(new LambdaQueryWrapper<OrderDetl>().eq(OrderDetl::getOrderNo, orderNo)); | 
|---|
|  |  |  | List<OrderDetl> orderDetls= new ArrayList<OrderDetl>(); | 
|---|
|  |  |  | for (OrderDetl o: orderDetl1) { | 
|---|
|  |  |  | BigDecimal c1 = new BigDecimal(o.getEnableQty()).setScale(2,BigDecimal.ROUND_HALF_UP); | 
|---|
|  |  |  | o.setAnfme(c1.doubleValue()); | 
|---|
|  |  |  | if (o.getAnfme().equals(0.0)){ | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | orderDetls.add(o); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return R.ok(orderDetls); | 
|---|
|  |  |  | 
|---|
|  |  |  | return R.ok(orderService.selectAllorderNo(getHostId())); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @RequestMapping(value = "/order/comb/list/all") | 
|---|
|  |  |  | @ManagerAuth | 
|---|
|  |  |  | public R orderListComb() { | 
|---|
|  |  |  | return R.ok(orderService.selectAllCombOrderNo(getHostId())); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //    @RequestMapping(value = "/outOrder/list/all") | 
|---|
|  |  |  | //    @ManagerAuth | 
|---|
|  |  |  | //    public R orderOutList() { | 
|---|
|  |  |  | //        return R.ok(orderService.selectAllOutOrderNo(getHostId())); | 
|---|
|  |  |  | //    } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @RequestMapping(value = "/outOrder/list/all") | 
|---|
|  |  |  | @ManagerAuth | 
|---|
|  |  |  | public R orderOutList() { | 
|---|
|  |  |  | return R.ok(orderService.selectAllOutOrderNo(getHostId())); | 
|---|
|  |  |  | public R orderOutListOrder(@RequestBody String orderNo) { | 
|---|
|  |  |  | return R.ok(orderService.selectAllOutOrderNo(orderNo,getHostId())); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @RequestMapping(value = "/order/{id}/auth") | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (!orderDetlService.remove(new LambdaQueryWrapper<OrderDetl>().eq(OrderDetl::getOrderId, orderId))) { | 
|---|
|  |  |  | throw new CoolException("删除单据明细失败"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return R.ok(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @RequestMapping(value = "/order/dy") | 
|---|
|  |  |  | @ManagerAuth(memo = "手动删除订单") | 
|---|
|  |  |  | @Transactional | 
|---|
|  |  |  | public R dy(@RequestParam Long orderId){ | 
|---|
|  |  |  | List<OrderDetl> list = orderDetlService.list(new LambdaQueryWrapper<OrderDetl>().eq(OrderDetl::getOrderId, orderId)); | 
|---|
|  |  |  | for (OrderDetl orderDetl : list) { | 
|---|
|  |  |  | Mat mat = matService.getOne(new LambdaQueryWrapper<Mat>().eq(Mat::getMatnr, orderDetl.getMatnr())); | 
|---|
|  |  |  | LocInPrintMat locInPrintMat = new LocInPrintMat(); | 
|---|
|  |  |  | locInPrintMat.setMatnr(orderDetl.getMatnr()); | 
|---|
|  |  |  | locInPrintMat.setMaktx(orderDetl.getMaktx()); | 
|---|
|  |  |  | locInPrintMat.setStatus(1); | 
|---|
|  |  |  | locInPrintMat.setOrderNo(orderDetl.getOrderNo()); | 
|---|
|  |  |  | locInPrintMat.setBatch(orderDetl.getBatch()); | 
|---|
|  |  |  | locInPrintMat.setCreateBy(getUserId()); | 
|---|
|  |  |  | locInPrintMat.setCreateTime(new Date()); | 
|---|
|  |  |  | locInPrintMat.setUpdateTime(new Date()); | 
|---|
|  |  |  | if(!Cools.isEmpty(mat)){ | 
|---|
|  |  |  | locInPrintMat.setDecrees(mat.getDecrees()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | locInPrintMatService.save(locInPrintMat); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | return R.ok(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | return R.ok("订单修改成功"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @RequestMapping(value = "/order/export/auth") | 
|---|
|  |  |  | @ManagerAuth(memo = "订单明细导出") | 
|---|
|  |  |  | public synchronized R export(@RequestBody JSONObject param){ | 
|---|
|  |  |  | List<String> fields = JSONObject.parseArray(param.getJSONArray("fields").toJSONString(), String.class); | 
|---|
|  |  |  | QueryWrapper<OrderDetl> wrapper = new QueryWrapper<>(); | 
|---|
|  |  |  | JSONArray orderNo = param.getJSONArray("orderNo"); | 
|---|
|  |  |  | List<String> orderNoList = new ArrayList<>(); | 
|---|
|  |  |  | for (int i = 0; i < orderNo.size(); i++) { | 
|---|
|  |  |  | Object o = orderNo.get(i); | 
|---|
|  |  |  | orderNoList.add(o.toString()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | List<OrderDetl> list = orderDetlService.list(new  QueryWrapper<OrderDetl>().in("order_no", orderNoList)); | 
|---|
|  |  |  | return R.ok(exportSupport(list, fields)); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 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") | 
|---|
|  |  |  | || Cools.eq(entry.getKey(),"unreason") | 
|---|
|  |  |  | || Cools.eq(entry.getKey(),"orderByField") | 
|---|
|  |  |  | || Cools.eq(entry.getKey(),"orderByType") | 
|---|
|  |  |  | || Cools.eq(entry.getKey(),"row") | 
|---|
|  |  |  | || Cools.eq(entry.getKey(),"condition")){ | 
|---|
|  |  |  | continue; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if(Cools.isEmpty(entry.getValue())){ | 
|---|
|  |  |  | 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())); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|