diff --git a/src/com/api/hrm/util/HrmBaseStateUtil.java b/src/com/api/hrm/util/HrmBaseStateUtil.java index 7008aa0..571ed79 100644 --- a/src/com/api/hrm/util/HrmBaseStateUtil.java +++ b/src/com/api/hrm/util/HrmBaseStateUtil.java @@ -9,6 +9,7 @@ import java.util.Map; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import com.engine.hrm.biz.HrmFieldManager; import org.apache.commons.lang.StringUtils; import weaver.common.StringUtil; import weaver.conn.RecordSet; @@ -885,6 +886,7 @@ public List> getWedlockRpResult(HttpServletRequest request, H /* * * 职称报表查询 + * #QC3428087# 职称报表替换为籍贯报表 籍贯字段个人信息自定义字段 */ @SuppressWarnings("deprecation") @@ -957,26 +959,55 @@ public List> getJobCallRpResult(HttpServletRequest request, H String sqlstr=""; String nullmothod = ""; - if(rs.getDBType().equals("oracle")) - { - nullmothod = "nvl(t1.jobcall,0)"; - } - else if(rs.getDBType().equals("db2")) - { - nullmothod = "coalesce(t1.jobcall,0)"; + + //#QC3428087 职称统计改为籍贯统计# +// if(rs.getDBType().equals("oracle")) +// { +// nullmothod = "nvl(t1.jobcall,0)"; +// } +// else if(rs.getDBType().equals("db2")) +// { +// nullmothod = "coalesce(t1.jobcall,0)"; +// }else if(DialectUtil.isMySql(rs.getDBType())){ +// nullmothod = DbDialectFactory.get(rs.getDBType()).isNull("t1.jobcall", 0) ; +// }else{ +// nullmothod = "ISNULL(t1.jobcall,0)"; +// } +// if(sqlwhere.equals("")) +// { +// sqlstr = "select "+nullmothod+" jobcall,COUNT(distinct t1.id) resultcount from HrmResource t1 where (t1.accounttype is null or t1.accounttype=0) group by t1.jobcall"; +// } +// else +// sqlstr = "select "+nullmothod+" jobcall,COUNT(distinct t1.id) resultcount from HrmResource t1 where (t1.accounttype is null or t1.accounttype=0) "+sqlwhere+" group by t1.jobcall"; +// sqlstr = "select a.jobcall, sum(a.resultcount) resultcount from ("+sqlstr+") a group by a.jobcall"; +// rs.executeSql(sqlstr); + + //#QC3428087# 职称统计改为籍贯统计# + String nativeplace = new BaseBean().getPropValue("gwsecond", "nativeplace"); + if("oracle".equals(rs.getDBType())) { + nullmothod = "nvl(t2."+nativeplace+",0)"; + } else if("db2".equals(rs.getDBType())) { + nullmothod = "coalesce(t2."+nativeplace+",0)"; }else if(DialectUtil.isMySql(rs.getDBType())){ - nullmothod = DbDialectFactory.get(rs.getDBType()).isNull("t1.jobcall", 0) ; + nullmothod = DbDialectFactory.get(rs.getDBType()).isNull("t2."+nativeplace+"", 0) ; }else{ - nullmothod = "ISNULL(t1.jobcall,0)"; + nullmothod = "ISNULL(t2."+nativeplace+",0)"; } - if(sqlwhere.equals("")) - { - sqlstr = "select "+nullmothod+" jobcall,COUNT(distinct t1.id) resultcount from HrmResource t1 where (t1.accounttype is null or t1.accounttype=0) group by t1.jobcall"; + if("".equals(sqlwhere)) { + sqlstr = "select "+nullmothod+" nativeplace,COUNT(distinct t1.id) resultcount from HrmResource t1 left join cus_fielddata t2 \n" + + " on t1.id = t2.id and t2.scopeid = 1 and t2.scope = 'HrmCustomFieldByInfoType'\n" + + " WHERE( t1.accounttype IS NULL OR t1.accounttype = 0 ) GROUP BY\n" + + " t2."+nativeplace; + } else { + sqlstr = "select "+nullmothod+" nativeplace,COUNT(distinct t1.id) resultcount from HrmResource t1 left join cus_fielddata t2 \n" + + " on t1.id = t2.id and t2.scopeid = 1 and t2.scope = 'HrmCustomFieldByInfoType'\n" + + " WHERE( t1.accounttype IS NULL OR t1.accounttype = 0 )"+sqlwhere+" GROUP BY\n" + + " t2."+nativeplace; + + sqlstr = "select a.nativeplace, sum(a.resultcount) resultcount from ("+sqlstr+") a group by a.nativeplace"; } - else - sqlstr = "select "+nullmothod+" jobcall,COUNT(distinct t1.id) resultcount from HrmResource t1 where (t1.accounttype is null or t1.accounttype=0) "+sqlwhere+" group by t1.jobcall"; - sqlstr = "select a.jobcall, sum(a.resultcount) resultcount from ("+sqlstr+") a group by a.jobcall"; - rs.executeSql(sqlstr); + + rs.executeQuery(sqlstr); while(rs.next()) { int resultcount = rs.getInt(2); @@ -985,6 +1016,7 @@ public List> getJobCallRpResult(HttpServletRequest request, H rs.beforFirst(); List> list = new ArrayList>(); Map map = null; + HrmFieldManager hrmFieldManager = new HrmFieldManager(); if(total!=0){ while(rs.next()){ String resultid = rs.getString(1); @@ -996,7 +1028,8 @@ public List> getJobCallRpResult(HttpServletRequest request, H title = SystemEnv.getHtmlLabelName(15863,user.getLanguage()); }else{ try { - title = Util.toScreen(new JobCallComInfo().getJobCallname(resultid),user.getLanguage()); + title = hrmFieldManager.getFieldvalue(user, null, 0, 3, 2222, resultid, 0); + title = Util.formatMultiLang(title, Util.null2String(user.getLanguage())); } catch (Exception e) { e.printStackTrace(); } diff --git a/src/com/engine/gainway/entity/ProvinceNamePo.java b/src/com/engine/gainway/entity/ProvinceNamePo.java new file mode 100644 index 0000000..9cc2eea --- /dev/null +++ b/src/com/engine/gainway/entity/ProvinceNamePo.java @@ -0,0 +1,24 @@ +package com.engine.gainway.entity; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +/** + * @Author liang.cheng + * @Date 2024/12/12 5:49 PM + * @Description: TODO + * @Version 1.0 + */ + +@Data +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class ProvinceNamePo { + + private Integer id; + + private String provinceName; +} diff --git a/src/com/engine/gainway/service/impl/BasicResourceTableServiceImpl.java b/src/com/engine/gainway/service/impl/BasicResourceTableServiceImpl.java index b02bc8d..c603126 100644 --- a/src/com/engine/gainway/service/impl/BasicResourceTableServiceImpl.java +++ b/src/com/engine/gainway/service/impl/BasicResourceTableServiceImpl.java @@ -7,6 +7,7 @@ import com.cloudstore.eccom.pc.table.WeaTableType; import com.cloudstore.eccom.result.WeaResultMsg; import com.engine.core.impl.Service; import com.engine.gainway.entity.EducationLevelPo; +import com.engine.gainway.entity.ProvinceNamePo; import com.engine.gainway.service.BasicResourceTableService; import com.engine.gainway.util.BasicResourceUtil; import weaver.conn.RecordSet; @@ -57,6 +58,7 @@ public class BasicResourceTableServiceImpl extends Service implements BasicResou String field3 = bb.getPropValue("gwsecond", "deptThree"); String field4 = bb.getPropValue("gwsecond", "deptFour"); String scopeId = bb.getPropValue("gwsecond", "scopeId"); + String nativeplace = bb.getPropValue("gwsecond", "nativeplace"); WeaTable table = new WeaTable(); @@ -66,10 +68,11 @@ public class BasicResourceTableServiceImpl extends Service implements BasicResou String pageSize = PageIdConst.getPageSize(pageId, user.getUID()); table.setPagesize(pageSize); - String fields = "a.subcompanyid1,b."+field1+",b."+field2+",b."+field3+",b."+field4+",a.workcode,a.lastname,a.jobtitle,\n" + + String fields = "a.subcompanyid1,b."+field1+",b."+field2+",b."+field3+",b."+field4+",c."+nativeplace+",a.workcode,a.lastname,a.jobtitle,\n" + " a.companystartdate,a.sex,a.birthday,a.birthday as age,a.educationlevel,a.companystartdate as companyworkyear"; table.setBackfields(fields); - String fromSql = "from hrmresource a left join cus_fielddata b on a.id = b.id and b.scopeid = "+scopeId; + String fromSql = "from hrmresource a left join cus_fielddata b on a.id = b.id and b.scope = 'HrmCustomFieldByInfoType' " + + " and b.scopeid = "+scopeId+" left join cus_fielddata c on a.id = c.id and c.scope = 'HrmCustomFieldByInfoType' and c.scopeid = 1"; table.setSqlform(fromSql); String sqlWhere = "where (accounttype is null or accounttype = 0) "; @@ -112,7 +115,7 @@ public class BasicResourceTableServiceImpl extends Service implements BasicResou String s = buildSqlwhere(cmd, name); sqlWhere = sqlWhere+s; - // todo 分权暂时不做 + // todo 分权不做 该项目未开启分权 String detachSqlWhere = hrmReportDetachUtil.getDetachSqlWhere(user.getUID(), "hrmresource"); table.setSqlwhere(sqlWhere); @@ -138,7 +141,10 @@ public class BasicResourceTableServiceImpl extends Service implements BasicResou if ("SeniorityRp".equals(cmd)) { table.getColumns().add(new WeaTableColumn("10%", "司龄", "companyworkyear").setTransmethod("com.engine.gainway.transmethod.BasicResourceTrans.selectCompanyYear")); + } + if ("JobCallRp".equals(cmd)) { + table.getColumns().add(new WeaTableColumn("10%", "籍贯(省)", nativeplace).setTransmethod("com.engine.gainway.transmethod.BasicResourceTrans.selectNativeplace").setOtherpara(String.valueOf(user.getUID()))); } table.setTableType(WeaTableType.NONE); @@ -150,6 +156,7 @@ public class BasicResourceTableServiceImpl extends Service implements BasicResou } private String buildSqlwhere(String cmd,String name) { + String nativeplace = new BaseBean().getPropValue("gwsecond", "nativeplace"); String sql = ""; if ("AgeRp".equals(cmd)) { if (SystemEnv.getHtmlLabelName(15863,user.getLanguage()).equals(name)) { @@ -183,7 +190,7 @@ public class BasicResourceTableServiceImpl extends Service implements BasicResou sql += " and (a.educationlevel is null or a.educationlevel < 2)"; }else { List educationLevel = new ArrayList<>(); - //获取学历数据 不带多语言 + //获取学历数据 getEduLevel(educationLevel); Integer levelId = educationLevel.stream() .filter(edu -> name.equals(edu.getLevelName())) @@ -192,6 +199,19 @@ public class BasicResourceTableServiceImpl extends Service implements BasicResou .orElse(-1); sql += " and a.educationlevel = "+levelId; } + }else if("JobCallRp".equals(cmd)) { + if (SystemEnv.getHtmlLabelName(15863,user.getLanguage()).equals(name)) { + sql += " and (c."+nativeplace+" is null or c."+nativeplace+" ='')"; + } else { + List provinceNames = new ArrayList<>(); + getNativeplace(provinceNames); + Integer provinceId = provinceNames.stream() + .filter(edu -> name.equals(edu.getProvinceName())) + .map(ProvinceNamePo::getId) + .findFirst() + .orElse(-1); + sql += " and c."+nativeplace+"= "+provinceId; + } } @@ -208,4 +228,14 @@ public class BasicResourceTableServiceImpl extends Service implements BasicResou educationLevel.add(EducationLevelPo.builder().id(id).levelName(name).build()); } } + + private void getNativeplace(List provinceNames) { + RecordSet rs = new RecordSet(); + rs.executeQuery("select id,provincename from hrmprovince"); + while (rs.next()) { + Integer id = Util.getIntValue(rs.getString("id")); + String name = Util.formatMultiLang(Util.null2String(rs.getString("provincename")),String.valueOf(user.getLanguage())); + provinceNames.add(ProvinceNamePo.builder().id(id).provinceName(name).build()); + } + } } diff --git a/src/com/engine/gainway/transmethod/BasicResourceTrans.java b/src/com/engine/gainway/transmethod/BasicResourceTrans.java index a4f5d7d..4185488 100644 --- a/src/com/engine/gainway/transmethod/BasicResourceTrans.java +++ b/src/com/engine/gainway/transmethod/BasicResourceTrans.java @@ -1,7 +1,10 @@ package com.engine.gainway.transmethod; import com.engine.gainway.util.BasicResourceUtil; +import com.engine.hrm.biz.HrmFieldManager; import org.apache.commons.lang.StringUtils; +import weaver.general.Util; +import weaver.hrm.User; import weaver.hrm.company.SubCompanyComInfo; import weaver.hrm.job.EducationLevelComInfo; import weaver.hrm.job.JobTitlesComInfo; @@ -67,4 +70,19 @@ public class BasicResourceTrans { } + public static String selectNativeplace(String nativeplace,String userId) { + HrmFieldManager hrmFieldManager = new HrmFieldManager(); + String title = ""; + User user = new User(); + try { + user.setUid(Integer.parseInt(userId)); + title = hrmFieldManager.getFieldvalue(user, null, 0, 3, 2222, nativeplace, 0); + title = Util.formatMultiLang(title, Util.null2String(user.getLanguage())); + }catch (Exception e) { + e.printStackTrace(); + } + return title; + } + + } diff --git a/src/test/MainTest.java b/src/test/MainTest.java index 4fdf652..30c148c 100644 --- a/src/test/MainTest.java +++ b/src/test/MainTest.java @@ -1,5 +1,9 @@ package test; +import com.engine.hrm.biz.HrmFieldManager; +import weaver.general.Util; +import weaver.hrm.User; + import java.util.regex.Matcher; import java.util.regex.Pattern; @@ -31,4 +35,16 @@ public class MainTest { System.out.println("Age From: " + ageFrom); System.out.println("Age To: " + ageTo); } + + public static String getBrowserShowNames(User user, int browserType, String value) { + HrmFieldManager hrmFieldManager = new HrmFieldManager(); + String fieldShowName; + try { + fieldShowName = hrmFieldManager.getFieldvalue(user, null, 0, 3, browserType, value, 0); + fieldShowName = Util.formatMultiLang(fieldShowName, Util.null2String(user.getLanguage())); + } catch (Exception e) { + throw new RuntimeException(e); + } + return fieldShowName; + } }