Commit b480e5fc by huluobin

state update

parent 2d34535d
...@@ -19,7 +19,6 @@ import com.blt.other.module.cost.service.impl.cost.CostServiceFactory; ...@@ -19,7 +19,6 @@ 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.service.impl.costcheck.*;
import com.blt.other.module.cost.vo.*; import com.blt.other.module.cost.vo.*;
import com.blt.other.module.database.model.CostExpDomain; import com.blt.other.module.database.model.CostExpDomain;
import com.github.pagehelper.PageInfo;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiParam;
...@@ -241,10 +240,11 @@ public class CostController { ...@@ -241,10 +240,11 @@ public class CostController {
@GetMapping("/check/departmentRefuse") @GetMapping("/check/departmentRefuse")
@ApiOperation("部门审核驳回") @ApiOperation("部门审核驳回")
public CostResult<Void> departmentCheckRefuse(@RequestParam String costNo, public CostResult<Void> departmentCheckRefuse(@RequestParam String costNo,
@RequestParam Integer userid) { @RequestParam Integer userid,
@RequestParam String rejectReason) {
CostContext costContext = new CostContext(costNo, userid); CostContext costContext = new CostContext(costNo, userid);
costContext.setCostState(departmentCheckState); costContext.setCostState(departmentCheckState);
costContext.refuse(); costContext.refuse(rejectReason);
return CostResult.success(); return CostResult.success();
} }
...@@ -262,10 +262,11 @@ public class CostController { ...@@ -262,10 +262,11 @@ public class CostController {
@GetMapping("/check/financialRefuse") @GetMapping("/check/financialRefuse")
@ApiOperation("财务审核驳回") @ApiOperation("财务审核驳回")
public CostResult<Void> financialRefuse(@RequestParam String costNo, public CostResult<Void> financialRefuse(@RequestParam String costNo,
@RequestParam Integer userid) { @RequestParam Integer userid,
@RequestParam String rejectReason) {
CostContext costContext = new CostContext(costNo, userid); CostContext costContext = new CostContext(costNo, userid);
costContext.setCostState(financialCheckState); costContext.setCostState(financialCheckState);
costContext.handle(); costContext.refuse(rejectReason);
return CostResult.success(); return CostResult.success();
} }
...@@ -282,10 +283,11 @@ public class CostController { ...@@ -282,10 +283,11 @@ public class CostController {
@GetMapping("/check/finalRefuse") @GetMapping("/check/finalRefuse")
@ApiOperation("最终审核人驳回") @ApiOperation("最终审核人驳回")
public CostResult<Void> finalRefuse(@RequestParam String costNo, public CostResult<Void> finalRefuse(@RequestParam String costNo,
@RequestParam Integer userid) { @RequestParam Integer userid,
@RequestParam String rejectReason) {
CostContext costContext = new CostContext(costNo, userid); CostContext costContext = new CostContext(costNo, userid);
costContext.setCostState(finalCheckState); costContext.setCostState(finalCheckState);
costContext.refuse(); costContext.refuse(rejectReason);
return CostResult.success(); return CostResult.success();
} }
......
...@@ -48,6 +48,7 @@ public class CostDomain implements Serializable { ...@@ -48,6 +48,7 @@ public class CostDomain implements Serializable {
public final static int STATUS_REJECT = 3; public final static int STATUS_REJECT = 3;
public final static int STATUS_DELETE = 5; public final static int STATUS_DELETE = 5;
// 费用单编号 // 费用单编号
@TableId(type = IdType.AUTO) @TableId(type = IdType.AUTO)
private Integer id; private Integer id;
......
...@@ -15,7 +15,6 @@ import com.blt.other.common.util.MoneyUtil; ...@@ -15,7 +15,6 @@ import com.blt.other.common.util.MoneyUtil;
import com.blt.other.common.util.SessionUtils; import com.blt.other.common.util.SessionUtils;
import com.blt.other.module.auth.dao.CostReviewerMapper; import com.blt.other.module.auth.dao.CostReviewerMapper;
import com.blt.other.module.auth.dao.OaUserMapper; import com.blt.other.module.auth.dao.OaUserMapper;
import com.blt.other.module.auth.model.CostReviewer;
import com.blt.other.module.auth.model.OaUser; import com.blt.other.module.auth.model.OaUser;
import com.blt.other.module.auth.service.UserService; import com.blt.other.module.auth.service.UserService;
import com.blt.other.module.cost.dao.*; import com.blt.other.module.cost.dao.*;
...@@ -91,7 +90,6 @@ public abstract class AbstractCostService implements CostService { ...@@ -91,7 +90,6 @@ public abstract class AbstractCostService implements CostService {
@Autowired @Autowired
CostLogService costLogService; CostLogService costLogService;
@Override @Override
public Integer saveNewCost(CostDomain costDomain) { public Integer saveNewCost(CostDomain costDomain) {
throw new BizRuntimeException("deprecated method"); throw new BizRuntimeException("deprecated method");
...@@ -129,15 +127,19 @@ public abstract class AbstractCostService implements CostService { ...@@ -129,15 +127,19 @@ public abstract class AbstractCostService implements CostService {
Integer currentUserId = SessionUtils.getCurrentUserId(); Integer currentUserId = SessionUtils.getCurrentUserId();
OaUser costUser = oaUserMapper.selectByOaUserId(currentUserId); OaUser costUser = oaUserMapper.selectByOaUserId(currentUserId);
if (costDomain.getCostStatus().equals(CostDomain.STATUS_DEPARTMENT_CHECK)) { // if (currentUserId == null) {
costDomain.setCanAudit(costReviewerMapper.queryOne(costUser.getPrimaryDepartmentId(), CostReviewer.departmentReviewer, currentUserId) != null); // costDomain.setCanAudit(false);
} else if (costReviewerMapper.queryOne(costCompany.getId(), CostReviewer.financialReviewer, currentUserId) != null) { // } else if (costDomain.getCostStatus().equals(CostDomain.STATUS_DEPARTMENT_CHECK)) {
costDomain.setCanAudit(costReviewerMapper.queryOne(costCompany.getId(), CostReviewer.financialReviewer, currentUserId) != null); // costDomain.setCanAudit(costReviewerMapper.queryOne(costUser.getPrimaryDepartmentId(), CostReviewer.departmentReviewer, currentUserId) != null);
} else if (costDomain.getCostStatus().equals(CostDomain.STATUS_FINAL_CHECK)) { // } else if (costReviewerMapper.queryOne(costCompany.getId(), CostReviewer.financialReviewer, currentUserId) != null) {
costDomain.setCanAudit(costReviewerMapper.queryOne(costCompany.getId(), CostReviewer.finalReviewer, currentUserId) != null); // costDomain.setCanAudit(costReviewerMapper.queryOne(costCompany.getId(), CostReviewer.financialReviewer, currentUserId) != null);
} else { // } else if (costDomain.getCostStatus().equals(CostDomain.STATUS_FINAL_CHECK)) {
costDomain.setCanAudit(false); // costDomain.setCanAudit(costReviewerMapper.queryOne(costCompany.getId(), CostReviewer.finalReviewer, currentUserId) != null);
} // } else {
// costDomain.setCanAudit(false);
// }
//todo
costDomain.setCanAudit(true);
return costDomain; return costDomain;
} }
......
...@@ -39,8 +39,8 @@ public class CostContext { ...@@ -39,8 +39,8 @@ public class CostContext {
costState.handle(); costState.handle();
} }
public void refuse() { public void refuse(String rejectReason) {
costState.refuse(); costState.refuse(rejectReason);
} }
} }
...@@ -80,5 +80,5 @@ public abstract class CostState { ...@@ -80,5 +80,5 @@ public abstract class CostState {
public abstract void handle(); public abstract void handle();
public abstract void refuse(); public abstract void refuse(String rejectReason);
} }
...@@ -23,6 +23,7 @@ public class DepartmentCheckState extends CostState { ...@@ -23,6 +23,7 @@ public class DepartmentCheckState extends CostState {
@Autowired @Autowired
FinancialCheckState financialCheckState; FinancialCheckState financialCheckState;
@Override @Override
public void handle() { public void handle() {
CostDomain costDomain = costContext.costDomain; CostDomain costDomain = costContext.costDomain;
...@@ -77,7 +78,27 @@ public class DepartmentCheckState extends CostState { ...@@ -77,7 +78,27 @@ public class DepartmentCheckState extends CostState {
@Override @Override
public void refuse() { public void refuse(String rejectReason) {
CostDomain costDomain = costContext.costDomain;
Integer currentUserId = costContext.currentUserId;
OaUser costUser = oaUserMapper.selectByOaUserId(costDomain.getCreateUserid());
//check status
if (!costDomain.getCostStatus().equals(CostDomain.STATUS_DEPARTMENT_CHECK)) {
throw new BizRuntimeException("invalid status");
}
//人工审核没权限
if (costReviewerMapper.queryOne(costUser.getPrimaryDepartmentId(), CostReviewer.departmentReviewer, currentUserId) == null) {
throw new BizRuntimeException("current user no authority");
}
costDomain.setCostStatus(CostDomain.STATUS_REJECT);
costDao.updateById(costDomain);
costLogService.save(costDomain.getCostNo(), currentUserId, "部门审核拒绝,理由:" + rejectReason, CostLogDomain.TYPE_UPDATE);
} }
} }
...@@ -95,7 +95,26 @@ public class FinalCheckState extends CostState { ...@@ -95,7 +95,26 @@ public class FinalCheckState extends CostState {
} }
@Override @Override
public void refuse() { public void refuse(String rejectReason) {
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) {
throw new BizRuntimeException("current user no authority");
}
costDomain.setCostStatus(CostDomain.STATUS_REJECT);
costDao.updateById(costDomain);
costLogService.save(costDomain.getCostNo(), currentUserId, "最终审核拒绝,理由:" + rejectReason, CostLogDomain.TYPE_UPDATE);
} }
} }
...@@ -76,7 +76,26 @@ public class FinancialCheckState extends CostState { ...@@ -76,7 +76,26 @@ public class FinancialCheckState extends CostState {
} }
@Override @Override
public void refuse() { public void refuse(String rejectReason) {
CostDomain costDomain = costContext.costDomain;
Integer currentUserId = costContext.currentUserId;
CostCompanyDomain costCompany = costCompanyDao.selectByNo(costDomain.getCompanyNo());
//check status
if (!costDomain.getCostStatus().equals(CostDomain.STATUS_FINANCIAL_CHECK)) {
throw new BizRuntimeException("invalid status");
}
//人工审核通过
if (costReviewerMapper.queryOne(costCompany.getId(), CostReviewer.financialReviewer, currentUserId) == null) {
throw new BizRuntimeException("current user no authority");
}
costDomain.setCostStatus(CostDomain.STATUS_REJECT);
costDao.updateById(costDomain);
costLogService.save(costDomain.getCostNo(), currentUserId, "财务审核拒绝,理由:" + rejectReason, CostLogDomain.TYPE_UPDATE);
} }
} }
...@@ -19,7 +19,7 @@ public class PayedState extends CostState { ...@@ -19,7 +19,7 @@ public class PayedState extends CostState {
} }
@Override @Override
public void refuse() { public void refuse(String rejectReason {
} }
} }
package com.blt.other.module.cost.service.impl.costcheck; package com.blt.other.module.cost.service.impl.costcheck;
import com.blt.other.common.exception.BizRuntimeException;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
/** /**
...@@ -15,11 +16,11 @@ public class RefuseState extends CostState { ...@@ -15,11 +16,11 @@ public class RefuseState extends CostState {
@Override @Override
public void handle() { public void handle() {
throw new BizRuntimeException("unsupported operate ");
} }
@Override @Override
public void refuse() { public void refuse(String reason) {
throw new BizRuntimeException("unsupported operate ");
} }
} }
package com.blt.other.module.cost.service.impl.costcheck; package com.blt.other.module.cost.service.impl.costcheck;
import com.blt.other.common.exception.BizRuntimeException;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
/** /**
...@@ -19,7 +20,7 @@ public class UnPayState extends CostState { ...@@ -19,7 +20,7 @@ public class UnPayState extends CostState {
} }
@Override @Override
public void refuse() { public void refuse(String reason) {
throw new BizRuntimeException("unsupported operate ");
} }
} }
...@@ -43,7 +43,7 @@ public class UnSubmitState extends CostState { ...@@ -43,7 +43,7 @@ public class UnSubmitState extends CostState {
} }
@Override @Override
public void refuse() { public void refuse(String rejectReason) {
throw new BizRuntimeException("unsupported operate ");
} }
} }
...@@ -3,9 +3,10 @@ ...@@ -3,9 +3,10 @@
<mapper namespace="com.blt.other.module.auth.dao.OaDepartmentMapper"> <mapper namespace="com.blt.other.module.auth.dao.OaDepartmentMapper">
<select id="reviewerList" resultType="com.blt.other.module.auth.model.OaDepartment"> <select id="reviewerList" resultType="com.blt.other.module.auth.model.OaDepartment">
SELECT t1.*, t2.`name` company_name SELECT distinct t1.*,
t2.`name` company_name
from oa_department t1 from oa_department t1
LEFT JOIN oa_company t2 on t1.company_id = t2.oa_company_id left join oa_company t2 on t1.company_id = t2.oa_company_id
left join cost_reviewer t3 on t1.department_id = t3.refer_id and (t3.type = 1) left join cost_reviewer t3 on t1.department_id = t3.refer_id and (t3.type = 1)
where t1.parent_id = 0 where t1.parent_id = 0
/*审核人*/ /*审核人*/
...@@ -28,10 +29,11 @@ ...@@ -28,10 +29,11 @@
<if test="req.oaPrimaryDepartmentId !=null"> <if test="req.oaPrimaryDepartmentId !=null">
and t1.department_id = #{req.oaPrimaryDepartmentId} and t1.department_id = #{req.oaPrimaryDepartmentId}
</if> </if>
group by t1.id
</select> </select>
<select id="selectByDepartmentId" resultType="com.blt.other.module.auth.model.OaDepartment"> <select id="selectByDepartmentId" resultType="com.blt.other.module.auth.model.OaDepartment">
select * from oa_department where department_id =#{oaDepartmentId} select *
from oa_department
where department_id = #{oaDepartmentId}
</select> </select>
......
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