update code
parent
fa8140c80c
commit
d8edf04fa7
|
@ -56,7 +56,7 @@ public class SurProjectAttendanceCfgController extends BaseController
|
||||||
public AjaxResult makeAppId(long projectId,long subDeptId){
|
public AjaxResult makeAppId(long projectId,long subDeptId){
|
||||||
Map<String,String> map=new HashMap<>();
|
Map<String,String> map=new HashMap<>();
|
||||||
map.put("appId", Md5Utils.yzMd5("陕西研筑"+projectId+"-"+subDeptId+ RandomUtil.randomString(10))+RandomUtil.randomString(10));
|
map.put("appId", Md5Utils.yzMd5("陕西研筑"+projectId+"-"+subDeptId+ RandomUtil.randomString(10))+RandomUtil.randomString(10));
|
||||||
map.put("secret", Md5Utils.yzMd5("研筑陕西"+projectId+"_"+subDeptId+ RandomUtil.randomString(10))+RandomUtil.randomString(10));
|
map.put("secret", Md5Utils.yzMd5("研筑陕西"+projectId+"_"+subDeptId+ RandomUtil.randomString(10))+RandomUtil.randomString(30));
|
||||||
map.put("projectId",Md5Utils.yzMd5("陕西研筑"+projectId+ RandomUtil.randomString(10))+RandomUtil.randomString(10));
|
map.put("projectId",Md5Utils.yzMd5("陕西研筑"+projectId+ RandomUtil.randomString(10))+RandomUtil.randomString(10));
|
||||||
map.put("tenantId",Md5Utils.yzMd5("研筑陕西"+subDeptId+ RandomUtil.randomString(10))+RandomUtil.randomString(10));
|
map.put("tenantId",Md5Utils.yzMd5("研筑陕西"+subDeptId+ RandomUtil.randomString(10))+RandomUtil.randomString(10));
|
||||||
return AjaxResult.success("ok",map);
|
return AjaxResult.success("ok",map);
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
package com.yanzhu.jh.project.domain;
|
package com.yanzhu.jh.project.domain;
|
||||||
|
|
||||||
|
import cn.hutool.core.date.DateUtil;
|
||||||
import com.alibaba.fastjson2.JSONObject;
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||||
|
@ -156,6 +157,38 @@ public class SurProjectAttendanceUser extends BaseEntity
|
||||||
private Date inTime;
|
private Date inTime;
|
||||||
private Date outTime;
|
private Date outTime;
|
||||||
|
|
||||||
|
public static SurProjectAttendanceUser createFromHuazhu(JSONObject j) {
|
||||||
|
SurProjectAttendanceUser u=new SurProjectAttendanceUser();
|
||||||
|
u.workerId=j.getLongValue("id",0);
|
||||||
|
u.name=j.getString("name");
|
||||||
|
u.ethnic=j.getString("nationalName");
|
||||||
|
u.nativePlace=j.getString("provinceName")+j.getString("cityName");
|
||||||
|
u.gender=j.getLongValue("sex",0);
|
||||||
|
u.birthDate=j.getLongValue("birthday",0);
|
||||||
|
u.phone=j.getString("phone");
|
||||||
|
u.degreeName=j.getString("levelOfEducation");
|
||||||
|
u.recentPhoto=j.getString("profile");
|
||||||
|
u.groupId=j.getLongValue("teamId",0);
|
||||||
|
u.groupName=j.getString("teamName");
|
||||||
|
u.workTypeCode=j.getString("workerTypeId");
|
||||||
|
u.workTypeName=j.getString("workerTypeName");
|
||||||
|
u.state=j.getLongValue("status",1)==2l?0l:1l;
|
||||||
|
long enterTime=j.getLong("enterTime");
|
||||||
|
if(enterTime>0){
|
||||||
|
u.enterDate= DateUtil.format(DateUtil.date(enterTime),"HH:mm:ss");
|
||||||
|
}
|
||||||
|
long leaveTime=j.getLong("leaveTime");
|
||||||
|
if(leaveTime>0) {
|
||||||
|
u.exitDate = DateUtil.format(DateUtil.date(leaveTime), "HH:mm:ss");
|
||||||
|
}
|
||||||
|
u.vendorId=j.getLongValue("unitProjectId",0);
|
||||||
|
u.companyId=j.getLongValue("unitId",0);
|
||||||
|
u.companyName=j.getString("unitName");
|
||||||
|
u.teamName=j.getString("teamName");
|
||||||
|
u.other=j.toJSONString();
|
||||||
|
return u;
|
||||||
|
}
|
||||||
|
|
||||||
public Date getInTime() {
|
public Date getInTime() {
|
||||||
return inTime;
|
return inTime;
|
||||||
}
|
}
|
||||||
|
@ -221,30 +254,30 @@ public class SurProjectAttendanceUser extends BaseEntity
|
||||||
|
|
||||||
public static SurProjectAttendanceUser create(JSONObject json) {
|
public static SurProjectAttendanceUser create(JSONObject json) {
|
||||||
SurProjectAttendanceUser u=new SurProjectAttendanceUser();
|
SurProjectAttendanceUser u=new SurProjectAttendanceUser();
|
||||||
u.workerId=json.getLong("workerId");
|
u.workerId=json.getLongValue("workerId",0);
|
||||||
u.laborWorkerId=json.getLong("laborWorkerId");
|
u.laborWorkerId=json.getLongValue("laborWorkerId",0);
|
||||||
u.workerCategory=json.getLong("workerCategory");
|
u.workerCategory=json.getLongValue("workerCategory",0);
|
||||||
u.qrCode=json.getLong("qrCode");
|
u.qrCode=json.getLongValue("qrCode",0);
|
||||||
u.name=json.getString("name");
|
u.name=json.getString("name");
|
||||||
u.ethnic=json.getString("ethnic");
|
u.ethnic=json.getString("ethnic");
|
||||||
u.nativePlace=json.getString("nativePlace");
|
u.nativePlace=json.getString("nativePlace");
|
||||||
u.gender=json.getLong("gender");
|
u.gender=json.getLongValue("gender",0);
|
||||||
u.birthDate=json.getLong("birthDate");
|
u.birthDate=json.getLongValue("birthDate",0);
|
||||||
u.phone=json.getString("phone");
|
u.phone=json.getString("phone");
|
||||||
u.recentPhoto=json.getString("recentPhoto");
|
u.recentPhoto=json.getString("recentPhoto");
|
||||||
u.groupId=json.getLong("groupId");
|
u.groupId=json.getLongValue("groupId",0);
|
||||||
u.groupName=json.getString("groupName");
|
u.groupName=json.getString("groupName");
|
||||||
u.leader=json.getBoolean("leader")?1:0;
|
u.leader=json.getBooleanValue("leader",false)?1:0;
|
||||||
u.workTypeCode=json.getString("workTypeCode");
|
u.workTypeCode=json.getString("workTypeCode");
|
||||||
u.workTypeName=json.getString("workTypeName");
|
u.workTypeName=json.getString("workTypeName");
|
||||||
u.specWorkType=json.getBoolean("specWorkType")?1:0;
|
u.specWorkType=json.getBooleanValue("specWorkType",false)?1:0;
|
||||||
u.hatCode=json.getString("hatCode");
|
u.hatCode=json.getString("hatCode");
|
||||||
u.state=json.getLong("state");
|
u.state=json.getLongValue("state",0);
|
||||||
u.enterDate=json.getString("enterDate");
|
u.enterDate=json.getString("enterDate");
|
||||||
u.exitDate=json.getString("exitDate");
|
u.exitDate=json.getString("exitDate");
|
||||||
u.companyId=json.getLong("companyId");
|
u.companyId=json.getLongValue("companyId",0);
|
||||||
u.companyName=json.getString("companyName");
|
u.companyName=json.getString("companyName");
|
||||||
u.vendorId=json.getLong("vendorId");
|
u.vendorId=json.getLongValue("vendorId",0);
|
||||||
u.teamId=json.getInteger("teamId");
|
u.teamId=json.getInteger("teamId");
|
||||||
u.teamName=json.getString("teamName");
|
u.teamName=json.getString("teamName");
|
||||||
u.enterType=json.getString("enterType");
|
u.enterType=json.getString("enterType");
|
||||||
|
|
|
@ -1,6 +1,12 @@
|
||||||
package com.yanzhu.jh.project.task;
|
package com.yanzhu.jh.project.task;
|
||||||
|
|
||||||
|
import cn.hutool.core.date.DateUtil;
|
||||||
import com.alibaba.fastjson2.JSON;
|
import com.alibaba.fastjson2.JSON;
|
||||||
|
import com.alibaba.fastjson2.JSONArray;
|
||||||
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
|
import com.yanzhu.jh.project.domain.SurProjectAttendanceCfg;
|
||||||
|
import com.yanzhu.jh.project.domain.SurProjectAttendanceData;
|
||||||
|
import com.yanzhu.jh.project.domain.SurProjectAttendanceUser;
|
||||||
import com.yanzhu.jh.project.service.ISurProjectAttendanceCfgService;
|
import com.yanzhu.jh.project.service.ISurProjectAttendanceCfgService;
|
||||||
import com.yanzhu.jh.project.service.ISurProjectAttendanceDataService;
|
import com.yanzhu.jh.project.service.ISurProjectAttendanceDataService;
|
||||||
import com.yanzhu.jh.project.service.ISurProjectAttendanceGroupService;
|
import com.yanzhu.jh.project.service.ISurProjectAttendanceGroupService;
|
||||||
|
@ -11,6 +17,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
|
@ -28,7 +35,8 @@ public class AttendanceHuazhuTask {
|
||||||
@Autowired
|
@Autowired
|
||||||
ISurProjectAttendanceGroupService attendanceGroupService;
|
ISurProjectAttendanceGroupService attendanceGroupService;
|
||||||
|
|
||||||
public static void main(String[] args) {
|
/*
|
||||||
|
public static void main1(String[] args) {
|
||||||
//String host="http://tapi.huazhukeji.cn:82/hz-labour";
|
//String host="http://tapi.huazhukeji.cn:82/hz-labour";
|
||||||
String host="http://api.1357.cn/hz-labour";
|
String host="http://api.1357.cn/hz-labour";
|
||||||
String path="/api/open/labour/findWorkerTypeByPage";
|
String path="/api/open/labour/findWorkerTypeByPage";
|
||||||
|
@ -45,10 +53,6 @@ public class AttendanceHuazhuTask {
|
||||||
params.put("tenantId","1666337067184893953");
|
params.put("tenantId","1666337067184893953");
|
||||||
params.put("size","200");
|
params.put("size","200");
|
||||||
params.put("current","1");
|
params.put("current","1");
|
||||||
|
|
||||||
params.forEach((s, o) -> {
|
|
||||||
urlBuilder.addQueryParameter(s, (String) o);
|
|
||||||
});
|
|
||||||
Request request = new Request.Builder()
|
Request request = new Request.Builder()
|
||||||
.url(urlBuilder.build())
|
.url(urlBuilder.build())
|
||||||
.post(toFormBody(params)).headers(setHeaderParams(headerParams))
|
.post(toFormBody(params)).headers(setHeaderParams(headerParams))
|
||||||
|
@ -57,6 +61,28 @@ public class AttendanceHuazhuTask {
|
||||||
System.out.println(data);
|
System.out.println(data);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
|
//380649600000
|
||||||
|
public static void main4(String[] args) {
|
||||||
|
String s= DateUtil.format(DateUtil.date(1704167341751l),"yyyy-MM-dd HH:mm:ss");
|
||||||
|
System.out.println(s);
|
||||||
|
}
|
||||||
|
public static void main(String[] args) {
|
||||||
|
String path="/api/open/labour/findLabourWorkerByPage";
|
||||||
|
Map<String,String> map=new HashMap<>();
|
||||||
|
map.put("appId","8024283707153666851");
|
||||||
|
map.put("secret","2070308b49399d94b401d98adeaa5b342aa81627");
|
||||||
|
map.put("projectId","1666339529033805825");
|
||||||
|
map.put("tenantId","1666337067184893953");
|
||||||
|
JSONObject jo=JSON.parseObject(JSON.toJSONString(map));
|
||||||
|
int page=1;
|
||||||
|
SurProjectAttendanceCfg it=new SurProjectAttendanceCfg();
|
||||||
|
//new AttendanceHuazhuTask().doSyncWorker(jo,1,it);
|
||||||
|
long p=jo.getLongValue("page",1);
|
||||||
|
jo.put("page",1);
|
||||||
|
System.out.println(p);
|
||||||
|
System.out.println(jo.toString());
|
||||||
|
}
|
||||||
private static RequestBody toFormBody(Map<String, String> params ){
|
private static RequestBody toFormBody(Map<String, String> params ){
|
||||||
return RequestBody.create(
|
return RequestBody.create(
|
||||||
MediaType.parse("application/json"), JSON.toJSONString(params));
|
MediaType.parse("application/json"), JSON.toJSONString(params));
|
||||||
|
@ -77,4 +103,93 @@ public class AttendanceHuazhuTask {
|
||||||
return headers;
|
return headers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void syncAttendanceData(){
|
||||||
|
SurProjectAttendanceCfg where =new SurProjectAttendanceCfg();
|
||||||
|
where.setEnabled(1l);
|
||||||
|
where.setIsDel(0l);
|
||||||
|
where.setVendorsCode("huazhu");
|
||||||
|
List<SurProjectAttendanceCfg> list=attendanceCfgService.selectSurProjectAttendanceCfgList(where);
|
||||||
|
for(SurProjectAttendanceCfg it :list){
|
||||||
|
String param= it.getVendorsParameter();
|
||||||
|
if(Strings.isNotEmpty(param)){
|
||||||
|
try{
|
||||||
|
JSONObject jo=JSON.parseObject(param);
|
||||||
|
doSyncAttendanceData(jo,it);
|
||||||
|
}catch (Exception ex){
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
private void doSyncAttendanceData(JSONObject jo,SurProjectAttendanceCfg it){
|
||||||
|
|
||||||
|
}
|
||||||
|
public void syncWorker(){
|
||||||
|
SurProjectAttendanceCfg where =new SurProjectAttendanceCfg();
|
||||||
|
where.setEnabled(1l);
|
||||||
|
where.setIsDel(0l);
|
||||||
|
where.setVendorsCode("huazhu");
|
||||||
|
List<SurProjectAttendanceCfg> list=attendanceCfgService.selectSurProjectAttendanceCfgList(where);
|
||||||
|
for(SurProjectAttendanceCfg it :list){
|
||||||
|
String param= it.getVendorsParameter();
|
||||||
|
if(Strings.isNotEmpty(param)){
|
||||||
|
try{
|
||||||
|
JSONObject jo=JSON.parseObject(param);
|
||||||
|
|
||||||
|
doSyncWorker(jo,1,it);
|
||||||
|
}catch (Exception ex){
|
||||||
|
ex.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Request getRequest(String path,JSONObject jo,int page){
|
||||||
|
String appId=jo.getString("appId");
|
||||||
|
String secret=jo.getString("secret");
|
||||||
|
String projectId=jo.getString("projectId");
|
||||||
|
String tenantId=jo.getString("tenantId");
|
||||||
|
String host="http://api.1357.cn/hz-labour";
|
||||||
|
HttpUrl.Builder urlBuilder = Objects.requireNonNull(HttpUrl.parse(host + path))
|
||||||
|
.newBuilder();
|
||||||
|
|
||||||
|
Map<String, String> headerParams=new HashMap<>();
|
||||||
|
headerParams.put("appId",appId);
|
||||||
|
headerParams.put("appSecret",secret);
|
||||||
|
headerParams.put("Content-Type","application/json");
|
||||||
|
|
||||||
|
Map<String, String> params = new HashMap<>();
|
||||||
|
params.put("orgId",projectId);
|
||||||
|
params.put("tenantId",tenantId);
|
||||||
|
params.put("size","500");
|
||||||
|
params.put("current",""+page);
|
||||||
|
|
||||||
|
|
||||||
|
Request request = new Request.Builder()
|
||||||
|
.url(urlBuilder.build())
|
||||||
|
.post(toFormBody(params)).headers(setHeaderParams(headerParams))
|
||||||
|
.build();
|
||||||
|
return request;
|
||||||
|
}
|
||||||
|
private void doSyncWorker(JSONObject jdata,int page,SurProjectAttendanceCfg it){
|
||||||
|
String path="/api/open/labour/findLabourWorkerByPage";
|
||||||
|
Request request=getRequest(path,jdata,page);
|
||||||
|
String data=AttendanceTask.getResult(request);
|
||||||
|
JSONObject jo= JSON.parseObject(data);
|
||||||
|
JSONObject joData= jo.getJSONObject("data");
|
||||||
|
JSONArray arr=joData.getJSONArray("records");
|
||||||
|
long pages=joData.getLong("pages");
|
||||||
|
if(arr!=null && arr.size()>0){
|
||||||
|
for(int i=0;i<arr.size();i++){
|
||||||
|
JSONObject json=arr.getJSONObject(i);
|
||||||
|
SurProjectAttendanceUser user=SurProjectAttendanceUser.createFromHuazhu(json);
|
||||||
|
user.setVendorsCode(it.getVendorsCode());
|
||||||
|
user.setCfgid(it.getId());
|
||||||
|
attendanceUserService.add(user);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(page<pages){
|
||||||
|
doSyncWorker(jdata,page+1,it);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue