Enford пре 5 година
родитељ
комит
3a62077ab1

+ 106 - 0
src/main/java/com/jeeplus/modules/wexintheorder/Utils/OrderUtils.java

@@ -0,0 +1,106 @@
+package com.jeeplus.modules.wexintheorder.Utils;
+
+import com.jeeplus.modules.wexinpackage.access.util.access.AccessTokenUtil;
+import com.jeeplus.modules.wexinpackage.access.util.access.RequestAccess;
+import com.jeeplus.modules.wexinpackage.access.util.access.WeChatParamsUtil;
+import net.sf.json.JSONObject;
+import org.junit.Test;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.client.RestTemplate;
+
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.Calendar;
+import java.util.Date;
+
+public class OrderUtils {
+
+
+    //返回工作日 返回工作日(0)、休息日(1)和节假日(2) 3-错误
+    public static Integer getHolidayGet(){
+        Date date = new Date();
+        DateFormat dateFormat = new SimpleDateFormat("yyyyMMdd");
+        dateFormat.format(date);
+        String addOrMinusDayString = "";
+        Integer status = 0;
+        for (int i = 1; i < 10; i++) {
+            addOrMinusDayString = getAddOrMinusDayString(i, dateFormat);
+            String url = "https://tool.bitefu.net/jiari/?d=" + addOrMinusDayString;
+            RestTemplate restTemplate = new RestTemplate();
+            ResponseEntity<Integer> res = restTemplate.getForEntity(url, Integer.class);
+            try {
+                Thread.sleep(500);
+                if (res.getBody() != null) {
+                    if (res.getBody() == 0) {
+                        status = i;
+                        break;
+                    }
+                } else {
+                    status = 1314;
+                    break;
+                }
+            } catch (InterruptedException e) {
+                e.printStackTrace();
+            }
+        }
+        return status;
+    }
+
+
+    //返回工作日 返回工作日(0)、休息日(1)和节假日(2) 3-错误
+    public static Integer getHolidayGetMinus(){
+        Date date = new Date();
+        DateFormat dateFormat = new SimpleDateFormat("yyyyMMdd");
+        dateFormat.format(date);
+        String addOrMinusDayString = "";
+        Integer status = 0;
+        for (int i = 0; i > -10; i--) {
+            addOrMinusDayString = getAddOrMinusDayString(i, dateFormat);
+            String url = "https://tool.bitefu.net/jiari/?d=" + addOrMinusDayString;
+            RestTemplate restTemplate = new RestTemplate();
+            ResponseEntity<Integer> res = restTemplate.getForEntity(url, Integer.class);
+            try {
+                Thread.sleep(500);
+                if (res.getBody() != null) {
+                    if (res.getBody() == 0) {
+                        status = i;
+                        break;
+                    }
+                } else {
+                    status = 1314;
+                    break;
+                }
+            } catch (InterruptedException e) {
+                e.printStackTrace();
+            }
+        }
+        return status;
+    }
+
+    //获取明后天时间
+    public static String getAddOrMinusDayString(Integer date,DateFormat dateFormat){
+        Date d = new Date();
+        Calendar calendar=Calendar.getInstance();
+        calendar.setTime(d);
+        calendar.add(calendar.DATE,date);
+        return dateFormat.format(calendar.getTime());
+    }
+
+    //查询userId
+    public static String findUserId(String code){
+        String url = "https://qyapi.weixin.qq.com/cgi-bin/user/getuserinfo?access_token=ACCESS_TOKEN&code=CODE";//获取用户信息
+        String accessToken = AccessTokenUtil.getAccessTokenTotal(WeChatParamsUtil.corpId, WeChatParamsUtil.agentSecret);
+        String string = "";
+        if (accessToken != null) {
+            String sureUrl = url.replace("ACCESS_TOKEN", accessToken).replace("CODE",code);
+            JSONObject jsonObject = RequestAccess.httpRequest(sureUrl, "POST", null);
+            string = jsonObject.getString("UserId");
+            if (null != jsonObject) {
+                if (0 != jsonObject.getInt("errcode")) {
+                    System.out.println("成功");
+                }
+            }
+        }
+        return string;
+    }
+}

+ 6 - 0
src/main/java/com/jeeplus/modules/wexintheorder/dao/TheLeadershipDao.java

@@ -16,4 +16,10 @@ public interface TheLeadershipDao extends CrudDao<TheLeadership> {
 
     //根据userid查找分管领导
     List<TheLeadership> findListUserId(TheLeadership theLeadership);
+
+    //获取部门name
+    String findOffice(String id);
+
+    //修改分管领导
+    Integer updateLeaderShip(TheLeadership theLeadership);
 }

+ 5 - 1
src/main/java/com/jeeplus/modules/wexintheorder/dao/TheOrderDao.java

@@ -5,12 +5,16 @@ import com.jeeplus.common.persistence.annotation.MyBatisDao;
 import com.jeeplus.modules.sys.entity.User;
 import com.jeeplus.modules.wexintheorder.entity.TheOrder;
 
+import java.util.List;
+
 @MyBatisDao
 public interface TheOrderDao extends CrudDao<TheOrder> {
     public Integer insertOrder(TheOrder theOrder);
 
     public Integer updateOrder(TheOrder theOrder);
 
+    public List<TheOrder> findListPlan(TheOrder theOrder);
+
+    public List<TheOrder> findListSure(TheOrder theOrder);
 
-    public User findUser(String wechatId);
 }

+ 37 - 10
src/main/java/com/jeeplus/modules/wexintheorder/entity/TheLeadership.java

@@ -3,22 +3,49 @@ package com.jeeplus.modules.wexintheorder.entity;
 import com.jeeplus.common.persistence.DataEntity;
 
 public class TheLeadership extends DataEntity<TheLeadership> {
-    private String userId;
-    private String leadership;
+   private String team;
+   private String department;
+   private String specific;
+   private String financial;
+   private String correlationId;
 
-    public String getUserId() {
-        return userId;
+    public String getSpecific() {
+        return specific;
     }
 
-    public void setUserId(String userId) {
-        this.userId = userId;
+    public void setSpecific(String specific) {
+        this.specific = specific;
     }
 
-    public String getLeadership() {
-        return leadership;
+    public String getTeam() {
+        return team;
     }
 
-    public void setLeadership(String leadership) {
-        this.leadership = leadership;
+    public void setTeam(String team) {
+        this.team = team;
+    }
+
+    public String getDepartment() {
+        return department;
+    }
+
+    public void setDepartment(String department) {
+        this.department = department;
+    }
+
+    public String getFinancial() {
+        return financial;
+    }
+
+    public void setFinancial(String financial) {
+        this.financial = financial;
+    }
+
+    public String getCorrelationId() {
+        return correlationId;
+    }
+
+    public void setCorrelationId(String correlationId) {
+        this.correlationId = correlationId;
     }
 }

+ 49 - 18
src/main/java/com/jeeplus/modules/wexintheorder/entity/TheOrder.java

@@ -1,19 +1,66 @@
 package com.jeeplus.modules.wexintheorder.entity;
 
+import com.fasterxml.jackson.annotation.JsonFormat;
 import com.jeeplus.common.persistence.DataEntity;
 
 import javax.xml.crypto.Data;
 import java.util.Date;
 
 public class TheOrder extends DataEntity<TheOrder> {
+
     private String name;//姓名
     private String department;//部门
-    private String leadership;//分管领导
-    private Date confirmOrder;//确定订餐
+    private String team;//团队
+    private String specific;//具体部门
     private Date scheduled;//预定餐
     private String correlationId;//关联id
 
+    private String departStatus;//部门状态
     private String status;//有无回显 1-回显 2-本来就有
+    private String dateStart;//开始时间
+    private String dateEnd;//结束时间
+
+    public String getDepartStatus() {
+        return departStatus;
+    }
+
+    public void setDepartStatus(String departStatus) {
+        this.departStatus = departStatus;
+    }
+
+    public String getTeam() {
+        return team;
+    }
+
+    public void setTeam(String team) {
+        this.team = team;
+    }
+
+    public String getSpecific() {
+        return specific;
+    }
+
+    public void setSpecific(String specific) {
+        this.specific = specific;
+    }
+
+    public String getDateStart() {
+        return dateStart;
+    }
+
+    public void setDateStart(String dateStart) {
+        this.dateStart = dateStart;
+    }
+
+    public String getDateEnd() {
+        return dateEnd;
+    }
+
+    public void setDateEnd(String dateEnd) {
+        this.dateEnd = dateEnd;
+    }
+
+
 
     public String getStatus() {
         return status;
@@ -39,22 +86,6 @@ public class TheOrder extends DataEntity<TheOrder> {
         this.department = department;
     }
 
-    public String getLeadership() {
-        return leadership;
-    }
-
-    public void setLeadership(String leadership) {
-        this.leadership = leadership;
-    }
-
-    public Date getConfirmOrder() {
-        return confirmOrder;
-    }
-
-    public void setConfirmOrder(Date confirmOrder) {
-        this.confirmOrder = confirmOrder;
-    }
-
     public Date getScheduled() {
         return scheduled;
     }

+ 67 - 0
src/main/java/com/jeeplus/modules/wexintheorder/entity/TheOrderToUser.java

@@ -0,0 +1,67 @@
+package com.jeeplus.modules.wexintheorder.entity;
+
+public class TheOrderToUser {
+    private String ToUserName;//企业微信CorpID
+    private String FromUserName;//成员UserID
+    private String CreateTime;//消息创建时间(整型)
+    private String MsgType;//消息类型,此时固定为:event
+    private String Event;//事件类型,subscribe(关注)、unsubscribe(取消关注)
+    private String EventKey;//事件KEY值,此事件该值为空
+    private String AgentID;//企业应用的id,整型。可在应用的设置页面查看
+
+    public String getToUserName() {
+        return ToUserName;
+    }
+
+    public void setToUserName(String toUserName) {
+        ToUserName = toUserName;
+    }
+
+    public String getFromUserName() {
+        return FromUserName;
+    }
+
+    public void setFromUserName(String fromUserName) {
+        FromUserName = fromUserName;
+    }
+
+    public String getCreateTime() {
+        return CreateTime;
+    }
+
+    public void setCreateTime(String createTime) {
+        CreateTime = createTime;
+    }
+
+    public String getMsgType() {
+        return MsgType;
+    }
+
+    public void setMsgType(String msgType) {
+        MsgType = msgType;
+    }
+
+    public String getEvent() {
+        return Event;
+    }
+
+    public void setEvent(String event) {
+        Event = event;
+    }
+
+    public String getEventKey() {
+        return EventKey;
+    }
+
+    public void setEventKey(String eventKey) {
+        EventKey = eventKey;
+    }
+
+    public String getAgentID() {
+        return AgentID;
+    }
+
+    public void setAgentID(String agentID) {
+        AgentID = agentID;
+    }
+}

+ 9 - 0
src/main/java/com/jeeplus/modules/wexintheorder/service/TheLeadershipService.java

@@ -26,6 +26,11 @@ public class TheLeadershipService extends CrudService<TheLeadershipDao, TheLeade
         theLeadership.preInsert();
         theLeadershipDao.insertLeaderShip(theLeadership);
     }
+    @Transactional
+    public void updateLeaderShip(TheLeadership theLeadership){
+        theLeadership.preUpdate();
+        theLeadershipDao.updateLeaderShip(theLeadership);
+    }
     /*
        User
     */
@@ -33,4 +38,8 @@ public class TheLeadershipService extends CrudService<TheLeadershipDao, TheLeade
     public User findUser(String weChatId){
         return theLeadershipDao.findUser(weChatId);
     }
+    //获取部门name
+    public String findOffice(String id){
+        return theLeadershipDao.findOffice(id);
+    }
 }

+ 26 - 1
src/main/java/com/jeeplus/modules/wexintheorder/service/TheOrderService.java

@@ -1,13 +1,27 @@
 package com.jeeplus.modules.wexintheorder.service;
 
 import com.jeeplus.common.service.CrudService;
-import com.jeeplus.modules.sys.entity.User;
+import com.jeeplus.modules.wexinpackage.access.util.access.ContactUtil;
 import com.jeeplus.modules.wexintheorder.dao.TheOrderDao;
 import com.jeeplus.modules.wexintheorder.entity.TheOrder;
+import com.jeeplus.modules.wexintheorder.entity.TheOrderToUser;
+import org.apache.shiro.SecurityUtils;
+import org.apache.shiro.authc.IncorrectCredentialsException;
+import org.apache.shiro.authc.UnknownAccountException;
+import org.apache.shiro.authc.UsernamePasswordToken;
+import org.dom4j.Document;
+import org.dom4j.DocumentException;
+import org.dom4j.DocumentHelper;
+import org.dom4j.Element;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
+import javax.servlet.http.HttpServletRequest;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
 @Service
 public class TheOrderService extends CrudService<TheOrderDao,TheOrder>{
     @Autowired
@@ -16,14 +30,25 @@ public class TheOrderService extends CrudService<TheOrderDao,TheOrder>{
     //增加操作
     @Transactional
     public void insertOrder(TheOrder theOrder){
+        theOrder.preInsert();
         theOrderDao.insertOrder(theOrder);
     };
 
     //修改操作
     @Transactional
     public void updateOrder(TheOrder theOrder){
+        theOrder.preUpdate();
         theOrderDao.updateOrder(theOrder);
     }
 
+    public List<TheOrder> findListPlan(TheOrder theOrder){
+        return theOrderDao.findListPlan(theOrder);
+    };
+
+    public List<TheOrder> findListSure(TheOrder theOrder){
+        return theOrderDao.findListSure(theOrder);
+    };
+
+
 
 }

+ 78 - 0
src/main/java/com/jeeplus/modules/wexintheorder/web/SimpleOAuth2Controller.java

@@ -0,0 +1,78 @@
+package com.jeeplus.modules.wexintheorder.web;
+
+import com.jeeplus.modules.wexinpackage.access.entity.AccessToken;
+import com.jeeplus.modules.wexinpackage.access.util.access.WeChatParamsUtil;
+import org.springframework.stereotype.Controller;
+
+import org.slf4j.Logger;
+
+import org.slf4j.LoggerFactory;
+import org.springframework.web.bind.annotation.RequestMapping;
+
+import javax.servlet.http.HttpServletRequest;
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+
+@Controller
+public class SimpleOAuth2Controller {
+    private Logger logger = LoggerFactory.getLogger(SimpleOAuth2Controller.class);
+    /**
+     * 拼接网页授权链接
+     * 此处步骤也可以用页面链接代替
+     * @return
+     */
+    @RequestMapping(value = { "/oauth2wx.do" })
+    public String Oauth2API(HttpServletRequest request){
+        //获取项目域名
+        String requestUrl = request.getServerName();
+        String contextPath = request.getContextPath();
+        logger.info("domain name: " + requestUrl + " project name: " + contextPath);
+        //拼接微信回调地址
+        String backUrl ="http://total2.viphk.ngrok.org/weXin/theOrder/orderFrom";
+        String redirect_uri = "";
+        try {
+            redirect_uri = URLEncoder.encode(backUrl, "utf-8");
+        } catch (UnsupportedEncodingException e) {
+            e.printStackTrace();
+            logger.error("ecdoe error: " + e.getMessage());
+        }
+        String oauth2Url = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=" + WeChatParamsUtil.corpId + "&redirect_uri=" + redirect_uri
+                + "&response_type=code&scope=snsapi_base&state=STATE#wechat_redirect";
+        return "redirect:" + oauth2Url;
+    }
+//    /**
+//
+//     * 授权回调请求处理
+//
+//     * @return
+//
+//     */
+//
+//    @RequestMapping(value = { "/oauth2me.do" })
+//    public String oAuth2Url(HttpServletRequest request, @RequestParam String code){
+//
+//        // 调用获取access_token的接口
+//
+//        AccessToken accessToken = WeiXinQiYeUtil.access_token();
+//        HttpSession session = request.getSession();
+//        if (accessToken != null && accessToken.getAccess_token() != null) {
+//
+//            // 调用获取用户信息的接口
+//
+//            String UserId = getMemberGuidByCode(accessToken.getAccess_token(), code, WeiXinQiYeConstants.AGENTID);
+//
+//            logger.info("UserId: " + UserId);
+//
+//            if (UserId != null) {
+//
+//                session.setAttribute("UserId", UserId);
+//
+//                logger.info("UserId放入session成功!");
+//
+//            }
+//
+//        }
+//        // 这里简单处理,存储到session中
+//        return "user/result";
+//    }
+}

+ 98 - 115
src/main/java/com/jeeplus/modules/wexintheorder/web/TheOrderController.java

@@ -1,12 +1,9 @@
 package com.jeeplus.modules.wexintheorder.web;
 
 import com.jeeplus.common.json.AjaxJson;
-import com.jeeplus.common.utils.StringUtils;
 import com.jeeplus.common.web.BaseController;
 import com.jeeplus.modules.sys.entity.User;
-import com.jeeplus.modules.wexinpackage.access.util.access.WeChatParamsUtil;
-import com.jeeplus.modules.wexinpackage.access.util.encryption.WXBizMsgCrypt;
-import com.jeeplus.modules.wexintheorder.dao.TheLeadershipDao;
+import com.jeeplus.modules.wexintheorder.Utils.OrderUtils;
 import com.jeeplus.modules.wexintheorder.entity.TheLeadership;
 import com.jeeplus.modules.wexintheorder.entity.TheOrder;
 import com.jeeplus.modules.wexintheorder.service.TheLeadershipService;
@@ -15,16 +12,16 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
 import org.springframework.ui.Model;
 import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
 
 import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-import java.io.BufferedReader;
-import java.io.PrintWriter;
-import java.util.Date;
-import java.util.List;
+import java.text.DateFormat;
+import java.text.SimpleDateFormat;
+import java.util.*;
 
 @Controller
-@RequestMapping(value = "${adminPath}/weXin/theOrder")
+@RequestMapping(value = "/weXin/theOrder")
 public class TheOrderController extends BaseController {
     @Autowired
     private TheOrderService theOrderService;
@@ -32,109 +29,73 @@ public class TheOrderController extends BaseController {
     @Autowired
     private TheLeadershipService theLeadershipService;
 
+
     //页面显示
     @RequestMapping(value = "orderFrom")
-    public String getOrderFrom(Model model, HttpServletRequest request){
-        return "modules/weixin/theorder/home";//返回一个界面
-    }
-
-    @RequestMapping(value = "callBack")
-    public void getCallBack(HttpServletRequest request, HttpServletResponse response) throws Exception{
-        String method = request.getMethod();
-        if ("GET".equals(method)){
-            doGet(request,response);
-        }else {
-            doPost(request,response);
-        }
-    }
-    private void doGet(HttpServletRequest request, HttpServletResponse response){
-        String token = "AL8aMOYlujP28AE8WDHrxQqW9D5bfxBa";
-        String aceKey = "yIpls2iEHKcp7Pftlp8MrieuJ6HJAb9yeKLqZGLmeHL";
-        // 微信加密签名
-        String msg_signature = request.getParameter("msg_signature");
-        // 时间戳
-        String timestamp = request.getParameter("timestamp");
-        // 随机数
-        String nonce = request.getParameter("nonce");
-        // 随机字符串
-        String echoStr = request.getParameter("echostr");
-        //回调key值
-        String sEchoStr = null;
-        WXBizMsgCrypt wxcpt;
-        try {
-            PrintWriter writer = response.getWriter();
-            wxcpt = new WXBizMsgCrypt(token,aceKey,WeChatParamsUtil.corpId);
-            sEchoStr = wxcpt.VerifyURL(msg_signature, timestamp, nonce, echoStr);
-            if (StringUtils.isBlank(sEchoStr)){
-                logger.error("url验证失败");
-            }
-            writer.write(sEchoStr);
-            writer.close();
-        }catch (Exception e){
-            logger.error("企业微信回调验证错误",e);
-        }
-    }
-    private  void  doPost(HttpServletRequest request, HttpServletResponse response) throws Exception{
-        String sReqMsgSig = request.getParameter("msg_signature");
-        String sReqTimeStamp = request.getParameter("timestamp");
-        String sReqNonce = request.getParameter("nonce");
-//        try {
-        BufferedReader reader = request.getReader();
-        char[] buf = new char[512];
-        int len = 0;
-        StringBuffer stringBuffer = new StringBuffer();
-        while ((len = (int) reader.read(buf))!= -1){
-            stringBuffer =  stringBuffer.append(buf, 0, len);
-        }
-        String content = stringBuffer.toString();
-        if (content == null){
-            content = "";
-        }
-        WXBizMsgCrypt wxcpt = new WXBizMsgCrypt(WeChatParamsUtil.contacts_token,WeChatParamsUtil.encodingAESKey,WeChatParamsUtil.corpId);
-        String sMsg = wxcpt.DecryptMsg(sReqMsgSig, sReqTimeStamp, sReqNonce, content);
-//        weChatCallbackService.getMapOperation(sMsg,request);
-        // 循环所有子元素
-//        } catch (Exception e) {
-//            // TODO
-//            // 解密失败,失败原因请查看异常
-//            e.printStackTrace();
-//        }
+    public String getOrderFrom(Model model, HttpServletRequest request,@RequestParam String code){
+        String userId = OrderUtils.findUserId(code);//获取useerid
+        String weChatUserId = "00000011";
+        TheOrder userOrderEcho = getUserOrderEcho(weChatUserId);
+        model.addAttribute("theOrder",userOrderEcho);
+        return "modules/weixin/theorder/orderMeal";//返回一个界面
     }
 
     //获取部门以及分管领导信息--回显FROM
     public TheOrder getUserOrderEcho(String weChatUserId){
         TheOrder theOrder = new TheOrder();
-        weChatUserId = "00000011";
-        //获取用户user
         User user = theLeadershipService.findUser(weChatUserId);
-        //获取用户id
-        String userId = user.getId();
+        String userId = user.getId();//获取用户id
+        //获取用户user
         //添加回显对象
         theOrder.setName(user.getName());//姓名
         theOrder.setCorrelationId(userId);
-        theOrder.setDepartment(user.getOffice().getName());//部门
         TheLeadership theLeadership = new TheLeadership();
-        theLeadership.setUserId(userId);
+        theLeadership.setCorrelationId(userId);
         List<TheLeadership> listUserId = theLeadershipService.findListUserId(theLeadership);
         if (listUserId.size()>0){
-            theLeadership = listUserId.get(1);//获取分管领导信息
-            theOrder.setLeadership(theLeadership.getLeadership());//添加分管领导
+            theLeadership.setTeam(listUserId.get(0).getTeam());
+            if (listUserId.get(0).getTeam().equals("潘中")){
+                theOrder.setDepartment("1");
+            }
+            theOrder.setDepartment("2");//全显示
+            theLeadership.setSpecific(listUserId.get(0).getSpecific());
+            theLeadership.setDepartment(listUserId.get(0).getDepartment());
             theOrder.setStatus("0"); //是回显
         }else {
-            theOrder.setLeadership("");//无分管领导
+            theLeadership.setTeam("");
+            theLeadership.setSpecific("");
+            theLeadership.setDepartment("");
             theOrder.setStatus("1"); //不是回显
+            theOrder.setDepartStatus("1");//显示一级
         }
         return theOrder;
     }
 
     //获取--预定餐
-    public AjaxJson getReservation(String status,TheOrder theOrder){
+    @ResponseBody
+    @RequestMapping(value = "noSureTem")
+    public AjaxJson getReservation(TheOrder theOrder){
+        DateFormat dateFormat1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
+        Date date = new Date();//当前时间
         AjaxJson ajaxJson = new AjaxJson();
         try {
-            //保存分管领导
-            saveLeader(status,theOrder);
-            //保存订单信息 需要处理周末
-            theOrder.setScheduled(new Date());
+            //获取工作日 -- 第二天
+            String addOrMinusDayString = OrderUtils.getAddOrMinusDayString(1, dateFormat);
+            //验证是否存在订单  --true未为存在
+            boolean planOrder = getPlanOrder(theOrder.getCorrelationId(), addOrMinusDayString);
+            if (planOrder){
+                ajaxJson.setSuccess(true);
+                ajaxJson.setMsg("您已经预定过餐");
+                return ajaxJson;
+            }
+            //修改分管领导
+//            updateLeader(theOrder);
+            //保存团队信息,如果status为1,说明是回显信息,无需保存
+            saveLeader(theOrder);
+            addOrMinusDayString = addOrMinusDayString+" 12:00:00";
+            Date parse = dateFormat1.parse(addOrMinusDayString);
+            theOrder.setScheduled(parse);//添加预定时间
             theOrderService.insertOrder(theOrder);//保存订单信息
             ajaxJson.setSuccess(true);
             ajaxJson.setMsg("预定餐成功");
@@ -147,35 +108,57 @@ public class TheOrderController extends BaseController {
         return ajaxJson;
     }
 
-    //获取确定订餐时间
-    public AjaxJson getConfirmOrder(String status,TheOrder theOrder){
-        AjaxJson ajaxJson = new AjaxJson();
-        //用来查找昨天的预定餐情况
-        TheOrder to = new TheOrder();
-
-        try {
-            saveLeader(status,theOrder);
-            theOrderService.findList(theOrder);
-            ajaxJson.setSuccess(true);
-            ajaxJson.setMsg("确定订餐成功");
-            return ajaxJson;
-        }catch (Exception e){
-            e.printStackTrace();
-        }
-        ajaxJson.setSuccess(false);
-        ajaxJson.setMsg("确定订餐失败,请重新确定");
-        return ajaxJson;
-    }
-
-    //保存分管领导
-    public void saveLeader(String status,TheOrder theOrder){
+    //保存团队部门信息
+    public void saveLeader(TheOrder theOrder){
         //保存分管领导信息
-        if (status.equals("1")){
+        if (theOrder.getStatus().equals("1")){
             //保存信息分管领导信息
             TheLeadership theLeadership = new TheLeadership();
-            theLeadership.setUserId(theOrder.getCorrelationId());
-            theLeadership.setLeadership(theOrder.getLeadership());
+            theLeadership.setTeam(theOrder.getTeam());//添加团队
+            theLeadership.setDepartment(theOrder.getDepartment());//部门
+            theLeadership.setSpecific(theOrder.getSpecific());//具体部门
+            theLeadership.setCorrelationId(theOrder.getCorrelationId());//关联id
             theLeadershipService.insertLeaderShip(theLeadership);
         }
     }
-}
+    //确定是否预定过餐
+    public boolean getPlanOrder(String userId,String addOrMinusDayString){
+        boolean flag = false;
+       try {
+           DateFormat dateFormat=new SimpleDateFormat("yyyy-MM-dd");
+           addOrMinusDayString = addOrMinusDayString+" 12:00:00";
+           TheOrder toOrderDate = new TheOrder();
+           toOrderDate.setDateStart(addOrMinusDayString);//开始时间
+           toOrderDate.setCorrelationId(userId);
+           List<TheOrder> list = theOrderService.findList(toOrderDate);//查询上个工作日时间范围内容
+           if(null!=list&&list.size()>0){
+               flag = true;
+           }
+       }catch (Exception e){
+           e.printStackTrace();
+       }
+       return flag;
+    }
+
+    //验证是否订过餐
+//    public boolean getSureOrder(String userid){
+//        boolean flag = false;
+//        try {
+//            DateFormat dateFormat=new SimpleDateFormat("yyyy-MM-dd");
+//            //查询今天是否订过餐
+//            TheOrder sureOrder = new TheOrder();
+//            Date date = new Date();
+//            sureOrder.setDateEnd(dateFormat.format(date));
+//            List<TheOrder> list1 = theOrderService.findList(sureOrder);
+//            for (TheOrder theOrder:list1){
+//                if (theOrder.getCorrelationId().equals(userid)){
+//                    flag =true;
+//                    break;
+//                }
+//            }
+//        }catch (Exception e){
+//            e.printStackTrace();
+//        }
+//        return  flag;
+//    }
+}