|
|
@ -0,0 +1,540 @@
|
|
|
|
|
|
|
|
package com.glxp.udidl.admin.service.dataUpdate;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
|
|
|
|
|
import com.glxp.udidl.admin.entity.udi.CountProductEntity;
|
|
|
|
|
|
|
|
import com.glxp.udidl.admin.entity.udi.ProductClassify;
|
|
|
|
|
|
|
|
import com.glxp.udidl.admin.entity.udi.ProductInfoEntity;
|
|
|
|
|
|
|
|
import com.glxp.udidl.admin.entity.udi.UdiCompanyEntity;
|
|
|
|
|
|
|
|
import com.glxp.udidl.admin.entity.udid.*;
|
|
|
|
|
|
|
|
import com.glxp.udidl.admin.req.ProductInfoFilterRequest;
|
|
|
|
|
|
|
|
import com.glxp.udidl.admin.req.UdiCompanyRequest;
|
|
|
|
|
|
|
|
import com.glxp.udidl.admin.res.udid.DataSetResult;
|
|
|
|
|
|
|
|
import com.glxp.udidl.admin.service.inout.DeviceService;
|
|
|
|
|
|
|
|
import com.glxp.udidl.admin.service.inout.ProductInfoService;
|
|
|
|
|
|
|
|
import com.glxp.udidl.admin.service.udi.ProductClassifyService;
|
|
|
|
|
|
|
|
import com.glxp.udidl.admin.service.udi.UdiCompanyService;
|
|
|
|
|
|
|
|
import com.glxp.udidl.admin.util.BeanUtils;
|
|
|
|
|
|
|
|
import com.glxp.udidl.admin.util.DateUtil;
|
|
|
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
|
|
|
import java.util.*;
|
|
|
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 同步数据存储
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
@Service
|
|
|
|
|
|
|
|
public class DeviceParseService {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
|
|
|
private DeviceService deviceService;
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
|
|
|
ProductClassifyService productClassifyService;
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
|
|
|
ProductInfoService productInfoService;
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
|
|
|
UdiCompanyService udiCompanyService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 存储设备信息
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @param dataSets
|
|
|
|
|
|
|
|
* @return 返回存储条数
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
public int DeviceSave(List<DataSetResult.DataSet> dataSets, Date requestDate) {
|
|
|
|
|
|
|
|
int result = 0;
|
|
|
|
|
|
|
|
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()) {
|
|
|
|
|
|
|
|
//1:判断数据是否存在
|
|
|
|
|
|
|
|
if (StrUtil.isNotEmpty(deviceService.selectDiIsSame(item.getZxxsdycpbs(), item.getVersionNumber() + "")))
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
Device device = responseToDevice(item);
|
|
|
|
|
|
|
|
String uuid = getUUId();
|
|
|
|
|
|
|
|
Boolean isHistory = false;
|
|
|
|
|
|
|
|
if (item.getDeviceHistoryKey() != null && !item.getDeviceHistoryKey().isEmpty()) {
|
|
|
|
|
|
|
|
isHistory = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
device.setUuid(uuid);
|
|
|
|
|
|
|
|
if (requestDate != null)
|
|
|
|
|
|
|
|
device.setRequestDate(requestDate);
|
|
|
|
|
|
|
|
//2,存储 deviceInfo
|
|
|
|
|
|
|
|
deviceService.updateDevice(device);
|
|
|
|
|
|
|
|
result++;
|
|
|
|
|
|
|
|
//3,存储ContactList
|
|
|
|
|
|
|
|
List<DataSetResult.ContactInfo> contactInfos = item.getContactList();
|
|
|
|
|
|
|
|
if (contactInfos != null && contactInfos.size() > 0) {
|
|
|
|
|
|
|
|
List<Contactlist> contactlistList = new ArrayList<>();
|
|
|
|
|
|
|
|
for (DataSetResult.ContactInfo contactInfo : contactInfos) {
|
|
|
|
|
|
|
|
Contactlist contactlist = responseToContactlist(contactInfo);
|
|
|
|
|
|
|
|
contactlist.setDevicerecordkey(device.getDevicerecordkey());
|
|
|
|
|
|
|
|
contactlist.setUuid(uuid);
|
|
|
|
|
|
|
|
contactlistList.add(contactlist);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
deviceService.updateContactlist(contactlistList);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//4,存储 Deviceclinical
|
|
|
|
|
|
|
|
if (ClinicalInfoAll != null && ClinicalInfoAll.size() > 0) {
|
|
|
|
|
|
|
|
List<DataSetResult.ClinicalInfo> deviceclinicals;
|
|
|
|
|
|
|
|
if (isHistory == true)
|
|
|
|
|
|
|
|
deviceclinicals = ClinicalInfoAll.stream().filter(p -> p.getDeviceHistoryKey().equals(item.getDeviceHistoryKey())).
|
|
|
|
|
|
|
|
collect(Collectors.toList());
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
deviceclinicals = ClinicalInfoAll.stream().filter(p -> p.getDeviceRecordKey().equals(item.getDeviceRecordKey())).
|
|
|
|
|
|
|
|
collect(Collectors.toList());
|
|
|
|
|
|
|
|
List<Deviceclinical> deviceclinicalList = new ArrayList<>();
|
|
|
|
|
|
|
|
if (deviceclinicals != null && deviceclinicals.size() > 0) {
|
|
|
|
|
|
|
|
for (DataSetResult.ClinicalInfo deviceClinical : deviceclinicals) {
|
|
|
|
|
|
|
|
Deviceclinical deviceclinical = responseToDeviceclinical(deviceClinical);
|
|
|
|
|
|
|
|
if (isHistory == true)
|
|
|
|
|
|
|
|
deviceclinical.setDevicerecordkey(item.getDeviceHistoryKey());
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
deviceclinical.setDevicerecordkey(device.getDevicerecordkey());
|
|
|
|
|
|
|
|
deviceclinical.setUuid(uuid);
|
|
|
|
|
|
|
|
deviceclinicalList.add(deviceclinical);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
deviceService.updateDeviceClinical(deviceclinicalList);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//5 存储 Devicestorage
|
|
|
|
|
|
|
|
if (storageInfoAll != null && storageInfoAll.size() > 0) {
|
|
|
|
|
|
|
|
List<DataSetResult.StorageInfo> storageInfos;
|
|
|
|
|
|
|
|
if (isHistory == true)
|
|
|
|
|
|
|
|
storageInfos = storageInfoAll.stream().filter(p -> p.getDeviceHistoryKey().equals(item.getDeviceHistoryKey())).
|
|
|
|
|
|
|
|
collect(Collectors.toList());
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
storageInfos = storageInfoAll.stream().filter(p -> p.getDeviceRecordKey().equals(item.getDeviceRecordKey())).
|
|
|
|
|
|
|
|
collect(Collectors.toList());
|
|
|
|
|
|
|
|
if (storageInfos != null && storageInfos.size() > 0) {
|
|
|
|
|
|
|
|
List<Devicestorage> devicestorageList = new ArrayList<>();
|
|
|
|
|
|
|
|
for (DataSetResult.StorageInfo storageInfo : storageInfos) {
|
|
|
|
|
|
|
|
Devicestorage devicestorage = responseToDevicestorage(storageInfo);
|
|
|
|
|
|
|
|
if (isHistory == true)
|
|
|
|
|
|
|
|
devicestorage.setDevicerecordkey(item.getDeviceHistoryKey());
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
devicestorage.setDevicerecordkey(device.getDevicerecordkey());
|
|
|
|
|
|
|
|
devicestorage.setUuid(uuid);
|
|
|
|
|
|
|
|
devicestorageList.add(devicestorage);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
deviceService.updateDevicestorage(devicestorageList);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//6 存储Devicepackage
|
|
|
|
|
|
|
|
if (packingInfoAll != null && packingInfoAll.size() > 0) {
|
|
|
|
|
|
|
|
List<DataSetResult.PackingInfo> packingInfos;
|
|
|
|
|
|
|
|
if (isHistory == true)
|
|
|
|
|
|
|
|
packingInfos = packingInfoAll.stream().filter(p -> p.getDeviceHistoryKey().equals(item.getDeviceHistoryKey())).
|
|
|
|
|
|
|
|
collect(Collectors.toList());
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
packingInfos = packingInfoAll.stream().filter(p -> p.getDeviceRecordKey().equals(item.getDeviceRecordKey())).
|
|
|
|
|
|
|
|
collect(Collectors.toList());
|
|
|
|
|
|
|
|
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.updateDevicepackage(devicepackageList);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//7存储productInfo信息
|
|
|
|
|
|
|
|
productInfoSave(uuid);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* device数据格式转换
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @param dataSetBean
|
|
|
|
|
|
|
|
* @return
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
private Device responseToDevice(DataSetResult.DeviceInfo dataSetBean) {
|
|
|
|
|
|
|
|
Device device = new Device();
|
|
|
|
|
|
|
|
BeanUtils.copyProperties(dataSetBean, device);
|
|
|
|
|
|
|
|
device.setDevicehistoryrecordkey(dataSetBean.getDeviceHistoryKey());
|
|
|
|
|
|
|
|
device.setDevicerecordkey(dataSetBean.getDeviceRecordKey());
|
|
|
|
|
|
|
|
device.setBtcpbs(dataSetBean.getBtcpbs());
|
|
|
|
|
|
|
|
device.setBtcpbsyzxxsdycpbssfyz(dataSetBean.getBtcpbsyzxxsdycpbssfyz());
|
|
|
|
|
|
|
|
device.setCgzmraqxgxx(dataSetBean.getCgzmraqxgxx());
|
|
|
|
|
|
|
|
device.setCpbsbmtxmc(dataSetBean.getCpbsbmtxmc());
|
|
|
|
|
|
|
|
device.setCpbsfbrq(dataSetBean.getCpbsfbrq());
|
|
|
|
|
|
|
|
device.setCphhhbh(dataSetBean.getCphhhbh());
|
|
|
|
|
|
|
|
device.setCplb(dataSetBean.getCplb());
|
|
|
|
|
|
|
|
device.setCpmctymc(dataSetBean.getCpmctymc());
|
|
|
|
|
|
|
|
device.setCpms(dataSetBean.getCpms());
|
|
|
|
|
|
|
|
device.setFlbm(dataSetBean.getFlbm());
|
|
|
|
|
|
|
|
device.setGgxh(dataSetBean.getGgxh());
|
|
|
|
|
|
|
|
device.setMjfs(dataSetBean.getMjfs());
|
|
|
|
|
|
|
|
device.setQtxxdwzlj(dataSetBean.getQtxxdwzlj());
|
|
|
|
|
|
|
|
device.setQxlb(dataSetBean.getQxlb());
|
|
|
|
|
|
|
|
device.setScbssfbhph(dataSetBean.getScbssfbhph());
|
|
|
|
|
|
|
|
device.setScbssfbhscrq(dataSetBean.getScbssfbhscrq());
|
|
|
|
|
|
|
|
device.setScbssfbhsxrq(dataSetBean.getScbssfbhsxrq());
|
|
|
|
|
|
|
|
device.setScbssfbhxlh(dataSetBean.getScbssfbhxlh());
|
|
|
|
|
|
|
|
device.setSfbjwycxsy(dataSetBean.getSfbjwycxsy());
|
|
|
|
|
|
|
|
device.setSfwblztlcp(dataSetBean.getSfwblztlcp());
|
|
|
|
|
|
|
|
device.setSfwwjbz(dataSetBean.getSfwwjbz());
|
|
|
|
|
|
|
|
device.setSfybtzjbs(dataSetBean.getSfybtzjbs());
|
|
|
|
|
|
|
|
device.setSpmc(dataSetBean.getSpmc());
|
|
|
|
|
|
|
|
device.setSydycpbs(dataSetBean.getSydycpbs());
|
|
|
|
|
|
|
|
device.setSyqsfxyjxmj(dataSetBean.getSyqsfxyjxmj());
|
|
|
|
|
|
|
|
device.setTscchcztj(dataSetBean.getTscchcztj());
|
|
|
|
|
|
|
|
device.setTsccsm(dataSetBean.getTsccsm());
|
|
|
|
|
|
|
|
device.setTsrq(dataSetBean.getTsrq());
|
|
|
|
|
|
|
|
device.setTyshxydm(dataSetBean.getTyshxydm());
|
|
|
|
|
|
|
|
device.setVersionnumber(dataSetBean.getVersionNumber() + "");
|
|
|
|
|
|
|
|
device.setVersionstatus(dataSetBean.getVersionStatus());
|
|
|
|
|
|
|
|
device.setVersiontime(dataSetBean.getVersionTime());
|
|
|
|
|
|
|
|
device.setYbbm(dataSetBean.getYbbm());
|
|
|
|
|
|
|
|
device.setYlqxzcrbarmc(dataSetBean.getYlqxzcrbarmc());
|
|
|
|
|
|
|
|
device.setYlqxzcrbarywmc(dataSetBean.getYlqxzcrbarywmc());
|
|
|
|
|
|
|
|
device.setZczbhhzbapzbh(getString(dataSetBean.getZczbhhzbapzbh()));
|
|
|
|
|
|
|
|
device.setZdcfsycs(dataSetBean.getZdcfsycs());
|
|
|
|
|
|
|
|
device.setYflbm(dataSetBean.getYflbm());
|
|
|
|
|
|
|
|
device.setZxxsdycpbs(dataSetBean.getZxxsdycpbs());
|
|
|
|
|
|
|
|
device.setBszt(dataSetBean.getBszt());
|
|
|
|
|
|
|
|
device.setSfyzcbayz(dataSetBean.getSfyzcbayz());
|
|
|
|
|
|
|
|
device.setZcbacpbs(dataSetBean.getZcbacpbs());
|
|
|
|
|
|
|
|
device.setZxxsdyzsydydsl(dataSetBean.getZxxsdyzsydydsl());
|
|
|
|
|
|
|
|
device.setBssjzt(dataSetBean.getBssjzt());
|
|
|
|
|
|
|
|
device.setLastModifyTime(DateUtil.formatDateTime(new Date()));
|
|
|
|
|
|
|
|
device.setCplx(dataSetBean.getCplx());
|
|
|
|
|
|
|
|
device.setHchzsb(dataSetBean.getHchzsb());
|
|
|
|
|
|
|
|
return device;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private Contactlist responseToContactlist(DataSetResult.ContactInfo contactInfo) {
|
|
|
|
|
|
|
|
Contactlist contactlist = new Contactlist();
|
|
|
|
|
|
|
|
contactlist.setQylxrcz(contactInfo.getQylxrcz());
|
|
|
|
|
|
|
|
contactlist.setQylxrdh(contactInfo.getQylxrdh());
|
|
|
|
|
|
|
|
contactlist.setQylxryx(contactInfo.getQylxryx());
|
|
|
|
|
|
|
|
return contactlist;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public Deviceclinical responseToDeviceclinical(DataSetResult.ClinicalInfo clinicalInfo) {
|
|
|
|
|
|
|
|
Deviceclinical deviceclinical = new Deviceclinical();
|
|
|
|
|
|
|
|
deviceclinical.setLcsycclx(clinicalInfo.getLcsycclx());
|
|
|
|
|
|
|
|
deviceclinical.setCcz(clinicalInfo.getCcz());
|
|
|
|
|
|
|
|
deviceclinical.setCcdw(clinicalInfo.getCcdw());
|
|
|
|
|
|
|
|
return deviceclinical;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public Devicestorage responseToDevicestorage(DataSetResult.StorageInfo storageInfo) {
|
|
|
|
|
|
|
|
Devicestorage devicestorage = new Devicestorage();
|
|
|
|
|
|
|
|
devicestorage.setCchcztj(storageInfo.getCchcztj());
|
|
|
|
|
|
|
|
devicestorage.setJldw(storageInfo.getJldw());
|
|
|
|
|
|
|
|
devicestorage.setZgz(storageInfo.getZgz());
|
|
|
|
|
|
|
|
devicestorage.setZdz(storageInfo.getZdz());
|
|
|
|
|
|
|
|
return devicestorage;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public Devicepackage responseToDevicepackage(DataSetResult.PackingInfo packingInfo) {
|
|
|
|
|
|
|
|
Devicepackage devicepackage = new Devicepackage();
|
|
|
|
|
|
|
|
devicepackage.setBzcpbs(packingInfo.getBzcpbs());
|
|
|
|
|
|
|
|
devicepackage.setBznhxyjbzcpbs(packingInfo.getBznhxyjbzcpbs());
|
|
|
|
|
|
|
|
devicepackage.setCpbzjb(packingInfo.getCpbzjb());
|
|
|
|
|
|
|
|
//devicepackage.setBznhxyjcpbssl(Integer.parseInt(packingInfo.getBznhxyjcpbssl()));
|
|
|
|
|
|
|
|
devicepackage.setBznhxyjcpbssl(getInteger(packingInfo.getBznhxyjcpbssl()));
|
|
|
|
|
|
|
|
return devicepackage;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void productInfoSave(String uuid) {
|
|
|
|
|
|
|
|
transUdi(uuid);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private String getUUId() {
|
|
|
|
|
|
|
|
UUID uuid = UUID.randomUUID();
|
|
|
|
|
|
|
|
return uuid.toString().replace("-", "");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private String getString(String s) {
|
|
|
|
|
|
|
|
if (s != null && s != "")
|
|
|
|
|
|
|
|
return s.length() > 255 ? s.substring(0, 255) : s;
|
|
|
|
|
|
|
|
else return s;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private Integer getInteger(String s) {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
return Integer.parseInt(s);
|
|
|
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void transUdi(String key) {
|
|
|
|
|
|
|
|
DeviceEntity deviceEntity = deviceService.searchById(key);
|
|
|
|
|
|
|
|
String di = deviceEntity.getZxxsdycpbs();
|
|
|
|
|
|
|
|
ProductInfoEntity productInfoEntity = new ProductInfoEntity();
|
|
|
|
|
|
|
|
org.springframework.beans.BeanUtils.copyProperties(deviceEntity, productInfoEntity);
|
|
|
|
|
|
|
|
productInfoEntity.setUuid(key);
|
|
|
|
|
|
|
|
productInfoEntity.setDeviceRecordKey(deviceEntity.getDevicerecordkey());
|
|
|
|
|
|
|
|
productInfoEntity.setNameCode(deviceEntity.getZxxsdycpbs());
|
|
|
|
|
|
|
|
productInfoEntity.setCpmctymc(deviceEntity.getCpmctymc());
|
|
|
|
|
|
|
|
productInfoEntity.setCplb(deviceEntity.getCplb());
|
|
|
|
|
|
|
|
productInfoEntity.setFlbm(deviceEntity.getFlbm());
|
|
|
|
|
|
|
|
productInfoEntity.setGgxh(deviceEntity.getGgxh());
|
|
|
|
|
|
|
|
productInfoEntity.setQxlb(deviceEntity.getQxlb());
|
|
|
|
|
|
|
|
productInfoEntity.setTyshxydm(deviceEntity.getTyshxydm());
|
|
|
|
|
|
|
|
productInfoEntity.setYlqxzcrbarmc(deviceEntity.getYlqxzcrbarmc());
|
|
|
|
|
|
|
|
productInfoEntity.setZczbhhzbapzbh(deviceEntity.getZczbhhzbapzbh());
|
|
|
|
|
|
|
|
productInfoEntity.setScbssfbhph(deviceEntity.getScbssfbhph());
|
|
|
|
|
|
|
|
productInfoEntity.setScbssfbhscrq(deviceEntity.getScbssfbhscrq());
|
|
|
|
|
|
|
|
productInfoEntity.setScbssfbhsxrq(deviceEntity.getScbssfbhsxrq());
|
|
|
|
|
|
|
|
productInfoEntity.setScbssfbhxlh(deviceEntity.getScbssfbhxlh());
|
|
|
|
|
|
|
|
productInfoEntity.setBhxjsl(0);
|
|
|
|
|
|
|
|
productInfoEntity.setPackLevel(1 + "");
|
|
|
|
|
|
|
|
productInfoEntity.setBhxjcpbm("");
|
|
|
|
|
|
|
|
productInfoEntity.setBhzxxsbzsl(0);
|
|
|
|
|
|
|
|
productInfoEntity.setZxxsbzbhsydysl(0);
|
|
|
|
|
|
|
|
productInfoEntity.setScbssfbhxlh(deviceEntity.getScbssfbhxlh());
|
|
|
|
|
|
|
|
productInfoEntity.setYbbm(deviceEntity.getYbbm());
|
|
|
|
|
|
|
|
productInfoEntity.setSpmc(deviceEntity.getSpmc());
|
|
|
|
|
|
|
|
productInfoEntity.setCphhhbh(deviceEntity.getCphhhbh());
|
|
|
|
|
|
|
|
productInfoEntity.setCpms(deviceEntity.getCpms());
|
|
|
|
|
|
|
|
productInfoEntity.setCpbsbmtxmc(deviceEntity.getCpbsbmtxmc());
|
|
|
|
|
|
|
|
productInfoEntity.setCplx(deviceEntity.getCplx());
|
|
|
|
|
|
|
|
productInfoEntity.setHchzsb(deviceEntity.getHchzsb());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (StrUtil.trimToEmpty(productInfoEntity.getSfwblztlcp()).equals("1")) {
|
|
|
|
|
|
|
|
productInfoEntity.setSfwblztlcp("是");
|
|
|
|
|
|
|
|
} else if (StrUtil.trimToEmpty(productInfoEntity.getSfwblztlcp()).equals("0")) {
|
|
|
|
|
|
|
|
productInfoEntity.setSfwblztlcp("否");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (StrUtil.trimToEmpty(productInfoEntity.getCgzmraqxgxx()).equals("0")) {
|
|
|
|
|
|
|
|
productInfoEntity.setCgzmraqxgxx("安全");
|
|
|
|
|
|
|
|
} else if (StrUtil.trimToEmpty(productInfoEntity.getCgzmraqxgxx()).equals("1")) {
|
|
|
|
|
|
|
|
productInfoEntity.setCgzmraqxgxx("条件安全");
|
|
|
|
|
|
|
|
} else if (StrUtil.trimToEmpty(productInfoEntity.getCgzmraqxgxx()).equals("2")) {
|
|
|
|
|
|
|
|
productInfoEntity.setCgzmraqxgxx("说明书或标签上面不包括 MR 安全信息");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (StrUtil.trimToEmpty(productInfoEntity.getSfwwjbz()).equals("1")) {
|
|
|
|
|
|
|
|
productInfoEntity.setSfwwjbz("是");
|
|
|
|
|
|
|
|
} else if (StrUtil.trimToEmpty(productInfoEntity.getSfwwjbz()).equals("0")) {
|
|
|
|
|
|
|
|
productInfoEntity.setSfwwjbz("否");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (StrUtil.trimToEmpty(productInfoEntity.getSyqsfxyjxmj()).equals("1")) {
|
|
|
|
|
|
|
|
productInfoEntity.setSyqsfxyjxmj("是");
|
|
|
|
|
|
|
|
} else if (StrUtil.trimToEmpty(productInfoEntity.getSyqsfxyjxmj()).equals("0")) {
|
|
|
|
|
|
|
|
productInfoEntity.setSyqsfxyjxmj("否");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ProductClassify productClassifyEntity = productClassifyService.findByCode(productInfoEntity.getFlbm(), productInfoEntity.getCplx());
|
|
|
|
|
|
|
|
productInfoEntity.setCategoryName(productClassifyEntity.getName());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
productInfoEntity.setVersionNumber(Integer.parseInt(deviceEntity.getVersionnumber()));
|
|
|
|
|
|
|
|
if (deviceEntity.getSydycpbs() != null && !deviceEntity.getSydycpbs().equals("")) {
|
|
|
|
|
|
|
|
productInfoEntity.setBhxjcpbm("");
|
|
|
|
|
|
|
|
productInfoEntity.setBhxjsl(0);
|
|
|
|
|
|
|
|
productInfoEntity.setBzcj("");
|
|
|
|
|
|
|
|
productInfoEntity.setBhzxxsbzsl(0);
|
|
|
|
|
|
|
|
productInfoEntity.setPackLevel(1 + "");
|
|
|
|
|
|
|
|
productInfoEntity.setAddType(1 + "");
|
|
|
|
|
|
|
|
productInfoEntity.setZxxsbzbhsydysl(0);
|
|
|
|
|
|
|
|
productInfoEntity.setDiType(2);
|
|
|
|
|
|
|
|
productInfoEntity.setNameCode(deviceEntity.getSydycpbs());
|
|
|
|
|
|
|
|
productInfoEntity.setSjcpbm(deviceEntity.getZxxsdycpbs());
|
|
|
|
|
|
|
|
productInfoEntity.setUpdateTime(new Date());
|
|
|
|
|
|
|
|
productInfoService.insertProductInfo(productInfoEntity);
|
|
|
|
|
|
|
|
productInfoEntity.setBhxjcpbm(deviceEntity.getSydycpbs());
|
|
|
|
|
|
|
|
productInfoEntity.setBhxjsl(1);
|
|
|
|
|
|
|
|
productInfoEntity.setPackLevel(2 + "");
|
|
|
|
|
|
|
|
productInfoEntity.setZxxsbzbhsydysl(1);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else if (deviceEntity.getBtcpbs() != null && !deviceEntity.getBtcpbs().equals("")) {
|
|
|
|
|
|
|
|
productInfoEntity.setBhxjcpbm("");
|
|
|
|
|
|
|
|
productInfoEntity.setBhxjsl(0);
|
|
|
|
|
|
|
|
productInfoEntity.setBzcj("");
|
|
|
|
|
|
|
|
productInfoEntity.setBhzxxsbzsl(0);
|
|
|
|
|
|
|
|
productInfoEntity.setPackLevel(1 + "");
|
|
|
|
|
|
|
|
productInfoEntity.setAddType(1 + "");
|
|
|
|
|
|
|
|
productInfoEntity.setZxxsbzbhsydysl(0);
|
|
|
|
|
|
|
|
productInfoEntity.setDiType(3);
|
|
|
|
|
|
|
|
productInfoEntity.setSjcpbm(deviceEntity.getZxxsdycpbs());
|
|
|
|
|
|
|
|
productInfoEntity.setNameCode(deviceEntity.getBtcpbs());
|
|
|
|
|
|
|
|
productInfoEntity.setUpdateTime(new Date());
|
|
|
|
|
|
|
|
productInfoService.insertProductInfo(productInfoEntity);
|
|
|
|
|
|
|
|
productInfoEntity.setBhxjcpbm(deviceEntity.getBtcpbs());
|
|
|
|
|
|
|
|
productInfoEntity.setBhxjsl(1);
|
|
|
|
|
|
|
|
productInfoEntity.setPackLevel(2 + "");
|
|
|
|
|
|
|
|
productInfoEntity.setZxxsbzbhsydysl(1);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
productInfoEntity.setDiType(1);
|
|
|
|
|
|
|
|
productInfoEntity.setBzcj("");
|
|
|
|
|
|
|
|
productInfoEntity.setAddType(1 + "");
|
|
|
|
|
|
|
|
productInfoEntity.setNameCode(deviceEntity.getZxxsdycpbs());
|
|
|
|
|
|
|
|
if (deviceEntity.getZxxsdyzsydydsl() != null && !deviceEntity.getZxxsdyzsydydsl().equals("") && Integer.parseInt(deviceEntity.getZxxsdyzsydydsl()) > 1) {
|
|
|
|
|
|
|
|
productInfoEntity.setZxxsbzbhsydysl(Integer.parseInt(deviceEntity.getZxxsdyzsydydsl()));
|
|
|
|
|
|
|
|
productInfoEntity.setBhxjsl(Integer.parseInt(deviceEntity.getZxxsdyzsydydsl()));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
List<Devicepackage> devicepackages = deviceEntity.getDevicepackages();
|
|
|
|
|
|
|
|
productInfoEntity.setSjcpbm(getSjcpbm(devicepackages, productInfoEntity.getNameCode()));
|
|
|
|
|
|
|
|
productInfoEntity.setUpdateTime(new Date());
|
|
|
|
|
|
|
|
productInfoService.insertProductInfo(productInfoEntity);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<CountProductEntity> countProductEntities = new ArrayList<>();
|
|
|
|
|
|
|
|
int curLevel = Integer.parseInt(productInfoEntity.getPackLevel()) + 1;
|
|
|
|
|
|
|
|
if (devicepackages != null && devicepackages.size() > 0) {
|
|
|
|
|
|
|
|
HashMap<String, String> packRation = new HashMap<>();
|
|
|
|
|
|
|
|
for (Devicepackage devicepackage : devicepackages) {
|
|
|
|
|
|
|
|
CountProductEntity countProductEntity = new CountProductEntity();
|
|
|
|
|
|
|
|
Devicepackage head = devicepackage;
|
|
|
|
|
|
|
|
//包装层级,初始为2,最小销售单元为1
|
|
|
|
|
|
|
|
int level = curLevel;
|
|
|
|
|
|
|
|
int zxbsCount = devicepackage.getBznhxyjcpbssl(); //最小销售单元数量
|
|
|
|
|
|
|
|
int count = 1; //计数,如果计数超过包装标识层级,就是死循环,包装标识有误
|
|
|
|
|
|
|
|
while (!head.getBznhxyjbzcpbs().equals(deviceEntity.getZxxsdycpbs())) {
|
|
|
|
|
|
|
|
head = getNext(devicepackages, head);
|
|
|
|
|
|
|
|
if (head == null) {
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
count++;
|
|
|
|
|
|
|
|
if (count > devicepackages.size()) {
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
level++;
|
|
|
|
|
|
|
|
zxbsCount = zxbsCount * head.getBznhxyjcpbssl();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
packRation.put(level - 1 + "", devicepackage.getBznhxyjcpbssl() + "");
|
|
|
|
|
|
|
|
countProductEntity.setLevel(level);
|
|
|
|
|
|
|
|
countProductEntity.setZxbsCount(zxbsCount);
|
|
|
|
|
|
|
|
countProductEntities.add(countProductEntity);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
CountProductEntity max = getMaxLevel(countProductEntities);
|
|
|
|
|
|
|
|
packRation.put(max.getLevel() + "", max.getZxbsCount() + "");
|
|
|
|
|
|
|
|
for (int i = 0; i < devicepackages.size(); i++) {
|
|
|
|
|
|
|
|
Devicepackage devicepackage = devicepackages.get(i);
|
|
|
|
|
|
|
|
CountProductEntity countProductEntity = countProductEntities.get(i);
|
|
|
|
|
|
|
|
productInfoEntity.setNameCode(devicepackage.getBzcpbs());
|
|
|
|
|
|
|
|
productInfoEntity.setBhxjcpbm(devicepackage.getBznhxyjbzcpbs());
|
|
|
|
|
|
|
|
productInfoEntity.setBhxjsl(devicepackage.getBznhxyjcpbssl());
|
|
|
|
|
|
|
|
productInfoEntity.setBzcj(devicepackage.getCpbzjb());
|
|
|
|
|
|
|
|
productInfoEntity.setBhzxxsbzsl(countProductEntity.getZxbsCount());
|
|
|
|
|
|
|
|
productInfoEntity.setPackLevel(countProductEntity.getLevel() + "");
|
|
|
|
|
|
|
|
productInfoEntity.setSjcpbm(getSjcpbm(devicepackages, productInfoEntity.getNameCode()));
|
|
|
|
|
|
|
|
productInfoEntity.setDiType(4);
|
|
|
|
|
|
|
|
productInfoEntity.setUpdateTime(new Date());
|
|
|
|
|
|
|
|
productInfoService.insertProductInfo(productInfoEntity);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//更新为最新版本
|
|
|
|
|
|
|
|
ProductInfoFilterRequest filterRequest1 = new ProductInfoFilterRequest();
|
|
|
|
|
|
|
|
filterRequest1.setNameCode(di);
|
|
|
|
|
|
|
|
List<ProductInfoEntity> updateEntitys = productInfoService.filterUdi(filterRequest1);
|
|
|
|
|
|
|
|
if (updateEntitys != null && updateEntitys.size() > 0) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//获取最高版本号
|
|
|
|
|
|
|
|
ProductInfoEntity updateEntity = updateEntitys.get(0);
|
|
|
|
|
|
|
|
for (ProductInfoEntity tempEntity : updateEntitys) {
|
|
|
|
|
|
|
|
if (tempEntity.getVersionNumber() > updateEntity.getVersionNumber()) {
|
|
|
|
|
|
|
|
updateEntity = tempEntity;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ProductInfoFilterRequest filterRequest = new ProductInfoFilterRequest();
|
|
|
|
|
|
|
|
filterRequest.setDeviceRecordKey(updateEntity.getDeviceRecordKey());
|
|
|
|
|
|
|
|
List<ProductInfoEntity> temps = productInfoService.filterProductInfo(filterRequest);
|
|
|
|
|
|
|
|
if (temps != null && temps.size() > 0) {
|
|
|
|
|
|
|
|
for (ProductInfoEntity change : temps) {
|
|
|
|
|
|
|
|
change.setIsNewest(false);
|
|
|
|
|
|
|
|
change.setUpdateTime(new Date());
|
|
|
|
|
|
|
|
productInfoService.updateProductInfo(change);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<ProductInfoEntity> updates = productInfoService.selectByUuid(updateEntity.getUuid());
|
|
|
|
|
|
|
|
for (ProductInfoEntity update : updates) {
|
|
|
|
|
|
|
|
update.setIsNewest(true);
|
|
|
|
|
|
|
|
update.setUpdateTime(new Date());
|
|
|
|
|
|
|
|
productInfoService.updateProductInfo(update);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//更新厂家信息,
|
|
|
|
|
|
|
|
UdiCompanyRequest udiCompanyRequest = new UdiCompanyRequest();
|
|
|
|
|
|
|
|
udiCompanyRequest.setTyshxydm(productInfoEntity.getTyshxydm());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (StrUtil.isNotEmpty(udiCompanyRequest.getTyshxydm())) {
|
|
|
|
|
|
|
|
List<UdiCompanyEntity> udiCompanyEntitys = udiCompanyService.filterUdiCompany(udiCompanyRequest);
|
|
|
|
|
|
|
|
if (udiCompanyEntitys == null || udiCompanyEntitys.size() == 0) {
|
|
|
|
|
|
|
|
UdiCompanyEntity udiCompanyEntity = new UdiCompanyEntity();
|
|
|
|
|
|
|
|
udiCompanyEntity.setTyshxydm(productInfoEntity.getTyshxydm());
|
|
|
|
|
|
|
|
udiCompanyEntity.setUpdateTime(new Date());
|
|
|
|
|
|
|
|
udiCompanyEntity.setYlqxzcrbarywmc(productInfoEntity.getYlqxzcrbarywmc());
|
|
|
|
|
|
|
|
udiCompanyEntity.setYlqxzcrbarmc(productInfoEntity.getYlqxzcrbarmc());
|
|
|
|
|
|
|
|
List<Contactlist> contactlists = udiCompanyService.selectContactBykey(productInfoEntity.getDeviceRecordKey());
|
|
|
|
|
|
|
|
if (contactlists != null && contactlists.size() > 0) {
|
|
|
|
|
|
|
|
udiCompanyEntity.setQylxrcz(contactlists.get(0).getQylxrcz());
|
|
|
|
|
|
|
|
udiCompanyEntity.setQylxrdh(contactlists.get(0).getQylxrdh());
|
|
|
|
|
|
|
|
udiCompanyEntity.setQylxryx(contactlists.get(0).getQylxryx());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
udiCompanyEntity.setUpdateTime(new Date());
|
|
|
|
|
|
|
|
udiCompanyService.insertUdiCompany(udiCompanyEntity);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public String getSjcpbm(List<Devicepackage> devicepackages, String nameCode) {
|
|
|
|
|
|
|
|
String sjcpbs = "";
|
|
|
|
|
|
|
|
if (devicepackages != null && devicepackages.size() > 0) {
|
|
|
|
|
|
|
|
for (Devicepackage devicepackage : devicepackages) {
|
|
|
|
|
|
|
|
if (devicepackage.getBznhxyjbzcpbs() != null && devicepackage.getBznhxyjbzcpbs().equals(nameCode)) {
|
|
|
|
|
|
|
|
sjcpbs = sjcpbs + "," + devicepackage.getBzcpbs();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sjcpbs.length() > 1)
|
|
|
|
|
|
|
|
return sjcpbs.substring(1);
|
|
|
|
|
|
|
|
return sjcpbs;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public CountProductEntity getMaxLevel(List<CountProductEntity> countProductEntities) {
|
|
|
|
|
|
|
|
int index = 0;
|
|
|
|
|
|
|
|
int max = 0;
|
|
|
|
|
|
|
|
for (int i = 0; i < countProductEntities.size(); i++) {
|
|
|
|
|
|
|
|
CountProductEntity countProductEntity = countProductEntities.get(i);
|
|
|
|
|
|
|
|
if (countProductEntity.getZxbsCount() > max) {
|
|
|
|
|
|
|
|
max = countProductEntity.getZxbsCount();
|
|
|
|
|
|
|
|
index = i;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return countProductEntities.get(index);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public Devicepackage getNext(List<Devicepackage> devicepackages, Devicepackage devicepackage) {
|
|
|
|
|
|
|
|
if (devicepackages != null && devicepackages.size() > 0) {
|
|
|
|
|
|
|
|
for (int i = 0; i < devicepackages.size(); i++) {
|
|
|
|
|
|
|
|
Devicepackage temp = devicepackages.get(i);
|
|
|
|
|
|
|
|
if (temp.getBzcpbs().equals(devicepackage.getBznhxyjbzcpbs())) {
|
|
|
|
|
|
|
|
return temp;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return null;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|