/**
   * @功能描述:修改工单数据
   *
   * @author gel @2015年8月31日
   * @param
   * @version
   * @throws Exception
   */
  @RequestMapping(value = "updateDataWn", method = RequestMethod.POST)
  @ResponseBody
  public void updateDataDirectory(
      @RequestBody WnVo vo, HttpServletRequest request, HttpServletResponse response)
      throws Exception {
    // 判断vo
    if (vo == null) {
      throw new MbvException("传入参数为空!");
    }

    Map<String, Object> map = new HashMap<String, Object>();

    try {
      log.info("WnController.updateDataWn -> entity: " + vo.getEntity());
      WnEntity entity = vo.getEntity();
      HttpSession session = request.getSession();
      entity.setLastModifiedUser((String) session.getAttribute(MbvConstant.USER_CODE));
      entity.setLastModifiedDate(new Date());

      boolean updateResult = wnService.updateByPrimaryKeySelective(entity);
      log.info(
          "WnController.updateDataWn -> docType: "
              + entity.getDocType()
              + ", docState: "
              + entity.getDocState()
              + ",id:"
              + entity.getId());

      // 0缺货 1提交状态
      if (updateResult == true
          && MbvConstant.MBV_WN_DOC_TYPE.equals(entity.getDocType())
          && MbvConstant.MBV_WN_DOC_STATE.equals(entity.getDocState())) {
        /** 调用消息队列 */
        //				wnService.sendOrder(wnJsonStr(entity));
        //				mqWnService.sendOrder(wnJsonStr(entity));
        wnService.sendOrder(entity);
      }

      map.put("result", updateResult);
      map.put("success", true);
    } catch (MbvException e) {
      throw new MbvException(MbvConstant.MBV_SYS_ERROR_TIP);
    } catch (RuntimeException e) {
      throw new MbvException(MbvConstant.MBV_SYS_ERROR_TIP);
    }

    // 保存成功
    returnSuccess(response, map);
  }
  /**
   * @功能描述:保存工单
   *
   * @author henry @2015年8月31日
   * @param
   * @version
   * @throws Exception
   */
  @RequestMapping(value = "saveDataWn", method = RequestMethod.POST)
  @ResponseBody
  public void addSysParam(
      @RequestBody WnVo vo, HttpServletRequest request, HttpServletResponse response)
      throws Exception {
    // 判断vo
    if (vo == null) {
      throw new MbvException("传入参数为空!");
    }
    Map<String, Object> map = new HashMap<String, Object>();

    try {
      WnEntity entity = vo.getEntity();
      entity.setDocDate(new Date());
      // entity.setDocState(MbvConstant.WN_STATUS_INPUT);//录入中

      HttpSession session = request.getSession();
      String user = (String) session.getAttribute(MbvConstant.USER_CODE);
      String unitCode = (String) session.getAttribute(MbvConstant.UNIT_CODE);

      entity.setCreateUser(user);
      entity.setCreateDate(new Date());
      entity.setLastModifiedUser(user);
      entity.setLastModifiedDate(new Date());
      entity.setUnitCode(unitCode);

      // doccode
      String docCode = wnService.selectDocCodeSeq(MbvConstant.MBV_WN_SEQ_NAME);
      entity.setDocCode(docCode);

      boolean result = wnService.insertSelective(entity);

      log.info(
          "WnController.saveDataWn -> docType: "
              + entity.getDocType()
              + ", docState: "
              + entity.getDocState());

      // 0缺货 1提交状态
      if (MbvConstant.MBV_WN_DOC_TYPE.equals(entity.getDocType())
          && MbvConstant.MBV_WN_DOC_STATE.equals(entity.getDocState())) {
        /** 调用消息队列 */
        //				wnService.sendOrder(wnJsonStr(entity));
        WnEntity wnEntity = wnService.selectByDocCode(docCode);
        //				mqWnService.sendOrder(wnJsonStr(wnEntity));
        wnService.sendOrder(wnEntity);
      }

      map.put("success", result);
    } catch (MbvException e) {
      throw new MbvException(MbvConstant.MBV_SYS_ERROR_TIP);
    } catch (RuntimeException e) {
      throw new MbvException(MbvConstant.MBV_SYS_ERROR_TIP);
    }

    // 保存成功
    returnSuccess(response, map);
  }
  /**
   * @功能描述:根据id查询工单
   *
   * @author gel @2015年8月31日
   * @param
   * @version
   */
  @RequestMapping(value = "findDataWnById", method = RequestMethod.POST)
  @ResponseBody
  public void findDataDirectory(@RequestBody WnVo vo, HttpServletResponse response)
      throws MbvException {
    // 判断vo
    if (vo == null) {
      throw new MbvException("传入参数为空!");
    }

    Map<String, Object> map = new HashMap<String, Object>();
    try {
      WnEntity entity = wnService.selectByPrimaryKey(vo.getEntity().getId());
      log.info("WnController.findDataWnById -> id: " + vo.getEntity().getId());

      map.put("data", entity);
      map.put("success", true);
    } catch (MbvException e) {
      throw new MbvException(MbvConstant.MBV_SYS_ERROR_TIP);
    } catch (RuntimeException e) {
      throw new MbvException(MbvConstant.MBV_SYS_ERROR_TIP);
    }
    // 保存成功
    returnSuccess(response, map);
  }