sqlserver存入版本修复、定时任务

pull/96/head^2
Mlin 3 years ago
parent 9c80a74386
commit 43f00f7d9d

@ -4,6 +4,7 @@ import com.engine.organization.entity.map.JclOrgMap;
import org.apache.ibatis.annotations.Param;
import java.sql.Date;
import java.util.List;
/**
* @author:dxfeng
@ -26,4 +27,6 @@ public interface JclOrgMapper {
JclOrgMap getSumPlanAndJobByFParentId(@Param("currentDate") Date currentDate, @Param("fparentid") String fparentid);
int updateMapById(@Param("id") Integer id,@Param("fplan") Integer fplan,@Param("fonjob") Integer fonjob,@Param("currentDate") Date currentDate);
List<JclOrgMap> getJclOrgMapByType(@Param("fType") String fType, @Param("currentDate") Date currentDate);
}

@ -66,4 +66,8 @@
AND FDATEBEGIN &lt;= #{currentDate}
AND FDATEEND &gt;= #{currentDate}
</update>
<select id="getJclOrgMapByType" resultType="com.engine.organization.entity.map.JclOrgMap">
select * from jcl_org_map where ftype = #{fType} AND FDATEBEGIN &lt;= #{currentDate} AND FDATEEND &gt;= #{currentDate}
</select>
</mapper>

@ -74,28 +74,163 @@
</select>
<insert id="insertHrmResourceVersion">
<insert id="insertHrmResourceVersion" keyColumn="id" keyProperty="id" parameterType="com.engine.organization.entity.version.HrmResourceVersion" useGeneratedKeys="true">
insert into hrmresource_version
(resourceid, companystartdate, companyworkyear, workstartdate, workyear, usekind, jobcall,
accumfundaccount, birthplace, folk, residentphone, residentpostcode, extphone, managerstr,
status, fax, islabouunion, weight, tempresidentnumber, probationenddate, countryid, passwdchgdate,
lloginid, dsporder, passwordstate, accounttype, belongto, messagerurl, accountname,
loginid, password, lastname, sex, birthday, nationality, maritalstatus, telephone, mobile,
mobilecall, email, locationid, workroom, homeaddress, resourcetype, startdate, enddate, jobtitle,
jobactivitydesc, joblevel, seclevel, departmentid, subcompanyid1, costcenterid, managerid, assistantid,
bankid1, accountid1, resourceimageid, certificatenum, nativeplace, educationlevel, bememberdate,
bepartydate, workcode, regresidentplace, healthinfo, residentplace, policy, degree, height,
classification, description, operator, version, operate_time)
values (#{resourceid}, #{companystartdate}, #{companyworkyear}, #{workstartdate}, #{workyear}, #{usekind}, #{jobcall},
#{accumfundaccount}, #{birthplace}, #{folk}, #{residentphone}, #{residentpostcode}, #{extphone}, #{managerstr},
#{status}, #{fax}, #{islabouunion}, #{weight}, #{tempresidentnumber}, #{probationenddate}, #{countryid}, #{passwdchgdate},
#{lloginid}, #{dsporder}, #{passwordstate}, #{accounttype}, #{belongto}, #{messagerurl}, #{accountname},
#{loginid}, #{password}, #{lastname}, #{sex}, #{birthday}, #{nationality}, #{maritalstatus}, #{telephone}, #{mobile},
#{mobilecall}, #{email}, #{locationid}, #{workroom}, #{homeaddress}, #{resourcetype}, #{startdate}, #{enddate}, #{jobtitle},
#{jobactivitydesc}, #{joblevel}, #{seclevel}, #{departmentid}, #{subcompanyid1}, #{costcenterid}, #{managerid}, #{assistantid},
#{bankid1}, #{accountid1}, #{resourceimageid}, #{certificatenum}, #{nativeplace}, #{educationlevel}, #{bememberdate},
#{bepartydate}, #{workcode}, #{regresidentplace}, #{healthinfo}, #{residentplace}, #{policy}, #{degree}, #{height},
#{classification}, #{description}, #{operator}, #{version}, #{operateTime})
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="id != null">id,</if>
<if test="resourceid != null">resourceid,</if>
<if test="companystartdate != null">companystartdate,</if>
<if test="companyworkyear != null">companyworkyear,</if>
<if test="workstartdate != null">workstartdate,</if>
<if test="workyear != null">workyear,</if>
<if test="usekind != null">usekind,</if>
<if test="jobcall != null">jobcall,</if>
<if test="accumfundaccount != null">accumfundaccount,</if>
<if test="birthplace != null">birthplace,</if>
<if test="folk != null">folk,</if>
<if test="residentphone != null">residentphone,</if>
<if test="residentpostcode != null">residentpostcode,</if>
<if test="extphone != null">extphone,</if>
<if test="managerstr != null">managerstr,</if>
<if test="status != null">status,</if>
<if test="fax != null">fax,</if>
<if test="islabouunion != null">islabouunion,</if>
<if test="weight != null">weight,</if>
<if test="tempresidentnumber != null">tempresidentnumber,</if>
<if test="probationenddate != null">probationenddate,</if>
<if test="countryid != null">countryid,</if>
<if test="passwdchgdate != null">passwdchgdate,</if>
<if test="lloginid != null">lloginid,</if>
<if test="dsporder != null">dsporder,</if>
<if test="passwordstate != null">passwordstate,</if>
<if test="accounttype != null">accounttype,</if>
<if test="belongto != null">belongto,</if>
<if test="messagerurl != null">messagerurl,</if>
<if test="accountname != null">accountname,</if>
<if test="loginid != null">loginid,</if>
<if test="password != null">password,</if>
<if test="lastname != null">lastname,</if>
<if test="sex != null">sex,</if>
<if test="birthday != null">birthday,</if>
<if test="nationality != null">nationality,</if>
<if test="maritalstatus != null">maritalstatus,</if>
<if test="telephone != null">telephone,</if>
<if test="mobile != null">mobile,</if>
<if test="mobilecall != null">mobilecall,</if>
<if test="email != null">email,</if>
<if test="locationid != null">locationid,</if>
<if test="workroom != null">workroom,</if>
<if test="homeaddress != null">homeaddress,</if>
<if test="resourcetype != null">resourcetype,</if>
<if test="startdate != null">startdate,</if>
<if test="enddate != null">enddate,</if>
<if test="jobtitle != null">jobtitle,</if>
<if test="jobactivitydesc != null">jobactivitydesc,</if>
<if test="joblevel != null">joblevel,</if>
<if test="seclevel != null">seclevel,</if>
<if test="departmentid != null">departmentid,</if>
<if test="subcompanyid1 != null">subcompanyid1,</if>
<if test="costcenterid != null">costcenterid,</if>
<if test="managerid != null">managerid,</if>
<if test="assistantid != null">assistantid,</if>
<if test="bankid1 != null">bankid1,</if>
<if test="accountid1 != null">accountid1,</if>
<if test="resourceimageid != null">resourceimageid,</if>
<if test="certificatenum != null">certificatenum,</if>
<if test="nativeplace != null">nativeplace,</if>
<if test="educationlevel != null">educationlevel,</if>
<if test="bememberdate != null">bememberdate,</if>
<if test="bepartydate != null">bepartydate,</if>
<if test="workcode != null">workcode,</if>
<if test="regresidentplace != null">regresidentplace,</if>
<if test="healthinfo != null">healthinfo,</if>
<if test="residentplace != null">residentplace,</if>
<if test="policy != null">policy,</if>
<if test="degree != null">degree,</if>
<if test="height != null">height,</if>
<if test="classification != null">classification,</if>
<if test="description != null">description,</if>
<if test="operator != null">operator,</if>
<if test="version != null">version,</if>
<if test="operateTime != null">operate_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="id != null">#{id,jdbcType=INTEGER},</if>
<if test="resourceid != null">#{resourceid,jdbcType=INTEGER},</if>
<if test="companystartdate != null">#{companystartdate,jdbcType=TIMESTAMP},</if>
<if test="companyworkyear != null">#{companyworkyear,jdbcType=INTEGER},</if>
<if test="workstartdate != null">#{workstartdate,jdbcType=TIMESTAMP},</if>
<if test="workyear != null">#{workyear,jdbcType=INTEGER},</if>
<if test="usekind != null">#{usekind,jdbcType=INTEGER},</if>
<if test="jobcall != null">#{jobcall,jdbcType=INTEGER},</if>
<if test="accumfundaccount != null">#{accumfundaccount,jdbcType=VARCHAR},</if>
<if test="birthplace != null">#{birthplace,jdbcType=VARCHAR},</if>
<if test="folk != null">#{folk,jdbcType=VARCHAR},</if>
<if test="residentphone != null">#{residentphone,jdbcType=VARCHAR},</if>
<if test="residentpostcode != null">#{residentpostcode,jdbcType=VARCHAR},</if>
<if test="extphone != null">#{extphone,jdbcType=VARCHAR},</if>
<if test="managerstr != null">#{managerstr,jdbcType=VARCHAR},</if>
<if test="status != null">#{status,jdbcType=INTEGER},</if>
<if test="fax != null">#{fax,jdbcType=VARCHAR},</if>
<if test="islabouunion != null">#{islabouunion,jdbcType=CHAR},</if>
<if test="weight != null">#{weight,jdbcType=INTEGER},</if>
<if test="tempresidentnumber != null">#{tempresidentnumber,jdbcType=VARCHAR},</if>
<if test="probationenddate != null">#{probationenddate,jdbcType=TIMESTAMP},</if>
<if test="countryid != null">#{countryid,jdbcType=INTEGER},</if>
<if test="passwdchgdate != null">#{passwdchgdate,jdbcType=TIMESTAMP},</if>
<if test="lloginid != null">#{lloginid,jdbcType=VARCHAR},</if>
<if test="dsporder != null">#{dsporder,jdbcType=INTEGER},</if>
<if test="passwordstate != null">#{passwordstate,jdbcType=INTEGER},</if>
<if test="accounttype != null">#{accounttype,jdbcType=INTEGER},</if>
<if test="belongto != null">#{belongto,jdbcType=INTEGER},</if>
<if test="messagerurl != null">#{messagerurl,jdbcType=VARCHAR},</if>
<if test="accountname != null">#{accountname,jdbcType=VARCHAR},</if>
<if test="loginid != null">#{loginid,jdbcType=VARCHAR},</if>
<if test="password != null">#{password,jdbcType=VARCHAR},</if>
<if test="lastname != null">#{lastname,jdbcType=VARCHAR},</if>
<if test="sex != null">#{sex,jdbcType=CHAR},</if>
<if test="birthday != null">#{birthday,jdbcType=CHAR},</if>
<if test="nationality != null">#{nationality,jdbcType=INTEGER},</if>
<if test="maritalstatus != null">#{maritalstatus,jdbcType=CHAR},</if>
<if test="telephone != null">#{telephone,jdbcType=VARCHAR},</if>
<if test="mobile != null">#{mobile,jdbcType=VARCHAR},</if>
<if test="mobilecall != null">#{mobilecall,jdbcType=VARCHAR},</if>
<if test="email != null">#{email,jdbcType=VARCHAR},</if>
<if test="locationid != null">#{locationid,jdbcType=INTEGER},</if>
<if test="workroom != null">#{workroom,jdbcType=VARCHAR},</if>
<if test="homeaddress != null">#{homeaddress,jdbcType=VARCHAR},</if>
<if test="resourcetype != null">#{resourcetype,jdbcType=CHAR},</if>
<if test="startdate != null">#{startdate,jdbcType=TIMESTAMP},</if>
<if test="enddate != null">#{enddate,jdbcType=TIMESTAMP},</if>
<if test="jobtitle != null">#{jobtitle,jdbcType=INTEGER},</if>
<if test="jobactivitydesc != null">#{jobactivitydesc,jdbcType=VARCHAR},</if>
<if test="joblevel != null">#{joblevel,jdbcType=INTEGER},</if>
<if test="seclevel != null">#{seclevel,jdbcType=INTEGER},</if>
<if test="departmentid != null">#{departmentid,jdbcType=INTEGER},</if>
<if test="subcompanyid1 != null">#{subcompanyid1,jdbcType=INTEGER},</if>
<if test="costcenterid != null">#{costcenterid,jdbcType=INTEGER},</if>
<if test="managerid != null">#{managerid,jdbcType=INTEGER},</if>
<if test="assistantid != null">#{assistantid,jdbcType=INTEGER},</if>
<if test="bankid1 != null">#{bankid1,jdbcType=INTEGER},</if>
<if test="accountid1 != null">#{accountid1,jdbcType=VARCHAR},</if>
<if test="resourceimageid != null">#{resourceimageid,jdbcType=INTEGER},</if>
<if test="certificatenum != null">#{certificatenum,jdbcType=VARCHAR},</if>
<if test="nativeplace != null">#{nativeplace,jdbcType=VARCHAR},</if>
<if test="educationlevel != null">#{educationlevel,jdbcType=INTEGER},</if>
<if test="bememberdate != null">#{bememberdate,jdbcType=TIMESTAMP},</if>
<if test="bepartydate != null">#{bepartydate,jdbcType=TIMESTAMP},</if>
<if test="workcode != null">#{workcode,jdbcType=VARCHAR},</if>
<if test="regresidentplace != null">#{regresidentplace,jdbcType=VARCHAR},</if>
<if test="healthinfo != null">#{healthinfo,jdbcType=CHAR},</if>
<if test="residentplace != null">#{residentplace,jdbcType=VARCHAR},</if>
<if test="policy != null">#{policy,jdbcType=VARCHAR},</if>
<if test="degree != null">#{degree,jdbcType=VARCHAR},</if>
<if test="height != null">#{height,jdbcType=VARCHAR},</if>
<if test="classification != null">#{classification,jdbcType=CHAR},</if>
<if test="description != null">#{description,jdbcType=VARCHAR},</if>
<if test="operator != null">#{operator,jdbcType=VARCHAR},</if>
<if test="version != null">#{version,jdbcType=FLOAT},</if>
<if test="operateTime != null">#{operateTime,jdbcType=TIMESTAMP},</if>
</trim>
</insert>
</mapper>

@ -50,7 +50,7 @@ public class VersionManageServiceImpl extends Service implements VersionManageSe
saveSubComToVersion(params,user);
break;
case 2:
saveComToVersion(params, user);
saveDeptToVersion(params, user);
saveDeptToMap(params);
break;
case 4:
@ -82,6 +82,7 @@ public class VersionManageServiceImpl extends Service implements VersionManageSe
jclOrgMap.setFClass(0);
jclOrgMap.setFClassName("行政维度");
jclOrgMap.setFName((String) params.get("subCompanyName"));
String supSubComId = (String) params.get("supSubComId");
jclOrgMap.setFParentId(Integer.parseInt((String) params.get("supSubComId")));
jclOrgMap.setFIsVitual(0);
jclOrgMap.setFDateBegin(new Date(OrganizationDateUtil.stringToDate(currentDate).getTime()));
@ -131,7 +132,14 @@ public class VersionManageServiceImpl extends Service implements VersionManageSe
jclOrgMap.setFLeaderJobId(Math.toIntExact(hrmResourcePO.getJobTitle()));
}
jclOrgMap.setFName((String) params.get("departmentName"));
jclOrgMap.setFParentId(st+Integer.parseInt((String) params.get("subCompanyId1")));
String subCompanyId1 = (String) params.get("subCompanyId1");
String supdepid = (String) params.get("supDepId");
if (supdepid!=null){
jclOrgMap.setFParentId(st + Integer.parseInt(supdepid));
}
if ("0".equals(supdepid)){
jclOrgMap.setFParentId(Integer.parseInt(subCompanyId1));
}
jclOrgMap.setFDateBegin(new Date(OrganizationDateUtil.stringToDate(currentDate).getTime()));
jclOrgMap.setFDateEnd(new Date(OrganizationDateUtil.stringToDate("2022-12-31").getTime()));
jclOrgMap.setFIsVitual(0);
@ -235,7 +243,7 @@ public class VersionManageServiceImpl extends Service implements VersionManageSe
/**
*
*/
void saveComToVersion(Map<String, Object> params,User user) {
void saveDeptToVersion(Map<String, Object> params,User user) {
String id = (String) params.get("id");
String currentDate = OrganizationDateUtil.getFormatLocalDateTime(new java.util.Date());
@ -245,9 +253,12 @@ public class VersionManageServiceImpl extends Service implements VersionManageSe
hrmDepartmentVersion.setDepartmentCode((String) params.get("departmentCode"));
hrmDepartmentVersion.setDepartmentName((String) params.get("departmentName"));
hrmDepartmentVersion.setSubCompanyId1(Integer.parseInt((String) params.get("subCompanyId1")));
hrmDepartmentVersion.setSupDepId(Integer.parseInt((String) params.get("supDepId")));
String supDepId = (String) params.get("supDepId");
if (supDepId!=null){
hrmDepartmentVersion.setSupDepId(Integer.parseInt(supDepId));
}
String bmfzr = (String) params.get("bmfzr");
if (!"".equals(bmfzr)){
if (!"".equals(bmfzr) && bmfzr!=null){
hrmDepartmentVersion.setBmfzr(Integer.parseInt(bmfzr));
}
String showOrder = (String) params.get("showOrder");
@ -280,7 +291,8 @@ public class VersionManageServiceImpl extends Service implements VersionManageSe
hrmResourceVersion.setJobtitle(Integer.parseInt((String) params.get("jobtitle")));
hrmResourceVersion.setMobile((String) params.get("mobile"));
hrmResourceVersion.setTelephone((String) params.get("telephone"));
hrmResourceVersion.setManagerid(Integer.parseInt((String) params.get("managerid")));
String managerid = (String) params.get("managerid");
hrmResourceVersion.setManagerid(StringUtils.isNotBlank(managerid) ? Integer.parseInt(managerid):null);
hrmResourceVersion.setLastname((String) params.get("lastname"));
hrmResourceVersion.setOperator(user.getLastname());
hrmResourceVersion.setVersion(genVersionId(4,id));

@ -0,0 +1,96 @@
package weaver.interfaces.organization.cronJob;
import com.engine.organization.entity.map.JclOrgMap;
import com.engine.organization.mapper.jclorgmap.JclOrgMapper;
import com.engine.organization.mapper.staff.StaffMapper;
import com.engine.organization.util.OrganizationDateUtil;
import com.engine.organization.util.db.MapperProxyFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import weaver.conn.RecordSet;
import weaver.general.Util;
import weaver.interfaces.schedule.BaseCronJob;
import java.sql.Date;
import java.util.List;
/**
*
*/
public class JobAndPlanCron extends BaseCronJob {
private static final Logger LOGGER = LoggerFactory.getLogger("chartDataLog");
char separator = Util.getSeparator();
private JclOrgMapper getJclOrgMapMapper(){
return MapperProxyFactory.getProxy(JclOrgMapper.class);
}
private StaffMapper getStaffMapper() {
return MapperProxyFactory.getProxy(StaffMapper.class);
}
@Override
public void execute() {
// 计划任务需要处理的逻辑
RecordSet recordSet = new RecordSet();
String fType = "3";
String currentDate = OrganizationDateUtil.getFormatLocalDate(new java.util.Date());
List<JclOrgMap> jclOrgMaps = getJclOrgMapMapper().getJclOrgMapByType(fType,new java.sql.Date(OrganizationDateUtil.stringToDate(currentDate).getTime()));
for (JclOrgMap jclOrgMap : jclOrgMaps){
String id = String.valueOf(jclOrgMap.getId());
}
}
/**
*
*/
void countJobs(String type,int id,String currentDate) {
//找上级
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, 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(new Date(OrganizationDateUtil.stringToDate(currentDate).getTime()), fparentid);
getJclOrgMapMapper().updateMapById(Integer.parseInt(fparentid), jclOrgMap.getFPlan(), jclOrgMap.getFOnJob(), new Date(OrganizationDateUtil.stringToDate(currentDate).getTime()));
if (fparentid.equals("-1")) {
countJobs(ftype, Integer.parseInt(fparentid), currentDate);
}
}
/**
*
*/
void countPlans(String type,int id,String currentDate) {
//找上级
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, 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
}
}
Loading…
Cancel
Save