瀏覽代碼

添加客户表创建联系人自动生成 登录用户

阿伏兔 4 年之前
父節點
當前提交
cfcb8442ea

+ 5 - 5
ruoyi-admin/src/main/java/com/ruoyi/web/controller/fleet/orderPlan/ftmsorderbillscarsController.java

@@ -52,7 +52,7 @@ public class ftmsorderbillscarsController extends BaseController {
     /**
      * 查询司机状态跟踪列表
      */
-//    @PreAuthorize("@ss.hasPermi('fleet:ftmsorderbillscars:query')")
+    @PreAuthorize("@ss.hasPermi('fleet:vehicleStatus:query')")
     @GetMapping("/query")
     public Map<String, Object> query(Ftmsorderbills ftmsorderbills) {
         Map<String, Object> map = new HashMap<>();
@@ -117,7 +117,7 @@ public class ftmsorderbillscarsController extends BaseController {
     /**
      * 司机操作接单/提箱/装卸货/还卸柜/回单操作  保存
      */
-    @PreAuthorize("@ss.hasPermi('fleet:ftmsorderbillscars:add')")
+    @PreAuthorize("@ss.hasPermi('fleet:ftmsorderbillscars:edit')")
     @Log(title = "车队派车", businessType = BusinessType.INSERT)
     @PostMapping(value = "/driverSave")
     @RepeatSubmit
@@ -137,7 +137,7 @@ public class ftmsorderbillscarsController extends BaseController {
     /**
      * 司机操作接单/提箱/装卸货/还卸柜/回单操作  提交
      */
-    @PreAuthorize("@ss.hasPermi('fleet:ftmsorderbillscars:add')")
+    @PreAuthorize("@ss.hasPermi('fleet:ftmsorderbillscars:edit')")
     @Log(title = "车队派车", businessType = BusinessType.INSERT)
     @PostMapping(value = "/insertDriver")
     @RepeatSubmit
@@ -156,7 +156,7 @@ public class ftmsorderbillscarsController extends BaseController {
     /**
      * 状态跟踪提交  提交
      */
-    @PreAuthorize("@ss.hasPermi('fleet:ftmsorderbillscars:add')")
+    @PreAuthorize("@ss.hasPermi('fleet:ftmsorderbillscars:edit')")
     @Log(title = "车队派车", businessType = BusinessType.INSERT)
     @PostMapping(value = "/driverSubmit")
     @RepeatSubmit
@@ -198,7 +198,7 @@ public class ftmsorderbillscarsController extends BaseController {
     /**
      * 司机操作接单/提箱/装卸货/还卸柜/回单操作  变更
      */
-    @PreAuthorize("@ss.hasPermi('fleet:ftmsorderbillscars:add')")
+    @PreAuthorize("@ss.hasPermi('fleet:ftmsorderbillscars:edit')")
     @Log(title = "车队派车", businessType = BusinessType.INSERT)
     @PostMapping(value = "/operationalChanges")
     @RepeatSubmit

+ 6 - 4
ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysUserController.java

@@ -135,9 +135,10 @@ public class SysUserController extends BaseController {
             return AjaxResult.error("新增用户'" + user.getUserName() + "'失败,登录账号已存在");
         } else if (UserConstants.NOT_UNIQUE.equals(userService.checkPhoneUnique(user))) {
             return AjaxResult.error("新增用户'" + user.getUserName() + "'失败,手机号码已存在");
-        } else if (UserConstants.NOT_UNIQUE.equals(userService.checkEmailUnique(user))) {
-            return AjaxResult.error("新增用户'" + user.getUserName() + "'失败,邮箱账号已存在");
         }
+//        if (UserConstants.NOT_UNIQUE.equals(userService.checkEmailUnique(user))) {
+//            return AjaxResult.error("新增用户'" + user.getUserName() + "'失败,邮箱账号已存在");
+//        }
         user.setCreateBy(SecurityUtils.getUsername());
         user.setPassword(SecurityUtils.encryptPassword(user.getPassword()));
         return toAjax(userService.insertUser(user));
@@ -153,9 +154,10 @@ public class SysUserController extends BaseController {
         userService.checkUserAllowed(user);
         if (UserConstants.NOT_UNIQUE.equals(userService.checkPhoneUnique(user))) {
             return AjaxResult.error("修改用户'" + user.getUserName() + "'失败,手机号码已存在");
-        } else if (UserConstants.NOT_UNIQUE.equals(userService.checkEmailUnique(user))) {
-            return AjaxResult.error("修改用户'" + user.getUserName() + "'失败,邮箱账号已存在");
         }
+//        if (UserConstants.NOT_UNIQUE.equals(userService.checkEmailUnique(user))) {
+//            return AjaxResult.error("修改用户'" + user.getUserName() + "'失败,邮箱账号已存在");
+//        }
         user.setUpdateBy(SecurityUtils.getUsername());
         return toAjax(userService.updateUser(user));
     }

+ 1 - 1
ruoyi-fleet/src/main/java/com/ruoyi/basicData/service/impl/FleetCompanyMsgServiceImpl.java

@@ -163,7 +163,7 @@ public class FleetCompanyMsgServiceImpl implements IFleetCompanyMsgService {
         user.setPassword(SecurityUtils.encryptPassword(tCorps.getfTel()));
         sysUserMapper.insertUser(user);
         // 查询是否存在车队 角色
-        SysRole role = sysRoleMapper.selectRoleByName("外部用户");
+        SysRole role = sysRoleMapper.selectRoleByName("车队");
         if (StringUtils.isNull(role)) {
             TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
             return AjaxResult.error("未找到外部用户角色,请添加角色后再提交");

+ 1 - 1
ruoyi-fleet/src/main/java/com/ruoyi/basicData/service/impl/FleetDriverMsgServiceImpl.java

@@ -170,7 +170,7 @@ public class FleetDriverMsgServiceImpl implements IFleetDriverMsgService {
             }
             // 新增用户与角色管理
             // 查询是否存在车队 角色
-            SysRole role = roleMapper.selectRoleByName("外部用户");
+            SysRole role = roleMapper.selectRoleByName("车队司机");
             if (StringUtils.isNull(role)) {
                 TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                 return AjaxResult.error("未找到司机角色,请创建司机角色后提交");

+ 1 - 1
ruoyi-system/src/main/resources/mapper/system/SysUserMapper.xml

@@ -149,7 +149,7 @@
 		SELECT COUNT(user_id) FROM sys_user where user_name = #{phonenumber} or phonenumber = #{phonenumber}
 	</select>
 
-	<select id="selectUserByPhonenumber" parameterType="String" resultType="com.ruoyi.common.core.domain.entity.SysUser">
+	<select id="selectUserByPhonenumber" parameterType="String" resultMap="SysUserResult">
 		SELECT user_id, dept_id, user_name, nick_name, email, user_type, user_system, sex, phonenumber, avatar, open_id, union_id, session_key, password
 		img_src, related_no, status, del_flag,login_ip, login_date FROM sys_user where phonenumber = #{phonenumber}
 	</select>

+ 26 - 0
ruoyi-warehouse/src/main/java/com/ruoyi/basicData/domain/TCustomerContact.java

@@ -80,6 +80,32 @@ public class TCustomerContact extends BaseEntity {
     @TableLogic
     private String delFlag;
 
+    /**
+     * 关联部门id
+     */
+    private Long deptId;
+
+    /**
+     * 关联用户id
+     */
+    private Long userId;
+
+    public Long getUserId() {
+        return userId;
+    }
+
+    public void setUserId(Long userId) {
+        this.userId = userId;
+    }
+
+    public Long getDeptId() {
+        return deptId;
+    }
+
+    public void setDeptId(Long deptId) {
+        this.deptId = deptId;
+    }
+
     public void settId(Long tId) {
         this.tId = tId;
     }

+ 7 - 0
ruoyi-warehouse/src/main/java/com/ruoyi/basicData/mapper/TCustomerContactMapper.java

@@ -62,4 +62,11 @@ public interface TCustomerContactMapper extends BaseMapper<TCustomerContact> {
     public int deleteTCustomerContactByIds(Long[] tIds);
 
     int deleteCustomerContactByCorps(Long fPid);
+
+    /**
+     *  查询手机号是否存在
+     * @param ftel
+     * @return
+     */
+    public int checkTelUnique(String ftel);
 }

+ 26 - 5
ruoyi-warehouse/src/main/java/com/ruoyi/basicData/service/impl/TCorpsServiceImpl.java

@@ -153,8 +153,11 @@ public class TCorpsServiceImpl implements ITCorpsService {
                 }
             }
             tCorpsMapper.updateTCorps(corps);
-            tCustomerContactMapper.deleteCustomerContactByCorps(fPid);
         }
+        TCustomerContact tCustomerContact = new TCustomerContact();
+        tCustomerContact.setfPid(corps.getfId());
+        List<TCustomerContact> contactList = tCustomerContactMapper.selectTCustomerContactList(tCustomerContact);
+        tCustomerContactMapper.deleteCustomerContactByCorps(fPid);
         if (StringUtils.isNotEmpty(tCustomerContacts) && !"[]".equals(tCustomerContacts)) {
             int line = 0;
             SysDept dept = sysDeptMapper.selectDeptByDeptName("外部用户");
@@ -178,6 +181,10 @@ public class TCorpsServiceImpl implements ITCorpsService {
                     TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                     return AjaxResult.error("联系人第" + line + "行,缺少客户状态");
                 }
+                if (tCustomerContactMapper.checkTelUnique(cc.getfTel()) > 0) {
+                    TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+                    return AjaxResult.error("联系人第" + line + "行,手机号已存在");
+                }
                 if (StringUtils.isNull(cc.gettId())) {
                     if (sysUserMapper.selectUserByUserNameOrTel(cc.getfTel()) > 0) {
                         TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
@@ -210,17 +217,31 @@ public class TCorpsServiceImpl implements ITCorpsService {
                     sysUserRole.setUserId(sysUser.getUserId());
                     list.add(sysUserRole);
                     userRoleMapper.batchUserRole(list);
+                    cc.setUserId(sysUser.getUserId());
                 } else {
-                    SysUser use = sysUserMapper.selectUserByPhonenumber(cc.getfTel());
+                    TCustomerContact contact = new TCustomerContact();
+                    for (TCustomerContact c : contactList) {
+                        if (c.gettId().equals(cc.gettId())) {
+                            if (StringUtils.isNull(c.getUserId())) {
+                                TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
+                                return AjaxResult.error("该客户联系人异常,请刷新后提交");
+                            }
+                            contact.setUserId(c.getUserId());
+                            break;
+                        }
+                    }
+                    SysUser use = sysUserMapper.selectUserById(contact.getUserId());
                     if (StringUtils.isNull(use)) {
                         TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                         return AjaxResult.error("该手机号未找到用户信息,请确认操作用户信息是否被删除");
                     }
-                    use.setDeptId(dept.getDeptId());
-                    use.setStatus(cc.getfStatus());
                     use.setUpdateTime(new Date());
+                    use.setNickName(cc.getfName());
+                    use.setStatus(cc.getfStatus());
+                    use.setDeptId(dept.getDeptId());
+                    use.setPhonenumber(cc.getfTel());
                     use.setUpdateBy(user.getUserName());
-                    sysUserMapper.updateUser(user);
+                    sysUserMapper.updateUser(use);
                 }
                 cc.setfPid(fPid);
                 cc.setfStatus("0");

+ 14 - 1
ruoyi-warehouse/src/main/resources/mapper/basicData/TCustomerContactMapper.xml

@@ -21,10 +21,12 @@
         <result property="updateBy" column="update_by"/>
         <result property="updateTime" column="update_time"/>
         <result property="remark" column="remark"/>
+        <result property="deptId" column="dept_id"/>
+        <result property="userId" column="user_id"/>
     </resultMap>
 
     <sql id="selectTCustomerContactVo">
-        select t_id, f_pid, f_no, f_name, f_ename, f_tel, f_duty, f_email, f_wx, f_status, del_flag, create_by, create_time, update_by, update_time, remark from t_customer_contact
+        select t_id, f_pid, f_no, f_name, f_ename, f_tel, f_duty, f_email, f_wx, dept_id, user_id, f_status, del_flag, create_by, create_time, update_by, update_time, remark from t_customer_contact
     </sql>
 
     <select id="selectTCustomerContactList" parameterType="TCustomerContact" resultMap="TCustomerContactResult">
@@ -37,6 +39,7 @@
             <if test="fTel != null  and fTel != ''">and f_tel = #{fTel}</if>
             <if test="fDuty != null  and fDuty != ''">and f_duty = #{fDuty}</if>
             <if test="fEmail != null  and fEmail != ''">and f_email = #{fEmail}</if>
+            <if test="userId != null  and userId != ''">and user_id = #{userId}</if>
             <if test="fWx != null  and fWx != ''">and f_wx = #{fWx}</if>
             <if test="fStatus != null  and fStatus != ''">and f_status = #{fStatus}</if>
         </where>
@@ -47,6 +50,10 @@
         where t_id = #{tId}
     </select>
 
+    <select id="checkTelUnique" parameterType="string" resultType="int">
+        select count(t_id) from t_customer_contact where f_tel = #{fTel}
+    </select>
+
     <insert id="insertTCustomerContact" parameterType="TCustomerContact" useGeneratedKeys="true" keyProperty="tId">
         insert into t_customer_contact
         <trim prefix="(" suffix=")" suffixOverrides=",">
@@ -65,6 +72,8 @@
             <if test="updateBy != null">update_by,</if>
             <if test="updateTime != null">update_time,</if>
             <if test="remark != null">remark,</if>
+            <if test="deptId != null">dept_id,</if>
+            <if test="userId != null">user_id,</if>
         </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="fPid != null">#{fPid},</if>
@@ -82,6 +91,8 @@
             <if test="updateBy != null">#{updateBy},</if>
             <if test="updateTime != null">#{updateTime},</if>
             <if test="remark != null">#{remark},</if>
+            <if test="deptId != null">#{deptId},</if>
+            <if test="userId != null">#{userId},</if>
         </trim>
     </insert>
 
@@ -103,6 +114,8 @@
             <if test="updateBy != null">update_by = #{updateBy},</if>
             <if test="updateTime != null">update_time = #{updateTime},</if>
             <if test="remark != null">remark = #{remark},</if>
+            <if test="deptId != null">dept_id = #{deptId},</if>
+            <if test="userId != null">user_id = #{userId},</if>
         </trim>
         where t_id = #{tId}
     </update>