浏览代码

Merge remote-tracking branch 'origin/master_liaozeyong'

# Conflicts:
#	docs/new_sql.sql
13660505945 1 月之前
父节点
当前提交
361426f687

+ 30 - 1
docs/new_sql.sql

@@ -46,9 +46,38 @@ ADD COLUMN warehousing_time DATE DEFAULT NULL COMMENT '出入库时间';
 -- 修改产品类型编码为BIGINT
 ALTER TABLE jsh_material_category MODIFY COLUMN serial_no BIGINT;
 
+CREATE TABLE `task_stocktaking` (
+    `id` bigint NOT NULL COMMENT '主键ID',
+    `task_name` varchar(255) DEFAULT NULL COMMENT '任务名称',
+    `creator` bigint DEFAULT NULL COMMENT '负责人',
+    `create_by` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL COMMENT '创建人',
+    `create_time` datetime DEFAULT NULL COMMENT '创建时间',
+    `task_type` varchar(255) DEFAULT NULL COMMENT '任务类型',
+    `depot_id` bigint DEFAULT NULL COMMENT '仓库ID',
+    `number` varchar(255) DEFAULT NULL COMMENT '任务单号',
+    `material_count` int DEFAULT NULL COMMENT '商品数',
+    `task_status` int DEFAULT NULL COMMENT '任务状态',
+    `position_range` varchar(255) DEFAULT NULL COMMENT '库位范围',
+    `delete_flag` tinyint DEFAULT NULL COMMENT '删除标志(0:否,1是)',
+    PRIMARY KEY (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COMMENT='盘点任务表';
 
 ALTER TABLE jsh_depot_head
     ADD COLUMN link_tesco varchar(50) DEFAULT '' COMMENT '集采订单编号',
     ADD COLUMN receiver_name VARCHAR(255) DEFAULT '' COMMENT '收货人',
     ADD COLUMN receiver_phone VARCHAR(20) DEFAULT '' COMMENT '收货人电话',
-    ADD COLUMN receiver_address VARCHAR(255) DEFAULT '' COMMENT '收货地址';
+    ADD COLUMN receiver_address VARCHAR(255) DEFAULT '' COMMENT '收货地址';
+
+CREATE TABLE `task_stocktaking_item` (
+    `id` bigint NOT NULL COMMENT '主键ID',
+    `task_stocktaking_id` bigint DEFAULT NULL COMMENT '任务ID',
+    `material_item_id` bigint DEFAULT NULL COMMENT '商品ID',
+    `creator` bigint DEFAULT NULL COMMENT '操作人',
+    `new_position` varchar(255) DEFAULT NULL COMMENT '新仓位货架',
+    `new_inventory` decimal(24,6) DEFAULT NULL COMMENT '新库存数',
+    `difference_count` int DEFAULT NULL COMMENT '差异数量',
+    `difference_reasion` varchar(255) DEFAULT NULL COMMENT '差异原因',
+    `delete_flag` varchar(1) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT '0' COMMENT '删除标记,0未删除,1删除',
+    `oper_time` datetime DEFAULT NULL COMMENT '操作时间',
+    PRIMARY KEY (`id`)
+) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3 COMMENT='盘点任务关联商品表';

+ 5 - 0
src/main/java/com/jsh/erp/controller/pda/PdaController.java

@@ -90,6 +90,11 @@ public class PdaController extends BaseController {
     @GetMapping("/materialDepotDetail/{type}/{materialId}")
     public TableDataInfo materialDepotDetail(@PathVariable("type") String type, @PathVariable("materialId") Long materialId) {
         startPage();
+        if ("out".equals(type)) {
+            type = "入库";
+        } else {
+            type = "出库";
+        }
         List<PDADepotItemVO> list = depotItemService.materialDepotDetail(type , materialId);
         return getDataTable(list);
     }

+ 53 - 0
src/main/java/com/jsh/erp/controller/stocktaking/StocktakingController.java

@@ -0,0 +1,53 @@
+package com.jsh.erp.controller.stocktaking;
+
+import com.jsh.erp.base.AjaxResult;
+import com.jsh.erp.base.BaseController;
+import com.jsh.erp.base.TableDataInfo;
+import com.jsh.erp.datasource.dto.TaskStocktakingDTO;
+import com.jsh.erp.datasource.entities.TaskStocktaking;
+import com.jsh.erp.datasource.entities.User;
+import com.jsh.erp.datasource.vo.SpinnerVO;
+import com.jsh.erp.service.TaskStocktakingService;
+import com.jsh.erp.service.UserService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.Resource;
+import java.util.List;
+
+@RestController
+@RequestMapping(value = "/stocktaking")
+@Api(tags = {"盘点接口"})
+public class StocktakingController extends BaseController {
+
+    @Resource
+    private TaskStocktakingService taskStocktakingService;
+
+    @Resource
+    private UserService userService;
+
+    @ApiOperation("盘点任务列表")
+    @PostMapping("/list")
+    public TableDataInfo list(){
+        startPage();
+        return getDataTable(taskStocktakingService.list());
+    }
+
+    @ApiOperation("新增盘点任务")
+    @PostMapping("/add")
+    public AjaxResult add(@RequestBody TaskStocktakingDTO taskStocktakingDTO) {
+        taskStocktakingService.add(taskStocktakingDTO);
+        return AjaxResult.success();
+    }
+
+    @ApiOperation("负责人下拉列表")
+    @GetMapping("/creatorSpinnerList")
+    public AjaxResult creatorSpinnerList() {
+        List<SpinnerVO> spinnerVOList = userService.creatorSpinnerList();
+        return AjaxResult.success(spinnerVOList);
+    }
+
+
+
+}

+ 21 - 0
src/main/java/com/jsh/erp/datasource/dto/TaskStocktakingDTO.java

@@ -0,0 +1,21 @@
+package com.jsh.erp.datasource.dto;
+
+import com.jsh.erp.datasource.entities.TaskStocktaking;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.util.Date;
+import java.util.List;
+
+/**
+ * 盘点任务
+ */
+@Data
+@Accessors(chain = true)
+public class TaskStocktakingDTO extends TaskStocktaking {
+
+    @ApiModelProperty("商品扩展ID集合")
+    private List<Long> materialExtendIdList;
+
+}

+ 52 - 0
src/main/java/com/jsh/erp/datasource/entities/TaskStocktaking.java

@@ -0,0 +1,52 @@
+package com.jsh.erp.datasource.entities;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.util.Date;
+
+/**
+ * 盘点任务
+ */
+@Data
+@Accessors(chain = true)
+public class TaskStocktaking {
+
+    @ApiModelProperty("主键ID")
+    private Long id;
+
+    @ApiModelProperty("任务名称")
+    private String taskName;
+
+    @ApiModelProperty("负责人ID")
+    private Long creator;
+
+    @ApiModelProperty("创建人ID")
+    private Long createBy;
+
+    @ApiModelProperty("创建时间")
+    private Date createTime;
+
+    @ApiModelProperty("任务类型 1.全盘,2.抽盘")
+    private int taskType;
+
+    @ApiModelProperty("仓库ID")
+    private Long depotId;
+
+    @ApiModelProperty("任务单号")
+    private String number;
+
+    @ApiModelProperty("商品数")
+    private int materialCount;
+
+    @ApiModelProperty("任务状态 0.未开始,1.进行中,2.已完成,3.已取消")
+    private Integer taskStatus;
+
+    @ApiModelProperty("盘点范围")
+    private String positionRange;
+
+    @ApiModelProperty("删除标记,0.未删除,1.已删除")
+    private boolean deleteFlag;
+
+}

+ 47 - 0
src/main/java/com/jsh/erp/datasource/entities/TaskStocktakingItem.java

@@ -0,0 +1,47 @@
+package com.jsh.erp.datasource.entities;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * 盘点任务明细
+ */
+@Data
+@Accessors(chain = true)
+public class TaskStocktakingItem {
+
+    @ApiModelProperty("主键ID")
+    private Long id;
+
+    @ApiModelProperty("任务ID")
+    private Long taskStocktakingId;
+
+    @ApiModelProperty("商品ID")
+    private Long materialItemId;
+
+    @ApiModelProperty("操作人ID")
+    private Long creator;
+
+    @ApiModelProperty("操作时间")
+    private Date operTime;
+
+    @ApiModelProperty("新仓位货架")
+    private String newPosition;
+
+    @ApiModelProperty("新库存数")
+    private BigDecimal newInventory;
+
+    @ApiModelProperty("差异数量")
+    private Integer differenceCount;
+
+    @ApiModelProperty("差异原因")
+    private String differenceReason;
+
+    @ApiModelProperty("删除标记,0.未删除,1.已删除")
+    private boolean deleteFlag;
+
+}

+ 6 - 0
src/main/java/com/jsh/erp/datasource/mappers/TaskStocktakingItemMapper.java

@@ -0,0 +1,6 @@
+package com.jsh.erp.datasource.mappers;
+
+import com.jsh.erp.datasource.entities.TaskStocktakingItem;
+
+public interface TaskStocktakingItemMapper extends BaseMapperX<TaskStocktakingItem> {
+}

+ 6 - 0
src/main/java/com/jsh/erp/datasource/mappers/TaskStocktakingMapper.java

@@ -0,0 +1,6 @@
+package com.jsh.erp.datasource.mappers;
+
+import com.jsh.erp.datasource.entities.TaskStocktaking;
+
+public interface TaskStocktakingMapper extends BaseMapperX<TaskStocktaking> {
+}

+ 5 - 1
src/main/java/com/jsh/erp/datasource/mappers/UserMapper.java

@@ -3,9 +3,11 @@ package com.jsh.erp.datasource.mappers;
 import com.jsh.erp.datasource.entities.User;
 import com.jsh.erp.datasource.entities.UserExample;
 import java.util.List;
+
+import com.jsh.erp.datasource.vo.SpinnerVO;
 import org.apache.ibatis.annotations.Param;
 
-public interface UserMapper {
+public interface UserMapper extends BaseMapperX<User> {
     long countByExample(UserExample example);
 
     int deleteByExample(UserExample example);
@@ -27,4 +29,6 @@ public interface UserMapper {
     int updateByPrimaryKeySelective(User record);
 
     int updateByPrimaryKey(User record);
+
+    List<SpinnerVO> creatorSpinnerList();
 }

+ 14 - 0
src/main/java/com/jsh/erp/datasource/vo/SpinnerVO.java

@@ -0,0 +1,14 @@
+package com.jsh.erp.datasource.vo;
+
+import lombok.Data;
+import lombok.experimental.Accessors;
+
+@Data
+@Accessors(chain = true)
+public class SpinnerVO {
+
+    private String label;
+
+    private String value;
+
+}

+ 7 - 0
src/main/java/com/jsh/erp/service/TaskStocktakingItemService.java

@@ -0,0 +1,7 @@
+package com.jsh.erp.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.jsh.erp.datasource.entities.TaskStocktakingItem;
+
+public interface TaskStocktakingItemService extends IService<TaskStocktakingItem> {
+}

+ 10 - 0
src/main/java/com/jsh/erp/service/TaskStocktakingService.java

@@ -0,0 +1,10 @@
+package com.jsh.erp.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.jsh.erp.datasource.dto.TaskStocktakingDTO;
+import com.jsh.erp.datasource.entities.TaskStocktaking;
+
+public interface TaskStocktakingService extends IService<TaskStocktaking> {
+
+    boolean add(TaskStocktakingDTO taskStocktakingDTO);
+}

+ 65 - 889
src/main/java/com/jsh/erp/service/UserService.java

@@ -1,925 +1,101 @@
 package com.jsh.erp.service;
 
-import com.jsh.erp.datasource.entities.*;
-import com.jsh.erp.datasource.mappers.TenantMapper;
-import com.jsh.erp.exception.BusinessParamCheckingException;
-import com.jsh.erp.utils.*;
-import org.springframework.util.StringUtils;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
-import com.jsh.erp.constants.BusinessConstants;
-import com.jsh.erp.constants.ExceptionConstants;
-import com.jsh.erp.datasource.mappers.UserMapper;
-import com.jsh.erp.datasource.mappers.UserMapperEx;
+import com.baomidou.mybatisplus.extension.service.IService;
+import com.jsh.erp.datasource.entities.Role;
+import com.jsh.erp.datasource.entities.User;
+import com.jsh.erp.datasource.entities.UserEx;
+import com.jsh.erp.datasource.vo.SpinnerVO;
 import com.jsh.erp.datasource.vo.TreeNodeEx;
-import com.jsh.erp.exception.BusinessRunTimeException;
-import com.jsh.erp.exception.JshException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Value;
-import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
-import org.springframework.web.context.request.RequestContextHolder;
-import org.springframework.web.context.request.ServletRequestAttributes;
 
-import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
-import java.security.NoSuchAlgorithmException;
-import java.util.*;
-
-@Service
-public class UserService {
-    private Logger logger = LoggerFactory.getLogger(UserService.class);
-
-    @Resource
-    private UserMapper userMapper;
-    @Resource
-    private TenantMapper tenantMapper;
-    @Resource
-    private UserMapperEx userMapperEx;
-    @Resource
-    private OrgaUserRelService orgaUserRelService;
-    @Resource
-    private LogService logService;
-    @Resource
-    private UserService userService;
-    @Resource
-    private TenantService tenantService;
-    @Resource
-    private UserBusinessService userBusinessService;
-    @Resource
-    private RoleService roleService;
-    @Resource
-    private FunctionService functionService;
-    @Resource
-    private PlatformConfigService platformConfigService;
-    @Resource
-    private RedisService redisService;
-
-    @Value("${tenant.userNumLimit}")
-    private Integer userNumLimit;
-
-    @Value("${tenant.tryDayLimit}")
-    private Integer tryDayLimit;
-
-    public User getUser(long id)throws Exception {
-        User result=null;
-        try{
-            result=userMapper.selectByPrimaryKey(id);
-        }catch(Exception e){
-            JshException.readFail(logger, e);
-        }
-        return result;
-    }
-
-    public List<User> getUserListByIds(String ids)throws Exception {
-        List<Long> idList = StringUtil.strToLongList(ids);
-        List<User> list = new ArrayList<>();
-        try{
-            UserExample example = new UserExample();
-            example.createCriteria().andIdIn(idList);
-            list = userMapper.selectByExample(example);
-        }catch(Exception e){
-            JshException.readFail(logger, e);
-        }
-        return list;
-    }
-
-    public List<User> getUser(HttpServletRequest request) throws Exception {
-        List<User> list=null;
-        try{
-            //先校验是否登录,然后才能查询用户数据
-            Long userId = this.getUserId(request);
-            if(userId!=null) {
-                UserExample example = new UserExample();
-                example.createCriteria().andStatusEqualTo(BusinessConstants.USER_STATUS_NORMAL).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
-                list = userMapper.selectByExample(example);
-            }
-        }catch(Exception e){
-            JshException.readFail(logger, e);
-        }
-        return list;
-    }
-
-    public List<UserEx> select(String userName, String loginName)throws Exception {
-        List<UserEx> list=null;
-        try {
-            //先校验是否登录,然后才能查询用户数据
-            HttpServletRequest request = ((ServletRequestAttributes) Objects.requireNonNull(RequestContextHolder.getRequestAttributes())).getRequest();
-            Long userId = this.getUserId(request);
-            if(userId!=null) {
-                PageUtils.startPage();
-                list = userMapperEx.selectByConditionUser(userName, loginName);
-                for (UserEx ue : list) {
-                    String userType = "";
-                    if (ue.getId().equals(ue.getTenantId())) {
-                        userType = "租户";
-                    } else if (ue.getTenantId() == null) {
-                        userType = "超管";
-                    } else {
-                        userType = "普通";
-                    }
-                    ue.setUserType(userType);
-                    //是否经理
-                    String leaderFlagStr = "";
-                    if ("1".equals(ue.getLeaderFlag())) {
-                        leaderFlagStr = "是";
-                    } else {
-                        leaderFlagStr = "否";
-                    }
-                    ue.setLeaderFlagStr(leaderFlagStr);
-                }
-            }
-        } catch(Exception e){
-            JshException.readFail(logger, e);
-        }
-        return list;
-    }
-
-    public Long countUser(String userName, String loginName)throws Exception {
-        Long result=null;
-        try{
-            result=userMapperEx.countsByUser(userName, loginName);
-        }catch(Exception e){
-            JshException.readFail(logger, e);
-        }
-        return result;
-    }
+import java.util.List;
+import java.util.Map;
+
+public interface UserService extends IService<User> {
+    User getUser(long id)throws Exception;
+
+    List<SpinnerVO> creatorSpinnerList();
+    List<User> getUserListByIds(String ids)throws Exception;
+
+    List<User> getUser(HttpServletRequest request) throws Exception;
+
+    List<UserEx> select(String userName, String loginName)throws Exception;
+
+    Long countUser(String userName, String loginName)throws Exception;
 
     @Transactional(value = "transactionManager", rollbackFor = Exception.class)
-    public int insertUser(JSONObject obj, HttpServletRequest request)throws Exception {
-        User user = JSONObject.parseObject(obj.toJSONString(), User.class);
-        String password = "123456";
-        //因密码用MD5加密,需要对密码进行转化
-        try {
-            password = Tools.md5Encryp(password);
-            user.setPassword(password);
-        } catch (NoSuchAlgorithmException e) {
-            logger.error(">>>>>>>>>>>>>>转化MD5字符串错误 :" + e.getMessage());
-        }
-        int result=0;
-        try{
-            result=userMapper.insertSelective(user);
-            logService.insertLog("用户",
-                    new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_ADD).append(user.getLoginName()).toString(), request);
-        }catch(Exception e){
-            JshException.writeFail(logger, e);
-        }
-        return result;
-    }
+    int insertUser(JSONObject obj, HttpServletRequest request)throws Exception;
 
     @Transactional(value = "transactionManager", rollbackFor = Exception.class)
-    public int updateUser(JSONObject obj, HttpServletRequest request) throws Exception{
-        User user = JSONObject.parseObject(obj.toJSONString(), User.class);
-        int result=0;
-        try{
-            result=userMapper.updateByPrimaryKeySelective(user);
-            logService.insertLog("用户",
-                    new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(user.getLoginName()).toString(), request);
-        }catch(Exception e){
-            JshException.writeFail(logger, e);
-        }
-        return result;
-    }
+    int updateUser(JSONObject obj, HttpServletRequest request) throws Exception;
 
     @Transactional(value = "transactionManager", rollbackFor = Exception.class)
-    public int updateUserByObj(User user) throws Exception{
-        logService.insertLog("用户",
-                new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(user.getId()).toString(),
-                ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
-        int result=0;
-        try{
-            result=userMapper.updateByPrimaryKeySelective(user);
-        }catch(Exception e){
-            JshException.writeFail(logger, e);
-        }
-        return result;
-    }
+    int updateUserByObj(User user) throws Exception;
 
     @Transactional(value = "transactionManager", rollbackFor = Exception.class)
-    public int resetPwd(String md5Pwd, Long id) throws Exception{
-        int result=0;
-        logService.insertLog("用户",
-                new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(id).toString(),
-                ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
-        User u = getUser(id);
-        String loginName = u.getLoginName();
-        if("admin".equals(loginName)){
-            logger.info("禁止重置超管密码");
-        } else {
-            User user = new User();
-            user.setId(id);
-            user.setPassword(md5Pwd);
-            try{
-                result=userMapper.updateByPrimaryKeySelective(user);
-            }catch(Exception e){
-                JshException.writeFail(logger, e);
-            }
-        }
-        return result;
-    }
+    int resetPwd(String md5Pwd, Long id) throws Exception;
 
     @Transactional(value = "transactionManager", rollbackFor = Exception.class)
-    public int deleteUser(Long id, HttpServletRequest request)throws Exception {
-        return batDeleteUser(id.toString());
-    }
+    int deleteUser(Long id, HttpServletRequest request)throws Exception;
 
     @Transactional(value = "transactionManager", rollbackFor = Exception.class)
-    public int batchDeleteUser(String ids, HttpServletRequest request)throws Exception {
-        return batDeleteUser(ids);
-    }
+    int batchDeleteUser(String ids, HttpServletRequest request)throws Exception;
 
     @Transactional(value = "transactionManager", rollbackFor = Exception.class)
-    public int batDeleteUser(String ids) throws Exception{
-        int result=0;
-        StringBuffer sb = new StringBuffer();
-        sb.append(BusinessConstants.LOG_OPERATION_TYPE_DELETE);
-        List<User> list = getUserListByIds(ids);
-        for(User user: list){
-            if(user.getId().equals(user.getTenantId())) {
-                logger.error("异常码[{}],异常提示[{}],参数,ids:[{}]",
-                        ExceptionConstants.USER_LIMIT_TENANT_DELETE_CODE,ExceptionConstants.USER_LIMIT_TENANT_DELETE_MSG,ids);
-                throw new BusinessRunTimeException(ExceptionConstants.USER_LIMIT_TENANT_DELETE_CODE,
-                        ExceptionConstants.USER_LIMIT_TENANT_DELETE_MSG);
-            }
-            sb.append("[").append(user.getLoginName()).append("]");
-        }
-        logService.insertLog("用户", sb.toString(),
-                ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
-        String[] idsArray =ids.split(",");
-        try{
-            result=userMapperEx.batDeleteOrUpdateUser(idsArray);
-        }catch(Exception e){
-            JshException.writeFail(logger, e);
-        }
-        if(result<1){
-            logger.error("异常码[{}],异常提示[{}],参数,ids:[{}]",
-                    ExceptionConstants.USER_DELETE_FAILED_CODE,ExceptionConstants.USER_DELETE_FAILED_MSG,ids);
-            throw new BusinessRunTimeException(ExceptionConstants.USER_DELETE_FAILED_CODE,
-                    ExceptionConstants.USER_DELETE_FAILED_MSG);
-        }
-        return result;
-    }
-
-    /**
-     * 校验验证码
-     * @param code 验证码
-     * @param uuid 唯一标识
-     * @return 结果
-     */
-    public void validateCaptcha(String code, String uuid) {
-        if(StringUtil.isNotEmpty(code) && StringUtil.isNotEmpty(uuid)) {
-            code = code.trim();
-            uuid = uuid.trim();
-            String verifyKey = BusinessConstants.CAPTCHA_CODE_KEY + uuid;
-            String captcha = redisService.getCacheObject(verifyKey);
-            redisService.deleteObject(verifyKey);
-            if (captcha == null) {
-                logger.error("异常码[{}],异常提示[{}]", ExceptionConstants.USER_JCAPTCHA_EXPIRE_CODE, ExceptionConstants.USER_JCAPTCHA_EXPIRE_MSG);
-                throw new BusinessRunTimeException(ExceptionConstants.USER_JCAPTCHA_EXPIRE_CODE, ExceptionConstants.USER_JCAPTCHA_EXPIRE_MSG);
-            }
-            if (!code.equalsIgnoreCase(captcha)) {
-                logger.error("异常码[{}],异常提示[{}]", ExceptionConstants.USER_JCAPTCHA_ERROR_CODE, ExceptionConstants.USER_JCAPTCHA_ERROR_MSG);
-                throw new BusinessRunTimeException(ExceptionConstants.USER_JCAPTCHA_ERROR_CODE, ExceptionConstants.USER_JCAPTCHA_ERROR_MSG);
-            }
-        } else {
-            logger.error("异常码[{}],异常提示[{}]", ExceptionConstants.USER_JCAPTCHA_EMPTY_CODE, ExceptionConstants.USER_JCAPTCHA_EMPTY_MSG);
-            throw new BusinessRunTimeException(ExceptionConstants.USER_JCAPTCHA_EMPTY_CODE, ExceptionConstants.USER_JCAPTCHA_EMPTY_MSG);
-        }
-    }
-
-    /**
-     * 用户登录
-     * @param loginName
-     * @param password
-     * @param request
-     * @return
-     * @throws Exception
-     */
-    public Map<String, Object> login(String loginName, String password, HttpServletRequest request) throws Exception {
-        Map<String, Object> data = new HashMap<>();
-        String msgTip = "";
-        User user = null;
-        //判断用户是否已经登录过,登录过不再处理
-        Object userId = redisService.getObjectFromSessionByKey(request,"userId");
-        if (userId != null) {
-            logger.info("====用户已经登录过, login 方法调用结束====");
-            msgTip = "user already login";
-        }
-        //获取用户状态
-        int userStatus = -1;
-        try {
-            redisService.deleteObjectBySession(request,"userId");
-            userStatus = validateUser(loginName, password);
-        } catch (Exception e) {
-            logger.error(">>>>>>>>>>>>>用户  " + loginName + " 登录 login 方法 访问服务层异常====", e);
-            msgTip = "access service exception";
-        }
-        String token = UUID.randomUUID().toString().replaceAll("-", "") + "";
-        switch (userStatus) {
-            case ExceptionCodeConstants.UserExceptionCode.USER_NOT_EXIST:
-                msgTip = "user is not exist";
-                break;
-            case ExceptionCodeConstants.UserExceptionCode.USER_PASSWORD_ERROR:
-                msgTip = "user password error";
-                break;
-            case ExceptionCodeConstants.UserExceptionCode.BLACK_USER:
-                msgTip = "user is black";
-                break;
-            case ExceptionCodeConstants.UserExceptionCode.USER_ACCESS_EXCEPTION:
-                msgTip = "access service error";
-                break;
-            case ExceptionCodeConstants.UserExceptionCode.BLACK_TENANT:
-                msgTip = "tenant is black";
-                break;
-            case ExceptionCodeConstants.UserExceptionCode.EXPIRE_TENANT:
-                msgTip = "tenant is expire";
-                break;
-            case ExceptionCodeConstants.UserExceptionCode.USER_CONDITION_FIT:
-                msgTip = "user can login";
-                //验证通过 ,可以登录,放入session,记录登录日志
-                user = getUserByLoginName(loginName);
-                if(user.getTenantId()!=null) {
-                    token = token + "_" + user.getTenantId();
-                }
-                redisService.storageObjectBySession(token,"userId",user.getId());
-                break;
-            default:
-                break;
-        }
-        data.put("msgTip", msgTip);
-        if(user!=null){
-            //校验下密码是不是过于简单
-            boolean pwdSimple = false;
-            if(user.getPassword().equals(Tools.md5Encryp(BusinessConstants.USER_DEFAULT_PASSWORD))) {
-                pwdSimple = true;
-            }
-            user.setPassword(null);
-            redisService.storageObjectBySession(token,"clientIp", Tools.getLocalIp(request));
-            logService.insertLogWithUserId(user.getId(), user.getTenantId(), "用户",
-                    new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_LOGIN).append(user.getLoginName()).toString(),
-                    ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
-            data.put("token", token);
-            data.put("user", user);
-            data.put("pwdSimple", pwdSimple);
-        }
-        return data;
-    }
-
-    public int validateUser(String loginName, String password) throws Exception {
-        /**默认是可以登录的*/
-        List<User> list = null;
-        try {
-            UserExample example = new UserExample();
-            example.createCriteria().andLoginNameEqualTo(loginName).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
-            list = userMapper.selectByExample(example);
-            if (null != list && list.size() == 0) {
-                return ExceptionCodeConstants.UserExceptionCode.USER_NOT_EXIST;
-            } else if(list.size() ==1) {
-                if(list.get(0).getStatus()!=0) {
-                    return ExceptionCodeConstants.UserExceptionCode.BLACK_USER;
-                }
-                Long tenantId = list.get(0).getTenantId();
-                Tenant tenant = tenantService.getTenantByTenantId(tenantId);
-                if(tenant!=null) {
-                    if(tenant.getEnabled()!=null && !tenant.getEnabled()) {
-                        return ExceptionCodeConstants.UserExceptionCode.BLACK_TENANT;
-                    }
-                    if(tenant.getExpireTime()!=null && tenant.getExpireTime().getTime()<System.currentTimeMillis()){
-                        return ExceptionCodeConstants.UserExceptionCode.EXPIRE_TENANT;
-                    }
-                }
-            }
-        } catch (Exception e) {
-            logger.error(">>>>>>>>访问验证用户姓名是否存在后台信息异常", e);
-            return ExceptionCodeConstants.UserExceptionCode.USER_ACCESS_EXCEPTION;
-        }
-        try {
-            UserExample example = new UserExample();
-            example.createCriteria().andLoginNameEqualTo(loginName).andPasswordEqualTo(password)
-                    .andStatusEqualTo(BusinessConstants.USER_STATUS_NORMAL).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
-            list = userMapper.selectByExample(example);
-            if (null != list && list.size() == 0) {
-                return ExceptionCodeConstants.UserExceptionCode.USER_PASSWORD_ERROR;
-            }
-        } catch (Exception e) {
-            logger.error(">>>>>>>>>>访问验证用户密码后台信息异常", e);
-            return ExceptionCodeConstants.UserExceptionCode.USER_ACCESS_EXCEPTION;
-        }
-        return ExceptionCodeConstants.UserExceptionCode.USER_CONDITION_FIT;
-    }
-
-    public User getUserByLoginName(String loginName)throws Exception {
-        UserExample example = new UserExample();
-        example.createCriteria().andLoginNameEqualTo(loginName).andStatusEqualTo(BusinessConstants.USER_STATUS_NORMAL)
-                .andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
-        List<User> list=null;
-        try{
-            list= userMapper.selectByExample(example);
-        }catch(Exception e){
-            JshException.readFail(logger, e);
-        }
-        User user =null;
-        if(list!=null&&list.size()>0){
-            user = list.get(0);
-        }
-        return user;
-    }
-
-    public int checkIsNameExist(Long id, String name)throws Exception {
-        UserExample example = new UserExample();
-        List<Byte> userStatus = new ArrayList<>();
-        userStatus.add(BusinessConstants.USER_STATUS_NORMAL);
-        example.createCriteria().andIdNotEqualTo(id).andLoginNameEqualTo(name).andStatusIn(userStatus)
-                .andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
-        List<User> list=null;
-        try{
-            list= userMapper.selectByExample(example);
-        }catch(Exception e){
-            JshException.readFail(logger, e);
-        }
-        return list==null?0:list.size();
-    }
-    /**
-     * create by: cjl
-     * description:
-     *  获取当前用户信息
-     * create time: 2019/1/24 10:01
-     * @Param:
-     * @return com.jsh.erp.datasource.entities.User
-     */
-    public User getCurrentUser()throws Exception{
-        HttpServletRequest request = ((ServletRequestAttributes) Objects.requireNonNull(RequestContextHolder.getRequestAttributes())).getRequest();
-        Long userId = Long.parseLong(redisService.getObjectFromSessionByKey(request,"userId").toString());
-        return getUser(userId);
-    }
-
-    /**
-     * 根据用户名查询id
-     * @param loginName
-     * @return
-     */
-    public Long getIdByLoginName(String loginName) {
-        Long userId = 0L;
-        UserExample example = new UserExample();
-        example.createCriteria().andLoginNameEqualTo(loginName).andStatusEqualTo(BusinessConstants.USER_STATUS_NORMAL)
-                .andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
-        List<User> list = userMapper.selectByExample(example);
-        if(list!=null) {
-            userId = list.get(0).getId();
-        }
-        return userId;
-    }
+    int batDeleteUser(String ids) throws Exception;
+
+    void validateCaptcha(String code, String uuid);
+
+    Map<String, Object> login(String loginName, String password, HttpServletRequest request) throws Exception;
+
+    int validateUser(String loginName, String password) throws Exception;
+
+    User getUserByLoginName(String loginName)throws Exception;
+
+    int checkIsNameExist(Long id, String name)throws Exception;
+
+    User getCurrentUser()throws Exception;
+
+    Long getIdByLoginName(String loginName);
 
     @Transactional(value = "transactionManager", rollbackFor = Exception.class)
-    public void addUserAndOrgUserRel(UserEx ue, HttpServletRequest request) throws Exception{
-        if(BusinessConstants.DEFAULT_MANAGER.equals(ue.getLoginName())) {
-            throw new BusinessRunTimeException(ExceptionConstants.USER_NAME_LIMIT_USE_CODE,
-                    ExceptionConstants.USER_NAME_LIMIT_USE_MSG);
-        } else {
-            logService.insertLog("用户",
-                    BusinessConstants.LOG_OPERATION_TYPE_ADD,
-                    ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
-            //检查用户名和登录名
-            checkLoginName(ue);
-            //新增用户信息
-            ue= this.addUser(ue);
-            if(ue==null){
-                logger.error("异常码[{}],异常提示[{}],参数,[{}]",
-                        ExceptionConstants.USER_ADD_FAILED_CODE,ExceptionConstants.USER_ADD_FAILED_MSG);
-                throw new BusinessRunTimeException(ExceptionConstants.USER_ADD_FAILED_CODE,
-                        ExceptionConstants.USER_ADD_FAILED_MSG);
-            }
-            //用户id,根据用户名查询id
-            Long userId = getIdByLoginName(ue.getLoginName());
-            if(ue.getRoleId()!=null){
-                JSONObject ubObj = new JSONObject();
-                ubObj.put("type", "UserRole");
-                ubObj.put("keyid", userId);
-                ubObj.put("value", "[" + ue.getRoleId() + "]");
-                userBusinessService.insertUserBusiness(ubObj, request);
-            }
-            if(ue.getOrgaId()==null){
-                //如果没有选择机构,就不建机构和用户的关联关系
-                return;
-            }
-            if(ue.getOrgaId()!=null && "1".equals(ue.getLeaderFlag())){
-                //检查当前机构是否存在经理
-                List<User> checkList = userMapperEx.getListByOrgaId(ue.getId(), ue.getOrgaId());
-                if(checkList.size()>0) {
-                    throw new BusinessRunTimeException(ExceptionConstants.USER_LEADER_IS_EXIST_CODE,
-                            ExceptionConstants.USER_LEADER_IS_EXIST_MSG);
-                }
-            }
-            //新增用户和机构关联关系
-            OrgaUserRel oul=new OrgaUserRel();
-            //机构id
-            oul.setOrgaId(ue.getOrgaId());
-            oul.setUserId(userId);
-            //用户在机构中的排序
-            oul.setUserBlngOrgaDsplSeq(ue.getUserBlngOrgaDsplSeq());
-            oul=orgaUserRelService.addOrgaUserRel(oul);
-            if(oul==null){
-                logger.error("异常码[{}],异常提示[{}],参数,[{}]",
-                        ExceptionConstants.ORGA_USER_REL_ADD_FAILED_CODE,ExceptionConstants.ORGA_USER_REL_ADD_FAILED_MSG);
-                throw new BusinessRunTimeException(ExceptionConstants.ORGA_USER_REL_ADD_FAILED_CODE,
-                        ExceptionConstants.ORGA_USER_REL_ADD_FAILED_MSG);
-            }
-        }
-    }
+    void addUserAndOrgUserRel(UserEx ue, HttpServletRequest request) throws Exception;
+
     @Transactional(value = "transactionManager", rollbackFor = Exception.class)
-    public UserEx addUser(UserEx ue) throws Exception{
-        /**
-         * 新增用户默认设置
-         * 1、密码默认123456
-         * 2是否系统自带默认为非系统自带
-         * 3是否管理者默认为员工
-         * 4默认用户状态为正常
-         * */
-        ue.setPassword(Tools.md5Encryp(BusinessConstants.USER_DEFAULT_PASSWORD));
-        ue.setIsystem(BusinessConstants.USER_NOT_SYSTEM);
-        if(ue.getIsmanager()==null){
-            ue.setIsmanager(BusinessConstants.USER_NOT_MANAGER);
-        }
-        ue.setStatus(BusinessConstants.USER_STATUS_NORMAL);
-        int result=0;
-        try{
-            result= userMapper.insertSelective(ue);
-        }catch(Exception e){
-            JshException.writeFail(logger, e);
-        }
-        if(result>0){
-            return ue;
-        }
-        return null;
-    }
+    UserEx addUser(UserEx ue) throws Exception;
 
     @Transactional(value = "transactionManager", rollbackFor = Exception.class)
-    public void registerUser(UserEx ue, Integer manageRoleId, HttpServletRequest request) throws Exception{
-        /**
-         * 多次创建事务,事物之间无法协同,应该在入口处创建一个事务以做协调
-         */
-        if(BusinessConstants.DEFAULT_MANAGER.equals(ue.getLoginName())) {
-            throw new BusinessRunTimeException(ExceptionConstants.USER_NAME_LIMIT_USE_CODE,
-                    ExceptionConstants.USER_NAME_LIMIT_USE_MSG);
-        } else {
-            ue.setPassword(ue.getPassword());
-            ue.setIsystem(BusinessConstants.USER_NOT_SYSTEM);
-            if (ue.getIsmanager() == null) {
-                ue.setIsmanager(BusinessConstants.USER_NOT_MANAGER);
-            }
-            ue.setStatus(BusinessConstants.USER_STATUS_NORMAL);
-            try{
-                userMapper.insertSelective(ue);
-                Long userId = getIdByLoginName(ue.getLoginName());
-                ue.setId(userId);
-            }catch(Exception e){
-                JshException.writeFail(logger, e);
-            }
-            //更新租户id
-            User user = new User();
-            user.setId(ue.getId());
-            user.setTenantId(ue.getId());
-            userService.updateUserTenant(user);
-            //新增用户与角色的关系
-            JSONObject ubObj = new JSONObject();
-            ubObj.put("type", "UserRole");
-            ubObj.put("keyid", ue.getId());
-            JSONArray ubArr = new JSONArray();
-            ubArr.add(manageRoleId);
-            ubObj.put("value", ubArr.toString());
-            ubObj.put("tenantId", ue.getId());
-            userBusinessService.insertUserBusiness(ubObj, null);
-            //创建租户信息
-            JSONObject tenantObj = new JSONObject();
-            tenantObj.put("tenantId", ue.getId());
-            tenantObj.put("loginName",ue.getLoginName());
-            tenantObj.put("userNumLimit", ue.getUserNumLimit());
-            tenantObj.put("expireTime", ue.getExpireTime());
-            tenantObj.put("remark", ue.getRemark());
-            Tenant tenant = JSONObject.parseObject(tenantObj.toJSONString(), Tenant.class);
-            tenant.setCreateTime(new Date());
-            if(tenant.getUserNumLimit()==null) {
-                tenant.setUserNumLimit(userNumLimit); //默认用户限制数量
-            }
-            if(tenant.getExpireTime()==null) {
-                tenant.setExpireTime(Tools.addDays(new Date(), tryDayLimit)); //租户允许试用的天数
-            }
-            tenantMapper.insertSelective(tenant);
-            logger.info("===============创建租户信息完成===============");
-        }
-    }
+    void registerUser(UserEx ue, Integer manageRoleId, HttpServletRequest request) throws Exception;
 
     @Transactional(value = "transactionManager", rollbackFor = Exception.class)
-    public void updateUserTenant(User user) throws Exception{
-        UserExample example = new UserExample();
-        example.createCriteria().andIdEqualTo(user.getId());
-        try{
-            userMapper.updateByPrimaryKeySelective(user);
-        }catch(Exception e){
-            JshException.writeFail(logger, e);
-        }
-    }
+    void updateUserTenant(User user) throws Exception;
 
     @Transactional(value = "transactionManager", rollbackFor = Exception.class)
-    public void updateUserAndOrgUserRel(UserEx ue, HttpServletRequest request) throws Exception{
-        if(BusinessConstants.DEFAULT_MANAGER.equals(ue.getLoginName())) {
-            throw new BusinessRunTimeException(ExceptionConstants.USER_NAME_LIMIT_USE_CODE,
-                    ExceptionConstants.USER_NAME_LIMIT_USE_MSG);
-        } else {
-            logService.insertLog("用户",
-                    new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(ue.getId()).toString(),
-                    ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
-            //检查用户名和登录名
-            checkLoginName(ue);
-            //更新用户信息
-            ue = this.updateUser(ue);
-            if (ue == null) {
-                logger.error("异常码[{}],异常提示[{}],参数,[{}]",
-                        ExceptionConstants.USER_EDIT_FAILED_CODE, ExceptionConstants.USER_EDIT_FAILED_MSG);
-                throw new BusinessRunTimeException(ExceptionConstants.USER_EDIT_FAILED_CODE,
-                        ExceptionConstants.USER_EDIT_FAILED_MSG);
-            }
-            if(ue.getRoleId()!=null){
-                JSONObject ubObj = new JSONObject();
-                ubObj.put("type", "UserRole");
-                ubObj.put("keyid", ue.getId());
-                ubObj.put("value", "[" + ue.getRoleId() + "]");
-                Long ubId = userBusinessService.checkIsValueExist("UserRole", ue.getId().toString());
-                if(ubId!=null) {
-                    ubObj.put("id", ubId);
-                    userBusinessService.updateUserBusiness(ubObj, request);
-                } else {
-                    userBusinessService.insertUserBusiness(ubObj, request);
-                }
-            }
-            if (ue.getOrgaId() == null) {
-                //如果没有选择机构,就不建机构和用户的关联关系
-                return;
-            }
-            if(ue.getOrgaId()!=null && "1".equals(ue.getLeaderFlag())){
-                //检查当前机构是否存在经理
-                List<User> checkList = userMapperEx.getListByOrgaId(ue.getId(), ue.getOrgaId());
-                if(checkList.size()>0) {
-                    throw new BusinessRunTimeException(ExceptionConstants.USER_LEADER_IS_EXIST_CODE,
-                            ExceptionConstants.USER_LEADER_IS_EXIST_MSG);
-                }
-            }
-            //更新用户和机构关联关系
-            OrgaUserRel oul = new OrgaUserRel();
-            //机构和用户关联关系id
-            oul.setId(ue.getOrgaUserRelId());
-            //机构id
-            oul.setOrgaId(ue.getOrgaId());
-            //用户id
-            oul.setUserId(ue.getId());
-            //用户在机构中的排序
-            oul.setUserBlngOrgaDsplSeq(ue.getUserBlngOrgaDsplSeq());
-            if (oul.getId() != null) {
-                //已存在机构和用户的关联关系,更新
-                oul = orgaUserRelService.updateOrgaUserRel(oul);
-            } else {
-                //不存在机构和用户的关联关系,新建
-                oul = orgaUserRelService.addOrgaUserRel(oul);
-            }
-            if (oul == null) {
-                logger.error("异常码[{}],异常提示[{}],参数,[{}]",
-                        ExceptionConstants.ORGA_USER_REL_EDIT_FAILED_CODE, ExceptionConstants.ORGA_USER_REL_EDIT_FAILED_MSG);
-                throw new BusinessRunTimeException(ExceptionConstants.ORGA_USER_REL_EDIT_FAILED_CODE,
-                        ExceptionConstants.ORGA_USER_REL_EDIT_FAILED_MSG);
-            }
-        }
-    }
+    void updateUserAndOrgUserRel(UserEx ue, HttpServletRequest request) throws Exception;
+
     @Transactional(value = "transactionManager", rollbackFor = Exception.class)
-    public UserEx updateUser(UserEx ue)throws Exception{
-        int result =0;
-        try{
-            result=userMapper.updateByPrimaryKeySelective(ue);
-        }catch(Exception e){
-            JshException.writeFail(logger, e);
-        }
-        if(result>0){
-            return ue;
-        }
-        return null;
-    }
-    /**
-     *  检查登录名不能重复
-     * create time: 2019/3/12 11:36
-     * @Param: userEx
-     * @return void
-     */
-    public void checkLoginName(UserEx userEx)throws Exception{
-        List<User> list=null;
-        if(userEx==null){
-            return;
-        }
-        Long userId=userEx.getId();
-        //检查登录名
-        if(!StringUtils.isEmpty(userEx.getLoginName())){
-            String loginName=userEx.getLoginName();
-            list=this.getUserListByloginName(loginName);
-            if(list!=null&&list.size()>0){
-                if(list.size()>1){
-                    //超过一条数据存在,该登录名已存在
-                    logger.error("异常码[{}],异常提示[{}],参数,loginName:[{}]",
-                            ExceptionConstants.USER_LOGIN_NAME_ALREADY_EXISTS_CODE,ExceptionConstants.USER_LOGIN_NAME_ALREADY_EXISTS_MSG,loginName);
-                    throw new BusinessRunTimeException(ExceptionConstants.USER_LOGIN_NAME_ALREADY_EXISTS_CODE,
-                            ExceptionConstants.USER_LOGIN_NAME_ALREADY_EXISTS_MSG);
-                }
-                //一条数据,新增时抛出异常,修改时和当前的id不同时抛出异常
-                if(list.size()==1){
-                    if(userId==null||(userId!=null&&!userId.equals(list.get(0).getId()))){
-                        logger.error("异常码[{}],异常提示[{}],参数,loginName:[{}]",
-                                ExceptionConstants.USER_LOGIN_NAME_ALREADY_EXISTS_CODE,ExceptionConstants.USER_LOGIN_NAME_ALREADY_EXISTS_MSG,loginName);
-                        throw new BusinessRunTimeException(ExceptionConstants.USER_LOGIN_NAME_ALREADY_EXISTS_CODE,
-                                ExceptionConstants.USER_LOGIN_NAME_ALREADY_EXISTS_MSG);
-                    }
-                }
-            }
-        }
-    }
-    /**
-     * 通过登录名获取用户列表
-     * */
-    public List<User> getUserListByloginName(String loginName){
-        List<User> list =null;
-        try{
-            list=userMapperEx.getUserListByUserNameOrLoginName(null,loginName);
-        }catch(Exception e){
-            JshException.readFail(logger, e);
-        }
-        return list;
-    }
-
-    public List<TreeNodeEx> getOrganizationUserTree()throws Exception {
-        List<TreeNodeEx> list =null;
-        try{
-            list=userMapperEx.getNodeTree();
-        }catch(Exception e){
-            JshException.readFail(logger, e);
-        }
-        return list;
-    }
-
-    /**
-     * 根据用户id查询角色信息
-     * @param userId
-     * @return
-     */
+    UserEx updateUser(UserEx ue)throws Exception;
+
+    void checkLoginName(UserEx userEx)throws Exception;
+
+    List<User> getUserListByloginName(String loginName);
+
+    List<TreeNodeEx> getOrganizationUserTree()throws Exception;
+
     @Transactional(value = "transactionManager", rollbackFor = Exception.class)
-    public Role getRoleTypeByUserId(long userId) throws Exception {
-        Role role = new Role();
-        List<UserBusiness> list = userBusinessService.getBasicData(String.valueOf(userId), "UserRole");
-        UserBusiness ub = null;
-        if(list.size() > 0) {
-            ub = list.get(0);
-            String values = ub.getValue();
-            String roleId = null;
-            if(values!=null) {
-                values = values.replaceAll("\\[\\]",",").replace("[","").replace("]","");
-            }
-            String [] valueArray=values.split(",");
-            if(valueArray.length>0) {
-                roleId = valueArray[0];
-            }
-            role = roleService.getRoleWithoutTenant(Long.parseLong(roleId));
-        }
-        return role;
-    }
-
-    /**
-     * 获取用户id
-     * @param request
-     * @return
-     */
-    public Long getUserId(HttpServletRequest request) throws Exception{
-        Object userIdObj = redisService.getObjectFromSessionByKey(request,"userId");
-        Long userId = null;
-        if(userIdObj != null) {
-            userId = Long.parseLong(userIdObj.toString());
-        }
-        return userId;
-    }
-
-    /**
-     * 用户的按钮权限
-     * @param userId
-     * @return
-     * @throws Exception
-     */
-    public JSONArray getBtnStrArrById(Long userId) throws Exception {
-        JSONArray btnStrArr = new JSONArray();
-        List<UserBusiness> userRoleList = userBusinessService.getBasicData(userId.toString(), "UserRole");
-        if(userRoleList!=null && userRoleList.size()>0) {
-            String roleValue = userRoleList.get(0).getValue();
-            if(StringUtil.isNotEmpty(roleValue) && roleValue.indexOf("[")>-1 && roleValue.indexOf("]")>-1){
-                roleValue = roleValue.replace("[", "").replace("]", ""); //角色id-单个
-                List<UserBusiness> roleFunctionsList = userBusinessService.getBasicData(roleValue, "RoleFunctions");
-                if(roleFunctionsList!=null && roleFunctionsList.size()>0) {
-                    String btnStr = roleFunctionsList.get(0).getBtnStr();
-                    if(StringUtil.isNotEmpty(btnStr)){
-                        btnStrArr = JSONArray.parseArray(btnStr);
-                    }
-                }
-            }
-        }
-        //将数组中的funId转为url
-        JSONArray btnStrWithUrlArr = new JSONArray();
-        if(btnStrArr.size()>0) {
-            List<Function> functionList = functionService.getFunction();
-            Map<Long, String> functionMap = new HashMap<>();
-            for (Function function: functionList) {
-                functionMap.put(function.getId(), function.getUrl());
-            }
-            for (Object obj : btnStrArr) {
-                JSONObject btnStrObj = JSONObject.parseObject(obj.toString());
-                Long funId = btnStrObj.getLong("funId");
-                JSONObject btnStrWithUrlObj = new JSONObject();
-                btnStrWithUrlObj.put("url", functionMap.get(funId));
-                btnStrWithUrlObj.put("btnStr", btnStrObj.getString("btnStr"));
-                btnStrWithUrlArr.add(btnStrWithUrlObj);
-            }
-        }
-        return btnStrWithUrlArr;
-    }
+    Role getRoleTypeByUserId(long userId) throws Exception;
+
+    Long getUserId(HttpServletRequest request) throws Exception;
+
+    JSONArray getBtnStrArrById(Long userId) throws Exception;
 
     @Transactional(value = "transactionManager", rollbackFor = Exception.class)
-    public int batchSetStatus(Byte status, String ids, HttpServletRequest request)throws Exception {
-        int result=0;
-        List<User> list = getUserListByIds(ids);
-        //选中的用户的数量
-        int selectUserSize = list.size();
-        //查询启用状态的用户的数量
-        int enableUserSize = getUser(request).size();
-        User userInfo = userService.getCurrentUser();
-        Tenant tenant = tenantService.getTenantByTenantId(userInfo.getTenantId());
-        if(tenant!=null) {
-            if (selectUserSize + enableUserSize > tenant.getUserNumLimit() && status == 0) {
-                throw new BusinessParamCheckingException(ExceptionConstants.USER_ENABLE_OVER_LIMIT_FAILED_CODE,
-                        ExceptionConstants.USER_ENABLE_OVER_LIMIT_FAILED_MSG);
-            }
-        }
-        StringBuilder userStr = new StringBuilder();
-        List<Long> idList = new ArrayList<>();
-        for(User user: list) {
-            if(user.getId().equals(user.getTenantId())) {
-                //租户不能进行禁用
-            } else {
-                idList.add(user.getId());
-                userStr.append(user.getLoginName()).append(" ");
-            }
-        }
-        String statusStr ="";
-        if(status == 0) {
-            statusStr ="批量启用";
-        } else if(status == 2) {
-            statusStr ="批量禁用";
-        }
-        if(idList.size()>0) {
-            User user = new User();
-            user.setStatus(status);
-            UserExample example = new UserExample();
-            example.createCriteria().andIdIn(idList);
-            result = userMapper.updateByExampleSelective(user, example);
-            logService.insertLog("用户",
-                    new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(userStr).append("-").append(statusStr).toString(),
-                    ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
-        } else {
-            result = 1;
-        }
-        return result;
-    }
-
-    public User getUserByWeixinCode(String weixinCode) throws Exception {
-        String weixinUrl = platformConfigService.getPlatformConfigByKey("weixinUrl").getPlatformValue();
-        String weixinAppid = platformConfigService.getPlatformConfigByKey("weixinAppid").getPlatformValue();
-        String weixinSecret = platformConfigService.getPlatformConfigByKey("weixinSecret").getPlatformValue();
-        String url = weixinUrl + "?appid=" + weixinAppid + "&secret=" + weixinSecret + "&js_code=" + weixinCode
-                + "&grant_type=authorization_code";
-        JSONObject jsonObject = HttpClient.httpGet(url);
-        if(jsonObject!=null) {
-            String weixinOpenId = jsonObject.getString("openid");
-            if(StringUtil.isNotEmpty(weixinOpenId)) {
-                return userMapperEx.getUserByWeixinOpenId(weixinOpenId);
-            }
-        }
-        return null;
-    }
-
-    public int weixinBind(String loginName, String password, String weixinCode) throws Exception {
-        String weixinUrl = platformConfigService.getPlatformConfigByKey("weixinUrl").getPlatformValue();
-        String weixinAppid = platformConfigService.getPlatformConfigByKey("weixinAppid").getPlatformValue();
-        String weixinSecret = platformConfigService.getPlatformConfigByKey("weixinSecret").getPlatformValue();
-        String url = weixinUrl + "?appid=" + weixinAppid + "&secret=" + weixinSecret + "&js_code=" + weixinCode
-                + "&grant_type=authorization_code";
-        JSONObject jsonObject = HttpClient.httpGet(url);
-        if(jsonObject!=null) {
-            String weixinOpenId = jsonObject.getString("openid");
-            if(StringUtil.isNotEmpty(weixinOpenId)) {
-                return userMapperEx.updateUserWithWeixinOpenId(loginName, password, weixinOpenId);
-            }
-        }
-        return 0;
-    }
+    int batchSetStatus(Byte status, String ids, HttpServletRequest request)throws Exception;
+
+    User getUserByWeixinCode(String weixinCode) throws Exception;
+
+    int weixinBind(String loginName, String password, String weixinCode) throws Exception;
 }

+ 11 - 0
src/main/java/com/jsh/erp/service/impl/TaskStocktakingItemServiceImpl.java

@@ -0,0 +1,11 @@
+package com.jsh.erp.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.jsh.erp.datasource.entities.TaskStocktakingItem;
+import com.jsh.erp.datasource.mappers.TaskStocktakingItemMapper;
+import com.jsh.erp.service.TaskStocktakingItemService;
+import org.springframework.stereotype.Service;
+
+@Service
+public class TaskStocktakingItemServiceImpl extends ServiceImpl<TaskStocktakingItemMapper, TaskStocktakingItem> implements TaskStocktakingItemService {
+}

+ 75 - 0
src/main/java/com/jsh/erp/service/impl/TaskStocktakingServiceImpl.java

@@ -0,0 +1,75 @@
+package com.jsh.erp.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.jsh.erp.datasource.dto.TaskStocktakingDTO;
+import com.jsh.erp.datasource.entities.MaterialExtend;
+import com.jsh.erp.datasource.entities.TaskStocktaking;
+import com.jsh.erp.datasource.mappers.MaterialExtendMapper;
+import com.jsh.erp.datasource.mappers.TaskStocktakingMapper;
+import com.jsh.erp.service.TaskStocktakingService;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.stream.Collectors;
+
+@Service
+@RequiredArgsConstructor
+@Slf4j
+public class TaskStocktakingServiceImpl extends ServiceImpl<TaskStocktakingMapper, TaskStocktaking> implements TaskStocktakingService {
+
+
+    private final MaterialExtendMapper materialExtendMapper;
+
+    @Override
+    public boolean add(TaskStocktakingDTO taskStocktakingDTO) {
+        //商品库位范围处理
+        List<String> collect;
+        if (taskStocktakingDTO.getTaskType() == 1) {
+            collect = materialExtendMapper.selectList(new LambdaQueryWrapper<MaterialExtend>().ne(MaterialExtend::getInventory, BigDecimal.ZERO)).stream().map(MaterialExtend::getPosition).collect(Collectors.toList());
+        } else {
+            collect = materialExtendMapper.selectList(new LambdaQueryWrapper<MaterialExtend>().in(MaterialExtend::getId, taskStocktakingDTO.getMaterialExtendIdList())).stream().map(MaterialExtend::getPosition).collect(Collectors.toList());
+        }
+        String positionRange = extractRangePair(collect);
+        this.save(taskStocktakingDTO);
+        
+
+        return false;
+    }
+
+    /**
+     * 计算库位范围
+     * @param data 库位集合
+     * @return
+     */
+    public static String extractRangePair(List<String> data) {
+        // 用于存储提取的前两部分
+        List<String> rangeParts = new ArrayList<>();
+
+        for (String item : data) {
+            // 提取前两部分(假设格式固定,以 "-" 分割,取前两部分)
+            String[] parts = item.split("-");
+            if (parts.length >= 2) {
+                String rangePart = parts[0] + "-" + parts[1];
+                rangeParts.add(rangePart); // 添加到列表
+            }
+        }
+
+        // 如果范围为空,直接返回空字符串
+        if (rangeParts.isEmpty()) {
+            return "";
+        }
+
+        // 找到最小和最大范围
+        String minRange = Collections.min(rangeParts); // 字典序最小
+        String maxRange = Collections.max(rangeParts); // 字典序最大
+
+        // 返回范围对
+        return minRange + "——" + maxRange;
+    }
+}

+ 958 - 0
src/main/java/com/jsh/erp/service/impl/UserServiceImpl.java

@@ -0,0 +1,958 @@
+package com.jsh.erp.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.jsh.erp.datasource.entities.*;
+import com.jsh.erp.datasource.mappers.TenantMapper;
+import com.jsh.erp.datasource.vo.SpinnerVO;
+import com.jsh.erp.exception.BusinessParamCheckingException;
+import com.jsh.erp.service.*;
+import com.jsh.erp.utils.*;
+import org.springframework.util.StringUtils;
+import com.alibaba.fastjson.JSONArray;
+import com.alibaba.fastjson.JSONObject;
+import com.jsh.erp.constants.BusinessConstants;
+import com.jsh.erp.constants.ExceptionConstants;
+import com.jsh.erp.datasource.mappers.UserMapper;
+import com.jsh.erp.datasource.mappers.UserMapperEx;
+import com.jsh.erp.datasource.vo.TreeNodeEx;
+import com.jsh.erp.exception.BusinessRunTimeException;
+import com.jsh.erp.exception.JshException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.web.context.request.RequestContextHolder;
+import org.springframework.web.context.request.ServletRequestAttributes;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+import java.security.NoSuchAlgorithmException;
+import java.util.*;
+
+@Service
+public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements UserService {
+    private Logger logger = LoggerFactory.getLogger(UserService.class);
+
+    @Resource
+    private UserMapper userMapper;
+    @Resource
+    private TenantMapper tenantMapper;
+    @Resource
+    private UserMapperEx userMapperEx;
+    @Resource
+    private OrgaUserRelService orgaUserRelService;
+    @Resource
+    private LogService logService;
+    @Resource
+    private UserService userService;
+    @Resource
+    private TenantService tenantService;
+    @Resource
+    private UserBusinessService userBusinessService;
+    @Resource
+    private RoleService roleService;
+    @Resource
+    private FunctionService functionService;
+    @Resource
+    private PlatformConfigService platformConfigService;
+    @Resource
+    private RedisService redisService;
+
+    @Value("${tenant.userNumLimit}")
+    private Integer userNumLimit;
+
+    @Value("${tenant.tryDayLimit}")
+    private Integer tryDayLimit;
+
+    @Override
+    public User getUser(long id)throws Exception {
+        User result=null;
+        try{
+            result=userMapper.selectByPrimaryKey(id);
+        }catch(Exception e){
+            JshException.readFail(logger, e);
+        }
+        return result;
+    }
+
+    @Override
+    public List<SpinnerVO> creatorSpinnerList() {
+        return userMapper.creatorSpinnerList();
+    }
+
+    @Override
+    public List<User> getUserListByIds(String ids)throws Exception {
+        List<Long> idList = StringUtil.strToLongList(ids);
+        List<User> list = new ArrayList<>();
+        try{
+            UserExample example = new UserExample();
+            example.createCriteria().andIdIn(idList);
+            list = userMapper.selectByExample(example);
+        }catch(Exception e){
+            JshException.readFail(logger, e);
+        }
+        return list;
+    }
+
+    @Override
+    public List<User> getUser(HttpServletRequest request) throws Exception {
+        List<User> list=null;
+        try{
+            //先校验是否登录,然后才能查询用户数据
+            Long userId = this.getUserId(request);
+            if(userId!=null) {
+                UserExample example = new UserExample();
+                example.createCriteria().andStatusEqualTo(BusinessConstants.USER_STATUS_NORMAL).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
+                list = userMapper.selectByExample(example);
+            }
+        }catch(Exception e){
+            JshException.readFail(logger, e);
+        }
+        return list;
+    }
+
+    @Override
+    public List<UserEx> select(String userName, String loginName)throws Exception {
+        List<UserEx> list=null;
+        try {
+            //先校验是否登录,然后才能查询用户数据
+            HttpServletRequest request = ((ServletRequestAttributes) Objects.requireNonNull(RequestContextHolder.getRequestAttributes())).getRequest();
+            Long userId = this.getUserId(request);
+            if(userId!=null) {
+                PageUtils.startPage();
+                list = userMapperEx.selectByConditionUser(userName, loginName);
+                for (UserEx ue : list) {
+                    String userType = "";
+                    if (ue.getId().equals(ue.getTenantId())) {
+                        userType = "租户";
+                    } else if (ue.getTenantId() == null) {
+                        userType = "超管";
+                    } else {
+                        userType = "普通";
+                    }
+                    ue.setUserType(userType);
+                    //是否经理
+                    String leaderFlagStr = "";
+                    if ("1".equals(ue.getLeaderFlag())) {
+                        leaderFlagStr = "是";
+                    } else {
+                        leaderFlagStr = "否";
+                    }
+                    ue.setLeaderFlagStr(leaderFlagStr);
+                }
+            }
+        } catch(Exception e){
+            JshException.readFail(logger, e);
+        }
+        return list;
+    }
+
+    @Override
+    public Long countUser(String userName, String loginName)throws Exception {
+        Long result=null;
+        try{
+            result=userMapperEx.countsByUser(userName, loginName);
+        }catch(Exception e){
+            JshException.readFail(logger, e);
+        }
+        return result;
+    }
+
+    @Override
+    @Transactional(value = "transactionManager", rollbackFor = Exception.class)
+    public int insertUser(JSONObject obj, HttpServletRequest request)throws Exception {
+        User user = JSONObject.parseObject(obj.toJSONString(), User.class);
+        String password = "123456";
+        //因密码用MD5加密,需要对密码进行转化
+        try {
+            password = Tools.md5Encryp(password);
+            user.setPassword(password);
+        } catch (NoSuchAlgorithmException e) {
+            logger.error(">>>>>>>>>>>>>>转化MD5字符串错误 :" + e.getMessage());
+        }
+        int result=0;
+        try{
+            result=userMapper.insertSelective(user);
+            logService.insertLog("用户",
+                    new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_ADD).append(user.getLoginName()).toString(), request);
+        }catch(Exception e){
+            JshException.writeFail(logger, e);
+        }
+        return result;
+    }
+
+    @Override
+    @Transactional(value = "transactionManager", rollbackFor = Exception.class)
+    public int updateUser(JSONObject obj, HttpServletRequest request) throws Exception{
+        User user = JSONObject.parseObject(obj.toJSONString(), User.class);
+        int result=0;
+        try{
+            result=userMapper.updateByPrimaryKeySelective(user);
+            logService.insertLog("用户",
+                    new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(user.getLoginName()).toString(), request);
+        }catch(Exception e){
+            JshException.writeFail(logger, e);
+        }
+        return result;
+    }
+
+    @Override
+    @Transactional(value = "transactionManager", rollbackFor = Exception.class)
+    public int updateUserByObj(User user) throws Exception{
+        logService.insertLog("用户",
+                new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(user.getId()).toString(),
+                ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
+        int result=0;
+        try{
+            result=userMapper.updateByPrimaryKeySelective(user);
+        }catch(Exception e){
+            JshException.writeFail(logger, e);
+        }
+        return result;
+    }
+
+    @Override
+    @Transactional(value = "transactionManager", rollbackFor = Exception.class)
+    public int resetPwd(String md5Pwd, Long id) throws Exception{
+        int result=0;
+        logService.insertLog("用户",
+                new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(id).toString(),
+                ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
+        User u = getUser(id);
+        String loginName = u.getLoginName();
+        if("admin".equals(loginName)){
+            logger.info("禁止重置超管密码");
+        } else {
+            User user = new User();
+            user.setId(id);
+            user.setPassword(md5Pwd);
+            try{
+                result=userMapper.updateByPrimaryKeySelective(user);
+            }catch(Exception e){
+                JshException.writeFail(logger, e);
+            }
+        }
+        return result;
+    }
+
+    @Override
+    @Transactional(value = "transactionManager", rollbackFor = Exception.class)
+    public int deleteUser(Long id, HttpServletRequest request)throws Exception {
+        return batDeleteUser(id.toString());
+    }
+
+    @Override
+    @Transactional(value = "transactionManager", rollbackFor = Exception.class)
+    public int batchDeleteUser(String ids, HttpServletRequest request)throws Exception {
+        return batDeleteUser(ids);
+    }
+
+    @Override
+    @Transactional(value = "transactionManager", rollbackFor = Exception.class)
+    public int batDeleteUser(String ids) throws Exception{
+        int result=0;
+        StringBuffer sb = new StringBuffer();
+        sb.append(BusinessConstants.LOG_OPERATION_TYPE_DELETE);
+        List<User> list = getUserListByIds(ids);
+        for(User user: list){
+            if(user.getId().equals(user.getTenantId())) {
+                logger.error("异常码[{}],异常提示[{}],参数,ids:[{}]",
+                        ExceptionConstants.USER_LIMIT_TENANT_DELETE_CODE,ExceptionConstants.USER_LIMIT_TENANT_DELETE_MSG,ids);
+                throw new BusinessRunTimeException(ExceptionConstants.USER_LIMIT_TENANT_DELETE_CODE,
+                        ExceptionConstants.USER_LIMIT_TENANT_DELETE_MSG);
+            }
+            sb.append("[").append(user.getLoginName()).append("]");
+        }
+        logService.insertLog("用户", sb.toString(),
+                ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
+        String[] idsArray =ids.split(",");
+        try{
+            result=userMapperEx.batDeleteOrUpdateUser(idsArray);
+        }catch(Exception e){
+            JshException.writeFail(logger, e);
+        }
+        if(result<1){
+            logger.error("异常码[{}],异常提示[{}],参数,ids:[{}]",
+                    ExceptionConstants.USER_DELETE_FAILED_CODE,ExceptionConstants.USER_DELETE_FAILED_MSG,ids);
+            throw new BusinessRunTimeException(ExceptionConstants.USER_DELETE_FAILED_CODE,
+                    ExceptionConstants.USER_DELETE_FAILED_MSG);
+        }
+        return result;
+    }
+
+    /**
+     * 校验验证码
+     * @param code 验证码
+     * @param uuid 唯一标识
+     * @return 结果
+     */
+    @Override
+    public void validateCaptcha(String code, String uuid) {
+        if(StringUtil.isNotEmpty(code) && StringUtil.isNotEmpty(uuid)) {
+            code = code.trim();
+            uuid = uuid.trim();
+            String verifyKey = BusinessConstants.CAPTCHA_CODE_KEY + uuid;
+            String captcha = redisService.getCacheObject(verifyKey);
+            redisService.deleteObject(verifyKey);
+            if (captcha == null) {
+                logger.error("异常码[{}],异常提示[{}]", ExceptionConstants.USER_JCAPTCHA_EXPIRE_CODE, ExceptionConstants.USER_JCAPTCHA_EXPIRE_MSG);
+                throw new BusinessRunTimeException(ExceptionConstants.USER_JCAPTCHA_EXPIRE_CODE, ExceptionConstants.USER_JCAPTCHA_EXPIRE_MSG);
+            }
+            if (!code.equalsIgnoreCase(captcha)) {
+                logger.error("异常码[{}],异常提示[{}]", ExceptionConstants.USER_JCAPTCHA_ERROR_CODE, ExceptionConstants.USER_JCAPTCHA_ERROR_MSG);
+                throw new BusinessRunTimeException(ExceptionConstants.USER_JCAPTCHA_ERROR_CODE, ExceptionConstants.USER_JCAPTCHA_ERROR_MSG);
+            }
+        } else {
+            logger.error("异常码[{}],异常提示[{}]", ExceptionConstants.USER_JCAPTCHA_EMPTY_CODE, ExceptionConstants.USER_JCAPTCHA_EMPTY_MSG);
+            throw new BusinessRunTimeException(ExceptionConstants.USER_JCAPTCHA_EMPTY_CODE, ExceptionConstants.USER_JCAPTCHA_EMPTY_MSG);
+        }
+    }
+
+    /**
+     * 用户登录
+     * @param loginName
+     * @param password
+     * @param request
+     * @return
+     * @throws Exception
+     */
+    @Override
+    public Map<String, Object> login(String loginName, String password, HttpServletRequest request) throws Exception {
+        Map<String, Object> data = new HashMap<>();
+        String msgTip = "";
+        User user = null;
+        //判断用户是否已经登录过,登录过不再处理
+        Object userId = redisService.getObjectFromSessionByKey(request,"userId");
+        if (userId != null) {
+            logger.info("====用户已经登录过, login 方法调用结束====");
+            msgTip = "user already login";
+        }
+        //获取用户状态
+        int userStatus = -1;
+        try {
+            redisService.deleteObjectBySession(request,"userId");
+            userStatus = validateUser(loginName, password);
+        } catch (Exception e) {
+            logger.error(">>>>>>>>>>>>>用户  " + loginName + " 登录 login 方法 访问服务层异常====", e);
+            msgTip = "access service exception";
+        }
+        String token = UUID.randomUUID().toString().replaceAll("-", "") + "";
+        switch (userStatus) {
+            case ExceptionCodeConstants.UserExceptionCode.USER_NOT_EXIST:
+                msgTip = "user is not exist";
+                break;
+            case ExceptionCodeConstants.UserExceptionCode.USER_PASSWORD_ERROR:
+                msgTip = "user password error";
+                break;
+            case ExceptionCodeConstants.UserExceptionCode.BLACK_USER:
+                msgTip = "user is black";
+                break;
+            case ExceptionCodeConstants.UserExceptionCode.USER_ACCESS_EXCEPTION:
+                msgTip = "access service error";
+                break;
+            case ExceptionCodeConstants.UserExceptionCode.BLACK_TENANT:
+                msgTip = "tenant is black";
+                break;
+            case ExceptionCodeConstants.UserExceptionCode.EXPIRE_TENANT:
+                msgTip = "tenant is expire";
+                break;
+            case ExceptionCodeConstants.UserExceptionCode.USER_CONDITION_FIT:
+                msgTip = "user can login";
+                //验证通过 ,可以登录,放入session,记录登录日志
+                user = getUserByLoginName(loginName);
+                if(user.getTenantId()!=null) {
+                    token = token + "_" + user.getTenantId();
+                }
+                redisService.storageObjectBySession(token,"userId",user.getId());
+                break;
+            default:
+                break;
+        }
+        data.put("msgTip", msgTip);
+        if(user!=null){
+            //校验下密码是不是过于简单
+            boolean pwdSimple = false;
+            if(user.getPassword().equals(Tools.md5Encryp(BusinessConstants.USER_DEFAULT_PASSWORD))) {
+                pwdSimple = true;
+            }
+            user.setPassword(null);
+            redisService.storageObjectBySession(token,"clientIp", Tools.getLocalIp(request));
+            logService.insertLogWithUserId(user.getId(), user.getTenantId(), "用户",
+                    new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_LOGIN).append(user.getLoginName()).toString(),
+                    ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
+            data.put("token", token);
+            data.put("user", user);
+            data.put("pwdSimple", pwdSimple);
+        }
+        return data;
+    }
+
+    @Override
+    public int validateUser(String loginName, String password) throws Exception {
+        /**默认是可以登录的*/
+        List<User> list = null;
+        try {
+            UserExample example = new UserExample();
+            example.createCriteria().andLoginNameEqualTo(loginName).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
+            list = userMapper.selectByExample(example);
+            if (null != list && list.size() == 0) {
+                return ExceptionCodeConstants.UserExceptionCode.USER_NOT_EXIST;
+            } else if(list.size() ==1) {
+                if(list.get(0).getStatus()!=0) {
+                    return ExceptionCodeConstants.UserExceptionCode.BLACK_USER;
+                }
+            }
+        } catch (Exception e) {
+            logger.error(">>>>>>>>访问验证用户姓名是否存在后台信息异常", e);
+            return ExceptionCodeConstants.UserExceptionCode.USER_ACCESS_EXCEPTION;
+        }
+        try {
+            UserExample example = new UserExample();
+            example.createCriteria().andLoginNameEqualTo(loginName).andPasswordEqualTo(password)
+                    .andStatusEqualTo(BusinessConstants.USER_STATUS_NORMAL).andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
+            list = userMapper.selectByExample(example);
+            if (null != list && list.size() == 0) {
+                return ExceptionCodeConstants.UserExceptionCode.USER_PASSWORD_ERROR;
+            }
+        } catch (Exception e) {
+            logger.error(">>>>>>>>>>访问验证用户密码后台信息异常", e);
+            return ExceptionCodeConstants.UserExceptionCode.USER_ACCESS_EXCEPTION;
+        }
+        return ExceptionCodeConstants.UserExceptionCode.USER_CONDITION_FIT;
+    }
+
+    @Override
+    public User getUserByLoginName(String loginName)throws Exception {
+        UserExample example = new UserExample();
+        example.createCriteria().andLoginNameEqualTo(loginName).andStatusEqualTo(BusinessConstants.USER_STATUS_NORMAL)
+                .andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
+        List<User> list=null;
+        try{
+            list= userMapper.selectByExample(example);
+        }catch(Exception e){
+            JshException.readFail(logger, e);
+        }
+        User user =null;
+        if(list!=null&&list.size()>0){
+            user = list.get(0);
+        }
+        return user;
+    }
+
+    @Override
+    public int checkIsNameExist(Long id, String name)throws Exception {
+        UserExample example = new UserExample();
+        List<Byte> userStatus = new ArrayList<>();
+        userStatus.add(BusinessConstants.USER_STATUS_NORMAL);
+        example.createCriteria().andIdNotEqualTo(id).andLoginNameEqualTo(name).andStatusIn(userStatus)
+                .andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
+        List<User> list=null;
+        try{
+            list= userMapper.selectByExample(example);
+        }catch(Exception e){
+            JshException.readFail(logger, e);
+        }
+        return list==null?0:list.size();
+    }
+    /**
+     * create by: cjl
+     * description:
+     *  获取当前用户信息
+     * create time: 2019/1/24 10:01
+     * @Param:
+     * @return com.jsh.erp.datasource.entities.User
+     */
+    @Override
+    public User getCurrentUser()throws Exception{
+        HttpServletRequest request = ((ServletRequestAttributes) Objects.requireNonNull(RequestContextHolder.getRequestAttributes())).getRequest();
+        Long userId = Long.parseLong(redisService.getObjectFromSessionByKey(request,"userId").toString());
+        return getUser(userId);
+    }
+
+    /**
+     * 根据用户名查询id
+     * @param loginName
+     * @return
+     */
+    @Override
+    public Long getIdByLoginName(String loginName) {
+        Long userId = 0L;
+        UserExample example = new UserExample();
+        example.createCriteria().andLoginNameEqualTo(loginName).andStatusEqualTo(BusinessConstants.USER_STATUS_NORMAL)
+                .andDeleteFlagNotEqualTo(BusinessConstants.DELETE_FLAG_DELETED);
+        List<User> list = userMapper.selectByExample(example);
+        if(list!=null) {
+            userId = list.get(0).getId();
+        }
+        return userId;
+    }
+
+    @Override
+    @Transactional(value = "transactionManager", rollbackFor = Exception.class)
+    public void addUserAndOrgUserRel(UserEx ue, HttpServletRequest request) throws Exception{
+        if(BusinessConstants.DEFAULT_MANAGER.equals(ue.getLoginName())) {
+            throw new BusinessRunTimeException(ExceptionConstants.USER_NAME_LIMIT_USE_CODE,
+                    ExceptionConstants.USER_NAME_LIMIT_USE_MSG);
+        } else {
+            logService.insertLog("用户",
+                    BusinessConstants.LOG_OPERATION_TYPE_ADD,
+                    ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
+            //检查用户名和登录名
+            checkLoginName(ue);
+            //新增用户信息
+            ue= this.addUser(ue);
+            if(ue==null){
+                logger.error("异常码[{}],异常提示[{}],参数,[{}]",
+                        ExceptionConstants.USER_ADD_FAILED_CODE,ExceptionConstants.USER_ADD_FAILED_MSG);
+                throw new BusinessRunTimeException(ExceptionConstants.USER_ADD_FAILED_CODE,
+                        ExceptionConstants.USER_ADD_FAILED_MSG);
+            }
+            //用户id,根据用户名查询id
+            Long userId = getIdByLoginName(ue.getLoginName());
+            if(ue.getRoleId()!=null){
+                JSONObject ubObj = new JSONObject();
+                ubObj.put("type", "UserRole");
+                ubObj.put("keyid", userId);
+                ubObj.put("value", "[" + ue.getRoleId() + "]");
+                userBusinessService.insertUserBusiness(ubObj, request);
+            }
+            if(ue.getOrgaId()==null){
+                //如果没有选择机构,就不建机构和用户的关联关系
+                return;
+            }
+            if(ue.getOrgaId()!=null && "1".equals(ue.getLeaderFlag())){
+                //检查当前机构是否存在经理
+                List<User> checkList = userMapperEx.getListByOrgaId(ue.getId(), ue.getOrgaId());
+                if(checkList.size()>0) {
+                    throw new BusinessRunTimeException(ExceptionConstants.USER_LEADER_IS_EXIST_CODE,
+                            ExceptionConstants.USER_LEADER_IS_EXIST_MSG);
+                }
+            }
+            //新增用户和机构关联关系
+            OrgaUserRel oul=new OrgaUserRel();
+            //机构id
+            oul.setOrgaId(ue.getOrgaId());
+            oul.setUserId(userId);
+            //用户在机构中的排序
+            oul.setUserBlngOrgaDsplSeq(ue.getUserBlngOrgaDsplSeq());
+            oul=orgaUserRelService.addOrgaUserRel(oul);
+            if(oul==null){
+                logger.error("异常码[{}],异常提示[{}],参数,[{}]",
+                        ExceptionConstants.ORGA_USER_REL_ADD_FAILED_CODE,ExceptionConstants.ORGA_USER_REL_ADD_FAILED_MSG);
+                throw new BusinessRunTimeException(ExceptionConstants.ORGA_USER_REL_ADD_FAILED_CODE,
+                        ExceptionConstants.ORGA_USER_REL_ADD_FAILED_MSG);
+            }
+        }
+    }
+
+    @Override
+    @Transactional(value = "transactionManager", rollbackFor = Exception.class)
+    public UserEx addUser(UserEx ue) throws Exception{
+        /**
+         * 新增用户默认设置
+         * 1、密码默认123456
+         * 2是否系统自带默认为非系统自带
+         * 3是否管理者默认为员工
+         * 4默认用户状态为正常
+         * */
+        ue.setPassword(Tools.md5Encryp(BusinessConstants.USER_DEFAULT_PASSWORD));
+        ue.setIsystem(BusinessConstants.USER_NOT_SYSTEM);
+        if(ue.getIsmanager()==null){
+            ue.setIsmanager(BusinessConstants.USER_NOT_MANAGER);
+        }
+        ue.setStatus(BusinessConstants.USER_STATUS_NORMAL);
+        int result=0;
+        try{
+            result= userMapper.insertSelective(ue);
+        }catch(Exception e){
+            JshException.writeFail(logger, e);
+        }
+        if(result>0){
+            return ue;
+        }
+        return null;
+    }
+
+    @Override
+    @Transactional(value = "transactionManager", rollbackFor = Exception.class)
+    public void registerUser(UserEx ue, Integer manageRoleId, HttpServletRequest request) throws Exception{
+        /**
+         * 多次创建事务,事物之间无法协同,应该在入口处创建一个事务以做协调
+         */
+        if(BusinessConstants.DEFAULT_MANAGER.equals(ue.getLoginName())) {
+            throw new BusinessRunTimeException(ExceptionConstants.USER_NAME_LIMIT_USE_CODE,
+                    ExceptionConstants.USER_NAME_LIMIT_USE_MSG);
+        } else {
+            ue.setPassword(ue.getPassword());
+            ue.setIsystem(BusinessConstants.USER_NOT_SYSTEM);
+            if (ue.getIsmanager() == null) {
+                ue.setIsmanager(BusinessConstants.USER_NOT_MANAGER);
+            }
+            ue.setStatus(BusinessConstants.USER_STATUS_NORMAL);
+            try{
+                userMapper.insertSelective(ue);
+                Long userId = getIdByLoginName(ue.getLoginName());
+                ue.setId(userId);
+            }catch(Exception e){
+                JshException.writeFail(logger, e);
+            }
+            //更新租户id
+            User user = new User();
+            user.setId(ue.getId());
+            user.setTenantId(ue.getId());
+            userService.updateUserTenant(user);
+            //新增用户与角色的关系
+            JSONObject ubObj = new JSONObject();
+            ubObj.put("type", "UserRole");
+            ubObj.put("keyid", ue.getId());
+            JSONArray ubArr = new JSONArray();
+            ubArr.add(manageRoleId);
+            ubObj.put("value", ubArr.toString());
+            ubObj.put("tenantId", ue.getId());
+            userBusinessService.insertUserBusiness(ubObj, null);
+            //创建租户信息
+            JSONObject tenantObj = new JSONObject();
+            tenantObj.put("tenantId", ue.getId());
+            tenantObj.put("loginName",ue.getLoginName());
+            tenantObj.put("userNumLimit", ue.getUserNumLimit());
+            tenantObj.put("expireTime", ue.getExpireTime());
+            tenantObj.put("remark", ue.getRemark());
+            Tenant tenant = JSONObject.parseObject(tenantObj.toJSONString(), Tenant.class);
+            tenant.setCreateTime(new Date());
+            if(tenant.getUserNumLimit()==null) {
+                tenant.setUserNumLimit(userNumLimit); //默认用户限制数量
+            }
+            if(tenant.getExpireTime()==null) {
+                tenant.setExpireTime(Tools.addDays(new Date(), tryDayLimit)); //租户允许试用的天数
+            }
+            tenantMapper.insertSelective(tenant);
+            logger.info("===============创建租户信息完成===============");
+        }
+    }
+
+    @Override
+    @Transactional(value = "transactionManager", rollbackFor = Exception.class)
+    public void updateUserTenant(User user) throws Exception{
+        UserExample example = new UserExample();
+        example.createCriteria().andIdEqualTo(user.getId());
+        try{
+            userMapper.updateByPrimaryKeySelective(user);
+        }catch(Exception e){
+            JshException.writeFail(logger, e);
+        }
+    }
+
+    @Override
+    @Transactional(value = "transactionManager", rollbackFor = Exception.class)
+    public void updateUserAndOrgUserRel(UserEx ue, HttpServletRequest request) throws Exception{
+        if(BusinessConstants.DEFAULT_MANAGER.equals(ue.getLoginName())) {
+            throw new BusinessRunTimeException(ExceptionConstants.USER_NAME_LIMIT_USE_CODE,
+                    ExceptionConstants.USER_NAME_LIMIT_USE_MSG);
+        } else {
+            logService.insertLog("用户",
+                    new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(ue.getId()).toString(),
+                    ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
+            //检查用户名和登录名
+            checkLoginName(ue);
+            //更新用户信息
+            ue = this.updateUser(ue);
+            if (ue == null) {
+                logger.error("异常码[{}],异常提示[{}],参数,[{}]",
+                        ExceptionConstants.USER_EDIT_FAILED_CODE, ExceptionConstants.USER_EDIT_FAILED_MSG);
+                throw new BusinessRunTimeException(ExceptionConstants.USER_EDIT_FAILED_CODE,
+                        ExceptionConstants.USER_EDIT_FAILED_MSG);
+            }
+            if(ue.getRoleId()!=null){
+                JSONObject ubObj = new JSONObject();
+                ubObj.put("type", "UserRole");
+                ubObj.put("keyid", ue.getId());
+                ubObj.put("value", "[" + ue.getRoleId() + "]");
+                Long ubId = userBusinessService.checkIsValueExist("UserRole", ue.getId().toString());
+                if(ubId!=null) {
+                    ubObj.put("id", ubId);
+                    userBusinessService.updateUserBusiness(ubObj, request);
+                } else {
+                    userBusinessService.insertUserBusiness(ubObj, request);
+                }
+            }
+            if (ue.getOrgaId() == null) {
+                //如果没有选择机构,就不建机构和用户的关联关系
+                return;
+            }
+            if(ue.getOrgaId()!=null && "1".equals(ue.getLeaderFlag())){
+                //检查当前机构是否存在经理
+                List<User> checkList = userMapperEx.getListByOrgaId(ue.getId(), ue.getOrgaId());
+                if(checkList.size()>0) {
+                    throw new BusinessRunTimeException(ExceptionConstants.USER_LEADER_IS_EXIST_CODE,
+                            ExceptionConstants.USER_LEADER_IS_EXIST_MSG);
+                }
+            }
+            //更新用户和机构关联关系
+            OrgaUserRel oul = new OrgaUserRel();
+            //机构和用户关联关系id
+            oul.setId(ue.getOrgaUserRelId());
+            //机构id
+            oul.setOrgaId(ue.getOrgaId());
+            //用户id
+            oul.setUserId(ue.getId());
+            //用户在机构中的排序
+            oul.setUserBlngOrgaDsplSeq(ue.getUserBlngOrgaDsplSeq());
+            if (oul.getId() != null) {
+                //已存在机构和用户的关联关系,更新
+                oul = orgaUserRelService.updateOrgaUserRel(oul);
+            } else {
+                //不存在机构和用户的关联关系,新建
+                oul = orgaUserRelService.addOrgaUserRel(oul);
+            }
+            if (oul == null) {
+                logger.error("异常码[{}],异常提示[{}],参数,[{}]",
+                        ExceptionConstants.ORGA_USER_REL_EDIT_FAILED_CODE, ExceptionConstants.ORGA_USER_REL_EDIT_FAILED_MSG);
+                throw new BusinessRunTimeException(ExceptionConstants.ORGA_USER_REL_EDIT_FAILED_CODE,
+                        ExceptionConstants.ORGA_USER_REL_EDIT_FAILED_MSG);
+            }
+        }
+    }
+    @Override
+    @Transactional(value = "transactionManager", rollbackFor = Exception.class)
+    public UserEx updateUser(UserEx ue)throws Exception{
+        int result =0;
+        try{
+            result=userMapper.updateByPrimaryKeySelective(ue);
+        }catch(Exception e){
+            JshException.writeFail(logger, e);
+        }
+        if(result>0){
+            return ue;
+        }
+        return null;
+    }
+    /**
+     *  检查登录名不能重复
+     * create time: 2019/3/12 11:36
+     * @Param: userEx
+     * @return void
+     */
+    @Override
+    public void checkLoginName(UserEx userEx)throws Exception{
+        List<User> list=null;
+        if(userEx==null){
+            return;
+        }
+        Long userId=userEx.getId();
+        //检查登录名
+        if(!StringUtils.isEmpty(userEx.getLoginName())){
+            String loginName=userEx.getLoginName();
+            list=this.getUserListByloginName(loginName);
+            if(list!=null&&list.size()>0){
+                if(list.size()>1){
+                    //超过一条数据存在,该登录名已存在
+                    logger.error("异常码[{}],异常提示[{}],参数,loginName:[{}]",
+                            ExceptionConstants.USER_LOGIN_NAME_ALREADY_EXISTS_CODE,ExceptionConstants.USER_LOGIN_NAME_ALREADY_EXISTS_MSG,loginName);
+                    throw new BusinessRunTimeException(ExceptionConstants.USER_LOGIN_NAME_ALREADY_EXISTS_CODE,
+                            ExceptionConstants.USER_LOGIN_NAME_ALREADY_EXISTS_MSG);
+                }
+                //一条数据,新增时抛出异常,修改时和当前的id不同时抛出异常
+                if(list.size()==1){
+                    if(userId==null||(userId!=null&&!userId.equals(list.get(0).getId()))){
+                        logger.error("异常码[{}],异常提示[{}],参数,loginName:[{}]",
+                                ExceptionConstants.USER_LOGIN_NAME_ALREADY_EXISTS_CODE,ExceptionConstants.USER_LOGIN_NAME_ALREADY_EXISTS_MSG,loginName);
+                        throw new BusinessRunTimeException(ExceptionConstants.USER_LOGIN_NAME_ALREADY_EXISTS_CODE,
+                                ExceptionConstants.USER_LOGIN_NAME_ALREADY_EXISTS_MSG);
+                    }
+                }
+            }
+        }
+    }
+    /**
+     * 通过登录名获取用户列表
+     * */
+    @Override
+    public List<User> getUserListByloginName(String loginName){
+        List<User> list =null;
+        try{
+            list=userMapperEx.getUserListByUserNameOrLoginName(null,loginName);
+        }catch(Exception e){
+            JshException.readFail(logger, e);
+        }
+        return list;
+    }
+
+    @Override
+    public List<TreeNodeEx> getOrganizationUserTree()throws Exception {
+        List<TreeNodeEx> list =null;
+        try{
+            list=userMapperEx.getNodeTree();
+        }catch(Exception e){
+            JshException.readFail(logger, e);
+        }
+        return list;
+    }
+
+    /**
+     * 根据用户id查询角色信息
+     * @param userId
+     * @return
+     */
+    @Override
+    @Transactional(value = "transactionManager", rollbackFor = Exception.class)
+    public Role getRoleTypeByUserId(long userId) throws Exception {
+        Role role = new Role();
+        List<UserBusiness> list = userBusinessService.getBasicData(String.valueOf(userId), "UserRole");
+        UserBusiness ub = null;
+        if(list.size() > 0) {
+            ub = list.get(0);
+            String values = ub.getValue();
+            String roleId = null;
+            if(values!=null) {
+                values = values.replaceAll("\\[\\]",",").replace("[","").replace("]","");
+            }
+            String [] valueArray=values.split(",");
+            if(valueArray.length>0) {
+                roleId = valueArray[0];
+            }
+            role = roleService.getRoleWithoutTenant(Long.parseLong(roleId));
+        }
+        return role;
+    }
+
+    /**
+     * 获取用户id
+     * @param request
+     * @return
+     */
+    @Override
+    public Long getUserId(HttpServletRequest request) throws Exception{
+        Object userIdObj = redisService.getObjectFromSessionByKey(request,"userId");
+        Long userId = null;
+        if(userIdObj != null) {
+            userId = Long.parseLong(userIdObj.toString());
+        }
+        return userId;
+    }
+
+    /**
+     * 用户的按钮权限
+     * @param userId
+     * @return
+     * @throws Exception
+     */
+    @Override
+    public JSONArray getBtnStrArrById(Long userId) throws Exception {
+        JSONArray btnStrArr = new JSONArray();
+        List<UserBusiness> userRoleList = userBusinessService.getBasicData(userId.toString(), "UserRole");
+        if(userRoleList!=null && userRoleList.size()>0) {
+            String roleValue = userRoleList.get(0).getValue();
+            if(StringUtil.isNotEmpty(roleValue) && roleValue.indexOf("[")>-1 && roleValue.indexOf("]")>-1){
+                roleValue = roleValue.replace("[", "").replace("]", ""); //角色id-单个
+                List<UserBusiness> roleFunctionsList = userBusinessService.getBasicData(roleValue, "RoleFunctions");
+                if(roleFunctionsList!=null && roleFunctionsList.size()>0) {
+                    String btnStr = roleFunctionsList.get(0).getBtnStr();
+                    if(StringUtil.isNotEmpty(btnStr)){
+                        btnStrArr = JSONArray.parseArray(btnStr);
+                    }
+                }
+            }
+        }
+        //将数组中的funId转为url
+        JSONArray btnStrWithUrlArr = new JSONArray();
+        if(btnStrArr.size()>0) {
+            List<Function> functionList = functionService.getFunction();
+            Map<Long, String> functionMap = new HashMap<>();
+            for (Function function: functionList) {
+                functionMap.put(function.getId(), function.getUrl());
+            }
+            for (Object obj : btnStrArr) {
+                JSONObject btnStrObj = JSONObject.parseObject(obj.toString());
+                Long funId = btnStrObj.getLong("funId");
+                JSONObject btnStrWithUrlObj = new JSONObject();
+                btnStrWithUrlObj.put("url", functionMap.get(funId));
+                btnStrWithUrlObj.put("btnStr", btnStrObj.getString("btnStr"));
+                btnStrWithUrlArr.add(btnStrWithUrlObj);
+            }
+        }
+        return btnStrWithUrlArr;
+    }
+
+    @Override
+    @Transactional(value = "transactionManager", rollbackFor = Exception.class)
+    public int batchSetStatus(Byte status, String ids, HttpServletRequest request)throws Exception {
+        int result=0;
+        List<User> list = getUserListByIds(ids);
+        //选中的用户的数量
+        int selectUserSize = list.size();
+        //查询启用状态的用户的数量
+        int enableUserSize = getUser(request).size();
+        User userInfo = userService.getCurrentUser();
+        Tenant tenant = tenantService.getTenantByTenantId(userInfo.getTenantId());
+        if(tenant!=null) {
+            if (selectUserSize + enableUserSize > tenant.getUserNumLimit() && status == 0) {
+                throw new BusinessParamCheckingException(ExceptionConstants.USER_ENABLE_OVER_LIMIT_FAILED_CODE,
+                        ExceptionConstants.USER_ENABLE_OVER_LIMIT_FAILED_MSG);
+            }
+        }
+        StringBuilder userStr = new StringBuilder();
+        List<Long> idList = new ArrayList<>();
+        for(User user: list) {
+            if(user.getId().equals(user.getTenantId())) {
+                //租户不能进行禁用
+            } else {
+                idList.add(user.getId());
+                userStr.append(user.getLoginName()).append(" ");
+            }
+        }
+        String statusStr ="";
+        if(status == 0) {
+            statusStr ="批量启用";
+        } else if(status == 2) {
+            statusStr ="批量禁用";
+        }
+        if(idList.size()>0) {
+            User user = new User();
+            user.setStatus(status);
+            UserExample example = new UserExample();
+            example.createCriteria().andIdIn(idList);
+            result = userMapper.updateByExampleSelective(user, example);
+            logService.insertLog("用户",
+                    new StringBuffer(BusinessConstants.LOG_OPERATION_TYPE_EDIT).append(userStr).append("-").append(statusStr).toString(),
+                    ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest());
+        } else {
+            result = 1;
+        }
+        return result;
+    }
+
+    @Override
+    public User getUserByWeixinCode(String weixinCode) throws Exception {
+        String weixinUrl = platformConfigService.getPlatformConfigByKey("weixinUrl").getPlatformValue();
+        String weixinAppid = platformConfigService.getPlatformConfigByKey("weixinAppid").getPlatformValue();
+        String weixinSecret = platformConfigService.getPlatformConfigByKey("weixinSecret").getPlatformValue();
+        String url = weixinUrl + "?appid=" + weixinAppid + "&secret=" + weixinSecret + "&js_code=" + weixinCode
+                + "&grant_type=authorization_code";
+        JSONObject jsonObject = HttpClient.httpGet(url);
+        if(jsonObject!=null) {
+            String weixinOpenId = jsonObject.getString("openid");
+            if(StringUtil.isNotEmpty(weixinOpenId)) {
+                return userMapperEx.getUserByWeixinOpenId(weixinOpenId);
+            }
+        }
+        return null;
+    }
+
+    @Override
+    public int weixinBind(String loginName, String password, String weixinCode) throws Exception {
+        String weixinUrl = platformConfigService.getPlatformConfigByKey("weixinUrl").getPlatformValue();
+        String weixinAppid = platformConfigService.getPlatformConfigByKey("weixinAppid").getPlatformValue();
+        String weixinSecret = platformConfigService.getPlatformConfigByKey("weixinSecret").getPlatformValue();
+        String url = weixinUrl + "?appid=" + weixinAppid + "&secret=" + weixinSecret + "&js_code=" + weixinCode
+                + "&grant_type=authorization_code";
+        JSONObject jsonObject = HttpClient.httpGet(url);
+        if(jsonObject!=null) {
+            String weixinOpenId = jsonObject.getString("openid");
+            if(StringUtil.isNotEmpty(weixinOpenId)) {
+                return userMapperEx.updateUserWithWeixinOpenId(loginName, password, weixinOpenId);
+            }
+        }
+        return 0;
+    }
+}

+ 3 - 2
src/main/resources/mapper_xml/DepotItemMapper.xml

@@ -621,13 +621,14 @@
       me.commodity_unit AS commodity_unit
     FROM
       jsh_depot_item di
+      LEFT JOIN jsh_depot_head dh ON di.header_id = dh.id
       LEFT JOIN jsh_material m ON di.material_id = m.id
       LEFT JOIN jsh_material_extend me ON di.material_extend_id = me.id
       LEFT JOIN jsh_depot d ON di.depot_id = d.id
     WHERE
       di.delete_flag = '0'
-      AND m.status in ('2','3')
-      AND di.type = #{type}
+      AND dh.status in ('2','3')
+      AND dh.type = #{type}
       AND di.material_id = #{materialId}
   </select>
 

+ 5 - 0
src/main/resources/mapper_xml/TaskStocktakingItemMapper.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.jsh.erp.datasource.mappers.TaskStocktakingItemMapper">
+
+</mapper>

+ 5 - 0
src/main/resources/mapper_xml/TaskStocktakingMapper.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.jsh.erp.datasource.mappers.TaskStocktakingMapper">
+
+</mapper>

+ 8 - 0
src/main/resources/mapper_xml/UserMapper.xml

@@ -397,4 +397,12 @@
       delete_flag = #{deleteFlag,jdbcType=VARCHAR}
     where id = #{id,jdbcType=BIGINT}
   </update>
+
+  <select id="creatorSpinnerList" resultType="com.jsh.erp.datasource.vo.SpinnerVO">
+    SELECT
+      id AS label,
+      username AS VALUE
+    FROM
+      jsh_user
+  </select>
 </mapper>