Browse Source

Merge branch 'test'

anderx 4 years ago
parent
commit
6505d8890c

+ 22 - 0
src/main/java/com/goafanti/admin/service/impl/NewAdminServiceImpl.java

@@ -6,6 +6,7 @@ import java.util.Map;
 import java.util.TreeMap;
 import java.util.UUID;
 
+import com.goafanti.common.model.Role;
 import org.springframework.beans.BeanUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -89,11 +90,31 @@ public class NewAdminServiceImpl extends BaseMybatisDao<AdminMapper> implements
 			}
 			TokenManager.clearUserAuthByUserId(ad.getId());
 		}
+		ad.setType(sumType(roleIds));
 		int count=adminMapper.updateByPrimaryKeySelective(ad);
 		List<Admin> Nos =adminMapper.selectIDNBySuperiorId(ad.getId());
 		return count;
 	}
 
+	private int sumType(List<String > roleIds) {
+		int type=0;
+		for (String roleId : roleIds) {
+			Role r=userRoleMapper.selectById(roleId);
+			String rt=r.getRoleType().toString();
+			if (rt.equals(AFTConstants.SALESMAN)||rt.equals(AFTConstants.SALESMAN_MANAGER)||rt.equals(AFTConstants.SALESMAN_ADMIN)){
+				type=1;
+				break;
+			}else if (rt.equals(AFTConstants.FINANCE)||rt.equals(AFTConstants.FINANCE_MANAGER)||rt.equals(AFTConstants.FINANCE_ADMIN)){
+				type=2;
+				break;
+			}else if (rt.equals(AFTConstants.TECH)||rt.equals(AFTConstants.TECH_MANAGER)||rt.equals(AFTConstants.TECH_ADMIN)){
+				type=3;
+				break;
+			}
+		}
+		return type;
+	}
+
 	@Override
 	public int updateByPrimaryKey(Admin a) {
 		return adminMapper.updateByPrimaryKeySelective(a);
@@ -191,6 +212,7 @@ public class NewAdminServiceImpl extends BaseMybatisDao<AdminMapper> implements
 	public int insertNewAdmin(Admin ad ,List<String> roleIds) {
 		ad.setStatus("正常");
 		ad.setId(UUID.randomUUID().toString());
+		ad.setType(sumType(roleIds));
 		/*String sdepNo=adminMapper.selectUserNoBySuperiorId(ad.getSuperiorId());
 		int Count=adminMapper.selectCountBySuperiorId(ad.getSuperiorId());
 		if(Count<10){

+ 3 - 1
src/main/java/com/goafanti/common/dao/UserRoleMapper.java

@@ -3,6 +3,7 @@ package com.goafanti.common.dao;
 import java.util.List;
 import java.util.Map;
 
+import com.goafanti.common.model.Role;
 import com.goafanti.common.model.UserRole;
 
 public interface UserRoleMapper {
@@ -16,7 +17,6 @@ public interface UserRoleMapper {
 
 	void deleteByRoleId(List<String> records);
 
-	int deleteByUserRole(Map<String, Object> params);
 
 	int deleteByUserId(String id);
 
@@ -25,4 +25,6 @@ public interface UserRoleMapper {
 	List<String> listAuditor();
 
 	List<UserRole> selectAdminRole(String roleName);
+
+    Role selectById(String roleId);
 }

+ 11 - 11
src/main/java/com/goafanti/common/mapper/AdminMapper.xml

@@ -480,7 +480,9 @@
       <if test="openId != null">
         open_id = #{openId},
       </if>
-      
+      <if test="type != null">
+        type = #{type},
+      </if>
     </set>
     where id = #{id,jdbcType=VARCHAR}
   </update>
@@ -824,13 +826,13 @@
   <insert id="insertn" parameterType="com.goafanti.common.model.Admin">
     insert into admin (id, mobile, name, 
       password, email, create_time, 
-      number, province, position, superior_id, city,department_id,status,user_no,duty,district,head_portrait_url,contact_mobile)
+      number, province, position, superior_id, city,department_id,status,user_no,duty,district,head_portrait_url,contact_mobile,type)
     values (#{id,jdbcType=VARCHAR}, #{mobile,jdbcType=VARCHAR}, #{name,jdbcType=VARCHAR}, 
       #{password,jdbcType=VARCHAR}, #{email,jdbcType=VARCHAR}, #{createTime,jdbcType=TIMESTAMP}, 
       #{number,jdbcType=INTEGER}, #{province,jdbcType=INTEGER}, #{position,jdbcType=VARCHAR},
       #{superiorId,jdbcType=VARCHAR}, #{city,jdbcType=INTEGER},#{departmentId,jdbcType=VARCHAR},
-      #{status,jdbcType=VARCHAR},#{userNo,jdbcType=VARCHAR},#{duty,jdbcType=VARCHAR},#{district,jdbcType=VARCHAR},#{headPortraitUrl,jdbcType=VARCHAR},#{contactMobile,jdbcType=VARCHAR}
-      )
+      #{status,jdbcType=VARCHAR},#{userNo,jdbcType=VARCHAR},#{duty,jdbcType=VARCHAR},#{district,jdbcType=VARCHAR},#{headPortraitUrl,jdbcType=VARCHAR},#{contactMobile,jdbcType=VARCHAR},
+      #{type})
   </insert>
   <select id="selectUserNoBySuperiorId" parameterType="java.lang.String" resultType="java.lang.String">
   	select 
@@ -1105,13 +1107,11 @@
   </select>
   
    <select id="selectAdminCustomerDetailList"  resultType="com.goafanti.admin.bo.AdminCustomerDetailBo">
-     select a.id,a.nickname as name,a.source,d.name contacts,d.mobile as contactMobile,d.department contactsDep,d.`position` contactsPosition,
-     a.create_time as createTime,b.last_follow_time as followTime,c.location_province locationProvince, c.location_city locationCity,
-     c.location_area locationArea,c.business_scope businessScope , c.intended_project intendedProject
+     select a.id,a.nickname as name,a.source,c.contacts contacts,c.contact_mobile as contactMobile,c.contacts_dep contactsDep,
+     c.contacts_position contactsPosition, a.create_time as createTime,b.last_follow_time as followTime,c.location_province locationProvince,
+     c.location_city locationCity,c.location_area locationArea,c.business_scope businessScope , c.intended_project intendedProject
      from user a left join (select uid,last_follow_time from user_mid where aid= #{aid}) b  on a.id=b.uid
-     left join organization_identity c on a.id=c.uid left join (select y.id,y.uid,y.name ,y.mobile ,y.department ,y.`position`from (
-         select uid,max(id)id from organization_contact_book where major =1 and aid = #{aid} group by uid )x
-         left join organization_contact_book y on x.id=y.id) d on a.id =d.uid
+     left join organization_identity c on a.id=c.uid
      <if test="type==5 or type==6">
 	left join (select aid,uid from public_release where clock_in =1
 	and aid= #{aid,jdbcType=VARCHAR}
@@ -1166,7 +1166,7 @@
       <if test="startTime != null and endTime != null">
         and  clock_in_time between #{startTime,jdbcType=VARCHAR} and #{endTime,jdbcType=VARCHAR}
       </if>
-      )e on a.id=d.uid
+      )e on a.id=e.uid
 	</if>
 	where  a.type=1 
 	<if test="type != 5 and type !=6">

+ 37 - 14
src/main/java/com/goafanti/common/mapper/OrganizationIdentityMapper.xml

@@ -73,6 +73,8 @@
     <result column="honor_picture" jdbcType="VARCHAR" property="honorPicture" />
     <result column="sales_target" jdbcType="VARCHAR" property="salesTarget" />
     <result column="intended_project" jdbcType="VARCHAR" property="intendedProject" />
+    <result column="contacts_dep" jdbcType="VARCHAR" property="contactsDep" />
+    <result column="contacts_position" jdbcType="VARCHAR" property="contactsPosition" />
   </resultMap>
   <sql id="Base_Column_List">
     id, `uid`, contacts, contact_mobile, fixed_tel, qq, postal_address, postcode, unit_name, 
@@ -86,7 +88,8 @@
     enterprise_scale, register_type, foreign_investment, field, tax_authority, ratepay_method, 
     high_tech_zone, risk_investment, business_scope, high_tech_name, patent_prory_statement_url, 
     international, review_instructions, investment, year_sales_amount, last_year_research_amount, 
-    assets, qualification, cooperation_situation, honor_picture, sales_target, intended_project
+    assets, qualification, cooperation_situation, honor_picture, sales_target, intended_project, 
+    contacts_dep, contacts_position
   </sql>
   <select id="selectByPrimaryKey" parameterType="java.lang.String" resultMap="BaseResultMap">
     select 
@@ -99,7 +102,7 @@
     where id = #{id,jdbcType=VARCHAR}
   </delete>
   <insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.goafanti.common.model.OrganizationIdentity" useGeneratedKeys="true">
-    insert into organization_identity (id,`uid`, contacts, contact_mobile,
+    insert into organization_identity (`uid`, contacts, contact_mobile, 
       fixed_tel, qq, postal_address, 
       postcode, unit_name, registered_capital, 
       licence_number, licence_province, licence_city, 
@@ -122,9 +125,9 @@
       international, review_instructions, investment, 
       year_sales_amount, last_year_research_amount, 
       assets, qualification, cooperation_situation, 
-      honor_picture, sales_target, intended_project
-      )
-    values (#{id,jdbcType=VARCHAR},#{uid,jdbcType=VARCHAR}, #{contacts,jdbcType=VARCHAR}, #{contactMobile,jdbcType=VARCHAR},
+      honor_picture, sales_target, intended_project, 
+      contacts_dep, contacts_position)
+    values (#{uid,jdbcType=VARCHAR}, #{contacts,jdbcType=VARCHAR}, #{contactMobile,jdbcType=VARCHAR}, 
       #{fixedTel,jdbcType=VARCHAR}, #{qq,jdbcType=VARCHAR}, #{postalAddress,jdbcType=VARCHAR}, 
       #{postcode,jdbcType=VARCHAR}, #{unitName,jdbcType=VARCHAR}, #{registeredCapital,jdbcType=DECIMAL}, 
       #{licenceNumber,jdbcType=VARCHAR}, #{licenceProvince,jdbcType=INTEGER}, #{licenceCity,jdbcType=INTEGER}, 
@@ -147,15 +150,12 @@
       #{international,jdbcType=INTEGER}, #{reviewInstructions,jdbcType=VARCHAR}, #{investment,jdbcType=INTEGER}, 
       #{yearSalesAmount,jdbcType=DECIMAL}, #{lastYearResearchAmount,jdbcType=DECIMAL}, 
       #{assets,jdbcType=DECIMAL}, #{qualification,jdbcType=VARCHAR}, #{cooperationSituation,jdbcType=VARCHAR}, 
-      #{honorPicture,jdbcType=VARCHAR}, #{salesTarget,jdbcType=VARCHAR}, #{intendedProject,jdbcType=VARCHAR}
-      )
+      #{honorPicture,jdbcType=VARCHAR}, #{salesTarget,jdbcType=VARCHAR}, #{intendedProject,jdbcType=VARCHAR}, 
+      #{contactsDep,jdbcType=VARCHAR}, #{contactsPosition,jdbcType=VARCHAR})
   </insert>
   <insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.goafanti.common.model.OrganizationIdentity" useGeneratedKeys="true">
     insert into organization_identity
     <trim prefix="(" suffix=")" suffixOverrides=",">
-      <if test="id != null">
-        `id`,
-      </if>
       <if test="uid != null">
         `uid`,
       </if>
@@ -366,11 +366,14 @@
       <if test="intendedProject != null">
         intended_project,
       </if>
+      <if test="contactsDep != null">
+        contacts_dep,
+      </if>
+      <if test="contactsPosition != null">
+        contacts_position,
+      </if>
     </trim>
     <trim prefix="values (" suffix=")" suffixOverrides=",">
-      <if test="id != null">
-        #{id,jdbcType=VARCHAR},
-      </if>
       <if test="uid != null">
         #{uid,jdbcType=VARCHAR},
       </if>
@@ -581,6 +584,12 @@
       <if test="intendedProject != null">
         #{intendedProject,jdbcType=VARCHAR},
       </if>
+      <if test="contactsDep != null">
+        #{contactsDep,jdbcType=VARCHAR},
+      </if>
+      <if test="contactsPosition != null">
+        #{contactsPosition,jdbcType=VARCHAR},
+      </if>
     </trim>
   </insert>
   <update id="updateByPrimaryKeySelective" parameterType="com.goafanti.common.model.OrganizationIdentity">
@@ -796,6 +805,12 @@
       <if test="intendedProject != null">
         intended_project = #{intendedProject,jdbcType=VARCHAR},
       </if>
+      <if test="contactsDep != null">
+        contacts_dep = #{contactsDep,jdbcType=VARCHAR},
+      </if>
+      <if test="contactsPosition != null">
+        contacts_position = #{contactsPosition,jdbcType=VARCHAR},
+      </if>
     </set>
     where id = #{id,jdbcType=VARCHAR}
   </update>
@@ -870,7 +885,9 @@
       cooperation_situation = #{cooperationSituation,jdbcType=VARCHAR},
       honor_picture = #{honorPicture,jdbcType=VARCHAR},
       sales_target = #{salesTarget,jdbcType=VARCHAR},
-      intended_project = #{intendedProject,jdbcType=VARCHAR}
+      intended_project = #{intendedProject,jdbcType=VARCHAR},
+      contacts_dep = #{contactsDep,jdbcType=VARCHAR},
+      contacts_position = #{contactsPosition,jdbcType=VARCHAR}
     where id = #{id,jdbcType=VARCHAR}
   </update>
 	<select id="selectOrgIdentityByUserId" parameterType="java.lang.String" resultMap="BaseResultMap">
@@ -1302,6 +1319,12 @@
       <if test="intendedProject != null">
         intended_project = #{intendedProject,jdbcType=VARCHAR},
       </if>
+      <if test="contactsDep != null">
+        contacts_dep = #{contactsDep,jdbcType=VARCHAR},
+      </if>
+      <if test="contactsPosition != null">
+        contacts_position = #{contactsPosition,jdbcType=VARCHAR},
+      </if>
     </set>
     where uid = #{uid,jdbcType=VARCHAR}
   </update>

+ 5 - 5
src/main/java/com/goafanti/common/mapper/UserMapperExt.xml

@@ -728,11 +728,11 @@
 	</select>
 
 	<select id="findCustomerContacts" parameterType="java.lang.String" resultType="com.goafanti.common.model.OrganizationContactBook">
-	select a.id,a.name,a.mobile,a.email,a.qq,a.wechat,a.department,a.position,a.major,a.fixed_tel fixedTel,a.aname,b.location_province,
-	d1.name provinceName,d2.name cityName,d3.name areaName,date_format(a.create_time,'%Y-%m-%d')createTimes,a.aid
-	from organization_contact_book a
-	left join organization_identity b on a.uid=b.uid left join district_glossory d1 on b.location_province=d1.id
-	left join district_glossory d2 on b.location_city=d2.id left join district_glossory d3 on b.location_area=d3.id
+		select a.id,a.name,a.mobile,a.email,a.qq,a.wechat,a.department,a.position,a.major,a.fixed_tel fixedTel,ad.name aname,b.location_province,
+			   d1.name provinceName,d2.name cityName,d3.name areaName,date_format(a.create_time,'%Y-%m-%d')createTimes,a.aid
+		from organization_contact_book a left join admin ad on a.aid=ad.id
+		 left join organization_identity b on a.uid=b.uid left join district_glossory d1 on b.location_province=d1.id
+		 left join district_glossory d2 on b.location_city=d2.id left join district_glossory d3 on b.location_area=d3.id
 		where a.uid = #{uid,jdbcType=VARCHAR} and a.aid= #{aid,jdbcType=VARCHAR} order by a.create_time desc
 	</select>
 

+ 4 - 0
src/main/java/com/goafanti/common/mapper/UserRoleMapper.xml

@@ -74,4 +74,8 @@
 	left join role b on a.rid=b.id
 	where b.role_name=#{roleName,jdbcType=VARCHAR}
   </select>
+    <select id="selectById" resultType="com.goafanti.common.model.Role">
+      select id,role_name roleName,role_type roleType
+      from `role` where id = #{roleId}
+    </select>
 </mapper>

+ 10 - 1
src/main/java/com/goafanti/common/model/Admin.java

@@ -96,6 +96,15 @@ public class Admin extends BaseModel implements AftUser {
 	private String	openId;
 
 	/**
+	 * �?在市
+	 */
+	private Integer				type;
+
+	public void setType(Integer type) {
+		this.type = type;
+	}
+
+	/**
 	 * This field was generated by MyBatis Generator. This field corresponds to the database column admin.contact_mobile
 	 * @mbg.generated  Wed Jun 13 10:27:07 CST 2018
 	 */
@@ -295,7 +304,7 @@ public class Admin extends BaseModel implements AftUser {
 
 	@Override
 	public Integer getType() {
-		return null;
+		return this.type;
 	}
 
 	public Date getLastLoginTime() {

+ 26 - 0
src/main/java/com/goafanti/common/model/OrganizationIdentity.java

@@ -358,6 +358,16 @@ public class OrganizationIdentity implements Serializable {
      */
     private String intendedProject;
 
+    /**
+     * 联系人部门
+     */
+    private String contactsDep;
+
+    /**
+     * 联系人职位
+     */
+    private String contactsPosition;
+
     private static final long serialVersionUID = 1L;
 
     public String getId() {
@@ -927,4 +937,20 @@ public class OrganizationIdentity implements Serializable {
     public void setIntendedProject(String intendedProject) {
         this.intendedProject = intendedProject;
     }
+
+    public String getContactsDep() {
+        return contactsDep;
+    }
+
+    public void setContactsDep(String contactsDep) {
+        this.contactsDep = contactsDep;
+    }
+
+    public String getContactsPosition() {
+        return contactsPosition;
+    }
+
+    public void setContactsPosition(String contactsPosition) {
+        this.contactsPosition = contactsPosition;
+    }
 }

+ 14 - 2
src/main/java/com/goafanti/customer/service/impl/CustomerServiceImpl.java

@@ -353,6 +353,7 @@ public class CustomerServiceImpl extends BaseMybatisDao<UserMapper> implements C
 			oi.setUid(uid);
 			oi.setContacts(in.getContacts());
 			oi.setContactMobile(in.getContactMobile());
+			oi.setContactsPosition(in.getPosition());
 			oi.setLocationProvince(in.getProvince());
 			oi.setLocationCity(in.getCity());
 			oi.setLocationArea(in.getArea());
@@ -1155,6 +1156,7 @@ public class CustomerServiceImpl extends BaseMybatisDao<UserMapper> implements C
 			if (flag <= 0)
 				throw new BusinessException(new Error(ErrorConstants.CUSTOMER_ALREADY_RECEIVE, ""));
 			updateUserMid(aid,uid,0,null);
+			organizationContactBookMapper.updateAdmin(uid,aid);
 			//转交
 		} else if (AFTConstants.USER_TRANSFER_TO_OTHER.equals(operatorType)
 				|| AFTConstants.SIGN_USER_TRANSFER_TO_OTHER == operatorType) {
@@ -1211,6 +1213,8 @@ public class CustomerServiceImpl extends BaseMybatisDao<UserMapper> implements C
 		return 1;
 	}
 
+
+
 	/**
 	 * 处理中间表
 	 * @param aid
@@ -1546,10 +1550,18 @@ public class CustomerServiceImpl extends BaseMybatisDao<UserMapper> implements C
 	public int addOneContact(OrganizationContactBook ocb) {
 		ocb.setAid(TokenManager.getAdminId());
 		ocb.setId(UUID.randomUUID().toString());
-		ocb.setMajor(AFTConstants.NO);
 		Admin ad = adminMapper.selectByPrimaryKey(TokenManager.getAdminId());
 		ocb.setAname(ad.getName());
-		return organizationContactBookMapper.insert(ocb);
+		if (ocb.getMajor()==1){
+			organizationContactBookMapper.updateSubContact(ocb.getUid());
+			OrganizationIdentity n=new OrganizationIdentity();
+			n.setUid(ocb.getUid());
+			n.setContacts(ocb.getName());
+			n.setContactsDep(ocb.getDepartment());
+			n.setContactsPosition(ocb.getPosition());
+			organizationIdentityMapper.updateServiceByUid(n);
+		}
+	return organizationContactBookMapper.insert(ocb);
 	}
 
 	@Override

+ 1 - 1
src/main/java/com/goafanti/permission/service/impl/NewRoleServiceImpl.java

@@ -156,7 +156,7 @@ public class NewRoleServiceImpl extends BaseMybatisDao<RoleMapper> implements Ne
 		params.put("rid", roleId);
 		params.put("uid", userId);
 		TokenManager.clearUserAuthByUserId(new String[] { userId });
-		return userRoleMapper.deleteByUserRole(params);
+		return 0;
 	}
 
 	@Override

+ 1 - 1
src/main/java/com/goafanti/permission/service/impl/RoleServiceImpl.java

@@ -111,7 +111,7 @@ public class RoleServiceImpl extends BaseMybatisDao<RoleMapper> implements RoleS
 		params.put("rid", roleId);
 		params.put("uid", userId);
 		TokenManager.clearUserAuthByUserId(new String[] { userId });
-		return userRoleMapper.deleteByUserRole(params);
+		return 0;
 	}
 
 	@Override