|
@@ -188,20 +188,7 @@ public class MuseumInfoServiceImpl implements MuseumInfoService {
|
|
|
public Integer MuseumInfoByOrigin(Integer year, Integer origin) {
|
|
|
return museumInfoMapper.countMuseumInfoByOrigin(year,origin);
|
|
|
}
|
|
|
- private Integer transformSampleType(String sampleType) {
|
|
|
- if (sampleType==null){
|
|
|
- return null;
|
|
|
- }else if (sampleType.equals("矿石")){
|
|
|
- return 1;
|
|
|
- }else if (sampleType.equals("岩石")){
|
|
|
- return 2;
|
|
|
- }else if (sampleType.equals("矿物")){
|
|
|
- return 3;
|
|
|
- }else if (sampleType.equals("陨石")){
|
|
|
- return 4;
|
|
|
- }
|
|
|
- throw new IllegalArgumentException("无效的标本类型: " + sampleType);
|
|
|
- }
|
|
|
+
|
|
|
/**
|
|
|
* 批量导入用户
|
|
|
*
|
|
@@ -225,8 +212,17 @@ public class MuseumInfoServiceImpl implements MuseumInfoService {
|
|
|
// 2.2.1 判断如果不存在,在进行插入
|
|
|
MuseumInfoDO existSample = museumInfoMapper.selectMuseumInfoBySampleId(importSample.getSampleId());
|
|
|
if (existSample == null) {
|
|
|
+ //改变模式
|
|
|
+
|
|
|
Integer SampleType = transformSampleType(importSample.getSampleTypeC());
|
|
|
importSample.setSampleType(SampleType);
|
|
|
+ Integer KeepType = transformKeepType(importSample.getKeepTypeC());
|
|
|
+ importSample.setKeepType(KeepType);
|
|
|
+ Integer Store = transformStore(importSample.getStoreC());
|
|
|
+ importSample.setKeepType(Store);
|
|
|
+ Integer Origin = transformOrigin(importSample.getOriginC());
|
|
|
+ importSample.setKeepType(Origin);
|
|
|
+
|
|
|
MuseumInfoDO newSample = BeanUtils.toBean(importSample, MuseumInfoDO.class);
|
|
|
museumInfoMapper.insert(newSample);
|
|
|
respVO.getCreateSampleIds().add(importSample.getSampleId());
|
|
@@ -244,12 +240,23 @@ public class MuseumInfoServiceImpl implements MuseumInfoService {
|
|
|
// } catch (ServiceException ex) {
|
|
|
// respVO.getFailureSampleIds().put(importSample.getSampleId(), ex.getMessage());
|
|
|
// }
|
|
|
-
|
|
|
+ //改变模式
|
|
|
Integer SampleType = transformSampleType(importSample.getSampleTypeC());
|
|
|
importSample.setSampleType(SampleType);
|
|
|
+ Integer KeepType = transformKeepType(importSample.getKeepTypeC());
|
|
|
+ importSample.setKeepType(KeepType);
|
|
|
+ Integer Store = transformStore(importSample.getStoreC());
|
|
|
+ importSample.setKeepType(Store);
|
|
|
+ Integer Origin = transformOrigin(importSample.getOriginC());
|
|
|
+ importSample.setKeepType(Origin);
|
|
|
+
|
|
|
+
|
|
|
MuseumInfoDO updateSample = BeanUtils.toBean(importSample, MuseumInfoDO.class);
|
|
|
updateSample.setId(existSample.getId());
|
|
|
updateSample.setSampleType(SampleType);
|
|
|
+ updateSample.setKeepType(KeepType);
|
|
|
+ updateSample.setStore(Store);
|
|
|
+ updateSample.setOrigin(Origin);
|
|
|
museumInfoMapper.updateById(updateSample);
|
|
|
respVO.getUpdateSampleIds().add(importSample.getSampleId());
|
|
|
});
|
|
@@ -297,6 +304,71 @@ public class MuseumInfoServiceImpl implements MuseumInfoService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private MuseuminfoImportExcelVO transform(MuseuminfoImportExcelVO importSample){
|
|
|
+ Integer SampleType = transformSampleType(importSample.getSampleTypeC());
|
|
|
+ importSample.setSampleType(SampleType);
|
|
|
+ Integer KeepType = transformKeepType(importSample.getKeepTypeC());
|
|
|
+ importSample.setKeepType(KeepType);
|
|
|
+ Integer Store = transformStore(importSample.getStoreC());
|
|
|
+ importSample.setKeepType(Store);
|
|
|
+ Integer Origin = transformOrigin(importSample.getOriginC());
|
|
|
+ importSample.setKeepType(Origin);
|
|
|
+ return importSample;
|
|
|
+ }
|
|
|
+
|
|
|
+ private Integer transformSampleType(String sampleType) {
|
|
|
+ if (sampleType==null){
|
|
|
+ return null;
|
|
|
+ }else if (sampleType.equals("矿石")){
|
|
|
+ return 1;
|
|
|
+ }else if (sampleType.equals("岩石")){
|
|
|
+ return 2;
|
|
|
+ }else if (sampleType.equals("矿物")){
|
|
|
+ return 3;
|
|
|
+ }else if (sampleType.equals("陨石")){
|
|
|
+ return 4;
|
|
|
+ }
|
|
|
+ throw new IllegalArgumentException("无效的标本类型: " + sampleType);
|
|
|
+ }
|
|
|
+// 标本-1 光片-2 薄片-3 其他-4
|
|
|
+ private Integer transformKeepType(String keepType) {
|
|
|
+ if (keepType == null) {
|
|
|
+ return null;
|
|
|
+ } else if (keepType.equals("标本")) {
|
|
|
+ return 1;
|
|
|
+ } else if (keepType.equals("光片")) {
|
|
|
+ return 2;
|
|
|
+ } else if (keepType.equals("薄片")) {
|
|
|
+ return 3;
|
|
|
+ } else if (keepType.equals("其他")) {
|
|
|
+ return 4;
|
|
|
+ }
|
|
|
+ throw new IllegalArgumentException("无效的保存类型: " + keepType);
|
|
|
+ }
|
|
|
+// 采购-1 捐赠-2 采集-3
|
|
|
+ private Integer transformOrigin(String origin) {
|
|
|
+ if (origin == null) {
|
|
|
+ return null;
|
|
|
+ } else if (origin.equals("采购")) {
|
|
|
+ return 1;
|
|
|
+ } else if (origin.equals("捐赠")) {
|
|
|
+ return 2;
|
|
|
+ } else if (origin.equals("采集")) {
|
|
|
+ return 3;
|
|
|
+ }
|
|
|
+ throw new IllegalArgumentException("无效的标本来源: " + origin);
|
|
|
+ }
|
|
|
+
|
|
|
+ private Integer transformStore(String store) {
|
|
|
+ if (store == null) {
|
|
|
+ return null;
|
|
|
+ } else if (store.equals("在库")) {
|
|
|
+ return 1;
|
|
|
+ } else if (store.equals("出库")) {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ throw new IllegalArgumentException("无效的标本状态: " + store);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|