洲际酒店任务元素开发、delwithbug修复

jingwei
youhong.ai 2023-05-12 11:15:29 +08:00
parent daaefd64c2
commit 0cc0b9889a
12 changed files with 386 additions and 209 deletions

View File

@ -115,6 +115,19 @@ class CusUtils {
return Utils.convertNameObjToId(fieldName)
}
getQueryString(name) {
let reg = new RegExp("(^|&|\/?)" + name + "=([^&]*)(&|$)", "i");
let searchStr = window.location.href
if (searchStr.startsWith('&')) {
searchStr = searchStr.substr(1)
}
let search = searchStr.match(reg)
if (search != null) {
return unescape(search[2]);
}
return null;
}
/**
* 将字段名称转为字段id
* @param fieldObj 字段名称对象 {string|object}

View File

@ -32,6 +32,7 @@ import weaver.file.ImageFileManager;
import javax.ws.rs.core.MediaType;
import java.io.*;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.concurrent.*;
@ -127,7 +128,11 @@ public class HttpUtils {
builder.append("&");
builder.append(entry.getKey());
builder.append("=");
builder.append(entry.getValue());
try {
builder.append(URLEncoder.encode(Util.null2String(entry.getValue()), "UTF-8"));
} catch (UnsupportedEncodingException e) {
builder.append(entry.getKey());
}
}
return removeSeparator(builder);
}

View File

@ -460,7 +460,7 @@ public class ResultMapper {
}
if ("int".equalsIgnoreCase(columnType) || "long".equalsIgnoreCase(columnType) || "number".equalsIgnoreCase(columnType) || "MEDIUMINT".equalsIgnoreCase(columnType) || "TINYINT".equalsIgnoreCase(columnType) || "SMALLINT".equalsIgnoreCase(columnType) || "BIGINT".equalsIgnoreCase(columnType) || "INTEGER".equalsIgnoreCase(columnType)) {
if (enable) {
((Map<? super Object, ? super Object>) o).put(Util.toCamelCase(columnName[i]), rs.getInt(i + 1));
((Map<? super Object, ? super Object>) o).put(Util.toCamelCase(columnName[i]), rs.getInt(columnName[i]));
continue;
}
if (DBConstant.DB_TYPE_ORACLE.equals(rs.getDBType())) {
@ -473,11 +473,11 @@ public class ResultMapper {
}
if ("FLOAT".equalsIgnoreCase(columnType) || "DOUBLE".equalsIgnoreCase(columnType) || "DECIMAL".equalsIgnoreCase(columnType)) {
if (enable) {
((Map<? super Object, ? super Object>) o).put(Util.toCamelCase(columnName[i]), rs.getString(i + 1));
((Map<? super Object, ? super Object>) o).put(Util.toCamelCase(columnName[i]), rs.getString(columnName[i]));
continue;
}
if (DBConstant.DB_TYPE_ORACLE.equals(rs.getDBType())) {
((Map<? super Object, ? super Object>) o).put(Util.toCamelCase(columnName[i]), rs.getString(i + 1));
((Map<? super Object, ? super Object>) o).put(Util.toCamelCase(columnName[i]), rs.getString(columnName[i]));
}
((Map<? super Object, ? super Object>) o).put(columnName[i].toLowerCase(), rs.getString(i + 1));
((Map<? super Object, ? super Object>) o).put(columnName[i].toUpperCase(), rs.getString(i + 1));
@ -507,7 +507,7 @@ public class ResultMapper {
}
}
if (enable) {
((Map<? super Object, ? super Object>) o).put(Util.toCamelCase(columnName[i]), rs.getString(i + 1));
((Map<? super Object, ? super Object>) o).put(Util.toCamelCase(columnName[i]), rs.getString(columnName[i]));
continue;
}
if (DBConstant.DB_TYPE_ORACLE.equals(rs.getDBType())) {
@ -569,7 +569,7 @@ public class ResultMapper {
cassociationValue = paramType.get(declaredField.getType()).apply(String.valueOf(cassociationValue));
}
try {
if (Objects.nonNull(value)) {
if (Objects.nonNull(cassociationValue)) {
propertyDescriptor.getWriteMethod().invoke(o, cassociationValue);
}
} catch (Exception e) {
@ -651,7 +651,6 @@ public class ResultMapper {
Association[] mappings = annotation.value();
Association mapping = null;
for (Association item : mappings) {
Util.getLogger().info("column: " + item.column() + " ===property: " + item.property() + " ====fieldName: " + filedName);
String property = isMap ? item.column() : item.property();
if (isMap ? filedName.equalsIgnoreCase(property) : filedName.equals(property)) {
mapping = item;
@ -664,7 +663,6 @@ public class ResultMapper {
Id id = annotation.id();
String column = annotation.column();
String columnValue = rs.getString(column);
Util.getLogger().info(Arrays.toString(rs.getColumnName()));
if (Objects.isNull(columnValue) || "".equals(columnValue)) {
columnValue = rs.getString(column.toUpperCase());
}

View File

@ -58,4 +58,34 @@ public class TaskElementController {
return ApiResult.error("system error!");
}
}
@Path("/get-btn")
@GET
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public String buttonInfo(@Context HttpServletRequest request,
@Context HttpServletResponse response) {
User user = HrmUserVarify.getUser(request, response);
try {
return ApiResult.success(service.buttonInfo(user));
} catch (Exception e) {
log.error("get button info error!\n" + Util.getErrString(e));
return ApiResult.error("system error!");
}
}
@Path("/clear-config")
@GET
@Produces(MediaType.APPLICATION_JSON)
public String clearConfig() {
try {
service.clearConfig();
return ApiResult.successNoData();
} catch (Exception e) {
log.error("clear config error!\n" + Util.getErrString(e));
return ApiResult.error("system error!");
}
}
}

View File

@ -29,6 +29,11 @@ public class IhgTaskElementConfigItem {
private String unitEn;
/** icon */
private String icon;
/** 移动端图标 */
private String iconMobile;
/** 移动端激活图标 */
private String iconMobileActive;
/** 激活icon */
private String iconActive;
/** 查看权限 */
@ -36,6 +41,9 @@ public class IhgTaskElementConfigItem {
/** 数据来源 */
private String dataSource;
/** 序号 */
private String sortNum;
/** 跳转链接 */
private String link;
/** 数据来源值 */

View File

@ -23,7 +23,7 @@ public interface TaskElementMapper {
*
* @return
*/
@Select("select * from uf_ihg_el_config ")
@Select("select * from uf_ihg_el_config where enable_status = 1")
@Associations({
@Association(
property = "icon",
@ -32,6 +32,14 @@ public interface TaskElementMapper {
@Association(
property = "iconActive",
column = "icon_active",
id = @Id(methodId = 1, value = String.class)),
@Association(
property = "iconMobile",
column = "icon_mobile",
id = @Id(methodId = 1, value = String.class)),
@Association(
property = "iconMobileActive",
column = "icon_mobile_active",
id = @Id(methodId = 1, value = String.class))
})
List<IhgTaskElementConfigItem> selectConfig();
@ -42,7 +50,7 @@ public interface TaskElementMapper {
* @param configId id
* @return
*/
@Select("select * from uf_ihg_el_config where id = #{configId}")
@Select("select * from uf_ihg_el_config where id = #{configId} and enable_status = 1")
@Associations({
@Association(
property = "icon",
@ -51,6 +59,14 @@ public interface TaskElementMapper {
@Association(
property = "iconActive",
column = "icon_active",
id = @Id(methodId = 1, value = String.class)),
@Association(
property = "iconMobile",
column = "icon_mobile",
id = @Id(methodId = 1, value = String.class)),
@Association(
property = "iconMobileActive",
column = "icon_mobile_active",
id = @Id(methodId = 1, value = String.class))
})
IhgTaskElementConfigItem selectConfig(@ParamMapper("configId") String configId);
@ -72,7 +88,6 @@ public interface TaskElementMapper {
* @param viewAuthoritySql sql
* @param user
* @param map
* @param where
* @return
*/
@Select(custom = true)
@ -86,6 +101,7 @@ public interface TaskElementMapper {
* @param customerValue sql
* @param item
* @param user
* @param map
* @param where
* @return
*/
@ -93,5 +109,16 @@ public interface TaskElementMapper {
List<Map<String, Object>> selectWorkList(@SqlString String customerValue,
@ParamMapper("param") Map<String, Object> item,
@ParamMapper("user") User user,
@ParamMapper("where") Map<String, Object> where);
@ParamMapper("where") Map<String, Object> where,
@ParamMapper("current") Map<String, Object> map);
/**
* <h2></h2>
*
* @param sql
* @param o
* @return
*/
@Select(custom = true)
String selectConvert(@SqlString String sql, @ParamMapper("value") String o);
}

View File

@ -9,13 +9,11 @@ import com.api.youhong.ai.ihgzhouji.taskele.entity.IhgTaskElementConfigItem;
import com.api.youhong.ai.ihgzhouji.taskele.mapper.TaskElementMapper;
import com.api.youhong.ai.ihgzhouji.taskele.mapstruct.TaskElementMapstruct;
import com.api.youhong.ai.ihgzhouji.taskele.vo.IhgTaskElementVo;
import org.apache.log4j.Logger;
import weaver.conn.RecordSet;
import weaver.hrm.User;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.stream.Collectors;
/**
* <h1>service</h1>
@ -26,6 +24,29 @@ import java.util.stream.Collectors;
*/
public class TaskElementService {
private final TaskElementMapper mapper = Util.getMapper(TaskElementMapper.class);
private final Logger log = Util.getLogger();
private final RecordSet rs = new RecordSet();
private volatile Map<String, Object> config = null;
public void clearConfig() {
this.config = null;
}
private Map<String, Object> getConfig() {
if (this.config == null) {
synchronized (TaskElementService.class) {
if (this.config == null) {
this.config = Util.readProperties2Map("IHGWorkListInfoConvert", "cus");
if (config == null) {
this.config = Collections.emptyMap();
}
}
}
}
return config;
}
public List<IhgTaskElementVo> getList(User user) {
List<IhgTaskElementConfigItem> ihgTaskElementConfItemList = mapper.selectConfig();
@ -50,7 +71,7 @@ public class TaskElementService {
for (Map.Entry<IhgTaskElementConfigItem, List<Map<String, Object>>> entry : taskConfigMap.entrySet()) {
IhgTaskElementConfigItem taskElementConfigItem = entry.getKey();
List<Map<String, Object>> authorityList = entry.getValue();
List<Map<String, Object>> workList = queryWorkList(taskElementConfigItem, authorityList, user, "", Collections.emptyMap());
List<Map<String, Object>> workList = queryWorkList(taskElementConfigItem, authorityList, user, "", Collections.emptyMap(), map);
IhgTaskElementVo ihgTaskElementVo = TaskElementMapstruct.INSTANCE.entity2Vo(taskElementConfigItem);
ihgTaskElementVo.setList(workList);
ihgTaskElementVo.setSize(workList.size());
@ -60,26 +81,44 @@ public class TaskElementService {
}
result.add(ihgTaskElementVo);
}
result.sort(Comparator.comparing(item -> StrUtil.isBlank(item.getSortNum()) ? -1 : Integer.parseInt(item.getSortNum())));
return result;
}
private List<Map<String, Object>> queryWorkList(IhgTaskElementConfigItem taskElementConfigItem,
List<Map<String, Object>> authorityList,
User user, String whereStr,
Map<String, Object> whereMap) {
Map<String, Object> whereMap,
Map<String, Object> currentMap) {
String dataSource = taskElementConfigItem.getDataSource();
String customerValue = taskElementConfigItem.getCustomerValue();
if (StrUtil.isBlank(customerValue)) {
throw new CustomerException("自定义sql或自定义接口不能为空");
}
List<Map<String, Object>> result = new ArrayList<>();
Map<String, Object> convertConfig = getConfig();
for (Map<String, Object> item : authorityList) {
if ("0".equals(dataSource)) {
// 自定义sql
customerValue += " " + whereStr;
List<Map<String, Object>> list = mapper.selectWorkList(customerValue, item, user, whereMap);
List<Map<String, Object>> list = mapper.selectWorkList(customerValue, item, user, whereMap, currentMap);
if (CollectionUtil.isNotEmpty(list)) {
result.addAll(list);
Map<String, Object> convert = (Map<String, Object>) convertConfig.get("convert");
if (Objects.nonNull(convert)) {
// 自定义转换设置
for (Map<String, Object> listItem : list) {
for (Map.Entry<String, Object> entry : convert.entrySet()) {
String sql = Util.null2String(entry.getValue());
String replace = sql.replace("$?$", "#{value}");
if (StrUtil.isNotBlank(replace)) {
String value = mapper.selectConvert(replace, Util.null2String(listItem.get(Util.null2String(entry.getKey()))));
listItem.put(entry.getKey(), value);
}
}
}
}
}
} else {
// 自定义接口
@ -99,18 +138,23 @@ public class TaskElementService {
}
}
}
// 去重
result = result.stream()
.filter(distinctByKey(item -> item.get("id")))
.collect(Collectors.toList());
return result;
return removeDuplicates(result);
}
static <T> Predicate<T> distinctByKey(Function<? super T, ?> keyExtractor) {
Map<Object, Boolean> seen = new ConcurrentHashMap<>(8);
return t -> seen.putIfAbsent(keyExtractor.apply(t), Boolean.TRUE) == null;
public List<Map<String, Object>> removeDuplicates(List<Map<String, Object>> list) {
Set<String> idSet = new HashSet<>();
List<Map<String, Object>> resultList = new ArrayList<>();
for (Map<String, Object> map : list) {
String id = Util.null2String(map.get("id"));
if (!idSet.contains(id)) {
idSet.add(id);
resultList.add(map);
}
}
return resultList;
}
/**
* <h2></h2>
@ -134,8 +178,14 @@ public class TaskElementService {
Map<String, Object> valueMap = (Map<String, Object>) entry.getValue();
String key = Util.null2String(valueMap.get("key"));
String value = Util.null2String(valueMap.get("value"));
String type = Util.null2String(valueMap.get("type"));
if (StrUtil.isNotBlank(value)) {
if ("like".equalsIgnoreCase(type)) {
value = "%" + value + "%";
builder.append(" and ").append(key).append(" like ").append("#{where.").append(key).append("}");
} else {
builder.append(" and ").append(key).append(" = ").append("#{where.").append(key).append("}");
}
map.put(key, value);
}
}
@ -147,7 +197,7 @@ public class TaskElementService {
return null;
}
// 查询数据
List<Map<String, Object>> workList = this.queryWorkList(ihgTaskElementConfItem, authorityList, user, whereStr, map);
List<Map<String, Object>> workList = this.queryWorkList(ihgTaskElementConfItem, authorityList, user, whereStr, map, map);
IhgTaskElementVo ihgTaskElementVo = TaskElementMapstruct.INSTANCE.entity2Vo(ihgTaskElementConfItem);
ihgTaskElementVo.setList(workList);
ihgTaskElementVo.setSize(workList.size());
@ -157,4 +207,35 @@ public class TaskElementService {
}
return ihgTaskElementVo;
}
/**
* <h2></h2>
*
* @param user
* @return
*/
public Map<String, Object> buttonInfo(User user) {
String sendWorkButtonAuthority = Util.getCusConfigValue("SEND_WORK_BUTTON_AUTHORITY");
String sendWorkButtonLink = Util.getCusConfigValue("SEND_WORK_BUTTON_LINK");
String workListButtonAuthority = Util.getCusConfigValue("WORK_LIST_BUTTON_AUTHORITY");
String workListButtonLink = Util.getCusConfigValue("WORK_LIST_BUTTON_LINK");
Map<String, Object> result = new HashMap<>(8);
// 设置查询基础参数
Map<String, Object> map = new HashMap<>(8);
map.put("currentDate", Util.getTime("yyyy-MM-dd"));
map.put("currentTime", Util.getTime("HH:mm:ss"));
if (StrUtil.isNotBlank(sendWorkButtonAuthority)) {
List<Map<String, Object>> maps = mapper.selectAuthority(sendWorkButtonAuthority, user, map);
if (CollectionUtil.isNotEmpty(maps)) {
result.put("sendWork", sendWorkButtonLink);
}
}
if (StrUtil.isNotBlank(sendWorkButtonAuthority)) {
List<Map<String, Object>> maps = mapper.selectAuthority(workListButtonAuthority, user, map);
if (CollectionUtil.isNotEmpty(maps)) {
result.put("workList", workListButtonLink);
}
}
return result;
}
}

View File

@ -25,15 +25,18 @@ public class IhgTaskElementVo {
private String title;
/** 单位 */
private String unit;
/** icon */
private String icon;
/** 激活icon */
private String iconActive;
/** 移动端图标 */
private String iconMobile;
/** 移动端激活图标 */
private String iconMobileActive;
/** 跳转链接 */
private String link;
/** 序号 */
private String sortNum;
/** 数据长度 */
private Integer size;
/** 数据 */

View File

@ -1297,8 +1297,11 @@ public class DealWithMapping extends ToolUtil {
if (null == resultList || resultList.isEmpty()) {
return;
}
if (Objects.isNull(childList) || childList.isEmpty()) {
list.addAll(resultList);
return;
}
if ("0".equals(childType)) {
// 对象类型
for (Object o : resultList) {
Map<String, Object> item = new HashMap<>();
@ -1376,6 +1379,10 @@ public class DealWithMapping extends ToolUtil {
if (null == resultList || resultList.isEmpty()) {
return;
}
if (Objects.isNull(childList) || childList.isEmpty()) {
list.addAll(resultList);
return;
}
if ("0".equals(childType)) {
// 对象类型

View File

@ -0,0 +1,2 @@
# 任务接受人转换规则
cus.convert.rwjsr=select lastname from hrmresource where id = $?$

View File

@ -62,16 +62,13 @@ public class DecentralizationOfPowersCronJob extends BaseCronJob {
for (OrgInfoHotelEntity orgInfoHotelEntity : hotelInfoList) {
insertSysdetachinfo(orgInfoHotelEntity);
}
log.info("查询酒店后信息数据: " + hotelInfoList.size());
// 将没有infoID的数据过滤
List<OrgInfoHotelEntity> hasInfoIdHotelInfo = hotelInfoList.stream()
.filter(item -> item.getInfoId() != null && item.getInfoId() > 0)
.collect(Collectors.toList());
log.info("过滤后数据信息:" + hasInfoIdHotelInfo.size());
Map<String, List<OrgInfoHotelEntity>> groupByUpdate = hasInfoIdHotelInfo
.stream().collect(Collectors.groupingBy(OrgInfoHotelEntity::getUpdate));
log.info("分组后数据信息:" + groupByUpdate.size());
List<OrgInfoHotelEntity> updateInfo = groupByUpdate.get("true");
List<OrgInfoHotelEntity> insertInfo = groupByUpdate.get("false");
if (updateInfo == null) {
@ -85,7 +82,6 @@ public class DecentralizationOfPowersCronJob extends BaseCronJob {
List<List> lists = OrgInfoHotelEntity.orgInfoHotelEntityToSqlList(item, "");
insertSqlArgs.addAll(lists);
});
log.info("将待插入数据插入数据表中: " + insertSqlArgs.size());
if (!insertSqlArgs.isEmpty()) {
boolean insertSuccess = recordSet.executeBatchSql(OrgInfoHotelEntity.getInsertSql(), insertSqlArgs);
if (!insertSuccess) {
@ -96,7 +92,6 @@ public class DecentralizationOfPowersCronJob extends BaseCronJob {
List<OrgInfoHotelEntity> updateDetachDetailList = new ArrayList<>();
List<OrgInfoHotelEntity> insertDetachDetailList = new ArrayList<>();
for (OrgInfoHotelEntity orgInfoHotelEntity : updateInfo) {
log.info("循环查询权限ID " + orgInfoHotelEntity);
Integer detachdetailId1 = mapper.selectSysdetachdetailByInfoIdAndYh(orgInfoHotelEntity.getInfoId(), 1);
if (null != detachdetailId1 && detachdetailId1 > 0) {
// 需要更新
@ -120,8 +115,6 @@ public class DecentralizationOfPowersCronJob extends BaseCronJob {
insertDetachDetailList.add(orgInfoHotelEntity);
}
}
log.info("需要插入的数据: " + insertDetachDetailList.size());
log.info("需要更新的数据: " + updateDetachDetailList.size());
insertSqlArgs.clear();
insertDetachDetailList.forEach(item -> {
List<List> lists = OrgInfoHotelEntity.orgInfoHotelEntityToSqlList(item, "");

View File

@ -3,6 +3,8 @@ package youhong.ai.yihong;
import aiyh.utils.Util;
import basetest.BaseTest;
import com.alibaba.fastjson.JSON;
import com.api.youhong.ai.ihgzhouji.taskele.entity.IhgTaskElementConfigItem;
import com.api.youhong.ai.ihgzhouji.taskele.mapper.TaskElementMapper;
import org.junit.Test;
import weaver.youhong.ai.yihong.formmode.stagediagram.mapper.ModeExpandSaveActionMapper;
import weaver.youhong.ai.yihong.formmode.stagediagram.pojo.StageUpdateFieldConfig;
@ -35,4 +37,12 @@ public class YiHongTest extends BaseTest {
System.out.println(strings.stream().filter(item -> !item.equals("2")).collect(Collectors.toList()));
}
@Test
public void tesetst() {
TaskElementMapper mapper = Util.getMapper(TaskElementMapper.class);
List<IhgTaskElementConfigItem> ihgTaskElementConfigItems = mapper.selectConfig();
System.out.println(JSON.toJSONString(ihgTaskElementConfigItems));
}
}