Ejemplo n.º 1
0
  /**
   * Press 新規登録
   *
   * @return String 弁一覧画面パス
   */
  @RequestMapping(value = "/calculatePress", method = RequestMethod.GET)
  @ResponseBody
  public String calculatePress(
      @RequestParam("pressId") String pressId,
      @RequestParam("base") String base,
      @RequestParam("pressG") String pressG,
      @RequestParam("pressHigh") String pressHigh,
      @RequestParam("keisu") String keisu,
      @RequestParam("adjust") String adjust,
      HttpSession session) {
    User user = (User) session.getAttribute("user");
    if (user == null) {
      return "login";
    } else {
      // 変数
      double Doubase = Double.parseDouble(base);
      double DouPressG = Double.parseDouble(pressG);
      double DouHigh = Double.parseDouble(pressHigh);
      double DouKeisu = Double.parseDouble(keisu);
      double DouAdjust = Double.parseDouble(adjust);

      PCALCPress press = new PCALCPress();
      press.setPressId(Integer.parseInt(pressId));
      press.setUserterm(user.getUserid());
      press.setBase(Doubase);
      press.setPressG(DouPressG);
      press.setPressHigh(DouHigh);
      press.setKeisu(DouKeisu);
      press.setAdjust(DouAdjust);

      double result = 0;
      if (DouKeisu > 0) {
        result = Doubase + ((DouPressG - 0.00863 * DouHigh) / DouKeisu);
      }
      // 元データをBigDecimal型にする
      BigDecimal bd = new BigDecimal(result);
      BigDecimal bd3 = bd.setScale(2, BigDecimal.ROUND_DOWN); // 切り捨て 小数第3位
      result = bd3.doubleValue();
      press.setPressResult(result);

      // DB更新する
      pressService.editPress(press);
      return "" + result;
    }
  }
Ejemplo n.º 2
0
  /**
   * Press 新規登録
   *
   * @return String 弁一覧画面パス
   */
  @RequestMapping(value = "/addPress", method = RequestMethod.GET)
  @ResponseBody
  public String addPress(@RequestParam("valveId") String valveId, HttpSession session) {
    User user = (User) session.getAttribute("user");
    if (user == null) {
      return "login";
    } else {
      PCALCPress press = new PCALCPress();
      press.setValveId(Integer.parseInt(valveId));
      press.setUserterm(user.getUserid());
      press.setPressHigh(1);
      // pressNum 設定
      List<PCALCPress> pressList = pressService.getPressByValveId(valveId);
      if (pressList.size() > 0) {
        press.setPressNum(pressMapper.getLastpressNumByValveId(Integer.parseInt(valveId)) + 1);
        PCALCPress tmpPress = new PCALCPress();
        tmpPress = pressService.getLastPressByValveId(valveId);
        if (tmpPress != null) {
          press.setKeisu(tmpPress.getKeisu());
        }
      } else {
        press.setPressNum(1);
      }

      press = pressService.addPress(press); // 新規空データ追加した
      // valveIDのすべてのPressを取得する
      pressList = pressService.getPressByValveId(valveId);
      // Press件数を取得
      Integer pressListNum = 0;
      if (pressList != null) {
        pressListNum = pressList.size();
      }

      Gson gson = new Gson();
      System.out.println("press=" + gson.toJson(press));

      return "" + gson.toJson(pressList);
    }
  }