|
@@ -0,0 +1,355 @@
|
|
|
+package com.tianhu.system.controller;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.tianhu.common.core.domain.R;
|
|
|
+import com.tianhu.common.core.utils.CommonUtil;
|
|
|
+import com.tianhu.common.core.utils.DateUtils;
|
|
|
+import com.tianhu.common.core.utils.IdUtils;
|
|
|
+import com.tianhu.common.core.utils.SecurityUtils;
|
|
|
+import com.tianhu.common.core.web.controller.BaseController;
|
|
|
+import com.tianhu.common.core.web.domain.AjaxResult;
|
|
|
+import com.tianhu.common.core.web.page.TableDataInfo;
|
|
|
+import com.tianhu.common.log.annotation.Log;
|
|
|
+import com.tianhu.common.log.enums.BusinessType;
|
|
|
+import com.tianhu.common.security.annotation.PreAuthorize;
|
|
|
+import com.tianhu.common.security.service.TokenService;
|
|
|
+import com.tianhu.system.api.domain.SysDept;
|
|
|
+import com.tianhu.system.api.domain.SysRole;
|
|
|
+import com.tianhu.system.api.domain.SysUser;
|
|
|
+import com.tianhu.system.api.model.LoginUser;
|
|
|
+import com.tianhu.system.domain.SysCompany;
|
|
|
+import com.tianhu.system.domain.SysManagementInf;
|
|
|
+import com.tianhu.system.domain.SysUserCompanyRel;
|
|
|
+import com.tianhu.system.service.*;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+import java.util.Date;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 资方管理Controller
|
|
|
+ *
|
|
|
+ * @author cuixq
|
|
|
+ * @date 2021-08-17
|
|
|
+ */
|
|
|
+@RestController
|
|
|
+@RequestMapping("/fundSide")
|
|
|
+public class OwnManagementInfController extends BaseController
|
|
|
+{
|
|
|
+ @Autowired
|
|
|
+ private IOwnCompanyService companyService;
|
|
|
+ @Autowired
|
|
|
+ private IOwnManagementInfService ownManagementInfService;
|
|
|
+ @Autowired
|
|
|
+ private ISysManagementInfService sysManagementInfService;
|
|
|
+ @Autowired
|
|
|
+ private ISysUserCompanyRelService sysUserCompanyRelService;
|
|
|
+ @Autowired
|
|
|
+ private ISysCompanyService sysCompanyService;
|
|
|
+ @Autowired
|
|
|
+ private ISysDeptService deptService;
|
|
|
+ @Autowired
|
|
|
+ private ISysRoleService roleService;
|
|
|
+ @Autowired
|
|
|
+ private ISysUserService userService;
|
|
|
+ @Autowired
|
|
|
+ private TokenService tokenService;
|
|
|
+ @Autowired
|
|
|
+ private ISysConfigService configService;
|
|
|
+ /**
|
|
|
+ * 公司状态(正常)
|
|
|
+ */
|
|
|
+ private String staust_00 = "00";
|
|
|
+ /**
|
|
|
+ * 公司类型(资方)
|
|
|
+ */
|
|
|
+ private String type_03 = "03";
|
|
|
+ /**
|
|
|
+ * 默认父级id
|
|
|
+ */
|
|
|
+ private Long defaultId = 0L;
|
|
|
+ /**
|
|
|
+ * 默认祖级列表
|
|
|
+ */
|
|
|
+ private String defaultAn = "0";
|
|
|
+ /**
|
|
|
+ * 默认排序
|
|
|
+ */
|
|
|
+ private String defaultOrder = "1";
|
|
|
+ /**
|
|
|
+ * 数据权限1全部
|
|
|
+ */
|
|
|
+ private String dataScope = "1";
|
|
|
+ /**
|
|
|
+ * 是否关联显示
|
|
|
+ */
|
|
|
+ private boolean isCheck = true;
|
|
|
+ /**
|
|
|
+ * 默认状态0正常
|
|
|
+ */
|
|
|
+ private String status = "0";
|
|
|
+ /**
|
|
|
+ * 自动创建
|
|
|
+ */
|
|
|
+ private String isAuto = "1";
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询资方列表
|
|
|
+ */
|
|
|
+ @PreAuthorize(hasPermi = "fundSide:fundSide:list")
|
|
|
+ @GetMapping("/list")
|
|
|
+ public TableDataInfo list(String scyName,String smiType,String smiManager,String smiContract,String smiContractPhone)
|
|
|
+ {
|
|
|
+ startPage();
|
|
|
+ Map map = new HashMap<>();
|
|
|
+ map.put("scyName",scyName);
|
|
|
+ map.put("smiType",smiType);
|
|
|
+ map.put("smiManager",smiManager);
|
|
|
+ map.put("smiContract",smiContract);
|
|
|
+ map.put("smiContractPhone",smiContractPhone);
|
|
|
+ List<Map> list = ownManagementInfService.selectFundSide(map);
|
|
|
+ return getDataTable(list);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询企业详情
|
|
|
+ */
|
|
|
+// @PreAuthorize(hasPermi = "system:company:details")
|
|
|
+ @GetMapping("details/{scyId}")
|
|
|
+ public AjaxResult details(@PathVariable("scyId") String scyId)throws Exception {
|
|
|
+ LoginUser user = tokenService.getLoginUser();
|
|
|
+ Map map = new HashMap<>();
|
|
|
+ map.put("scyId",scyId);
|
|
|
+ List<Map> list = ownManagementInfService.selectFundSide(map);
|
|
|
+ return AjaxResult.success(list);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 资方状态修改
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @PreAuthorize(hasPermi = "fundSide:fundSide:edit")
|
|
|
+ @Log(title = "资方状态修改", businessType = BusinessType.UPDATE)
|
|
|
+ @PutMapping("/fundSideStatus")
|
|
|
+ public R fundSideStatus(@RequestBody SysCompany company)
|
|
|
+ {
|
|
|
+ //获取当前操作人员
|
|
|
+ LoginUser userInfo = tokenService.getLoginUser();
|
|
|
+ SysUser use = userInfo.getSysUser();
|
|
|
+ //修改人
|
|
|
+ company.setUpdateBy(use.getUserId()+"");
|
|
|
+ //获取当前时间
|
|
|
+ Date currentTime = DateUtils.getNowDate();
|
|
|
+ //修改时间
|
|
|
+ company.setUpdateTime(currentTime);
|
|
|
+ sysCompanyService.updateSysCompany(company);
|
|
|
+ return R.ok();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 新增资方公司
|
|
|
+ */
|
|
|
+ @PreAuthorize(hasPermi = "fundSide:fundSide:add")
|
|
|
+ @Log(title = "新增资方公司", businessType = BusinessType.INSERT)
|
|
|
+ @Transactional(rollbackFor=Exception.class)
|
|
|
+ @PostMapping("/addFundSide")
|
|
|
+ public R addFundSide(@RequestBody Map<String,Object> map){
|
|
|
+ String scyName = CommonUtil.objToString(map.get("scyName"));
|
|
|
+ if(CommonUtil.isEmpty(scyName)){
|
|
|
+ return R.fail("资金方名称不可为空");
|
|
|
+ }
|
|
|
+ String smiType = CommonUtil.objToString(map.get("smiType"));
|
|
|
+ if(CommonUtil.isEmpty(smiType)){
|
|
|
+ return R.fail("资金方类型不可为空");
|
|
|
+ }
|
|
|
+ String smiAgreementType = CommonUtil.objToString(map.get("smiAgreementType"));
|
|
|
+ if(CommonUtil.isEmpty(smiAgreementType)){
|
|
|
+ return R.fail("合作协议签署不可为空");
|
|
|
+ }
|
|
|
+ String smiAddress = CommonUtil.objToString(map.get("smiAddress"));
|
|
|
+ if(CommonUtil.isEmpty(smiAddress)){
|
|
|
+ return R.fail("资金方网点不可为空");
|
|
|
+ }
|
|
|
+ String scySocialCode = CommonUtil.objToString(map.get("scySocialCode"));
|
|
|
+ if(CommonUtil.isEmpty(scySocialCode)){
|
|
|
+ return R.fail("社会统一代码不可为空");
|
|
|
+ }
|
|
|
+ String smiManager = CommonUtil.objToString(map.get("smiManager"));
|
|
|
+ if(CommonUtil.isEmpty(smiManager)){
|
|
|
+ return R.fail("客户经理不可为空");
|
|
|
+ }
|
|
|
+ String smiContract = CommonUtil.objToString(map.get("smiContract"));
|
|
|
+ if(CommonUtil.isEmpty(smiContract)){
|
|
|
+ return R.fail("联系人姓名不可为空");
|
|
|
+ }
|
|
|
+ String smiContractPhone = CommonUtil.objToString(map.get("smiContractPhone"));
|
|
|
+ if(CommonUtil.isEmpty(smiContractPhone)){
|
|
|
+ return R.fail("联系人电话不可为空");
|
|
|
+ }
|
|
|
+ String smiDesc = CommonUtil.objToString(map.get("smiDesc"));
|
|
|
+ List<Map<String,String>> smiAgreement = (List<Map<String, String>>) map.get("smiAgreement");
|
|
|
+ LambdaQueryWrapper<SysCompany> queryWrapper = new LambdaQueryWrapper();
|
|
|
+ queryWrapper.eq(SysCompany::getScyName,scyName);
|
|
|
+ List<SysCompany> list = sysCompanyService.findSysCompanys(queryWrapper);
|
|
|
+ SysCompany company = new SysCompany();
|
|
|
+ if(list.size()>0){
|
|
|
+ return R.fail("公司名称已存在");
|
|
|
+ }
|
|
|
+ LoginUser userInfo = tokenService.getLoginUser();
|
|
|
+ String scyId = IdUtils.fastSimpleUUID();
|
|
|
+ //创建用户
|
|
|
+ company.setScyId(scyId);
|
|
|
+ company.setScyName(scyName);
|
|
|
+ company.setScyStatus(staust_00);
|
|
|
+ company.setScyType(type_03);
|
|
|
+ company.setScySocialCode(scySocialCode);
|
|
|
+ //获取创建人
|
|
|
+ SysUser use = userInfo.getSysUser();
|
|
|
+ company.setCreateBy(use.getUserId()+"");
|
|
|
+ sysCompanyService.createSysCompany(company);
|
|
|
+ //创建部门
|
|
|
+ SysDept dept = new SysDept();
|
|
|
+ dept.setCompanyId(scyId);
|
|
|
+ dept.setDeptName(scyName);
|
|
|
+ dept.setParentId(defaultId);
|
|
|
+ dept.setAncestors(defaultAn);
|
|
|
+ dept.setOrderNum(defaultOrder);
|
|
|
+ dept.setCreateBy(use.getUserId()+"");
|
|
|
+ deptService.insertDept(dept);
|
|
|
+ List<SysDept> deptList= deptService.selectDeptList(dept);
|
|
|
+ //部门id
|
|
|
+ Long deptId = deptList.get(0).getDeptId();
|
|
|
+ //创建角色
|
|
|
+ SysRole sysRole = new SysRole();
|
|
|
+ sysRole.setCompanyId(scyId);
|
|
|
+ sysRole.setRoleName(scyName);
|
|
|
+ sysRole.setRoleSort(defaultOrder);
|
|
|
+ sysRole.setDataScope(dataScope);
|
|
|
+ sysRole.setMenuCheckStrictly(isCheck);
|
|
|
+ sysRole.setDeptCheckStrictly(isCheck);
|
|
|
+ sysRole.setStatus(status);
|
|
|
+ sysRole.setStatus("0");
|
|
|
+ sysRole.setCreateBy(use.getUserId()+"");
|
|
|
+ sysRole.setIsAuto("1");
|
|
|
+ companyService.insertRole(sysRole);
|
|
|
+ List<SysRole> roleList= roleService.selectRoleList(sysRole);
|
|
|
+ //角色id
|
|
|
+ Long roleId = roleList.get(0).getRoleId();
|
|
|
+ Long[] roleIds = new Long[1];
|
|
|
+ roleIds[0] = roleId;
|
|
|
+ //创建用户
|
|
|
+ SysUser sysUser = new SysUser();
|
|
|
+ SysUser listUser = userService.selectUserByUserName(smiContractPhone);
|
|
|
+ if(listUser == null){
|
|
|
+ sysUser.setUserName(smiContractPhone);
|
|
|
+ sysUser.setNickName(smiContract);
|
|
|
+ String password = configService.selectConfigByKey("sys.user.initPassword");
|
|
|
+ sysUser.setPassword(SecurityUtils.encryptPassword(password));
|
|
|
+ sysUser.setCreateBy(use.getUserId()+"");
|
|
|
+ sysUser.setRoleIds(roleIds);
|
|
|
+ userService.insertUser(sysUser);
|
|
|
+ } else {
|
|
|
+ listUser.setRoleIds(roleIds);
|
|
|
+ userService.insertUserRole(listUser);
|
|
|
+ }
|
|
|
+ SysUser listUserTwo = userService.selectUserByUserName(smiContractPhone);
|
|
|
+ //创建资方信息
|
|
|
+ SysManagementInf sysManagementInf =new SysManagementInf();
|
|
|
+ sysManagementInf.setSmiCompanyId(scyId);
|
|
|
+ sysManagementInf.setSmiType(smiType);
|
|
|
+ sysManagementInf.setSmiAgreementType(smiAgreementType);
|
|
|
+ sysManagementInf.setSmiAddress(smiAddress);
|
|
|
+ sysManagementInf.setSmiManager(smiManager);
|
|
|
+ sysManagementInf.setSmiContractId(listUserTwo.getUserId());
|
|
|
+ sysManagementInf.setSmiDesc(smiDesc);
|
|
|
+ sysManagementInfService.createSysManagementInf(sysManagementInf);
|
|
|
+ SysUserCompanyRel sysUserCompanyRel =new SysUserCompanyRel();
|
|
|
+ sysUserCompanyRel.setSucrCompanyId(scyId);
|
|
|
+ sysUserCompanyRel.setSucrUserId(listUserTwo.getUserId());
|
|
|
+ sysUserCompanyRel.setSucrDeptId(deptId);
|
|
|
+ sysUserCompanyRel.setSucrHandler("1");
|
|
|
+ sysUserCompanyRelService.createSysUserCompanyRel(sysUserCompanyRel);
|
|
|
+ return R.ok();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 修改资方公司
|
|
|
+ */
|
|
|
+ @PreAuthorize(hasPermi = "fundSide:fundSide:edit")
|
|
|
+ @Log(title = "修改资方公司", businessType = BusinessType.UPDATE)
|
|
|
+ @Transactional(rollbackFor=Exception.class)
|
|
|
+ @PostMapping("/editFundSide")
|
|
|
+ public R editFundSide(@RequestBody Map<String,Object> map) {
|
|
|
+ String scyId = CommonUtil.objToString(map.get("scyId"));
|
|
|
+ String scyName = CommonUtil.objToString(map.get("scyName"));
|
|
|
+ if(CommonUtil.isEmpty(scyName)){
|
|
|
+ return R.fail("资金方名称不可为空");
|
|
|
+ }
|
|
|
+ String smiType = CommonUtil.objToString(map.get("smiType"));
|
|
|
+ if(CommonUtil.isEmpty(smiType)){
|
|
|
+ return R.fail("资金方类型不可为空");
|
|
|
+ }
|
|
|
+ String smiAgreementType = CommonUtil.objToString(map.get("smiAgreementType"));
|
|
|
+ if(CommonUtil.isEmpty(smiAgreementType)){
|
|
|
+ return R.fail("合作协议签署不可为空");
|
|
|
+ }
|
|
|
+ String smiAddress = CommonUtil.objToString(map.get("smiAddress"));
|
|
|
+ if(CommonUtil.isEmpty(smiAddress)){
|
|
|
+ return R.fail("资金方网点不可为空");
|
|
|
+ }
|
|
|
+ String scySocialCode = CommonUtil.objToString(map.get("scySocialCode"));
|
|
|
+ if(CommonUtil.isEmpty(scySocialCode)){
|
|
|
+ return R.fail("社会统一代码不可为空");
|
|
|
+ }
|
|
|
+ String smiManager = CommonUtil.objToString(map.get("smiManager"));
|
|
|
+ if(CommonUtil.isEmpty(smiManager)){
|
|
|
+ return R.fail("客户经理不可为空");
|
|
|
+ }
|
|
|
+ String smiContract = CommonUtil.objToString(map.get("smiContract"));
|
|
|
+ if(CommonUtil.isEmpty(smiContract)){
|
|
|
+ return R.fail("联系人姓名不可为空");
|
|
|
+ }
|
|
|
+ String smiContractPhone = CommonUtil.objToString(map.get("smiContractPhone"));
|
|
|
+ if(CommonUtil.isEmpty(smiContractPhone)){
|
|
|
+ return R.fail("联系人电话不可为空");
|
|
|
+ }
|
|
|
+ String smiDesc = CommonUtil.objToString(map.get("smiDesc"));
|
|
|
+ List<Map<String,String>> smiAgreement = (List<Map<String, String>>) map.get("smiAgreement");
|
|
|
+ LambdaQueryWrapper<SysCompany> queryWrapper = new LambdaQueryWrapper();
|
|
|
+ queryWrapper.eq(SysCompany::getScyName,scyName);
|
|
|
+ queryWrapper.ne(SysCompany::getScyId,scyId);
|
|
|
+ List<SysCompany> list = sysCompanyService.findSysCompanys(queryWrapper);
|
|
|
+ SysCompany company = new SysCompany();
|
|
|
+ company.setScyId(scyId);
|
|
|
+ if(list.size()>0){
|
|
|
+ return R.fail("公司名称已存在");
|
|
|
+ }
|
|
|
+ company.setScyName(scyName);
|
|
|
+ company.setScySocialCode(scySocialCode);
|
|
|
+ //获取修改人
|
|
|
+ LoginUser userInfo = tokenService.getLoginUser();
|
|
|
+ SysUser use = userInfo.getSysUser();
|
|
|
+ company.setUpdateBy(use.getUserId()+"");
|
|
|
+ //获取当前时间
|
|
|
+ Date currentTime = DateUtils.getNowDate();
|
|
|
+ company.setUpdateTime(currentTime);
|
|
|
+ sysCompanyService.updateSysCompany(company);
|
|
|
+ //创建资方信息
|
|
|
+ SysManagementInf sysManagementInf =new SysManagementInf();
|
|
|
+ sysManagementInf.setSmiCompanyId(scyId);
|
|
|
+ sysManagementInf.setSmiType(smiType);
|
|
|
+ sysManagementInf.setSmiAgreementType(smiAgreementType);
|
|
|
+ sysManagementInf.setSmiAddress(smiAddress);
|
|
|
+ sysManagementInf.setSmiManager(smiManager);
|
|
|
+ sysManagementInf.setSmiDesc(smiDesc);
|
|
|
+ sysManagementInfService.updateSysManagementInf(sysManagementInf);
|
|
|
+ return R.ok();
|
|
|
+ }
|
|
|
+}
|