提交 618fc7b6 编写于 作者: sq3536's avatar sq3536

repair

上级 0da317ca
......@@ -12,6 +12,10 @@ import cn.ibizlab.core.ou.service.IIBZOrganizationService;
import cn.ibizlab.util.domain.IBZUSER;
import cn.ibizlab.util.errors.BadRequestAlertException;
import cn.ibizlab.util.service.IBZUSERService;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.Aspect;
......@@ -42,6 +46,14 @@ public class IBZEmp2UserAspect
@Lazy
private OUCoreService ouCoreService;
@Autowired
@Lazy
private IIBZOrganizationService iibzOrganizationService;
@Autowired
@Lazy
private IIBZDepartmentService iibzDepartmentService;
@Autowired
@Lazy
private IBZEmp2UserMapping ibzEmp2UserMapping;
......@@ -52,6 +64,23 @@ public class IBZEmp2UserAspect
@Value("${ibiz.auth.defaultpasswd:123456}")
private String defaultPasswd;
@Before(value = "execution(* cn.ibizlab.core.ou.service.IIBZEmployeeService.getDraft*(..))")
public void BeforeGetDraft(JoinPoint point) throws Exception {
Object[] args = point.getArgs();
if (args.length > 0) {
Object obj = args[0];
if (obj instanceof IBZEmployee) {
IBZEmployee ibzEmployee = (IBZEmployee) obj;
if(StringUtils.isEmpty(ibzEmployee.getOrgid())&&(!StringUtils.isEmpty(ibzEmployee.getMdeptid())))
{
ibzEmployee.setMaindept(iibzDepartmentService.get(ibzEmployee.getMdeptid()));
ibzEmployee.setOrgid(ibzEmployee.getMaindept().getOrgid());
ibzEmployee.setOrgname(ibzEmployee.getMaindept().getOrgname());
}
}
}
}
@Before(value = "execution(* cn.ibizlab.core.ou.service.IIBZEmployeeService.creat*(..))")
public void BeforeCreateEmp(JoinPoint point) throws Exception {
beforeSaveEmp(point);
......@@ -65,6 +94,11 @@ public class IBZEmp2UserAspect
beforeSaveEmp(point);
}
@Before(value = "execution(* cn.ibizlab.core.ou.service.IIBZOrganizationService.creat*(..))")
public void BeforeCreateOrg(JoinPoint point) throws Exception {
beforeSaveOrg(point);
}
@Before(value = "execution(* cn.ibizlab.core.ou.service.IIBZOrganizationService.updat*(..))")
public void BeforeUpdateOrg(JoinPoint point) throws Exception {
beforeSaveOrg(point);
......@@ -125,14 +159,16 @@ public class IBZEmp2UserAspect
Object obj = args[0];
if(obj instanceof IBZEmployee)
{
prepareEmp((IBZEmployee)obj);
prepareEmp((IBZEmployee)obj,null);
}
else if (obj instanceof List)
{
List<IBZEmployee> list=(List<IBZEmployee>)obj;
Integer lastOrder = null;
for(IBZEmployee emp:list)
{
prepareEmp(emp);
prepareEmp(emp,lastOrder);
lastOrder=emp.getShoworder();
}
}
}
......@@ -146,14 +182,16 @@ public class IBZEmp2UserAspect
Object obj = args[0];
if(obj instanceof IBZDepartment)
{
prepareDept((IBZDepartment)obj);
prepareDept((IBZDepartment)obj,null);
}
else if (obj instanceof List)
{
List<IBZDepartment> list=(List<IBZDepartment>)obj;
Integer lastOrder = null;
for(IBZDepartment dept:list)
{
prepareDept(dept);
prepareDept(dept,lastOrder);
lastOrder=dept.getShoworder();
}
}
}
......@@ -167,20 +205,22 @@ public class IBZEmp2UserAspect
Object obj = args[0];
if(obj instanceof IBZOrganization)
{
prepareOrg((IBZOrganization)obj);
prepareOrg((IBZOrganization)obj,null);
}
else if (obj instanceof List)
{
List<IBZOrganization> list=(List<IBZOrganization>)obj;
Integer lastOrder = null;
for(IBZOrganization org:list)
{
prepareOrg(org);
prepareOrg(org,lastOrder);
lastOrder=org.getShoworder();
}
}
}
}
private void prepareEmp(IBZEmployee emp)
private void prepareEmp(IBZEmployee emp,Integer lastOrder)
{
String userName=emp.getUsername();
if(StringUtils.isEmpty(emp.getUserid())&&(!StringUtils.isEmpty(emp.getUsercode()))&&(!StringUtils.isEmpty(emp.getOrgid())))
......@@ -195,6 +235,19 @@ public class IBZEmp2UserAspect
userName = emp.getLoginname();
emp.setUsername(userName);
}
if((!StringUtils.isEmpty(emp.getMdeptid()))&&(!StringUtils.isEmpty(emp.getOrgid()))&&emp.getShoworder()==null)
{
if(lastOrder==null){
IBZEmployee order=iibzEmployeeService.getOne(Wrappers.query(new IBZEmployee()).select("max(showorder) as showorder").eq("mdeptid",emp.getMdeptid()).eq("orgid",emp.getOrgid()),false);
if(order!=null)
lastOrder=order.getShoworder();
}
if(lastOrder!=null)
lastOrder+=10;
else
lastOrder=10;
emp.setShoworder(lastOrder);
}
String password = emp.getPassword();
if(StringUtils.isEmpty(password))
{
......@@ -207,7 +260,7 @@ public class IBZEmp2UserAspect
}
}
private void prepareDept(IBZDepartment dept)
private void prepareDept(IBZDepartment dept,Integer lastOrder)
{
if ((!StringUtils.isEmpty(dept.getDeptid()))&&(!StringUtils.isEmpty(dept.getParentdeptid())))
{
......@@ -218,15 +271,42 @@ public class IBZEmp2UserAspect
{
dept.setDeptid(dept.getOrgid() + dept.getDeptcode());
}
if((!StringUtils.isEmpty(dept.getOrgid()))&&dept.getShoworder()==null)
{
if(lastOrder==null){
IBZDepartment order=iibzDepartmentService.getOne(Wrappers.query(new IBZDepartment()).select("max(showorder) as showorder").eq("orgid",dept.getOrgid()),false);
if(order!=null)
lastOrder=order.getShoworder();
}
if(lastOrder!=null)
lastOrder+=10;
else
lastOrder=10;
dept.setShoworder(lastOrder);
}
}
private void prepareOrg(IBZOrganization org)
private void prepareOrg(IBZOrganization org,Integer lastOrder)
{
if ((!StringUtils.isEmpty(org.getOrgid()))&&(!StringUtils.isEmpty(org.getParentorgid())))
{
if(ouCoreService.getOrgModel(org.getOrgid()).getSub().contains(org.getParentorgid()))
throw new BadRequestAlertException("上级单位选择有误","IBZOrganization",org.getOrgid());
}
if(org.getShoworder()==null)
{
if(lastOrder==null)
{
IBZOrganization order=iibzOrganizationService.getOne((Wrappers.query(new IBZOrganization())).select("max(showorder) as showorder"),false);
if(order!=null)
lastOrder=order.getShoworder();
}
if(lastOrder!=null)
lastOrder+=10;
else
lastOrder=10;
org.setShoworder(lastOrder);
}
}
private void saveUser(JoinPoint point)
......
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog" xmlns:ext="http://www.liquibase.org/xml/ns/dbchangelog-ext" xmlns:pro="http://www.liquibase.org/xml/ns/pro" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog-ext http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-ext.xsd http://www.liquibase.org/xml/ns/pro http://www.liquibase.org/xml/ns/pro/liquibase-pro-3.8.xsd http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.8.xsd">
<changeSet author="sq3536 (generated)" id="1589973108564-1">
<createTable tableName="IBZDEPT">
<column name="DEPTID" type="VARCHAR(100)">
<constraints nullable="false" primaryKey="true" primaryKeyName="PK_IBZDEPT_DEPTID"/>
</column>
<column name="DEPTCODE" type="VARCHAR(100)"/>
<column name="DEPTNAME" type="VARCHAR(100)"/>
<column name="ORGID" type="VARCHAR(100)"/>
<column name="PDEPTID" type="VARCHAR(100)"/>
<column name="SHORTNAME" type="VARCHAR(100)"/>
<column name="DEPTLEVEL" type="INT"/>
<column name="SHOWORDER" type="INT"/>
<column name="BCODE" type="VARCHAR(100)"/>
<column name="LEADERID" type="VARCHAR(100)"/>
<column name="LEADERNAME" type="VARCHAR(100)"/>
<column name="ENABLE" type="INT"/>
<column name="CREATEDATE" type="TIMESTAMP"/>
<column name="UPDATEDATE" type="TIMESTAMP"/>
</createTable>
</changeSet>
<changeSet author="sq3536 (generated)" id="1589973108564-2">
<createTable tableName="IBZDEPTMEMBER">
<column name="MEMBERID" type="VARCHAR(100)">
<constraints nullable="false" primaryKey="true" primaryKeyName="PK_IBZDEPTMEMBER_MEMBERID"/>
</column>
<column name="DEPTID" type="VARCHAR(100)"/>
<column name="USERID" type="VARCHAR(100)"/>
</createTable>
</changeSet>
<changeSet author="sq3536 (generated)" id="1589973108564-3">
<createTable tableName="IBZEMP">
<column name="USERID" type="VARCHAR(100)">
<constraints nullable="false" primaryKey="true" primaryKeyName="PK_IBZEMP_USERID"/>
</column>
<column name="USERNAME" type="VARCHAR(100)"/>
<column name="PERSONNAME" type="VARCHAR(100)"/>
<column name="USERCODE" type="VARCHAR(100)"/>
<column name="LOGINNAME" type="VARCHAR(100)"/>
<column name="PASSWORD" type="VARCHAR(100)"/>
<column name="DOMAINS" type="VARCHAR(100)"/>
<column name="MDEPTID" type="VARCHAR(100)"/>
<column name="MDEPTCODE" type="VARCHAR(100)"/>
<column name="MDEPTNAME" type="VARCHAR(100)"/>
<column name="BCODE" type="VARCHAR(100)"/>
<column name="POSTID" type="VARCHAR(100)"/>
<column name="POSTCODE" type="VARCHAR(100)"/>
<column name="POSTNAME" type="VARCHAR(100)"/>
<column name="ORGID" type="VARCHAR(100)"/>
<column name="ORGCODE" type="VARCHAR(100)"/>
<column name="ORGNAME" type="VARCHAR(100)"/>
<column name="NICKNAME" type="VARCHAR(100)"/>
<column name="SEX" type="VARCHAR(20)"/>
<column name="CERTCODE" type="VARCHAR(100)"/>
<column name="PHONE" type="VARCHAR(100)"/>
<column name="BIRTHDAY" type="TIMESTAMP"/>
<column name="EMAIL" type="VARCHAR(100)"/>
<column name="AVATAR" type="VARCHAR(100)"/>
<column name="ADDR" type="VARCHAR(255)"/>
<column name="USERICON" type="VARCHAR(255)"/>
<column name="IPADDR" type="VARCHAR(100)"/>
<column name="THEME" type="VARCHAR(100)"/>
<column name="LANG" type="VARCHAR(100)"/>
<column name="FONTSIZE" type="VARCHAR(10)"/>
<column name="MEMO" type="VARCHAR(255)"/>
<column name="RESERVER" type="VARCHAR(255)"/>
<column name="SHOWORDER" type="INT"/>
<column name="ENABLE" type="INT"/>
<column name="CREATEDATE" type="TIMESTAMP"/>
<column name="UPDATEDATE" type="TIMESTAMP"/>
</createTable>
</changeSet>
<changeSet author="sq3536 (generated)" id="1589973108564-4">
<createTable tableName="IBZORG">
<column name="ORGID" type="VARCHAR(100)">
<constraints nullable="false" primaryKey="true" primaryKeyName="PK_IBZORG_ORGID"/>
</column>
<column name="ORGCODE" type="VARCHAR(100)"/>
<column name="ORGNAME" type="VARCHAR(100)"/>
<column name="PORGID" type="VARCHAR(100)"/>
<column name="SHORTNAME" type="VARCHAR(100)"/>
<column name="ORGLEVEL" type="INT"/>
<column name="SHOWORDER" type="INT"/>
<column name="ENABLE" type="INT"/>
<column name="CREATEDATE" type="TIMESTAMP"/>
<column name="UPDATEDATE" type="TIMESTAMP"/>
</createTable>
</changeSet>
<changeSet author="sq3536 (generated)" id="1589973108564-5">
<addForeignKeyConstraint baseColumnNames="DEPTID" baseTableName="IBZDEPTMEMBER" constraintName="DER1N_IBZDEPTMEMBER_IBZDEPT_DE" deferrable="false" initiallyDeferred="false" onDelete="RESTRICT" onUpdate="RESTRICT" referencedColumnNames="DEPTID" referencedTableName="IBZDEPT" validate="true"/>
</changeSet>
<changeSet author="sq3536 (generated)" id="1589973108564-6">
<addForeignKeyConstraint baseColumnNames="USERID" baseTableName="IBZDEPTMEMBER" constraintName="DER1N_IBZDEPTMEMBER_IBZEMP_USE" deferrable="false" initiallyDeferred="false" onDelete="RESTRICT" onUpdate="RESTRICT" referencedColumnNames="USERID" referencedTableName="IBZEMP" validate="true"/>
</changeSet>
<changeSet author="sq3536 (generated)" id="1589973108564-7">
<addForeignKeyConstraint baseColumnNames="PDEPTID" baseTableName="IBZDEPT" constraintName="DER1N_IBZDEPT_IBZDEPT_PDEPTID" deferrable="false" initiallyDeferred="false" onDelete="RESTRICT" onUpdate="RESTRICT" referencedColumnNames="DEPTID" referencedTableName="IBZDEPT" validate="true"/>
</changeSet>
<changeSet author="sq3536 (generated)" id="1589973108564-8">
<addForeignKeyConstraint baseColumnNames="ORGID" baseTableName="IBZDEPT" constraintName="DER1N_IBZDEPT_IBZORG_ORGID" deferrable="false" initiallyDeferred="false" onDelete="RESTRICT" onUpdate="RESTRICT" referencedColumnNames="ORGID" referencedTableName="IBZORG" validate="true"/>
</changeSet>
<changeSet author="sq3536 (generated)" id="1589973108564-9">
<addForeignKeyConstraint baseColumnNames="MDEPTID" baseTableName="IBZEMP" constraintName="DER1N_IBZEMP_IBZDEPT_MDEPTID" deferrable="false" initiallyDeferred="false" onDelete="RESTRICT" onUpdate="RESTRICT" referencedColumnNames="DEPTID" referencedTableName="IBZDEPT" validate="true"/>
</changeSet>
<changeSet author="sq3536 (generated)" id="1589973108564-10">
<addForeignKeyConstraint baseColumnNames="ORGID" baseTableName="IBZEMP" constraintName="DER1N_IBZEMP_IBZORG_ORGID" deferrable="false" initiallyDeferred="false" onDelete="RESTRICT" onUpdate="RESTRICT" referencedColumnNames="ORGID" referencedTableName="IBZORG" validate="true"/>
</changeSet>
<changeSet author="sq3536 (generated)" id="1589973108564-11">
<addForeignKeyConstraint baseColumnNames="PORGID" baseTableName="IBZORG" constraintName="DER1N_IBZORG_IBZORG_PORGID" deferrable="false" initiallyDeferred="false" onDelete="RESTRICT" onUpdate="RESTRICT" referencedColumnNames="ORGID" referencedTableName="IBZORG" validate="true"/>
</changeSet>
</databaseChangeLog>
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册