Browse Source

增加邮箱账号开通默认密码,企业微信推送

zhouy 3 months ago
parent
commit
4595f0cc5c

+ 15 - 4
src/main/java/com/uas/eis/serviceImpl/NetEasyService.java

@@ -106,15 +106,19 @@ public class NetEasyService {
         }
         logger.info("邮箱无此账号,创建邮箱账号:{}",employee.toString());
         QiyeOpenPlatSDK instanceSDK = netEasySDK.getSDKInstance();
+        String initAccount = PinyinUtils.getCustomPinyin(employee.getEm_name());
         Q q = Q.init(null)
                 .addParam("domain", netEasyConfig.getDomain())
-                .addParam("accountName", PinyinUtils.getCustomPinyin(employee.getEm_name()))
+                .addParam("accountName", initAccount)
                 .addParam("name", employee.getEm_name())
                 .addParam("job", employee.getEm_position())
                 .addParam("jobNumber", employee.getEm_code())
                 .addParam("unitId", employee.getOrneteasyid());
-        if(employee.getEm_password().length() >=8 && hasThreeCharacterTypes(employee.getEm_password())){
-            q.addParam("password", employee.getEm_password());
+        String initPWD = employee.getEm_password();
+        if(! StringUtil.hasText(initPWD) || initPWD.length() <8 || ! hasThreeCharacterTypes(initPWD)){
+            //初始密码拼音+系统账号+SI
+            initPWD = initAccount+employee.getEm_code()+"SI";
+            q.addParam("password", PinyinUtils.getCustomPinyin(employee.getEm_name())+employee.getEm_code()+"SI");
         }
         if(StringUtil.hasText(employee.getEm_mobile())){
             q.addParam("mobile", employee.getEm_mobile());
@@ -124,6 +128,13 @@ public class NetEasyService {
         if(ResultEnum.SUCCESS.getCode() == r.getCode()){
             AccountResp accountResp = (AccountResp) r.getDataBean(AccountResp.class);
             baseDao.updateByCondition("employee","em_neteasyid='"+accountResp.getAccountName()+"'","em_code='"+employee.getEm_code()+"'");
+            baseDao.execute("insert into UAPPROVALMSG(ID_,TYPE_,TITLE_,MSG_,EMS_) " +
+                              "select UAPPROVALMSG_SEQ.NEXTVAL,'TEXT','邮箱开通提醒','"+employee.getEm_name()+" 您的企业邮箱账号已创建\n" +
+                    "账号:"+initAccount+"@sisemi.com.cn\n" +
+                    "初始密码:"+initPWD+"\n" +
+                    "登录地址:https://mail.sisemi.com.cn/\n" +
+                    "您也可以通过UAS系统首页-->右上角 网易邮箱 进行SSO免密登录。',em_qywx" +
+                              " from  employee where em_code='"+employee.getEm_code()+"' and  em_qywx is not null");
             logger.info("创建账号成功,账号名称:{}",employee.getEm_name());
         }
     }
@@ -453,7 +464,7 @@ public class NetEasyService {
         return 0;
     }
 
-    private boolean hasThreeCharacterTypes(String password) {
+    public boolean hasThreeCharacterTypes(String password) {
         int typeCount = 0;
         // 检查是否包含大写字母
         if (password.matches(".*[A-Z].*")) typeCount++;

+ 22 - 0
src/test/java/com/uas/eis/NetEasyTest.java

@@ -5,15 +5,19 @@ import com.netease.qiye.qiyeopenplatform.sdk.QiyeOpenPlatSDK;
 import com.netease.qiye.qiyeopenplatform.sdk.QiyeOpenPlatSDKConfig;
 import com.netease.qiye.qiyeopenplatform.sdk.dto.R;
 import com.uas.eis.core.config.NetEasyConfig;
+import com.uas.eis.dao.BaseDao;
+import com.uas.eis.entity.Employee;
 import com.uas.eis.sdk.NetEasySDK;
 import com.uas.eis.serviceImpl.NetEasyService;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.context.annotation.Lazy;
 import org.springframework.test.context.junit4.SpringRunner;
 
 import javax.annotation.Resource;
+import java.util.List;
 
 @RunWith(SpringRunner.class)
 @SpringBootTest(classes = {UasEisApplication.class})
@@ -22,6 +26,9 @@ public class NetEasyTest {
     private NetEasyService netEasyService;
     @Autowired
     private NetEasySDK netEasySDK;
+    @Autowired
+    @Lazy
+    private BaseDao baseDao;
 
     @Resource
     private NetEasyConfig netEasyConfig;
@@ -39,9 +46,18 @@ public class NetEasyTest {
     }
     @Test
     public void syncEmp() throws Exception {
+
         netEasyService.syncEmployee();
     }
     @Test
+    public void createEmp() throws Exception {
+     List<Employee> EmployeeS =  baseDao.query("select em_code,em_name,or_code orcode,or_neteasyid orneteasyid,em_class,em_neteasyid,em_emptype,em_isneteasy,em_position,em_password,em_mobile from employee  left join hrorg on em_defaultorid=or_id"+
+                        " where em_code='005096' order by em_id asc"
+                ,
+                Employee.class);
+       netEasyService.createNetEasyEmployee(EmployeeS.get(0));
+    }
+    @Test
     public void ssoLogin() throws Exception {
         System.out.println(netEasyService.ssoLogin("yangxin"));
     }
@@ -50,6 +66,12 @@ public class NetEasyTest {
         netEasyService.getUnreadMsg("zhuad");
     }
 
+    @Test
+    public void testPwd() throws Exception {
+        System.out.println(netEasyService.hasThreeCharacterTypes("12345678zl"));
+    }
+
+
     @Test
     public void refreshToken() throws Exception {