java110 vor 3 Jahren
Ursprung
Commit
6f3933406c

+ 12 - 4
service-common/src/main/java/com/java110/common/cmd/machine/SaveMachineCmd.java

@@ -76,6 +76,14 @@ public class SaveMachineCmd extends Cmd {
         Assert.hasKeyAndValue(reqJson, "authCode", "必填,请填写鉴权编码");
         Assert.hasKeyAndValue(reqJson, "locationTypeCd", "必填,请选择位置类型");
 
+        MachineDto machineDto = new MachineDto();
+        machineDto.setMachineCode(reqJson.getString("machineCode"));
+        int count = machineV1InnerServiceSMOImpl.queryMachinesCount(machineDto);
+
+        if (count > 0) {
+            throw new CmdException("设备已存在");
+        }
+
         //属性校验
         Assert.judgeAttrValue(reqJson);
 
@@ -86,14 +94,14 @@ public class SaveMachineCmd extends Cmd {
     public void doCmd(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) throws CmdException {
         MachinePo machinePo = BeanConvertUtil.covertBean(reqJson, MachinePo.class);
 
-        if(!MachineDto.MACHINE_TYPE_MONITOR.equals(reqJson.getString("machineTypeCd"))){
+        if (!MachineDto.MACHINE_TYPE_MONITOR.equals(reqJson.getString("machineTypeCd"))) {
             CommunityLocationDto communityLocationDto = new CommunityLocationDto();
             communityLocationDto.setCommunityId(reqJson.getString("communityId"));
             communityLocationDto.setLocationId(reqJson.getString("locationTypeCd"));
             List<CommunityLocationDto> locationDtos = communityLocationV1InnerServiceSMOImpl.queryCommunityLocations(communityLocationDto);
             Assert.listOnlyOne(locationDtos, "位置不存在");
             machinePo.setLocationObjId(locationDtos.get(0).getLocationObjId());
-        }else{
+        } else {
             machinePo.setLocationObjId("-1");
             machinePo.setLocationTypeCd("-1");
         }
@@ -107,12 +115,12 @@ public class SaveMachineCmd extends Cmd {
             throw new CmdException("保存数据失败");
         }
 
-        dealMachineAttr(reqJson,machinePo);
+        dealMachineAttr(reqJson, machinePo);
 
         cmdDataFlowContext.setResponseEntity(ResultVo.success());
     }
 
-    private void dealMachineAttr(JSONObject paramObj,MachinePo machinePo) {
+    private void dealMachineAttr(JSONObject paramObj, MachinePo machinePo) {
 
         if (!paramObj.containsKey("attrs")) {
             return;

+ 9 - 2
service-common/src/main/java/com/java110/common/cmd/machine/UpdateMachineCmd.java

@@ -31,7 +31,6 @@ import com.java110.intf.common.IMachineV1InnerServiceSMO;
 import com.java110.intf.community.ICommunityLocationV1InnerServiceSMO;
 import com.java110.po.machine.MachineAttrPo;
 import com.java110.po.machine.MachinePo;
-import com.java110.utils.constant.BusinessTypeConstant;
 import com.java110.utils.exception.CmdException;
 import com.java110.utils.util.Assert;
 import com.java110.utils.util.BeanConvertUtil;
@@ -79,6 +78,14 @@ public class UpdateMachineCmd extends Cmd {
         Assert.hasKeyAndValue(reqJson, "authCode", "必填,请填写鉴权编码");
         Assert.hasKeyAndValue(reqJson, "locationTypeCd", "必填,请选择位置类型");
 
+        MachineDto machineDto = new MachineDto();
+        machineDto.setMachineCode(reqJson.getString("machineCode"));
+        List<MachineDto> machineDtos = machineV1InnerServiceSMOImpl.queryMachines(machineDto);
+
+        if (machineDtos != null && machineDtos.size() > 0 && !reqJson.getString("machineId").equals(machineDtos.get(0).getMachineId())) {
+            throw new CmdException("设备已存在");
+        }
+
         Assert.judgeAttrValue(reqJson);
 
     }
@@ -88,7 +95,7 @@ public class UpdateMachineCmd extends Cmd {
     public void doCmd(CmdEvent event, ICmdDataFlowContext cmdDataFlowContext, JSONObject reqJson) throws CmdException {
         MachinePo machinePo = BeanConvertUtil.covertBean(reqJson, MachinePo.class);
 
-        if(!MachineDto.MACHINE_TYPE_MONITOR.equals(reqJson.getString("machineTypeCd"))) {
+        if (!MachineDto.MACHINE_TYPE_MONITOR.equals(reqJson.getString("machineTypeCd"))) {
             CommunityLocationDto communityLocationDto = new CommunityLocationDto();
             communityLocationDto.setCommunityId(reqJson.getString("communityId"));
             communityLocationDto.setLocationId(reqJson.getString("locationTypeCd"));

+ 45 - 38
service-job/src/main/java/com/java110/job/adapt/hcIot/staff/AddStaffToIotAdapt.java

@@ -111,55 +111,62 @@ public class AddStaffToIotAdapt extends DatabusAdaptImpl {
 
         StoreUserPo storeUserPo = BeanConvertUtil.covertBean(businessStoreUser, StoreUserPo.class);
 
+        //查询员工部门
         //查询员工部门
         OrgStaffRelDto orgStaffRelDto = new OrgStaffRelDto();
         orgStaffRelDto.setStaffId(storeUserPo.getUserId());
         orgStaffRelDto.setStoreId(storeUserPo.getStoreId());
         List<OrgStaffRelDto> orgStaffRelDtos = orgStaffRelInnerServiceSMOImpl.queryOrgStaffRels(orgStaffRelDto);
 
-        Assert.listOnlyOne(orgStaffRelDtos, "未包含员工信息");
-
-        //查询员工部门是否参与考勤
-        AttendanceClassesDto attendanceClassesDto = new AttendanceClassesDto();
-        attendanceClassesDto.setClassesObjType(AttendanceClassesDto.CLASSES_OBJ_TYPE_PARTMENT);
-        attendanceClassesDto.setClassesObjId(orgStaffRelDtos.get(0).getDepartmentId());
-        List<AttendanceClassesDto> attendanceClassesDtos = attendanceClassesInnerServiceSMOImpl.queryAttendanceClassess(attendanceClassesDto);
 
-        //员工部门没有考勤,不用处理
-        if (attendanceClassesDtos == null || attendanceClassesDtos.size() < 1) {
-            return;
+        if(orgStaffRelDtos == null || orgStaffRelDtos.size()<1){
+            throw new IllegalArgumentException("员工未包含组织");
         }
 
-        MachineDto machineDto = new MachineDto();
-        machineDto.setLocationObjId(orgStaffRelDtos.get(0).getDepartmentId());
-        machineDto.setMachineTypeCd(MachineDto.MACHINE_TYPE_ATTENDANCE);
-        List<MachineDto> machineDtos = machineV1InnerServiceSMOImpl.queryMachines(machineDto);
-
-        String img = getStaffPhoto(orgStaffRelDtos.get(0));
-
-        JSONObject storeUserObj = null;
-        List<JSONObject> storeUserObjs = new ArrayList<>();
-        for (AttendanceClassesDto tmpAttendanceClassesDto : attendanceClassesDtos) {
-
-            storeUserObj = new JSONObject();
-            storeUserObj.put("extClassesId", tmpAttendanceClassesDto.getClassesId());
-            storeUserObj.put("extStaffId", orgStaffRelDtos.get(0).getStaffId());
-            storeUserObj.put("staffName", orgStaffRelDtos.get(0).getStaffName());
-            storeUserObj.put("departmentId", orgStaffRelDtos.get(0).getDepartmentId());
-            storeUserObj.put("departmentName", orgStaffRelDtos.get(0).getDepartmentName());
-            if (machineDtos != null && machineDtos.size() < 1) {
-                storeUserObj.put("machineCode", machineDtos.get(0).getMachineCode());
-                storeUserObj.put("extMachineId", machineDtos.get(0).getMachineId());
-                storeUserObj.put("extCommunityId", machineDtos.get(0).getCommunityId());
+        for (OrgStaffRelDto tmpOrgStaffRelDto : orgStaffRelDtos) {
+
+            //查询员工部门是否参与考勤
+            AttendanceClassesDto attendanceClassesDto = new AttendanceClassesDto();
+            attendanceClassesDto.setClassesObjType(AttendanceClassesDto.CLASSES_OBJ_TYPE_PARTMENT);
+            attendanceClassesDto.setClassesObjId(tmpOrgStaffRelDto.getOrgId());
+            List<AttendanceClassesDto> attendanceClassesDtos = attendanceClassesInnerServiceSMOImpl.queryAttendanceClassess(attendanceClassesDto);
+
+            //员工部门没有考勤,不用处理
+            if (attendanceClassesDtos == null || attendanceClassesDtos.size() < 1) {
+                continue;
+            }
+
+            MachineDto machineDto = new MachineDto();
+            machineDto.setLocationObjId(tmpOrgStaffRelDto.getOrgId());
+            machineDto.setMachineTypeCd(MachineDto.MACHINE_TYPE_ATTENDANCE);
+            List<MachineDto> machineDtos = machineV1InnerServiceSMOImpl.queryMachines(machineDto);
+
+            String img = getStaffPhoto(orgStaffRelDtos.get(0));
+
+            JSONObject storeUserObj = null;
+            List<JSONObject> storeUserObjs = new ArrayList<>();
+            for (AttendanceClassesDto tmpAttendanceClassesDto : attendanceClassesDtos) {
+
+                storeUserObj = new JSONObject();
+                storeUserObj.put("extClassesId", tmpAttendanceClassesDto.getClassesId());
+                storeUserObj.put("extStaffId", tmpOrgStaffRelDto.getStaffId());
+                storeUserObj.put("staffName", tmpOrgStaffRelDto.getStaffName());
+                storeUserObj.put("departmentId", tmpOrgStaffRelDto.getOrgId());
+                storeUserObj.put("departmentName", tmpOrgStaffRelDto.getOrgName());
+                if (machineDtos != null && machineDtos.size() < 1) {
+                    storeUserObj.put("machineCode", machineDtos.get(0).getMachineCode());
+                    storeUserObj.put("extMachineId", machineDtos.get(0).getMachineId());
+                    storeUserObj.put("extCommunityId", machineDtos.get(0).getCommunityId());
+                }
+                storeUserObj.put("faceBase64", img);
+                storeUserObjs.add(storeUserObj);
             }
-            storeUserObj.put("faceBase64", img);
-            storeUserObjs.add(storeUserObj);
+            JSONObject postParameters = new JSONObject();
+            postParameters.put("classesName", attendanceClassesDtos.get(0).getClassesName());
+            postParameters.put("extClassesId", attendanceClassesDtos.get(0).getClassesId());
+            postParameters.put("extCommunityId", "-1");
+            hcStoreUserAsynImpl.addAttendanceStaff(postParameters, storeUserObjs);
         }
-        JSONObject postParameters = new JSONObject();
-        postParameters.put("classesName", attendanceClassesDtos.get(0).getClassesName());
-        postParameters.put("extClassesId", attendanceClassesDtos.get(0).getClassesId());
-        postParameters.put("extCommunityId", "-1");
-        hcStoreUserAsynImpl.addAttendanceStaff(postParameters, storeUserObjs);
     }
 
     private String getStaffPhoto(OrgStaffRelDto orgStaffRelDto) {