liupeng 5 éve
szülő
commit
e85eeec45b

+ 19 - 0
code/sapparent/sapcms/src/main/java/org/fouram/controller/TaskController.java

@@ -4,6 +4,7 @@ import org.fouram.core.base.controller.BaseController;
 import org.fouram.core.util.AppUtil;
 import org.fouram.core.util.AppUtil.ResultConstant;
 import org.fouram.core.util.LoggerUtil;
+import org.fouram.service.SapReportService;
 import org.fouram.service.TaskService;
 import org.fouram.service.TestUserService;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -19,6 +20,8 @@ public class TaskController extends BaseController {
 	private TaskService taskService;
 	@Autowired
 	private TestUserService testUserService;
+	@Autowired
+	private SapReportService sapReportService;
 
 	@RequestMapping(value = "/syncWeixinUser", produces = "application/json;charset=utf-8")
 	@ResponseBody
@@ -47,4 +50,20 @@ public class TaskController extends BaseController {
 			return AppUtil.error(ResultConstant.WEB_ERR_MSG);
 		}
 	}
+	
+	/**
+	 * http://localhost:8080/sapcms/task/saveSapAllReportDataAnon
+	 * @return
+	 */
+	@RequestMapping(value = "/saveSapAllReportDataAnon", produces = "application/json;charset=utf-8")
+	@ResponseBody
+	public Object saveSapAllReportDataAnon() {
+		try {
+			sapReportService.saveSapAllReportData();
+			return AppUtil.success();
+		} catch (Exception e) {
+			LoggerUtil.error(e);
+			return AppUtil.error(ResultConstant.WEB_ERR_MSG);
+		}
+	}
 }

+ 1 - 0
code/sapparent/sapservice/src/main/java/org/fouram/entity/SapUser.java

@@ -21,6 +21,7 @@ public class SapUser implements Serializable {
 
 	private String userId;
 	private String personId;
+	private String avatar;
 	//邮箱
 	private String username;
 	//姓名

+ 46 - 14
code/sapparent/sapservice/src/main/java/org/fouram/mapper/SapReportMapper.xml

@@ -63,38 +63,70 @@
 		values (#{userId})
 	</insert>
 	
+	<delete id="deleteSapOutsideWorkExperience">
+		delete from sapoutsideworkexperience
+	</delete>
+	
 	<insert id="saveSapOutsideWorkExperience">
-		insert into SapOutsideWorkExperience(userId) 
-		values (#{userId})
+		insert into sapoutsideworkexperience(userId,startDate,endDate,employer,businessType,
+			department,position,leavingReason,immediateSupervisorName,contactInformation) 
+		values (#{userId},#{startDate}#{endDate},#{employer},#{businessType},
+			#{department},#{position},#{leavingReason},#{immediateSupervisorName},#{contactInformation})
 	</insert>
+	
+	<delete id="deleteSapInsideWorkExperience">
+		delete from sapinsideworkexperience
+	</delete>
 
 	<insert id="saveSapInsideWorkExperience">
-		insert into SapInsideWorkExperience(userId) 
-		values (#{userId})
+		insert into sapinsideworkexperience(userId,startDate,endDate,title,department) 
+		values (#{userId},#{startDate},#{endDate},#{title},#{department})
 	</insert>
+	
+	<delete id="deleteSapCourses">
+		delete from sapcourses
+	</delete>
 
 	<insert id="saveSapCourses">
-		insert into SapCourses(userId) 
-		values (#{userId})
+		insert into sapcourses(userId,course,institution,instructionType,lengthCode,
+			place,duration,result,certificateOrNot,dueTime,remark) 
+		values (#{userId},#{course},#{institution},#{instructionType},#{lengthCode},
+			#{place},#{duration},#{result},#{certificateOrNot},#{dueTime},#{remark})
 	</insert>
+	
+	<delete id="deleteSapEducation">
+		delete from sapeducation
+	</delete>
 
 	<insert id="saveSapEducation">
-		insert into SapEducation(userId) 
-		values (#{userId})
+		insert into sapeducation(userId,startDate,endDate,school,major,degree,qualification) 
+		values (#{userId},#{startDate},#{endDate},#{school},#{major},#{degree},#{qualification})
 	</insert>
 
+	<delete id="deleteSapCertificates">
+		delete from sapcertificates
+	</delete>
+
 	<insert id="saveSapCertificates">
-		insert into SapCertificates(userId) 
-		values (#{userId})
+		insert into sapcertificates(userId,name,description,institution,startDate,endDate) 
+		values (#{userId},#{name},#{description},#{institution},#{startDate},#{endDate})
 	</insert>
 	
+	<delete id="deleteSapLanguages">
+		delete from saplanguages
+	</delete>
+
 	<insert id="saveSapLanguages">
-		insert into SapLanguages(userId) 
-		values (#{userId})
+		insert into saplanguages(userId,languageCode,speakingProfCode,readingProfCode,writingProfCode) 
+		values (#{userId},#{languageCode},#{speakingProfCode},#{readingProfCode},#{writingProfCode})
 	</insert>
+	
+	<delete id="deleteSapOverallPerformance">
+		delete from sapoverallperformance
+	</delete>
 
 	<insert id="saveSapOverallPerformance">
-		insert into SapOverallPerformance(userId) 
-		values (#{userId})
+		insert into sapoverallperformance(userId,startDate,endDate,module,name,description) 
+		values (#{userId},#{startDate},#{endDate},#{module},#{name},#{description})
 	</insert>
 </mapper>

+ 10 - 0
code/sapparent/sapservice/src/main/java/org/fouram/mapper/SapUserMapper.xml

@@ -37,6 +37,10 @@
 		update sap_user set delFlag=#{delFlag} where userId=#{userId}
 	</update>
 	
+	<update id="updateAvatar">
+		update sap_user set avatar=#{avatar} where personId=#{personId}
+	</update>
+	
 	<update id="updateResult">
 		update sap_user set result=#{result} where personId=#{personId}
 	</update>
@@ -71,6 +75,12 @@
 		order by sortNumber ASC
 	</select>
 	
+	<select id="selectSuccessList" resultType="SapUser">
+		select * from sap_user 
+		where result = 'SUCCESS' and isPrimary = 1 and delFlag = 0 
+		order by sortNumber ASC
+	</select>
+	
 	<select id="selectListByDepartId" resultType="SapUser">
 		select * from sap_user 
 		where result = 'SUCCESS' and isPrimary = 1 and delFlag = 0 and (

+ 30 - 22
code/sapparent/sapservice/src/main/java/org/fouram/service/SapReportService.java

@@ -49,23 +49,23 @@ public class SapReportService extends BaseService {
 			personIds += "'" + sapUser.getPersonId() + "',";
 			userIds += "'" + sapUser.getUserId() + "',";
 		}
-		this.saveSapCertificates(headers, personIds, userIds);
-		this.saveSapCourses(headers, userIds);
-		this.saveSapEducation(headers, personIds, userIds);
-		this.saveSapInsideWorkExperience(headers, userIds);
-		this.saveSapLanguages(headers, personIds, userIds);
-		this.saveSapOverallPerformance(headers, personIds, userIds);
+//		this.saveSapCertificates(headers, userIds);
+//		this.saveSapCourses(headers, userIds);
+//		this.saveSapEducation(headers, userIds);
+//		this.saveSapInsideWorkExperience(headers, userIds);
+//		this.saveSapLanguages(headers, personIds, userIds);
+//		this.saveSapOverallPerformance(headers, userIds);
 		this.saveSapOutsideWorkExperience(headers, userIds);
-		this.saveSapEmpEmployment(headers, personIds, userIds);
-		this.saveSapEmpJob(headers, personIds, userIds);
-		this.saveSapEmpJobRelationships(headers, userIds);
-		this.saveSapPerEmail(headers, personIds, userIds);
-		this.saveSapPerGlobalInfoCHN(headers, personIds, userIds);
-		this.saveSapPerNationalId(headers, personIds, userIds);
-		this.saveSapPerPersonal(headers, personIds, userIds);
-		this.saveSapPerPerson(headers, personIds, userIds);
-		this.saveSapPerPhone(headers, personIds, userIds);
-		this.saveSapPerSocialAccount(headers, personIds, userIds);
+//		this.saveSapEmpEmployment(headers, personIds, userIds);
+//		this.saveSapEmpJob(headers, personIds, userIds);
+//		this.saveSapEmpJobRelationships(headers, userIds);
+//		this.saveSapPerEmail(headers, personIds, userIds);
+//		this.saveSapPerGlobalInfoCHN(headers, personIds, userIds);
+//		this.saveSapPerNationalId(headers, personIds, userIds);
+//		this.saveSapPerPersonal(headers, personIds, userIds);
+//		this.saveSapPerPerson(headers, personIds, userIds);
+//		this.saveSapPerPhone(headers, personIds, userIds);
+//		this.saveSapPerSocialAccount(headers, personIds, userIds);
 	}
 
 // 基本信息	PerPerson,PerPersonal
@@ -312,6 +312,8 @@ public class SapReportService extends BaseService {
 
 	// 先前工作经历 Background_OutsideWorkExperience
 	public void saveSapOutsideWorkExperience(HttpHeaders headers, String userIds) throws Exception {
+		delete("SapReportMapper.deleteSapOutsideWorkExperience", null);
+		
 		String url = "https://api15.sapsf.cn/odata/v2/Background_OutsideWorkExperience?$filter=userId in %s&$format=json";
 		url = String.format(url, userIds);
 		JsonNode node = requestService.getForObject(url, headers);
@@ -389,9 +391,9 @@ public class SapReportService extends BaseService {
 	}
 
 	// 学历教育 Background_Education
-	public void saveSapEducation(HttpHeaders headers, String personIds, String userIds) throws Exception {
+	public void saveSapEducation(HttpHeaders headers, String userIds) throws Exception {
 		String url = "https://api15.sapsf.cn/odata/v2/Background_Education?$filter=userId in %s&$format=json";
-		url = String.format(url, personIds);
+		url = String.format(url, userIds);
 		JsonNode node = requestService.getForObject(url, headers);
 		if (node != null) {
 			Iterator<JsonNode> iterator = node.get("d").get("results").elements();
@@ -412,9 +414,11 @@ public class SapReportService extends BaseService {
 	}
 
 	// 证书 Background_Certificates
-	public void saveSapCertificates(HttpHeaders headers, String personIds, String userIds) throws Exception {
+	public void saveSapCertificates(HttpHeaders headers, String userIds) throws Exception {
+		delete("SapReportMapper.deleteSapCertificates", null);
+		
 		String url = "https://api15.sapsf.cn/odata/v2/Background_Certificates?$filter=userId in %s&$format=json";
-		url = String.format(url, personIds);
+		url = String.format(url, userIds);
 		JsonNode node = requestService.getForObject(url, headers);
 		if (node != null) {
 			Iterator<JsonNode> iterator = node.get("d").get("results").elements();
@@ -435,6 +439,8 @@ public class SapReportService extends BaseService {
 
 	// 语言能力 Background_Languages
 	public void saveSapLanguages(HttpHeaders headers, String personIds, String userIds) throws Exception {
+		delete("SapReportMapper.deleteSapLanguages", null);
+		
 		String url = "https://api15.sapsf.cn/odata/v2/Background_Languages?$filter=userId in %s&$format=json&$expand=languageNav,speakingProfNav,readingProfNav,writingProfNav";
 		url = String.format(url, personIds);
 		JsonNode node = requestService.getForObject(url, headers);
@@ -456,9 +462,11 @@ public class SapReportService extends BaseService {
 	}
 
 	// 绩效历史 TrendData_SysOverallPerformance
-	public void saveSapOverallPerformance(HttpHeaders headers, String personIds, String userIds) throws Exception {
+	public void saveSapOverallPerformance(HttpHeaders headers, String userIds) throws Exception {
+		delete("SapReportMapper.deleteSapOverallPerformance", null);
+		
 		String url = "https://api15.sapsf.cn/odata/v2/TrendData_SysOverallPerformance?$filter=userId in %s&$format=json";
-		url = String.format(url, personIds);
+		url = String.format(url, userIds);
 		JsonNode node = requestService.getForObject(url, headers);
 		if (node != null) {
 			Iterator<JsonNode> iterator = node.get("d").get("results").elements();

+ 9 - 0
code/sapparent/sapservice/src/main/java/org/fouram/service/SapUserService.java

@@ -194,6 +194,11 @@ public class SapUserService extends BaseService {
 	}
 
 	@SuppressWarnings("unchecked")
+	public List<SapUser> selectSuccessList() throws Exception {
+		return (List<SapUser>) findList("SapUserMapper.selectSuccessList", null);
+	}
+
+	@SuppressWarnings("unchecked")
 	public List<SapUser> selectListByDepartId(String departId) throws Exception {
 		return (List<SapUser>) findList("SapUserMapper.selectListByDepartId", departId);
 	}
@@ -235,4 +240,8 @@ public class SapUserService extends BaseService {
 		SapUser sapUser = selectByUserId(userId);
 		return toInfoDetail(sapUser);
 	}
+
+	public void updateAvatar(SapUser sapUser) throws Exception {
+		update("SapUserMapper.updateAvatar", sapUser);
+	}
 }

+ 11 - 0
code/sapparent/sapservice/src/main/java/org/fouram/service/TaskService.java

@@ -4,6 +4,7 @@ import java.util.List;
 import java.util.Map;
 
 import org.fouram.core.base.service.BaseService;
+import org.fouram.core.plugin.weixin.cp.util.WXCpUserUtil;
 import org.fouram.core.util.DateUtil;
 import org.fouram.core.util.LoggerUtil;
 import org.fouram.entity.SapUser;
@@ -11,6 +12,8 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
+import me.chanjar.weixin.cp.bean.WxCpUser;
+
 @Service
 public class TaskService extends BaseService {
 
@@ -46,6 +49,14 @@ public class TaskService extends BaseService {
 					}
 				}
 			}
+			List<SapUser> successUsers = sapUserService.selectSuccessList();
+			for (SapUser sapUser : successUsers) {
+				WxCpUser user = WXCpUserUtil.getById(sapUser.getPersonId());
+				if(user != null) {
+					sapUser.setAvatar(user.getAvatar());
+					sapUserService.updateAvatar(sapUser);
+				}
+			}
 			// 查询未更新delFlag数据对应企业微信账号
 			List<SapUser> deleteSapUsers = sapUserService.selectDeleteList();
 			LoggerUtil.info("SAP删除数据->" + deleteSapUsers.size());