diff --git a/src/com/engine/forstarsecond/entity/FamilyWorkUnit.java b/src/com/engine/forstarsecond/entity/FamilyWorkUnit.java new file mode 100644 index 0000000..827b1e9 --- /dev/null +++ b/src/com/engine/forstarsecond/entity/FamilyWorkUnit.java @@ -0,0 +1,24 @@ +package com.engine.forstarsecond.entity; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @Author liang.cheng + * @Date 2025/5/8 09:29 + * @Description: TODO + * @Version 1.0 + */ + +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class FamilyWorkUnit { + + private String id; + + private String unit; +} diff --git a/src/com/engine/forstarsecond/service/ExamineRankingService.java b/src/com/engine/forstarsecond/service/ExamineRankingService.java index bfa5f8b..8e10a0f 100644 --- a/src/com/engine/forstarsecond/service/ExamineRankingService.java +++ b/src/com/engine/forstarsecond/service/ExamineRankingService.java @@ -49,5 +49,23 @@ public interface ExamineRankingService { * @param: [resourceId] * @return: java.lang.String */ - String resourceImage(String billid); + Map resourceImage(String billid); + + /** + * @Description: 获取普实供应商列表 + * @Author: liang.cheng + * @Date: 2025/5/7 15:47 + * @param: [billid] + * @return: java.util.List + */ + List workUnits(); + + /** + * @Description: 家庭成员工作单位 + * @Author: liang.cheng + * @Date: 2025/5/7 16:03 + * @param: [params] + * @return: java.util.List + */ + Map> familyWorkUnit(Map params); } diff --git a/src/com/engine/forstarsecond/service/impl/ExamineRankingServiceImpl.java b/src/com/engine/forstarsecond/service/impl/ExamineRankingServiceImpl.java index d50619f..36f809d 100644 --- a/src/com/engine/forstarsecond/service/impl/ExamineRankingServiceImpl.java +++ b/src/com/engine/forstarsecond/service/impl/ExamineRankingServiceImpl.java @@ -2,13 +2,16 @@ package com.engine.forstarsecond.service.impl; import com.engine.core.impl.Service; import com.engine.forstarsecond.entity.ExamineRanking; +import com.engine.forstarsecond.entity.FamilyWorkUnit; import com.engine.forstarsecond.service.ExamineRankingService; import lombok.SneakyThrows; import weaver.conn.RecordSet; +import weaver.conn.RecordSetDataSource; import weaver.general.Util; import weaver.hrm.resource.ResourceComInfo; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.function.BiConsumer; @@ -89,12 +92,50 @@ public class ExamineRankingServiceImpl extends Service implements ExamineRanking @SneakyThrows @Override - public String resourceImage(String billid) { + public Map resourceImage(String billid) { RecordSet rs = new RecordSet(); + Map result = new HashMap<>(); rs.executeQuery("select ryid from uf_hr_employee where id = ?",billid); rs.next(); String ryid = Util.null2String(rs.getString("ryid")); - return new ResourceComInfo().getMessagerUrls(ryid); + result.put("id",ryid); + result.put("url",new ResourceComInfo().getMessagerUrls(ryid)); + return result; + } + + @Override + public List workUnits() { + RecordSetDataSource rst = new weaver.conn.RecordSetDataSource(); + List unitList = new ArrayList<>(); + rst.executeQueryWithDatasource("select VndName from V_OA_BPVnd","AErp8_XAFSD"); + while (rst.next()) { + unitList.add(Util.null2String(rst.getString("VndName").trim())); + } + return unitList; + } + + @Override + public Map> familyWorkUnit(Map params) { + RecordSet rs = new RecordSet(); + String type = Util.null2String(params.get("type")); + //1 正式员工台账 + String tableName = "1".equals(type) ? "uf_jcl_rzgl_dt3" : "uf_jcl_wbrzgl_dt3"; + List familyWorkUnits = new ArrayList<>(); + rs.executeQuery("select mainid,gzdw from "+tableName); + while (rs.next()) { + familyWorkUnits.add(FamilyWorkUnit.builder() + .id(Util.null2String(rs.getString("mainid"))) + .unit(Util.null2String(rs.getString("gzdw"))) + .build()); + } + return familyWorkUnits.stream() + .collect(Collectors.groupingBy( + FamilyWorkUnit::getId, + Collectors.mapping( + FamilyWorkUnit::getUnit, + Collectors.toList() + ) + )); } /** @@ -105,8 +146,8 @@ public class ExamineRankingServiceImpl extends Service implements ExamineRanking */ private void calculateRank( List dataList, - Function groupKeyGetter, // 分组字段的 Getter - BiConsumer rankFieldSetter // 排名结果的 Setter(直接使用 BiConsumer) + Function groupKeyGetter, + BiConsumer rankFieldSetter ) { // 1. 按分组字段(如 ssks 或 bmmc)分组 Map> groupedData = dataList.stream() diff --git a/src/com/engine/forstarsecond/web/ExamineRankingAction.java b/src/com/engine/forstarsecond/web/ExamineRankingAction.java index cd724e9..0c2828b 100644 --- a/src/com/engine/forstarsecond/web/ExamineRankingAction.java +++ b/src/com/engine/forstarsecond/web/ExamineRankingAction.java @@ -52,7 +52,7 @@ public class ExamineRankingAction { Map data = new HashMap<>(8); try { User user = HrmUserVarify.getUser(request, response); - data.put("url", getService(user).resourceImage(billid)); + data.putAll(getService(user).resourceImage(billid)); data.put("code", 200); } catch (Exception e) { data.put("code", 500); @@ -61,6 +61,39 @@ public class ExamineRankingAction { return JSONObject.toJSONString(data, SerializerFeature.DisableCircularReferenceDetect); } + @GET + @Path("/workUnits") + @Produces(MediaType.TEXT_PLAIN) + public String workUnits(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map data = new HashMap<>(8); + try { + User user = HrmUserVarify.getUser(request, response); + data.put("units",getService(user).workUnits()); + data.put("code", 200); + } catch (Exception e) { + data.put("code", 500); + data.put("msg", "catch exception : " + e.getMessage()); + } + return JSONObject.toJSONString(data, SerializerFeature.DisableCircularReferenceDetect); + } + + @GET + @Path("/familyWorkUnit") + @Produces(MediaType.TEXT_PLAIN) + public String familyWorkUnit(@Context HttpServletRequest request, @Context HttpServletResponse response) { + Map data = new HashMap<>(8); + try { + User user = HrmUserVarify.getUser(request, response); + data.put("unitList", getService(user).familyWorkUnit(ParamUtil.request2Map(request))); + data.put("code", 200); + } catch (Exception e) { + data.put("code", 500); + data.put("msg", "catch exception : " + e.getMessage()); + } + return JSONObject.toJSONString(data,SerializerFeature.DisableCircularReferenceDetect); + } + + } diff --git a/src/com/weaver/formmode/customjavacode/forstarsecond/CustomSearchTemplate.java b/src/com/weaver/formmode/customjavacode/forstarsecond/CustomSearchTemplate.java new file mode 100644 index 0000000..12144a9 --- /dev/null +++ b/src/com/weaver/formmode/customjavacode/forstarsecond/CustomSearchTemplate.java @@ -0,0 +1,42 @@ +package com.weaver.formmode.customjavacode.forstarsecond; + +import java.util.*; +import java.util.stream.Collectors; + +import weaver.conn.RecordSetDataSource; +import weaver.formmode.customjavacode.AbstractCustomSqlConditionJavaCode; +import weaver.general.Util; + + +public class CustomSearchTemplate extends AbstractCustomSqlConditionJavaCode { + + /** + * 生成SQL查询限制条件 + * @param param + * param包含(但不限于)以下数据 + * user 当前用户 + * + * @return + * 返回的查询限制条件的格式举例为: t1.a = '1' and t1.b = '3' and t1.c like '%22%' + * 其中t1为表单主表表名的别名 + */ + @Override + public String generateSqlCondition(Map param) throws Exception { + + RecordSetDataSource rst = new weaver.conn.RecordSetDataSource(); + List unitList = new ArrayList<>(); + rst.executeQueryWithDatasource("select VndName from V_OA_BPVnd","AErp8_XAFSD"); + while (rst.next()) { + unitList.add(Util.null2String(rst.getString("VndName").trim())); + } + String join = unitList.stream() + .map(s -> "'" + s + "'") + .collect(Collectors.joining(",")); + rst.writeLog("CustomSearchTemplate:"+unitList.toString()); + + String sqlCondition = "d1.gzdw in ("+join+")"; + + return sqlCondition; + } + +}