| | |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | |
| | | import java.net.URLEncoder; |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.time.LocalDateTime; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | | * @author whj |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | @RequestMapping(value = "/getByUserId", method = RequestMethod.GET) |
| | | @ApiOperation(value = "获取今日任务统计信息") |
| | | public Result<Object> getAll(String sendTime) { |
| | |
| | | Map<String, Object> map = new HashMap<String, Object>(); |
| | | map.put("count", list.size()); |
| | | map.put("sum", sum); |
| | | String name = area.getName(); |
| | | Map<String, List<OrderTask>> collect = list.stream().collect(Collectors.groupingBy(OrderTask::getAreaSectionId)); |
| | | for (Map.Entry<String, List<OrderTask>> stringListEntry : collect.entrySet()) { |
| | | String key = stringListEntry.getKey(); |
| | | List<OrderTask> value = stringListEntry.getValue(); |
| | | if(value.size()>0){ |
| | | AreaSection a = iAreaSectionService.getById(key); |
| | | name+=a.getName(); |
| | | } |
| | | } |
| | | if(name.equals(area.getName())){ |
| | | map.put("name", ""); |
| | | }else { |
| | | map.put("name", name); |
| | | } |
| | | return new ResultUtil<Object>().setData(map); |
| | | } |
| | | |
| | | @RequestMapping(value = "/getTodayCount", method = RequestMethod.GET) |
| | | @ApiOperation(value = "获取今日任务统计信息") |
| | | public Result<Object> getAllNew(String sendTime) { |
| | | Area area = getArea(securityUtil.getCurrUser().getId()); |
| | | if (area == null) { |
| | | return ResultUtil.error("请联系管理员绑定该车辆"); |
| | | } |
| | | |
| | | QueryWrapper<OrderTask> wrapper2 = new QueryWrapper<OrderTask>(); |
| | | String format = getFormatDate(sendTime); |
| | | wrapper2.eq("area_id", area.getId()); |
| | | wrapper2.eq("send_date", format); |
| | | List<OrderTask> list = iOrderTaskService.list(wrapper2); |
| | | |
| | | int sum = iOrderTaskService.sum(area.getId(), format); |
| | | |
| | | Map<String, Object> map = new HashMap<String, Object>(); |
| | | map.put("count", list.size()); |
| | | map.put("sum", sum); |
| | | map.put("name", ""); |
| | | map.put("sectons", null); |
| | | if (list.size() > 0) { |
| | | OrderTask orderTask = list.get(0); |
| | | String areaSectionId = orderTask.getAreaSectionId(); |
| | | AreaSection a = iAreaSectionService.getById(areaSectionId); |
| | | Area area2 = iAreaService.getById(orderTask.getAreaId()); |
| | | map.put("name", area2.getName() + a.getName()); |
| | | List<String> temp = new ArrayList<>(); |
| | | List<String> tempIds = new ArrayList<>(); |
| | | List<AreaSection> areaSections = new ArrayList<>(); |
| | | for(int i=0;i<list.size();i++){ |
| | | if(!tempIds.contains(list.get(i).getAreaSectionId())){ |
| | | tempIds.add(list.get(i).getAreaSectionId()); |
| | | AreaSection a = iAreaSectionService.getById(list.get(i).getAreaSectionId()); |
| | | temp.add(a.getName()); |
| | | areaSections.add(a); |
| | | } |
| | | } |
| | | map.put("name", area.getName() + StringUtils.join(temp,"-")); |
| | | map.put("sectons",areaSections); |
| | | temp.clear(); |
| | | tempIds.clear(); |
| | | //areaSections.clear(); |
| | | list.clear(); |
| | | } |
| | | return new ResultUtil<Object>().setData(map); |
| | | } |
| | | |
| | | @RequestMapping(value = "/getTodayOrder", method = RequestMethod.GET) |
| | | /* @RequestMapping(value = "/getTodayOrder", method = RequestMethod.GET) |
| | | @ApiOperation(value = "获取今日配送任务详情列表") |
| | | public Result<List<OrderTask>> getTodayOrder(String sendTime) { |
| | | Area area = getArea(securityUtil.getCurrUser().getId()); |
| | |
| | | obj.setCode(obj.getLinker()); |
| | | } |
| | | return new ResultUtil<List<OrderTask>>().setData(list); |
| | | }*/ |
| | | |
| | | @RequestMapping(value = "/getTodayOrder", method = RequestMethod.GET) |
| | | @ApiOperation(value = "获取今日配送任务详情列表") |
| | | public Result<List<OrderTask>> getTodayOrder(String sendTime) { |
| | | |
| | | //获取订单列表 |
| | | Area area = getArea(securityUtil.getCurrUser().getId()); |
| | | if (area == null) { |
| | | return ResultUtil.error("请联系管理员绑定该车辆"); |
| | | } |
| | | |
| | | QueryWrapper<OrderTask> wrapper2 = new QueryWrapper<OrderTask>(); |
| | | String format = getFormatDate(sendTime); |
| | | // wrapper2.eq("a.area_id",area.getId()); |
| | | // wrapper2.eq("a.send_date",format); |
| | | // wrapper2.orderByAsc("a.seq").orderByAsc("a.status"); |
| | | //List<OrderTask> list = iOrderTaskService.list2(wrapper2); |
| | | wrapper2.eq("area_id", area.getId()); |
| | | wrapper2.eq("send_date", format); |
| | | |
| | | wrapper2.orderByAsc("area_section_id").orderByAsc("seq").orderByAsc("status"); |
| | | List<OrderTask> list = iOrderTaskService.list(wrapper2); |
| | | |
| | | return new ResultUtil<List<OrderTask>>().setData(list); |
| | | } |
| | | |
| | | @RequestMapping(value = "/getTodayOrderByHulue", method = RequestMethod.GET) |
| | | @ApiOperation(value = "获取今日配送任务详情列表,忽略某订单,客户端专用接口") |
| | | public Result<OrderListVo> getTodayOrderFromHulue(String orderId, String sendTime) { |
| | | public Result<OrderListVo> getTodayOrderFromHulue(String orderId, String sendTime,String areaSectionId) { |
| | | //忽略订单 |
| | | if (!StrUtil.isEmpty(orderId)) { |
| | | OrderTask orderTask = iOrderTaskService.getById(orderId); |
| | | orderTask.setSeq(1000); |
| | | int seq = orderTask.getSeq(); |
| | | orderTask.setSeq(1000+seq); |
| | | iOrderTaskService.saveOrUpdate(orderTask); |
| | | } |
| | | //获取订单列表 |
| | |
| | | //List<OrderTask> list = iOrderTaskService.list2(wrapper2); |
| | | wrapper2.eq("area_id", area.getId()); |
| | | wrapper2.eq("send_date", format); |
| | | wrapper2.orderByAsc("seq").orderByAsc("status"); |
| | | if(!StrUtil.isEmpty(areaSectionId)){ |
| | | wrapper2.eq("area_section_id", areaSectionId); |
| | | } |
| | | wrapper2.orderByAsc("area_section_id").orderByAsc("seq").orderByAsc("status"); |
| | | List<OrderTask> list = iOrderTaskService.list(wrapper2); |
| | | int num = 0; |
| | | for (OrderTask obj : list) { |
| | |
| | | return 0+ "%"; |
| | | } |
| | | } |
| | | |
| | | @RequestMapping(value = "/getOneMonthOrderPercent", method = RequestMethod.GET) |
| | | @ApiOperation(value = "获取本月配送百分比") |
| | | public Result<String> getMonthPercent(){ |
| | |
| | | wrapper2.eq("area_id", area.getId()); |
| | | wrapper2.eq("send_date", format); |
| | | wrapper2.eq("status", 0); |
| | | //wrapper2.orderByAsc("seq"); |
| | | |
| | | PageVo page = new PageVo(); |
| | | page.setSort("seq"); |
| | | page.setOrder("asc"); |
| | | page.setPageSize(1); |
| | | page.setPageNumber(0); |
| | | List<OrderTask> list = iOrderTaskService.page(PageUtil.initMpPage(page), wrapper2).getRecords(); |
| | | //List<OrderTask> list = iOrderTaskService.list(wrapper2); |
| | | if (list.size() > 0) { |
| | | orderTask = list.get(0); |
| | | } else { |
| | | return new ResultUtil<OrderTask>().setData(null); |
| | | } |
| | | } |
| | | |
| | | orderTask.setCustomer(iCustomerService.getById(orderTask.getCustomerId())); |
| | | QueryWrapper<OrderDetail> wrapper3 = new QueryWrapper<OrderDetail>(); |
| | | wrapper3.eq("order_id", orderTask.getId()); |
| | | orderTask.setOrderDetails(iOrderDetailService.list(wrapper3)); |
| | | |
| | | return new ResultUtil<OrderTask>().setData(orderTask); |
| | | } |
| | | |
| | | @RequestMapping(value = "/getTodayOrderDetailByAreaSection", method = RequestMethod.GET) |
| | | @ApiOperation(value = "获取当前配送商户详情") |
| | | public Result<OrderTask> getTodayOrderDetail(String orderId, String sendTime,String areaSectionId) { |
| | | OrderTask orderTask = new OrderTask(); |
| | | if (!StrUtil.isEmpty(orderId)) { |
| | | orderTask = iOrderTaskService.getById(orderId); |
| | | if (orderTask.getStatus() != 0) { |
| | | return ResultUtil.error("此商户已配送"); |
| | | } |
| | | } else { |
| | | Area area = getArea(securityUtil.getCurrUser().getId()); |
| | | if (area == null) { |
| | | return ResultUtil.error("请联系管理员绑定该车辆"); |
| | | } |
| | | |
| | | QueryWrapper<OrderTask> wrapper2 = new QueryWrapper<OrderTask>(); |
| | | String format = getFormatDate(sendTime); |
| | | wrapper2.eq("area_id", area.getId()); |
| | | wrapper2.eq("send_date", format); |
| | | wrapper2.eq("status", 0); |
| | | if(!StrUtil.isEmpty(areaSectionId)){ |
| | | wrapper2.eq("area_section_Id", areaSectionId); |
| | | } |
| | | //wrapper2.orderByAsc("seq"); |
| | | |
| | | PageVo page = new PageVo(); |
| | |
| | | orderTask.setCarId(carId); |
| | | if (StrUtil.isNotEmpty(customerReceiveId)) { |
| | | orderTask.setCustomerReceiveId(customerReceiveId); |
| | | } |
| | | |
| | | if (!StrUtil.isEmpty(content)) { |
| | | orderTask.setRemarks(content); |
| | | } else { |
| | | if (status == 2) { |
| | | return ResultUtil.error("请填写异常签收原因"); |
| | | } |
| | | } |
| | | iOrderTaskService.saveOrUpdate(orderTask); |
| | | |
| | | Car car = iCarService.getById(orderTask.getCarId()); |
| | | EventLog eventLog = new EventLog(); |
| | | eventLog.setCarNo(car.getCarNo()); |
| | | eventLog.setRefId(orderId); |
| | | eventLog.setType(6);//6:配送完成 |
| | | iEventLogService.saveOrUpdate(eventLog); |
| | | |
| | | saveLog(); |
| | | return ResultUtil.success("添加成功"); |
| | | } |
| | | |
| | | @RequestMapping(value = "/signForX", method = RequestMethod.POST) |
| | | @ApiOperation(value = "签收") |
| | | public Object signForX(String orderId, int status, String content, String customerReceiveId, int time, String carId,String img) { |
| | | if (status == 1) { |
| | | if (StrUtil.isEmpty(customerReceiveId)) { |
| | | return ResultUtil.error("正常签收,接货人id必填"); |
| | | } |
| | | } |
| | | |
| | | if (StrUtil.isEmpty(carId)) { |
| | | return ResultUtil.error("车辆id不能为空"); |
| | | } |
| | | OrderTask orderTask = iOrderTaskService.getById(orderId); |
| | | orderTask.setStatus(status); |
| | | orderTask.setUserId(securityUtil.getCurrUser().getId()); |
| | | orderTask.setTime(time); |
| | | orderTask.setCarId(carId); |
| | | if (StrUtil.isNotEmpty(customerReceiveId)) { |
| | | orderTask.setCustomerReceiveId(customerReceiveId); |
| | | } |
| | | if(StrUtil.isNotEmpty(img)){ |
| | | if(StrUtil.isNotEmpty(orderTask.getImg())){ |
| | | String imgO = orderTask.getImg(); |
| | | orderTask.setImg(imgO+","+img); |
| | | }else{ |
| | | orderTask.setImg(img); |
| | | } |
| | | } |
| | | |
| | | if (!StrUtil.isEmpty(content)) { |
| | |
| | | ; |
| | | return new ResultUtil<List<OrderStatusCount>>().setData(data); |
| | | } |
| | | @Autowired |
| | | private ISignCountService iSignCountService; |
| | | |
| | | @RequestMapping(value = "/getStatusCounts", method = RequestMethod.GET) |
| | | @ApiOperation(value = "获取今日任务统计信息") |
| | | public Result<Object> getStatusCounts() { |
| | | System.err.println("执行存储数据定时任务时间: " + LocalDateTime.now()); |
| | | OrderStatusCount orderStatusCount = new OrderStatusCount(); |
| | | List<OrderStatusCount> StatusCounts = new ArrayList<>(); |
| | | List<OrderStatusCount> temps = iOrderTaskService.countStatus(orderStatusCount); |
| | | for (OrderStatusCount statusCount : temps) { |
| | | if("丰南02车".equals(statusCount.getLine())){ |
| | | StatusCounts.add(statusCount); |
| | | } |
| | | } |
| | | if (StatusCounts != null && StatusCounts.size() != 0) { |
| | | List<SignCount> list = iSignCountService.list(); |
| | | for (OrderStatusCount statusCount : StatusCounts) { |
| | | SignCount signCount = new SignCount(); |
| | | boolean flag = false; |
| | | for (SignCount signCountS : list) { |
| | | if (signCountS.getTaskId().equals(statusCount.getId())) { |
| | | signCount.setId(signCountS.getId()); |
| | | signCount.setCarName(statusCount.getCarName()); |
| | | signCount.setAmount(statusCount.getAmount()); |
| | | signCount.setSignCount(statusCount.getSignCount()); |
| | | signCount.setAbnormalSign(statusCount.getAbnormalSign()); |
| | | signCount.setBatch(statusCount.getBatch()); |
| | | signCount.setLine(statusCount.getLine()); |
| | | signCount.setNotSignCount(statusCount.getNotSignCount()); |
| | | String SendDate=getBeforeOneDayByStringDate(statusCount.getSendDate()); |
| | | signCount.setSendDate(SendDate); |
| | | signCount.setProportion(statusCount.getProportion()); |
| | | signCount.setUserName(statusCount.getUserName()); |
| | | signCount.setTaskId(statusCount.getId()); |
| | | iSignCountService.saveOrUpdate(signCount); |
| | | System.out.println("更新成功"); |
| | | flag = true; |
| | | break; |
| | | } |
| | | } |
| | | if (flag) { |
| | | continue; |
| | | } |
| | | signCount.setCarName(statusCount.getCarName()); |
| | | signCount.setAmount(statusCount.getAmount()); |
| | | signCount.setSignCount(statusCount.getSignCount()); |
| | | signCount.setAbnormalSign(statusCount.getAbnormalSign()); |
| | | signCount.setBatch(statusCount.getBatch()); |
| | | signCount.setLine(statusCount.getLine()); |
| | | signCount.setNotSignCount(statusCount.getNotSignCount()); |
| | | |
| | | String SendDate=getBeforeOneDayByStringDate(statusCount.getSendDate()); |
| | | signCount.setSendDate(SendDate); |
| | | signCount.setProportion(statusCount.getProportion()); |
| | | signCount.setUserName(statusCount.getUserName()); |
| | | signCount.setTaskId(statusCount.getId()); |
| | | if (iSignCountService.saveOrUpdate(signCount)) { |
| | | System.out.println("定时存储成功"); |
| | | } |
| | | } |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | private String getBeforeOneDayByStringDate(String dateString) { |
| | | String times = ""; |
| | | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); |
| | | Date d; |
| | | try { |
| | | d = format.parse(dateString); |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTime(d); |
| | | calendar.add(Calendar.DAY_OF_MONTH, -1); // 在当前日基础上-1 |
| | | String format1 = format.format(calendar.getTime()); |
| | | times = format1; |
| | | //获取String类型的时间 |
| | | |
| | | } catch (ParseException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | return times; |
| | | } |
| | | } |