wisdomisite-java/src/main/java/com/zhgd/xmgl/call/WkServiceuCall.java
2023-09-13 14:16:46 +08:00

295 lines
14 KiB
Java
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package com.zhgd.xmgl.call;
import cn.hutool.core.map.MapUtil;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.zhgd.jeecg.common.mybatis.EntityMap;
import com.zhgd.xmgl.entity.vo.PersonBean;
import com.zhgd.xmgl.modules.basicdata.entity.UploadExecuteRecord;
import com.zhgd.xmgl.modules.basicdata.mapper.UploadExecuteRecordMapper;
import com.zhgd.xmgl.modules.project.entity.ProjectEnterprise;
import com.zhgd.xmgl.modules.project.entity.ProjectExternalSystemService;
import com.zhgd.xmgl.modules.project.service.IProjectExternalSystemServiceService;
import com.zhgd.xmgl.modules.worker.entity.*;
import com.zhgd.xmgl.modules.worker.mapper.DepartmentInfoMapper;
import com.zhgd.xmgl.modules.worker.mapper.EnterpriseInfoMapper;
import com.zhgd.xmgl.modules.worker.mapper.EnterpriseTypeMapper;
import com.zhgd.xmgl.modules.worker.mapper.TeamInfoMapper;
import com.zhgd.xmgl.util.PostToVankeUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
/**
* @program: wisdomSite
* @description: 万科服务
* @author: Mr.Peng
* @create: 2022-06-10 10:09
**/
@Component
public class WkServiceuCall {
@Autowired
private IProjectExternalSystemServiceService projectExternalSystemServiceService;
@Autowired
private EnterpriseInfoMapper enterpriseInfoMapper;
@Autowired
private TeamInfoMapper teamInfoMapper;
@Autowired
private DepartmentInfoMapper departmentInfoMapper;
@Autowired
private EnterpriseTypeMapper enterpriseTypeMapper;
@Autowired
private UploadExecuteRecordMapper uploadExecuteRecordMapper;
@Value("${serverUrl}")
private String serverUrl;
/**
* 新增人员
* @param projectSn
* @param workerInfo
*/
public void sendAddWork(String projectSn, WorkerInfo workerInfo){
try{
ProjectExternalSystemService projectExternalSystemService=projectExternalSystemServiceService.getWanKeProjectExternalSystem(projectSn);
if(projectExternalSystemService!=null){
if(workerInfo.getIsUploadHousing()!=null&&workerInfo.getIsUploadHousing()==1){
PersonBean personBean=new PersonBean();
personBean.setIdCard(workerInfo.getIdCard());
personBean.setName(workerInfo.getWorkerName());
personBean.setProjectCode(projectExternalSystemService.getAppId());
personBean.setPhoneNumber(workerInfo.getPhoneNumber());
personBean.setPersonType(workerInfo.getPersonType().toString());
//personBean.setPhotoUrl(workerInfo.getFieldAcquisitionUrl());
if(workerInfo.getFieldAcquisitionUrl().startsWith("http")){
personBean.setPhotoUrl(workerInfo.getFieldAcquisitionUrl());
}else{
personBean.setPhotoUrl(serverUrl+"/image/"+workerInfo.getFieldAcquisitionUrl());
}
//查询企业
Map<String,Object> param=new HashMap<>();
param.put("projectSn",workerInfo.getProjectSn());
param.put("enterpriseId",workerInfo.getEnterpriseId());
EnterpriseInfo enterpriseInfo=enterpriseInfoMapper.getEnterpriseInfoById(param);
if(enterpriseInfo!=null){
personBean.setSocialCode(enterpriseInfo.getSocialCode());
}
if(workerInfo.getPersonType()==1){
//查询班组
EntityMap teamInfo=teamInfoMapper.getTeamInfo(workerInfo.getTeamId());
personBean.setGroupName(MapUtil.getStr(teamInfo,"teamName"));
personBean.setWorkerTypeName(MapUtil.getStr(teamInfo,"workerTypeName"));
}else{
//查询部门
EntityMap departmentInfo=departmentInfoMapper.getDepartmentInfo(workerInfo.getDepartmentId());
personBean.setGroupName(MapUtil.getStr(departmentInfo,"departmentName"));
personBean.setWorkerTypeName("其他工种");
}
personBean.setInServiceType(workerInfo.getInserviceType().toString());
if(workerInfo.getSex()==1){
personBean.setSex("1");
}else{
personBean.setSex("0");
}
personBean.setNativePlace(workerInfo.getNativePlace());
personBean.setNationId(workerInfo.getNation());
personBean.setDateOfBirth(workerInfo.getBirthday());
personBean.setEmergentPerson(workerInfo.getEmergentPerson());
personBean.setEmergentPhone(workerInfo.getEmergentPhone());
//personBean.setIdCardUpPhotoUrl(workerInfo.getIdCardUpPhotoUrl());
if(workerInfo.getIdCardUpPhotoUrl().startsWith("http")){
personBean.setIdCardUpPhotoUrl(workerInfo.getIdCardUpPhotoUrl());
}else{
personBean.setIdCardUpPhotoUrl(serverUrl+"/image/"+workerInfo.getIdCardUpPhotoUrl());
}
//personBean.setIdCardDownPhotoUrl(workerInfo.getIdCardDownPhotoUrl());
if(workerInfo.getIdCardDownPhotoUrl().startsWith("http")){
personBean.setIdCardDownPhotoUrl(workerInfo.getIdCardDownPhotoUrl());
}else{
personBean.setIdCardDownPhotoUrl(serverUrl+"/image/"+workerInfo.getIdCardDownPhotoUrl());
}
//personBean.setIdCardBigPhotoUrl(workerInfo.getIdCardBigPhotoUrl());
if(workerInfo.getIdCardBigPhotoUrl().startsWith("http")){
personBean.setIdCardBigPhotoUrl(workerInfo.getIdCardBigPhotoUrl());
}else{
personBean.setIdCardBigPhotoUrl(serverUrl+"/image/"+workerInfo.getIdCardBigPhotoUrl());
}
personBean.setEnterDate(workerInfo.getEnterDate());
personBean.setOnlyCreate(1);
String result=PostToVankeUtils.sentAddPerson(personBean,projectExternalSystemService.getSystemUrl(),projectExternalSystemService.getAppKey());
saveExecuteRecord(workerInfo,result,"万科平台","人员信息",1);
}
}
}catch(Exception e){
e.printStackTrace();
}
}
/**
* 人员退场
* @param
* @param
*/
public void removeWork(String projectSn, WorkerInfo workerInfo){
try{
ProjectExternalSystemService projectExternalSystemService=projectExternalSystemServiceService.getWanKeProjectExternalSystem(projectSn);
if(projectExternalSystemService!=null) {
if(workerInfo.getIsUploadHousing()!=null&&workerInfo.getIsUploadHousing()==1) {
String result=PostToVankeUtils.sentDeletePerson(workerInfo.getIdCard(), projectExternalSystemService.getAppId(),projectExternalSystemService.getSystemUrl(),projectExternalSystemService.getAppKey());
saveExecuteRecord(workerInfo,result,"万科平台","人员退场",3);
}
}
}catch(Exception e){
e.printStackTrace();
}
}
public void removeEnterpriseInfo(ProjectEnterprise projectEnterprise){
try{
ProjectExternalSystemService projectExternalSystemService=projectExternalSystemServiceService.getWanKeProjectExternalSystem(projectEnterprise.getProjectSn());
if(projectExternalSystemService!=null) {
EnterpriseInfo enterpriseInfo=enterpriseInfoMapper.selectById(projectEnterprise.getEnterpriseId());
EnterpriseType enterpriseType=enterpriseTypeMapper.selectById(enterpriseInfo.getEnterpriseTypeId());
PostToVankeUtils.sendDeleteComapny(enterpriseInfo.getSocialCode(),projectExternalSystemService.getAppId(),enterpriseType.getCompanyTypeName(),
projectExternalSystemService.getSystemUrl(),projectExternalSystemService.getAppKey());
}
}catch(Exception e){
e.printStackTrace();
}
}
public void addEnterpriseInfo(EnterpriseInfo enterpriseInfo){
try{
ProjectExternalSystemService projectExternalSystemService=projectExternalSystemServiceService.getWanKeProjectExternalSystem(enterpriseInfo.getProjectSn());
if(projectExternalSystemService!=null) {
EnterpriseType enterpriseType=enterpriseTypeMapper.selectById(enterpriseInfo.getEnterpriseTypeId());
PostToVankeUtils.sendAddComapny(enterpriseInfo.getSocialCode(),projectExternalSystemService.getAppId(),enterpriseType.getCompanyTypeName(),enterpriseInfo.getEnterpriseName(),
enterpriseInfo.getEnterpriseLegalPerson(),projectExternalSystemService.getSystemUrl(),projectExternalSystemService.getAppKey());
}
}catch(Exception e){
e.printStackTrace();
}
}
/**
*
* @param teamInfo
* @param departmentInfo
* @param type 1 班组2 部门
* @param projectSn
*/
public void sendAddDepartmentGroup(TeamInfo teamInfo, DepartmentInfo departmentInfo, Integer type, String projectSn){
try{
ProjectExternalSystemService projectExternalSystemService=projectExternalSystemServiceService.getWanKeProjectExternalSystem(projectSn);
if(projectExternalSystemService!=null) {
if(type==1){
EnterpriseInfo enterpriseInfo=enterpriseInfoMapper.selectById(teamInfo.getEnterpriseId());
PostToVankeUtils.sendAddGroup(teamInfo.getTeamName(), null, projectExternalSystemService.getAppId(), enterpriseInfo.getSocialCode(),projectExternalSystemService.getSystemUrl(),projectExternalSystemService.getAppKey());
}else if(type==1){
EnterpriseInfo enterpriseInfo=enterpriseInfoMapper.selectById(departmentInfo.getEnterpriseId());
PostToVankeUtils.sendAddGroup(departmentInfo.getDepartmentName(), null, projectExternalSystemService.getAppId(), enterpriseInfo.getSocialCode(),projectExternalSystemService.getSystemUrl(),projectExternalSystemService.getAppKey());
}
}
}catch(Exception e){
e.printStackTrace();
}
}
/**
* 部门或班组删除
* @param groupName
* @param projectSn
*/
public void sendDeleteGroup(String groupName,String projectSn){
try{
ProjectExternalSystemService projectExternalSystemService=projectExternalSystemServiceService.getWanKeProjectExternalSystem(projectSn);
if(projectExternalSystemService!=null) {
PostToVankeUtils.sendDeleteGroup(groupName, projectExternalSystemService.getAppId(),projectExternalSystemService.getSystemUrl(),projectExternalSystemService.getAppKey());
}
}catch(Exception e){
e.printStackTrace();
}
}
/**
* 考勤记录
*/
public void sendAddPassRecord(WorkerInfo workerInfo, WorkerAttendance workerAttendance){
try{
ProjectExternalSystemService projectExternalSystemService=projectExternalSystemServiceService.getWanKeProjectExternalSystem(workerInfo.getProjectSn());
if(projectExternalSystemService!=null) {
if (workerInfo.getIsUploadHousing() != null && workerInfo.getIsUploadHousing() == 1) {
String result=PostToVankeUtils.sentAddPassRecord(workerAttendance.getDevSn(), workerAttendance.getCardType().toString(),
workerAttendance.getPassType().toString(), projectExternalSystemService.getAppId(), workerAttendance.getCreateTime(),
workerInfo.getIdCard(),projectExternalSystemService.getSystemUrl(),projectExternalSystemService.getAppKey());
saveExecuteRecord(workerInfo,result,"万科平台","人员考勤",2);
}
}
}catch(Exception e){
e.printStackTrace();
}
}
/**
* 上传人脸设备
* @param ufaceDev
*/
public void sentAddUfaceDev(UfaceDev ufaceDev){
try{
ProjectExternalSystemService projectExternalSystemService=projectExternalSystemServiceService.getWanKeProjectExternalSystem(ufaceDev.getProjectSn());
if(projectExternalSystemService!=null) {
String direction="2";
if(ufaceDev!=null&&ufaceDev.getIsEnter()!=null&&ufaceDev.getIsEnter()==1){
direction="1";
}
PostToVankeUtils.sentAddPassDev(ufaceDev.getDevSn(), ufaceDev.getDevName(), direction, projectExternalSystemService.getAppId(),
projectExternalSystemService.getSystemUrl(),projectExternalSystemService.getAppKey());
}
}catch(Exception e){
e.printStackTrace();
}
}
private void saveExecuteRecord(WorkerInfo workerInfo,String result,String serverName,String executeName,Integer executeType){
try {
UploadExecuteRecord uploadExecuteRecord=new UploadExecuteRecord();
uploadExecuteRecord.setName(workerInfo.getWorkerName());
uploadExecuteRecord.setPersonSn(workerInfo.getPersonSn());
uploadExecuteRecord.setProjectSn(workerInfo.getProjectSn());
uploadExecuteRecord.setExecuteType(executeType);
uploadExecuteRecord.setExecuteName(executeName);
uploadExecuteRecord.setServiceName(serverName);
uploadExecuteRecord.setExecuteTime(new Date());
JSONObject object = JSONUtil.parseObj(result);
if(object!=null){
if("1".equals(object.getStr("status"))){
uploadExecuteRecord.setResultType(1);
uploadExecuteRecord.setExecuteResult("上传成功");
}else{
uploadExecuteRecord.setResultType(2);
uploadExecuteRecord.setExecuteResult(result);
}
}else{
uploadExecuteRecord.setResultType(2);
uploadExecuteRecord.setExecuteResult("上传失败");
}
uploadExecuteRecordMapper.insert(uploadExecuteRecord);
}catch (Exception e){
e.printStackTrace();
}
}
}