|
|
@ -1,14 +1,33 @@ |
|
|
|
package com.kms.enterprise.controller; |
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.Arrays; |
|
|
|
import java.util.Date; |
|
|
|
import java.util.List; |
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
import cn.dev33.satoken.stp.StpUtil; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
import com.jianwei.common.core.controller.BaseController; |
|
|
|
import com.jianwei.common.core.domain.SearchParam; |
|
|
|
import com.jianwei.common.core.domain.entity.SysDept; |
|
|
|
import com.jianwei.common.core.domain.entity.SysRole; |
|
|
|
import com.jianwei.common.core.domain.entity.SysUser; |
|
|
|
import com.jianwei.common.mybaitsplus.WrapperUtils; |
|
|
|
import com.jianwei.common.utils.poi.ExcelUtil; |
|
|
|
import com.kms.common.utils.BaseEntityUtils; |
|
|
|
|
|
|
|
|
|
|
|
import com.kms.common.utils.UserUtils; |
|
|
|
import com.kms.enterprise.domain.BsSgcYxjdCreditApproval; |
|
|
|
import com.kms.enterprise.service.BsSgcYxjdCreditApprovalService; |
|
|
|
import com.kms.framework.manager.factory.AsyncFactory; |
|
|
|
import com.kms.system.domain.SysUserRole; |
|
|
|
import com.kms.system.service.SysDeptService; |
|
|
|
import com.kms.system.service.SysRoleService; |
|
|
|
import com.kms.system.service.SysUserRoleService; |
|
|
|
import com.kms.system.service.SysUserService; |
|
|
|
import io.swagger.annotations.Api; |
|
|
|
import io.swagger.annotations.ApiOperation; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
@ -40,19 +59,64 @@ import com.kms.enterprise.service.BsSgcYxjdDynamicCreditService; |
|
|
|
@RestController |
|
|
|
@RequestMapping("/enterprise/credit") |
|
|
|
@Api(tags = "动态信用") |
|
|
|
public class BsSgcYxjdDynamicCreditController extends BaseController |
|
|
|
{ |
|
|
|
public class BsSgcYxjdDynamicCreditController extends BaseController { |
|
|
|
@Autowired |
|
|
|
private BsSgcYxjdDynamicCreditService bsSgcYxjdDynamicCreditService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private BsSgcYxjdCreditApprovalService bsSgcYxjdCreditApprovalService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private SysUserService sysUserService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private SysDeptService sysDeptService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private SysUserRoleService sysUserRoleService; |
|
|
|
|
|
|
|
@Autowired |
|
|
|
private SysRoleService sysRoleService; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 查询动态信用列表 |
|
|
|
*/ |
|
|
|
@PostMapping("/list") |
|
|
|
@ApiOperation("动态信用列表") |
|
|
|
public IPage list(@RequestBody SearchParam<BsSgcYxjdDynamicCredit> sp) |
|
|
|
{ |
|
|
|
return bsSgcYxjdDynamicCreditService.selectPage(sp); |
|
|
|
public IPage list(@RequestBody SearchParam<BsSgcYxjdDynamicCredit> sp) { |
|
|
|
|
|
|
|
SysUser user = UserUtils.getUser(); |
|
|
|
if (user.getUserName().equals("admin")) { |
|
|
|
return bsSgcYxjdDynamicCreditService.selectPage(sp); |
|
|
|
} else { |
|
|
|
LambdaQueryWrapper<SysUserRole> lambdaQuery = Wrappers.lambdaQuery(SysUserRole.class); |
|
|
|
|
|
|
|
lambdaQuery.eq(SysUserRole::getUserId, user.getId()); |
|
|
|
|
|
|
|
SysUserRole userRole = sysUserRoleService.getOne(lambdaQuery); |
|
|
|
|
|
|
|
SysRole byId = sysRoleService.getById(userRole.getRoleId()); |
|
|
|
List<BsSgcYxjdDynamicCredit> creditList = new ArrayList<>(); |
|
|
|
|
|
|
|
if (byId.getRoleName().equals("企业审核员")) { |
|
|
|
LambdaQueryWrapper<BsSgcYxjdDynamicCredit> queryWrapper = Wrappers.lambdaQuery(BsSgcYxjdDynamicCredit.class); |
|
|
|
queryWrapper.eq(BsSgcYxjdDynamicCredit::getStatus, "1").or().eq(BsSgcYxjdDynamicCredit::getStatus, "4") |
|
|
|
.orderByDesc(BsSgcYxjdDynamicCredit::getCreateTime); |
|
|
|
List<BsSgcYxjdDynamicCredit> list = bsSgcYxjdDynamicCreditService.list(queryWrapper); |
|
|
|
IPage<BsSgcYxjdDynamicCredit> page = bsSgcYxjdDynamicCreditService.selectPage(sp); |
|
|
|
creditList.addAll(list); |
|
|
|
creditList.addAll(page.getRecords()); |
|
|
|
creditList = creditList.stream().filter(x -> !x.getStatus().equals("0")).collect(Collectors.toList()); |
|
|
|
creditList = creditList.stream().distinct().collect(Collectors.toList()); |
|
|
|
page.setRecords(creditList); |
|
|
|
return page; |
|
|
|
} else { |
|
|
|
return bsSgcYxjdDynamicCreditService.selectPage(sp); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@ -61,8 +125,7 @@ public class BsSgcYxjdDynamicCreditController extends BaseController |
|
|
|
@Log(title = "动态信用导出", businessType = BusinessType.EXPORT) |
|
|
|
@PostMapping("/export") |
|
|
|
@ApiOperation("动态信用导出") |
|
|
|
public AjaxResult export(@RequestBody BsSgcYxjdDynamicCredit bsSgcYxjdDynamicCredit) |
|
|
|
{ |
|
|
|
public AjaxResult export(@RequestBody BsSgcYxjdDynamicCredit bsSgcYxjdDynamicCredit) { |
|
|
|
List<BsSgcYxjdDynamicCredit> list = bsSgcYxjdDynamicCreditService.listByIds(bsSgcYxjdDynamicCredit.getIds()); |
|
|
|
ExcelUtil<BsSgcYxjdDynamicCredit> util = new ExcelUtil<>(BsSgcYxjdDynamicCredit.class); |
|
|
|
return util.exportExcel(list, "credit"); |
|
|
@ -73,8 +136,7 @@ public class BsSgcYxjdDynamicCreditController extends BaseController |
|
|
|
*/ |
|
|
|
@ApiOperation(" 动态信用详情") |
|
|
|
@GetMapping(value = "/{id}") |
|
|
|
public AjaxResult getInfo(@PathVariable("id") String id) |
|
|
|
{ |
|
|
|
public AjaxResult getInfo(@PathVariable("id") String id) { |
|
|
|
return AjaxResult.success(bsSgcYxjdDynamicCreditService.getById(id)); |
|
|
|
} |
|
|
|
|
|
|
@ -84,10 +146,18 @@ public class BsSgcYxjdDynamicCreditController extends BaseController |
|
|
|
@Log(title = "动态信用新增", businessType = BusinessType.INSERT) |
|
|
|
@PostMapping |
|
|
|
@ApiOperation("动态信用新增") |
|
|
|
public AjaxResult add(@RequestBody BsSgcYxjdDynamicCredit bsSgcYxjdDynamicCredit) |
|
|
|
{ |
|
|
|
public AjaxResult add(@RequestBody BsSgcYxjdDynamicCredit bsSgcYxjdDynamicCredit) { |
|
|
|
BaseEntityUtils.preInsert(bsSgcYxjdDynamicCredit); |
|
|
|
return toAjax(bsSgcYxjdDynamicCreditService.save(bsSgcYxjdDynamicCredit)); |
|
|
|
bsSgcYxjdDynamicCreditService.save(bsSgcYxjdDynamicCredit); |
|
|
|
String loginId = StpUtil.getLoginIdAsString(); |
|
|
|
SysUser user = sysUserService.getById(loginId); |
|
|
|
SysDept sysDept = sysDeptService.getById(user.getDeptId()); |
|
|
|
BsSgcYxjdCreditApproval creditApproval = new BsSgcYxjdCreditApproval(); |
|
|
|
creditApproval.setCreditId(bsSgcYxjdDynamicCredit.getId()); |
|
|
|
creditApproval.setProcessProgress(sysDept.getDeptName() + "-填写"); |
|
|
|
creditApproval.setApprovalTime(new Date()); |
|
|
|
BaseEntityUtils.preInsert(creditApproval); |
|
|
|
return toAjax(bsSgcYxjdCreditApprovalService.save(creditApproval)); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@ -96,8 +166,10 @@ public class BsSgcYxjdDynamicCreditController extends BaseController |
|
|
|
@ApiOperation("动态信用修改") |
|
|
|
@Log(title = "动态信用修改", businessType = BusinessType.UPDATE) |
|
|
|
@PutMapping |
|
|
|
public AjaxResult edit(@RequestBody BsSgcYxjdDynamicCredit bsSgcYxjdDynamicCredit) |
|
|
|
{ |
|
|
|
public AjaxResult edit(@RequestBody BsSgcYxjdDynamicCredit bsSgcYxjdDynamicCredit) { |
|
|
|
|
|
|
|
String status = bsSgcYxjdDynamicCredit.getStatus(); |
|
|
|
AsyncFactory.recordDynamicCredit(bsSgcYxjdDynamicCredit.getId(), status,bsSgcYxjdDynamicCredit.getBonusPoints()); |
|
|
|
return toAjax(bsSgcYxjdDynamicCreditService.updateById(bsSgcYxjdDynamicCredit)); |
|
|
|
} |
|
|
|
|
|
|
@ -106,9 +178,8 @@ public class BsSgcYxjdDynamicCreditController extends BaseController |
|
|
|
*/ |
|
|
|
@ApiOperation("动态信用删除") |
|
|
|
@Log(title = "动态信用删除", businessType = BusinessType.DELETE) |
|
|
|
@DeleteMapping("/{ids}") |
|
|
|
public AjaxResult remove(@PathVariable String[] ids) |
|
|
|
{ |
|
|
|
@DeleteMapping("/{ids}") |
|
|
|
public AjaxResult remove(@PathVariable String[] ids) { |
|
|
|
return toAjax(bsSgcYxjdDynamicCreditService.removeByIds(Arrays.asList(ids))); |
|
|
|
} |
|
|
|
} |
|
|
|