コード例 #1
0
 @Override
 public HxGoodbill getGoodbillByPrimaryKey(List<String> asList) {
   HxGoodbillKey key = new HxGoodbillKey();
   key.setGsxx01(asList.get(0));
   key.setThdh(new Long(asList.get(1)));
   return hxGoodbillDao.selectByPrimaryKey(key);
 }
コード例 #2
0
  @Override
  public Map<String, String> insertGoodbills(List<HxGoodbill> bills) {

    Map<String, String> resultMap = new HashMap<String, String>();
    String exists = "{";
    String success = "{";
    String failure = "{";

    for (int i = 0; i < bills.size(); i++) {
      HxGoodbill bill = bills.get(i);
      HxGoodbillKey key = new HxGoodbillKey();
      key.setGsxx01(bill.getGsxx01());
      key.setThdh(bill.getThdh());
      HxGoodbill temp = hxGoodbillDao.selectByPrimaryKey(key);
      if (temp != null) {
        exists += (i + 2) + ",";
      } else {
        String gsxx = bill.getGsxx01();
        Long thdh = bill.getThdh();
        if ("".equals(gsxx) || thdh == null || gsxx == null) {
          failure += (i + 2) + ",";
        } else {
          try {
            hxGoodbillDao.insert(bill);
            success += (i + 2) + ",";
          } catch (Exception e) {
            failure += (i + 2) + ",";
          }
        }
      }
    }
    resultMap.put(
        "exists",
        exists.length() == 1 ? exists + "}" : exists.subSequence(0, exists.length() - 1) + "}");
    resultMap.put(
        "success",
        success.length() == 1 ? success + "}" : success.subSequence(0, success.length() - 1) + "}");
    resultMap.put(
        "failure",
        failure.length() == 1 ? failure + "}" : failure.subSequence(0, failure.length() - 1) + "}");
    return resultMap;
  }