| | |
| | | package org.springblade.modules.information.controller; |
| | | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | |
| | | import org.springblade.core.boot.ctrl.BladeController; |
| | | import org.springblade.core.cache.utils.CacheUtil; |
| | | import org.springblade.core.excel.util.ExcelUtil; |
| | | import org.springblade.core.log.exception.ServiceException; |
| | | import org.springblade.core.mp.support.Condition; |
| | | import org.springblade.core.mp.support.Query; |
| | | import org.springblade.core.tool.api.R; |
| | | import org.springblade.core.tool.support.Kv; |
| | | import org.springblade.core.tool.utils.DigestUtil; |
| | | import org.springblade.core.tool.utils.Func; |
| | | import org.springblade.core.tool.utils.StringUtil; |
| | | import org.springblade.modules.FTP.FtpUtil; |
| | | import org.springblade.modules.FTP.OutJson; |
| | | import org.springblade.modules.information.entity.Information; |
| | |
| | | import org.springblade.modules.information.service.IInformationService; |
| | | import org.springblade.modules.information.vo.InformationVO; |
| | | import org.springblade.modules.system.entity.Dept; |
| | | import org.springblade.modules.system.entity.Role; |
| | | import org.springblade.modules.system.entity.User; |
| | | import org.springblade.modules.system.service.IDeptService; |
| | | import org.springblade.modules.system.service.IRoleService; |
| | | import org.springblade.modules.system.service.IUserService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import org.springframework.web.multipart.MultipartFile; |
| | | |
| | |
| | | |
| | | private final IInformationService informationService; |
| | | private final IDeptService iDeptService; |
| | | |
| | | |
| | | private final IUserService userService; |
| | | |
| | | private final IRoleService roleService; |
| | | |
| | | /** |
| | | * 详情 |
| | |
| | | @PostMapping("/save") |
| | | @ApiOperationSupport(order = 4) |
| | | @ApiOperation(value = "新增", notes = "传入information") |
| | | public R save(@Valid @RequestBody Information information) throws Exception { |
| | | public R save(@Valid @RequestBody Information information){ |
| | | Dept dept = new Dept(); |
| | | //自招保安公司 |
| | | if (information.getStats().equals("0")) { |
| | |
| | | String id = kv.get("id").toString(); |
| | | information.setDepartmentid(id); |
| | | } |
| | | informationService.save(information); |
| | | String formatStr = new SimpleDateFormat("yyyy-MM-dd").format(information.getEstablishtime()); |
| | | |
| | | //公司新增 |
| | | boolean status = informationService.save(information); |
| | | |
| | | //公司新增成功则创建默认账户,公司名即为账号名,默认密码为 123456 |
| | | if (status) { |
| | | User user = new User(); |
| | | user.setAccount(information.getEnterprisename()); |
| | | user.setPassword(DigestUtil.encrypt("123456")); |
| | | Integer userCount = userService.selectCount(information.getEnterprisename()); |
| | | if (userCount > 0 && Func.isEmpty(user.getId())) { |
| | | throw new ServiceException(StringUtil.format("当前用户 [{}] 已存在!", user.getAccount())); |
| | | } |
| | | user.setDeptId(information.getDepartmentid()); |
| | | user.setTenantId("000000"); |
| | | user.setCreateTime(new Date()); |
| | | user.setUpdateTime(new Date()); |
| | | user.setStatus(1); |
| | | user.setIsDeleted(0); |
| | | //分配保安角色 |
| | | Role role = new Role(); |
| | | role.setRoleAlias("保安公司管理员"); |
| | | Role oneRole = roleService.getOne(Condition.getQueryWrapper(role)); |
| | | user.setRoleId(oneRole.getId().toString()); |
| | | //插入用户数据 |
| | | userService.save(user); |
| | | |
| | | Integer isDeleted = 0; |
| | | //Integer id = information.getId(); |
| | | String s = "insert into sys_information(id,creditCode,enterpriseName,representative,establishTime," + |
| | | "registeredCapital,organizationCode,registrationNumber, enterprises, address," + |
| | | String s = "insert into sys_information(id,creditCode,enterpriseName,representative" + |
| | | ",registeredCapital,organizationCode,registrationNumber, enterprises, address," + |
| | | " business,region,registration,industry,departmentid,stats,jurisdiction,representativecell,contacts,contactscell) " + |
| | | "values(" + "'" + information.getId() + "'" + "," + "'" + information.getCreditcode() + "'" + "," + "'" + information.getEnterprisename() + "'" + "," + "'" + information.getRepresentative() + "'" + "," + |
| | | "'" + formatStr + "'" + "," + "'" + information.getRegisteredcapital() + "'" + "," + "'" + information.getOrganizationcode() + "'" + "," + "'" + information.getRegistrationnumber() + "'" + "," + "'" + information.getEnterprises() + "'" + "," + "'" + |
| | | information.getAddress() + "'" + "," + "'" + information.getBusiness() + "'" + "," + "'" + |
| | | information.getRegion() + "'" + "," + "'" + information.getRegistration() + "'" + "," + "'" + information.getIndustry() + "'" + "," + "'" + information.getDepartmentid() + "'" + "," + |
| | | "'" + information.getStats() + "'" + "," + "'" + information.getJurisdiction() + "'" + "," + "'" + information.getRepresentativecell() + "'" + "," + |
| | | "'" + information.getContacts() + "'" + "," + "'" + information.getContactscell() + "'" + ");" + |
| | | "values(" + "'" + information.getId() + "'" + |
| | | "," + "'" + information.getCreditcode() + "'" + |
| | | "," + "'" + information.getEnterprisename() + "'" + |
| | | "," + "'" + information.getRepresentative() + "'" + |
| | | "," + "'" + information.getRegisteredcapital() + "'" + |
| | | "," + "'" + information.getOrganizationcode() + "'" + |
| | | "," + "'" + information.getRegistrationnumber() + "'" + |
| | | "," + "'" + information.getEnterprises() + "'" + |
| | | "," + "'" + information.getAddress() + "'" + |
| | | "," + "'" + information.getBusiness() + "'" + |
| | | "," + "'" + information.getRegion() + "'" + |
| | | "," + "'" + information.getRegistration() + "'" + |
| | | "," + "'" + information.getIndustry() + "'" + |
| | | "," + "'" + information.getDepartmentid() + "'" + |
| | | "," + "'" + information.getStats() + "'" + |
| | | "," + "'" + information.getJurisdiction() + "'" + |
| | | "," + "'" + information.getRepresentativecell() + "'" + |
| | | "," + "'" + information.getContacts() + "'" + |
| | | "," + "'" + information.getContactscell() + "'" + ");" + |
| | | "insert into blade_dept(id,parent_id,tenant_id,dept_name,ancestors,dept_category,is_deleted) values(" + "'" + information.getDepartmentid() + "'" + "," + "'" + dept.getParentId() + "'" + "," |
| | | + "'" + dept.getTenantId() + "'" + |
| | | "," + "'" + information.getEnterprisename() + "'" + |
| | | "," + "'" + dept.getAncestors() + "'" + |
| | | "," + "'" + dept.getDeptCategory() + "'" + |
| | | "," + "'" + isDeleted + "'" + ")"; |
| | | "," + "'" + isDeleted + "'" + ");" + |
| | | "insert into blade_user(id,tenant_id,account,password,role_id,dept_id,create_time,update_time,status,is_deleted) " + |
| | | "values(" + "'" + user.getId() + "'" + |
| | | "," + "'" + user.getTenantId() + "'" |
| | | + "," + "'" + user.getAccount() + "'" + |
| | | "," + "'" + user.getPassword() + "'" + |
| | | "," + "'" + user.getRoleId() + "'" + |
| | | "," + "'" + user.getDeptId() + "'" + |
| | | "," + "'" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(user.getCreateTime()) + "'" + |
| | | "," + "'" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(user.getUpdateTime()) + "'" + |
| | | "," + "'" + user.getStatus() + "'" + |
| | | "," + "'" + user.getIsDeleted() + "'" + ")"; |
| | | FtpUtil.sqlFileUpload(s); |
| | | } |
| | | return R.success("成功"); |
| | | } |
| | | |