Browse Source

Merge remote-tracking branch 'origin/shenai_4a' into shenai_4a

zhouy 2 months ago
parent
commit
6d986ea6a6

+ 23 - 1
src/main/java/com/uas/eis/serviceImpl/ADSyncService.java

@@ -74,9 +74,19 @@ public class ADSyncService {
                 if(orgOptional.isPresent()){
                 if(orgOptional.isPresent()){
                     String ouPath = getOUPath(orgOptional.get().getOr_path());
                     String ouPath = getOUPath(orgOptional.get().getOr_path());
                     String adaccountname = getADID(employee);
                     String adaccountname = getADID(employee);
-                    String adid = addUser(adaccountname,employee.getEm_name(),ouPath,employee.getEm_password(), employee.getEmjob());
+                    String initPWD = employee.getEm_password();
+                    if(! StringUtil.hasText(initPWD) || initPWD.length() <8 || ! hasThreeCharacterTypes(initPWD)){
+                        //初始密码拼音+系统账号+SI
+                        initPWD = adaccountname+employee.getEm_code()+"SI";
+                    }
+                    String adid = addUser(adaccountname,employee.getEm_name(),ouPath,initPWD, employee.getEmjob());
                     System.out.println(adaccountname+":"+adid);
                     System.out.println(adaccountname+":"+adid);
                     if(adid!=null){
                     if(adid!=null){
+                        baseDao.execute("insert into UAPPROVALMSG(ID_,TYPE_,TITLE_,MSG_,EMS_) " +
+                                "select UAPPROVALMSG_SEQ.NEXTVAL,'TEXT','AD域开通提醒','"+employee.getEm_name()+" 您的AD(电脑账号)已创建\n" +
+                                "账号:si\\"+adaccountname+"\n" +
+                                "初始密码:"+initPWD+"',em_qywx" +
+                                " from  employee where em_code='"+employee.getEm_code()+"' and  em_qywx is not null");
                         baseDao.updateByCondition("employee","em_adid='"+adid+"',em_adaccountname='"+adaccountname+"'","em_code='"+employee.getEm_code()+"'");
                         baseDao.updateByCondition("employee","em_adid='"+adid+"',em_adaccountname='"+adaccountname+"'","em_code='"+employee.getEm_code()+"'");
                     }
                     }
                 }
                 }
@@ -582,4 +592,16 @@ public class ADSyncService {
         Object accountid= baseDao.getFieldDataByCondition("dual","get_4a_id('"+employee.getEm_code()+"','"+PinyinUtils.getCustomPinyin(employee.getEm_name())+"','AD')","1=1");
         Object accountid= baseDao.getFieldDataByCondition("dual","get_4a_id('"+employee.getEm_code()+"','"+PinyinUtils.getCustomPinyin(employee.getEm_name())+"','AD')","1=1");
         return String.valueOf(accountid);
         return String.valueOf(accountid);
     }
     }
+    public boolean hasThreeCharacterTypes(String password) {
+        int typeCount = 0;
+        // 检查是否包含大写字母
+        if (password.matches(".*[A-Z].*")) typeCount++;
+        // 检查是否包含小写字母
+        if (password.matches(".*[a-z].*")) typeCount++;
+        // 检查是否包含数字
+        if (password.matches(".*[0-9].*")) typeCount++;
+        // 检查是否包含特殊符号(非字母数字)
+        if (password.matches(".*[^A-Za-z0-9].*")) typeCount++;
+        return typeCount >= 3;
+    }
 }
 }

+ 16 - 0
src/main/java/com/uas/eis/serviceImpl/SyncResService.java

@@ -0,0 +1,16 @@
+package com.uas.eis.serviceImpl;
+
+import com.uas.eis.dao.BaseDao;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+@Service
+public class SyncResService {
+    @Autowired
+    private BaseDao baseDao;
+
+    public void updateSyncResult(String key,String result,String err){
+        String resultSql="update ssoAccountSyncItem set SSO_LASTSYNCTIME=sysdate, SSO_INFO='"+ result +"',SSO_err='"+err+"' where SSO_KEY='"+key+"'";
+        baseDao.execute(resultSql);
+    }
+}

+ 2 - 2
src/main/java/com/uas/eis/serviceImpl/YongHService.java

@@ -132,9 +132,9 @@ public class YongHService {
                 baseDao.updateByCondition("employee","EM_YONGHONGID='"+name+"',em_yonghongsynced=-1","em_code='"+employee.getEm_code()+"'");
                 baseDao.updateByCondition("employee","EM_YONGHONGID='"+name+"',em_yonghongsynced=-1","em_code='"+employee.getEm_code()+"'");
                 baseDao.execute("insert into UAPPROVALMSG(ID_,TYPE_,TITLE_,MSG_,EMS_) " +
                 baseDao.execute("insert into UAPPROVALMSG(ID_,TYPE_,TITLE_,MSG_,EMS_) " +
                         "select UAPPROVALMSG_SEQ.NEXTVAL,'TEXT','永洪账号开通提醒','"+employee.getEm_name()+" 您的永洪报表平台账号已创建\n" +
                         "select UAPPROVALMSG_SEQ.NEXTVAL,'TEXT','永洪账号开通提醒','"+employee.getEm_name()+" 您的永洪报表平台账号已创建\n" +
-                        "账号:"+name+
+                        "账号:"+name+"\n" +
                         "初始密码:"+initPWD+"\n" +
                         "初始密码:"+initPWD+"\n" +
-                        "您可以通过UAS系统首页-->右上角 永洪 进行SSO免密登录。',em_qywx" +
+                        "您可以通过UAS系统首页-->右上角 永洪 进行SSO免密登录。',em_qywx" +
                         " from  employee where em_code='"+employee.getEm_code()+"' and  em_qywx is not null");
                         " from  employee where em_code='"+employee.getEm_code()+"' and  em_qywx is not null");
                 map.put("success",true);
                 map.put("success",true);
             }else{
             }else{

+ 46 - 0
src/main/java/com/uas/eis/task/SyncAccountTask.java

@@ -0,0 +1,46 @@
+package com.uas.eis.task;
+
+import com.uas.eis.serviceImpl.ADSyncService;
+import com.uas.eis.serviceImpl.NetEasyService;
+import com.uas.eis.serviceImpl.SyncResService;
+import com.uas.eis.serviceImpl.YongHService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Scheduled;
+import org.springframework.stereotype.Component;
+
+import java.util.Map;
+
+@Component
+public class SyncAccountTask {
+    @Autowired
+    private NetEasyService netEasyService;
+    @Autowired
+    private ADSyncService adSyncService;
+    @Autowired
+    private YongHService yongHService;
+    @Autowired
+    private SyncResService syncResService;
+
+    @Scheduled(cron = "0 0 12,20 * * ?")
+    public void syncNetEasy(){
+        netEasyService.syncNetEasyOrg();
+        netEasyService.syncEmployee();
+    }
+
+    @Scheduled(cron = "0 0 12,20 * * ?")
+    public void syncAD(){
+        adSyncService.syncOrg();
+        adSyncService.syncUser();
+    }
+
+    @Scheduled(cron = "0 0 12,20 * * ?")
+    public void syncYongH() throws Exception {
+        String key="yonghong";
+        String err="";
+        String message="";
+        Map<String,Object> resMap=yongHService.syncEmployee();
+        err = resMap.get("err")==null?"":resMap.get("err").toString();
+        message=resMap.get("message")==null?"":resMap.get("message").toString();
+        syncResService.updateSyncResult(key,message,err);
+    }
+}