From fc96e4d7fc20dbec5d2d96c6e8c557c1cc3212d3 Mon Sep 17 00:00:00 2001
From: wjli <591616088@qq.com>
Date: 星期一, 08 四月 2024 18:53:10 +0800
Subject: [PATCH] 修改密码错误登录bug
---
xboot-modules/xboot-your/src/main/java/cn/exrick/xboot/your/controller/OrderTaskController.java | 828 ++++++++++++++++++++++++++++++++++++++++++++++++++++------
1 files changed, 739 insertions(+), 89 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 13ff276..ad1ec24 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,21 +11,28 @@
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;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
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.util.Date;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
+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;
+import java.time.LocalDateTime;
+import java.util.*;
/**
* @author whj
@@ -67,6 +74,22 @@
@Autowired
private IEventLogService iEventLogService;
+ @Autowired
+ private IOrderLogService iOrderLogService;
+
+ @Autowired
+ private IOrderTaskOriginalService iOrderTaskOriginalService;
+
+ @Autowired
+ private IOrderDetailOriginalService iOrderDetailOriginalService;
+
+
+ @Autowired
+ private ICustomerReceiveService iCustomerReceiveService;
+
+ boolean b = false;
+
+
@RequestMapping(value = "/get/{id}", method = RequestMethod.GET)
@ApiOperation(value = "閫氳繃id鑾峰彇")
public Result<OrderTask> get(@PathVariable String id) {
@@ -75,103 +98,377 @@
return new ResultUtil<OrderTask>().setData(orderTask);
}
- public Area getArea(String userId){
- QueryWrapper<Area> wrapper = new QueryWrapper<Area>();
- wrapper.eq("user_id",userId);
- Area area = iAreaService.getOne(wrapper);
- if(area==null){
- QueryWrapper<Car> carQueryWrapper = new QueryWrapper<Car>();
- carQueryWrapper.eq("user_id",userId);
- Car one = iCarService.getOne(carQueryWrapper);
+ @RequestMapping(value = "/getByPage2", method = RequestMethod.GET)
+ @ApiOperation(value = "鍒嗛〉鑾峰彇")
+ public Result<IPage<OrderTask>> getByPage2(PageVo page,String sendDate,String userName,String customerName,Integer status) {
+ QueryWrapper<OrderTask> wrapper = new QueryWrapper<>();
+ if(StrUtil.isNotEmpty(sendDate)){
+ wrapper.eq("order_date",sendDate);
+ }
+ IPage<OrderTask> data = iOrderTaskService.page(PageUtil.initMpPage(page),wrapper);
+ List<OrderTask> records = data.getRecords();
+ for (OrderTask record : records) {
+ if(record.getAreaSectionId() != null){
+ AreaSection byId = iAreaSectionService.getById(record.getAreaSectionId());
+ if(byId != null){
+ record.setAreaSectionName(byId.getName());
+ }
+ }
+ }
+ data.setRecords(records);
+ return new ResultUtil<IPage<OrderTask>>().setData(data);
+ }
- QueryWrapper<Area> wrapper3 = new QueryWrapper<Area>();
- wrapper3.eq("user_id",one.getFollowUserId());
- area = iAreaService.getOne(wrapper3);
+// public Area getArea(String userId){
+// QueryWrapper<Area> wrapper = new QueryWrapper<Area>();
+// wrapper.eq("user_id",userId);
+// Area area = iAreaService.getOne(wrapper);
+// if(area==null){
+// QueryWrapper<Car> carQueryWrapper = new QueryWrapper<Car>();
+// carQueryWrapper.eq("user_id",userId);
+// Car one = iCarService.getOne(carQueryWrapper);
+// if(one==null){
+// return null;
+// }
+// if(StrUtil.isEmpty(one.getFollowUserId())){
+// return null;
+// }
+//
+// QueryWrapper<Area> wrapper3 = new QueryWrapper<Area>();
+// wrapper3.eq("user_id",one.getFollowUserId());
+// area = iAreaService.getOne(wrapper3);
+// return area;
+// }
+// return area;
+// }
+
+
+ private String getFormatDate(String sendTime) {
+ if (StrUtil.isNotEmpty(sendTime)) {
+ return sendTime;
+ } else {
+ return DateUtil.format(new Date(), "yyyy-MM-dd");
+ }
+ }
+
+ private Date getDate(String sendTime){
+ SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
+ if (StrUtil.isNotEmpty(sendTime)) {
+ return new Date();
+ } else {
+ try {
+ return format.parse(sendTime);
+ } catch (ParseException e) {
+ e.printStackTrace();
+ return new Date();
+ }
+ }
+ }
+
+ public Area getArea(String userId) {
+ QueryWrapper<Car> carQueryWrapper = new QueryWrapper<Car>();
+ carQueryWrapper.eq("user_id", userId).or().eq("follow_user_id", userId);
+ Car one = iCarService.getOne(carQueryWrapper);
+ if (one == null) {
+ return null;
+ } else {
+ QueryWrapper<Area> wrapper = new QueryWrapper<Area>();
+ wrapper.eq("car_id", one.getId());
+ Area area = iAreaService.getOne(wrapper);
return area;
}
- return area;
}
+
@RequestMapping(value = "/getByUserId", method = RequestMethod.GET)
@ApiOperation(value = "鑾峰彇浠婃棩浠诲姟缁熻淇℃伅")
- public Result<Object> getAll() {
+ public Result<Object> getAll(String sendTime) {
Area area = getArea(securityUtil.getCurrUser().getId());
- if(area==null){
- return ResultUtil.error("璇疯仈绯荤鐞嗗憳缁戝畾鐗囧尯閰嶉�佸憳");
+ if (area == null) {
+ return ResultUtil.error("璇疯仈绯荤鐞嗗憳缁戝畾璇ヨ溅杈�");
}
QueryWrapper<OrderTask> wrapper2 = new QueryWrapper<OrderTask>();
- String format = DateUtil.format(new Date(), "yyyy-MM-dd");
- wrapper2.eq("area_id",area.getId());
- wrapper2.eq("send_date",format);
+ 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);
+ 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","");
- if(list.size()>0){
+ Map<String, Object> map = new HashMap<String, Object>();
+ map.put("count", list.size());
+ map.put("sum", sum);
+ map.put("name", "");
+ 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());
+ map.put("name", area2.getName() + a.getName());
list.clear();
}
return new ResultUtil<Object>().setData(map);
}
- @RequestMapping(value = "/getTodayOrder", method = RequestMethod.GET)
- @ApiOperation(value = "鑾峰彇浠婃棩浠诲姟璇︽儏")
- public Result<List<OrderTask>> getTodayOrder() {
+ @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("璇疯仈绯荤鐞嗗憳缁戝畾鐗囧尯閰嶉�佸憳");
+ if (area == null) {
+ return ResultUtil.error("璇疯仈绯荤鐞嗗憳缁戝畾璇ヨ溅杈�");
}
QueryWrapper<OrderTask> wrapper2 = new QueryWrapper<OrderTask>();
- String format = DateUtil.format(new Date(), "yyyy-MM-dd");
- wrapper2.eq("a.area_id",area.getId());
- wrapper2.eq("a.send_date",format);
- wrapper2.orderByAsc("a.seq");
- List<OrderTask> list = iOrderTaskService.list2(wrapper2);
+ 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) {
+ 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("seq").orderByAsc("status");
+ List<OrderTask> list = iOrderTaskService.list(wrapper2);
+ for (OrderTask obj : list) {
+ 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,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) {
+ public Result<OrderTask> getTodayOrderDetail(String orderId, String sendTime) {
OrderTask orderTask = new OrderTask();
- if(!StrUtil.isEmpty(orderId)){
+ if (!StrUtil.isEmpty(orderId)) {
orderTask = iOrderTaskService.getById(orderId);
- if(orderTask.getStatus()!=0){
+ if (orderTask.getStatus() != 0) {
return ResultUtil.error("姝ゅ晢鎴峰凡閰嶉��");
}
- }else{
+ } else {
Area area = getArea(securityUtil.getCurrUser().getId());
- if(area==null){
- return ResultUtil.error("璇疯仈绯荤鐞嗗憳缁戝畾鐗囧尯閰嶉�佸憳");
+ if (area == null) {
+ return ResultUtil.error("璇疯仈绯荤鐞嗗憳缁戝畾璇ヨ溅杈�");
}
QueryWrapper<OrderTask> wrapper2 = new QueryWrapper<OrderTask>();
- String format = DateUtil.format(new Date(), "yyyy-MM-dd");
- wrapper2.eq("area_id",area.getId());
- wrapper2.eq("send_date",format);
- wrapper2.eq("status",0);
- wrapper2.orderByAsc("seq");
- List<OrderTask> list = iOrderTaskService.list(wrapper2);
- if(list.size()>0){
+ String format = getFormatDate(sendTime);
+ 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{
+ } 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());
+ 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();
+ 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);
@@ -179,34 +476,34 @@
@RequestMapping(value = "/getTodayOtherInfo", method = RequestMethod.GET)
@ApiOperation(value = "鑾峰彇鍏跺畠淇℃伅")
- public Result<Object> getTodayOtherInfo() {
+ public Result<Object> getTodayOtherInfo(String sendTime) {
Area area = getArea(securityUtil.getCurrUser().getId());
- if(area==null){
- return ResultUtil.error("璇疯仈绯荤鐞嗗憳缁戝畾鐗囧尯閰嶉�佸憳");
+ if (area == null) {
+ return ResultUtil.error("璇疯仈绯荤鐞嗗憳缁戝畾璇ヨ溅杈�");
}
QueryWrapper<OrderTask> wrapper2 = new QueryWrapper<OrderTask>();
- String format = DateUtil.format(new Date(), "yyyy-MM-dd");
- wrapper2.eq("area_id",area.getId());
- wrapper2.eq("send_date",format);
- wrapper2.ne("status",0);
+ String format = getFormatDate(sendTime);
+ wrapper2.eq("area_id", area.getId());
+ wrapper2.eq("send_date", format);
+ wrapper2.ne("status", 0);
wrapper2.orderByAsc("seq");
int count = iOrderTaskService.count(wrapper2);
QueryWrapper<OrderTask> wrapper4 = new QueryWrapper<OrderTask>();
- wrapper4.eq("area_id",area.getId());
- wrapper4.eq("send_date",format);
+ wrapper4.eq("area_id", area.getId());
+ wrapper4.eq("send_date", format);
int count2 = iOrderTaskService.count(wrapper4);
- Map<String,Object> map = new HashMap<>();
- map.put("num",count+"/"+count2);
+ Map<String, Object> map = new HashMap<>();
+ map.put("num", count + "/" + count2);
QueryWrapper<OrderTask> wrapper5 = new QueryWrapper<OrderTask>();
- wrapper5.ne("status",0);
- wrapper5.eq("send_date",format);
+ wrapper5.ne("status", 0);
+ wrapper5.eq("send_date", format);
PageVo page = new PageVo();
page.setSort("updateTime");
@@ -215,35 +512,35 @@
page.setPageNumber(0);
IPage<OrderTask> data = iOrderTaskService.page(PageUtil.initMpPage(page), wrapper5);
String content = "";
- if(data.getRecords().size()>0){
+ if (data.getRecords().size() > 0) {
String userId = data.getRecords().get(0).getUserId();
User user = userService.get(userId);
QueryWrapper<OrderTask> wrapper6 = new QueryWrapper<OrderTask>();
- wrapper6.eq("user_id",userId);
- wrapper6.eq("send_date",format);
- wrapper6.ne("status",0);
+ wrapper6.eq("user_id", userId);
+ wrapper6.eq("send_date", format);
+ wrapper6.ne("status", 0);
int count6 = iOrderTaskService.count(wrapper6);
- if(count6>0){
- content+=user.getNickname()+"宸查厤閫�"+count6+"鍗�";
+ if (count6 > 0) {
+ content += user.getNickname() + "宸查厤閫�" + count6 + "鍗�";
}
}
- map.put("content",content);
+ map.put("content", content);
- map.put("lng","");
- map.put("lat","");
+ map.put("lng", "");
+ map.put("lat", "");
String deptId = securityUtil.getCurrUser().getDepartmentId();
- if(StrUtil.isNotEmpty(deptId)){
+ if (StrUtil.isNotEmpty(deptId)) {
Department department = departmentService.get(deptId);
- map.put("lng",department.getLng());
- map.put("lat",department.getLat());
+ map.put("lng", department.getLng());
+ map.put("lat", department.getLat());
}
return new ResultUtil<Object>().setData(map);
}
@RequestMapping(value = "/addImg", method = RequestMethod.POST)
@ApiOperation(value = "涓婁紶闂ㄥご鐓�")
- public Object saveOrUpdate(String orderId,String imgUrl) {
+ public Object saveOrUpdate(String orderId, String imgUrl) {
OrderTask orderTask = iOrderTaskService.getById(orderId);
orderTask.setImg(imgUrl);
iOrderTaskService.saveOrUpdate(orderTask);
@@ -252,14 +549,14 @@
@RequestMapping(value = "/signFor", method = RequestMethod.POST)
@ApiOperation(value = "绛炬敹")
- public Object signFor(String orderId,int status,String content,String customerReceiveId,int time,String carId) {
- if(status==1){
- if(StrUtil.isEmpty(customerReceiveId)){
+ public Object signFor(String orderId, int status, String content, String customerReceiveId, int time, String carId) {
+ if (status == 1) {
+ if (StrUtil.isEmpty(customerReceiveId)) {
return ResultUtil.error("姝e父绛炬敹锛屾帴璐т汉id蹇呭~");
}
}
- if(StrUtil.isEmpty(carId)){
+ if (StrUtil.isEmpty(carId)) {
return ResultUtil.error("杞﹁締id涓嶈兘涓虹┖");
}
OrderTask orderTask = iOrderTaskService.getById(orderId);
@@ -267,14 +564,14 @@
orderTask.setUserId(securityUtil.getCurrUser().getId());
orderTask.setTime(time);
orderTask.setCarId(carId);
- if(StrUtil.isNotEmpty(customerReceiveId)){
+ if (StrUtil.isNotEmpty(customerReceiveId)) {
orderTask.setCustomerReceiveId(customerReceiveId);
}
- if(!StrUtil.isEmpty(content)){
+ if (!StrUtil.isEmpty(content)) {
orderTask.setRemarks(content);
- }else{
- if(status==2){
+ } else {
+ if (status == 2) {
return ResultUtil.error("璇峰~鍐欏紓甯哥鏀跺師鍥�");
}
}
@@ -286,14 +583,94 @@
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("姝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);
+ OrderLog one = iOrderLogService.getOne(wp);
+ if (one != null) {
+ one.setNum(one.getNum() + 1);
+ } else {
+ one = new OrderLog();
+ one.setNum(1);
+ one.setType(2);
+ }
+ iOrderLogService.saveOrUpdate(one);
+ }
+
+ @RequestMapping(value = "/getTaKan", method = RequestMethod.GET)
+ @ApiOperation(value = "鑾峰彇韪忓嫎鍟嗘埛")
+ public Result<List<Customer>> getTaKan() {
+ Area area = getArea(securityUtil.getCurrUser().getId());
+ if (area == null) {
+ return ResultUtil.error("璇疯仈绯荤鐞嗗憳缁戝畾璇ヨ溅杈�");
+ }
+
+ QueryWrapper<Customer> wrapper2 = new QueryWrapper<Customer>();
+ wrapper2.eq("area_id", area.getId());
+ wrapper2.eq("kstatus", 0);
+ List<Customer> list = iCustomerService.list(wrapper2);
+ return new ResultUtil<List<Customer>>().setData(list);
}
@RequestMapping(value = "/getByPage", method = RequestMethod.GET)
@ApiOperation(value = "鍒嗛〉鑾峰彇")
public Result<IPage<OrderTask>> getByPage(PageVo page) {
- IPage<OrderTask> data = iOrderTaskService.page(PageUtil.initMpPage(page));
+ IPage<OrderTask> data = iOrderTaskService.page2(PageUtil.initMpPage(page));
return new ResultUtil<IPage<OrderTask>>().setData(data);
}
@@ -316,4 +693,277 @@
}
return ResultUtil.success("鎵归噺閫氳繃id鍒犻櫎鏁版嵁鎴愬姛");
}
+
+ @RequestMapping(value = "/insertOrders", method = RequestMethod.GET)
+ @ApiOperation(value = "瑙f瀽璁㈠崟")
+ public Result<Object> insertOrders(String sendTime) {
+ if(b){
+ return ResultUtil.error("姝e湪澶勭悊");
+ }
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+ Date parse = null;
+ try {
+ parse = sdf.parse(sendTime);
+ } catch (ParseException e) {
+ e.printStackTrace();
+ }
+ String formatDate = getFormatDate(sendTime);
+ QueryWrapper<OrderTask> wrapper2 = new QueryWrapper<OrderTask>();
+ wrapper2.eq("order_date", formatDate);
+ List<OrderTask> list = iOrderTaskService.list(wrapper2);
+ if(list.size() > 0){
+ return ResultUtil.error("宸插瓨鍦ㄤ粖鏃ユ暟鎹�");
+ }else {
+ QueryWrapper<OrderTaskOriginal> queryWrapper = new QueryWrapper<>();
+ queryWrapper.between("order_date",DateUtil.beginOfDay(parse),DateUtil.endOfDay(parse));
+ List<OrderTaskOriginal> originals = iOrderTaskOriginalService.list(queryWrapper);
+ if(originals.size()>0){
+ b=true;
+ }
+ int sumNum = 0;
+ for(OrderTaskOriginal original:originals){
+ try {
+ OrderTask orderTask = new OrderTask();
+ orderTask.setCode(original.getCode());
+ Area area = getArea2(original.getAreaName());
+ orderTask.setAreaId(area.getId());
+ orderTask.setCarId(area.getCarId());
+ orderTask.setAreaSectionId(getAreaSection(orderTask.getAreaId(),original.getAreaSection()));
+ Customer customer = getCustomer(original.getCustomerCode(), original.getCustomerName(), original.getCustomerPhone(), original.getLinker(), orderTask.getAreaId(), orderTask.getAreaSectionId());
+ orderTask.setCustomerId(customer.getId());
+ orderTask.setCustomerName(customer.getName());
+ orderTask.setLinker(customer.getLinker());
+ orderTask.setEndDate(original.getPacketDate());
+ //orderTask.setSendDate(original.getSendDate());
+ orderTask.setSendDate(DateUtil.offsetDay(original.getOrderDate(),1));
+ orderTask.setOrderDate(original.getOrderDate());
+ if(original.getSeq()!=null){
+ orderTask.setSeq(original.getSeq());
+ }else{
+ orderTask.setSeq(999);
+ }
+
+ orderTask.setNum(original.getNum());
+ sumNum+=original.getNum();
+
+ iOrderTaskService.saveOrUpdate(orderTask);
+
+ updateCustomerRecive(orderTask.getCustomerId(),original.getLinker(),original.getCustomerPhone());
+
+ QueryWrapper<OrderDetailOriginal> wrapper = new QueryWrapper<>();
+ wrapper.eq("order_id",original.getId());
+ List<OrderDetailOriginal> list1 = iOrderDetailOriginalService.list(wrapper);
+
+ List<OrderDetail> detailList = new ArrayList<>();
+ for(OrderDetailOriginal o:list1){
+ OrderDetail orderDetail = new OrderDetail();
+ orderDetail.setNum(o.getNum());
+ orderDetail.setOrderId(orderTask.getId());
+ orderDetail.setProduct(o.getProductName());
+ detailList.add(orderDetail);
+ }
+ iOrderDetailService.saveBatch(detailList);
+ }catch (Exception e){
+ System.out.println(original.getId()+"鎶ラ敊浜�");
+ }
+ }
+
+ OrderLog orderLog = new OrderLog();
+ orderLog.setNum(sumNum);
+ orderLog.setType(0);
+ iOrderLogService.save(orderLog);
+ System.out.println("澶勭悊璁㈠崟缁撴潫");
+ b=false;
+
+
+ return ResultUtil.success("瀵煎叆鎴愬姛");
+ }
+
+
+ }
+ public void updateCustomerRecive(String customerId,String linker,String phone){
+ QueryWrapper<CustomerReceive> wrapper = new QueryWrapper<>();
+ wrapper.eq("customer_id",customerId);
+ wrapper.eq("name",linker);
+ List<CustomerReceive> list = iCustomerReceiveService.list(wrapper);
+ if(list.size()==0){
+ CustomerReceive one = new CustomerReceive();
+ one.setCustomerId(customerId);
+ one.setFstatus(0);
+ one.setStatus(1);
+ one.setName(linker);
+ one.setPhone(phone);
+ iCustomerReceiveService.saveOrUpdate(one);
+ }
+ }
+
+ public Customer getCustomer(String customerCode,String customerName,String customerPhone,String linker,String areaId,String areaSectionId){
+ QueryWrapper<Customer> queryWrapper = new QueryWrapper<>();
+ queryWrapper.eq("licence",customerCode);
+ Customer one = iCustomerService.getOne(queryWrapper);
+ if(one==null){
+ Customer customer = new Customer();
+ customer.setLicence(customerCode);
+ customer.setName(customerName);
+ customer.setPhone(customerPhone);
+ customer.setLinker(linker);
+ customer.setAreaId(areaId);
+ customer.setAreaSectionId(areaSectionId);
+ customer.setKstatus(1);
+ iCustomerService.saveOrUpdate(customer);
+ return customer;
+ }
+ one.setAreaId(areaId);
+ one.setAreaSectionId(areaSectionId);
+ iCustomerService.saveOrUpdate(one);
+ return one;
+ }
+
+ public Area getArea2(String name){
+ QueryWrapper<Area> queryWrapper = new QueryWrapper<>();
+ queryWrapper.eq("name",name);
+ Area one = iAreaService.getOne(queryWrapper);
+ if(one==null){
+ Area area = new Area();
+ area.setName(name);
+ iAreaService.saveOrUpdate(area);
+ return area;
+ }
+ return one;
+ }
+
+ public String getAreaSection(String areaId,String name){
+ QueryWrapper<AreaSection> queryWrapper = new QueryWrapper<>();
+ queryWrapper.eq("name",name);
+ queryWrapper.eq("area_id",areaId);
+ AreaSection one = iAreaSectionService.getOne(queryWrapper);
+ if(one==null){
+ AreaSection area = new AreaSection();
+ area.setName(name);
+ area.setAreaId(areaId);
+ iAreaSectionService.saveOrUpdate(area);
+ return area.getId();
+ }
+ return one.getId();
+ }
+
+
+ public String dateStringFormat(Date strDate) {
+ if (strDate == null)
+ return "";
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+ return sdf.format(strDate)+" 00:00:00";
+ }
+
+
+ public String dateStringFormat2(Date strDate) {
+ if (strDate == null)
+ return "";
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+ return sdf.format(strDate)+" 23:59:59";
+ }
+
+ @GetMapping("/outExcel")// 瀵煎嚭鐨勪笉鏄腑闂磋〃
+ @ApiOperation(value = "瀵煎嚭绛炬敹缁熻淇℃伅琛�", notes = "瀵煎嚭绛炬敹缁熻淇℃伅琛�")
+ public void export1(OrderStatusCount orderStatusCount, HttpServletResponse response) throws IOException {
+ List<OrderStatusCount> orderStatus = this.iOrderTaskService.countStatus(orderStatusCount);
+ response.setContentType("application/vnd.ms-excel");
+ response.setCharacterEncoding("utf-8");
+ String fileName = URLEncoder.encode("绛炬敹鏁伴噺缁熻鎶ヨ〃", "UTF-8");
+ String fileName2 = new String(fileName.getBytes("UTF-8"), "ISO8859-1");
+// response.setHeader("Content-dispostion", "attachment;filename="+fileName+".xls");
+ response.setHeader("Content-disposition", "attachment;filename=" + fileName2 + ".xlsx");
+ EasyExcel.write(response.getOutputStream(), OrderStatusCount.class).
+ sheet(0).doWrite(orderStatus);
+ }
+
+ @GetMapping(value = "/count")
+ public Result<List<OrderStatusCount>> getAll(OrderStatusCount orderStatusCount) {
+ List<OrderStatusCount> data = this.iOrderTaskService.countStatus(orderStatusCount);
+ ;
+ 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;
+ }
}
--
Gitblit v1.9.1