Commit 5d921f92 by huluobin

update

parent e0249ef0
......@@ -6,37 +6,22 @@ import com.bailuntec.cost.api.dto.CostListPrintDto;
import com.bailuntec.cost.api.response.CostResult;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
import com.blt.other.common.util.AxiosUtil;
import com.blt.other.common.util.MyMapperUtil;
import com.blt.other.common.util.PathUtil;
import com.blt.other.module.cost.dao.CostDao;
import com.blt.other.module.cost.dto.request.CheckCostListReq;
import com.blt.other.module.cost.dto.response.*;
import com.blt.other.module.cost.model.CostDomain;
import com.blt.other.module.cost.service.CostExportService;
import com.blt.other.module.cost.service.CostListSearchService;
import com.blt.other.module.cost.service.CostLogService;
import com.blt.other.module.cost.service.CostService;
import com.blt.other.module.cost.service.impl.cost.CostServiceFactory;
import com.blt.other.module.cost.service.impl.costcheck.*;
import com.blt.other.module.cost.vo.*;
import com.blt.other.module.database.model.CostExpDomain;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.FileSystemResource;
import org.springframework.core.io.InputStreamResource;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
......@@ -54,33 +39,24 @@ import java.util.stream.Collectors;
@RestController
@Api(tags = "费用单接口")
public class CostController {
private CostService costService;
@Resource
CostListSearchService costListSearchService;
@Resource
CostExportService costExportService;
@Resource
CostLogService costLogService;
@Resource
CostDao costDao;
@Autowired
@Resource
UnSubmitState unSubmitState;
@Autowired
@Resource
DepartmentCheckState departmentCheckState;
@Autowired
@Resource
FinalCheckState finalCheckState;
@Autowired
@Resource
FinancialCheckState financialCheckState;
@Autowired
PayedState payedState;
@Autowired
RefuseState refuseState;
@Autowired
UnPayState unPayState;
@Autowired
@Resource
HrCheckState hrCheckState;
@ApiOperation("获取前端要打印的费用单列表")
......@@ -223,7 +199,7 @@ public class CostController {
}
@ApiOperation("审核费用单列表")
@ApiOperation("待我审核费用单列表")
@GetMapping("/checkCostList")
public CostResult<IPage<CostDto>> checkCostList(CheckCostListReq req) {
costService = CostServiceFactory.getCostService();
......@@ -470,100 +446,4 @@ public class CostController {
return resp;
}
@PostMapping("/list/exportList")
public String exportList(HttpServletResponse response, HttpServletRequest request) {
Enumeration<String> parameterNames = request.getParameterNames();
if (null != parameterNames && parameterNames.hasMoreElements()) {
String s = parameterNames.nextElement();
CostExportVo costExportVo = (CostExportVo) MyMapperUtil.getObject(s, CostExportVo.class);
String filePath = costExportService.exportFees(costExportVo.getParams().getExportNos());
// 保存下载记录
CostExpDomain exp = costExportService.saveRecord(costExportVo, filePath);
return exp.getExpNo();
}
return null;
}
@PostMapping("/list/exportListAll")
public String exportListAll(HttpServletResponse response, HttpServletRequest request) {
CostService costService = CostServiceFactory.getCostService();
AxiosUtil.setCors(response, request);
Enumeration<String> parameterNames = request.getParameterNames();
if (null != parameterNames && parameterNames.hasMoreElements()) {
String s = parameterNames.nextElement();
CostExportVo costExportVo = JsonUtilByFsJson.jsonToBean(s, CostExportVo.class);
List<String> exportNos;
if (null != costExportVo.getParams().getKeys().getCostForm() && 3 == costExportVo.getParams().getKeys().getCostForm()) {
costExportVo.getParams().getKeys().setIsLend(1);
}
if (null != costExportVo.getParams().getKeys().getCostForm() && 4 == costExportVo.getParams().getKeys().getCostForm()) {
costExportVo.getParams().getKeys().setCostForm(3);
costExportVo.getParams().getKeys().setIsLend(2);
}
exportNos = costDao.listCostNoAll(costExportVo);
String filePath = costExportService.exportFees(exportNos);
// 保存下载记录
CostExpDomain exp = costExportService.saveRecord(costExportVo, filePath);
return exp.getExpNo();
}
return null;
}
@GetMapping("list/download")
public ResponseEntity<InputStreamResource> download(HttpServletRequest request, HttpServletResponse response) throws IOException {
String pathNo = request.getParameter("pathNo");
CostExpDomain exp = costExportService.getByExpNo(pathNo);
String filePath = exp.getExpPath();
String fileName = PathUtil.getFileName(filePath);
FileSystemResource file = new FileSystemResource(filePath);
HttpHeaders headers = new HttpHeaders();
headers.add("Cache-Control", "no-cache, no-store, must-revalidate");
// new String(fileName.getBytes("UTF-8"),"iso-8859-1") 解决文件下载的时候文件名乱码的问题
headers.add("Content-Disposition", String.format("attachment; filename=\"%s\"", new String(fileName.getBytes("UTF-8"), "iso-8859-1")));
headers.add("Pragma", "no-cache");
headers.add("Expires", "0");
return ResponseEntity
.ok()
.headers(headers)
.contentLength(file.contentLength())
.contentType(MediaType.parseMediaType("application/octet-stream"))
.body(new InputStreamResource(file.getInputStream()));
}
@GetMapping("list/downloadCashierAnnex")
public ResponseEntity<InputStreamResource> downCashierAnnex(HttpServletRequest request, HttpServletResponse response) throws IOException {
String detailNo = request.getParameter("detailNo");
CostDomain cost = costDao.selectByCostNo(detailNo);
String filePath = null;
String fileName = null;
if (null != cost) {
filePath = cost.getCashierFilePath();
if (null != filePath) {
fileName = filePath.substring(filePath.lastIndexOf("/") + 1);
}
} else {
return null;
}
FileSystemResource file = new FileSystemResource(filePath);
HttpHeaders headers = new HttpHeaders();
headers.add("Cache-Control", "no-cache, no-store, must-revalidate");
// new String(fileName.getBytes("UTF-8"),"iso-8859-1") 解决文件下载的时候文件名乱码的问题
headers.add("Content-Disposition", String.format("attachment; filename=\"%s\"", new String(fileName.getBytes("UTF-8"), "iso-8859-1")));
headers.add("Pragma", "no-cache");
headers.add("Expires", "0");
return ResponseEntity
.ok()
.headers(headers)
.contentLength(file.contentLength())
.contentType(MediaType.parseMediaType("application/octet-stream"))
.body(new InputStreamResource(file.getInputStream()));
}
}
package com.blt.other.module.cost.controller.finansys;
package com.blt.other.module.cost.controller;
import com.bailuntec.cost.api.dto.CostDto;
import com.blt.other.module.auth.service.UserService;
......
package com.blt.other.module.cost.controller;
import com.bailuntec.common.JsonUtilByFsJson;
import com.blt.other.common.util.AxiosUtil;
import com.blt.other.common.util.MyMapperUtil;
import com.blt.other.common.util.PathUtil;
import com.blt.other.module.cost.dao.CostDao;
import com.blt.other.module.cost.model.CostDomain;
import com.blt.other.module.cost.service.CostExportService;
import com.blt.other.module.cost.service.CostService;
import com.blt.other.module.cost.service.impl.cost.CostServiceFactory;
import com.blt.other.module.cost.vo.CostExportVo;
import com.blt.other.module.database.model.CostExpDomain;
import org.springframework.core.io.FileSystemResource;
import org.springframework.core.io.InputStreamResource;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.Enumeration;
import java.util.List;
/**
* <p>
*
* </p>
*
* @author robbendev
* @since 2020/12/16 1:59 下午
*/
@RestController
public class CostReportController {
@Resource
CostExportService costExportService;
@Resource
CostDao costDao;
@PostMapping("/cost/list/exportList")
public String exportList(HttpServletResponse response, HttpServletRequest request) {
Enumeration<String> parameterNames = request.getParameterNames();
if (null != parameterNames && parameterNames.hasMoreElements()) {
String s = parameterNames.nextElement();
CostExportVo costExportVo = (CostExportVo) MyMapperUtil.getObject(s, CostExportVo.class);
String filePath = costExportService.exportFees(costExportVo.getParams().getExportNos());
// 保存下载记录
CostExpDomain exp = costExportService.saveRecord(costExportVo, filePath);
return exp.getExpNo();
}
return null;
}
@PostMapping("/cost/list/exportListAll")
public String exportListAll(HttpServletResponse response, HttpServletRequest request) {
CostService costService = CostServiceFactory.getCostService();
AxiosUtil.setCors(response, request);
Enumeration<String> parameterNames = request.getParameterNames();
if (null != parameterNames && parameterNames.hasMoreElements()) {
String s = parameterNames.nextElement();
CostExportVo costExportVo = JsonUtilByFsJson.jsonToBean(s, CostExportVo.class);
List<String> exportNos;
if (null != costExportVo.getParams().getKeys().getCostForm() && 3 == costExportVo.getParams().getKeys().getCostForm()) {
costExportVo.getParams().getKeys().setIsLend(1);
}
if (null != costExportVo.getParams().getKeys().getCostForm() && 4 == costExportVo.getParams().getKeys().getCostForm()) {
costExportVo.getParams().getKeys().setCostForm(3);
costExportVo.getParams().getKeys().setIsLend(2);
}
exportNos = costDao.listCostNoAll(costExportVo);
String filePath = costExportService.exportFees(exportNos);
// 保存下载记录
CostExpDomain exp = costExportService.saveRecord(costExportVo, filePath);
return exp.getExpNo();
}
return null;
}
@GetMapping("/cost/list/download")
public ResponseEntity<InputStreamResource> download(HttpServletRequest request, HttpServletResponse response) throws IOException {
String pathNo = request.getParameter("pathNo");
CostExpDomain exp = costExportService.getByExpNo(pathNo);
String filePath = exp.getExpPath();
String fileName = PathUtil.getFileName(filePath);
FileSystemResource file = new FileSystemResource(filePath);
HttpHeaders headers = new HttpHeaders();
headers.add("Cache-Control", "no-cache, no-store, must-revalidate");
// new String(fileName.getBytes("UTF-8"),"iso-8859-1") 解决文件下载的时候文件名乱码的问题
headers.add("Content-Disposition", String.format("attachment; filename=\"%s\"", new String(fileName.getBytes("UTF-8"), "iso-8859-1")));
headers.add("Pragma", "no-cache");
headers.add("Expires", "0");
return ResponseEntity
.ok()
.headers(headers)
.contentLength(file.contentLength())
.contentType(MediaType.parseMediaType("application/octet-stream"))
.body(new InputStreamResource(file.getInputStream()));
}
@GetMapping("/cost/list/downloadCashierAnnex")
public ResponseEntity<InputStreamResource> downCashierAnnex(HttpServletRequest request, HttpServletResponse response) throws IOException {
String detailNo = request.getParameter("detailNo");
CostDomain cost = costDao.selectByCostNo(detailNo);
String filePath = null;
String fileName = null;
if (null != cost) {
filePath = cost.getCashierFilePath();
if (null != filePath) {
fileName = filePath.substring(filePath.lastIndexOf("/") + 1);
}
} else {
return null;
}
FileSystemResource file = new FileSystemResource(filePath);
HttpHeaders headers = new HttpHeaders();
headers.add("Cache-Control", "no-cache, no-store, must-revalidate");
// new String(fileName.getBytes("UTF-8"),"iso-8859-1") 解决文件下载的时候文件名乱码的问题
headers.add("Content-Disposition", String.format("attachment; filename=\"%s\"", new String(fileName.getBytes("UTF-8"), "iso-8859-1")));
headers.add("Pragma", "no-cache");
headers.add("Expires", "0");
return ResponseEntity
.ok()
.headers(headers)
.contentLength(file.contentLength())
.contentType(MediaType.parseMediaType("application/octet-stream"))
.body(new InputStreamResource(file.getInputStream()));
}
}
package com.blt.other.module.cost.controller.finansys;
package com.blt.other.module.cost.controller;
import com.bailuntec.cost.api.dto.LogisticsFinansysDto;
import com.bailuntec.cost.api.dto.SubLogisticsFinansysDto;
......
......@@ -62,8 +62,29 @@ public interface CostDao extends BaseMapper<CostDomain> {
//
List<String> listCostNoAll(CostExportVo costExportVo);
//管理后台审核列表查询
IPage<CostDomain> checkCostList(@Param("page") IPage<CostDomain> page,
//管理后台 需要财务审核或者需要我最终审核费用列表查询
IPage<CostDomain> financialOrFinalCheckCostList(@Param("page") IPage<CostDomain> page,
@Param("req") CheckCostListReq req);
//管理后台 需要我部门审核费用列表查询
IPage<CostDomain> departmentCheckCostList(@Param("page") IPage<CostDomain> page,
@Param("req") CheckCostListReq req);
//管理后台 所有需要我部门审核 + 我已经部门审核通过 费用列表查询
IPage<CostDomain> departmentCheckAllCostList(@Param("page") IPage<CostDomain> page,
@Param("req") CheckCostListReq req);
//管理后台 已经部门手动审核费用列表查询
IPage<CostDomain> departmentManualCheckLllCostList(@Param("page") IPage<CostDomain> page,
@Param("req") CheckCostListReq req);
//管理后台 已经部门自动核费用列表查询
IPage<CostDomain> departmentAutoCheckLllCostList(@Param("page") IPage<CostDomain> page,
@Param("req") CheckCostListReq req);
//管理后台 需要我人事审核费用列表查询
IPage<CostDomain> hrCheckCostList(@Param("page") IPage<CostDomain> page,
@Param("req") CheckCostListReq req);
//小程序审核列表查询
......
......@@ -85,9 +85,6 @@ public class CostDomain implements Serializable {
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date createTime;
// @ApiModelProperty("关联子单")puh
// @Deprecated
// private String sonCostNo;
@ApiModelProperty("关联父单")
private String supCostNo;
......@@ -225,17 +222,12 @@ public class CostDomain implements Serializable {
@TableField(exist = false)
private Integer primaryDepartmentId;
@TableField(exist = false)
private String primaryDepartmentName;
@ApiModelProperty("最终审核人")
private String finalReviewerUserName;
@ApiModelProperty("财务审核人")
private String financialFinalReviewerUserName;
@ApiModelProperty("部门审核人")
private String departmentReviewerUserName;
@ApiModelProperty("行政审核人")
private String hrReviewerUserName;
@TableField(exist = false)
private String costCurrentReviewer;
public CostDto castToDto() {
......
......@@ -4,12 +4,10 @@ import com.bailuntec.common.ListUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.blt.other.module.cost.dao.CostCurrentReviewerMapper;
import com.blt.other.module.cost.dao.CostDao;
import com.blt.other.module.cost.model.CostCurrentReviewer;
import com.blt.other.module.cost.service.ICostCurrentReviewerService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
/**
......@@ -28,6 +26,6 @@ public class CostCurrentReviewerServiceImpl extends ServiceImpl<CostCurrentRevie
List<CostCurrentReviewer> costCurrentReviewerList = baseMapper.selectList(new LambdaQueryWrapper<CostCurrentReviewer>()
.eq(CostCurrentReviewer::getCostNo, costNo));
return ListUtil.isNotEmpty(costCurrentReviewerList) && costCurrentReviewerList.stream()
.map(CostCurrentReviewer::getOaUserId).anyMatch(id -> id.equals(oaUserId))
.map(CostCurrentReviewer::getOaUserId).anyMatch(id -> id.equals(oaUserId));
}
}
......@@ -15,7 +15,6 @@ import com.blt.other.common.exception.BizRuntimeException;
import com.blt.other.common.util.CurUtils;
import com.blt.other.common.util.MoneyUtil;
import com.blt.other.common.util.SessionUtils;
import com.blt.other.module.auth.dao.CostReviewerMapper;
import com.blt.other.module.auth.dao.OaDepartmentMapper;
import com.blt.other.module.auth.dao.OaUserMapper;
import com.blt.other.module.auth.model.OaDepartment;
......@@ -137,8 +136,6 @@ public abstract class AbstractCostService implements CostService {
}
@Resource
CostReviewerMapper costReviewerMapper;
@Resource
OaUserMapper oaUserMapper;
@Resource
ICostCurrentReviewerService costCurrentReviewerService;
......@@ -274,7 +271,27 @@ public abstract class AbstractCostService implements CostService {
@Override
public IPage<CostDto> checkCostList(CheckCostListReq req) {
IPage<CostDomain> page = new Page<>(req.getPageNum(), req.getPageSize());
return costDao.checkCostList(page, req).convert(CostDomain::castToDto);
if (req.getType().equals(1)) {
return costDao.financialOrFinalCheckCostList(page, req).convert(CostDomain::castToDto);
}
if (req.getType().equals(2)) {
if (req.getStatus().equals(1)) {
return costDao.departmentCheckAllCostList(page, req).convert(CostDomain::castToDto);
}
if (req.getStatus().equals(2)) {
return costDao.departmentCheckCostList(page, req).convert(CostDomain::castToDto);
}
if (req.getStatus().equals(3)) {
return costDao.departmentManualCheckLllCostList(page, req).convert(CostDomain::castToDto);
}
if (req.getStatus().equals(4)) {
return costDao.departmentAutoCheckLllCostList(page, req).convert(CostDomain::castToDto);
}
}
if (req.getType().equals(3)) {
return costDao.hrCheckCostList(page, req).convert(CostDomain::castToDto);
}
throw new BizRuntimeException("invalid param");
}
@Resource
......
......@@ -6,10 +6,12 @@ import com.blt.other.module.cost.dao.CostDao;
import com.blt.other.module.cost.model.CostDomain;
import com.blt.other.module.cost.model.CostTemplate;
import com.blt.other.module.cost.service.CostLogService;
import com.blt.other.module.cost.service.ICostCurrentReviewerService;
import com.blt.other.module.cost.service.ICostTemplateService;
import com.blt.other.module.cost.service.impl.cost.CostSubscribe;
import org.springframework.beans.factory.annotation.Autowired;
import javax.annotation.Resource;
import java.util.List;
import java.util.stream.Collectors;
......@@ -24,7 +26,8 @@ import java.util.stream.Collectors;
public abstract class CostState {
@Resource
ICostCurrentReviewerService costCurrentReviewerService;
@Autowired
CostDao costDao;
@Autowired
......
......@@ -3,7 +3,6 @@ package com.blt.other.module.cost.service.impl.costcheck;
import com.blt.other.common.exception.BizRuntimeException;
import com.blt.other.module.auth.dao.OaDepartmentMapper;
import com.blt.other.module.auth.dao.OaUserMapper;
import com.blt.other.module.auth.model.CostReviewer;
import com.blt.other.module.auth.model.OaDepartment;
import com.blt.other.module.auth.model.OaUser;
import com.blt.other.module.cost.model.CostDomain;
......@@ -11,6 +10,7 @@ import com.blt.other.module.cost.model.CostTemplate;
import com.blt.other.module.database.model.CostLogDomain;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.time.LocalDateTime;
......@@ -33,6 +33,7 @@ public class DepartmentCheckState extends CostState {
@Resource
OaUserMapper oaUserMapper;
@Transactional(rollbackFor =Exception.class)
@Override
public void handle() {
CostDomain costDomain = costContext.costDomain;
......@@ -82,7 +83,7 @@ public class DepartmentCheckState extends CostState {
OaUser costUser = oaUserMapper.selectByOaUserId(costDomain.getCreateUserid());
if (costContext.currentUserId != null) {
//人工审核通过
if (costReviewerMapper.queryOne(costUser.getPrimaryDepartmentId(), CostReviewer.departmentReviewer, currentUserId) != null) {
if (!costCurrentReviewerService.canAudit(currentUserId, costDomain.getCostNo())) {
costDomain.setCostStatus(CostDomain.STATUS_HR_CHECK);
costDomain.setLastModifyDate(LocalDateTime.now());
costDao.updateById(costDomain);
......@@ -114,7 +115,7 @@ public class DepartmentCheckState extends CostState {
}
//人工审核没权限
if (costReviewerMapper.queryOne(costUser.getPrimaryDepartmentId(), CostReviewer.departmentReviewer, currentUserId) == null) {
if (!costCurrentReviewerService.canAudit(currentUserId, costDomain.getCostNo())) {
throw new BizRuntimeException("current user no authority");
}
......
package com.blt.other.module.cost.service.impl.costcheck;
import com.blt.other.common.exception.BizRuntimeException;
import com.blt.other.module.auth.model.CostReviewer;
import com.blt.other.module.cost.dao.CostCompanyDao;
import com.blt.other.module.cost.dao.CostLogDao;
import com.blt.other.module.cost.model.CostDomain;
import com.blt.other.module.cost.model.CostTemplate;
import com.blt.other.module.database.model.CostCompanyDomain;
import com.blt.other.module.database.model.CostLogDomain;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
......@@ -30,8 +27,6 @@ public class FinalCheckState extends CostState {
@Resource
UnPayState unPayState;
@Resource
CostCompanyDao costCompanyDao;
@Resource
CostLogDao costLogDao;
private void autoPass() {
......@@ -54,7 +49,6 @@ public class FinalCheckState extends CostState {
CostDomain costDomain = costContext.costDomain;
Integer currentUserId = costContext.currentUserId;
CostTemplate costTemplate = costTemplateService.queryDetail(costDomain.getCostTemplateId());
CostCompanyDomain costCompany = costCompanyDao.selectByNo(costDomain.getCompanyNo());
//check status
......@@ -89,7 +83,7 @@ public class FinalCheckState extends CostState {
if (costContext.currentUserId != null) {
//人工审核通过
if (costReviewerMapper.queryOne(costCompany.getId(), CostReviewer.finalReviewer, currentUserId) != null) {
if (!costCurrentReviewerService.canAudit(currentUserId, costDomain.getCostNo())) {
costDomain.setCostStatus(CostDomain.STATUS_UN_PAY);
costDomain.setLastModifyDate(LocalDateTime.now());
costDao.updateById(costDomain);
......@@ -115,15 +109,13 @@ public class FinalCheckState extends CostState {
CostDomain costDomain = costContext.costDomain;
Integer currentUserId = costContext.currentUserId;
CostCompanyDomain costCompany = costCompanyDao.selectByNo(costDomain.getCompanyNo());
//check status
if (!costDomain.getCostStatus().equals(CostDomain.STATUS_FINAL_CHECK)) {
throw new BizRuntimeException("invalid status");
}
//人工审核通过
if (costReviewerMapper.queryOne(costCompany.getId(), CostReviewer.finalReviewer, currentUserId) == null) {
if (!costCurrentReviewerService.canAudit(currentUserId, costDomain.getCostNo())) {
throw new BizRuntimeException("current user no authority");
}
......
......@@ -66,7 +66,7 @@ public class FinancialCheckState extends CostState {
CostCompanyDomain costCompany = costCompanyDao.selectByNo(costDomain.getCompanyNo());
if (costContext.currentUserId != null) {
//人工审核通过
if (costReviewerMapper.queryOne(costCompany.getId(), CostReviewer.financialReviewer, currentUserId) != null) {
if (!costCurrentReviewerService.canAudit(currentUserId, costDomain.getCostNo())) {
costDomain.setCostStatus(CostDomain.STATUS_FINAL_CHECK);
costDomain.setLastModifyDate(LocalDateTime.now());
costDao.updateById(costDomain);
......@@ -98,7 +98,7 @@ public class FinancialCheckState extends CostState {
}
//人工审核通过
if (costReviewerMapper.queryOne(costCompany.getId(), CostReviewer.financialReviewer, currentUserId) == null) {
if (!costCurrentReviewerService.canAudit(currentUserId, costDomain.getCostNo())) {
throw new BizRuntimeException("current user no authority");
}
......
......@@ -63,10 +63,9 @@ public class HrCheckState extends CostState {
}
//人工审核
CostCompanyDomain costCompany = costCompanyDao.selectByNo(costDomain.getCompanyNo());
if (costContext.currentUserId != null) {
//人工审核通过
if (costReviewerMapper.queryOne(costCompany.getId(), CostReviewer.hrReviewer, currentUserId) != null) {
if (!costCurrentReviewerService.canAudit(currentUserId, costDomain.getCostNo())) {
costDomain.setCostStatus(CostDomain.STATUS_FINANCIAL_CHECK);
costDomain.setLastModifyDate(LocalDateTime.now());
costDao.updateById(costDomain);
......@@ -89,8 +88,6 @@ public class HrCheckState extends CostState {
CostDomain costDomain = costContext.costDomain;
Integer currentUserId = costContext.currentUserId;
OaUser costUser = oaUserMapper.selectByOaUserId(costDomain.getCreateUserid());
//check status
if (!costDomain.getCostStatus().equals(CostDomain.STATUS_HR_CHECK)) {
......@@ -99,7 +96,7 @@ public class HrCheckState extends CostState {
//人工审核没权限
CostCompanyDomain costCompany = costCompanyDao.selectByNo(costDomain.getCompanyNo());
if (costReviewerMapper.queryOne(costCompany.getId(), CostReviewer.hrReviewer, currentUserId) == null) {
if (!costCurrentReviewerService.canAudit(currentUserId, costDomain.getCostNo())) {
throw new BizRuntimeException("current user no authority");
}
......
package com.blt.other.module.cost.service.impl.costcheck;
import com.bailuntec.common.ListUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.blt.other.common.exception.BizRuntimeException;
import com.blt.other.module.auth.model.CostReviewer;
import com.blt.other.module.auth.model.OaUser;
import com.blt.other.module.cost.model.CostDomain;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDateTime;
import java.util.List;
/**
* <p>
......@@ -22,6 +27,20 @@ public class UnSubmitState extends CostState {
@Autowired
DepartmentCheckState departmentCheckState;
@Override
void nextState(CostState costState) {
super.nextState(costState);
CostDomain costDomain = costContext.costDomain;
OaUser costUser = oaUserMapper.selectByOaUserId(costDomain.getCreateUserid());
List<CostReviewer> costReviewerList = costReviewerMapper.selectList(new LambdaQueryWrapper<CostReviewer>()
.eq(CostReviewer::getReferId, costUser.getPrimaryDepartmentId())
.eq(CostReviewer::getType, CostReviewer.departmentReviewer));
if (ListUtil.isNotEmpty(costReviewerList)) {
}
}
@Transactional(rollbackFor = Exception.class)
@Override
public void handle() {
......
......@@ -11,46 +11,51 @@
<select id="selectAll" resultMap="cost">
SELECT
*
t1.*,
group_concat(distinct t2.username) as cost_current_reviewer,
FROM
cost
cost t1
left join cost_current_reviewer t2 on t1.cost_no = t2.cost_no
<if test="userId != null">
where create_userid = #{userId}
where t1.create_userid = #{userId}
</if>
<if test="projectTypeList != null and projectTypeList.size() > 0">
AND project_type in
AND t1.project_type in
<foreach collection="projectTypeList" item="projectType" index="index" open="(" close=")" separator=",">
#{projectType}
</foreach>
</if>
ORDER BY
id DESC
t1.id DESC
</select>
<select id="selectByCostNo" resultMap="cost">
SELECT *
FROM cost
WHERE cost_no = #{costNo}
ORDER BY id
SELECT t1.*,
group_concat(distinct t2.username) as cost_current_reviewer,
FROM cost t1
left join cost_current_reviewer t2 on t1.cost_no = t2.cost_no
WHERE t1.cost_no = #{costNo}
ORDER BY t1.id
DESC
</select>
<select id="selectByKeys" resultType="com.blt.other.module.cost.model.CostDomain">
SELECT
*
FROM
cost
t1.*,
group_concat(distinct t2.username) as cost_current_reviewer,
from cost t1
left join cost_current_reviewer t2 on t1.cost_no = t2.cost_no
WHERE
cost_status >= 1
<if test=" costForm!=null and costForm != ''">and cost_form= #{costForm}</if>
<if test=" isLend!=null and isLend != ''">and is_lend=#{isLend}</if>
<if test=" companyName!=null and companyName != ''">and company_name=#{companyName}</if>
<if test=" createUsername!=null and createUsername != ''">and create_username=#{createUsername}</if>
<if test=" kindNo!=null and kindNo != ''">and kind_no=#{kindNo}</if>
<if test=" costStatus!=null and costStatus != ''">and cost_status=#{costStatus}</if>
<if test=" lendStatus!=null and lendStatus != ''">and lend_status=#{lendStatus}</if>
t1.cost_status >= 1
<if test=" costForm!=null and costForm != ''">and t1.cost_form= #{costForm}</if>
<if test=" isLend!=null and isLend != ''">and t1.is_lend=#{isLend}</if>
<if test=" companyName!=null and companyName != ''">and t1.company_name=#{companyName}</if>
<if test=" createUsername!=null and createUsername != ''">and t1.create_username=#{createUsername}</if>
<if test=" kindNo!=null and kindNo != ''">and t1.kind_no=#{kindNo}</if>
<if test=" costStatus!=null and costStatus != ''">and t1.cost_status=#{costStatus}</if>
<if test=" lendStatus!=null and lendStatus != ''">and t1.lend_status=#{lendStatus}</if>
ORDER BY
id DESC
t1.id DESC
</select>
<select id="selectByCostPlanNo" resultMap="cost">
......@@ -128,7 +133,6 @@
</select>
<!--管理成本:查询付款单+收款单+借还单+采购单-->
<select id="selectManageCost" resultType="com.bailuntec.cost.api.dto.ManageCostDto">
SELECT
......@@ -362,7 +366,6 @@
AND kind_name IN ('借款--其他应付款', '收款--其他应付款')
</select>
<select id="listCostNoAll" resultType="java.lang.String">
select cost_no from cost
WHERE
......@@ -410,72 +413,6 @@
</if>
</select>
<select id="checkCostList" resultMap="cost">
select t1.*,
group_concat(distinct t4.reviewer_user_name) as final_reviewer_user_name,
group_concat(distinct t5.reviewer_user_name) as financial_final_reviewer_user_name,
group_concat(distinct t7.reviewer_user_name) as department_reviewer_user_name,
group_concat(distinct t8.reviewer_user_name) as hr_reviewer_user_name
from cost t1
left join cost_log t2 on t1.cost_no = t2.cost_no
left join cost_company t3 on t1.company_no = t3.company_no
left join cost_reviewer t4 on t3.id = t4.refer_id and t4.type = 3
left join cost_reviewer t5 on t3.id = t5.refer_id and t5.type = 2
left join oa_user t6 on t1.create_userid = t6.oa_user_id
left join cost_reviewer t7 on t6.primary_department_id = t7.refer_id and t7.type = 1
left join cost_reviewer t8 on t3.id = t8.refer_id and t5.type = 4
where true
/*财务 或者 最终审核 只显示待审核的*/
<if test="req.type == 1">
and (t1.cost_status = 7 or t1.cost_status = 8)
and (t4.reviewer_user_id = #{req.userid} or t5.reviewer_user_id = #{req.userid})
</if>
/*行政审核*/
<if test="req.type == 3">
/* 全部 */
<if test=" req.status == 1 ">
and t1.company_name like concat('%','工会','%')
</if>
/*待行政审核*/
<if test=" req.status == 2 ">
and t1.cost_status = 9
</if>
/*行政已手动审核*/
<if test=" req.status == 3 ">
and t2.type = 8
</if>
</if>
/* 部门审核 */
<if test="req.type == 2">
/*0 待提交 1- 待财务审核 2待出纳付款 3被驳回 4已支付 5已作废 6-待部门审核 7-待财务审核 8-待最终审核人审核*/
/*全部 */
<if test=" req.status == 1 ">
and t1.cost_status not in (0,5,3)
</if>
/*待审核*/
<if test=" req.status == 2 ">
and t1.cost_status = 6
</if>
/*已手动审核 日志类型区分*/
<if test=" req.status == 3 ">
and t2.type = 5
</if>
/*已自动审核 日志类型区分*/
<if test=" req.status == 4 ">
and t2.type = 4
</if>
and (t7.reviewer_user_id = #{req.userid} )
</if>
<if test=" req.costNo!=null and req.costNo != ''">
and t1.cost_no like concat('%',#{req.costNo},'%')
</if>
group by
t1.id
order by t1.create_time desc
</select>
<select id="appCheckCostList" resultType="com.blt.other.module.cost.model.CostDomain">
select t1.*
from cost t1
......@@ -522,4 +459,67 @@
and create_time &lt;=#{req.endTime}
</if>
</select>
<!--待部门审核-->
<select id="departmentCheckCostList" resultType="com.blt.other.module.cost.model.CostDomain">
select t1.*
from cost t1
left join cost_current_reviewer t3 on t1.cost_no = t3.cost_no and t3.oa_user_id = #{req.oaUserId}
where t1.cost_status = 6
and t3.id is not null
</select>
<!--待我部门审核 + 我已经部门手动审核 + 我已经部门自动审核-->
<select id="departmentCheckAllCostList" resultType="com.blt.other.module.cost.model.CostDomain">
select t1.*
from cost t1
left join cost_log t2 on t1.cost_no = t2.cost_no and t2.type in (2, 3) and t2.update_userid = #{req.oaUserId}
where t1.cost_status not in (0, 3, 5)
and t2.id is not null
union
select t1.*
from cost t1
left join cost_current_reviewer t3 on t1.cost_no = t3.cost_no and t3.oa_user_id = #{req.oaUserId}
where t1.cost_status = 6
and t3.id is not null
</select>
<!--我手动部门审核过的 -->
<select id="departmentManualCheckLllCostList" resultType="com.blt.other.module.cost.model.CostDomain">
select t1.*
from cost t1
left join cost_log t2 on t1.cost_no = t2.cost_no and t2.type = 3 and t2.update_userid = #{req.oaUserId}
left join cost_current_reviewer t3 on t1.cost_no = t3.cost_no and t3.oa_user_id = #{req.oaUserId}
where t1.cost_status not in (0, 3, 5)
and t2.id is not null
</select>
<!--我部门自动审核过的 -->
<select id="departmentAutoCheckLllCostList" resultType="com.blt.other.module.cost.model.CostDomain">
select t1.*
from cost t1
left join cost_log t2 on t1.cost_no = t2.cost_no and t2.type = 2 and t2.update_userid = #{req.oaUserId}
left join cost_current_reviewer t3 on t1.cost_no = t3.cost_no and t3.oa_user_id = #{req.oaUserId}
where t1.cost_status not in (0, 3, 5)
and t2.id is not null
</select>
<!--需要我财务审核的-->
<select id="financialOrFinalCheckCostList" resultType="com.blt.other.module.cost.model.CostDomain">
select t1.*
from cost t1
left join cost_current_reviewer t3 on t1.cost_no = t3.cost_no and t3.oa_user_id = #{req.oaUserId}
where t1.cost_status = 6
and t3.id is not null
</select>
<!--需要我人事审核的-->
<select id="hrCheckCostList" resultType="com.blt.other.module.cost.model.CostDomain">
select t1.*
from cost t1
left join cost_current_reviewer t3 on t1.cost_no = t3.cost_no and t3.oa_user_id = #{req.oaUserId}
where t1.cost_status = 9
and t3.id is not null
</select>
</mapper>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment