Ejemplo n.º 1
0
  public String addEpPreset(String name, short presetNumber, String vicId, BigDecimal setFlag)
      throws BusinessException {
    // 同一个摄像头的预置点名称不能重复
    EpPresetExample example = new EpPresetExample();
    EpPresetExample.Criteria criteria = example.createCriteria();
    criteria.andNameEqualTo(name);
    criteria.andVicIdEqualTo(vicId);
    List<EpPreset> list = epPresetDAO.selectByExample(example);
    if (list.size() > 0) {
      throw new BusinessException(name, ErrorCode.NAME_EXIST);
    }

    EpPreset epPreset = new EpPreset();
    String id = sequenceDAO.getEpPresetSeq();
    epPreset.setId(id);
    epPreset.setVicId(vicId);
    epPreset.setName(name);
    epPreset.setPresetNumber(presetNumber);
    epPreset.setSetFlag(setFlag);
    epPresetDAO.insert(epPreset);
    return id;
  }
Ejemplo n.º 2
0
 public void addOrUpdateEpPreset(String jsonString) throws JSONException {
   if (StringUtils.isBlank(jsonString)) {
     throw new BusinessException("jsonString", ErrorCode.PARAMETER_NOT_FOUND);
   }
   JSONObject jsonObject = new JSONObject(jsonString);
   String vicId = jsonObject.getString("vicId");
   epPresetDAO.deleteByvicId(vicId);
   JSONArray jsonArray = jsonObject.getJSONArray("presets");
   if (jsonArray.length() > 0) {
     for (int i = 0; i < jsonArray.length(); i++) {
       JSONObject jsonObj = new JSONObject(jsonArray.getString(i));
       String name = jsonObj.getString("name");
       String note = jsonObj.getString("note");
       String presetNumberstr = jsonObj.getString("presetNumber");
       Short presetNumber;
       try {
         presetNumber = Short.valueOf(presetNumberstr);
       } catch (Exception e) {
         throw new BusinessException("presetNumber", ErrorCode.AC_PARAMETER_INVALID);
       }
       String setFlagstr = jsonObj.getString("setFlag");
       BigDecimal setFlag;
       try {
         setFlag = new BigDecimal(setFlagstr);
       } catch (Exception e) {
         throw new BusinessException("setFlag", ErrorCode.AC_PARAMETER_INVALID);
       }
       EpPreset epPreset = new EpPreset();
       String id = sequenceDAO.getEpPresetSeq();
       epPreset.setId(id);
       epPreset.setVicId(vicId);
       epPreset.setName(name);
       epPreset.setNote(note);
       epPreset.setPresetNumber(Short.valueOf(presetNumber));
       epPreset.setSetFlag(setFlag);
       epPresetDAO.insert(epPreset);
     }
   }
 }