|
|
@@ -17,25 +17,23 @@ package com.java110.job.adapt.hcIot.attendance;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
-import com.java110.dto.owner.OwnerCarDto;
|
|
|
-import com.java110.dto.parking.ParkingSpaceDto;
|
|
|
+import com.java110.dto.attendanceClasses.AttendanceClassesDto;
|
|
|
import com.java110.entity.order.Business;
|
|
|
-import com.java110.intf.community.IParkingSpaceInnerServiceSMO;
|
|
|
-import com.java110.intf.user.IOwnerCarInnerServiceSMO;
|
|
|
+import com.java110.intf.common.IAttendanceClassesInnerServiceSMO;
|
|
|
+import com.java110.intf.user.IOrgStaffRelInnerServiceSMO;
|
|
|
import com.java110.job.adapt.DatabusAdaptImpl;
|
|
|
import com.java110.job.adapt.hcIot.asyn.IIotSendAsyn;
|
|
|
-import com.java110.po.car.OwnerCarPo;
|
|
|
+import com.java110.po.attendanceClasses.AttendanceClassesPo;
|
|
|
import com.java110.utils.constant.StatusConstant;
|
|
|
import com.java110.utils.util.Assert;
|
|
|
import com.java110.utils.util.BeanConvertUtil;
|
|
|
-import com.java110.utils.util.StringUtil;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
/**
|
|
|
- * HC iot 设备同步适配器
|
|
|
+ * HC iot 考勤同步适配器
|
|
|
* <p>
|
|
|
* 接口协议地址: https://gitee.com/java110/MicroCommunityThings/blob/master/back/docs/api.md
|
|
|
*
|
|
|
@@ -45,18 +43,24 @@ import java.util.List;
|
|
|
public class DeleteAttendanceToIotAdapt extends DatabusAdaptImpl {
|
|
|
|
|
|
@Autowired
|
|
|
- private IIotSendAsyn hcOwnerCarAsynImpl;
|
|
|
+ private IIotSendAsyn hcOwnerAttendanceAsynImpl;
|
|
|
+
|
|
|
|
|
|
@Autowired
|
|
|
- private IOwnerCarInnerServiceSMO ownerCarInnerServiceSMOImpl;
|
|
|
+ private IAttendanceClassesInnerServiceSMO attendanceClassesInnerServiceSMOImpl;
|
|
|
|
|
|
@Autowired
|
|
|
- private IParkingSpaceInnerServiceSMO parkingSpaceInnerServiceSMOImpl;
|
|
|
+ private IOrgStaffRelInnerServiceSMO orgStaffRelInnerServiceSMOImpl;
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
- * {
|
|
|
- * "extOwnerCarId": "702020042194860037"
|
|
|
- * }
|
|
|
+ * accessToken={access_token}
|
|
|
+ * &extCommunityUuid=01000
|
|
|
+ * &extCommunityId=1
|
|
|
+ * &devSn=111111111
|
|
|
+ * &name=设备名称
|
|
|
+ * &positionType=0
|
|
|
+ * &positionUuid=1
|
|
|
*
|
|
|
* @param business 当前处理业务
|
|
|
* @param businesses 所有业务信息
|
|
|
@@ -64,49 +68,41 @@ public class DeleteAttendanceToIotAdapt extends DatabusAdaptImpl {
|
|
|
@Override
|
|
|
public void execute(Business business, List<Business> businesses) {
|
|
|
JSONObject data = business.getData();
|
|
|
- if (data.containsKey(OwnerCarPo.class.getSimpleName())) {
|
|
|
- Object bObj = data.get(OwnerCarPo.class.getSimpleName());
|
|
|
- JSONArray businessOwnerCars = null;
|
|
|
+ if (data.containsKey(AttendanceClassesPo.class.getSimpleName())) {
|
|
|
+ Object bObj = data.get(AttendanceClassesPo.class.getSimpleName());
|
|
|
+ JSONArray businessOwnerAttendances = null;
|
|
|
if (bObj instanceof JSONObject) {
|
|
|
- businessOwnerCars = new JSONArray();
|
|
|
- businessOwnerCars.add(bObj);
|
|
|
+ businessOwnerAttendances = new JSONArray();
|
|
|
+ businessOwnerAttendances.add(bObj);
|
|
|
} else if (bObj instanceof List) {
|
|
|
- businessOwnerCars = JSONArray.parseArray(JSONObject.toJSONString(bObj));
|
|
|
+ businessOwnerAttendances = JSONArray.parseArray(JSONObject.toJSONString(bObj));
|
|
|
} else {
|
|
|
- businessOwnerCars = (JSONArray) bObj;
|
|
|
+ businessOwnerAttendances = (JSONArray) bObj;
|
|
|
}
|
|
|
- //JSONObject businessOwnerCar = data.getJSONObject("businessOwnerCar");
|
|
|
- for (int bOwnerCarIndex = 0; bOwnerCarIndex < businessOwnerCars.size(); bOwnerCarIndex++) {
|
|
|
- JSONObject businessOwnerCar = businessOwnerCars.getJSONObject(bOwnerCarIndex);
|
|
|
- doSendOwnerCar(business, businessOwnerCar);
|
|
|
+ //JSONObject businessOwnerAttendance = data.getJSONObject("businessOwnerAttendance");
|
|
|
+ for (int bOwnerAttendanceIndex = 0; bOwnerAttendanceIndex < businessOwnerAttendances.size(); bOwnerAttendanceIndex++) {
|
|
|
+ JSONObject businessOwnerAttendance = businessOwnerAttendances.getJSONObject(bOwnerAttendanceIndex);
|
|
|
+ doSendOwnerAttendance(business, businessOwnerAttendance);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void doSendOwnerCar(Business business, JSONObject businessOwnerCar) {
|
|
|
- OwnerCarPo ownerCarPo = BeanConvertUtil.covertBean(businessOwnerCar, OwnerCarPo.class);
|
|
|
- OwnerCarDto ownerCarDto = new OwnerCarDto();
|
|
|
- ownerCarDto.setCarId(ownerCarPo.getCarId());
|
|
|
- ownerCarDto.setStatusCd(StatusConstant.STATUS_CD_INVALID);
|
|
|
- List<OwnerCarDto> ownerCarDtos = ownerCarInnerServiceSMOImpl.queryOwnerCars(ownerCarDto);
|
|
|
- Assert.listOnlyOne(ownerCarDtos, "未找到停车场");
|
|
|
+ private void doSendOwnerAttendance(Business business, JSONObject businessOwnerAttendance) {
|
|
|
|
|
|
- //没有车位就不同步了
|
|
|
- if (StringUtil.isEmpty(ownerCarDtos.get(0).getPsId()) || "-1".equals(ownerCarDtos.get(0).getPsId())) {
|
|
|
- return;
|
|
|
- }
|
|
|
+ AttendanceClassesPo ownerAttendancePo = BeanConvertUtil.covertBean(businessOwnerAttendance, AttendanceClassesPo.class);
|
|
|
+
|
|
|
+ AttendanceClassesDto ownerAttendanceDto = new AttendanceClassesDto();
|
|
|
+ ownerAttendanceDto.setClassesId(ownerAttendancePo.getClassesId());
|
|
|
+ ownerAttendanceDto.setStoreId(ownerAttendancePo.getStoreId());
|
|
|
+ ownerAttendanceDto.setStatusCd(StatusConstant.STATUS_CD_INVALID);
|
|
|
+ List<AttendanceClassesDto> attendanceDtos = attendanceClassesInnerServiceSMOImpl.queryAttendanceClassess(ownerAttendanceDto);
|
|
|
|
|
|
- ParkingSpaceDto parkingSpaceDto = new ParkingSpaceDto();
|
|
|
- parkingSpaceDto.setPsId(ownerCarDtos.get(0).getPsId());
|
|
|
- parkingSpaceDto.setCommunityId(ownerCarDtos.get(0).getCommunityId());
|
|
|
- List<ParkingSpaceDto> parkingSpaceDtos = parkingSpaceInnerServiceSMOImpl.queryParkingSpaces(parkingSpaceDto);
|
|
|
- Assert.listOnlyOne(ownerCarDtos, "未找到车位");
|
|
|
+ Assert.listOnlyOne(attendanceDtos, "未找到考勤班组");
|
|
|
|
|
|
JSONObject postParameters = new JSONObject();
|
|
|
- postParameters.put("extCarId", ownerCarDtos.get(0).getCarId());
|
|
|
- postParameters.put("carNum", ownerCarDtos.get(0).getCarNum());
|
|
|
- postParameters.put("extPaId", parkingSpaceDtos.get(0).getPaId());
|
|
|
- postParameters.put("extCommunityId", ownerCarDtos.get(0).getCommunityId());
|
|
|
- hcOwnerCarAsynImpl.deleteOwnerCar(postParameters);
|
|
|
+ postParameters.put("extClassesId", attendanceDtos.get(0).getClassesId());
|
|
|
+ postParameters.put("classesName", attendanceDtos.get(0).getClassesName());
|
|
|
+ postParameters.put("extCommunityId", "-1");
|
|
|
+ hcOwnerAttendanceAsynImpl.deleteAttendance(postParameters);
|
|
|
}
|
|
|
}
|