|
|
@@ -1,17 +1,18 @@
|
|
|
package com.goafanti.organization.service.impl;
|
|
|
|
|
|
import com.goafanti.admin.bo.AdminListBo;
|
|
|
-import com.goafanti.common.dao.DepartmentMapper;
|
|
|
-import com.goafanti.common.dao.ExpenseConfigDetailsMapper;
|
|
|
-import com.goafanti.common.dao.TOrderMidMapper;
|
|
|
-import com.goafanti.common.dao.TOrderNewMapper;
|
|
|
-import com.goafanti.common.model.Department;
|
|
|
-import com.goafanti.common.model.ExpenseConfigDetails;
|
|
|
+import com.goafanti.common.constant.AFTConstants;
|
|
|
+import com.goafanti.common.dao.*;
|
|
|
+import com.goafanti.common.enums.OrderLogProcess;
|
|
|
+import com.goafanti.common.model.*;
|
|
|
import com.goafanti.common.utils.AsyncUtils;
|
|
|
import com.goafanti.common.utils.StringUtils;
|
|
|
import com.goafanti.core.mybatis.BaseMybatisDao;
|
|
|
import com.goafanti.core.mybatis.page.Pagination;
|
|
|
import com.goafanti.core.shiro.token.TokenManager;
|
|
|
+import com.goafanti.order.bo.TOrderNewBo;
|
|
|
+import com.goafanti.order.enums.ApprovalNewState;
|
|
|
+import com.goafanti.order.enums.ProcessStatus;
|
|
|
import com.goafanti.organization.bo.DepOut;
|
|
|
import com.goafanti.organization.bo.InputDep;
|
|
|
import com.goafanti.organization.bo.OrganizationListOut;
|
|
|
@@ -35,6 +36,11 @@ public class OrganizationServiceImpl extends BaseMybatisDao<DepartmentMapper> im
|
|
|
private TOrderNewMapper torderNewMapper;
|
|
|
@Autowired
|
|
|
private TOrderMidMapper torderMidMapper;
|
|
|
+ @Autowired
|
|
|
+ private TOrderExamineMapper torderExamineMapper;
|
|
|
+ @Autowired
|
|
|
+ private TOrderLogMapper tOrderLogMapper;
|
|
|
+
|
|
|
|
|
|
@Autowired
|
|
|
private AsyncUtils asyncUtils;
|
|
|
@@ -232,24 +238,88 @@ public class OrganizationServiceImpl extends BaseMybatisDao<DepartmentMapper> im
|
|
|
//财务与复审切换的时候要切换所有未审核的财务
|
|
|
boolean updateFinance=false;
|
|
|
boolean updateRetrialFinance=false;
|
|
|
- if(StringUtils.isNotBlank(in.getFinanceId())&&!in.getFinanceId().equals(useDep.getFinanceId())){
|
|
|
- dep.setFinanceId(in.getFinanceId());
|
|
|
- //处理订单
|
|
|
- departmentMapper.updateOrderDepFinanceNotExamine(in.getFinanceId(),useDep.getFinanceId());
|
|
|
- List<String> list = torderNewMapper.selectByFinanceNotExamine(in.getFinanceId());
|
|
|
- if (!list.isEmpty()){
|
|
|
- torderNewMapper.updateOrderDepFinanceExamineName(list);
|
|
|
- }
|
|
|
+ //获取需要重新刷新的财务
|
|
|
+ List<String> aids =new ArrayList<>();
|
|
|
+ if(!in.getFinanceId().equals(useDep.getFinanceId())){
|
|
|
+ if(StringUtils.isBlank(in.getFinanceId())){
|
|
|
+ //先将旧的查出来
|
|
|
+ List<String> list = torderNewMapper.selectByFinanceNotExamine(useDep.getFinanceId());
|
|
|
+ //再删除旧单需要审核的
|
|
|
+ torderExamineMapper.deleteExamineFinance(useDep.getFinanceId());
|
|
|
+ if (!list.isEmpty()){
|
|
|
+ torderNewMapper.updateOrderDepFinanceExamineName(list);
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ dep.setFinanceId(in.getFinanceId());
|
|
|
+ //审核人切换
|
|
|
+ departmentMapper.updateOrderDepFinanceNotExamine(in.getFinanceId(),useDep.getFinanceId());
|
|
|
+ //查询切换后的订单刷新审核人
|
|
|
+ List<String> list = torderNewMapper.selectByFinanceNotExamine(in.getFinanceId());
|
|
|
+ if (!list.isEmpty()){
|
|
|
+ torderNewMapper.updateOrderDepFinanceExamineName(list);
|
|
|
+ }
|
|
|
|
|
|
- updateFinance=true;
|
|
|
+ }
|
|
|
+ updateFinance=true;
|
|
|
}
|
|
|
- if (StringUtils.isNotBlank(in.getRetrialFinanceId())&&
|
|
|
- !in.getRetrialFinanceId().equals(useDep.getRetrialFinanceId())){
|
|
|
- dep.setRetrialFinanceId(in.getRetrialFinanceId());
|
|
|
- departmentMapper.updateOrderDepFinanceNotExamine(in.getRetrialFinanceId(),useDep.getRetrialFinanceId());
|
|
|
- List<String> list = torderNewMapper.selectByFinanceNotExamine(in.getRetrialFinanceId());
|
|
|
- if (!list.isEmpty()){
|
|
|
- torderNewMapper.updateOrderDepFinanceExamineName(list);
|
|
|
+ if (StringUtils.isBlank(in.getTechAdminId())||StringUtils.isBlank(in.getOperationGuaranteeId())
|
|
|
+ ||StringUtils.isBlank(in.getRetrialFinanceId())){
|
|
|
+ if(StringUtils.isBlank(in.getTechAdminId()))in.setTechAdminId(null);
|
|
|
+ if(StringUtils.isBlank(in.getOperationGuaranteeId()))in.setOperationGuaranteeId(null);
|
|
|
+ if(StringUtils.isBlank(in.getRetrialFinanceId()))in.setRetrialFinanceId(null);
|
|
|
+ departmentMapper.updateNull(in);
|
|
|
+ }
|
|
|
+ if (!in.getRetrialFinanceId().equals(useDep.getRetrialFinanceId())){
|
|
|
+ if(StringUtils.isBlank(in.getRetrialFinanceId())) {
|
|
|
+ //先将旧的查出来
|
|
|
+ List<String> list = torderNewMapper.selectByFinanceNotExamine(useDep.getRetrialFinanceId());
|
|
|
+ //再删除旧单需要审核的
|
|
|
+ torderExamineMapper.deleteExamineFinance(useDep.getRetrialFinanceId());
|
|
|
+ if (!list.isEmpty()) {
|
|
|
+ //先把药推送到下个流程的查出来
|
|
|
+ for (String s : list) {
|
|
|
+ List<TOrderExamine> tOrderExamines = torderExamineMapper.selectByOrderNo(s, 0);
|
|
|
+ int i = 0;
|
|
|
+ for (TOrderExamine e : tOrderExamines) {
|
|
|
+ if (e.getStatus() == 1) i++;
|
|
|
+ }
|
|
|
+ if (i == tOrderExamines.size()) {
|
|
|
+ //推送订单流程
|
|
|
+ addOrderLog(s,OrderLogProcess.TP.getCode(),"订单修改财务复审,判定审核通过");
|
|
|
+ StringBuilder str = new StringBuilder();
|
|
|
+ TOrderNew tOrderNew = torderNewMapper.selectByPrimaryKey(s);
|
|
|
+ TOrderNewBo order = torderNewMapper.getSaleIdByOno(s);
|
|
|
+ TOrderNew newOrder = new TOrderNew();
|
|
|
+ //如果订单是特批
|
|
|
+ if (tOrderNew.getApproval() == ApprovalNewState.TPDSH.getCode() || tOrderNew.getApproval() == ApprovalNewState.TPBH.getCode()) {
|
|
|
+ if (StringUtils.isNotEmpty(in.getOperationGuaranteeId())) {
|
|
|
+ newOrder.setProcessStatus(ProcessStatus.YYBZSH.getCode());
|
|
|
+ str.append(order.getOperationGuaranteeName()).append(",");
|
|
|
+ aids.add(order.getOperationGuaranteeId());
|
|
|
+ } else if (order.getApprovalStatus() == 0) {
|
|
|
+ newOrder.setProcessStatus(ProcessStatus.YPZXSGLY.getCode());
|
|
|
+ newOrder.setApproval(ApprovalNewState.TPTG.getCode());
|
|
|
+ addOrderLog(s,OrderLogProcess.TP.getCode(),"部门特批审核人未设置,系统自动通过");
|
|
|
+ } else {
|
|
|
+ newOrder.setProcessStatus(ProcessStatus.YPTPSH.getCode());
|
|
|
+ aids.add(order.getApprovalAid());
|
|
|
+ str.append(order.getApprovalName()).append(",");
|
|
|
+ addOrderLog(s,OrderLogProcess.TP.getCode(),"运营保障审核人未设置,系统自动通过");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ newOrder.setExamineName(str.substring(0,str.length()-1));
|
|
|
+ torderNewMapper.updateByPrimaryKeySelective(newOrder);
|
|
|
+ }
|
|
|
+ torderNewMapper.updateOrderDepFinanceExamineName(list);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ dep.setRetrialFinanceId(in.getRetrialFinanceId());
|
|
|
+ departmentMapper.updateOrderDepFinanceNotExamine(in.getRetrialFinanceId(),useDep.getRetrialFinanceId());
|
|
|
+ List<String> list = torderNewMapper.selectByFinanceNotExamine(in.getRetrialFinanceId());
|
|
|
+ if (!list.isEmpty()){
|
|
|
+ torderNewMapper.updateOrderDepFinanceExamineName(list);
|
|
|
+ }
|
|
|
}
|
|
|
updateRetrialFinance=true;
|
|
|
}
|
|
|
@@ -257,13 +327,8 @@ public class OrganizationServiceImpl extends BaseMybatisDao<DepartmentMapper> im
|
|
|
dep.setExpenseFinanceId(in.getExpenseFinanceId());
|
|
|
departmentMapper.updateExpenseFinanceNotExamine(in.getExpenseFinanceId(),useDep.getExpenseFinanceId());
|
|
|
}
|
|
|
-
|
|
|
- //获取需要重新刷新的财务
|
|
|
- List<String> aids =new ArrayList<>();
|
|
|
if (updateFinance){
|
|
|
- if (aids.contains(in.getFinanceId())){
|
|
|
- aids.add(in.getFinanceId());
|
|
|
- }
|
|
|
+ aids.add(in.getFinanceId());
|
|
|
if(!aids.contains(useDep.getFinanceId())){
|
|
|
aids.add(useDep.getFinanceId());
|
|
|
}
|
|
|
@@ -271,7 +336,7 @@ public class OrganizationServiceImpl extends BaseMybatisDao<DepartmentMapper> im
|
|
|
asyncUtils.updateFinanceExamine(in.getFinanceId());
|
|
|
}
|
|
|
if(updateRetrialFinance){
|
|
|
- if (aids.contains(in.getRetrialFinanceId())){
|
|
|
+ if (!aids.contains(in.getRetrialFinanceId())){
|
|
|
aids.add(in.getRetrialFinanceId());
|
|
|
}
|
|
|
if(!aids.contains(useDep.getRetrialFinanceId())){
|
|
|
@@ -295,18 +360,26 @@ public class OrganizationServiceImpl extends BaseMybatisDao<DepartmentMapper> im
|
|
|
if (in.getCashierExamine()==1){
|
|
|
dep.setCashierExamine(in.getCashierExamine());
|
|
|
}
|
|
|
- if (in.getTechAdminId()==null){
|
|
|
- departmentMapper.updateNull(in);
|
|
|
- }
|
|
|
+
|
|
|
return departmentMapper.updateByPrimaryKeySelective(dep);
|
|
|
}
|
|
|
|
|
|
+ private void addOrderLog(String orderNo, Integer process, String remarks) {
|
|
|
+ TOrderLog tl=new TOrderLog();
|
|
|
+ tl.setAid(AFTConstants.SUPERADMIN_ID);
|
|
|
+ tl.setProcess(process);
|
|
|
+ tl.setOrderNo(orderNo);
|
|
|
+ tl.setRemarks(remarks);
|
|
|
+ tOrderLogMapper.insertSelective(tl);
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 如果更换了负责人刷新中间表
|
|
|
*/
|
|
|
private void checkFinaceUpdate(List<String> aids) {
|
|
|
- asyncUtils.financeCoutSwitch(aids);
|
|
|
-
|
|
|
+ if (!aids.isEmpty()){
|
|
|
+ asyncUtils.financeCoutSwitch(aids);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@Override
|