From 2906b3e02f546e7789e97c2ddbe51283aac38443 Mon Sep 17 00:00:00 2001 From: Chengliang <1546584672@qq.com> Date: Fri, 25 Oct 2024 17:56:13 +0800 Subject: [PATCH] =?UTF-8?q?=E6=97=B6=E7=82=B9=E8=8A=B1=E5=90=8D=E5=86=8C?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../web/EmployeeRecordReportAction.java | 6 +- .../annotation/CheckboxPopedom.java | 21 +++ .../jclproduct/annotation/OperatePopedom.java | 25 ++++ .../jclproduct/annotation/TableTitle.java | 22 +++ .../jclproduct/annotation/WeaverTable.java | 82 +++++++++++ .../annotation/WeaverTableColumn.java | 35 +++++ .../annotation/WeaverTableOperate.java | 27 ++++ .../jclproduct/component/WeaverWeaTable.java | 134 ++++++++++++++++++ .../jclproduct/entity/vo/TimeResourceVo.java | 109 ++++++++++++++ .../service/EmployeeRecordReportService.java | 23 +++ .../impl/EmployeeRecordReportServiceImpl.java | 25 ++++ .../transmethod/EmReportTransMethod.java | 18 +++ .../web/EmployeeRecordReportAction.java | 39 +++++ .../web/EmploymentRecordAction.java | 2 +- 14 files changed, 566 insertions(+), 2 deletions(-) create mode 100644 src/com/engine/jclproduct/annotation/CheckboxPopedom.java create mode 100644 src/com/engine/jclproduct/annotation/OperatePopedom.java create mode 100644 src/com/engine/jclproduct/annotation/TableTitle.java create mode 100644 src/com/engine/jclproduct/annotation/WeaverTable.java create mode 100644 src/com/engine/jclproduct/annotation/WeaverTableColumn.java create mode 100644 src/com/engine/jclproduct/annotation/WeaverTableOperate.java create mode 100644 src/com/engine/jclproduct/component/WeaverWeaTable.java create mode 100644 src/com/engine/jclproduct/entity/vo/TimeResourceVo.java create mode 100644 src/com/engine/jclproduct/transmethod/EmReportTransMethod.java diff --git a/src/com/api/jclproduct/web/EmployeeRecordReportAction.java b/src/com/api/jclproduct/web/EmployeeRecordReportAction.java index ec3444c..4fad93a 100644 --- a/src/com/api/jclproduct/web/EmployeeRecordReportAction.java +++ b/src/com/api/jclproduct/web/EmployeeRecordReportAction.java @@ -1,10 +1,14 @@ package com.api.jclproduct.web; +import javax.ws.rs.Path; + /** * @Author liang.cheng * @Date 2024/10/25 11:06 AM * @Description: * @Version 1.0 */ -public class EmployeeRecordReportAction { + +@Path("/jclproduct/report") +public class EmployeeRecordReportAction extends com.engine.jclproduct.web.EmployeeRecordReportAction{ } diff --git a/src/com/engine/jclproduct/annotation/CheckboxPopedom.java b/src/com/engine/jclproduct/annotation/CheckboxPopedom.java new file mode 100644 index 0000000..f90d609 --- /dev/null +++ b/src/com/engine/jclproduct/annotation/CheckboxPopedom.java @@ -0,0 +1,21 @@ +package com.engine.jclproduct.annotation; + +import java.lang.annotation.*; + +/** + * @Author liang.cheng + * @Date 2024/10/25 1:48 PM + * @Description: + * @Version 1.0 + */ +@Target({ElementType.ANNOTATION_TYPE}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface CheckboxPopedom { + + String id() default ""; + + String showmethod() default ""; + + String popedompara() default ""; +} diff --git a/src/com/engine/jclproduct/annotation/OperatePopedom.java b/src/com/engine/jclproduct/annotation/OperatePopedom.java new file mode 100644 index 0000000..0f39555 --- /dev/null +++ b/src/com/engine/jclproduct/annotation/OperatePopedom.java @@ -0,0 +1,25 @@ +package com.engine.jclproduct.annotation; + +import java.lang.annotation.*; + +/** + * @Author liang.cheng + * @Date 2024/10/25 1:48 PM + * @Description: + * @Version 1.0 + */ +@Target({ElementType.ANNOTATION_TYPE}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface OperatePopedom { + + boolean async() default true; + + String transmethod() default ""; + + String otherpara() default ""; + + String otherpara2() default ""; + + String column() default ""; +} diff --git a/src/com/engine/jclproduct/annotation/TableTitle.java b/src/com/engine/jclproduct/annotation/TableTitle.java new file mode 100644 index 0000000..a4da240 --- /dev/null +++ b/src/com/engine/jclproduct/annotation/TableTitle.java @@ -0,0 +1,22 @@ +package com.engine.jclproduct.annotation; + +import java.lang.annotation.*; + +/** + * @Author liang.cheng + * @Date 2024/10/25 1:48 PM + * @Description: + * @Version 1.0 + */ +@Target({ElementType.FIELD}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface TableTitle { + int labelId() default -1; + String title(); + String dataIndex(); + String key(); + boolean display() default true; + String width() default ""; + boolean sorter() default false; +} diff --git a/src/com/engine/jclproduct/annotation/WeaverTable.java b/src/com/engine/jclproduct/annotation/WeaverTable.java new file mode 100644 index 0000000..07dc2ff --- /dev/null +++ b/src/com/engine/jclproduct/annotation/WeaverTable.java @@ -0,0 +1,82 @@ +package com.engine.jclproduct.annotation; + + +import com.cloudstore.eccom.pc.table.WeaTableType; + + +import java.lang.annotation.*; + +/** + * @Author liang.cheng + * @Date 2024/10/25 1:48 PM + * @Description: + * @Version 1.0 + */ +@Target({ElementType.TYPE}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface WeaverTable { + + String pageId() default ""; + + /** + * 数据库字段,以','分割,例如:"id, name, description" + */ + String fields() default ""; + + /** + * 表名 ,例如:"FROM hrsa_tax_agent" + */ + String fromSql() default ""; + + /** + * 条件 + */ + String where() default ""; + + /** + * 分组 + */ + String groupby() default ""; + + + /** + * 排序 + */ + String orderby() default ""; + + /** + * 主键 + */ + String primarykey() default ""; + + /** + * 去重 + */ + boolean distinct() default false; + + + /** + * 排序方式 + * @return + */ + String sortway() default "desc"; + + /** + * 操作按钮 + */ + WeaverTableOperate[] operates() default {}; + + /** + * 操作按钮权限控制 + * @return + */ + OperatePopedom operatePopedom() default @OperatePopedom; + + /** + * 列表选择框 + */ + WeaTableType tableType() default WeaTableType.NONE; + + CheckboxPopedom checkboxPopedom() default @CheckboxPopedom; +} diff --git a/src/com/engine/jclproduct/annotation/WeaverTableColumn.java b/src/com/engine/jclproduct/annotation/WeaverTableColumn.java new file mode 100644 index 0000000..1972fb4 --- /dev/null +++ b/src/com/engine/jclproduct/annotation/WeaverTableColumn.java @@ -0,0 +1,35 @@ +package com.engine.jclproduct.annotation; + +import java.lang.annotation.*; + +/** + * @Author liang.cheng + * @Date 2024/10/25 1:48 PM + * @Description: + * @Version 1.0 + */ +@Target({ElementType.FIELD}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface WeaverTableColumn { + + String text() default ""; + + int labelId() default -1; + + String width() default ""; + + String column() default ""; + + boolean display() default true; + + String orderkey() default ""; + + String transmethod() default ""; + + // 额外参数 + String otherPara() default ""; + + // 多语言转换 + boolean multiLanguage() default false; +} diff --git a/src/com/engine/jclproduct/annotation/WeaverTableOperate.java b/src/com/engine/jclproduct/annotation/WeaverTableOperate.java new file mode 100644 index 0000000..0739356 --- /dev/null +++ b/src/com/engine/jclproduct/annotation/WeaverTableOperate.java @@ -0,0 +1,27 @@ +package com.engine.jclproduct.annotation; + +import java.lang.annotation.*; + +/** + * @Author liang.cheng + * @Date 2024/10/25 1:48 PM + * @Description: + * @Version 1.0 + */ +@Target({ElementType.ANNOTATION_TYPE}) +@Retention(RetentionPolicy.RUNTIME) +@Documented +public @interface WeaverTableOperate { + + String text() default ""; + + int labelId() default -1; + + String href() default ""; + + String index() default "0"; + + + + +} diff --git a/src/com/engine/jclproduct/component/WeaverWeaTable.java b/src/com/engine/jclproduct/component/WeaverWeaTable.java new file mode 100644 index 0000000..4ee010c --- /dev/null +++ b/src/com/engine/jclproduct/component/WeaverWeaTable.java @@ -0,0 +1,134 @@ +package com.engine.jclproduct.component; + +import com.cloudstore.eccom.constant.WeaBoolAttr; +import com.cloudstore.eccom.pc.table.*; +import com.engine.jclproduct.annotation.*; +import org.apache.commons.lang3.StringUtils; +import weaver.general.PageIdConst; +import weaver.hrm.User; +import weaver.systeminfo.SystemEnv; + +import java.lang.reflect.Field; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +public class WeaverWeaTable extends WeaTable { + + public WeaverWeaTable(User user, Class clazz) { + + boolean isAnno = clazz.isAnnotationPresent(WeaverTable.class); + if (isAnno) { + WeaverTable table = (WeaverTable) clazz.getAnnotation(WeaverTable.class); + String pageId = table.pageId(); + super.setPageID(pageId); + String pageUid = pageId + "_" + user.getUID(); + super.setPageUID(pageUid); + String pageSize = PageIdConst.getPageSize(pageId, user.getUID()); + super.setPagesize(pageSize); + String backfields = table.fields(); + super.setBackfields(backfields); + String sql = table.fromSql(); + super.setSqlform(sql); + String where = table.where(); + if (StringUtils.isNotBlank(where)) { + super.setSqlwhere(where); + } + String orderby = table.orderby(); + if (StringUtils.isNotBlank(orderby)) { + super.setSqlorderby(orderby); + } + String sortway = table.sortway(); + if (StringUtils.isNotBlank(sortway)) { + super.setSqlsortway(sortway); + } + String groupby = table.groupby(); + if (StringUtils.isNotBlank(groupby)) { + super.setSqlgroupby(groupby); + } + boolean distinct = table.distinct(); + super.setSqlisdistinct(String.valueOf(distinct)); + String primarykey = table.primarykey(); + if (StringUtils.isNotBlank(primarykey)) { + super.setSqlprimarykey(primarykey); + } + WeaverTableOperate[] operates = table.operates(); + if (operates != null && operates.length > 0) { + List operateList = new ArrayList<>(); + Arrays.stream(operates).forEach(o -> { + String text = o.text(); + int labelId = o.labelId(); + String htmlLabelName = SystemEnv.getHtmlLabelName(labelId, user.getLanguage()); + if (StringUtils.isNotBlank(htmlLabelName)) { + text = htmlLabelName; + } + WeaTableOperate weaTableOperate = new WeaTableOperate(text, o.href(), o.index()); + operateList.add(weaTableOperate); + }); + WeaTableOperates weaTableOperates = new WeaTableOperates(); + OperatePopedom popedoms = table.operatePopedom(); + WeaTablePopedom popedom = new WeaTablePopedom(); + if (popedoms != null && !"".equals(popedoms.transmethod())) { + popedom.setTransmethod(popedoms.transmethod()); + popedom.setOtherpara(popedoms.otherpara()); + weaTableOperates.setPopedom(popedom); + } + weaTableOperates.setOperate(operateList); + super.setOperates(weaTableOperates); + } + + WeaTableType weaTableTypeEnum = table.tableType(); + //设置check是否可用 + if (weaTableTypeEnum == WeaTableType.CHECKBOX) { + super.setTableType(weaTableTypeEnum); + CheckboxPopedom checkPopedom = table.checkboxPopedom(); + WeaTableCheckboxpopedom checkboxpopedom = new WeaTableCheckboxpopedom(); + if (checkPopedom != null && !"".equals(checkPopedom.showmethod())) { + checkboxpopedom.setShowmethod(checkPopedom.showmethod()); + checkboxpopedom.setPopedompara(checkPopedom.popedompara()); + } + super.setCheckboxpopedom(checkboxpopedom); + } + + } + + Field[] fields = clazz.getDeclaredFields(); + for (Field f : fields) { + boolean isanno = f.isAnnotationPresent(WeaverTableColumn.class); + if (isanno) { + WeaverTableColumn columnAnn = f.getAnnotation(WeaverTableColumn.class); + String text = columnAnn.text(); + int labelId = columnAnn.labelId(); + String htmlLabelName = SystemEnv.getHtmlLabelName(labelId, user.getLanguage()); + if (StringUtils.isNotBlank(htmlLabelName)) { + text = htmlLabelName; + } + String width = columnAnn.width(); + String column = columnAnn.column(); + String orderkey = columnAnn.orderkey(); + boolean display = columnAnn.display(); + WeaTableColumn weaTableColumn = new WeaTableColumn(width, text, column, orderkey); + String transmethod = columnAnn.transmethod(); + + if (StringUtils.isNotBlank(transmethod)) { + weaTableColumn.setTransmethod(transmethod); + } + String otherPara = columnAnn.otherPara(); + if (StringUtils.isNotBlank(otherPara)) { + weaTableColumn.setOtherpara(otherPara); + } else { + // 未设置其他参数,但是设置了多语言,自动添加其它参数为语言类型 + if (columnAnn.multiLanguage()) { + weaTableColumn.setOtherpara(String.valueOf(user.getLanguage())); + } + } + if (!display) { + weaTableColumn.setDisplay(WeaBoolAttr.FALSE); + } + super.getColumns().add(weaTableColumn); + } + } + + + } +} diff --git a/src/com/engine/jclproduct/entity/vo/TimeResourceVo.java b/src/com/engine/jclproduct/entity/vo/TimeResourceVo.java new file mode 100644 index 0000000..a4a2ad3 --- /dev/null +++ b/src/com/engine/jclproduct/entity/vo/TimeResourceVo.java @@ -0,0 +1,109 @@ +package com.engine.jclproduct.entity.vo; + +import com.cloudstore.eccom.pc.table.WeaTableType; +import com.engine.jclproduct.annotation.WeaverTable; +import com.engine.jclproduct.annotation.WeaverTableColumn; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @Author liang.cheng + * @Date 2024/10/25 2:22 PM + * @Description: + * @Version 1.0 + */ + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +@WeaverTable(pageId = "6f201832-a940-4225-a4c9-3f4b96ff5b89", + fields = "t.id," + + "t.userId," + + "t.workcode," + + "t.employeeStatus," + + "t.subCompanyId," + + "t.departmentId," + + "t.position," + + "t.superior," + + "t.companyStartDate," + + "t.workyear," + + "t.sex," + + "t.birthday", + fromSql = "FROM uf_EmploymentRecord t", + orderby = "userid", + sortway = "asc", + primarykey = "id", + tableType = WeaTableType.CHECKBOX +) +public class TimeResourceVo { + + /** + * 主键 + */ + @WeaverTableColumn(column = "id",text = "序号", display = false) + private Integer id; + + /** + * 姓名 + */ + @WeaverTableColumn( text = "姓名", width = "10%", column = "userId", transmethod = "") + private String userId; + /** + * 工号 + */ + @WeaverTableColumn( text = "工号", width = "10%", column = "workcode", transmethod = "") + private String workcode; + /** + * 状态 + */ + @WeaverTableColumn( text = "状态", width = "10%", column = "employeeStatus") + private String employeeStatus; + + /** + * 分部 + */ + @WeaverTableColumn( text = "分部", width = "10%", column = "subCompanyId", transmethod = "") + private String subCompanyId; + /** + * 部门 + */ + @WeaverTableColumn( text = "部门", width = "10%", column = "departmentId", transmethod = "") + private String departmentId; + /** + * 岗位 + */ + @WeaverTableColumn( text = "岗位", width = "10%", column = "position", transmethod = "") + private String position; + /** + * 直接上级 + */ + @WeaverTableColumn( text = "直接上级", width = "10%", column = "superior") + private Integer superior; + /** + * 入职日期 + */ + @WeaverTableColumn( text = "入职日期", width = "10%", column = "companyStartDate") + private Integer companyStartDate; + /** + * 司龄 + */ + @WeaverTableColumn( text = "司龄", width = "10%", column = "workyear") + private Integer workyear; + /** + * 性别 + */ + @WeaverTableColumn( text = "性别", width = "20%", column = "sex", transmethod = "") + private String sex; + /** + * 生日 + */ + @WeaverTableColumn( text = "生日", width = "10%", column = "birthday") + private String birthday; + + + + +} diff --git a/src/com/engine/jclproduct/service/EmployeeRecordReportService.java b/src/com/engine/jclproduct/service/EmployeeRecordReportService.java index 7e2332f..8849b35 100644 --- a/src/com/engine/jclproduct/service/EmployeeRecordReportService.java +++ b/src/com/engine/jclproduct/service/EmployeeRecordReportService.java @@ -1,5 +1,7 @@ package com.engine.jclproduct.service; +import java.util.Map; + /** * @Author liang.cheng * @Date 2024/10/25 11:10 AM @@ -7,4 +9,25 @@ package com.engine.jclproduct.service; * @Version 1.0 */ public interface EmployeeRecordReportService { + + /** + * @Description: 人事花名册(总) + * @Author: liang.cheng + * @Date: 2024/10/25 2:19 PM + * @param: [params] + * @return: java.util.Map + */ + Map commonReport(Map params); + + + + /** + * @Description: 时点花名册 + * @Author: liang.cheng + * @Date: 2024/10/25 2:21 PM + * @param: [] + * @return: java.util.Map + */ + Map timeResourece(); + } diff --git a/src/com/engine/jclproduct/service/impl/EmployeeRecordReportServiceImpl.java b/src/com/engine/jclproduct/service/impl/EmployeeRecordReportServiceImpl.java index b4edb25..897cf06 100644 --- a/src/com/engine/jclproduct/service/impl/EmployeeRecordReportServiceImpl.java +++ b/src/com/engine/jclproduct/service/impl/EmployeeRecordReportServiceImpl.java @@ -1,8 +1,14 @@ package com.engine.jclproduct.service.impl; +import com.cloudstore.eccom.result.WeaResultMsg; import com.engine.core.impl.Service; +import com.engine.jclproduct.component.WeaverWeaTable; +import com.engine.jclproduct.entity.vo.TimeResourceVo; import com.engine.jclproduct.service.EmployeeRecordReportService; +import java.util.HashMap; +import java.util.Map; + /** * @Author liang.cheng * @Date 2024/10/25 11:11 AM @@ -10,4 +16,23 @@ import com.engine.jclproduct.service.EmployeeRecordReportService; * @Version 1.0 */ public class EmployeeRecordReportServiceImpl extends Service implements EmployeeRecordReportService { + + @Override + public Map commonReport(Map params) { + return timeResourece(); + } + + @Override + public Map timeResourece() { + Map resultMap = new HashMap<>(8); + + WeaverWeaTable table = new WeaverWeaTable<>(user, TimeResourceVo.class); +// String sqlWhere = buildSqlWhere(params); +// table.setSqlwhere(sqlWhere); + WeaResultMsg result = new WeaResultMsg(false); + result.putAll(table.makeDataResult()); + result.success(); + resultMap.putAll(result.getResultMap()); + return resultMap; + } } diff --git a/src/com/engine/jclproduct/transmethod/EmReportTransMethod.java b/src/com/engine/jclproduct/transmethod/EmReportTransMethod.java new file mode 100644 index 0000000..a1280a1 --- /dev/null +++ b/src/com/engine/jclproduct/transmethod/EmReportTransMethod.java @@ -0,0 +1,18 @@ +package com.engine.jclproduct.transmethod; + + +import weaver.hrm.company.SubCompanyComInfo; + +/** + * @Author liang.cheng + * @Date 2024/10/25 2:34 PM + * @Description: + * @Version 1.0 + */ +public class EmReportTransMethod { + + public static String subCompanyName(String id) { + SubCompanyComInfo subCompanyComInfo = new SubCompanyComInfo(); + return subCompanyComInfo.getSubCompanyname(id); + } +} diff --git a/src/com/engine/jclproduct/web/EmployeeRecordReportAction.java b/src/com/engine/jclproduct/web/EmployeeRecordReportAction.java index 9b91f4b..df78752 100644 --- a/src/com/engine/jclproduct/web/EmployeeRecordReportAction.java +++ b/src/com/engine/jclproduct/web/EmployeeRecordReportAction.java @@ -1,5 +1,24 @@ package com.engine.jclproduct.web; +import com.alibaba.fastjson.JSONObject; +import com.alibaba.fastjson.serializer.SerializerFeature; +import com.engine.common.util.ParamUtil; +import com.engine.common.util.ServiceUtil; +import com.engine.jclproduct.service.EmployeeRecordReportService; +import com.engine.jclproduct.service.impl.EmployeeRecordReportServiceImpl; +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 liang.cheng * @Date 2024/10/25 11:08 AM @@ -7,4 +26,24 @@ package com.engine.jclproduct.web; * @Version 1.0 */ public class EmployeeRecordReportAction { + + private EmployeeRecordReportService getService(User user) { + return ServiceUtil.getService(EmployeeRecordReportServiceImpl.class, user); + } + + @GET + @Path("/record/employee") + @Produces(MediaType.TEXT_PLAIN) + public String commonReport(@Context HttpServletRequest request, @Context HttpServletResponse response){ + Map data = new HashMap<>(8); + try { + User user = HrmUserVarify.getUser(request, response); + data.put("datas",getService(user).commonReport(ParamUtil.request2Map(request))); + data.put("api_status", true); + } catch (Exception e) { + data.put("api_status", false); + data.put("msg", "catch exception : " + e.getMessage()); + } + return JSONObject.toJSONString(data, SerializerFeature.DisableCircularReferenceDetect); + } } diff --git a/src/com/engine/jclproduct/web/EmploymentRecordAction.java b/src/com/engine/jclproduct/web/EmploymentRecordAction.java index d2c77a2..d62b2f5 100644 --- a/src/com/engine/jclproduct/web/EmploymentRecordAction.java +++ b/src/com/engine/jclproduct/web/EmploymentRecordAction.java @@ -34,7 +34,7 @@ public class EmploymentRecordAction { @GET @Path("/initPerson") @Produces(MediaType.TEXT_PLAIN) - public String resourceSnip(@Context HttpServletRequest request, @Context HttpServletResponse response){ + public String initPerson(@Context HttpServletRequest request, @Context HttpServletResponse response){ Map data = new HashMap<>(8); try { User user = HrmUserVarify.getUser(request, response);