Commit 7602f191 authored by fancy's avatar fancy
Browse files

app自助打包增加外部包名的功能,可以打包出和官方不一样的包

Showing with 437 additions and 40 deletions
+437 -40
......@@ -67,6 +67,7 @@ public class Config {
public static final String PATH_CONFIG_WORKTIME = "config/workTime.json";
public static final String PATH_CONFIG_CENTERSERVER = "config/centerServer.json";
public static final String PATH_CONFIG_COLLECT = "config/collect.json";
public static final String NAME_CONFIG_COLLECT = "collect.json";
public static final String PATH_CONFIG_DUMPRESTOREDATA = "config/dumpRestoreData.json";
public static final String PATH_CONFIG_DUMPRESTORESTORAGE = "config/dumpRestoreStorage.json";
public static final String PATH_CONFIG_MESSAGES = "config/messages.json";
......@@ -92,6 +93,7 @@ public class Config {
public static final String PATH_COMMONS_INITIALSERVICESCRIPTTEXT = "commons/initialServiceScriptText.js";
public static final String PATH_COMMONS_MOOTOOLSSCRIPTTEXT = "commons/mooToolsScriptText.js";
public static final String PATH_CONFIG_JPUSH = "config/jpushConfig.json";
public static final String NAME_CONFIG_JPUSH = "jpushConfig.json";
public static final String PATH_CONFIG_COMMUNICATE = "config/communicate.json";
public static final String PATH_CONFIG_EXMAIL = "config/exmail.json";
public static final String PATH_CONFIG_PORTAL = "config/portal.json";
......
......@@ -12,6 +12,10 @@ public class JpushConfig extends ConfigObject {
private static final String O2_apns_path_default = "configSample/o2oa_apns.p12";
private static final String O2_apns_password_default = "1209";
// 自助打包的outer包使用的key
private static final String O2_app_key_outer = "24a4af5965d2c325b33c243d";
private static final String O2_master_secret_outer = "a7b5689399307b29957e7dce";
public static JpushConfig defaultInstance() {
return new JpushConfig();
......@@ -44,6 +48,19 @@ public class JpushConfig extends ConfigObject {
private String apnsKeystorePassword;
/**
* 获取给自助打包生成的 外部包名 的app使用的config
* @return
*/
public JpushConfig getOuterApplicationJpushConfig() {
JpushConfig config = new JpushConfig();
config.setAppKey(O2_app_key_outer);
config.setMasterSecret(O2_master_secret_outer);
config.setEnable(true);
return config;
}
/**
* 获取苹果推送证书文件
* @return
......@@ -94,7 +111,7 @@ public class JpushConfig extends ConfigObject {
}
public Boolean getHuaweiPushEnable() {
return huaweiPushEnable;
return huaweiPushEnable == null ? false : huaweiPushEnable;
}
public void setHuaweiPushEnable(Boolean huaweiPushEnable) {
......
......@@ -64,7 +64,7 @@ public class ThisApplication {
Config.zhengwuDingding().getForceSyncCron());
}
/* 企业微信拉入同步 */
if (BooleanUtils.isTrue(Config.qiyeweixin().getEnable()) && StringUtils.isNotBlank(Config.qiyeweixin().getSyncCron())) {
if (BooleanUtils.isTrue(Config.qiyeweixin().getEnable()) && StringUtils.isNotBlank(Config.qiyeweixin().getForceSyncCron())) {
/* 启动同步任务 */
context().scheduleLocal(QiyeweixinSyncOrganization.class, Config.qiyeweixin().getSyncCron());
/* 添加一个强制同步任务 */
......@@ -72,14 +72,14 @@ public class ThisApplication {
Config.qiyeweixin().getForceSyncCron());
}
/* 钉钉同步 */
if (BooleanUtils.isTrue(Config.dingding().getEnable())) {
if (BooleanUtils.isTrue(Config.dingding().getEnable()) && StringUtils.isNotBlank(Config.dingding().getForceSyncCron())) {
/* 启动同步任务 */
context().scheduleLocal(DingdingSyncOrganization.class, Config.dingding().getSyncCron());
/* 添加一个强制同步任务 */
context().scheduleLocal(DingdingSyncOrganizationTrigger.class, Config.dingding().getForceSyncCron());
}
/* WeLink同步 */
if (BooleanUtils.isTrue(Config.weLink().getEnable())) {
if (BooleanUtils.isTrue(Config.weLink().getEnable()) && StringUtils.isNotBlank(Config.weLink().getForceSyncCron())) {
/* 启动同步任务 */
context().scheduleLocal(WeLinkSyncOrganization.class, Config.weLink().getSyncCron());
/* 添加一个强制同步任务 */
......
......@@ -9,6 +9,7 @@ import com.x.program.center.jaxrs.adminlogin.AdminLoginAction;
import com.x.program.center.jaxrs.agent.AgentAction;
import com.x.program.center.jaxrs.applications.ApplicationsAction;
import com.x.program.center.jaxrs.apppack.AppPackAction;
import com.x.program.center.jaxrs.apppack.AppPackAnonymousAction;
import com.x.program.center.jaxrs.appstyle.AppStyleAction;
import com.x.program.center.jaxrs.authentication.AuthenticationAction;
import com.x.program.center.jaxrs.cachedispatch.CacheDispatchAction;
......@@ -77,6 +78,7 @@ public class ActionApplication extends AbstractActionApplication {
classes.add(DesignerAction.class);
classes.add(MPWeixinAction.class);
classes.add(AppPackAction.class);
classes.add(AppPackAnonymousAction.class);
classes.add(TokenThresholdAction.class);
return classes;
}
......
package com.x.program.center.jaxrs;
import com.x.base.core.project.jaxrs.AnonymousCipherManagerUserJaxrsFilter;
import javax.servlet.annotation.WebFilter;
@WebFilter(urlPatterns = "/jaxrs/apppackanony/*", asyncSupported = true)
public class AppPackAnonymousJaxrsFilter extends AnonymousCipherManagerUserJaxrsFilter {
}
\ No newline at end of file
......@@ -35,7 +35,7 @@ public class ActionAndroidPack extends BaseAction {
private static Logger logger = LoggerFactory.getLogger(ActionAndroidPack.class);
ActionResult<Wo> execute(String token, String appName, String o2ServerProtocol, String o2ServerHost,
String o2ServerPort, String o2ServerContext, String fileName, byte[] bytes,
String o2ServerPort, String o2ServerContext, String isPackAppIdOuter, String fileName, byte[] bytes,
FormDataContentDisposition disposition) throws Exception {
ActionResult<Wo> result = new ActionResult<Wo>();
if (StringUtils.isEmpty(token)) {
......@@ -75,7 +75,7 @@ public class ActionAndroidPack extends BaseAction {
if (!fileName.toLowerCase().endsWith("png")) {
throw new ExceptionFileNotPng();
}
String s = postFormData(token, appName, o2ServerProtocol, o2ServerHost, o2ServerPort, o2ServerContext, fileName,
String s = postFormData(token, appName, o2ServerProtocol, o2ServerHost, o2ServerPort, o2ServerContext, isPackAppIdOuter, fileName,
bytes);
Type type = new TypeToken<AppPackResult<IdValue>>() {
}.getType();
......@@ -106,9 +106,9 @@ public class ActionAndroidPack extends BaseAction {
* @throws Exception
*/
private String postFormData(String token, String appName, String o2ServerProtocol, String o2ServerHost,
String o2ServerPort, String o2ServerContext, String fileName, byte[] bytes) throws Exception {
String o2ServerPort, String o2ServerContext, String isPackAppIdOuter, String fileName, byte[] bytes) throws Exception {
logger.info("发起打包请求,form : " + token + " ," + appName + " ," + o2ServerProtocol + " ," + o2ServerHost + " ,"
+ o2ServerPort + " ," + o2ServerContext + " ," + fileName);
+ o2ServerPort + " ," + o2ServerContext + " ," + isPackAppIdOuter + " ," + fileName);
String boundary = "abcdefghijk";
String end = "\r\n";
String twoHyphens = "--";
......@@ -147,6 +147,7 @@ public class ActionAndroidPack extends BaseAction {
writeFormProperties("o2ServerHost", o2ServerHost, boundary, end, twoHyphens, ds);
writeFormProperties("o2ServerPort", o2ServerPort, boundary, end, twoHyphens, ds);
writeFormProperties("o2ServerContext", o2ServerContext, boundary, end, twoHyphens, ds);
writeFormProperties("isPackAppIdOuter", isPackAppIdOuter, boundary, end, twoHyphens, ds);
writeFormProperties("collectName", Config.collect().getName(), boundary, end, twoHyphens, ds);
// file
ds.writeBytes(twoHyphens + boundary + end);
......
......@@ -33,14 +33,14 @@ public class ActionLastPackFileInfo extends BaseAction {
CriteriaBuilder cb = em.getCriteriaBuilder();
CriteriaQuery<AppPackApkFile> query = cb.createQuery(AppPackApkFile.class);
Root<AppPackApkFile> root = query.from(AppPackApkFile.class);
query.orderBy(cb.desc(root.get(AppPackApkFile_.updateTime)));
query.orderBy(cb.desc(root.get(AppPackApkFile_.lastUpdateTime)));
List<AppPackApkFile> list = em.createQuery(query).setMaxResults(1).getResultList();
if (list != null && !list.isEmpty()) {
AppPackApkFile file = list.get(0);
Wo wo = Wo.copier.copy(file);
result.setData(wo);
} else {
throw new ExceptionFileNotExist(null);
// throw new ExceptionFileNotExist(null);
}
}
return result;
......
......@@ -65,6 +65,7 @@ public class ActionPackFileDownload extends BaseAction {
throw e;
}
}
result.setData(wo);
}
return result;
......
......@@ -18,6 +18,7 @@ import com.x.program.center.core.entity.AppPackApkFile_;
import org.apache.commons.lang3.StringUtils;
import javax.persistence.Column;
import javax.persistence.EntityManager;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
......@@ -114,27 +115,39 @@ public class ActionPackInfo extends BaseAction {
private String appLogoPath; // logo图片地址 相对路径
private String apkPath; // apk下载地址 相对路径
// 版本号 暂时还没有
private String appVersionName;
private String appVersionNo;
// 版本名称
private String versionName;
// 版本号 100
private String buildNo;
// 是否使用外部包名,2: 就是用 net.zoneland.x.bpm.mobile.v1.zoneXBPM.outer 作为apk的applicationId,默认使用老的applicationId,兼容老的版本
private String isPackAppIdOuter;
private AppPackApkFile appFile; // 关联的下载文件
public String getAppVersionName() {
return appVersionName;
public String getVersionName() {
return versionName;
}
public void setVersionName(String versionName) {
this.versionName = versionName;
}
public String getBuildNo() {
return buildNo;
}
public void setAppVersionName(String appVersionName) {
this.appVersionName = appVersionName;
public void setBuildNo(String buildNo) {
this.buildNo = buildNo;
}
public String getAppVersionNo() {
return appVersionNo;
public String getIsPackAppIdOuter() {
return isPackAppIdOuter;
}
public void setAppVersionNo(String appVersionNo) {
this.appVersionNo = appVersionNo;
public void setIsPackAppIdOuter(String isPackAppIdOuter) {
this.isPackAppIdOuter = isPackAppIdOuter;
}
public AppPackApkFile getAppFile() {
......
......@@ -4,9 +4,11 @@ import com.google.gson.JsonElement;
import com.x.base.core.container.EntityManagerContainer;
import com.x.base.core.container.factory.EntityManagerContainerFactory;
import com.x.base.core.entity.annotation.CheckPersistType;
import com.x.base.core.project.Application;
import com.x.base.core.project.annotation.FieldDescribe;
import com.x.base.core.project.config.Config;
import com.x.base.core.project.config.StorageMapping;
import com.x.base.core.project.config.*;
import com.x.base.core.project.connection.ActionResponse;
import com.x.base.core.project.connection.CipherConnectionAction;
import com.x.base.core.project.connection.ConnectionAction;
import com.x.base.core.project.gson.GsonPropertyObject;
import com.x.base.core.project.http.ActionResult;
......@@ -14,11 +16,17 @@ import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.jaxrs.WrapBoolean;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
import com.x.base.core.project.x_jpush_assemble_control;
import com.x.base.core.project.x_program_center;
import com.x.program.center.ThisApplication;
import com.x.program.center.core.entity.AppPackApkFile;
import com.x.program.center.jaxrs.config.ActionSave;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.lang3.BooleanUtils;
import org.apache.commons.lang3.StringUtils;
import java.util.Date;
import java.util.Map;
/**
* Created by fancyLou on 11/30/21.
......@@ -50,12 +58,16 @@ public class ActionPublishAPK2Local extends BaseAction {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
AppPackApkFile appPackApkFile = new AppPackApkFile();
appPackApkFile.setName(fileName);
appPackApkFile.setExtension(StringUtils.lowerCase(FilenameUtils.getExtension(fileName)));
appPackApkFile.setStorage(mapping.getName());
appPackApkFile.setPackInfoId(wi.getPackInfoId());
Date now = new Date();
appPackApkFile.setCreateTime(now);
appPackApkFile.setLastUpdateTime(now);
appPackApkFile.setStatus(AppPackApkFile.statusInit);
appPackApkFile.setAppVersionNo(wi.getAppVersionNo());
appPackApkFile.setAppVersionName(wi.getAppVersionName());
appPackApkFile.setIsPackAppIdOuter(wi.getIsPackAppIdOuter());
emc.check(appPackApkFile, CheckPersistType.all);
appPackApkFile.saveContent(mapping, new byte[]{}, fileName);
emc.beginTransaction(AppPackApkFile.class);
......@@ -104,17 +116,131 @@ public class ActionPublishAPK2Local extends BaseAction {
file.updateContent(mapping, bytes);
file.setStatus(AppPackApkFile.statusCompleted);
file.setLastUpdateTime(new Date());
// emc.persist(file);
emc.commit();
// 发布成功了,需要修改jpush配置文件,把outer包的key配置上去
if (StringUtils.isNotBlank(file.getIsPackAppIdOuter()) && "2".equals(file.getIsPackAppIdOuter())) {
updateJpushConfig();
}
updateAppUrl(wi.getWebUrl());
logger.info("下载发布apk成功。。。。。。");
} else {
logger.info("错误,没有找到对应的文件对象,id:"+id);
logger.error(new Exception("错误,没有找到对应的文件对象,id:"+id));
}
}
} catch (Exception e) {
logger.error(e);
logger.info("下载失败,更新错误状态!!!!");
try {
try (EntityManagerContainer emc = EntityManagerContainerFactory.instance().create()) {
AppPackApkFile file = emc.find(this.id, AppPackApkFile.class);
if (file != null) {
emc.beginTransaction(AppPackApkFile.class);
file.setStatus(AppPackApkFile.statusError);
file.setLastUpdateTime(new Date());
emc.commit();
} else {
logger.error(new Exception("错误,没有找到对应的文件对象,id:"+id));
}
}
}catch (Exception e1) {
logger.error(e1);
}
}
}
private void updateJpushConfig() {
try {
logger.info("开始修改jpush文件.......");
JpushConfig newConfig = JpushConfig.defaultInstance().getOuterApplicationJpushConfig();
updateConfigFileOnLine(Config.NAME_CONFIG_JPUSH, newConfig.toString());
}catch (Exception e) {
logger.error(e);
}
}
/**
* 更新appUrl collect.json配置文件 登录界面扫码可以下载
*/
private void updateAppUrl(String webUrl) {
try {
logger.info("updateAppUrl : "+webUrl);
if (StringUtils.isNotEmpty(webUrl)) {
String myUrl = webUrl;
String protocol = Config.nodes().centerServers().first().getValue().getHttpProtocol();
String webProxyHost = "";
int webProxyPort = 80;
for (Map.Entry<String, Node> en : Config.nodes().entrySet()) {
if (null != en.getValue()) {
WebServer webServer = en.getValue().getWeb();
if (null != webServer && BooleanUtils.isTrue(webServer.getEnable())) {
webProxyHost = webServer.getProxyHost();
webProxyPort = webServer.getProxyPort();
}
}
}
if (StringUtils.isNotEmpty(webProxyHost)) {
String url = protocol + "://" +webProxyHost + ":" +webProxyPort;
if (!url.equals(webUrl)) {
myUrl = url;
}
}
logger.info("最后的URL :" + myUrl);
Config.collect().setAppUrl(myUrl+ "/x_desktop/appDownload.html");
updateConfigFileOnLine(Config.NAME_CONFIG_COLLECT, Config.collect().toString());
}
}catch (Exception e) {
logger.error(e);
}
}
/**
* 更新配置文件
* @param fileName 配置文件名称 如 jpushConfig.json
* @param content 配置文件内容 json
* @throws Exception
*/
private void updateConfigFileOnLine(String fileName, String content) throws Exception {
logger.info("更新配置文件。。。。。。。。。。。。。。");
logger.info("文件:" + fileName);
logger.info("内容:" + content);
JPushConfigSaveWi wi = new JPushConfigSaveWi();
wi.setFileName(fileName);
wi.setFileContent(content);
ActionResponse response = CipherConnectionAction.post(false, Config.url_x_program_center_jaxrs("config", "save") ,wi);
if (response != null) {
ActionSave.Wo wo = response.getData(ActionSave.Wo.class);
if (wo != null && wo.getStatus() != null) {
logger.info("修改保存["+fileName+"]配置文件成功!");
}
} else {
logger.info("保存["+fileName+"]配置文件 返回为空!!");
}
}
}
public static class JPushConfigSaveWi extends GsonPropertyObject {
private String fileName;
private String fileContent;
public String getFileName() {
return fileName;
}
public void setFileName(String fileName) {
this.fileName = fileName;
}
public String getFileContent() {
return fileContent;
}
public void setFileContent(String fileContent) {
this.fileContent = fileContent;
}
}
public static class Wi extends GsonPropertyObject {
......@@ -130,7 +256,20 @@ public class ActionPublishAPK2Local extends BaseAction {
private String appVersionName;
@FieldDescribe("app的版本编译号")
private String appVersionNo;
@FieldDescribe("是否使用外部包名,2: 就是用 net.zoneland.x.bpm.mobile.v1.zoneXBPM.outer 作为apk的applicationId")
private String isPackAppIdOuter;
@FieldDescribe("前端web地址,如 http://dd.o2oa.net")
private String webUrl;
public String getWebUrl() {
return webUrl;
}
public void setWebUrl(String webUrl) {
this.webUrl = webUrl;
}
public String getAppVersionName() {
return appVersionName;
......@@ -171,6 +310,14 @@ public class ActionPublishAPK2Local extends BaseAction {
public void setPackInfoId(String packInfoId) {
this.packInfoId = packInfoId;
}
public String getIsPackAppIdOuter() {
return isPackAppIdOuter;
}
public void setIsPackAppIdOuter(String isPackAppIdOuter) {
this.isPackAppIdOuter = isPackAppIdOuter;
}
}
......
......@@ -81,13 +81,14 @@ public class AppPackAction extends BaseAction {
@JaxrsParameterDescribe("o2ServerHost") @FormDataParam("o2ServerHost") String o2ServerHost,
@JaxrsParameterDescribe("o2ServerPort") @FormDataParam("o2ServerPort") String o2ServerPort,
@JaxrsParameterDescribe("o2ServerContext") @FormDataParam("o2ServerContext") String o2ServerContext,
@JaxrsParameterDescribe("isPackAppIdOuter") @FormDataParam("isPackAppIdOuter") String isPackAppIdOuter,
@JaxrsParameterDescribe("附件名称") @FormDataParam(FILENAME_FIELD) String fileName,
@JaxrsParameterDescribe("附件标识") @FormDataParam(FILE_FIELD) final byte[] bytes,
@JaxrsParameterDescribe("上传文件") @FormDataParam(FILE_FIELD) final FormDataContentDisposition disposition){
ActionResult<ActionAndroidPack.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionAndroidPack().execute(token, appName, o2ServerProtocol, o2ServerHost, o2ServerPort, o2ServerContext, fileName, bytes, disposition);
result = new ActionAndroidPack().execute(token, appName, o2ServerProtocol, o2ServerHost, o2ServerPort, o2ServerContext, isPackAppIdOuter, fileName, bytes, disposition);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
......@@ -140,7 +141,7 @@ public class AppPackAction extends BaseAction {
@Path("pack/info/file/last")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void androidPackReStart(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request) {
public void androidPackLastAPk(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request) {
ActionResult<ActionLastPackFileInfo.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
......@@ -161,7 +162,7 @@ public class AppPackAction extends BaseAction {
@Path("pack/info/file/publish")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void listPaging(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request, JsonElement jsonElement) {
public void publishApk(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request, JsonElement jsonElement) {
ActionResult<ActionPublishAPK2Local.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
......
package com.x.program.center.jaxrs.apppack;
import com.x.base.core.project.annotation.JaxrsDescribe;
import com.x.base.core.project.annotation.JaxrsMethodDescribe;
import com.x.base.core.project.annotation.JaxrsParameterDescribe;
import com.x.base.core.project.http.ActionResult;
import com.x.base.core.project.http.EffectivePerson;
import com.x.base.core.project.http.HttpMediaType;
import com.x.base.core.project.jaxrs.ResponseFactory;
import com.x.base.core.project.logger.Logger;
import com.x.base.core.project.logger.LoggerFactory;
import javax.servlet.http.HttpServletRequest;
import javax.ws.rs.*;
import javax.ws.rs.container.AsyncResponse;
import javax.ws.rs.container.Suspended;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
@Path("apppackanony")
@JaxrsDescribe("移动客户端在线打包服务")
public class AppPackAnonymousAction extends BaseAction {
private static Logger logger = LoggerFactory.getLogger(AppPackAnonymousAction.class);
@JaxrsMethodDescribe(value = "下载app包", action = ActionPackFileDownload.class)
@GET
@Path("pack/info/file/download/{id}")
@Consumes(MediaType.APPLICATION_JSON)
public void download(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request,
@JaxrsParameterDescribe("app下载标识") @PathParam("id") String id) {
ActionResult<ActionPackFileDownload.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionPackFileDownload().execute(effectivePerson, id);
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
@JaxrsMethodDescribe(value = "查询最新发布的app下载包.", action = ActionLastPackFileInfo.class)
@GET
@Path("pack/info/file/last")
@Produces(HttpMediaType.APPLICATION_JSON_UTF_8)
@Consumes(MediaType.APPLICATION_JSON)
public void androidPackLastAPk(@Suspended final AsyncResponse asyncResponse, @Context HttpServletRequest request) {
ActionResult<ActionLastPackFileInfo.Wo> result = new ActionResult<>();
EffectivePerson effectivePerson = this.effectivePerson(request);
try {
result = new ActionLastPackFileInfo().execute();
} catch (Exception e) {
logger.error(e, effectivePerson, request, null);
result.error(e);
}
asyncResponse.resume(ResponseFactory.getEntityTagActionResultResponse(request, result));
}
}
......@@ -116,12 +116,12 @@ public class AppPackApkFile extends StorageObject {
private String packInfoId;
public static final String appVersionName_FIELDNAME = "appVersionName";
@FieldDescribe("安装包版本号名称,暂时没有先预留.")
@FieldDescribe("安装包版本号名称.")
@Column(length = length_64B, name = ColumnNamePrefix + appVersionName_FIELDNAME)
private String appVersionName;
public static final String appVersionNo_FIELDNAME = "appVersionNo";
@FieldDescribe("安装包版本号,可比较,暂时没有先预留.")
@FieldDescribe("安装包版本号,可比较.")
@Column(length = length_64B, name = ColumnNamePrefix + appVersionNo_FIELDNAME)
private String appVersionNo;
......@@ -131,10 +131,23 @@ public class AppPackApkFile extends StorageObject {
public static final Integer statusError = 2;
public static final String status_FIELDNAME = "status";
@FieldDescribe("状态,异步下载文件所以需要这个状态,0开启,1下载完成, 2过程有异常")
@FieldDescribe("状态,异步下载文件所以需要这个状态,0开启,1下载完成, 2过程有异常.")
@Column(name = ColumnNamePrefix + status_FIELDNAME)
private Integer status;
public static final String isPackAppIdOuter_FIELDNAME = "isPackAppIdOuter";
@FieldDescribe("是否使用外部包名,2: 就是用 net.zoneland.x.bpm.mobile.v1.zoneXBPM.outer 作为apk的applicationId,默认使用老的applicationId,兼容老的版本")
@Column(length = length_64B, name = ColumnNamePrefix + isPackAppIdOuter_FIELDNAME)
private String isPackAppIdOuter;
public String getIsPackAppIdOuter() {
return isPackAppIdOuter;
}
public void setIsPackAppIdOuter(String isPackAppIdOuter) {
this.isPackAppIdOuter = isPackAppIdOuter;
}
public Integer getStatus() {
return status;
......
......@@ -41,8 +41,11 @@
.pack-form-tips {
color: #9a9a9a;padding-top:4px;
}
.pack-form-top-30 {
margin-top:30px;
}
.pack-form-sb-btn {
margin-top:30px;display: inline-block;overflow: visible;margin-left: .5em;margin-right: .5em;min-width: 80px !important;padding: 0;height: 30px;line-height: 30px;vertical-align: middle;text-align: center;text-decoration: none;border-radius: 3px;font-size: 14px;border-width: 1px;border-style: solid;cursor: pointer;background-color: #07c160;background-image: linear-gradient(to bottom,#07c160 0,#07c160 100%);border-color: #07c160;color: #fff;
display: inline-block;overflow: visible;margin-left: .5em;margin-right: .5em;min-width: 80px !important;padding: 0;height: 30px;line-height: 30px;vertical-align: middle;text-align: center;text-decoration: none;border-radius: 3px;font-size: 14px;border-width: 1px;border-style: solid;cursor: pointer;background-color: #07c160;background-image: linear-gradient(to bottom,#07c160 0,#07c160 100%);border-color: #07c160;color: #fff;
}
.pack-form-sb-btn button {
color: #fff; display: block;background-color: transparent;outline: 0;overflow: visible;cursor: pointer;border: 0;height: 100%;
......
......@@ -68,6 +68,16 @@
</div>
</div>
<div class="pack-form-group">
<label class="pack-form-label">{{$.lp.mobile_apppack_form_enable_outer_package}}</label>
<div class="pack-form-controls">
<span class="pack-form-box">
<input type="checkbox" data-o2-element="apppackIsPackAppIdOuterInputNode"/>
</span>
<p class="pack-form-tips">{{$.lp.mobile_apppack_form_enable_outer_tips}}</p>
</div>
</div>
<span class="pack-form-sb-btn" data-o2-element="apppackBtnNode"><button >{{$.lp.mobile_apppack_form_button}}</button></span>
......@@ -130,16 +140,32 @@
</span>
</div>
</div>
<div class="pack-form-group">
<label class="pack-form-label">{{$.lp.mobile_apppack_form_enable_outer_package}}</label>
<div class="pack-form-controls">
<span class="pack-form-box" data-o2-element="apppackIsPackAppIdOuterShowNode">
</span>
</div>
</div>
<div class="pack-form-group" style="display:none;" data-o2-element="apppackDownloadShowNode">
<div class="pack-info-status-box" >
<a href="" target="_blank" data-o2-element="apppackDownloadLinkNode">下载APK文件</a>
<a href="" target="_blank" data-o2-element="apppackDownloadLinkNode">{{$.lp.mobile_apppack_form_download_apk_button}}</a>
</div>
</div>
<!-- 发布到本地情况展现 -->
<div class="pack-form-group" style="display:none;" data-o2-element="apppackPublishShowNode">
<div class="pack-info-status-box">
<span class="pack-form-sb-btn" data-o2-element="apppackPublishBtnNode" style="display: none;"><button >{{$.lp.mobile_apppack_form_download_publish_btn}}</button></span>
</div>
<div class="pack-info-status-box">
<span data-o2-element="apppackPublishStatusInfoNode" style="color: #fb4747;"></span>
</div>
</div>
<span class="pack-form-sb-btn" data-o2-element="apppackRePackBtnNode" style="display: none;"><button >{{$.lp.mobile_apppack_form_re_pack_button}}</button></span>
<span class="pack-form-sb-btn" data-o2-element="apppackReInputBtnNode" style="display: none;"><button >{{$.lp.mobile_apppack_form_reinput_button}}</button></span>
<span class="pack-form-sb-btn pack-form-top-30" data-o2-element="apppackRePackBtnNode" style="display: none;"><button >{{$.lp.mobile_apppack_form_re_pack_button}}</button></span>
<span class="pack-form-sb-btn pack-form-top-30" data-o2-element="apppackReInputBtnNode" style="display: none;"><button >{{$.lp.mobile_apppack_form_reinput_button}}</button></span>
</div>
......
......@@ -221,10 +221,15 @@ MWF.xApplication.Setting.AppPackOnlineDocument = new Class({
this.apppackHostShowNode.set("text", this.packInfo.o2ServerHost);
this.apppackPortShowNode.set("text", this.packInfo.o2ServerPort);
this.apppackContextShowNode.set("text", this.packInfo.o2ServerContext);
var isPackAppIdOuter = this.lp.mobile_apppack_form_enable_outer_status_no;
if (this.packInfo.isPackAppIdOuter && this.packInfo.isPackAppIdOuter === "2") {
isPackAppIdOuter = this.lp.mobile_apppack_form_enable_outer_status_yes;
}
this.apppackIsPackAppIdOuterShowNode.set("text", isPackAppIdOuter);
this.apppackLogoShowImgNode.set("src", this.packServerUrl + this.packInfo.appLogoPath + "?token=" + this.token);
var status = ""
if (this.packInfo.packStatus === "0") {
status = this.lp.mobile_apppack_status_order_inline
status = this.lp.mobile_apppack_status_order_inline;
this.apppackStatusRefreshNode.setStyles({
"display": ""
});
......@@ -288,10 +293,44 @@ MWF.xApplication.Setting.AppPackOnlineDocument = new Class({
this.apppackStatusShowNode.set("text", status);
if (this.packInfo.apkPath && this.packInfo.packStatus === "2") {
this.apppackDownloadLinkNode.set("href", this.packServerUrl + this.packInfo.apkPath + "?token=" + this.token);
this.apppackDownloadShowNode.setStyles({
"display": ""
});
// 显示发布区域
this.apppackPublishShowNode.setStyles({ "display": ""});
if (!this.packInfo.appFile) { // 还未发布到本地
this.apppackPublishBtnNode.setStyles({ "display": ""}); //显示发布按钮
this.apppackPublishBtnNode.addEvents({
"click": function(e) {
this.publishAPK2Local();
}.bind(this)
});
this.apppackPublishStatusInfoNode.set("text", "");
// 弹出发布提示
this.confirm(this.lp.alert, this.lp.mobile_apppack_message_confirm_publish, function() {
this.publishAPK2Local();
}.bind(this));
} else if (this.packInfo.appFile.status === 0) { // 发布中
this.apppackPublishBtnNode.setStyles({ "display": "none"}); //隐藏发布按钮
this.apppackPublishStatusInfoNode.set("text", this.lp.mobile_apppack_publish_status_doing);
} else if (this.packInfo.appFile.status === 1) { // 发布完成
this.apppackPublishBtnNode.setStyles({ "display": "none"}); //隐藏发布按钮
this.apppackPublishStatusInfoNode.set("text", this.lp.mobile_apppack_publish_status_completed);
// 发布完成,显示下载按钮
var url = o2.Actions.getHost("x_program_center") + "/x_program_center/jaxrs/apppack/pack/info/file/download/" + this.packInfo.appFile.id ;
this.apppackDownloadLinkNode.set("href", url);
this.apppackDownloadShowNode.setStyles({
"display": ""
});
} else if (this.packInfo.appFile.status === 2) { // 发布失败
this.apppackPublishBtnNode.setStyles({ "display": ""}); //显示发布按钮
this.apppackPublishStatusInfoNode.set("text", this.lp.mobile_apppack_publish_status_fail);
this.apppackPublishBtnNode.addEvents({
"click": function(e) {
this.publishAPK2Local();
}.bind(this)
});
}
} else {
this.apppackDownloadShowNode.setStyles({
"display": "none"
......@@ -306,6 +345,37 @@ MWF.xApplication.Setting.AppPackOnlineDocument = new Class({
}
},
// 发布打包好的apk到本地
publishAPK2Local: function() {
if (this.packInfo) {
var url = o2.Actions.getHost("")
var data = {
'token': this.token,
'apkPath': this.packInfo.apkPath,
'packInfoId': this.packInfo.id,
'appVersionName': this.packInfo.versionName,
'appVersionNo': this.packInfo.buildNo,
'isPackAppIdOuter': this.packInfo.isPackAppIdOuter,
'webUrl': url,
}
this.showLoading();
o2.Actions.load("x_program_center").AppPackAction.publishApk(data, function(json){
this.hiddenLoading();
if (json.data && json.data.value) {
// 提交成功 获取最新打包对象信息
this.loadAppPackInfo();
}else {
this.app.notice(json.message, "error", this.contentAreaNode);
}
}.bind(this), function (error) {
this.hiddenLoading();
console.log(error);
this.app.notice(error, "error", this.contentAreaNode);
}.bind(this));
} else {
console.log("没有打包信息,不能发布");
}
},
// 重新输入 提交表单
reInput: function () {
// 填充内容
......@@ -315,6 +385,11 @@ MWF.xApplication.Setting.AppPackOnlineDocument = new Class({
this.apppackPortInputNode.set("value", this.packInfo.o2ServerPort);
this.apppackContextInputNode.set("value", this.packInfo.o2ServerContext);
this.apppackAppNameInputNode.set("value", this.packInfo.appName);
var isPackAppIdOuter = false;
if (this.packInfo.isPackAppIdOuter && this.packInfo.isPackAppIdOuter === "2") {
isPackAppIdOuter = true;
}
this.apppackIsPackAppIdOuterInputNode.set("checked", isPackAppIdOuter);
}
this.showForm();
},
......@@ -415,6 +490,7 @@ MWF.xApplication.Setting.AppPackOnlineDocument = new Class({
this.app.notice(this.lp.mobile_apppack_message_context_not_empty, "error", this.contentAreaNode);
return;
}
var isPackAppIdOuter = this.apppackIsPackAppIdOuterInputNode.checked ? "2" : "1";
this.confirm(this.lp.alert, this.lp.mobile_apppack_message_alert_submit, function() {
this.showLoading();
var formData = new FormData();
......@@ -425,6 +501,7 @@ MWF.xApplication.Setting.AppPackOnlineDocument = new Class({
formData.append('o2ServerHost', host);
formData.append('o2ServerPort', port);
formData.append('o2ServerContext', context);
formData.append('isPackAppIdOuter', isPackAppIdOuter);
formData.append('token', this.token);
o2.Actions.load("x_program_center").AppPackAction.androidPackStart(formData, "{}",function (json) {
......
......@@ -271,10 +271,20 @@ MWF.xApplication.Setting.LP = {
"mobile_apppack_form_button": "Submit and start packaging",
"mobile_apppack_form_reinput_button": "Fill out the form again and pack it",
"mobile_apppack_form_re_pack_button": "Use original data to package directly",
"mobile_apppack_form_download_apk_button": "Download APK file",
"mobile_apppack_message_o2cloud_not_enable": "O2 Cloud is not enabled or cannot be connected!",
"mobile_apppack_message_o2cloud_not_login": "Please log in to O2 cloud first!",
"mobile_apppack_message_apppack_server_login_fail": "App package server login failed!",
"mobile_apppack_message_check_connect_fail": "App packaging service check connection failed!",
"mobile_apppack_form_enable_outer_status_no": "Not Enabled",
"mobile_apppack_form_enable_outer_status_yes": "Enabled",
"mobile_apppack_form_enable_outer_package": "Enable external package name",
"mobile_apppack_form_enable_outer_tips": "Enabling external package names can prevent conflicts and overwrites with officially released apps",
"mobile_apppack_form_download_publish_btn": "Download and publish to local",
"mobile_apppack_message_confirm_publish": "The app has been packaged. Download it and publish it to the local server immediately. You can scan the code and install it directly!",
"mobile_apppack_publish_status_doing": "In release ...",
"mobile_apppack_publish_status_completed": "After the release is completed, the QR code of the code scanning login interface can install the app!",
"mobile_apppack_publish_status_fail": "Publishing failed, please try again or contact the administrator!",
"mobile_apppack_status_order_inline": "In line ......",
"mobile_apppack_status_packing": "Packing......",
"mobile_apppack_status_pack_end": "Package complete",
......
......@@ -271,11 +271,22 @@ MWF.xApplication.Setting.LP = {
"mobile_apppack_form_button": "提交并开始打包",
"mobile_apppack_form_reinput_button": "重新填写表单并打包",
"mobile_apppack_form_re_pack_button": "使用原有资料直接打包",
"mobile_apppack_form_download_apk_button": "下载APK文件",
"mobile_apppack_message_o2cloud_not_enable": "O2云未启用或无法连接!",
"mobile_apppack_message_o2cloud_not_login": "请先登录O2云!",
"mobile_apppack_message_apppack_server_login_fail": "App打包服务器登录失败!",
"mobile_apppack_message_check_connect_fail": "App打包服务检查连接失败!",
"mobile_apppack_form_enable_outer_status_no": "未启用",
"mobile_apppack_form_enable_outer_status_yes": "已启用",
"mobile_apppack_form_enable_outer_package": "是否启用外部包名",
"mobile_apppack_form_enable_outer_tips": "启用外部包名可以防止和官方发布的APP冲突覆盖",
"mobile_apppack_form_download_publish_btn": "下载发布到本地",
"mobile_apppack_message_confirm_publish": "app已经打包完成,马上下载发布到本地服务器就可以直接扫码安装!",
"mobile_apppack_publish_status_doing": "发布中...",
"mobile_apppack_publish_status_completed": "发布完成,扫码登录界面的二维码可以安装APP!",
"mobile_apppack_publish_status_fail": "发布失败,请重试或联系管理员!",
"mobile_apppack_status_order_inline": "排队中......",
"mobile_apppack_status_packing": "打包中......",
"mobile_apppack_status_pack_end": "打包完成",
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment