金筑工实名制同步数据

This commit is contained in:
guo 2023-10-08 10:26:04 +08:00
parent d78537bd28
commit 11aa7cd217
3 changed files with 45 additions and 40 deletions

View File

@ -58,7 +58,7 @@ public class ProjectEnterpriseServiceImpl extends ServiceImpl<ProjectEnterpriseM
List<String> projectSnList = projectService.getProjectSnList(projectSn); List<String> projectSnList = projectService.getProjectSnList(projectSn);
map.put("projectSnList", projectSnList); map.put("projectSnList", projectSnList);
UserInfo user = SecurityUtils.getUser(); UserInfo user = SecurityUtils.getUser();
if (Objects.equals(user.getAccountType(), 6)) { if (user != null && Objects.equals(user.getAccountType(), 6)) {
//项目子账号就筛选自己能看到的 //项目子账号就筛选自己能看到的
Long userId = user.getUserId(); Long userId = user.getUserId();
UserEnterprise userEnterprise = userEnterpriseMapper.selectOne(new LambdaQueryWrapper<UserEnterprise>().eq(UserEnterprise::getUserId, userId)); UserEnterprise userEnterprise = userEnterpriseMapper.selectOne(new LambdaQueryWrapper<UserEnterprise>().eq(UserEnterprise::getUserId, userId));

View File

@ -775,7 +775,7 @@
SELECT count(t1.daytime) num, DATE_FORMAT(t1.daytime, '%m-%d') time SELECT count(t1.daytime) num, DATE_FORMAT(t1.daytime, '%m-%d') time
FROM ( FROM (
SELECT wa.create_time, SELECT wa.create_time,
DATE_FORMAT(wa.create_time,'%Y-%m-%d') daytime, DATE_FORMAT(wa.create_time, '%Y-%m-%d') daytime,
wa.person_sn wa.person_sn
FROM worker_attendance wa FROM worker_attendance wa
JOIN worker_info wi ON wi.person_sn = wa.person_sn JOIN worker_info wi ON wi.person_sn = wa.person_sn
@ -784,7 +784,7 @@
and DATE_FORMAT(wa.create_time, '%Y-%m-%d') >= #{queryStartTime} and DATE_FORMAT(wa.create_time, '%Y-%m-%d') >= #{queryStartTime}
</if> </if>
<if test="queryEndTime != null and queryEndTime != ''"> <if test="queryEndTime != null and queryEndTime != ''">
and DATE_FORMAT(wa.create_time, '%Y-%m-%d') <![CDATA[<=]]> concat(#{queryEndTime},' 23:59:59') and DATE_FORMAT(wa.create_time, '%Y-%m-%d') <![CDATA[<=]]> concat(#{queryEndTime}, ' 23:59:59')
</if> </if>
and wa.project_sn = #{projectSn} and wa.project_sn = #{projectSn}
AND wi.inService_type = 1 AND wi.inService_type = 1
@ -795,15 +795,14 @@
</select> </select>
<select id="queryPresenceList" resultType="com.zhgd.xmgl.modules.worker.entity.WorkerAttendance"> <select id="queryPresenceList" resultType="com.zhgd.xmgl.modules.worker.entity.WorkerAttendance">
SELECT a.* FROM worker_attendance a WHERE a.id in ( SELECT a.*
SELECT FROM worker_attendance a
max( id ) WHERE a.id in (
FROM SELECT max(id)
`worker_attendance` FROM `worker_attendance`
WHERE WHERE project_sn = #{projectSn}
project_sn = #{projectSn} AND create_time > CURRENT_DATE
AND create_time > DATE_SUB(CURRENT_DATE,INTERVAL 1 day) GROUP BY person_sn)
GROUP BY AND a.pass_type = 1
person_sn ) AND a.pass_type = 1
</select> </select>
</mapper> </mapper>

View File

@ -275,30 +275,26 @@ public class JzgTask {
wi.setSex(Integer.valueOf(jzg.getGender())); wi.setSex(Integer.valueOf(jzg.getGender()));
wi.setNation(getNation(jzg.getNation())); wi.setNation(getNation(jzg.getNation()));
if (StrUtil.isNotBlank(jzg.getIssueCardPicUrl())) { if (StrUtil.isNotBlank(jzg.getIssueCardPicUrl())) {
String file = owi.getFieldAcquisitionUrl(); if (owi != null) {
if (StrUtil.isNotBlank(file)) { deleteFile(owi.getFieldAcquisitionUrl());
FileUtil.del(new File(path, file));
} }
wi.setFieldAcquisitionUrl(uploadFileService.uploadUrlResourceRtName(jzg.getIssueCardPicUrl())); wi.setFieldAcquisitionUrl(uploadFileService.uploadUrlResourceRtName(jzg.getIssueCardPicUrl()));
} }
if (StrUtil.isNotBlank(jzg.getHeadImageUrl())) { if (StrUtil.isNotBlank(jzg.getHeadImageUrl())) {
String file = owi.getIdCardBigPhotoUrl(); if (owi != null) {
if (StrUtil.isNotBlank(file)) { deleteFile(owi.getIdCardBigPhotoUrl());
FileUtil.del(new File(path, file));
} }
wi.setIdCardBigPhotoUrl(uploadFileService.uploadUrlResourceRtName(jzg.getHeadImageUrl())); wi.setIdCardBigPhotoUrl(uploadFileService.uploadUrlResourceRtName(jzg.getHeadImageUrl()));
} }
if (StrUtil.isNotBlank(jzg.getPositiveIdCardImageUrl())) { if (StrUtil.isNotBlank(jzg.getPositiveIdCardImageUrl())) {
String file = owi.getIdCardUpPhotoUrl(); if (owi != null) {
if (StrUtil.isNotBlank(file)) { deleteFile(owi.getIdCardUpPhotoUrl());
FileUtil.del(new File(path, file));
} }
wi.setIdCardUpPhotoUrl(uploadFileService.uploadUrlResourceRtName(jzg.getPositiveIdCardImageUrl())); wi.setIdCardUpPhotoUrl(uploadFileService.uploadUrlResourceRtName(jzg.getPositiveIdCardImageUrl()));
} }
if (StrUtil.isNotBlank(jzg.getNegativeIdCardImageUrl())) { if (StrUtil.isNotBlank(jzg.getNegativeIdCardImageUrl())) {
String file = owi.getIdCardDownPhotoUrl(); if (owi != null) {
if (StrUtil.isNotBlank(file)) { deleteFile(owi.getIdCardDownPhotoUrl());
FileUtil.del(new File(path, file));
} }
wi.setIdCardDownPhotoUrl(uploadFileService.uploadUrlResourceRtName(jzg.getNegativeIdCardImageUrl())); wi.setIdCardDownPhotoUrl(uploadFileService.uploadUrlResourceRtName(jzg.getNegativeIdCardImageUrl()));
} }
@ -325,6 +321,12 @@ public class JzgTask {
return wi; return wi;
} }
private void deleteFile(String file) {
if (StrUtil.isNotBlank(file)) {
FileUtil.del(new File(path, file));
}
}
private WorkerInfo getManagerInfo(JzgManagerInfo jzg, WorkerInfo owi, String projectSn) { private WorkerInfo getManagerInfo(JzgManagerInfo jzg, WorkerInfo owi, String projectSn) {
WorkerInfo wi = new WorkerInfo(); WorkerInfo wi = new WorkerInfo();
wi.setId(owi != null ? owi.getId() : null); wi.setId(owi != null ? owi.getId() : null);
@ -800,29 +802,33 @@ public class JzgTask {
private void syncEnterpriseInfo(String appKey, String appSecret, String projectCode, String projectSn, String host) { private void syncEnterpriseInfo(String appKey, String appSecret, String projectCode, String projectSn, String host) {
JzgRt jzgRt = jzgPost(appKey, appSecret, projectCode, "/api/v1/getCompanyInfo", new JSONObject(), host); JzgRt jzgRt = jzgPost(appKey, appSecret, projectCode, "/api/v1/getCompanyInfo", new JSONObject(), host);
String data = jzgRt.getData();
HashMap<String, Object> eMap = new HashMap<>(); HashMap<String, Object> eMap = new HashMap<>();
eMap.put("projectSn", projectSn); eMap.put("projectSn", projectSn);
eMap.put("pageNo", "1"); eMap.put("pageNo", "1");
eMap.put("pageSize", "9999999"); eMap.put("pageSize", "9999999");
List<EnterpriseInfo> records = projectEnterpriseService.selectProjectEnterprisePage(eMap).getRecords(); List<EnterpriseInfo> records = projectEnterpriseService.selectProjectEnterprisePage(eMap).getRecords();
Map<String, EnterpriseInfo> recordMap = records.stream().collect(Collectors.toMap(o -> o.getSocialCode(), Function.identity())); Map<String, JzgEnterpriseInfo> jzgEnterpriseInfoMap = new HashMap<>();
ArrayList<JzgEnterpriseInfo> jzgEnterpriseInfos = JSON.parseObject(data, new TypeReference<ArrayList<JzgEnterpriseInfo>>() { if (jzgRt != null) {
}); String data = jzgRt.getData();
Map<String, JzgEnterpriseInfo> jzgEnterpriseInfoMap = jzgEnterpriseInfos.stream().collect(Collectors.toMap(JzgEnterpriseInfo::getCorpCode, Function.identity())); Map<String, EnterpriseInfo> recordMap = records.stream().collect(Collectors.toMap(o -> o.getSocialCode(), Function.identity()));
for (JzgEnterpriseInfo jzgEnterpriseInfo : jzgEnterpriseInfos) { ArrayList<JzgEnterpriseInfo> jzgEnterpriseInfos = JSON.parseObject(data, new TypeReference<ArrayList<JzgEnterpriseInfo>>() {
try { });
String corpCode = jzgEnterpriseInfo.getCorpCode(); jzgEnterpriseInfoMap = jzgEnterpriseInfos.stream().collect(Collectors.toMap(JzgEnterpriseInfo::getCorpCode, Function.identity()));
EnterpriseInfo enterpriseInfo = recordMap.get(corpCode); for (JzgEnterpriseInfo jzgEnterpriseInfo : jzgEnterpriseInfos) {
if (enterpriseInfo == null) { try {
enterpriseInfoService.saveEnterpriseInfo(getEnterpriseInfo(jzgEnterpriseInfo, null, projectSn)); String corpCode = jzgEnterpriseInfo.getCorpCode();
} else { EnterpriseInfo enterpriseInfo = recordMap.get(corpCode);
enterpriseInfoService.updateEnterpriseInfo(getEnterpriseInfo(jzgEnterpriseInfo, enterpriseInfo, projectSn)); if (enterpriseInfo == null) {
enterpriseInfoService.saveEnterpriseInfo(getEnterpriseInfo(jzgEnterpriseInfo, null, projectSn));
} else {
enterpriseInfoService.updateEnterpriseInfo(getEnterpriseInfo(jzgEnterpriseInfo, enterpriseInfo, projectSn));
}
} catch (Exception e) {
log.error("err:", e);
} }
} catch (Exception e) {
log.error("err:", e);
} }
} }
for (EnterpriseInfo enterpriseInfo : records) { for (EnterpriseInfo enterpriseInfo : records) {
try { try {
JzgEnterpriseInfo jzgEnterpriseInfo = jzgEnterpriseInfoMap.get(enterpriseInfo.getSocialCode()); JzgEnterpriseInfo jzgEnterpriseInfo = jzgEnterpriseInfoMap.get(enterpriseInfo.getSocialCode());