表格中 卡板号是三个,每个卡板又有很多箱,对每箱进行判定,如果一箱ng整个卡板批退,现在想得到批退的卡板数量

来源:互联网 发布:windows vista能升级 编辑:程序博客网 时间:2024/05/20 14:39

这里先做了一个小的构思, 

@Transientpublic Integer getRejBatch() {Set<String> set = new HashSet<String>();for(NormalSample sample : normalSamples){String aa  = sample.getJudgement()+sample.getBatchNO();set.add(aa);//如果 判断+卡板号  aa的数目=卡板数,表示全部通过,否者多几个就是几个不合格。}//FixedME cset中有几个Re就是几int a = getBatchNum().intValue();return set.size()> a ? (set.size() - getBatchNum()): 0;}
但是有个bug,就是,就一个卡板,就一箱,或者卡板每箱都是NG,这就不能判定了,

修改:

@Transientpublic Integer getRejBatch() {Set<String> set = new HashSet<String>();for(NormalSample sample : normalSamples){String aa  = (sample.getJudgement()+sample.getBatchNO());set.add(aa);//}//FixedME change to set中有几个Re就是几int a=0; String s1 ="Re";for(String str:set){if (str.contains(s1)){a++;}}return a;
}
直接从set集合中找包含“Re”的字符串的个数,,呵呵,这个解决后够自己乐好几天了--

0 0
原创粉丝点击