From a0af42a6acfc7a0ebbb92bffc1816525e508af70 Mon Sep 17 00:00:00 2001 From: Pu Zhibing <393733352@qq.com> Date: 星期五, 17 十月 2025 16:54:06 +0800 Subject: [PATCH] 修改bug --- management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/TBranchOfficeController.java | 176 +++++++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 166 insertions(+), 10 deletions(-) diff --git a/management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/TBranchOfficeController.java b/management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/TBranchOfficeController.java index 2271853..d9ecae6 100644 --- a/management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/TBranchOfficeController.java +++ b/management/guns-admin/src/main/java/com/stylefeng/guns/modular/system/controller/general/TBranchOfficeController.java @@ -6,11 +6,14 @@ import com.baomidou.mybatisplus.mapper.EntityWrapper; import com.baomidou.mybatisplus.mapper.Wrapper; import com.stylefeng.guns.core.base.controller.BaseController; +import com.stylefeng.guns.core.base.tips.ErrorTip; import com.stylefeng.guns.core.base.tips.SuccessTip; +import com.stylefeng.guns.core.beetl.ShiroExtUtil; import com.stylefeng.guns.core.common.constant.state.ManagerStatus; import com.stylefeng.guns.core.exception.GunsException; import com.stylefeng.guns.core.shiro.ShiroKit; import com.stylefeng.guns.core.util.SinataUtil; +import com.stylefeng.guns.core.util.ToolUtil; import com.stylefeng.guns.modular.system.controller.resp.TBranchOfficeResp; import com.stylefeng.guns.modular.system.enums.StatusEnum; import com.stylefeng.guns.modular.system.model.*; @@ -18,6 +21,10 @@ import com.stylefeng.guns.modular.system.util.DateUtil; import com.stylefeng.guns.modular.system.util.RedisUtil; import com.stylefeng.guns.modular.system.util.ResultUtil; +import com.stylefeng.guns.modular.system.util.qianyuntong.EmployeeUtil; +import com.stylefeng.guns.modular.system.util.qianyuntong.EnterpriseUtil; +import com.stylefeng.guns.modular.system.util.qianyuntong.UserUtil; +import com.stylefeng.guns.modular.system.util.qianyuntong.model.*; import io.swagger.annotations.ApiOperation; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Controller; @@ -65,6 +72,9 @@ private RedisUtil redisUtil; @Autowired private ITBranchOfficeAreaService branchOfficeAreaService; + + @Autowired + private ShiroExtUtil shiroExtUtil; /** * 跳转到首页 @@ -174,13 +184,18 @@ */ @RequestMapping("/tBranchOfficeDetail") public String tBranchOfficeDetail(Integer tBranchOfficeId, Model model) { - Integer roleType = Objects.requireNonNull(ShiroKit.getUser()).getRoleType(); - Integer objectId = Objects.requireNonNull(ShiroKit.getUser()).getObjectId(); + Integer roleType = Objects.requireNonNull(shiroExtUtil.getUser()).getRoleType(); + Integer objectId = Objects.requireNonNull(shiroExtUtil.getUser()).getObjectId(); tBranchOfficeService.tBranchOfficeDetail(tBranchOfficeId,model); TSystemConfig tSystemConfig = tSystemConfigService.selectOne(new EntityWrapper<TSystemConfig>().eq("type", 3) .eq("companyType",2) .eq("companyId",tBranchOfficeId) .last("LIMIT 1")); + if(null == tSystemConfig){ + tSystemConfig = tSystemConfigService.selectOne(new EntityWrapper<TSystemConfig>().eq("type", 3) + .eq("branchOfficeId",tBranchOfficeId) + .last("LIMIT 1")); + } JSONObject jsonObject = JSONObject.parseObject(tSystemConfig.getContent()); // model.addAttribute("num2",jsonObject.getInteger("num2")); Integer num4 = jsonObject.getInteger("num4"); @@ -234,8 +249,8 @@ */ @RequestMapping("/extractionRules") public String extractionRules(Model model,Integer tBranchOfficeId) { - Integer roleType = ShiroKit.getUser().getRoleType(); - Integer objectId = ShiroKit.getUser().getObjectId(); + Integer roleType = shiroExtUtil.getUser().getRoleType(); + Integer objectId = shiroExtUtil.getUser().getObjectId(); model.addAttribute("roleType",roleType); model.addAttribute("branchOfficeId",tBranchOfficeId); TSystemConfig tSystemConfig = tSystemConfigService.selectOne(new EntityWrapper<TSystemConfig>().eq("type", 3) @@ -276,8 +291,8 @@ @RequestMapping(value = "/systemConfigSubmit") @ResponseBody public Object systemConfigSubmit(Integer type,String content,Integer branchOfficeId) { - Integer roleType = Objects.requireNonNull(ShiroKit.getUser()).getRoleType(); - Integer objectId = Objects.requireNonNull(ShiroKit.getUser()).getObjectId(); + Integer roleType = Objects.requireNonNull(shiroExtUtil.getUser()).getRoleType(); + Integer objectId = Objects.requireNonNull(shiroExtUtil.getUser()).getObjectId(); TSystemConfig tSystemConfig = tSystemConfigService.selectOne(new EntityWrapper<TSystemConfig>().eq("type", 3) .eq("companyType",1) .eq("companyId",1) @@ -407,7 +422,7 @@ public Object list(String branchOfficeName,String principal,String principalPhone,Integer operatingBusiness ,Integer status) { List<TBranchOfficeResp> tBranchOfficeRespList = tBranchOfficeService.getPageList(branchOfficeName,principal,principalPhone,operatingBusiness,status); for (TBranchOfficeResp tBranchOfficeResp : tBranchOfficeRespList) { - tBranchOfficeResp.setUserType(Objects.requireNonNull(ShiroKit.getUser()).getRoleType()); + tBranchOfficeResp.setUserType(Objects.requireNonNull(shiroExtUtil.getUser()).getRoleType()); } // 分公司查询优惠券,订单,司机等信息 tBranchOfficeService.queryOtherInfo(tBranchOfficeRespList); @@ -520,6 +535,71 @@ if(Objects.nonNull(o)){ return o; } + + if(ToolUtil.isEmpty(tBranchOffice.getIdentifier())){ + return "统一社会信用代码不能为空"; + } + //调用中台接口创建企业 + CheckEnterExist checkEnterExist = EnterpriseUtil.checkEnterExistByEnterIdCardNo(tBranchOffice.getIdentifier()); + String enterCode = ""; + Integer enterNew = null; + Long empId = null; + Integer empnew = null; + //企业未注册,进行注册 + if (null == checkEnterExist || "0".equals(checkEnterExist.getIsReg())) { + CreateEnterpriseRequest request = new CreateEnterpriseRequest(); + request.setName(tBranchOffice.getBranchOfficeName()); + request.setNickName(tBranchOffice.getBranchOfficeName()); + request.setUscc(tBranchOffice.getIdentifier()); + request.setIndustry_code("292"); + request.setMobile(tBranchOffice.getAccount()); + CreateEnterprise enterprise = EnterpriseUtil.createEnterprise(request); + enterCode = enterprise.getIdCode(); + enterNew = 1; + List<QYTUserInfo> userInfoByPhone = UserUtil.getUserInfoByPhone(tBranchOffice.getAccount(), enterCode); + if(null != userInfoByPhone && userInfoByPhone.size() > 0){ + empId = userInfoByPhone.get(0).getEmpId(); + empnew = 0; + }else{ + empId = 0L; + empnew = 1; + } + } + //企业已注册 + if (null != checkEnterExist && "1".equals(checkEnterExist.getIsReg())) { + enterCode = checkEnterExist.getEnterCode(); + enterNew = 0; + List<QYTUserInfo> userInfoByPhone = UserUtil.getUserInfoByPhone(tBranchOffice.getAccount(), enterCode); + if(null == userInfoByPhone ||userInfoByPhone.size() == 0){ + //负责人不匹配,则创建新的员工到中台 + SaveStaffNodeRequest request = new SaveStaffNodeRequest(); + request.setMobile(checkEnterExist.getMobile()); + request.setEntercode(enterCode); + request.setEmpName(tBranchOffice.getBranchOfficeName() + "管理员"); + request.setEmpNickname(tBranchOffice.getBranchOfficeName() + "管理员"); + request.setLoginNo(tBranchOffice.getAccount()); + request.setEmpSex("男"); + request.setMphone(tBranchOffice.getAccount()); + request.setEmail(tBranchOffice.getAccount() + "@qyt.com"); + request.setDeptId(0); + request.setPositionId(1); + request.setSuperLevel(0); + request.setHideMobile(0); + ResultUtil<SaveStaffNode> resultUtil = EmployeeUtil.saveStaffNode(request); + if(200 != resultUtil.getStatus()){ + return new ErrorTip(resultUtil.getStatus(), resultUtil.getMsg()); + } + SaveStaffNode saveStaffNode = resultUtil.getData(); + empId = saveStaffNode.getEmpId(); + empnew = 1; + }else{ + empId = userInfoByPhone.get(0).getEmpId(); + empnew = 0; + } + } + + tBranchOffice.setEnterCode(enterCode); + tBranchOffice.setEnterNew(enterNew); tBranchOffice.setPrincipal(tBranchOffice.getPrincipal().replace(" ","")); tBranchOffice.setStatus(StatusEnum.NORMAL.getCode()); @@ -528,6 +608,7 @@ //添加User对象 User user = new User(); user.setAccount(tBranchOffice.getAccount()); + user.setPhone(tBranchOffice.getAccount()); user.setSalt(ShiroKit.getRandomSalt(5)); user.setPassword(ShiroKit.md5(tBranchOffice.getPassword(), user.getSalt())); user.setStatus(ManagerStatus.OK.getCode()); @@ -538,7 +619,29 @@ user.setObjectId(tBranchOffice.getId()); user.setName(tBranchOffice.getPrincipal()); user.setSex(1); + user.setEmpId(empId); + user.setEntercode(enterCode); + user.setEnterId(Long.valueOf(enterCode)); + user.setEmpnew(empnew); userService.insert(user); + tBranchOffice.setSysUserId(user.getId()); + tBranchOfficeService.updateById(tBranchOffice); + //编写异步延迟处理中台账号延迟创建的问题 + if(0 == empId){ + Timer timer = new Timer(); + String finalEnterCode = enterCode; + timer.schedule(new TimerTask() { + @Override + public void run() { + List<QYTUserInfo> userInfoByPhone = UserUtil.getUserInfoByPhone(tBranchOffice.getAccount(), finalEnterCode); + if(null != userInfoByPhone && userInfoByPhone.size() > 0){ + Long empId1 = userInfoByPhone.get(0).getEmpId(); + user.setEmpId(empId1); + userService.updateById(user); + } + } + },120*1000); + } //添加价格规则 TSystemConfig tSystemConfig = new TSystemConfig(); tSystemConfig.setCompanyId(tBranchOffice.getId()); @@ -662,8 +765,8 @@ public Object update(TBranchOffice tBranchOffice,String subArr, Integer systemPriceType, String systemPriceContent, Integer holiday, Integer isTaxiCar, String serviceTel) { TBranchOffice branchOffice = tBranchOfficeService.selectById(tBranchOffice.getId()); User user = userService.selectOne(new EntityWrapper<User>() - .eq("role_type", 2) - .eq("object_id", branchOffice.getId()) + .eq("roleType", 2) + .eq("objectId", branchOffice.getId()) .last("LIMIT 1")); // 判断区域是否已存在 Object o = addScopeIsExit(subArr, tBranchOffice); @@ -673,9 +776,42 @@ //判断账号是否已存在 if (SinataUtil.isNotEmpty(tBranchOffice.getAccount()) && SinataUtil.isNotEmpty(tBranchOffice.getPassword())){ if(Objects.isNull(user)){ + String enterCode = tBranchOffice.getEnterCode(); + Long empId = null; + Integer empnew = null; + CheckEnterExist checkEnterExist = EnterpriseUtil.checkEnterExistByEnterIdCardNo(tBranchOffice.getIdentifier()); + List<QYTUserInfo> userInfoByPhone = UserUtil.getUserInfoByPhone(tBranchOffice.getAccount(), enterCode); + if(null == userInfoByPhone ||userInfoByPhone.size() == 0){ + //负责人不匹配,则创建新的员工到中台 + SaveStaffNodeRequest request = new SaveStaffNodeRequest(); + request.setMobile(checkEnterExist.getMobile()); + request.setEntercode(enterCode); + request.setEmpName(tBranchOffice.getBranchOfficeName() + "管理员"); + request.setEmpNickname(tBranchOffice.getBranchOfficeName() + "管理员"); + request.setLoginNo(tBranchOffice.getAccount()); + request.setEmpSex("男"); + request.setMphone(tBranchOffice.getAccount()); + request.setEmail(tBranchOffice.getAccount() + "@qyt.com"); + request.setDeptId(0); + request.setPositionId(1); + request.setSuperLevel(0); + request.setHideMobile(0); + ResultUtil<SaveStaffNode> resultUtil = EmployeeUtil.saveStaffNode(request); + if(200 != resultUtil.getStatus()){ + return new ErrorTip(resultUtil.getStatus(), resultUtil.getMsg()); + } + SaveStaffNode saveStaffNode = resultUtil.getData(); + empId = saveStaffNode.getEmpId(); + empnew = 1; + }else{ + empId = userInfoByPhone.get(0).getEmpId(); + empnew = 0; + } + //添加User对象 user = new User(); user.setAccount(tBranchOffice.getAccount()); + user.setPhone(tBranchOffice.getAccount()); user.setSalt(ShiroKit.getRandomSalt(5)); user.setPassword(ShiroKit.md5(tBranchOffice.getPassword(), user.getSalt())); user.setStatus(ManagerStatus.OK.getCode()); @@ -686,7 +822,28 @@ user.setObjectId(tBranchOffice.getId()); user.setName(tBranchOffice.getPrincipal()); user.setSex(1); + user.setEmpId(empId); + user.setEntercode(enterCode); + user.setEnterId(Long.valueOf(enterCode)); + user.setEmpnew(empnew); userService.insert(user); + //编写异步延迟处理中台账号延迟创建的问题 + if(0 == empId){ + Timer timer = new Timer(); + String finalEnterCode = enterCode; + User finalUser = user; + timer.schedule(new TimerTask() { + @Override + public void run() { + List<QYTUserInfo> userInfoByPhone = UserUtil.getUserInfoByPhone(tBranchOffice.getAccount(), finalEnterCode); + if(null != userInfoByPhone && userInfoByPhone.size() > 0){ + Long empId1 = userInfoByPhone.get(0).getEmpId(); + finalUser.setEmpId(empId1); + userService.updateById(finalUser); + } + } + },120*1000); + } }else { if (!tBranchOffice.getAccount().equals(user.getAccount())){ //判断账号是否已存在 @@ -695,7 +852,6 @@ return new SuccessTip(500,"该账号已存在!"); } } - user.setAccount(tBranchOffice.getAccount()); user.setPassword(ShiroKit.md5(tBranchOffice.getPassword(), user.getSalt())); userService.updateById(user); } -- Gitblit v1.7.1