获取历史记录接口修改

master
hongtianzai 4 years ago
parent 8b4a1f7782
commit 805459f3ad

@ -24,7 +24,7 @@ public class DataSetResult {
*/ */
@Data @Data
public static class DeviceInfo{ public static class DeviceInfo{
private String deviceHistoryRecordKey; private String deviceHistoryKey;
private String deviceRecordKey; private String deviceRecordKey;
private int versionNumber; private int versionNumber;
private String versionStatus; private String versionStatus;
@ -84,6 +84,7 @@ public class DataSetResult {
} }
@Data @Data
public static class ClinicalInfo{ public static class ClinicalInfo{
private String deviceHistoryKey;//历史key
private String deviceRecordKey; // 数据库记录 key private String deviceRecordKey; // 数据库记录 key
private String lcsycclx; //尺寸类型 private String lcsycclx; //尺寸类型
private String ccz; //尺寸值 private String ccz; //尺寸值
@ -91,6 +92,7 @@ public class DataSetResult {
} }
@Data @Data
public static class StorageInfo{ public static class StorageInfo{
private String deviceHistoryKey;//历史key
private String deviceRecordKey; // 数据库记录 key private String deviceRecordKey; // 数据库记录 key
private String cchcztj; // 储存或操作条件 private String cchcztj; // 储存或操作条件
private String zdz; //最低值 private String zdz; //最低值
@ -99,6 +101,7 @@ public class DataSetResult {
} }
@Data @Data
public static class PackingInfo{ public static class PackingInfo{
private String deviceHistoryKey;//历史key
private String deviceRecordKey; // 数据库记录 key private String deviceRecordKey; // 数据库记录 key
private String bzcpbs; //包装产品标识 private String bzcpbs; //包装产品标识
private String bznhxyjbzcpbs; //包装内含下一级包装产品标识 private String bznhxyjbzcpbs; //包装内含下一级包装产品标识

@ -32,20 +32,30 @@ public class DeviceSaveService {
/** /**
* *
*
* @param dataSets * @param dataSets
* @return * @return
*/ */
public int DeviceSave(List<DataSetResult.DataSet> dataSets,Date requestDate) { public int DeviceSave(List<DataSetResult.DataSet> dataSets, Date requestDate) {
int result=0; int result = 0;
for (DataSetResult.DataSet ds : dataSets) { for (DataSetResult.DataSet ds : dataSets) {
List<DataSetResult.ClinicalInfo> ClinicalInfoAll = ds.getClinicalInfo();
List<DataSetResult.StorageInfo> storageInfoAll = ds.getStorageInfo();
List<DataSetResult.PackingInfo> packingInfoAll = ds.getPackingInfo();
for (DataSetResult.DeviceInfo item : ds.getDeviceInfo()) { for (DataSetResult.DeviceInfo item : ds.getDeviceInfo()) {
//1:判断数据是否存在 //1:判断数据是否存在
if (deviceService.selectisSame(item.getDeviceRecordKey(), item.getVersionNumber() + "") != null) if (deviceService.selectisSame(item.getDeviceRecordKey(), item.getVersionNumber() + "") != null)
continue; continue;
Device device = responseToDevice(item); Device device = responseToDevice(item);
String uuid = getUUId(); String uuid = getUUId();
Boolean isHistory = false;
if (item.getDeviceHistoryKey() != null && !item.getDeviceHistoryKey().isEmpty()) {
isHistory = true;
System.out.println(JSON.toJSONString(ds));
}
device.setUuid(uuid); device.setUuid(uuid);
if(requestDate != null) if (requestDate != null)
device.setRequestDate(requestDate); device.setRequestDate(requestDate);
//2,存储 deviceInfo //2,存储 deviceInfo
deviceService.insertDevice(device); deviceService.insertDevice(device);
@ -63,55 +73,77 @@ public class DeviceSaveService {
deviceService.insertContactlist(contactlistList); deviceService.insertContactlist(contactlistList);
} }
//4,存储 Deviceclinical //4,存储 Deviceclinical
List<DataSetResult.ClinicalInfo> deviceclinicals = ds.getClinicalInfo().stream().filter(p->p.getDeviceRecordKey().equals(item.getDeviceRecordKey())). if (ClinicalInfoAll != null && ClinicalInfoAll.size() > 0) {
collect(Collectors.toList()); List<DataSetResult.ClinicalInfo> deviceclinicals;
if(ds.getClinicalInfo().size()>0){ if (isHistory == true)
System.out.println("getClinicalInfo:"+JSON.toJSON(ds.getClinicalInfo())); deviceclinicals = ClinicalInfoAll.stream().filter(p -> p.getDeviceHistoryKey().equals(item.getDeviceHistoryKey())).
System.out.println("deviceclinicals:"+JSON.toJSON(deviceclinicals)); collect(Collectors.toList());
} else
List<Deviceclinical> deviceclinicalList = new ArrayList<>(); deviceclinicals = ClinicalInfoAll.stream().filter(p -> p.getDeviceRecordKey().equals(item.getDeviceRecordKey())).
if (deviceclinicals != null && deviceclinicals.size() > 0) { collect(Collectors.toList());
for (DataSetResult.ClinicalInfo deviceClinical : deviceclinicals) { List<Deviceclinical> deviceclinicalList = new ArrayList<>();
if (deviceclinicals != null && deviceclinicals.size() > 0) {
for (DataSetResult.ClinicalInfo deviceClinical : deviceclinicals) {
Deviceclinical deviceclinical = responseToDeviceclinical(deviceClinical); Deviceclinical deviceclinical = responseToDeviceclinical(deviceClinical);
deviceclinical.setDevicerecordkey(device.getDevicerecordkey()); if (isHistory == true)
deviceclinical.setDevicerecordkey(item.getDeviceHistoryKey());
else
deviceclinical.setDevicerecordkey(device.getDevicerecordkey());
deviceclinical.setUuid(uuid); deviceclinical.setUuid(uuid);
deviceclinicalList.add(deviceclinical); deviceclinicalList.add(deviceclinical);
}
deviceService.insertDeviceClinical(deviceclinicalList);
} }
System.out.println("deviceclinicalList:"+JSON.toJSON(deviceclinicalList));
deviceService.insertDeviceClinical(deviceclinicalList);
} }
//5 存储 Devicestorage //5 存储 Devicestorage
List<DataSetResult.StorageInfo> storageInfoes = ds.getStorageInfo().stream().filter(p->p.getDeviceRecordKey().equals(item.getDeviceRecordKey())). if(storageInfoAll != null && storageInfoAll.size()>0){
collect(Collectors.toList()); List<DataSetResult.StorageInfo> storageInfos;
/*if(ds.getStorageInfo().size()>0){ if(isHistory == true)
System.out.println(item.getDeviceRecordKey()); storageInfos = storageInfoAll.stream().filter(p -> p.getDeviceHistoryKey().equals(item.getDeviceHistoryKey())).
System.out.println("getDeviceInfo:"+JSON.toJSON(ds.getDeviceInfo())); collect(Collectors.toList());
System.out.println("getStorageInfo:"+JSON.toJSON(ds.getStorageInfo())); else
System.out.println("storageInfoes:"+JSON.toJSON(storageInfoes)); storageInfos = storageInfoAll.stream().filter(p -> p.getDeviceRecordKey().equals(item.getDeviceRecordKey())).
}*/ collect(Collectors.toList());
if (storageInfoes != null && storageInfoes.size() > 0) { if (storageInfos != null && storageInfos.size() > 0) {
List<Devicestorage> devicestorageList = new ArrayList<>(); List<Devicestorage> devicestorageList = new ArrayList<>();
for (DataSetResult.StorageInfo storageInfo : storageInfoes) { for (DataSetResult.StorageInfo storageInfo : storageInfos) {
Devicestorage devicestorage = responseToDevicestorage(storageInfo); Devicestorage devicestorage = responseToDevicestorage(storageInfo);
devicestorage.setDevicerecordkey(device.getDevicerecordkey()); if (isHistory == true)
devicestorage.setUuid(uuid); devicestorage.setDevicerecordkey(item.getDeviceHistoryKey());
devicestorageList.add(devicestorage); else
devicestorage.setDevicerecordkey(device.getDevicerecordkey());
devicestorage.setUuid(uuid);
devicestorageList.add(devicestorage);
}
deviceService.insertDevicestorage(devicestorageList);
} }
//System.out.println(JSON.toJSON("devicestorage"+devicestorageList));
deviceService.insertDevicestorage(devicestorageList);
} }
//6 存储Devicepackage //6 存储Devicepackage
List<DataSetResult.PackingInfo> packingInfoes = ds.getPackingInfo().stream().filter(p->p.getDeviceRecordKey().equals(item.getDeviceRecordKey())). if(packingInfoAll != null && packingInfoAll.size()>0){
collect(Collectors.toList()); List<DataSetResult.PackingInfo> packingInfos ;
if (packingInfoes != null && packingInfoes.size() > 0) { if(isHistory == true)
List<Devicepackage> devicepackageList = new ArrayList<>(); packingInfos = packingInfoAll.stream().filter(p -> p.getDeviceHistoryKey().equals(item.getDeviceHistoryKey())).
for (DataSetResult.PackingInfo packingInfo : packingInfoes) { collect(Collectors.toList());
Devicepackage devicepackage = responseToDevicepackage(packingInfo); else
devicepackage.setDevicerecordkey(device.getDevicerecordkey()); packingInfos = packingInfoAll.stream().filter(p -> p.getDeviceRecordKey().equals(item.getDeviceRecordKey())).
devicepackage.setUuid(uuid); collect(Collectors.toList());
devicepackageList.add(devicepackage); if (packingInfos != null && packingInfos.size() > 0) {
List<Devicepackage> devicepackageList = new ArrayList<>();
for (DataSetResult.PackingInfo packingInfo : packingInfos) {
Devicepackage devicepackage = responseToDevicepackage(packingInfo);
if (isHistory == true)
devicepackage.setDevicerecordkey(item.getDeviceHistoryKey());
else
devicepackage.setDevicerecordkey(device.getDevicerecordkey());
devicepackage.setUuid(uuid);
devicepackageList.add(devicepackage);
}
deviceService.insertDevicepackage(devicepackageList);
} }
deviceService.insertDevicepackage(devicepackageList);
} }
//7存储productInfo信息 //7存储productInfo信息
@ -129,7 +161,7 @@ public class DeviceSaveService {
*/ */
private Device responseToDevice(DataSetResult.DeviceInfo dataSetBean) { private Device responseToDevice(DataSetResult.DeviceInfo dataSetBean) {
Device device = new Device(); Device device = new Device();
//device.setDevicehistoryrecordkey(dataSetBean.getDeviceHistoryRecordKey()); device.setDevicehistoryrecordkey(dataSetBean.getDeviceHistoryKey());
device.setDevicerecordkey(dataSetBean.getDeviceRecordKey()); device.setDevicerecordkey(dataSetBean.getDeviceRecordKey());
device.setBtcpbs(dataSetBean.getBtcpbs()); device.setBtcpbs(dataSetBean.getBtcpbs());
device.setBtcpbsyzxxsdycpbssfyz(dataSetBean.getBtcpbsyzxxsdycpbssfyz()); device.setBtcpbsyzxxsdycpbssfyz(dataSetBean.getBtcpbsyzxxsdycpbssfyz());
@ -178,21 +210,24 @@ public class DeviceSaveService {
device.setLastModifyTime(DateUtil.formatDateTime(new Date())); device.setLastModifyTime(DateUtil.formatDateTime(new Date()));
return device; return device;
} }
private Contactlist responseToContactlist(DataSetResult.ContactInfo contactInfo ) {
private Contactlist responseToContactlist(DataSetResult.ContactInfo contactInfo) {
Contactlist contactlist = new Contactlist(); Contactlist contactlist = new Contactlist();
contactlist.setQylxrcz(contactInfo.getQylxrcz()); contactlist.setQylxrcz(contactInfo.getQylxrcz());
contactlist.setQylxrdh(contactInfo.getQylxrdh()); contactlist.setQylxrdh(contactInfo.getQylxrdh());
contactlist.setQylxryx(contactInfo.getQylxryx()); contactlist.setQylxryx(contactInfo.getQylxryx());
return contactlist; return contactlist;
} }
public Deviceclinical responseToDeviceclinical(DataSetResult.ClinicalInfo clinicalInfo) {
public Deviceclinical responseToDeviceclinical(DataSetResult.ClinicalInfo clinicalInfo) {
Deviceclinical deviceclinical = new Deviceclinical(); Deviceclinical deviceclinical = new Deviceclinical();
deviceclinical.setLcsycclx(clinicalInfo.getLcsycclx()); deviceclinical.setLcsycclx(clinicalInfo.getLcsycclx());
deviceclinical.setCcz(clinicalInfo.getCcz()); deviceclinical.setCcz(clinicalInfo.getCcz());
deviceclinical.setCcdw(clinicalInfo.getCcdw()); deviceclinical.setCcdw(clinicalInfo.getCcdw());
return deviceclinical; return deviceclinical;
} }
public Devicestorage responseToDevicestorage(DataSetResult.StorageInfo storageInfo) {
public Devicestorage responseToDevicestorage(DataSetResult.StorageInfo storageInfo) {
Devicestorage devicestorage = new Devicestorage(); Devicestorage devicestorage = new Devicestorage();
devicestorage.setCchcztj(storageInfo.getCchcztj()); devicestorage.setCchcztj(storageInfo.getCchcztj());
devicestorage.setJldw(storageInfo.getJldw()); devicestorage.setJldw(storageInfo.getJldw());
@ -200,6 +235,7 @@ public class DeviceSaveService {
devicestorage.setZdz(storageInfo.getZdz()); devicestorage.setZdz(storageInfo.getZdz());
return devicestorage; return devicestorage;
} }
public Devicepackage responseToDevicepackage(DataSetResult.PackingInfo packingInfo) { public Devicepackage responseToDevicepackage(DataSetResult.PackingInfo packingInfo) {
Devicepackage devicepackage = new Devicepackage(); Devicepackage devicepackage = new Devicepackage();
devicepackage.setBzcpbs(packingInfo.getBzcpbs()); devicepackage.setBzcpbs(packingInfo.getBzcpbs());
@ -208,11 +244,13 @@ public class DeviceSaveService {
devicepackage.setBznhxyjcpbssl(Integer.parseInt(packingInfo.getBznhxyjcpbssl())); devicepackage.setBznhxyjcpbssl(Integer.parseInt(packingInfo.getBznhxyjcpbssl()));
return devicepackage; return devicepackage;
} }
private void productInfoSave(String uuid){
if(udiTransferUtils == null) private void productInfoSave(String uuid) {
if (udiTransferUtils == null)
udiTransferUtils = new UdiTransferUtils(); udiTransferUtils = new UdiTransferUtils();
udiTransferUtils.transUdi(deviceService, productInfoService, uuid, udiCompanyService); udiTransferUtils.transUdi(deviceService, productInfoService, uuid, udiCompanyService);
} }
private String getUUId() { private String getUUId() {
UUID uuid = UUID.randomUUID(); UUID uuid = UUID.randomUUID();
return uuid.toString().replace("-", ""); return uuid.toString().replace("-", "");

Loading…
Cancel
Save