同步数据接口

pull/103/head^2
Mlin 3 years ago
parent 0b89abeaac
commit 78dfc87f61

@ -35,4 +35,13 @@ public interface JclOrgMapper {
int updateAllMap(@Param("currentDate") Date currentDate, @Param("yesterday") Date yesterday);
int insertResToMap();
int insertJobToMap();
int insertDeptToMap();
int insertSubComToMap();
int insertComToMap();
}

@ -118,11 +118,46 @@
where time_start <= convert(varchar(100),getDate(),23) and time_end > convert(varchar(100),getDate(),23)) and delete_type=0
group by job_id) e on a.id=e.job_id
left join (select jobtitle,count(1) fcnt from hrmresource group by jobtitle) f
on f.JOBTITLE=a.id
on f.JOBTITLE=a.ec_jobTitle
left join HrmJobTitles g on a.ec_jobTitle = g.id
where isnull(a.delete_type,0) <> 1 and isnull(a.forbidden_tag,0) <> 1
</insert>
<!--同步部门信息-->
<insert id="insertDeptToMap">
insert into jcl_org_map
(id,ftype,fobjid,uuid,fclass,fclassname,fnumber,fname,fleader,fleaderimg,
fleadername,fleaderjobid,fleaderjob,fleaderlv,fleaderst,fparentid,fobjparentid,
fplan,fonjob,fisvitual,fdatebegin,fdateend)
select a.id+100000000,2,a.id,a.uuid,0,'行政维度',a.DEPARTMENTCODE,a.departmentname,cast(a.BMFZR as varchar(10)),b.messagerurl,
b.lastname,b.jobtitle,c.jobtitlemark,null,null,
(case isnull(a.supdepid,0) when 0 then a.subcompanyid1 else a.supdepid+100000000 end),
(case isnull(a.supdepid,0) when 0 then a.subcompanyid1 else a.supdepid end),
0,0,0,convert(varchar(100),getDate(),23),'2099-12-31'
from
HrmDepartment as a
left join hrmresource as b on cast(a.BMFZR as varchar(10))=cast(b.ID as varchar(10))
left join hrmjobtitles as c on b.JOBTITLE=c.id
where isnull(a.canceled,0) &lt;&gt; 1
</insert>
<!--同步分部信息-->
<insert id="insertSubComToMap">
insert into jcl_org_map
(id,ftype,fobjid,uuid,fclass,fclassname,fnumber,fname,fleader,fleaderimg,
fleadername,fleaderjobid,fleaderjob,fleaderlv,fleaderst,fparentid,fobjparentid,
fplan,fonjob,fisvitual,fdatebegin,fdateend)
select a.id,1,a.id,a.uuid,0,'行政维度', '',a.subcompanyname,null,'',
'',NULL,'','','',isnull(a.supsubcomid,0),isnull(a.supsubcomid,0),
0,0,0,convert(varchar(100),getDate(),23),'2099-12-31' from hrmsubcompany as a
where isnull(a.canceled,0) &lt;&gt; 1
</insert>
<!--同步集团信息-->
<insert id="insertComToMap">
INSERT INTO jcl_org_map ( id, ftype, fobjid, uuid,fclass, fclassname, fnumber, fname,
fleader, fleaderimg, fleadername, fleaderjobid, fleaderjob, fparentid,fobjparentid,
fplan, fonjob, fisvitual, fdatebegin, fdateend)
SELECT 0, 0, 0, uuid, 0, '行政维度', '00', companyname,
0, NULL, NULL, 0, NULL, -1, 0,
0, 0, 0, convert(varchar(100),getDate(),23), '2099-12-31' FROM hrmcompany
</insert>
</mapper>

@ -21,6 +21,6 @@ public interface OrgChartService {
Map<String, Object> asyncCompanyData(Map<String, Object> request2Map, User user);
Map<String, Object> synchronousData(Map<String, Object> request2Map, User user);
String synchronousData(Map<String, Object> request2Map, User user);
}

@ -509,7 +509,7 @@ public class OrgChartServiceImpl extends Service implements OrgChartService {
return MapperProxyFactory.getProxy(StaffMapper.class);
}
@Override
public Map<String, Object> synchronousData(Map<String, Object> request2Map, User user) {
public String synchronousData(Map<String, Object> request2Map, User user) {
String currentDate = OrganizationDateUtil.getFormatLocalDate(new java.util.Date());
java.sql.Date date = new java.sql.Date(OrganizationDateUtil.stringToDate(currentDate).getTime());
Calendar cal = Calendar.getInstance();
@ -522,16 +522,48 @@ public class OrgChartServiceImpl extends Service implements OrgChartService {
//同步人员信息
getJclOrgMapMapper().insertResToMap();
//同步岗位信息
JclOrgMap jclOrgMap = new JclOrgMap();
// StaffPO staffPO = getStaffMapper().getStaffsByParamId(Integer.parseInt(type), null, null, String.valueOf(id));
return null;
getJclOrgMapMapper().insertJobToMap();
//同步部门信息
getJclOrgMapMapper().insertDeptToMap();
//同步分部信息
getJclOrgMapMapper().insertSubComToMap();
//同步集团信息
getJclOrgMapMapper().insertComToMap();
//刷新在岗数、编制数(从岗位向上刷,岗位不需处理)
List<JclOrgMap> jclOrgMaps = getJclOrgMapMapper().getJclOrgMapByType("3",date);
for (JclOrgMap jclOrgMap : jclOrgMaps){
int id = jclOrgMap.getId();
countJobAndPlans("3",id,currentDate);
}
return "同步成功";
}
/**
*
*/
void countJobAndPlans(String type,int id,String currentDate) {
java.sql.Date date = new java.sql.Date(OrganizationDateUtil.stringToDate(currentDate).getTime());
RecordSet rs = new RecordSet();
//处理上级
String sql = "select fparentid from jcl_org_map where ftype=? and id=? and fdateend>?";
String typeSql = "select ftype from jcl_org_map where id=? and fdateend>?";
rs.executeQuery(sql, type, id, currentDate);
String fparentid = null;
String ftype = null;
if (rs.next()) {
fparentid = rs.getString("fparentid");
rs.executeQuery(typeSql, fparentid, currentDate);
if (rs.next()) {
ftype = rs.getString("ftype");
}
}
JclOrgMap jclOrgMap = getJclOrgMapMapper().getSumPlanAndJobByFParentId(date, fparentid);
getJclOrgMapMapper().updateMapById(Integer.parseInt(fparentid), jclOrgMap.getFPlan(), jclOrgMap.getFOnJob(), date);
if (!"-1".equals(fparentid)) {
countJobAndPlans(ftype, Integer.parseInt(fparentid), String.valueOf(currentDate));
}
}
static class OrgSelectItem {
private String id;
private String fnumber;

@ -40,7 +40,7 @@ public class OrgChartWrapper extends Service {
return getOrgChartService(user).asyncCompanyData(request2Map, user);
}
public Map<String, Object> synchronousData(Map<String, Object> request2Map) {
public String synchronousData(Map<String, Object> request2Map) {
return getOrgChartService(user).synchronousData(request2Map, user);
}

Loading…
Cancel
Save