From 6c764f473b1e0e9dd2fb13034fe0d7295ab3724e Mon Sep 17 00:00:00 2001 From: xuefei <564615061@qq.cm> Date: 星期二, 08 八月 2023 11:05:58 +0800 Subject: [PATCH] 允许跨域 --- xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/controller/OrderTaskController.java | 222 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 222 insertions(+), 0 deletions(-) diff --git a/xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/controller/OrderTaskController.java b/xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/controller/OrderTaskController.java index 6c3eec3..0fb4216 100644 --- a/xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/controller/OrderTaskController.java +++ b/xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/controller/OrderTaskController.java @@ -11,6 +11,7 @@ import cn.exrick.xboot.core.service.UserService; import cn.exrick.xboot.your.entity.*; import cn.exrick.xboot.your.service.*; +import cn.exrick.xboot.your.vo.OrderListVo; import cn.hutool.core.date.DateUtil; import cn.hutool.core.util.StrUtil; import com.alibaba.excel.EasyExcel; @@ -19,12 +20,14 @@ 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 javax.servlet.http.HttpServletResponse; import java.io.IOException; +import java.math.BigDecimal; import java.net.URLEncoder; import java.text.ParseException; import java.text.SimpleDateFormat; @@ -206,6 +209,49 @@ 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) { + 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) @ApiOperation(value = "鑾峰彇浠婃棩閰嶉�佷换鍔¤鎯呭垪琛�") public Result<List<OrderTask>> getTodayOrder(String sendTime) { @@ -230,6 +276,86 @@ return new ResultUtil<List<OrderTask>>().setData(list); } + @RequestMapping(value = "/getTodayOrderByHulue", method = RequestMethod.GET) + @ApiOperation(value = "鑾峰彇浠婃棩閰嶉�佷换鍔¤鎯呭垪琛�,蹇界暐鏌愯鍗�,瀹㈡埛绔笓鐢ㄦ帴鍙�") + public Result<OrderListVo> getTodayOrderFromHulue(String orderId, String sendTime,String areaSectionId) { + //蹇界暐璁㈠崟 + if (!StrUtil.isEmpty(orderId)) { + OrderTask orderTask = iOrderTaskService.getById(orderId); + int seq = orderTask.getSeq(); + orderTask.setSeq(1000+seq); + iOrderTaskService.saveOrUpdate(orderTask); + } + //鑾峰彇璁㈠崟鍒楄〃 + 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); + 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) { + obj.setCode(obj.getLinker()); + if(obj.getStatus()==1){ + num++; + } + } + String percent = getPercent(num,list.size()); + OrderListVo vo = new OrderListVo(); + vo.setOrderTasks(list); + vo.setPercent(percent); + return new ResultUtil<OrderListVo>().setData(vo); + } + + public String getPercent(int num,int totalNum){ + if(totalNum>0){ + BigDecimal number = new BigDecimal(0); + number=BigDecimal.valueOf((int)num); + BigDecimal total = new BigDecimal(0); + total=BigDecimal.valueOf((int)totalNum); + BigDecimal divide = number.divide(total,2,BigDecimal.ROUND_HALF_UP); + double bfb = divide.doubleValue(); + int bfbInt = (int)(bfb*100); + return bfbInt+ "%"; + }else{ + return 0+ "%"; + } + } + + @RequestMapping(value = "/getOneMonthOrderPercent", method = RequestMethod.GET) + @ApiOperation(value = "鑾峰彇鏈湀閰嶉�佺櫨鍒嗘瘮") + public Result<String> getMonthPercent(){ + Area area = getArea(securityUtil.getCurrUser().getId()); + if (area == null) { + return ResultUtil.error("璇疯仈绯荤鐞嗗憳缁戝畾璇ヨ溅杈�"); + } + + String todayFormat = DateUtil.format(new Date(), "yyyy-MM-dd"); + String monthFormat = DateUtil.format(DateUtil.beginOfMonth(new Date()),"yyyy-MM-dd"); + + QueryWrapper<OrderTask> wrapper2 = new QueryWrapper<OrderTask>(); + wrapper2.eq("area_id", area.getId()); + wrapper2.between("send_date",monthFormat,todayFormat); + int allOrders = iOrderTaskService.count(wrapper2); + + wrapper2.eq("status",1); + int doOrders = iOrderTaskService.count(wrapper2); + + return new ResultUtil<String>().setData(getPercent(doOrders,allOrders)); + } + @RequestMapping(value = "/getTodayOrderDetail", method = RequestMethod.GET) @ApiOperation(value = "鑾峰彇褰撳墠閰嶉�佸晢鎴疯鎯�") public Result<OrderTask> getTodayOrderDetail(String orderId, String sendTime) { @@ -250,6 +376,53 @@ 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(); @@ -388,6 +561,55 @@ 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("姝e父绛炬敹锛屾帴璐т汉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)) { + 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("娣诲姞鎴愬姛"); + } + private void saveLog() { QueryWrapper<OrderLog> wp = new QueryWrapper<>(); wp.eq("type", 2); -- Gitblit v1.9.1