Pu Zhibing
3 天以前 25cf266e99714ac5d428e66b40ce272325c91dd8
ManagementQYTTravel/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/specialTrain/TDispatchController.java
@@ -4,6 +4,7 @@
import com.baomidou.mybatisplus.plugins.Page;
import com.stylefeng.guns.core.base.controller.BaseController;
import com.stylefeng.guns.core.base.tips.ErrorTip;
import com.stylefeng.guns.core.beetl.ShiroExtUtil;
import com.stylefeng.guns.core.common.constant.factory.PageFactory;
import com.stylefeng.guns.core.shiro.ShiroKit;
import com.stylefeng.guns.core.util.SinataUtil;
@@ -60,19 +61,19 @@
     */
    @RequestMapping("/tDispatch_add")
    public String tDispatchAdd(Model model) {
        model.addAttribute("roleType",ShiroKit.getUser().getRoleType());
        model.addAttribute("roleType", ShiroExtUtil.getUser().getRoleType());
        List<TCompany> companyList = tCompanyService.selectList(new EntityWrapper<TCompany>().eq("type", 2)
                .eq("isCross", 1)
                .last(" and state != 1 and FIND_IN_SET(flag,'1,2')"));
        model.addAttribute("companyList",companyList);
        if (2 == ShiroKit.getUser().getRoleType()){
        if (2 == ShiroExtUtil.getUser().getRoleType()) {
            List<TCompany> franchiseeList = tCompanyService.selectList(new EntityWrapper<TCompany>().eq("type", 3)
                    .eq("superiorId",ShiroKit.getUser().getObjectId()));
            model.addAttribute("franchiseeList",franchiseeList);
        }else{
            model.addAttribute("franchiseeList",null);
                    .eq("superiorId", ShiroExtUtil.getUser().getObjectId()));
            model.addAttribute("franchiseeList", franchiseeList);
        } else {
            model.addAttribute("franchiseeList", null);
        }
        return PREFIX + "tDispatch_add.html";
    }
@@ -104,8 +105,8 @@
        TDispatch tDispatch = tDispatchService.selectById(tDispatchId);
        model.addAttribute("item",tDispatch);
        LogObjectHolder.me().set(tDispatch);
        Integer roleType = ShiroKit.getUser().getRoleType();
        Integer roleType = ShiroExtUtil.getUser().getRoleType();
        model.addAttribute("roleType",roleType);
        if (1 == roleType){
            List<TCompany> companyList = tCompanyService.selectList(new EntityWrapper<TCompany>().eq("type", 2)
@@ -120,7 +121,7 @@
            model.addAttribute("franchiseeList",franchiseeList);
        }else if (2 == roleType){
            List<TCompany> franchiseeList = tCompanyService.selectList(new EntityWrapper<TCompany>().eq("type", 3)
                    .eq("superiorId",ShiroKit.getUser().getObjectId())
                    .eq("superiorId", ShiroExtUtil.getUser().getObjectId())
                    .eq("isCross", 1)
                    .last(" and state != 1 and FIND_IN_SET(flag,'1,2')"));
            model.addAttribute("franchiseeList",franchiseeList);
@@ -142,7 +143,7 @@
            endTime = timeArray[1];
        }
        Page<Map<String, Object>> page = new PageFactory<Map<String, Object>>().defaultPage();
        page.setRecords(tDispatchService.getDispatchList(page,ShiroKit.getUser().getRoleType(),ShiroKit.getUser().getObjectId(),beginTime,endTime,name,companyName,franchiseeName,account,state));
        page.setRecords(tDispatchService.getDispatchList(page, ShiroExtUtil.getUser().getRoleType(), ShiroExtUtil.getUser().getObjectId(), beginTime, endTime, name, companyName, franchiseeName, account, state));
        return super.packForBT(page);
    }
@@ -153,25 +154,25 @@
    @ResponseBody
    public Object add(TDispatch tDispatch) {
        //判断账号是否存在
        int count = tDispatchService.selectCount(new EntityWrapper<TDispatch>().eq("account",tDispatch.getAccount()).last(" and FIND_IN_SET(state,'1,2')"));
        if (count > 0){
            return new ErrorTip(500,"账号已存在,请重新输入");
        int count = tDispatchService.selectCount(new EntityWrapper<TDispatch>().eq("account", tDispatch.getAccount()).last(" and FIND_IN_SET(state,'1,2')"));
        if (count > 0) {
            return new ErrorTip(500, "账号已存在,请重新输入");
        }
        Integer roleType = ShiroKit.getUser().getRoleType();
        Integer objectId = ShiroKit.getUser().getObjectId();
        if (2 == roleType){
        Integer roleType = ShiroExtUtil.getUser().getRoleType();
        Integer objectId = ShiroExtUtil.getUser().getObjectId();
        if (2 == roleType) {
            tDispatch.setCompanyId(objectId);
        }else if (3 == roleType){
        } else if (3 == roleType) {
            TCompany company = tCompanyService.selectById(objectId);
            tDispatch.setCompanyId(company.getSuperiorId());
            tDispatch.setFranchiseeId(objectId);
        }
        tDispatch.setInsertTime(new Date());
        tDispatch.setInsertUserId(ShiroKit.getUser().getId());
        tDispatch.setInsertUserId(ShiroExtUtil.getUser().getId());
        tDispatch.setInsertUserRole(roleType);
        tDispatch.setState(1);
        if(tDispatch.getCompanyId() == null){
            Integer objectId1 = userService.selectById(ShiroKit.getUser().getId()).getObjectId();
            Integer objectId1 = userService.selectById(ShiroExtUtil.getUser().getId()).getObjectId();
            tDispatch.setCompanyId(objectId1);
        }
        tDispatch.setPassword(ShiroKit.md5(tDispatch.getPassword(), "WL:x9#"));
@@ -207,23 +208,23 @@
    @ResponseBody
    public Object update(TDispatch tDispatch) {
        TDispatch obj = tDispatchService.selectById(tDispatch.getId());
        if (!obj.getAccount().equals(tDispatch.getAccount())){
        if (!obj.getAccount().equals(tDispatch.getAccount())) {
            //判断账号是否存在
            int count = tDispatchService.selectCount(new EntityWrapper<TDispatch>().eq("account",tDispatch.getAccount()).last(" and FIND_IN_SET(state,'1,2')"));
            if (count > 0){
                return new ErrorTip(500,"账号已存在,请重新输入");
            int count = tDispatchService.selectCount(new EntityWrapper<TDispatch>().eq("account", tDispatch.getAccount()).last(" and FIND_IN_SET(state,'1,2')"));
            if (count > 0) {
                return new ErrorTip(500, "账号已存在,请重新输入");
            }
        }
        Integer roleType = ShiroKit.getUser().getRoleType();
        Integer objectId = ShiroKit.getUser().getObjectId();
        if (2 == roleType){
        Integer roleType = ShiroExtUtil.getUser().getRoleType();
        Integer objectId = ShiroExtUtil.getUser().getObjectId();
        if (2 == roleType) {
            tDispatch.setCompanyId(objectId);
        }else if (3 == roleType){
        } else if (3 == roleType) {
            TCompany company = tCompanyService.selectById(objectId);
            tDispatch.setCompanyId(company.getSuperiorId());
            tDispatch.setFranchiseeId(objectId);
        }
        if (SinataUtil.isNotEmpty(tDispatch.getPassword())){
        if (SinataUtil.isNotEmpty(tDispatch.getPassword())) {
            tDispatch.setPassword(ShiroKit.md5(tDispatch.getPassword(), "WL:x9#"));
        }
        tDispatchService.updateById(tDispatch);