| | |
| | | /** |
| | | * 初始化私有云本地数据库 |
| | | * |
| | | * @param hospitalId |
| | | * @param departmentId |
| | | * @return java.lang.String |
| | | * @param hospitalId 医院ID |
| | | * @param departmentId 科室ID |
| | | * @return java.lang.String 私有云数据库初始化SQL |
| | | */ |
| | | public String initPrivateData(Long hospitalId, Long departmentId) { |
| | | String initSQL = ""; // 初始化数据SQL |
| | |
| | | String roleUserSQL = ""; // 角色用户关系数据SQL |
| | | String productOrderSQL = ""; // 合同信息数据SQL |
| | | String productOrderDetailSQL = ""; // 合同明细(套餐)信息数据SQL |
| | | String productOrderRecordSQL = ""; // 合同充值记录表SQL |
| | | |
| | | // 时间转换格式 |
| | | SimpleDateFormat dateTimeFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
| | |
| | | "'" + hospitalInfo.getLongitude() + "', " + |
| | | "'" + hospitalInfo.getHospitalQualifiedId() + "', " + |
| | | "'" + hospitalInfo.getHospitalQualifiedName() + "', " + |
| | | "NULL," + |
| | | "'http://123.kidgrow.cloud/OtherImage/2020-08-12/logo.jpg'," + |
| | | "NULL," + |
| | | "NULL," + |
| | | "'" + hospitalInfo.getHospitalAbout() + "', " + |
| | |
| | | "'" + hospitalInfo.getCreateUserOrgCode() + "' " + |
| | | ");\n\r"; |
| | | } else { |
| | | log.error("[%s]医院信息读取失败",hospitalId); |
| | | log.error("【{}】医院信息读取失败",hospitalId); |
| | | return "医院信息读取失败,请重新生成SQL!"; |
| | | } |
| | | // 2、根据departmentId从sys_department中查询科室信息 |
| | |
| | | "'" + department.getPrivateServerGuuid() + "' " + |
| | | ");\n\r"; |
| | | } else { |
| | | log.error("[%s]科室信息读取失败",departmentId); |
| | | log.error("【{}】科室信息读取失败",departmentId); |
| | | return "科室信息读取失败,请重新生成SQL!"; |
| | | } |
| | | // 3、根据医院和科室表中的org_id查询sys_organization中查询组织信息 |
| | |
| | | "'admin', " + |
| | | "0, 1, " + |
| | | "'"+ UserType.DOCTOR.name()+"', " + |
| | | dateTimeFormat.format(DateTime.now()) + ", " + |
| | | "'" + dateTimeFormat.format(DateTime.now()) + "', " + |
| | | "NULL, NULL, NULL, 0, " + |
| | | "'" +CommonConstant.H_TENANT + "', " + |
| | | CommonConstant.ADMIN_USER_ID.toString() +", " + |
| | | CommonConstant.ADMIN_USER_NAME + ", " + |
| | | "'" + CommonConstant.ADMIN_USER_NAME + "', " + |
| | | "NULL, 0, " + |
| | | "NULL, "+ // create_user_org_code |
| | | "1" + |
| | |
| | | CommonConstant.SYSTEM_ORG_HOS_LEVEL.toString() + ", " + |
| | | "1, 0, " + |
| | | CommonConstant.ADMIN_USER_ID.toString() +", " + |
| | | CommonConstant.ADMIN_USER_NAME + ", " + |
| | | "'" + CommonConstant.ADMIN_USER_NAME + "', " + |
| | | "NULL, NULL, " + |
| | | dateTimeFormat.format(DateTime.now()) + ", " + |
| | | "'" + dateTimeFormat.format(DateTime.now()) + "', " + |
| | | "NULL, "+ |
| | | "NULL " + // create_user_org_code |
| | | ");\n\r"; |
| | |
| | | CommonConstant.SYSTEM_ORG_DEP_LEVEL.toString() + ", " + |
| | | "1, 0, " + |
| | | CommonConstant.ADMIN_USER_ID.toString() +", " + |
| | | CommonConstant.ADMIN_USER_NAME + ", " + |
| | | "'" + CommonConstant.ADMIN_USER_NAME + "', " + |
| | | "NULL, NULL, " + |
| | | dateTimeFormat.format(DateTime.now()) + ", " + |
| | | "'" + dateTimeFormat.format(DateTime.now()) + "', " + |
| | | "NULL, "+ |
| | | "NULL " + // create_user_org_code |
| | | ");\n\r"; |
| | |
| | | department.getId().toString() + ", " + |
| | | "'" + department.getDepartmentName() + "', " + |
| | | "'管理员', NULL, NULL, 'admin', " + |
| | | "NULL, NULL, NULL, NULL, NULL, NULL, " + |
| | | "NULL, NULL, NULL, NULL, NULL, " + |
| | | "0, 0, 0, 0, 1, 1, 1, " + |
| | | CommonConstant.ADMIN_USER_ID.toString() +", " + |
| | | "'" + CommonConstant.ADMIN_USER_NAME + "', " + |
| | | "NULL, NULL, " + |
| | | dateTimeFormat.format(DateTime.now()) + ", " + |
| | | "'" +dateTimeFormat.format(DateTime.now()) + "', " + |
| | | "NULL, " + |
| | | department.getSaleUserId().toString() + ", " + |
| | | "'" + department.getSaleUserName() + "', " + |
| | | "1, " + |
| | | "'" + CommonConstant.ADMIN_USER_ORG_CODE + "'" + |
| | | ");\n\r"; |
| | | // 5、根据hospitalId和departmentId从opration_center.product_order中查询合同信息 |
| | |
| | | orderMap.put("department_id", departmentId); |
| | | orderMap.put("enabled", 1); |
| | | orderMap.put("is_del", 0); |
| | | orderMap.put("sql_is_downloaded",0); |
| | | ResultBody orderResult = productOrderService.findProductOrderListByMap(orderMap); |
| | | if (orderResult.isOk()) { |
| | | //List<ProductOrder> productOrderList = (List<ProductOrder>) orderResult.getData(); |
| | |
| | | "'" + dateTimeFormat.format(productOrder.getContractTime()) + "', " + |
| | | productOrder.getIsDel() + ", " + |
| | | productOrder.getEnabled() + ", " + |
| | | "1, " + |
| | | updateTime + ", " + |
| | | productOrder.getCreateUserId() + ", " + |
| | | "'" + productOrder.getCreateUserName() + "', " + |
| | |
| | | "Null, " + // tenant_id |
| | | "'" + productOrderDetail.getCreateUserOrgCode() + "' " + |
| | | ");\n\r"; |
| | | productOrderRecordSQL += "INSERT INTO opration_center_pri.product_order_record VALUES( " + |
| | | productOrderDetail.getId() + ", " + |
| | | productOrderDetail.getOrderId() + ", " + |
| | | productOrderDetail.getProId() + ", " + |
| | | productOrderDetail.getProType() + ", " + |
| | | "'" + productOrderDetail.getProName() + "', " + |
| | | productOrderDetail.getIsShare() + ", " + |
| | | productOrderDetail.getIsDel() + ", " + |
| | | productOrderDetail.getAilightCount() + ", " + |
| | | productOrderDetail.getRecordCount() + ", " + |
| | | "'" + dateFormat.format(productOrderDetail.getProBegintime()) + "', " + |
| | | "'" + dateFormat.format(productOrderDetail.getProEndtime()) + "', " + |
| | | productOrderDetail.getEnabled() + ", " + |
| | | productOrderDetail.getCreateUserId() + ", " + |
| | | "'" + productOrderDetail.getCreateUserName() + "', " + |
| | | productOrderDetail.getUpdateUserId() + ", " + |
| | | updateTime + ", " + |
| | | "'" + productOrderDetail.getUpdateUserName() + "', " + |
| | | createTime + ", " + |
| | | "Null, " + // tenant_id |
| | | "'" + productOrderDetail.getCreateUserOrgCode() + "' " + |
| | | ");\n\r"; |
| | | } |
| | | } else { |
| | | log.error("此合同【】没有合同明细(套餐)",productOrder.getId()); |
| | | log.error("此合同【{}】没有合同明细(套餐)",productOrder.getId()); |
| | | // return "没有已开通的合同明细(套餐),请先充值,再生成SQL文"; |
| | | } |
| | | |
| | | } else { |
| | | log.error(detailResult.getMsg()); |
| | | return "没有已开通的合同明细(套餐),请先充值,再生成SQL文"; |
| | | } |
| | | // 更新合同表中的是否下载字段,为已下载(true) |
| | | productOrder.setSqlIsDownloaded(true); |
| | | ResultBody updateResult = productOrderService.downLoadProductOrderOver(productOrder); |
| | | if (!updateResult.isOk()) { |
| | | log.error("合同表下载状态更新失败!"); |
| | | } |
| | | |
| | | } |
| | | } else { |
| | | |
| | | log.error("此科室【hospital_id:%s,department_id:%s】没有已开通的合同记录",hospitalId,departmentId); |
| | | log.error("此科室【hospital_id:{},department_id:{}】没有已开通的合同记录",hospitalId,departmentId); |
| | | return "没有已开通的合同记录,请先充值,再生成SQL文"; |
| | | } |
| | | } else { |
| | |
| | | } |
| | | |
| | | if ((productOrderSQL.isEmpty()) || (productOrderDetailSQL.isEmpty())){ |
| | | log.error("此科室【hospital_id:%s,department_id:%s】没有已开通的合同记录",hospitalId,departmentId); |
| | | log.error("此科室【hospital_id:{},department_id:{}】没有已开通的合同记录",hospitalId,departmentId); |
| | | return "没有已开通的合同记录,请先充值,再生成SQL文"; |
| | | } |
| | | |
| | | initSQL = organizationSQL + hospitalSQL + departmentSQL + |
| | | userSQL + userOrgSQL + roleUserSQL + doctorSQL + |
| | | productOrderSQL + productOrderDetailSQL; |
| | | productOrderSQL + productOrderDetailSQL + productOrderRecordSQL; |
| | | |
| | | return initSQL; |
| | | } |