update code
parent
d8edf04fa7
commit
93b207a1dc
|
@ -157,7 +157,7 @@ export default {
|
|||
open: false,
|
||||
// 查询参数
|
||||
queryParams: {
|
||||
vendorsCode:'gld',
|
||||
vendorsCode:'huazhu',
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
projectId:null,
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.yanzhu.jh.project.domain;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
@ -94,6 +95,24 @@ public class SurProjectAttendanceData extends BaseEntity
|
|||
private Long projectId;
|
||||
private Long subDeptId;
|
||||
|
||||
public static SurProjectAttendanceData createFromHuazhu(JSONObject j) {
|
||||
SurProjectAttendanceData d=new SurProjectAttendanceData();
|
||||
d.vendorsCode="huazhu";
|
||||
d.serverid=j.getLongValue("id",0);
|
||||
d.workerId=j.getLongValue("labourWorkerId",0);
|
||||
d.attendanceType=j.getLongValue("inOrOut",1l)==1l?"E":"L";
|
||||
long recordTime=j.getLongValue("recordTime",0);
|
||||
if(recordTime>0){
|
||||
d.attendanceTime= DateUtil.format(DateUtil.date(recordTime),"yyyy-MM-dd HH:mm:ss");
|
||||
}
|
||||
d.identification=j.getString("idCardNo");
|
||||
d.teamId=j.getLongValue("teamId",0);
|
||||
d.workTypeCode=j.getString("workerTypeId");
|
||||
d.companyId=j.getLongValue("unitId",1);
|
||||
d.deviceCode=j.getString("deviceNo");
|
||||
return d;
|
||||
}
|
||||
|
||||
public Long getDeptId() {
|
||||
return deptId;
|
||||
}
|
||||
|
@ -137,7 +156,7 @@ public class SurProjectAttendanceData extends BaseEntity
|
|||
d.workerId=json.getLong("workerId");
|
||||
d.identification=json.getString("identification");
|
||||
d.teamId=json.getLong("teamId");
|
||||
d.workTypeCode=json.getString("workTypeCode");
|
||||
d.workTypeCode=json.getString("workerTypeId");
|
||||
d.companyId=json.getLong("companyId");
|
||||
d.vendorId=json.getLong("vendorId");
|
||||
d.projectType=json.getLong("projectType");
|
||||
|
|
|
@ -175,11 +175,11 @@ public class SurProjectAttendanceUser extends BaseEntity
|
|||
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");
|
||||
u.enterDate= DateUtil.format(DateUtil.date(enterTime),"yyyy-MM-dd HH:mm:ss");
|
||||
}
|
||||
long leaveTime=j.getLong("leaveTime");
|
||||
if(leaveTime>0) {
|
||||
u.exitDate = DateUtil.format(DateUtil.date(leaveTime), "HH:mm:ss");
|
||||
u.exitDate = DateUtil.format(DateUtil.date(leaveTime), "yyyy-MM-dd HH:mm:ss");
|
||||
}
|
||||
u.vendorId=j.getLongValue("unitProjectId",0);
|
||||
u.companyId=j.getLongValue("unitId",0);
|
||||
|
|
|
@ -62,4 +62,6 @@ public interface SurProjectAttendanceDataMapper
|
|||
public long getLastServerId(SurProjectAttendanceData where);
|
||||
|
||||
List<SurProjectAttendanceData> groupByComany(SurProjectAttendanceData where);
|
||||
|
||||
public Long getHuazhuPage(Long id);
|
||||
}
|
||||
|
|
|
@ -66,4 +66,5 @@ public interface ISurProjectAttendanceDataService
|
|||
|
||||
public List<SurProjectAttendanceData> groupByComany(SurProjectAttendanceData where);
|
||||
|
||||
public Long getHuazhuPage(Long id);
|
||||
}
|
||||
|
|
|
@ -121,4 +121,9 @@ public class SurProjectAttendanceDataServiceImpl implements ISurProjectAttendanc
|
|||
public List<SurProjectAttendanceData> groupByComany(SurProjectAttendanceData where) {
|
||||
return surProjectAttendanceDataMapper.groupByComany(where);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long getHuazhuPage(Long id) {
|
||||
return surProjectAttendanceDataMapper.getHuazhuPage(id);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -77,11 +77,13 @@ public class AttendanceHuazhuTask {
|
|||
JSONObject jo=JSON.parseObject(JSON.toJSONString(map));
|
||||
int page=1;
|
||||
SurProjectAttendanceCfg it=new SurProjectAttendanceCfg();
|
||||
it.setId(0l);;
|
||||
//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());
|
||||
new AttendanceHuazhuTask().doSyncAttendanceData(jo,1,it);
|
||||
}
|
||||
private static RequestBody toFormBody(Map<String, String> params ){
|
||||
return RequestBody.create(
|
||||
|
@ -114,15 +116,40 @@ public class AttendanceHuazhuTask {
|
|||
if(Strings.isNotEmpty(param)){
|
||||
try{
|
||||
JSONObject jo=JSON.parseObject(param);
|
||||
doSyncAttendanceData(jo,it);
|
||||
Long page=attendanceDataService.getHuazhuPage(it.getId());
|
||||
if(null==page){
|
||||
doSyncAttendanceData(jo,1,it);
|
||||
}else{
|
||||
doSyncAttendanceData(jo,page,it);
|
||||
}
|
||||
|
||||
}catch (Exception ex){
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private void doSyncAttendanceData(JSONObject jo,SurProjectAttendanceCfg it){
|
||||
|
||||
private void doSyncAttendanceData(JSONObject jdata,long page,SurProjectAttendanceCfg it){
|
||||
String path="/api/open/labour/findCardRecordByPage";
|
||||
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);
|
||||
SurProjectAttendanceData sdata = SurProjectAttendanceData.createFromHuazhu(json);
|
||||
sdata.setVendorId(page); //VendorId保存华筑的页
|
||||
sdata.setCfgid(it.getId());
|
||||
sdata.setVendorsCode(it.getVendorsCode());
|
||||
attendanceDataService.add(sdata);
|
||||
}
|
||||
}
|
||||
if(page<pages){
|
||||
doSyncAttendanceData(jdata,page+1,it);
|
||||
}
|
||||
}
|
||||
public void syncWorker(){
|
||||
SurProjectAttendanceCfg where =new SurProjectAttendanceCfg();
|
||||
|
@ -144,7 +171,7 @@ public class AttendanceHuazhuTask {
|
|||
}
|
||||
}
|
||||
|
||||
public static Request getRequest(String path,JSONObject jo,int page){
|
||||
public static Request getRequest(String path,JSONObject jo,long page){
|
||||
String appId=jo.getString("appId");
|
||||
String secret=jo.getString("secret");
|
||||
String projectId=jo.getString("projectId");
|
||||
|
@ -171,7 +198,7 @@ public class AttendanceHuazhuTask {
|
|||
.build();
|
||||
return request;
|
||||
}
|
||||
private void doSyncWorker(JSONObject jdata,int page,SurProjectAttendanceCfg it){
|
||||
private void doSyncWorker(JSONObject jdata,long page,SurProjectAttendanceCfg it){
|
||||
String path="/api/open/labour/findLabourWorkerByPage";
|
||||
Request request=getRequest(path,jdata,page);
|
||||
String data=AttendanceTask.getResult(request);
|
||||
|
@ -186,6 +213,7 @@ public class AttendanceHuazhuTask {
|
|||
user.setVendorsCode(it.getVendorsCode());
|
||||
user.setCfgid(it.getId());
|
||||
attendanceUserService.add(user);
|
||||
|
||||
}
|
||||
}
|
||||
if(page<pages){
|
||||
|
|
|
@ -188,4 +188,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
group by workerId )
|
||||
and companyTypeId in (1,2,3,8) group by companyTypeId
|
||||
</select>
|
||||
<select id="getHuazhuPage" parameterType="long" resultType="Long">
|
||||
select max(vendorId) vendorId from sur_project_attendance_data WHERE cfgid=#{id}
|
||||
</select>
|
||||
</mapper>
|
|
@ -244,7 +244,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|||
<sql id="sqlAttendanceData">
|
||||
(
|
||||
SELECT * FROM sur_project_attendance_data WHERE DATE(attendance_time)=date(#{createBy}) AND cfgid IN (
|
||||
SELECT id FROM sur_project_attendance_cfg WHERE project_id=#{projectId} AND sub_dept_id=#{subDeptId} AND vendors_code=#{vendorsCode}
|
||||
SELECT id FROM sur_project_attendance_cfg WHERE project_id=#{projectId} AND sub_dept_id=#{subDeptId}
|
||||
) ) xx
|
||||
</sql>
|
||||
<select id="queryAttendanceData" parameterType="SurProjectAttendanceCfg" resultMap="SurProjectAttendanceUserResult">
|
||||
|
|
Loading…
Reference in New Issue