Compare commits

...

7 Commits

@ -1,6 +1,6 @@
<component name="ArtifactManager"> <component name="ArtifactManager">
<artifact type="jar" name="weaver-develop:jar"> <artifact type="jar" name="weaver-develop:jar">
<output-path>$PROJECT_DIR$/out/artifacts/weaver_develop_jar</output-path> <output-path>$PROJECT_DIR$/../../../../weaver/ecology/WEB-INF/lib</output-path>
<root id="archive" name="weaver-develop.jar"> <root id="archive" name="weaver-develop.jar">
<element id="module-output" name="weaver-develop" /> <element id="module-output" name="weaver-develop" />
</root> </root>

@ -0,0 +1,13 @@
package com.api.jclattendance.web;
import javax.ws.rs.Path;
/**
* @Author liang.cheng
* @Date 2023/12/26 6:52 PM
* @Description:
* @Version 1.0
*/
@Path("/bs/jcl/workrules")
public class WorkRulesController extends com.engine.jclattendance.web.WorkRulesController{
}

@ -1,13 +0,0 @@
package com.api.jygf.web;
import javax.ws.rs.Path;
/**
* @Author weaver_cl
* @Description:
* @Date 2022/10/9
* @Version V1.0
**/
@Path("/mobile/permission")
public class MobilePermissionsAction extends com.engine.jygf.web.MobilePermissionsAction {
}

@ -0,0 +1,22 @@
package com.engine.jclattendance.exception;
/**
* @Author liang.cheng
* @Date 2023/11/16 2:37 PM
* @Description: TODO
* @Version 1.0
*/
public class CustomizeRunTimeException extends RuntimeException{
public CustomizeRunTimeException(String message) {
super(message);
}
public CustomizeRunTimeException(Throwable cause) {
super(cause);
}
public CustomizeRunTimeException(String message, Throwable cause) {
super(message, cause);
}
}

@ -0,0 +1,21 @@
package com.engine.jclattendance.service;
import java.util.Map;
/**
* @Author liang.cheng
* @Date 2023/12/26 6:53 PM
* @Description: TODO
* @Version 1.0
*/
public interface WorkRulesService {
/**
* @Description:
* @Author: liang.cheng
* @Date: 2023/12/26 7:18 PM
* @param: [resourceIds]
* @return: java.lang.String
*/
Map<String, Object> getWorkRulesList(String resourceIds);
}

@ -0,0 +1,64 @@
package com.engine.jclattendance.service.impl;
import com.cloudstore.eccom.constant.WeaBoolAttr;
import com.cloudstore.eccom.pc.table.WeaTable;
import com.cloudstore.eccom.pc.table.WeaTableColumn;
import com.cloudstore.eccom.pc.table.WeaTableType;
import com.cloudstore.eccom.result.WeaResultMsg;
import com.engine.core.impl.Service;
import com.engine.jclattendance.service.WorkRulesService;
import weaver.conn.RecordSet;
import weaver.conn.constant.DBConstant;
import weaver.general.PageIdConst;
import weaver.systeminfo.SystemEnv;
import java.util.HashMap;
import java.util.Map;
/**
* @Author liang.cheng
* @Date 2023/12/26 6:54 PM
* @Description: TODO
* @Version 1.0
*/
public class WorkRulesServiceImpl extends Service implements WorkRulesService {
@Override
public Map<String, Object> getWorkRulesList(String resourceIds) {
Map<String, Object> resultMap = new HashMap<>(4);
WeaTable table = new WeaTable();
String pageId = "ba1c29c23a8a46d9acff1d2ee4ff5fb3";
table.setPageID(pageId);
table.setPageUID(String.format("%s_%s",pageId,user.getUID()));
String pageSize = PageIdConst.getPageSize(pageId, user.getUID());
table.setPagesize(pageSize);
RecordSet rs=new RecordSet();
String fields = "t.id, t.mc,t.jc,t.ys,CONCAT(kssj, '-', jssj) as bcsj";
if(DBConstant.DB_TYPE_SQLSERVER.equalsIgnoreCase(rs.getDBType())){
fields = "t.id, t.mc,t.jc,t.ys,kssj + '-' + jssj as bcsj";
}
table.setBackfields(fields);
String fromSql = " from uf_jcl_kq_bcxx t";
table.setSqlform(fromSql);
String sqlWhere = " where 1=1 and t.attendance_organization in ("+resourceIds+")";
table.setSqlwhere(sqlWhere);
table.setSqlprimarykey("id");
table.getColumns().add(new WeaTableColumn("id").setDisplay(WeaBoolAttr.FALSE));
table.getColumns().add(new WeaTableColumn("20%", "班次名称", "mc"));
table.getColumns().add(new WeaTableColumn("20%", "简称", "jc"));
table.getColumns().add(new WeaTableColumn("20%", "颜色", "ys"));
table.getColumns().add(new WeaTableColumn("40%", "班次时间", "bcsj"));
table.setTableType(WeaTableType.RADIO);
WeaResultMsg result = new WeaResultMsg(false);
result.putAll(table.makeDataResult());
result.success();
resultMap.putAll(result.getResultMap());
return resultMap;
}
}

@ -0,0 +1,20 @@
package com.engine.jclattendance.util;
/**
* @Author liang.cheng
* @Date 2023/11/16 2:37 PM
* @Description: TODO
* @Version 1.0
*/
public class ExceptionUtil {
public static String getRealMessage(Throwable e) {
while (e != null) {
Throwable cause = e.getCause();
if (cause == null) {
return e.getMessage();
}
e = cause;
}
return "";
}
}

@ -0,0 +1,184 @@
package com.engine.jclattendance.util;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.engine.core.exception.ECException;
import com.engine.jclattendance.exception.CustomizeRunTimeException;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.slf4j.Slf4j;
import weaver.general.BaseBean;
import weaver.hrm.User;
import java.util.HashMap;
import java.util.Map;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Supplier;
@Slf4j
public class ResponseResult<T, R> {
private static final long serialVersionUID = 1L;
private final User user;
private final BaseBean baseBean = new BaseBean();
private final Boolean isLog = "true".equals(baseBean.getPropValue("hrmSalary", "log"));
public ResponseResult(User user) {
this.user = user;
}
/**
* ()
*/
public String customRun(Function<T, R> f, T t) {
try {
if (isLog) {
log.info("run api , param {}", t);
}
return getJsonString(f.apply(t));
} catch (CustomizeRunTimeException e) {
log.error("api run fail", e);
return Error(e.getMessage());
} catch (ECException e) {
log.error("api run fail", e);
Throwable cause = e.getCause();
return Error(cause.getMessage());
} catch (Exception e) {
log.error("api run fail", e);
return Error("系统异常!");
}
}
/**
*
*/
public String run(Function<T, R> f, T t) {
try {
if (isLog) {
log.info("run api , param {}", t);
}
return Ok(f.apply(t));
} catch (CustomizeRunTimeException e) {
log.error("api run fail", e);
return Error(e.getMessage());
} catch (ECException e) {
log.error("api run fail", e);
Throwable cause = e.getCause();
return Error(cause.getMessage());
} catch (Exception e) {
log.error("api run fail", e);
return Error("系统异常!");
}
}
/**
*
*/
public String run(Consumer<T> f, T t) {
try {
if (isLog) {
log.info("run api , param {}", t);
}
f.accept(t);
return Ok();
} catch (CustomizeRunTimeException e) {
log.error("api run fail", e);
return Error(e.getMessage());
} catch (ECException e) {
log.error("api run fail", e);
return Error(ExceptionUtil.getRealMessage(e));
} catch (Exception e) {
log.error("api run fail", e);
return Error("系统异常!", e);
}
}
/**
*
*/
public String run(Supplier<R> f) {
try {
if (isLog) {
log.info("run api");
}
return Ok(f.get());
} catch (CustomizeRunTimeException e) {
log.error("api run fail", e);
return Error(e.getMessage());
} catch (ECException e) {
log.error("api run fail", e);
Throwable cause = e.getCause();
return Error(cause.getMessage());
} catch (Exception e) {
log.error("api run fail", e);
return Error("系统异常!", e);
}
}
private static String getJsonString(Object apidatas) {
ObjectMapper mapper = new ObjectMapper();
try {
return mapper.writeValueAsString(apidatas);
} catch (JsonProcessingException e) {
e.printStackTrace();
}
return "";
}
/**
*
*/
private String Ok() {
Map<String, Object> apidatas = new HashMap<>();
apidatas.put("api_status", true);
return JSONObject.toJSONString(apidatas, SerializerFeature.DisableCircularReferenceDetect);
}
/**
*
*/
private String Ok(R r) {
Map<String, Object> apidatas = new HashMap<>();
apidatas.put("api_status", true);
apidatas.put("data", r);
String success = getJsonString(apidatas);
if (isLog) {
log.info("run salary api success return {}", success);
}
return success;
}
/**
*
*/
private static String Error(String message) {
Map<String, Object> apidatas = new HashMap<>();
apidatas.put("api_status", false);
apidatas.put("errormsg", message);
return JSONObject.toJSONString(apidatas, SerializerFeature.DisableCircularReferenceDetect);
}
/**
*
*/
private static String Error(String message, Exception e) {
Map<String, Object> apidatas = new HashMap<>();
apidatas.put("api_status", false);
apidatas.put("errormsg", message);
apidatas.put("error", e.getMessage());
return JSONObject.toJSONString(apidatas, SerializerFeature.DisableCircularReferenceDetect);
}
}

@ -0,0 +1,42 @@
package com.engine.jclattendance.web;
import com.engine.common.util.ServiceUtil;
import com.engine.jclattendance.service.WorkRulesService;
import com.engine.jclattendance.service.impl.WorkRulesServiceImpl;
import com.engine.jclattendance.util.ResponseResult;
import weaver.hrm.HrmUserVarify;
import weaver.hrm.User;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import java.util.Map;
/**
* @Author liang.cheng
* @Date 2023/12/26 6:52 PM
* @Description: TODO
* @Version 1.0
*/
public class WorkRulesController {
private WorkRulesService getReportCollectService(User user) {
return ServiceUtil.getService(WorkRulesServiceImpl.class,user);
}
@GET
@Path("/list")
@Produces(MediaType.APPLICATION_JSON)
public String getWorkRulesList(@Context HttpServletRequest request, @Context HttpServletResponse response,
@QueryParam("resourceIds") String resourceIds) {
User user = HrmUserVarify.getUser(request, response);
return new ResponseResult<String, Map<String, Object>>(user).run(getReportCollectService(user) :: getWorkRulesList,resourceIds);
}
}

@ -1,68 +0,0 @@
package com.engine.jygf.cmd;
import com.engine.common.biz.AbstractCommonCommand;
import com.engine.common.entity.BizLogContext;
import com.engine.core.interceptor.CommandContext;
import org.apache.commons.lang3.StringUtils;
import weaver.conn.RecordSet;
import weaver.hrm.User;
import weaver.wechat.util.Utils;
import java.util.*;
/**
* @Author weaver_cl
* @Description:
* @Date 2022/10/9
* @Version V1.0
**/
public class MobilePermissionsCmd extends AbstractCommonCommand<Map<String, Object>> {
private static final String FIELDID = "field100043"; //移动电话自定义字段field100026
private static final String SCOPE = "HrmCustomFieldByInfoType";
private static final String SCOPEID = "-1";
public MobilePermissionsCmd(Map<String, Object> params, User user) {
this.user = user;
this.params = params;
}
@Override
public BizLogContext getLogContext() {
return null;
}
@Override
public Map<String, Object> execute(CommandContext commandContext) {
Map<String, Object> data = new HashMap<>();
String uid = Utils.null2String(user.getUID());
RecordSet rs = new RecordSet();
HashSet<String> ids = new HashSet<>();
ids.add(uid);
rs.executeQuery("select ckr,bckr from uf_yddhqx_dt1");
while (rs.next()) {
String ckr = Utils.null2String(rs.getString("ckr"));
String bckr = Utils.null2String(rs.getString("bckr"));
if (Arrays.asList(ckr.split(",")).contains(uid)) {
ids.addAll(Arrays.asList(bckr.split(",")));
}
}
Map<String,String> mobileInfo = new HashMap<>();
String value = StringUtils.join(ids,",");
rs.executeQuery("select id,"+FIELDID+" from cus_fielddata where scope = ? and scopeid = ?" +
" and id in ("+value+")",SCOPE,SCOPEID);
while (rs.next()){
mobileInfo.put(Utils.null2String(rs.getString("id")),rs.getString(FIELDID));
}
data.put("ids",ids);
data.put("mobileInfo",mobileInfo);
return data;
}
}

@ -1,16 +0,0 @@
package com.engine.jygf.service;
import weaver.hrm.User;
import java.util.Map;
/**
* @Author weaver_cl
* @Description:
* @Date 2022/10/9
* @Version V1.0
**/
public interface MobilePermissionsService {
Map<String, Object> getPermissionInfo(Map<String, Object> params, User user);
}

@ -1,24 +0,0 @@
package com.engine.jygf.service.impl;
import com.engine.core.impl.Service;
import com.engine.jygf.cmd.MobilePermissionsCmd;
import com.engine.jygf.service.MobilePermissionsService;
import weaver.hrm.User;
import java.util.Map;
/**
* @Author weaver_cl
* @Description:
* @Date 2022/10/9
* @Version V1.0
**/
public class MobilePermissionsServiceImpl extends Service implements MobilePermissionsService {
@Override
public Map<String, Object> getPermissionInfo(Map<String, Object> params, User user) {
return commandExecutor.execute(new MobilePermissionsCmd(params,user));
}
}

@ -1,57 +0,0 @@
package com.engine.jygf.web;
import com.alibaba.fastjson.JSONObject;
import com.engine.common.util.ParamUtil;
import com.engine.common.util.ServiceUtil;
import com.engine.jygf.service.MobilePermissionsService;
import com.engine.jygf.service.impl.MobilePermissionsServiceImpl;
import weaver.hrm.HrmUserVarify;
import weaver.hrm.User;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import java.util.HashMap;
import java.util.Map;
/**
* @Author weaver_cl
* @Description:
* @Date 2022/10/9
* @Version V1.0
**/
public class MobilePermissionsAction {
public MobilePermissionsService getMobilePermissionsService(User user) {
return ServiceUtil.getService(MobilePermissionsServiceImpl.class,user);
}
/**
*
* @param request
* @param response
* @return
*/
@GET
@Path("/controller")
@Produces(MediaType.APPLICATION_JSON)
public String getPermissionInfo(@Context HttpServletRequest request, @Context HttpServletResponse response) {
Map<String, Object> apidatas = new HashMap<>();
try {
User user = HrmUserVarify.getUser(request, response);
//实例化Service 并调用业务类处理
apidatas = getMobilePermissionsService(user).getPermissionInfo(ParamUtil.request2Map(request), user);
} catch (Exception e) {
//异常处理
apidatas.put("api_status", false);
}
return JSONObject.toJSONString(apidatas);
}
}

@ -1,14 +0,0 @@
package test;
/**
* @Author weaver_cl
* @Description:
* @Date 2022/10/9
* @Version V1.0
**/
public class MainTest {
public static void main(String[] args) {
}
}

@ -1,135 +0,0 @@
package weaver.interfaces.gsjrkg.action;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import weaver.conn.RecordSet;
import weaver.general.Util;
import weaver.interfaces.workflow.action.Action;
import weaver.soa.workflow.request.MainTableInfo;
import weaver.soa.workflow.request.Property;
import weaver.soa.workflow.request.RequestInfo;
import java.util.*;
/**
* @Description:
* @author:dxfeng
* @createTime: 2023/02/20
* @version: 1.0
*/
public class SyncCertificateAction implements Action {
/**
*
*/
private String modeTableName;
/**
*
*/
private String params;
private String resourceFieldGroup;
@Override
public String execute(RequestInfo requestInfo) {
if (StringUtils.isBlank(params)) {
requestInfo.getRequestManager().setMessagecontent("自定义接口参数值配置错误");
return Action.FAILURE_AND_CONTINUE;
}
if (StringUtils.isBlank(resourceFieldGroup)) {
// -1:基本信息,1:个人信息,3:工作信息
resourceFieldGroup = "1";
}
Map<String, String> fieldMap = new HashMap<>();
String[] fieldsArray = params.split(";");
for (String fields : fieldsArray) {
String[] field = fields.split(":");
if (field.length == 2) {
fieldMap.put(field[0], field[1]);
}
}
if (fieldMap.size() != fieldsArray.length) {
requestInfo.getRequestManager().setMessagecontent("自定义接口参数值格式错误,请检查");
return Action.FAILURE_AND_CONTINUE;
}
Set<String> modeFields = fieldMap.keySet();
Map<String, Set<String>> modeMap = new HashMap<>();
RecordSet rs = new RecordSet();
String resourceId = "";
MainTableInfo mainTableInfo = requestInfo.getMainTableInfo();
Property[] property = mainTableInfo.getProperty();
for (Property item : property) {
String name = item.getName();
String value = Util.null2String(item.getValue());
if (StringUtils.isNotBlank(name) && StringUtils.isNotBlank(value)) {
if ("xm".equals(name)) {
resourceId = value;
}
}
}
// 查询当前人员的所有数据
StringBuilder sqlBuilder = new StringBuilder("select ").append(StringUtils.join(modeFields, ",")).append(" from ").append(modeTableName).append(" where xm = ").append(resourceId).append(" order by id");
rs.executeQuery(sqlBuilder.toString());
while (rs.next()) {
appendIds(modeFields, rs, modeMap);
}
// 判断有无数据,没有的话插入数据
sqlBuilder = new StringBuilder("SELECT id FROM CUS_FIELDDATA where scope ='HrmCustomFieldByInfoType' and scopeid = '").append(resourceFieldGroup).append("' and id =? ");
rs.executeQuery(sqlBuilder.toString(), resourceId);
if (!rs.next()) {
// 插入人员信息数据
rs.executeUpdate("insert into cus_fielddata (scope,scopeid,id) values ('HrmCustomFieldByInfoType','" + resourceFieldGroup + "',?)", resourceId);
}
// 组装更新SQL语句
sqlBuilder = new StringBuilder("update cus_fielddata set ");
for (Map.Entry<String, String> entry : fieldMap.entrySet()) {
Set<String> valueSet = modeMap.get(entry.getKey());
String values = CollectionUtils.isEmpty(valueSet) ? "" : StringUtils.join(valueSet, ",");
sqlBuilder.append(" ").append(entry.getValue()).append(" = '").append(values).append("',");
}
sqlBuilder.deleteCharAt(sqlBuilder.length() - 1);
sqlBuilder.append(" where scope ='HrmCustomFieldByInfoType' and scopeid = ").append(resourceFieldGroup).append(" and id = ").append(resourceId);
rs.executeUpdate(sqlBuilder.toString());
return Action.SUCCESS;
}
private void appendIds(Set<String> modeFields, RecordSet rs, Map<String, Set<String>> modeMap) {
for (String modeField : modeFields) {
String ids = rs.getString(modeField);
if (StringUtils.isBlank(ids)) {
return;
}
if (CollectionUtils.isEmpty(modeMap.get(modeField))) {
modeMap.put(modeField, new HashSet<>());
}
modeMap.get(modeField).addAll(Arrays.asList(ids.split(",")));
}
}
public String getParams() {
return params;
}
public void setParams(String params) {
this.params = params;
}
public String getModeTableName() {
return modeTableName;
}
public void setModeTableName(String modeTableName) {
this.modeTableName = modeTableName;
}
public String getResourceFieldGroup() {
return resourceFieldGroup;
}
public void setResourceFieldGroup(String resourceFieldGroup) {
this.resourceFieldGroup = resourceFieldGroup;
}
}
Loading…
Cancel
Save