Commit 556d3d98 by huluobin

update

parent 38ea3157
......@@ -176,7 +176,7 @@ public class CostController {
CostContext costContext = new CostContext(costNo, costDomain.getCreateUserid());
costContext.setCostState(unSubmitState);
costContext.nexState();
costContext.handle();
CostApiDto.UpdateCostResp resp = new CostApiDto.UpdateCostResp();
......
......@@ -124,7 +124,6 @@ public interface CostService {
void finalCheck(String costNo, Integer currentUserId);
/**
* 审核费用单列表
*
......@@ -135,4 +134,13 @@ public interface CostService {
* @return 费用单列表
*/
IPage<CostDto> checkCostList(Integer userid, Integer pageNum, Integer pageSize, Integer type);
/**
* <p>
* 审核成功通知财务系统付款
* </p>
*
* @param costDomain cost
*/
void toFinancial(CostDomain costDomain);
}
......@@ -10,7 +10,6 @@ import com.blt.other.common.util.MoneyUtil;
import com.blt.other.module.auth.dao.CostReviewerMapper;
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.service.UserService;
import com.blt.other.module.cost.dao.CostCompanyDao;
import com.blt.other.module.cost.dao.CostDao;
......@@ -24,6 +23,8 @@ import com.blt.other.module.cost.model.CostTemplate;
import com.blt.other.module.cost.service.CostLogService;
import com.blt.other.module.cost.service.CostService;
import com.blt.other.module.cost.service.ICostTemplateService;
import com.blt.other.module.cost.service.impl.costcheck.CostContext;
import com.blt.other.module.cost.service.impl.costcheck.DepartmentCheckState;
import com.blt.other.module.database.model.CostCompanyDomain;
import com.blt.other.module.database.model.CostLogDomain;
import com.blt.other.module.database.model.CostTypeKindDomain;
......@@ -184,37 +185,17 @@ public abstract class AbstractCostService implements CostService {
}
@Resource
DepartmentCheckState departmentCheckState;
@Transactional
@Override
public void departmentCheck(String costNo, Integer currentUserId) {
CostDomain costDomain = costDao.selectByCostNo(costNo);
CostTemplate costTemplate = costTemplateService.queryDetail(costDomain.getCostTemplateId());
//需要自动审核
if (costTemplate.shouldDepartmentAutoCheck()) {
//自动审核通过
if (this.autoCheck(costDomain)) {
costDomain.setCostStatus(CostDomain.STATUS_FINANCIAL_CHECK);
costDao.updateById(costDomain);
//流转状态
costSubscribe.subscribe(costDomain);
costLogService.save(costNo, currentUserId, "部门自动审核通过", CostLogDomain.AUTO_CHECK);
}
//自动审核失败
else {
//人工审核
this.departmentManualCheck(costNo, currentUserId);
}
}
//人工审核
else {
//人工审核
this.departmentManualCheck(costNo, currentUserId);
}
}
CostContext costContext = new CostContext(costNo, currentUserId);
costContext.setCostState(departmentCheckState);
costContext.handle();
}
@Transactional
......@@ -223,46 +204,11 @@ public abstract class AbstractCostService implements CostService {
CostDomain costDomain = costDao.selectByCostNo(costNo);
CostTemplate costTemplate = costTemplateService.queryDetail(costDomain.getCostTemplateId());
//需要自动审核
if (costTemplate.shouldFinalAutoCheck()) {
//自动审核通过
if (this.autoCheck(costDomain)) {
costDomain.setCostStatus(CostDomain.STATUS_FINAL_CHECK);
costDao.updateById(costDomain);
//流转状态
costSubscribe.subscribe(costDomain);
costLogService.save(costNo, currentUserId, "财务自动审核通过", CostLogDomain.AUTO_CHECK);
}
//自动审核失败
else {
//人工审核
this.financialManualCheck(costNo, currentUserId);
}
}
//人工审核
else {
//人工审核
this.financialManualCheck(costNo, currentUserId);
}
}
protected void financialManualCheck(String costNo, Integer currentUserId) {
CostDomain costDomain = costDao.selectByCostNo(costNo);
CostCompanyDomain costCompany = costCompanyDao.selectByNo(costDomain.getCompanyNo());
//人工审核通过
if (costReviewerMapper.queryOne(costCompany.getId(), CostReviewer.financialReviewer, currentUserId) != null) {
costDomain.setCostStatus(CostDomain.STATUS_FINAL_CHECK);
costDao.updateById(costDomain);
//流转状态
costSubscribe.subscribe(costDomain);
costLogService.save(costNo, currentUserId, "财务审核通过", CostLogDomain.MANUAL_CHECK);
}
//人工审核没权限
else {
throw new BizRuntimeException("current user no authority");
}
}
......
......@@ -23,6 +23,6 @@ public class CostSubscribe {
@Async
public void subscribe(CostContext costContext) {
costContext.nexState();
costContext.handle();
}
}
package com.blt.other.module.cost.service.impl.cost;
import com.blt.other.module.cost.model.CostDomain;
import com.blt.other.module.cost.service.CostService;
import org.springframework.stereotype.Service;
......@@ -17,4 +18,9 @@ public class PayCostServiceImpl extends AbstractCostService implements CostServi
public void finalCheck(String costNo, Integer currentUserId) {
}
@Override
public void toFinancial(CostDomain costDomain) {
}
}
package com.blt.other.module.cost.service.impl.costcheck;
import com.bailuntec.common.SpringContextUtil;
import com.blt.other.module.cost.dao.CostDao;
import com.blt.other.module.cost.model.CostDomain;
import com.blt.other.module.cost.service.CostService;
import com.blt.other.module.cost.service.impl.cost.CostServiceFactory;
/**
* <p>
*
* 费用单上下文
* </p>
*
* @author robbendev
......@@ -33,11 +31,11 @@ public class CostContext {
public CostContext(String costNo, Integer currentUserId) {
this.costService = CostServiceFactory.getCostService(costNo);
this.currentUserId = currentUserId;
this.costDomain = SpringContextUtil.getBean(CostDao.class).selectByCostNo(costNo);
this.costDomain = costService.getCostByCostNo(costNo);
}
public void nexState() {
public void handle() {
costState.handle();
}
......@@ -45,5 +43,4 @@ public class CostContext {
costState.refuse();
}
}
......@@ -27,8 +27,13 @@ public class DepartmentCheckState extends CostState {
public void handle() {
CostDomain costDomain = costContext.costDomain;
Integer currentUserId = costContext.currentUserId;
CostTemplate costTemplate = costTemplateService.queryDetail(costDomain.getCostTemplateId());
//check status
if (!costDomain.getCostStatus().equals(CostDomain.STATUS_DEPARTMENT_CHECK)) {
throw new BizRuntimeException("invalid status");
}
//需要自动审核
if (costTemplate.shouldDepartmentAutoCheck()) {
//自动审核通过
......@@ -54,8 +59,7 @@ public class DepartmentCheckState extends CostState {
costLogService.save(costDomain.getCostNo(), currentUserId, "部门审核通过", CostLogDomain.MANUAL_CHECK);
nextState(financialCheckState);
//发布到总线尝试审核
//发布到总线尝试下个环节的自动审核
costSubscribe.subscribe(costContext);
}
//人工审核没权限
......
package com.blt.other.module.cost.service.impl.costcheck;
import org.springframework.stereotype.Component;
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.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 javax.annotation.Resource;
/**
* <p>
......@@ -12,9 +20,67 @@ import org.springframework.stereotype.Component;
*/
public class FinalCheckState extends CostState {
@Resource
UnPayState unPayState;
@Resource
CostCompanyDao costCompanyDao;
@Override
public void handle() {
CostDomain costDomain = costContext.costDomain;
Integer currentUserId = costContext.currentUserId;
CostTemplate costTemplate = costTemplateService.queryDetail(costDomain.getCostTemplateId());
//check status
if (!costDomain.getCostStatus().equals(CostDomain.STATUS_FINAL_CHECK)) {
throw new BizRuntimeException("invalid status");
}
//如果不需要审核 直接通过
if (!costTemplate.shouldFinalCheck(costDomain.getAmount())) {
costDomain.setCostStatus(CostDomain.STATUS_UN_PAY);
costDao.updateById(costDomain);
costLogService.save(costDomain.getCostNo(), currentUserId, "金额不够最终审核标准,无需最终审核", null);
//通知财务系统
costContext.costService.toFinancial(costDomain);
}
//需要自动审核
if (costTemplate.shouldFinalAutoCheck()) {
//自动审核通过
if (this.autoCheck(costDomain)) {
costDomain.setCostStatus(CostDomain.STATUS_UN_PAY);
costDao.updateById(costDomain);
costLogService.save(costDomain.getCostNo(), currentUserId, "最终审核自动通过", CostLogDomain.AUTO_CHECK);
//流转状态
nextState(unPayState);
//通知财务系统
costContext.costService.toFinancial(costDomain);
return;
}
}
CostCompanyDomain costCompany = costCompanyDao.selectByNo(costDomain.getCompanyNo());
//人工审核通过
if (costReviewerMapper.queryOne(costCompany.getId(), CostReviewer.financialReviewer, currentUserId) != null) {
costDomain.setCostStatus(CostDomain.STATUS_UN_PAY);
costDao.updateById(costDomain);
costLogService.save(costDomain.getCostNo(), currentUserId, "最终审核通过", CostLogDomain.MANUAL_CHECK);
//流转状态
nextState(unPayState);
//通知财务系统
costContext.costService.toFinancial(costDomain);
}
//人工审核没权限
else {
throw new BizRuntimeException("current user no authority");
}
}
@Override
......
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.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 org.springframework.stereotype.Component;
import javax.annotation.Resource;
/**
* <p>
*
......@@ -13,9 +22,57 @@ import org.springframework.stereotype.Component;
@Component
public class FinancialCheckState extends CostState {
@Resource
FinalCheckState finalCheckState;
@Resource
CostCompanyDao costCompanyDao;
@Override
public void handle() {
CostDomain costDomain = costContext.costDomain;
Integer currentUserId = costContext.currentUserId;
CostTemplate costTemplate = costTemplateService.queryDetail(costDomain.getCostTemplateId());
//check status
if (!costDomain.getCostStatus().equals(CostDomain.STATUS_FINANCIAL_CHECK)) {
throw new BizRuntimeException("invalid status");
}
//需要自动审核
if (costTemplate.shouldFinalAutoCheck()) {
//自动审核通过
if (this.autoCheck(costDomain)) {
costDomain.setCostStatus(CostDomain.STATUS_FINAL_CHECK);
costDao.updateById(costDomain);
costLogService.save(costDomain.getCostNo(), currentUserId, "财务自动审核通过", CostLogDomain.AUTO_CHECK);
//流转状态
nextState(finalCheckState);
//发布到总线尝试下个环节的自动审核
costSubscribe.subscribe(costContext);
return;
}
}
CostCompanyDomain costCompany = costCompanyDao.selectByNo(costDomain.getCompanyNo());
//人工审核通过
if (costReviewerMapper.queryOne(costCompany.getId(), CostReviewer.financialReviewer, currentUserId) != null) {
costDomain.setCostStatus(CostDomain.STATUS_FINAL_CHECK);
costDao.updateById(costDomain);
costLogService.save(costDomain.getCostNo(), currentUserId, "财务审核通过", CostLogDomain.MANUAL_CHECK);
//流转状态
nextState(finalCheckState);
//发布到总线尝试下个环节的自动审核
costSubscribe.subscribe(costContext);
}
//人工审核没权限
else {
throw new BizRuntimeException("current user no authority");
}
}
@Override
......
package com.blt.other.module.cost.service.impl.costcheck;
import org.springframework.stereotype.Component;
/**
* <p>
*
......
......@@ -41,7 +41,7 @@ public class UnSubmitState extends CostState {
//并且流转到下一个状态
costContext.setCostState(departmentCheckState);
//尝试审核(由于清空了审核人,这里只会走自动审核)
costContext.nexState();
costContext.handle();
}
@Override
......
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