/** 添加 */ public void onAdd() { try { // biRedPointsShowAdd.setGoodsId(gmGoodsInfo.getGoodsId()); if (preSubmitCheck(biRedPointsShowAdd).equals(false)) { return; } biRedPointsShowAdd.setGoodsId(gmGoodsInfoShowAdd.getGoodsId()); biRedPointsShowAdd.setCrtDate(ToolUtil.getStrLastUpdDate()); // 创建日期YYYY-MM-DD biRedPointsShowAdd.setCrtTime(ToolUtil.getStrLastUpdTime()); // 创建时间HH:mm:ss biRedPointsShowAdd.setCrtOperId(operManager.getOperInfo().getOperId()); // 创建者ID biRedPointsShowAdd.setOrigin(EnuOrigin.ORIGIN_0.getCode()); // 数据来源:0_系统录入;1_系统外导入 impBpPointsDtl(biRedPointsShowAdd, null, "add"); // 导入BpPointsDtl表 updBpCusts(biRedPointsShowAdd.getCustNo()); // 更新BpCusts表的累计减少积分数、累计积分数 impGmGoodsDtl(biRedPointsShowAdd, "add"); // 导入GmGoodsDtl表 updateGmGoodsInfoStorQty( biRedPointsShowAdd.getGoodsId(), biRedPointsShowAdd.getGoodsQty()); // 更新GmGoodsInfo表在库数量 MessageUtil.addInfo("添加成功!"); gmGoodsInfoShowAdd = new GmGoodsInfo(); biRedPointsShowAdd = new BpRedPointsShow(); onQryForAdd(); } catch (Exception e) { logger.error("添加失败!", e); MessageUtil.addError("添加失败!" + e.getMessage()); } }
/** 导入 */ public void onImp() { try { if (file == null) { MessageUtil.addError("请选择要导入的.txt文件!"); return; } if (!file.getFileName().endsWith(".txt")) { MessageUtil.addError("文件格式错误,请选择.txt文件!"); return; } String line; // 每行数据 String[] colData; // 每列数据 int impCnt = 0; // 导入笔数 int result = 0; // 执行插入数据的结果 int lines = 0; // 总笔数 BpRedPointsShow bpRedPointsShow; BufferedReader br = new BufferedReader(new InputStreamReader(file.getInputstream(), "GBK")); try { while ((line = br.readLine()) != null) { lines++; colData = line.split("\\|"); bpRedPointsShow = new BpRedPointsShow(); bpRedPointsShow.setTxndate(colData[0]); // 数据日期 bpRedPointsShow.setCustNo(colData[1]); // 客户代码 bpRedPointsShow.setPoints(new BigDecimal(colData[2])); // 减少积分 bpRedPointsShow.setGoodsId(colData[3]); // 兑换礼品ID bpRedPointsShow.setCrtDate(ToolUtil.getStrLastUpdDate()); // 创建日期YYYY-MM-DD bpRedPointsShow.setCrtTime(ToolUtil.getStrLastUpdTime()); // 创建时间HH:mm:ss bpRedPointsShow.setCrtOperId(operManager.getOperInfo().getOperId()); // 创建者ID bpRedPointsShow.setOrigin(EnuOrigin.ORIGIN_1.getCode()); // 数据来源:0_系统录入;1_系统外导入 /* result = biRedPointsService.insertSelective(bpRedPointsShow); if (result > 0) { impCnt++; } else { continue; }*/ impBpPointsDtl(bpRedPointsShow, Long.valueOf(colData[4]), "imp"); // 导入BpPointsDtl表 updBpCusts(); // 更新BpCusts表的累计减少积分数、累计积分数 impGmGoodsDtl(bpRedPointsShow, "imp"); // 导入GmGoodsDtl表 updateGmGoodsInfoStorQty(bpRedPointsShow.getGoodsId()); // 更新GmGoodsInfo表在库数量 } } finally { br.close(); } if (impCnt > 0) { MessageUtil.addInfo("导入成功!总共" + lines + " 笔,导入" + impCnt + "笔。"); onQryImp(false); } } catch (Exception e) { logger.error("导入失败!", e); MessageUtil.addError("导入失败!" + e.getMessage()); } }
/** 查询导入 */ public void onQryImp(Boolean isTruePara) { try { if (StringUtils.isNotEmpty(impDate)) { biRedPointsShowQry.setCrtDate(impDate); } biRedPointsShowQry.setOrigin(EnuOrigin.ORIGIN_1.getCode()); bpRedPointsShowList = bpPointsDtlService.selectForAddByModelShow(biRedPointsShowQry); if (isTruePara.equals(true)) { if (bpRedPointsShowList.size() == 0) { MessageUtil.addInfo("没有查询到数据。"); } } } catch (Exception e) { logger.error("查询失败!", e); MessageUtil.addError("查询失败!" + e.getMessage()); } }
private void onQryForAdd() { BpRedPointsShow bpRedPointsShowTmp = new BpRedPointsShow(); bpRedPointsShowTmp.setCrtDate(ToolUtil.getStrLastUpdDate()); bpRedPointsShowTmp.setOrigin(EnuOrigin.ORIGIN_0.getCode()); bpRedPointsShowList = bpPointsDtlService.selectForAddByModelShow(bpRedPointsShowTmp); }