Commit c5c848bd by lijingjing

处理原铝重取添加多个的情况;

parent 19b1d411
......@@ -147,4 +147,6 @@ public interface IEntrustSampleService extends IBaseService<EntrustSample> {
String getCompatibleCode(EntrustSample sample);
Long getEntrustIdBySampleCode(String sampleCode);
List<Long> getEntrustIdsBySampleCodes(List<String> sampleCodes);
}
......@@ -1513,23 +1513,19 @@ public class EntrustSampleItemServiceImpl extends BaseServiceImpl<EntrustSampleI
//Y2201086159C1
//Y2112052110C2
//测试环境中,原铝重取可能并不是同一天生成的,"Y" + DateUtils.dateTransfer(sample.getCtime(), "yyMMdd") + "-" + sample.getSlotNo().trim();
String sampleCode = sample.getCode(), prefix = "Y";
// == 只有旧数据会有这种情况,可以不去考虑
if (StringUtils.isBlank(sampleCode)) {
sampleCode = "Y" + DateUtils.dateTransfer(sample.getCtime(), "yyMMdd") + "-" + sample.getSlotNo().trim();
} else {
sampleCode = sampleCode.startsWith(prefix) ? sampleCode : (prefix + sampleCode);
sampleCode = sampleCode.substring(0, 7) + "-" + sample.getSlotNo().trim();
}
List<String> sampleCodes = getSampleCodes(sampleList);
logger.error("sample code is : {}", sampleCodes);
//根据样品编号,查询出委托id
Long entrustId = entrustSampleService.getEntrustIdBySampleCode(sampleCode);
List<Long> entrustIds = entrustSampleService.getEntrustIdsBySampleCodes(sampleCodes);
logger.error("entrust id is : {}", entrustIds);
// 基本上不可能为空的
if (Objects.isNull(entrustId)) {
if (CollectionUtils.isEmpty(entrustIds)) {
log("根据样品编号获取委托id失败");
return;
}
// 根据委托去查询,也只能根据委托去查询
dataList = entrustSampleItemIndexService.listSampleItemIndex(Collections.singletonList(entrustId), null);
dataList = entrustSampleItemIndexService.listSampleItemIndex(entrustIds, null);
} else {
dataList = entrustSampleItemIndexService.listCpSampleItemIndex(null, ids);
}
......@@ -1538,8 +1534,8 @@ public class EntrustSampleItemServiceImpl extends BaseServiceImpl<EntrustSampleI
// == search data loop
dataList.forEach(t -> {
// 根据有无ID判断是属于哪一种数据来源
Object oid = t.get("id");
if (Objects.nonNull(oid)) {
Object oid = t.get("id"), obrand = t.get("brand");
if (Objects.nonNull(oid) && Objects.isNull(obrand)) {
Long sampleId = Long.valueOf(oid.toString());
t.put("brand", sampleBrandMap.get(sampleId));
t.remove("id");
......@@ -1560,6 +1556,27 @@ public class EntrustSampleItemServiceImpl extends BaseServiceImpl<EntrustSampleI
}
}
private List<String> getSampleCodes(List<EntrustSample> sampleList) {
List<String> sampleCodes = new ArrayList<String>();
for (EntrustSample sample : sampleList) {
String sampleCode = getSampleCode(sample);
sampleCodes.add(sampleCode);
}
return sampleCodes;
}
private String getSampleCode(EntrustSample sample) {
String sampleCode = sample.getCode(), prefix = "Y";
// == 只有旧数据会有这种情况,可以不去考虑
if (StringUtils.isBlank(sampleCode)) {
sampleCode = "Y" + DateUtils.dateTransfer(sample.getCtime(), "yyMMdd") + "-" + sample.getSlotNo().trim();
} else {
sampleCode = sampleCode.startsWith(prefix) ? sampleCode : (prefix + sampleCode);
sampleCode = sampleCode.substring(0, 7) + "-" + sample.getSlotNo().trim();
}
return sampleCode;
}
private void log(String str) {
logger.error("HMHJ====>ERP===={}....", str);
}
......
......@@ -2376,6 +2376,14 @@ public class EntrustSampleServiceImpl extends BaseServiceImpl<EntrustSampleMappe
return (Long) super.getObj(Condition.create().setSqlSelect("entrust_id").eq("code", sampleCode.trim()));
}
@Override
public List<Long> getEntrustIdsBySampleCodes(List<String> sampleCodes) {
if (CollectionUtils.isEmpty(sampleCodes)) {
return null;
}
return super.getObjs(Condition.create().setSqlSelect("entrust_id").in("code", sampleCodes));
}
private List<EntrustSampleItemIndex> getIndexList(Long sampleId) {
if (null == sampleId) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment