| | |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.DigestUtils; |
| | | |
| | | import java.io.File; |
| | | import java.io.IOException; |
| | | import java.io.InputStream; |
| | | import java.text.SimpleDateFormat; |
| | |
| | | String updateTime = ""; |
| | | try { |
| | | // 1、读取基础表结构SQL |
| | | Resource resource = resourceLoader.getResource("classpath:template//imageServer_template.sql"); |
| | | Resource resource = resourceLoader.getResource("classpath:template"+ File.separator+"imageServer_template.sql"); |
| | | fileImput = resource.getInputStream(); //new FileInputStream("./template/imageServer_template.sql"); |
| | | dbSql = FileUtils.readFile(fileImput); |
| | | if (fileImput != null) { |
| | | dbSql = FileUtils.readFile(fileImput); |
| | | |
| | | // 2、读取医院信息表Hospital_Info,插入SQL文中 |
| | | Map<String, Object> hospitalMap = new HashMap<>(); |
| | | hospitalMap.put("id", partnerDockingInfo.getHospitalId()); |
| | | ResultBody hospitalResult = sysHospitalService.findAllByMap(hospitalMap); |
| | | // 2、读取医院信息表Hospital_Info,插入SQL文中 |
| | | Map<String, Object> hospitalMap = new HashMap<>(); |
| | | hospitalMap.put("id", partnerDockingInfo.getHospitalId()); |
| | | ResultBody hospitalResult = sysHospitalService.findAllByMap(hospitalMap); |
| | | |
| | | if (hospitalResult.isOk()) { |
| | | String jsonData = JSONObject.toJSONString(hospitalResult.getData()); |
| | | List<SysHospital> hospitalLists = JSONObject.parseArray(jsonData, SysHospital.class); |
| | | if (hospitalLists.size() > 0) { |
| | | SysHospital hospitalInfo = hospitalLists.get(0); |
| | | createTime = "'" + dateTimeFormat.format(hospitalInfo.getCreateTime()) + "'"; |
| | | updateTime = (hospitalInfo.getUpdateTime() == null) ? "NULL" : "'" + dateTimeFormat.format(hospitalInfo.getUpdateTime())+ "'"; |
| | | hospitalSQL = " INSERT INTO sys_hospital VALUES (" + |
| | | hospitalInfo.getId() + ", " + |
| | | "'" + hospitalInfo.getHospitalName() + "', " + |
| | | "'" + hospitalInfo.getHospitalShortName() + "', " + |
| | | "'" + hospitalInfo.getHospitalCode() + "', " + |
| | | "'" + hospitalInfo.getHospitalTypeId() + "', " + |
| | | "'" + hospitalInfo.getHospitalTypeName() + "', " + |
| | | "'" + hospitalInfo.getHospitalTel() + "', " + |
| | | "'" + hospitalInfo.getHospitalProvince() + "', " + |
| | | "'" + hospitalInfo.getHospitalCity() + "', " + |
| | | "'" + hospitalInfo.getHospitalArea() + "', " + |
| | | "'" + hospitalInfo.getAreaCode() + "', " + |
| | | "'" + hospitalInfo.getHospitalLink() + "', " + |
| | | "'" + hospitalInfo.getHospitalAdress() + "', " + |
| | | "'" + hospitalInfo.getLatitude() + "', " + |
| | | "'" + hospitalInfo.getLongitude() + "', " + |
| | | "'" + hospitalInfo.getHospitalQualifiedId() + "', " + |
| | | "'" + hospitalInfo.getHospitalQualifiedName() + "', " + |
| | | "NULL," + |
| | | "NULL," + |
| | | "NULL," + |
| | | "'" + hospitalInfo.getHospitalAbout() + "', " + |
| | | hospitalInfo.getHospitalState() + ", " + |
| | | hospitalInfo.getEnabled() + ", " + |
| | | hospitalInfo.getIsDel() + ", " + |
| | | hospitalInfo.getCreateUserId() + ", " + |
| | | "'" + hospitalInfo.getCreateUserName() + "', " + |
| | | hospitalInfo.getUpdateUserId() + ", " + |
| | | "'" + hospitalInfo.getUpdateUserName() + "', " + |
| | | createTime + ", " + |
| | | updateTime + " " + |
| | | ");\n\r"; |
| | | if (hospitalResult.isOk()) { |
| | | String jsonData = JSONObject.toJSONString(hospitalResult.getData()); |
| | | List<SysHospital> hospitalLists = JSONObject.parseArray(jsonData, SysHospital.class); |
| | | if (hospitalLists.size() > 0) { |
| | | SysHospital hospitalInfo = hospitalLists.get(0); |
| | | createTime = "'" + dateTimeFormat.format(hospitalInfo.getCreateTime()) + "'"; |
| | | updateTime = (hospitalInfo.getUpdateTime() == null) ? "NULL" : "'" + dateTimeFormat.format(hospitalInfo.getUpdateTime()) + "'"; |
| | | hospitalSQL = " INSERT INTO sys_hospital VALUES (" + |
| | | hospitalInfo.getId() + ", " + |
| | | "'" + hospitalInfo.getHospitalName() + "', " + |
| | | "'" + hospitalInfo.getHospitalShortName() + "', " + |
| | | "'" + hospitalInfo.getHospitalCode() + "', " + |
| | | "'" + hospitalInfo.getHospitalTypeId() + "', " + |
| | | "'" + hospitalInfo.getHospitalTypeName() + "', " + |
| | | "'" + hospitalInfo.getHospitalTel() + "', " + |
| | | "'" + hospitalInfo.getHospitalProvince() + "', " + |
| | | "'" + hospitalInfo.getHospitalCity() + "', " + |
| | | "'" + hospitalInfo.getHospitalArea() + "', " + |
| | | "'" + hospitalInfo.getAreaCode() + "', " + |
| | | "'" + hospitalInfo.getHospitalLink() + "', " + |
| | | "'" + hospitalInfo.getHospitalAdress() + "', " + |
| | | "'" + hospitalInfo.getLatitude() + "', " + |
| | | "'" + hospitalInfo.getLongitude() + "', " + |
| | | "'" + hospitalInfo.getHospitalQualifiedId() + "', " + |
| | | "'" + hospitalInfo.getHospitalQualifiedName() + "', " + |
| | | "NULL," + |
| | | "NULL," + |
| | | "NULL," + |
| | | "'" + hospitalInfo.getHospitalAbout() + "', " + |
| | | hospitalInfo.getHospitalState() + ", " + |
| | | hospitalInfo.getEnabled() + ", " + |
| | | hospitalInfo.getIsDel() + ", " + |
| | | hospitalInfo.getCreateUserId() + ", " + |
| | | "'" + hospitalInfo.getCreateUserName() + "', " + |
| | | hospitalInfo.getUpdateUserId() + ", " + |
| | | "'" + hospitalInfo.getUpdateUserName() + "', " + |
| | | createTime + ", " + |
| | | updateTime + " " + |
| | | ");\n\r"; |
| | | } else { |
| | | return "医院信息读取失败,请重新生成SQL!"; |
| | | } |
| | | } else { |
| | | return "医院信息读取失败,请重新生成SQL!"; |
| | | } |
| | | } else { |
| | | return "医院信息读取失败,请重新生成SQL!"; |
| | | } |
| | | |
| | | // 3、读取科室信息表Department_Info,生成SQL文 |
| | | departmentSQL = "INSERT INTO sys_department VALUES (" + |
| | | +partnerDockingInfo.getDepartmentId() + ", " + |
| | | "'" + partnerDockingInfo.getDepartmentName() + "', " + |
| | | +partnerDockingInfo.getHospitalId() + ", " + |
| | | "0, 1, 0, '喜高科技', 0 , '喜高科技', " + |
| | | "'" + DateTime.now().toString() + "', " + |
| | | "'" + DateTime.now().toString() + "', " + |
| | | "6 " + |
| | | ");\n\r"; |
| | | // 4、读取医生信息表Doctor_Info,生成SQL文 |
| | | Map<String, Object> doctorMap = new HashMap<>(); |
| | | doctorMap.put("hospital_id", partnerDockingInfo.getHospitalId()); |
| | | doctorMap.put("department_id", partnerDockingInfo.getDepartmentId()); |
| | | doctorMap.put("is_admin_user", 1); |
| | | ResultBody doctorResult = sysDoctorService.getListByMap(doctorMap); |
| | | // 3、读取科室信息表Department_Info,生成SQL文 |
| | | departmentSQL = "INSERT INTO sys_department VALUES (" + |
| | | +partnerDockingInfo.getDepartmentId() + ", " + |
| | | "'" + partnerDockingInfo.getDepartmentName() + "', " + |
| | | +partnerDockingInfo.getHospitalId() + ", " + |
| | | "0, 1, 0, '喜高科技', 0 , '喜高科技', " + |
| | | "'" + DateTime.now().toString() + "', " + |
| | | "'" + DateTime.now().toString() + "', " + |
| | | "6 " + |
| | | ");\n\r"; |
| | | // 4、读取医生信息表Doctor_Info,生成SQL文 |
| | | Map<String, Object> doctorMap = new HashMap<>(); |
| | | doctorMap.put("hospital_id", partnerDockingInfo.getHospitalId()); |
| | | doctorMap.put("department_id", partnerDockingInfo.getDepartmentId()); |
| | | doctorMap.put("is_admin_user", 1); |
| | | ResultBody doctorResult = sysDoctorService.getListByMap(doctorMap); |
| | | |
| | | if (doctorResult.isOk()) { |
| | | String jsonData = JSONObject.toJSONString(doctorResult.getData()); |
| | | List<SysDoctor> doctorList = JSONObject.parseArray(jsonData, SysDoctor.class); |
| | | if (doctorList.size() > 0) { |
| | | SysDoctor doctorInfo = doctorList.get(0); |
| | | doctorSQL = "INSERT INTO sys_doctor VALUES(" + |
| | | doctorInfo.getId() + ", " + |
| | | +doctorInfo.getHospitalId() + ", " + |
| | | "'" + doctorInfo.getHospitalName() + "', " + |
| | | +doctorInfo.getDepartmentId() + ", " + |
| | | "'" + doctorInfo.getDepartmentName() + "', " + |
| | | "'" + doctorInfo.getDoctorName() + "', " + |
| | | "NULL, NULL, " + |
| | | "'" + doctorInfo.getDoctorTel() + "', " + |
| | | "'" + DigestUtils.md5DigestAsHex("123456".getBytes()).replace("-", "") + "', " + |
| | | "'" + doctorInfo.getDoctorRankId() + "', " + |
| | | "'" + doctorInfo.getDoctorRank() + "', " + |
| | | "'" + doctorInfo.getDoctorOtherLink() + "', " + |
| | | "'" + doctorInfo.getDoctorEmail() + "', " + |
| | | "'" + doctorInfo.getDoctorAbout() + "', " + |
| | | "0, " + |
| | | doctorInfo.getDoctorState() + ", " + |
| | | doctorInfo.getDoctorType() + ", " + |
| | | "1, 0, '喜高科技', 0 , '喜高科技', " + |
| | | "'" + DateTime.now().toString() + "', " + |
| | | "'" + DateTime.now().toString() + "', " + |
| | | "1" + |
| | | ");\n\r"; |
| | | if (doctorResult.isOk()) { |
| | | String jsonData = JSONObject.toJSONString(doctorResult.getData()); |
| | | List<SysDoctor> doctorList = JSONObject.parseArray(jsonData, SysDoctor.class); |
| | | if (doctorList.size() > 0) { |
| | | SysDoctor doctorInfo = doctorList.get(0); |
| | | doctorSQL = "INSERT INTO sys_doctor VALUES(" + |
| | | doctorInfo.getId() + ", " + |
| | | +doctorInfo.getHospitalId() + ", " + |
| | | "'" + doctorInfo.getHospitalName() + "', " + |
| | | +doctorInfo.getDepartmentId() + ", " + |
| | | "'" + doctorInfo.getDepartmentName() + "', " + |
| | | "'" + doctorInfo.getDoctorName() + "', " + |
| | | "NULL, NULL, " + |
| | | "'" + doctorInfo.getDoctorTel() + "', " + |
| | | "'" + DigestUtils.md5DigestAsHex("123456".getBytes()).replace("-", "") + "', " + |
| | | "'" + doctorInfo.getDoctorRankId() + "', " + |
| | | "'" + doctorInfo.getDoctorRank() + "', " + |
| | | "'" + doctorInfo.getDoctorOtherLink() + "', " + |
| | | "'" + doctorInfo.getDoctorEmail() + "', " + |
| | | "'" + doctorInfo.getDoctorAbout() + "', " + |
| | | "0, " + |
| | | doctorInfo.getDoctorState() + ", " + |
| | | doctorInfo.getDoctorType() + ", " + |
| | | "1, 0, '喜高科技', 0 , '喜高科技', " + |
| | | "'" + DateTime.now().toString() + "', " + |
| | | "'" + DateTime.now().toString() + "', " + |
| | | "1" + |
| | | ");\n\r"; |
| | | } else { |
| | | return "医生信息读取失败,请先创建管理员,再重新生成SQL!"; |
| | | } |
| | | } else { |
| | | return "医生信息读取失败,请先创建管理员,再重新生成SQL!"; |
| | | } |
| | | } else { |
| | | return "医生信息读取失败,请先创建管理员,再重新生成SQL!"; |
| | | } |
| | | |
| | | // 5、读取合作商信息表Partner_Info,生成SQL文 |
| | | PartnerInfo partnerInfo = partnerInfoService.getById(partnerDockingInfo.getPartnerId()); |
| | | if (partnerInfo != null) { |
| | | createTime = "'" + dateTimeFormat.format(partnerInfo.getCreateTime()) + "'"; |
| | | updateTime = (partnerInfo.getUpdateTime() == null) ? "NULL" : "'" + dateTimeFormat.format(partnerInfo.getUpdateTime()) + "'"; |
| | | // 5、读取合作商信息表Partner_Info,生成SQL文 |
| | | PartnerInfo partnerInfo = partnerInfoService.getById(partnerDockingInfo.getPartnerId()); |
| | | if (partnerInfo != null) { |
| | | createTime = "'" + dateTimeFormat.format(partnerInfo.getCreateTime()) + "'"; |
| | | updateTime = (partnerInfo.getUpdateTime() == null) ? "NULL" : "'" + dateTimeFormat.format(partnerInfo.getUpdateTime()) + "'"; |
| | | |
| | | partnerSQL = "INSERT INTO partner_info VALUES (" + |
| | | partnerInfo.getId() + ", " + |
| | | "'" + partnerInfo.getPartnerName() + "', " + |
| | | +partnerInfo.getPartnerType() + ", " + |
| | | "'" + partnerInfo.getPartnerAddress() + "', " + |
| | | "'" + partnerInfo.getPartnerProvince() + "', " + |
| | | "'" + partnerInfo.getPartnerCity() + "', " + |
| | | "'" + partnerInfo.getPartnerArea() + "', " + |
| | | "'" + partnerInfo.getPartnerLinkMan() + "', " + |
| | | "'" + partnerInfo.getPartnerLinkTelephone() + "', " + |
| | | "'" + partnerInfo.getPartnerBussinessArea() + "', " + |
| | | "'" + partnerInfo.getPartnerIntroduce() + "', " + |
| | | "'" + partnerInfo.getPartnerUniqueCode() + "', " + |
| | | "0, 1, " + partnerInfo.getCreateUserId() + ", " + |
| | | "'" + partnerInfo.getCreateUserName() + "', " + |
| | | createTime + ", " + |
| | | +partnerInfo.getUpdateUserId() + ", " + |
| | | "'" + partnerInfo.getUpdateUserName() + "', " + |
| | | updateTime + |
| | | " );\n\r"; |
| | | } else { |
| | | return "合作商信息读取失败,请重新生成SQL!"; |
| | | } |
| | | // 6、读取服务器信息表Server_Info,生成SQL文 |
| | | createTime = "'"+ dateTimeFormat.format(partnerDockingInfo.getCreateTime())+"'"; |
| | | updateTime = (partnerDockingInfo.getUpdateTime() == null) ? "NULL" : "'"+ dateTimeFormat.format(partnerDockingInfo.getUpdateTime())+"'"; |
| | | |
| | | serverSQL = "INSERT INTO server_info VALUES(" + |
| | | partnerDockingInfo.getId() + ", " + |
| | | partnerDockingInfo.getPartnerId() + ", " + |
| | | partnerDockingInfo.getHospitalId() + ", " + |
| | | partnerDockingInfo.getDepartmentId() + ", " + |
| | | "NULL, NULL, NULL, NULL, "; |
| | | // 判断机器码是否为空,拼接不同的字符串。 |
| | | if ((partnerDockingInfo.getServerMachineCode() == null) || (partnerDockingInfo.getServerMachineCode().isEmpty())) { |
| | | serverSQL += "NULL, "; |
| | | } else { |
| | | serverSQL += "'" + partnerDockingInfo.getServerMachineCode() + "', "; |
| | | } |
| | | serverSQL += "NULL, NULL, " + |
| | | "'" + partnerDockingInfo.getAccessKey() + "', " + |
| | | "0, 1, " + |
| | | partnerDockingInfo.getCreateUserId() + ", " + |
| | | "'" + partnerDockingInfo.getCreateUserName() + "', " + |
| | | createTime + ", " + |
| | | partnerDockingInfo.getUpdateUserId() + ", " + |
| | | "'" + partnerDockingInfo.getUpdateUserName() + "', " + |
| | | updateTime + " " + |
| | | ");\n\r"; |
| | | |
| | | // 7、订单、订单明细(服务期限和数量)的数据生成 |
| | | // 7.1 订单数据 |
| | | Map<String, Object> orderMap = new HashMap<>(); |
| | | orderMap.put("hospital_id", partnerDockingInfo.getHospitalId()); |
| | | orderMap.put("department_id", partnerDockingInfo.getDepartmentId()); |
| | | orderMap.put("enabled", 1); |
| | | orderMap.put("is_del", 0); |
| | | List<ProductOrder> productOrderList = productOrderService.listByMap(orderMap); |
| | | if ((productOrderList != null) && (productOrderList.size() > 0)) { |
| | | for (int i = 0; i < productOrderList.size(); i++) { |
| | | ProductOrder productOrder = productOrderList.get(i); |
| | | createTime = "'"+dateTimeFormat.format(productOrder.getCreateTime()) +"'"; |
| | | updateTime = (productOrder.getUpdateTime() == null) ? "NULL" : "'"+dateTimeFormat.format(productOrder.getUpdateTime())+"'"; |
| | | serviceSQL += "INSERT INTO order_record VALUES(" + |
| | | productOrder.getId() + ", " + |
| | | productOrder.getHospitalId() + ", " + |
| | | "'" + productOrder.getHospitalName() + "', " + |
| | | productOrder.getDepartmentId() + ", " + |
| | | "'" + productOrder.getDepartmentName() + "', " + |
| | | "'" + productOrder.getContractNo() + "', " + |
| | | "'" + productOrder.getContractTitle() + "', " + |
| | | "'" + dateFormat.format(productOrder.getContractBeginTime()) + "', " + |
| | | "'" + dateFormat.format(productOrder.getContractEndTime()) + "', " + |
| | | "'" + dateTimeFormat.format(productOrder.getContractTime()) + "', " + |
| | | productOrder.getIsDel() + ", " + |
| | | productOrder.getEnabled() + ", " + |
| | | partnerSQL = "INSERT INTO partner_info VALUES (" + |
| | | partnerInfo.getId() + ", " + |
| | | "'" + partnerInfo.getPartnerName() + "', " + |
| | | +partnerInfo.getPartnerType() + ", " + |
| | | "'" + partnerInfo.getPartnerAddress() + "', " + |
| | | "'" + partnerInfo.getPartnerProvince() + "', " + |
| | | "'" + partnerInfo.getPartnerCity() + "', " + |
| | | "'" + partnerInfo.getPartnerArea() + "', " + |
| | | "'" + partnerInfo.getPartnerLinkMan() + "', " + |
| | | "'" + partnerInfo.getPartnerLinkTelephone() + "', " + |
| | | "'" + partnerInfo.getPartnerBussinessArea() + "', " + |
| | | "'" + partnerInfo.getPartnerIntroduce() + "', " + |
| | | "'" + partnerInfo.getPartnerUniqueCode() + "', " + |
| | | "0, 1, " + partnerInfo.getCreateUserId() + ", " + |
| | | "'" + partnerInfo.getCreateUserName() + "', " + |
| | | createTime + ", " + |
| | | productOrder.getCreateUserId() + ", " + |
| | | "'" + productOrder.getCreateUserName() + "', " + |
| | | updateTime + ", " + |
| | | productOrder.getUpdateUserId() + ", " + |
| | | "'" + productOrder.getUpdateUserName() + "' " + |
| | | ");\n\r"; |
| | | |
| | | // 7.2 订单明细数据 |
| | | orderMap.clear(); |
| | | orderMap.put("order_id", productOrder.getId()); |
| | | orderMap.put("enabled", 1); |
| | | orderMap.put("is_del", 0); |
| | | List<ProductOrderRecord> productOrderRecordList = productOrderRecordService.listByMap(orderMap); |
| | | |
| | | if ((productOrderRecordList != null) && (productOrderRecordList.size() > 0)) { |
| | | |
| | | for (i = 0; i < productOrderRecordList.size(); i++) { |
| | | ProductOrderRecord productOrderRecord = productOrderRecordList.get(i); |
| | | createTime = "'"+dateTimeFormat.format(productOrderRecord.getCreateTime())+"'"; |
| | | updateTime = (productOrderRecord.getUpdateTime() == null) ? "NULL" : "'"+dateTimeFormat.format(productOrderRecord.getUpdateTime())+"'"; |
| | | serviceSQL += "INSERT INTO order_detail VALUES( " + |
| | | productOrderRecord.getId() + ", " + |
| | | productOrderRecord.getOrderId() + ", " + |
| | | productOrderRecord.getProId() + ", " + |
| | | productOrderRecord.getProType() + ", " + |
| | | "'" + productOrderRecord.getProName() + "', " + |
| | | productOrderRecord.getAilightCount() + ", " + |
| | | productOrderRecord.getRecordCount() + ", " + |
| | | "'" + dateFormat.format(productOrderRecord.getProBegintime()) + "', " + |
| | | "'" + dateFormat.format(productOrderRecord.getProEndtime()) + "', " + |
| | | productOrderRecord.getIsShare() + ", " + |
| | | "0, 0, " + |
| | | // 服务验证字符串【合作商ID、医院ID、科室ID、产品ID、开始日期、结束日期、读片数量、报告数量、已使用读片数量、已使用报告数量】 |
| | | "'" + EncryptUtils.encryptAES((partnerDockingInfo.getPartnerId().toString() + "|" + |
| | | partnerDockingInfo.getHospitalId().toString() + "|" + |
| | | partnerDockingInfo.getDepartmentId().toString() + "|" + |
| | | productOrderRecord.getProId().toString() + "|" + |
| | | dateFormat.format(productOrderRecord.getProBegintime()) + "|" + |
| | | dateFormat.format(productOrderRecord.getProEndtime()) + "|" + |
| | | productOrderRecord.getAilightCount().toString() + "|" + |
| | | productOrderRecord.getRecordCount() + "|" + |
| | | "0|0"), SecurityConstants.AES_KEY) + "', " + |
| | | productOrderRecord.getIsDel() + ", " + |
| | | productOrderRecord.getEnabled() + ", " + |
| | | createTime + ", " + |
| | | productOrderRecord.getCreateUserId() + ", " + |
| | | "'" + productOrderRecord.getCreateUserName() + "', " + |
| | | updateTime + ", " + |
| | | productOrderRecord.getUpdateUserId() + ", " + |
| | | "'" + productOrderRecord.getUpdateUserName() + "' " + |
| | | ");\n\r"; |
| | | } |
| | | } else { |
| | | return "没有已开通的服务记录,请先充值,再生成SQL文"; |
| | | } |
| | | +partnerInfo.getUpdateUserId() + ", " + |
| | | "'" + partnerInfo.getUpdateUserName() + "', " + |
| | | updateTime + |
| | | " );\n\r"; |
| | | } else { |
| | | return "合作商信息读取失败,请重新生成SQL!"; |
| | | } |
| | | } else { |
| | | return "没有已开通的服务记录,请先充值,再生成SQL文"; |
| | | // 6、读取服务器信息表Server_Info,生成SQL文 |
| | | createTime = "'" + dateTimeFormat.format(partnerDockingInfo.getCreateTime()) + "'"; |
| | | updateTime = (partnerDockingInfo.getUpdateTime() == null) ? "NULL" : "'" + dateTimeFormat.format(partnerDockingInfo.getUpdateTime()) + "'"; |
| | | |
| | | serverSQL = "INSERT INTO server_info VALUES(" + |
| | | partnerDockingInfo.getId() + ", " + |
| | | partnerDockingInfo.getPartnerId() + ", " + |
| | | partnerDockingInfo.getHospitalId() + ", " + |
| | | partnerDockingInfo.getDepartmentId() + ", " + |
| | | "NULL, NULL, NULL, NULL, "; |
| | | // 判断机器码是否为空,拼接不同的字符串。 |
| | | if ((partnerDockingInfo.getServerMachineCode() == null) || (partnerDockingInfo.getServerMachineCode().isEmpty())) { |
| | | serverSQL += "NULL, "; |
| | | } else { |
| | | serverSQL += "'" + partnerDockingInfo.getServerMachineCode() + "', "; |
| | | } |
| | | serverSQL += "NULL, NULL, " + |
| | | "'" + partnerDockingInfo.getAccessKey() + "', " + |
| | | "0, 1, " + |
| | | partnerDockingInfo.getCreateUserId() + ", " + |
| | | "'" + partnerDockingInfo.getCreateUserName() + "', " + |
| | | createTime + ", " + |
| | | partnerDockingInfo.getUpdateUserId() + ", " + |
| | | "'" + partnerDockingInfo.getUpdateUserName() + "', " + |
| | | updateTime + " " + |
| | | ");\n\r"; |
| | | |
| | | // 7、订单、订单明细(服务期限和数量)的数据生成 |
| | | // 7.1 订单数据 |
| | | Map<String, Object> orderMap = new HashMap<>(); |
| | | orderMap.put("hospital_id", partnerDockingInfo.getHospitalId()); |
| | | orderMap.put("department_id", partnerDockingInfo.getDepartmentId()); |
| | | orderMap.put("enabled", 1); |
| | | orderMap.put("is_del", 0); |
| | | List<ProductOrder> productOrderList = productOrderService.listByMap(orderMap); |
| | | if ((productOrderList != null) && (productOrderList.size() > 0)) { |
| | | for (int i = 0; i < productOrderList.size(); i++) { |
| | | ProductOrder productOrder = productOrderList.get(i); |
| | | createTime = "'" + dateTimeFormat.format(productOrder.getCreateTime()) + "'"; |
| | | updateTime = (productOrder.getUpdateTime() == null) ? "NULL" : "'" + dateTimeFormat.format(productOrder.getUpdateTime()) + "'"; |
| | | serviceSQL += "INSERT INTO order_record VALUES(" + |
| | | productOrder.getId() + ", " + |
| | | productOrder.getHospitalId() + ", " + |
| | | "'" + productOrder.getHospitalName() + "', " + |
| | | productOrder.getDepartmentId() + ", " + |
| | | "'" + productOrder.getDepartmentName() + "', " + |
| | | "'" + productOrder.getContractNo() + "', " + |
| | | "'" + productOrder.getContractTitle() + "', " + |
| | | "'" + dateFormat.format(productOrder.getContractBeginTime()) + "', " + |
| | | "'" + dateFormat.format(productOrder.getContractEndTime()) + "', " + |
| | | "'" + dateTimeFormat.format(productOrder.getContractTime()) + "', " + |
| | | productOrder.getIsDel() + ", " + |
| | | productOrder.getEnabled() + ", " + |
| | | createTime + ", " + |
| | | productOrder.getCreateUserId() + ", " + |
| | | "'" + productOrder.getCreateUserName() + "', " + |
| | | updateTime + ", " + |
| | | productOrder.getUpdateUserId() + ", " + |
| | | "'" + productOrder.getUpdateUserName() + "' " + |
| | | ");\n\r"; |
| | | |
| | | // 7.2 订单明细数据 |
| | | orderMap.clear(); |
| | | orderMap.put("order_id", productOrder.getId()); |
| | | orderMap.put("enabled", 1); |
| | | orderMap.put("is_del", 0); |
| | | List<ProductOrderRecord> productOrderRecordList = productOrderRecordService.listByMap(orderMap); |
| | | |
| | | if ((productOrderRecordList != null) && (productOrderRecordList.size() > 0)) { |
| | | |
| | | for (i = 0; i < productOrderRecordList.size(); i++) { |
| | | ProductOrderRecord productOrderRecord = productOrderRecordList.get(i); |
| | | createTime = "'" + dateTimeFormat.format(productOrderRecord.getCreateTime()) + "'"; |
| | | updateTime = (productOrderRecord.getUpdateTime() == null) ? "NULL" : "'" + dateTimeFormat.format(productOrderRecord.getUpdateTime()) + "'"; |
| | | serviceSQL += "INSERT INTO order_detail VALUES( " + |
| | | productOrderRecord.getId() + ", " + |
| | | productOrderRecord.getOrderId() + ", " + |
| | | productOrderRecord.getProId() + ", " + |
| | | productOrderRecord.getProType() + ", " + |
| | | "'" + productOrderRecord.getProName() + "', " + |
| | | productOrderRecord.getAilightCount() + ", " + |
| | | productOrderRecord.getRecordCount() + ", " + |
| | | "'" + dateFormat.format(productOrderRecord.getProBegintime()) + "', " + |
| | | "'" + dateFormat.format(productOrderRecord.getProEndtime()) + "', " + |
| | | productOrderRecord.getIsShare() + ", " + |
| | | "0, 0, " + |
| | | // 服务验证字符串【合作商ID、医院ID、科室ID、产品ID、开始日期、结束日期、读片数量、报告数量、已使用读片数量、已使用报告数量】 |
| | | "'" + EncryptUtils.encryptAES((partnerDockingInfo.getPartnerId().toString() + "|" + |
| | | partnerDockingInfo.getHospitalId().toString() + "|" + |
| | | partnerDockingInfo.getDepartmentId().toString() + "|" + |
| | | productOrderRecord.getProId().toString() + "|" + |
| | | dateFormat.format(productOrderRecord.getProBegintime()) + "|" + |
| | | dateFormat.format(productOrderRecord.getProEndtime()) + "|" + |
| | | productOrderRecord.getAilightCount().toString() + "|" + |
| | | productOrderRecord.getRecordCount() + "|" + |
| | | "0|0"), SecurityConstants.AES_KEY) + "', " + |
| | | productOrderRecord.getIsDel() + ", " + |
| | | productOrderRecord.getEnabled() + ", " + |
| | | createTime + ", " + |
| | | productOrderRecord.getCreateUserId() + ", " + |
| | | "'" + productOrderRecord.getCreateUserName() + "', " + |
| | | updateTime + ", " + |
| | | productOrderRecord.getUpdateUserId() + ", " + |
| | | "'" + productOrderRecord.getUpdateUserName() + "' " + |
| | | ");\n\r"; |
| | | } |
| | | } else { |
| | | return "没有已开通的服务记录,请先充值,再生成SQL文"; |
| | | } |
| | | } |
| | | } else { |
| | | return "没有已开通的服务记录,请先充值,再生成SQL文"; |
| | | } |
| | | |
| | | |
| | | // 8、所有SQL文合并入基本的SQL中 |
| | | dbSql += hospitalSQL + departmentSQL + doctorSQL + partnerSQL + serverSQL + serviceSQL; |
| | | } |
| | | else { |
| | | log.error("ImageServerSQL-Template读取错误!"); |
| | | |
| | | |
| | | // 8、所有SQL文合并入基本的SQL中 |
| | | dbSql += hospitalSQL + departmentSQL + doctorSQL + partnerSQL + serverSQL + serviceSQL; |
| | | |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } finally { |
| | | try { |
| | | fileImput.close(); |
| | | if (fileImput != null) { |
| | | fileImput.close(); |
| | | } |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |