|
|
|
@ -19,12 +19,16 @@ import com.glxp.udidl.admin.thread.UdiTransferUtils;
|
|
|
|
|
import com.glxp.udidl.admin.util.DateUtil;
|
|
|
|
|
import com.glxp.udidl.admin.util.HttpClient;
|
|
|
|
|
import com.glxp.udidl.admin.util.WarehousBeanUtils;
|
|
|
|
|
import jdk.nashorn.internal.ir.annotations.Reference;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.UUID;
|
|
|
|
|
|
|
|
|
|
@Service
|
|
|
|
|
public class DownloadDeviceHelper {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -32,11 +36,16 @@ public class DownloadDeviceHelper {
|
|
|
|
|
String url = "";
|
|
|
|
|
String appId;
|
|
|
|
|
String appSecret;
|
|
|
|
|
final int pageSize = 400;
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
UdiCompanyService udiCompanyService;
|
|
|
|
|
|
|
|
|
|
public DownloadDeviceHelper(CompanyService companyService, UdiCompanyService udiCompanyService) {
|
|
|
|
|
@Resource
|
|
|
|
|
CompanyService companyService;
|
|
|
|
|
@Resource
|
|
|
|
|
UdiTransferUtils udiTransferUtils;
|
|
|
|
|
@Resource
|
|
|
|
|
DeviceService deviceService;
|
|
|
|
|
|
|
|
|
|
public void DownloadDeviceHelper() {
|
|
|
|
|
companyEntity = companyService.findCompany();
|
|
|
|
|
if (companyEntity != null && companyEntity.getClasses() != null) {
|
|
|
|
|
if (companyEntity.getClasses().equals("1")) {
|
|
|
|
@ -47,7 +56,6 @@ public class DownloadDeviceHelper {
|
|
|
|
|
appId = companyEntity.getAppId();
|
|
|
|
|
appSecret = companyEntity.getAppSecret();
|
|
|
|
|
}
|
|
|
|
|
this.udiCompanyService = udiCompanyService;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public TokenEntity getToken() {
|
|
|
|
@ -112,13 +120,13 @@ public class DownloadDeviceHelper {
|
|
|
|
|
keys.setDeviceRecordKey(device.getDevicerecordkey());
|
|
|
|
|
dataSetBeans.add(keys);
|
|
|
|
|
deviceHistoryRequest.setDataSet(dataSetBeans);
|
|
|
|
|
downloadHistory(productInfoService, deviceHistoryRequest, deviceService);
|
|
|
|
|
downloadHistory(deviceHistoryRequest);
|
|
|
|
|
} else {
|
|
|
|
|
device.setLastModifyTime(DateUtil.formatDateTime(new Date()));
|
|
|
|
|
deviceService.insertDevice(device);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
new UdiTransferUtils().transUdi(deviceService, productInfoService, uuid, udiCompanyService);
|
|
|
|
|
udiTransferUtils.transUdi(uuid);
|
|
|
|
|
List<DataSetBean.DeviceClinicalBean> deviceclinicals = dataSetBean.getDeviceClinical();
|
|
|
|
|
List<Deviceclinical> deviceclinicalList = new ArrayList<>();
|
|
|
|
|
if (deviceclinicalList != null && deviceclinicalList.size() > 0) {
|
|
|
|
@ -176,113 +184,8 @@ public class DownloadDeviceHelper {
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int simpleDownloadDevices(ProductInfoService productInfoService, DeviceService deviceService, DeviceRequest deviceRequest) {
|
|
|
|
|
String response = HttpClient.post(url, deviceRequest);
|
|
|
|
|
int result = -1;
|
|
|
|
|
List<DataSetBean> dataSetBeanList = null;
|
|
|
|
|
MedicalResonse medicalResonse = null;
|
|
|
|
|
if (url.equals("sharing/get")) {
|
|
|
|
|
medicalResonse = (MedicalResonse) JSONObject.parseObject(response, MedicalResonse.class);
|
|
|
|
|
result = medicalResonse.getReturnCode();
|
|
|
|
|
dataSetBeanList = medicalResonse.getDataSet();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (dataSetBeanList != null && dataSetBeanList.size() > 0) {
|
|
|
|
|
for (int i = 0; i < dataSetBeanList.size(); i++) {
|
|
|
|
|
DataSetBean dataSetBean = dataSetBeanList.get(i);
|
|
|
|
|
Device device = WarehousBeanUtils.responseToDevice(dataSetBean);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (Integer.parseInt(deviceRequest.getCurrentPageNumber()) >= medicalResonse.getTotalPageCount()) {
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//下载生产企业
|
|
|
|
|
public int downloadProduct(ProductInfoService productInfoService, DeviceService deviceService, DeviceRequest deviceRequest) {
|
|
|
|
|
String response = HttpClient.post(url, deviceRequest);
|
|
|
|
|
MedicalHistoryResonse medicalResonse = (MedicalHistoryResonse) JSONObject.parseObject(response, MedicalHistoryResonse.class);
|
|
|
|
|
if (medicalResonse.getReturnCode() == 1) {
|
|
|
|
|
List<DataSetBean> dataSetBeanList = medicalResonse.getDataList();
|
|
|
|
|
if (dataSetBeanList != null && dataSetBeanList.size() > 0) {
|
|
|
|
|
for (int i = 0; i < dataSetBeanList.size(); i++) {
|
|
|
|
|
DataSetBean dataSetBean = dataSetBeanList.get(i);
|
|
|
|
|
Device device = WarehousBeanUtils.responseToDevice(dataSetBean);
|
|
|
|
|
if (deviceService.selectisSame(device.getDevicerecordkey(), device.getVersionnumber()) == null) {
|
|
|
|
|
if (device.getBssjzt() != null && device.getBssjzt().equals("草稿")) {
|
|
|
|
|
//草稿数据忽略
|
|
|
|
|
} else {
|
|
|
|
|
String uuid = getUUId();
|
|
|
|
|
device.setUuid(uuid);
|
|
|
|
|
String versionNum = device.getVersionnumber();
|
|
|
|
|
//如果版本号大于1,说明是新增,则更新历史记录
|
|
|
|
|
if (versionNum != null && Integer.parseInt(versionNum) > 1) {
|
|
|
|
|
deviceService.deleteHistory(device.getDevicerecordkey());
|
|
|
|
|
DownloadHistoryRequest deviceHistoryRequest = new DownloadHistoryRequest();
|
|
|
|
|
deviceHistoryRequest.setAccessToken(deviceRequest.getAccessToken());
|
|
|
|
|
deviceHistoryRequest.setCurrentPageNumber("1");
|
|
|
|
|
List<DownloadHistoryRequest.DataSetBean> dataSetBeans = new ArrayList<>();
|
|
|
|
|
DownloadHistoryRequest.DataSetBean keys = new DownloadHistoryRequest.DataSetBean();
|
|
|
|
|
keys.setDeviceRecordKey(device.getDevicerecordkey());
|
|
|
|
|
dataSetBeans.add(keys);
|
|
|
|
|
deviceHistoryRequest.setDataSet(dataSetBeans);
|
|
|
|
|
downloadHistory(productInfoService, deviceHistoryRequest, deviceService);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
deviceService.insertDevice(device);
|
|
|
|
|
List<DataSetBean.DeviceClinicalBean> deviceclinicals = dataSetBean.getDeviceClinical();
|
|
|
|
|
List<Deviceclinical> deviceclinicalList = new ArrayList<>();
|
|
|
|
|
for (DataSetBean.DeviceClinicalBean deviceClinicalBean : deviceclinicals) {
|
|
|
|
|
if (deviceClinicalBean != null) {
|
|
|
|
|
Deviceclinical deviceclinical = WarehousBeanUtils.responseToDeviceclinical(deviceClinicalBean);
|
|
|
|
|
deviceclinical.setDevicerecordkey(device.getDevicerecordkey());
|
|
|
|
|
deviceclinical.setUuid(uuid);
|
|
|
|
|
deviceclinicalList.add(deviceclinical);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
deviceService.insertDeviceClinical(deviceclinicalList);
|
|
|
|
|
|
|
|
|
|
List<DataSetBean.DevicePackageBean> devicePackageBeans = dataSetBean.getDevicePackage();
|
|
|
|
|
List<Devicepackage> devicepackageList = new ArrayList<>();
|
|
|
|
|
for (DataSetBean.DevicePackageBean devicePackageBean : devicePackageBeans) {
|
|
|
|
|
Devicepackage devicepackage = WarehousBeanUtils.responseToDevicepackage(devicePackageBean);
|
|
|
|
|
devicepackage.setDevicerecordkey(device.getDevicerecordkey());
|
|
|
|
|
devicepackage.setUuid(uuid);
|
|
|
|
|
devicepackageList.add(devicepackage);
|
|
|
|
|
}
|
|
|
|
|
deviceService.insertDevicepackage(devicepackageList);
|
|
|
|
|
|
|
|
|
|
List<DataSetBean.DeviceStorageBean> deviceStorageBeans = dataSetBean.getDeviceStorage();
|
|
|
|
|
List<Devicestorage> devicestorageList = new ArrayList<>();
|
|
|
|
|
for (DataSetBean.DeviceStorageBean deviceStorageBean : deviceStorageBeans) {
|
|
|
|
|
Devicestorage devicestorage = WarehousBeanUtils.responseToDevicestorage(deviceStorageBean);
|
|
|
|
|
devicestorage.setDevicerecordkey(device.getDevicerecordkey());
|
|
|
|
|
devicestorage.setUuid(uuid);
|
|
|
|
|
devicestorageList.add(devicestorage);
|
|
|
|
|
}
|
|
|
|
|
deviceService.insertDevicestorage(devicestorageList);
|
|
|
|
|
|
|
|
|
|
List<DataSetBean.ContactListBean> contactListBeans = dataSetBean.getContactList();
|
|
|
|
|
List<Contactlist> contactlistList = new ArrayList<>();
|
|
|
|
|
for (DataSetBean.ContactListBean contactListBean : contactListBeans) {
|
|
|
|
|
Contactlist contactlist = WarehousBeanUtils.responseToContactlist(contactListBean);
|
|
|
|
|
contactlist.setDevicerecordkey(device.getDevicerecordkey());
|
|
|
|
|
contactlist.setUuid(uuid);
|
|
|
|
|
contactlistList.add(contactlist);
|
|
|
|
|
}
|
|
|
|
|
deviceService.insertContactlist(contactlistList);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int downloadHistory(ProductInfoService productInfoService, DownloadHistoryRequest deviceHistoryRequest, DeviceService deviceService) {
|
|
|
|
|
public int downloadHistory(DownloadHistoryRequest deviceHistoryRequest) {
|
|
|
|
|
String response = HttpClient.post("sharing/history/get", deviceHistoryRequest);
|
|
|
|
|
MedicalHistoryResonse medicalResonse = (MedicalHistoryResonse) JSONObject.parseObject(response, MedicalHistoryResonse.class);
|
|
|
|
|
if (medicalResonse.getReturnCode() == 1) {
|
|
|
|
@ -296,7 +199,7 @@ public class DownloadDeviceHelper {
|
|
|
|
|
device.setUuid(uuid);
|
|
|
|
|
device.setLastModifyTime(DateUtil.formatDateTime(new Date()));
|
|
|
|
|
deviceService.insertDevice(device);
|
|
|
|
|
new UdiTransferUtils().transUdi(deviceService, productInfoService, uuid, udiCompanyService);
|
|
|
|
|
udiTransferUtils.transUdi(uuid);
|
|
|
|
|
List<DataSetBean.DeviceClinicalBean> deviceclinicals = dataSetBean.getDeviceClinical();
|
|
|
|
|
List<Deviceclinical> deviceclinicalList = new ArrayList<>();
|
|
|
|
|
for (DataSetBean.DeviceClinicalBean deviceClinicalBean : deviceclinicals) {
|
|
|
|
@ -406,7 +309,7 @@ public class DownloadDeviceHelper {
|
|
|
|
|
}
|
|
|
|
|
deviceService.insertContactlist(contactlistList);
|
|
|
|
|
|
|
|
|
|
new UdiTransferUtils().transUdi(deviceService, productInfoService, uuid, udiCompanyService);
|
|
|
|
|
udiTransferUtils.transUdi(uuid);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|