Commit 2a8c262b authored by 赵啸非's avatar 赵啸非

添加站点返回提示信息

parent 04771f08
package com.mortals.xhx.module.matter.service;
import com.mortals.framework.common.Rest;
import com.mortals.framework.model.Context;
import com.mortals.framework.service.ICRUDCacheService;
import com.mortals.framework.service.ICRUDService;
......@@ -22,7 +23,7 @@ public interface MatterService extends ICRUDCacheService<MatterEntity,Long> {
* @param siteId
* @param context
*/
void addMatterToSite(String matterIds, Long siteId, Context context);
Rest<String> addMatterToSite(String matterIds, Long siteId, Context context);
/**
......
......@@ -7,6 +7,7 @@ import cn.hutool.setting.Setting;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.mortals.framework.common.Rest;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context;
import com.mortals.framework.model.PageInfo;
......@@ -111,18 +112,45 @@ public class MatterServiceImpl extends AbstractCRUDCacheServiceImpl<MatterDao, M
}
@Override
public void addMatterToSite(String matterIds, Long siteId, Context context) {
public Rest<String> addMatterToSite(String matterIds, Long siteId, Context context) {
if (ObjectUtils.isEmpty(siteId)) {
throw new AppException("请选择对应站点");
}
List<Long> matterIdList = Arrays.asList(matterIds.split(",")).stream().map(Long::parseLong).collect(Collectors.toList());
MatterQuery matterQuery = new MatterQuery();
matterQuery.setIdList(matterIdList);
this.find(matterQuery).stream()
.peek(item -> updateOrSave(item, siteId, context)).count();
List<MatterEntity> matterEntities = this.find(matterQuery);
int success = 0;
int fail = 0;
for (MatterEntity matterEntity : matterEntities) {
Boolean bool = updateOrSave(matterEntity, siteId, context);
if (bool) {
success++;
} else {
fail++;
}
}
String msg = "当前加入事项已存在!";
if (matterIdList.size() == 1) {
if (success > 0) {
msg = "加入事项成功!";
}
} else if (matterIdList.size() > 1) {
if (success > 0 && fail == 0) {
msg = String.format("加入事项成功%d条!", success);
} else if (success > 0 && fail > 0) {
msg = String.format("加入事项成功%d条,重复加入事项%d条!", success, fail);
} else if (success == 0 && fail > 0) {
msg = String.format("重复加入事项%d条!", fail);
}
}
return Rest.ok(msg);
}
private void updateOrSave(MatterEntity item, Long siteId, Context context) {
private Boolean updateOrSave(MatterEntity item, Long siteId, Context context) {
SiteMatterEntity siteMatterEntity = siteMatterService.selectOne(new SiteMatterQuery().siteId(siteId).matterId(item.getId()));
if (ObjectUtils.isEmpty(siteMatterEntity)) {
siteMatterEntity = new SiteMatterEntity();
......@@ -134,7 +162,9 @@ public class MatterServiceImpl extends AbstractCRUDCacheServiceImpl<MatterDao, M
siteMatterEntity.setCreateUserId(context == null ? 1L : context.getUser() == null ? 1L : context.getUser().getId());
siteMatterEntity.setCreateTime(new Date());
siteMatterService.save(siteMatterEntity, context);
return true;
}
return false;
}
......
......@@ -2,6 +2,7 @@ package com.mortals.xhx.module.matter.web;
import cn.hutool.setting.Setting;
import com.alibaba.fastjson.JSONObject;
import com.mortals.framework.common.Rest;
import com.mortals.framework.model.Context;
import com.mortals.framework.util.DataUtil;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
......@@ -79,18 +80,18 @@ public class MatterController extends BaseCRUDJsonBodyMappingController<MatterSe
Setting baseInfoSetting = interceptorConfig.getBaseInfoSetting();
Map<String, String> baseInfoMap = new HashMap<>();
baseInfoSetting.entrySet().stream().forEach(item->{
if(!ObjectUtils.isEmpty(item.getValue())){
baseInfoMap.put( item.getValue(), item.getKey());
baseInfoSetting.entrySet().stream().forEach(item -> {
if (!ObjectUtils.isEmpty(item.getValue())) {
baseInfoMap.put(item.getValue(), item.getKey());
}
});
this.addDict(model, "baseInfo", baseInfoMap);
Setting sqclInfoSetting = interceptorConfig.getSqclInfoSetting();
Map<String, String> sqclInfoMap = new HashMap<>();
sqclInfoSetting.entrySet().stream().forEach(item->{
if(!ObjectUtils.isEmpty(item.getValue())){
sqclInfoMap.put( item.getValue(), item.getKey());
sqclInfoSetting.entrySet().stream().forEach(item -> {
if (!ObjectUtils.isEmpty(item.getValue())) {
sqclInfoMap.put(item.getValue(), item.getKey());
}
});
this.addDict(model, "sqclInfo", sqclInfoMap);
......@@ -107,10 +108,11 @@ public class MatterController extends BaseCRUDJsonBodyMappingController<MatterSe
JSONObject jsonObject = new JSONObject();
Map<String, Object> model = new HashMap<String, Object>();
String matterIds = (String) map.get("matterIds");
Long siteId = DataUtil.converStr2Long(map.get("siteId").toString(),0L) ;
Long siteId = DataUtil.converStr2Long(map.get("siteId").toString(), 0L);
try {
this.service.addMatterToSite(matterIds, siteId, getContext());
Rest<String> rest = this.service.addMatterToSite(matterIds, siteId, getContext());
jsonObject.put(KEY_RESULT_MSG, rest.getData());
jsonObject.put(KEY_RESULT_DATA, model);
jsonObject.put(KEY_RESULT_CODE, VALUE_RESULT_SUCCESS);
} catch (Exception e) {
......
......@@ -18,6 +18,11 @@ GATEWAY_PORT="@profiles.server.gatewayport@"
SHELL_LOG="${BASEDIR}/${SHELL_NAME}.log"
MYSQL_HOST="127.0.0.1"
MYSQL_PORT="3306"
MYSQL_USER="root"
MYSQL_PASSWORD="xhx@2022"
SERVICE_PATH="/usr/lib/systemd/system"
JAVA_HOME="/usr/local/java/jdk1.8"
......@@ -139,7 +144,7 @@ start_service_and_nginx() {
systemctl enable ${PROJECT_NAME}
systemctl daemon-reload
systemctl stop ${PROJECT_NAME} && systemctl start ${PROJECT_NAME}
project_status=$(systemctl status "${PROJECT_NAME}"|grep Active |awk '{print $2}')
project_status=$(systemctl status "${PROJECT_NAME}" | grep Active | awk '{print $2}')
nginx -t
nginx -s reload
jcpid=$(ps -ef | grep -v "grep" | grep "${PROJECT_NAME} " | awk '{print $2}')
......@@ -164,7 +169,13 @@ project_ui_deploy() {
clear_ui_deploy ${PROJECT_UI_EXECPATH}
tar -zvxf ./${PROJECT_UI_FILENAME} -C ${PUBLISH_PATH}
writelog "${PROJECT_NAME}_ui_deploy_finish"
}
init_db() {
writelog "${PROJECT_NAME}_db_init"
mysql -h${MYSQL_HOST} -P${MYSQL_PORT} -u${MYSQL_USER} -p${MYSQL_PASSWORD} <${EXECPATH}/db/db.sql
mysql -h${MYSQL_HOST} -P${MYSQL_PORT} -u${MYSQL_USER} -p${MYSQL_PASSWORD} <${EXECPATH}/db/menu.sql
writelog "${PROJECT_NAME}_db_init"
}
#主函数
......@@ -176,4 +187,32 @@ main() {
exit ${RETVAL}
}
init_params(){
#获取参数
while getopts h:P:u:p opt; do
case $opt in
h)
#echo "-mysql-host ---- $OPTARG"
MYSQL_HOST=$OPTARG
;;
P)
#echo "-mysql-port ---- $OPTARG"
MYSQL_PORT=$OPTARG
;;
u)
#echo "-mysql-user ---- $OPTARG"
MYSQL_USER=$OPTARG
;;
p)
#echo "-mysql-password ---- $OPTARG"
MYSQL_PASSWORD=$OPTARG
;;
?)
echo "$opt is an invalid option"
;;
esac
done
}
main $1
Markdown is supported
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