| | |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | 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.shiro.ShiroUser; |
| | | import com.stylefeng.guns.core.util.SinataUtil; |
| | | import com.stylefeng.guns.core.util.ToolUtil; |
| | | import com.stylefeng.guns.modular.system.model.*; |
| | | import com.stylefeng.guns.modular.system.service.ITCompanyCityService; |
| | | import com.stylefeng.guns.modular.system.service.ITRegionService; |
| | | import com.stylefeng.guns.modular.system.service.IUserService; |
| | | 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 org.springframework.stereotype.Controller; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.ResponseBody; |
| | |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | import com.stylefeng.guns.modular.system.service.ITCompanyService; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.*; |
| | | |
| | | /** |
| | | * 分公司管理控制器 |
| | |
| | | |
| | | @Autowired |
| | | private ITCompanyCityService tCompanyCityService; |
| | | |
| | | @Autowired |
| | | private ShiroExtUtil shiroExtUtil; |
| | | |
| | | /** |
| | | * 跳转到修改平台信息 |
| | |
| | | if (count > 0){ |
| | | return "error"; |
| | | } |
| | | if(ToolUtil.isEmpty(tCompany.getIdentifier())){ |
| | | return "统一社会信用代码不能为空"; |
| | | } |
| | | //调用中台接口创建企业 |
| | | CheckEnterExist checkEnterExist = EnterpriseUtil.checkEnterExistByEnterIdCardNo(tCompany.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(tCompany.getName()); |
| | | request.setNickName(tCompany.getName()); |
| | | request.setUscc(tCompany.getIdentifier()); |
| | | request.setIndustry_code("292"); |
| | | request.setMobile(account); |
| | | CreateEnterprise enterprise = EnterpriseUtil.createEnterprise(request); |
| | | enterCode = enterprise.getIdCode(); |
| | | enterNew = 1; |
| | | List<QYTUserInfo> userInfoByPhone = UserUtil.getUserInfoByPhone(account, 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(account, enterCode); |
| | | if(null == userInfoByPhone ||userInfoByPhone.size() == 0){ |
| | | //负责人不匹配,则创建新的员工到中台 |
| | | SaveStaffNodeRequest request = new SaveStaffNodeRequest(); |
| | | request.setMobile(checkEnterExist.getMobile()); |
| | | request.setEntercode(enterCode); |
| | | request.setEmpName(tCompany.getName() + "管理员"); |
| | | request.setEmpNickname(tCompany.getName() + "管理员"); |
| | | request.setLoginNo(account); |
| | | request.setEmpSex("男"); |
| | | request.setMphone(account); |
| | | request.setEmail(account + "@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; |
| | | } |
| | | } |
| | | |
| | | tCompany.setEnterCode(enterCode); |
| | | tCompany.setEnterNew(enterNew); |
| | | tCompany.setType(2); //2:分公司 |
| | | tCompany.setState(0); //0:正常 |
| | | tCompany.setInsertTime(new Date()); |
| | |
| | | user.setObjectId(tCompany.getId()); |
| | | user.setName(tCompany.getName()); |
| | | 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; |
| | | timer.schedule(new TimerTask() { |
| | | @Override |
| | | public void run() { |
| | | List<QYTUserInfo> userInfoByPhone = UserUtil.getUserInfoByPhone(account, finalEnterCode); |
| | | if(null != userInfoByPhone && userInfoByPhone.size() > 0){ |
| | | Long empId1 = userInfoByPhone.get(0).getEmpId(); |
| | | user.setEmpId(empId1); |
| | | userService.updateById(user); |
| | | } |
| | | } |
| | | },120*1000); |
| | | } |
| | | //添加经营区域 |
| | | addSocpe(subArr,tCompany.getId()); |
| | | return SUCCESS_TIP; |
| | | } |
| | | |
| | | |
| | | |
| | | //添加经营区域 |
| | | public void addSocpe(String subArr,Integer id){ |
| | | JSONArray jsonArray = JSON.parseArray(subArr); |
| | |
| | | if (count > 0){ |
| | | return "error"; |
| | | } |
| | | if(ToolUtil.isEmpty(tCompany.getIdentifier())){ |
| | | return "统一社会信用代码不能为空"; |
| | | } |
| | | //调用中台接口创建企业 |
| | | CheckEnterExist checkEnterExist = EnterpriseUtil.checkEnterExistByEnterIdCardNo(tCompany.getIdentifier()); |
| | | String enterCode = ""; |
| | | Long empId = null; |
| | | Integer empnew = null; |
| | | Integer enterNew = null; |
| | | |
| | | //企业未注册,进行注册 |
| | | if (null == checkEnterExist || "0".equals(checkEnterExist.getIsReg())) { |
| | | CreateEnterpriseRequest request = new CreateEnterpriseRequest(); |
| | | request.setName(tCompany.getName()); |
| | | request.setNickName(tCompany.getName()); |
| | | request.setUscc(tCompany.getIdentifier()); |
| | | request.setIndustry_code("292"); |
| | | request.setMobile(account); |
| | | CreateEnterprise enterprise = EnterpriseUtil.createEnterprise(request); |
| | | enterCode = enterprise.getIdCode(); |
| | | enterNew = 1; |
| | | List<QYTUserInfo> userInfoByPhone = UserUtil.getUserInfoByPhone(account, 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(); |
| | | List<QYTUserInfo> userInfoByPhone = UserUtil.getUserInfoByPhone(account, enterCode); |
| | | enterNew = 0; |
| | | if(null == userInfoByPhone || userInfoByPhone.size() == 0){ |
| | | SaveStaffNodeRequest request = new SaveStaffNodeRequest(); |
| | | request.setMobile(checkEnterExist.getMobile()); |
| | | request.setEntercode(enterCode); |
| | | request.setEmpName(tCompany.getName() + "管理员"); |
| | | request.setEmpNickname(tCompany.getName() + "管理员"); |
| | | request.setLoginNo(account); |
| | | request.setEmpSex("女"); |
| | | request.setMphone(account); |
| | | request.setEmail(account + "@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; |
| | | } |
| | | } |
| | | |
| | | tCompany.setEnterCode(enterCode); |
| | | tCompany.setEnterNew(enterNew); |
| | | tCompany.setType(3); //2:分公司 |
| | | if (ShiroKit.getUser().getRoleType() == 2){ |
| | | tCompany.setSuperiorId(ShiroKit.getUser().getObjectId()); |
| | |
| | | user.setObjectId(tCompany.getId()); |
| | | user.setName(tCompany.getName()); |
| | | 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; |
| | | timer.schedule(new TimerTask() { |
| | | @Override |
| | | public void run() { |
| | | List<QYTUserInfo> userInfoByPhone = UserUtil.getUserInfoByPhone(account, finalEnterCode); |
| | | if(null != userInfoByPhone && userInfoByPhone.size() > 0){ |
| | | Long empId1 = userInfoByPhone.get(0).getEmpId(); |
| | | user.setEmpId(empId1); |
| | | userService.updateById(user); |
| | | } |
| | | } |
| | | },120*1000); |
| | | } |
| | | return SUCCESS_TIP; |
| | | } |
| | | |
| | |
| | | @ResponseBody |
| | | public Object delete(@RequestParam Integer tCompanyId) { |
| | | TCompany tCompany = tCompanyService.selectById(tCompanyId); |
| | | //调用中台接口创建企业 |
| | | if(1 == tCompany.getEnterNew()){ |
| | | CheckEnterExist checkEnterExist = EnterpriseUtil.checkEnterExistByEnterIdCardNo(tCompany.getIdentifier()); |
| | | if (null != checkEnterExist && "1".equals(checkEnterExist.getIsReg())) { |
| | | ShiroUser user1 = shiroExtUtil.getUser(); |
| | | User user = userService.selectById(user1.getId()); |
| | | ResultUtil resultUtil = EnterpriseUtil.delEnterprise(checkEnterExist.getEnterCode(), user.getPhone()); |
| | | if(resultUtil.getStatus() != 200){ |
| | | return new ErrorTip(resultUtil.getStatus(), resultUtil.getMsg()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | tCompany.setFlag("3"); |
| | | tCompanyService.updateById(tCompany); |
| | | return SUCCESS_TIP; |