Ejemplo n.º 1
0
  /**
   * apply for appointments
   *
   * @param model
   * @return
   */
  @RequestMapping(value = "/vi_testAppointment")
  public String applyAppointment(Model modelmap, HttpSession httpSession) {
    String account = (String) httpSession.getAttribute("accountName");
    Integer flag = (Integer) httpSession.getAttribute("flag");
    AccountClient accountClient = accountClientDao.findClientByAccount(account);
    if (accountClient != null) {
      //    		List<?> appointmentslist = new LinkedList();
      //	    	appointmentslist = (List<?>)indentVipDao.findByAccount(account);
      //	    	int n = appointmentslist==null?0:appointmentslist.size();//For testing
      // ...................................
      // LinkedList<Object> list = (LinkedList<Object>)
      // physicalDao.queryAll(Constant.TABLE_PHYSICALITEMS);
      List<?> list = (List<?>) physicalDao.retrieveAll();

      List<?> projectDetailList = new LinkedList();
      List<Project> projectList = new LinkedList();
      projectList = projectDao.getProjectsByAccount(account);
      Project lastProject = null;
      ProjectDetail projectDetail = null;
      Integer n = 0;
      if (projectList != null && projectList.size() > 0) {
        lastProject = projectList.get(projectList.size() - 1);
        projectDetailList =
            (List<?>) projectDetailDao.queryAllByProjectId(lastProject.getUidProject());
        projectDetail = (ProjectDetail) projectDetailList.get(0);
        if (projectDetail != null) {
          n = projectDetail.getNumber();
        }
      }

      modelmap.addAttribute("appointments_sum", n);
      modelmap.addAttribute("name", accountClient.getAccountClient());
      modelmap.addAttribute("appointments_content", list);
    } else {
      modelmap.addAttribute("appointments_sum", 0);
      modelmap.addAttribute("name", accountClient.getAccountClient());
      modelmap.addAttribute("appointments_content", null);
    }
    return "vip/vi_testAppointment";
  }
Ejemplo n.º 2
0
  /**
   * apply for appointments
   *
   * @param model
   * @return
   */
  @RequestMapping(value = "/vi_submitAppointment", method = RequestMethod.POST)
  public String submitAppointment(
      Model modelmap,
      HttpSession httpSession,
      String year,
      String month,
      String day,
      Integer total,
      String chooseNum,
      String chooseId) {
    String account = (String) httpSession.getAttribute("accountName");
    Integer flag = (Integer) httpSession.getAttribute("flag");
    AccountClient accountClient =
        accountClientDao.findClientByAccount(
            account); // For testing ...................................
    if (accountClient != null && flag != null && flag == Constant.account_client) {
      boolean insertResult = false;
      String[] chooseIdArray = chooseId.split(","); // split
      List<PhysicalItem> physicalList = (List<PhysicalItem>) physicalDao.retrieveAll(); //
      List<String> chooseIdItems = new ArrayList<String>();
      // resolve chooseId from chooseIdArray to chooseIdItems
      for (int i = 0; i < chooseIdArray.length; i++) {
        if (chooseIdArray[i].equalsIgnoreCase("true")) {
          chooseIdItems.add(String.valueOf(i));
        }
      }
      if (chooseIdItems.size() > 0) {

        // generate indent
        List indentList = (List) indentDao.queryAll();
        int indentSum = indentList == null ? 0 : indentList.size();
        Indent indent = new Indent();
        indent.setUidIndent(indentSum + 1); // inital the uid of the indent
        indent.setMoneyIndent(total);
        indentDao.save(indent); // Are you sure it is ok?

        // generate project
        List projectList = (List) projectDao.queryAll();
        int projectSum = projectList == null ? 0 : projectList.size();
        Project project = new Project();
        project.setUidProject(projectSum + 1);
        project.setAccount(
            account); // For testing ...............................................................
        project.setClientName(
            accountClient
                .getAccountClient()); // For testing
                                      // ...............................................................
        project.setPeopleNumber(1);
        project.setTimeBegin(year + month + day);
        project.setTimeEnd("UnRecord");
        project.setAddressGroup("个人");
        projectDao.save(project);

        IndentVip indentVip = new IndentVip();
        List indentVipList = (List) indentVipDao.queryAll();
        int indentVipSum = indentVipList.size();
        indentVip.setUidIndentVip(indentVipSum + 1); // int
        indentVip.setUidIndent(indent.getUidIndent()); // int
        indentVip.setUidProject(project.getUidProject()); // int
        indentVip.setAccountClientIndent(account);
        indentVip.setIndentVipName(accountClient.getAccountClient());
        indentVip.setIndentVipSex(accountClient.getSexClient());
        indentVip.setIndentVipEmail(accountClient.getEmailClient());
        indentVip.setIndentVipAddress(accountClient.getAddressClient());
        indentVip.setIndentVipPhone(accountClient.getPhoneClient());
        indentVipDao.save(indentVip);

        for (int j = 0; j < chooseIdItems.size(); j++) {
          // generate projectdetail
          List ProjectDetailList = (List) projectDetailDao.queryAll();
          int projectDetailSum = ProjectDetailList == null ? 0 : ProjectDetailList.size();
          ProjectDetail projectDetail = new ProjectDetail();
          projectDetail.setUidProjectDetail(projectDetailSum + 1);
          projectDetail.setProject(project);
          projectDetail.setTestType(physicalList.get(j).getTypeItem());
          projectDetailDao.save(projectDetail); // Are you sure it is ok?

          // generate orderdetail
          List orderDetailList = (List) orderDetailDao.queryAll();
          int orderdetailSum = orderDetailList == null ? 0 : orderDetailList.size();
          OrderDetail orderDetail = new OrderDetail();
          orderDetail.setUidOrderDetail(orderdetailSum + 1);
          orderDetail.setIndent(indent);
          orderDetail.setProjectDetail(projectDetail);
          orderDetail.setMoneyOrder(total);
          orderDetail.setOrderClientName(
              accountClient
                  .getAccountClient()); // For testing
                                        // .........................................................
          orderDetail.setOrderTime(TimeUtils.getNowDate());
          orderDetailDao.save(orderDetail); // Are you sure it is ok?

          List testResultSumList = ((List) testResultDao.queryAll());
          int testResultSum = testResultSumList == null ? 0 : testResultSumList.size();
          TestResult testResult = new TestResult();
          testResult.setUidTestDetail(testResultSum + 1);
          testResult.setOrderDetail(orderDetail);
          testResult.setIdPhysicalItem(chooseIdItems.get(j));
          testResult.setResult("haven't yet");
          testResult.setIndentGroupMember("");
          testResult.setUidProject(String.valueOf(project.getUidProject()));
          testResult.setAccount(
              account); // For testing .........................................................
          testResultDao.save(testResult);
        }
        insertResult = true;

      } else {
        insertResult = false;
      }
      if (insertResult) {
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("id", accountClient.getAccountClient());
        map.put("gender", accountClient.getSexClient());
        map.put("identity", accountClient.getIdentityCardNumber());
        map.put("mobilephone", accountClient.getPhoneClient());
        map.put("officephone", "无");
        map.put("email", accountClient.getEmailClient());
        map.put("address", accountClient.getAddressClient());
        map.put("sicknesshistory", accountClient.getSicknessHistory());
        map.put("salesman", "Unknown");
        map.put("name", accountClient.getAccountClient());
        modelmap.addAttribute("user", map);
        modelmap.addAttribute("submitAppointmentsuccess", "true");
      }
    } else {
      Map<String, Object> map = new HashMap<String, Object>();
      map.put("id", accountClient.getAccountClient());
      map.put("gender", accountClient.getSexClient());
      map.put("identity", accountClient.getIdentityCardNumber());
      map.put("mobilephone", accountClient.getPhoneClient());
      map.put("officephone", "无");
      map.put("email", accountClient.getEmailClient());
      map.put("address", accountClient.getAddressClient());
      map.put("sicknesshistory", accountClient.getSicknessHistory());
      map.put("salesman", "Unknown");
      map.put("name", accountClient.getAccountClient());
      modelmap.addAttribute("user", map);
      modelmap.addAttribute("submitAppointmentsuccess", null);
    }
    return "vip/vi_index";
  }