Commit 556d3d98 by huluobin

update

parent 38ea3157
//package com.blt.other.module.cost.controller.cost; package com.blt.other.module.cost.controller.cost;
//
//import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
//import com.bailuntec.cost.api.dto.CostDto; import com.bailuntec.cost.api.dto.CostDto;
//import com.blt.other.common.util.AxiosUtil; import com.blt.other.common.util.AxiosUtil;
//import com.blt.other.common.util.CurUtils; import com.blt.other.common.util.CurUtils;
//import com.blt.other.common.util.IpUtil; import com.blt.other.common.util.IpUtil;
//import com.blt.other.module.cost.dto.CostCheckApiDto; import com.blt.other.module.cost.dto.CostCheckApiDto;
//import com.blt.other.module.cost.model.CostDomain; import com.blt.other.module.cost.model.CostDomain;
//import com.blt.other.module.cost.service.*; import com.blt.other.module.cost.service.*;
//import com.blt.other.module.cost.vo.ApplyCallbackUrlVo; import com.blt.other.module.cost.vo.ApplyCallbackUrlVo;
//import com.blt.other.module.cost.vo.ApplyCallbackVo; import com.blt.other.module.cost.vo.ApplyCallbackVo;
//import com.blt.other.module.cost.vo.ApplyMoneyDetail; import com.blt.other.module.cost.vo.ApplyMoneyDetail;
//import com.blt.other.module.cost.vo.CashierCallbackUrlVo; import com.blt.other.module.cost.vo.CashierCallbackUrlVo;
//import com.blt.other.module.database.model.CostApplycallbackDomain; import com.blt.other.module.database.model.CostApplycallbackDomain;
//import com.blt.other.module.database.model.CostCashiercallbackDomain; import com.blt.other.module.database.model.CostCashiercallbackDomain;
//import com.blt.other.module.database.model.CostCompanyDomain; import com.blt.other.module.database.model.CostCompanyDomain;
//import com.blt.other.module.database.model.CostTofinanceDomain; import com.blt.other.module.database.model.CostTofinanceDomain;
//import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
//import io.swagger.annotations.Api; import io.swagger.annotations.Api;
//import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
//import org.slf4j.Logger; import org.slf4j.Logger;
//import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
//import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
//import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
//import org.springframework.core.io.FileSystemResource; import org.springframework.core.io.FileSystemResource;
//import org.springframework.core.io.InputStreamResource; import org.springframework.core.io.InputStreamResource;
//import org.springframework.http.HttpEntity; import org.springframework.http.HttpEntity;
//import org.springframework.http.HttpHeaders; import org.springframework.http.HttpHeaders;
//import org.springframework.http.MediaType; import org.springframework.http.MediaType;
//import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
//import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.LinkedMultiValueMap;
//import org.springframework.util.MultiValueMap; import org.springframework.util.MultiValueMap;
//import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
//import org.springframework.web.client.RestTemplate; import org.springframework.web.client.RestTemplate;
//
//import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
//import java.io.BufferedReader; import java.io.BufferedReader;
//import java.io.IOException; import java.io.IOException;
//import java.io.InputStreamReader; import java.io.InputStreamReader;
//import java.math.BigDecimal; import java.math.BigDecimal;
//import java.util.*; import java.util.*;
//
//@Api(tags = "费用审核接口") @Api(tags = "费用审核接口")
//@RestController @RestController
//@RequestMapping("cost/check") @RequestMapping("cost/check")
//public class CostCheckController { public class CostCheckController {
//
// private static Logger logger = LoggerFactory.getLogger(CostCheckController.class); private static Logger logger = LoggerFactory.getLogger(CostCheckController.class);
//
// @Autowired @Autowired
// private CostService costService; private CostService costService;
// @Autowired @Autowired
// private CostCompanyService costCompanyService; private CostCompanyService costCompanyService;
// @Autowired @Autowired
// private RestTemplate restTemplate; private RestTemplate restTemplate;
// @Autowired @Autowired
// private CostTofinanceService costTofinanceService; private CostTofinanceService costTofinanceService;
// @Autowired @Autowired
// private CostApplycallbackService costApplycallbackService; private CostApplycallbackService costApplycallbackService;
// @Autowired @Autowired
// private CostCashiercallbackService costCashiercallbackService; private CostCashiercallbackService costCashiercallbackService;
// @Autowired @Autowired
// private CostLogService costLogService; private CostLogService costLogService;
//
// @Value("${url.api.postApplyApi}") @Value("${url.api.postApplyApi}")
// private String postApplyApi; private String postApplyApi;
//
// @Value("${url.my.costApplyCallbackUrlPost}") @Value("${url.my.costApplyCallbackUrlPost}")
// private String costApplyCallbackUrlPost; private String costApplyCallbackUrlPost;
//
// @Value("${url.my.costCashierCallbackUrlPost}") @Value("${url.my.costCashierCallbackUrlPost}")
// private String costCashierCallbackUrlPost; private String costCashierCallbackUrlPost;
//
// @Value("${url.my.lendCostApplyCallBackUrlPost}") @Value("${url.my.lendCostApplyCallBackUrlPost}")
// private String lendCostApplyCallBackUrlPost; private String lendCostApplyCallBackUrlPost;
//
// @Value("${url.my.lendCostCashierCallbackUrlPost}") @Value("${url.my.lendCostCashierCallbackUrlPost}")
// private String lendCostCashierCallbackUrlPost; private String lendCostCashierCallbackUrlPost;
//
// @Value("${url.api.getExchangeRateApi}") @Value("${url.api.getExchangeRateApi}")
// private String getExchangeRateApi; private String getExchangeRateApi;
//
//
// @ApiOperation("获取财务审核系统费用单列表") @ApiOperation("获取财务审核系统费用单列表")
// @GetMapping("getCostCheckList") @GetMapping("getCostCheckList")
// public CostCheckApiDto.GetCostCheckListResp getCostCheckList(@RequestParam Integer pageNum, public CostCheckApiDto.GetCostCheckListResp getCostCheckList(@RequestParam Integer pageNum,
// @RequestParam Integer pageSize, @RequestParam Integer pageSize,
// @RequestParam Integer costStatus) { @RequestParam Integer costStatus) {
// return costService.getCostByStatus(pageNum, pageSize, costStatus); return costService.getCostByStatus(pageNum, pageSize, costStatus);
// } }
//
//
// @ApiOperation("审核通过") @ApiOperation("审核通过")
// @PostMapping("pass") @PostMapping("pass")
// public Map<String, Object> pass(@RequestParam String costNo, public Map<String, Object> pass(@RequestParam String costNo,
// @RequestParam Integer updateuserid) { @RequestParam Integer updateuserid) {
//
// Integer costStatus = costService.getCostStatusByNo(costNo); Integer costStatus = costService.getCostStatusByNo(costNo);
// /** /**
// * 吴通新增 * 吴通新增
// * 如果是支付状态, 就不准改 * 如果是支付状态, 就不准改
// */ */
// if (null != costStatus && costStatus.equals(4)) { if (null != costStatus && costStatus.equals(4)) {
// map = new HashMap<>(); map = new HashMap<>();
// map.put("msg", "error"); map.put("msg", "error");
// map.put("result", 0); map.put("result", 0);
// map.put("finance", false); map.put("finance", false);
// costLogService.save(costNo, Integer.parseInt(updateuserid), "尝试修改已支付费用单,被拦截"); costLogService.save(costNo, Integer.parseInt(updateuserid), "尝试修改已支付费用单,被拦截");
// return map; return map;
// } }
//
// costLogService.save(costNo, Integer.parseInt(updateuserid), "费用系统财务审核通过"); costLogService.save(costNo, Integer.parseInt(updateuserid), "费用系统财务审核通过");
//
// // 审核通过,自动提交到出纳付款 // 审核通过,自动提交到出纳付款
// boolean toFinance = tofinanceMethod(costNo); boolean toFinance = tofinanceMethod(costNo);
// if (toFinance) { if (toFinance) {
// costLogService.save(costNo, Integer.parseInt(updateuserid), "出纳自动审核通过"); costLogService.save(costNo, Integer.parseInt(updateuserid), "出纳自动审核通过");
// map = changeStatus(costNo, 2); map = changeStatus(costNo, 2);
// } else { } else {
// costLogService.save(costNo, Integer.parseInt(updateuserid), "出纳审核失败"); costLogService.save(costNo, Integer.parseInt(updateuserid), "出纳审核失败");
// map = new HashMap<>(); map = new HashMap<>();
// } }
// map.put("finance", toFinance); map.put("finance", toFinance);
// return map; return map;
// } }
//
// @ApiOperation("驳回审核") @ApiOperation("驳回审核")
// @PostMapping("reject") @PostMapping("reject")
// public Map<String, Object> reject(HttpServletRequest request, HttpServletResponse response) { public Map<String, Object> reject(HttpServletRequest request, HttpServletResponse response) {
// AxiosUtil.setCors(response, request); AxiosUtil.setCors(response, request);
//
// String costNo = request.getParameter("costNo"); String costNo = request.getParameter("costNo");
// String rejectReason = request.getParameter("rejectReason"); String rejectReason = request.getParameter("rejectReason");
// String updateuserid = request.getParameter("updateuserid"); String updateuserid = request.getParameter("updateuserid");
// CostDomain costDomain = new CostDomain(); CostDomain costDomain = new CostDomain();
// costDomain.setCostNo(costNo); costDomain.setCostNo(costNo);
// costDomain.setRejectReason(rejectReason); costDomain.setRejectReason(rejectReason);
// costDomain.setRejectTime(new Date()); costDomain.setRejectTime(new Date());
// Map<String, Object> stringObjectMap = costService.updateCost(costDomain); Map<String, Object> stringObjectMap = costService.updateCost(costDomain);
// Map<String, Object> map = changeStatus(costNo, 3); Map<String, Object> map = changeStatus(costNo, 3);
// costLogService.save(costNo, Integer.parseInt(updateuserid), "费用系统财务审核驳回:" + rejectReason); costLogService.save(costNo, Integer.parseInt(updateuserid), "费用系统财务审核驳回:" + rejectReason);
//
// return map; return map;
// } }
//
//
// @ApiOperation("财务审核回调接口") @ApiOperation("财务审核回调接口")
// @PostMapping(value = "ApplyCallbackUrl", consumes = "application/json") @PostMapping(value = "ApplyCallbackUrl", consumes = "application/json")
// public String applyCallbackUrl(HttpServletRequest request) { public String applyCallbackUrl(HttpServletRequest request) {
// String result = null; String result = null;
// String line = null; String line = null;
// try { try {
// BufferedReader br = new BufferedReader(new InputStreamReader(request.getInputStream())); BufferedReader br = new BufferedReader(new InputStreamReader(request.getInputStream()));
// line = br.readLine(); line = br.readLine();
// } catch (IOException e) { } catch (IOException e) {
// logger.error(IpUtil.getIpAddr(request) + " CostApplyCallbackUrl " + " 费用系统财务审核反馈信息获取失败"); logger.error(IpUtil.getIpAddr(request) + " CostApplyCallbackUrl " + " 费用系统财务审核反馈信息获取失败");
// result = "{result:false,msg:\"发生错误\"}"; result = "{result:false,msg:\"发生错误\"}";
// return result; return result;
// } }
// line = line.replace("\\", ""); line = line.replace("\\", "");
// // 格式化为标准 json 格式 // 格式化为标准 json 格式
// int data = line.lastIndexOf("Data"); int data = line.lastIndexOf("Data");
// int id = line.lastIndexOf("id"); int id = line.lastIndexOf("id");
// String substring1 = line.substring(0, data + 6); String substring1 = line.substring(0, data + 6);
// String substring2 = line.substring(data + 7, id - 4); String substring2 = line.substring(data + 7, id - 4);
// String substring3 = line.substring(id - 3); String substring3 = line.substring(id - 3);
// line = substring1 + substring2 + substring3; line = substring1 + substring2 + substring3;
// line = line.toLowerCase(); line = line.toLowerCase();
//
// //保存为 bean,并且将反馈信息保存到数据库 //保存为 bean,并且将反馈信息保存到数据库
// ObjectMapper mapper = new ObjectMapper(); ObjectMapper mapper = new ObjectMapper();
// ApplyCallbackUrlVo applyCallbackUrlVo = null; ApplyCallbackUrlVo applyCallbackUrlVo = null;
// try { try {
// applyCallbackUrlVo = mapper.readValue(line, ApplyCallbackUrlVo.class); applyCallbackUrlVo = mapper.readValue(line, ApplyCallbackUrlVo.class);
// if (null == applyCallbackUrlVo) { if (null == applyCallbackUrlVo) {
// logger.error("保存财务审核信息发生错误:" + line); logger.error("保存财务审核信息发生错误:" + line);
// result = "{result:false,msg:\"发生错误\"}"; result = "{result:false,msg:\"发生错误\"}";
// return result; return result;
// } }
// // 执行保存反馈信息流程 // 执行保存反馈信息流程
// CostApplycallbackDomain applycallbackDomain = new CostApplycallbackDomain(); CostApplycallbackDomain applycallbackDomain = new CostApplycallbackDomain();
// BeanUtils.copyProperties(applyCallbackUrlVo.getData().getData(), applycallbackDomain); BeanUtils.copyProperties(applyCallbackUrlVo.getData().getData(), applycallbackDomain);
// String costNo = applyCallbackUrlVo.getId().toUpperCase(); String costNo = applyCallbackUrlVo.getId().toUpperCase();
// if (costNo.contains("-")) { if (costNo.contains("-")) {
// costNo = costNo.split("-")[0]; costNo = costNo.split("-")[0];
// } }
// applycallbackDomain.setCostNo(costNo); applycallbackDomain.setCostNo(costNo);
// applycallbackDomain.setMessage(applyCallbackUrlVo.getData().getMessage().toUpperCase()); applycallbackDomain.setMessage(applyCallbackUrlVo.getData().getMessage().toUpperCase());
// applycallbackDomain.setApplyno(applycallbackDomain.getApplyno().toUpperCase()); applycallbackDomain.setApplyno(applycallbackDomain.getApplyno().toUpperCase());
// Integer integer = costApplycallbackService.saveApplycallbackResponse(applycallbackDomain); Integer integer = costApplycallbackService.saveApplycallbackResponse(applycallbackDomain);
// logger.warn("保存财务审核信息成功:" + integer + " " + line); logger.warn("保存财务审核信息成功:" + integer + " " + line);
// } catch (IOException e) { } catch (IOException e) {
// logger.error("保存财务审核信息发生错误:" + line); logger.error("保存财务审核信息发生错误:" + line);
// result = "{result:false,msg:\"发生错误\"}"; result = "{result:false,msg:\"发生错误\"}";
// return result; return result;
// } }
// result = "{result:true,msg:\"\"}"; result = "{result:true,msg:\"\"}";
// return result; return result;
// } }
//
// @ApiOperation("财务付款回调接口") @ApiOperation("财务付款回调接口")
// @PostMapping(value = "CashierCallbackUrl", consumes = "application/json") @PostMapping(value = "CashierCallbackUrl", consumes = "application/json")
// public String cashierCallbackUrl(HttpServletRequest request) { public String cashierCallbackUrl(HttpServletRequest request) {
// String result; String result;
//
// // 将状态改为审核通过、已付款 // 将状态改为审核通过、已付款
// logger.warn("费用系统出纳回调" + IpUtil.getIpAddr(request) + " CashierCallbackUrl "); logger.warn("费用系统出纳回调" + IpUtil.getIpAddr(request) + " CashierCallbackUrl ");
//
// String line; String line;
// try { try {
// BufferedReader br = new BufferedReader(new InputStreamReader(request.getInputStream())); BufferedReader br = new BufferedReader(new InputStreamReader(request.getInputStream()));
// line = br.readLine(); line = br.readLine();
// line = line.replace("\\", ""); line = line.replace("\\", "");
//
// // 格式化为标准 json 格式 // 格式化为标准 json 格式
// int data = line.lastIndexOf("Data"); int data = line.lastIndexOf("Data");
// int id = line.lastIndexOf("id"); int id = line.lastIndexOf("id");
// String substring1 = line.substring(0, data + 6); String substring1 = line.substring(0, data + 6);
// String substring2 = line.substring(data + 7, id - 4); String substring2 = line.substring(data + 7, id - 4);
// String substring3 = line.substring(id - 3); String substring3 = line.substring(id - 3);
// line = substring1 + substring2 + substring3; line = substring1 + substring2 + substring3;
// line = line.toLowerCase(); line = line.toLowerCase();
// line = line.replace("_", ""); line = line.replace("_", "");
// logger.warn("费用系统支付反馈信息:" + line); logger.warn("费用系统支付反馈信息:" + line);
//
// ObjectMapper mapper = new ObjectMapper(); ObjectMapper mapper = new ObjectMapper();
// CashierCallbackUrlVo cashierCallbackUrlVo = null; CashierCallbackUrlVo cashierCallbackUrlVo = null;
// CostCashiercallbackDomain costCashiercallbackDomain = new CostCashiercallbackDomain();check/lend/CashierCallbackUrl CostCashiercallbackDomain costCashiercallbackDomain = new CostCashiercallbackDomain();check/lend/CashierCallbackUrl
// BigDecimal toRmbRate = null; // 转人民币汇率 BigDecimal toRmbRate = null; // 转人民币汇率
// try { try {
// cashierCallbackUrlVo = mapper.readValue(line, CashierCallbackUrlVo.class); cashierCallbackUrlVo = mapper.readValue(line, CashierCallbackUrlVo.class);
// if (cashierCallbackUrlVo == null) { if (cashierCallbackUrlVo == null) {
// logger.error("费用系统保存出纳付款信息发生错误:" + line); logger.error("费用系统保存出纳付款信息发生错误:" + line);
// result = "{result:false,msg:\"发生错误\"}"; result = "{result:false,msg:\"发生错误\"}";
// return result; return result;
// } }
// BeanUtils.copyProperties(cashierCallbackUrlVo.getData(), costCashiercallbackDomain); BeanUtils.copyProperties(cashierCallbackUrlVo.getData(), costCashiercallbackDomain);
// BeanUtils.copyProperties(cashierCallbackUrlVo.getData().getData(), costCashiercallbackDomain); BeanUtils.copyProperties(cashierCallbackUrlVo.getData().getData(), costCashiercallbackDomain);
// BeanUtils.copyProperties(cashierCallbackUrlVo.getData().getData().getPaydetail(), costCashiercallbackDomain); BeanUtils.copyProperties(cashierCallbackUrlVo.getData().getData().getPaydetail(), costCashiercallbackDomain);
// String costNo = cashierCallbackUrlVo.getId().toUpperCase(); String costNo = cashierCallbackUrlVo.getId().toUpperCase();
// if (costNo.contains("-")) { if (costNo.contains("-")) {
// String[] split = costNo.split("-"); String[] split = costNo.split("-");
// costNo = split[0]; costNo = split[0];
// } }
// costCashiercallbackDomain.setCostNo(costNo); costCashiercallbackDomain.setCostNo(costNo);
// costCashiercallbackDomain.setMessage(costCashiercallbackDomain.getMessage().toUpperCase()); costCashiercallbackDomain.setMessage(costCashiercallbackDomain.getMessage().toUpperCase());
// costCashiercallbackDomain.setPayno(costCashiercallbackDomain.getPayno().toUpperCase()); costCashiercallbackDomain.setPayno(costCashiercallbackDomain.getPayno().toUpperCase());
//
// // 被出纳驳回 // 被出纳驳回
// if (costCashiercallbackDomain.getMessage().contains("被驳回")) { if (costCashiercallbackDomain.getMessage().contains("被驳回")) {
// boolean b = finansysReject(costCashiercallbackDomain); boolean b = finansysReject(costCashiercallbackDomain);
// if (b) { if (b) {
// logger.info("出纳驳回,费用单状态更改成功" + costCashiercallbackDomain); logger.info("出纳驳回,费用单状态更改成功" + costCashiercallbackDomain);
// costLogService.save(costNo, costCashiercallbackDomain.getPayuserid(), "被出纳驳回:" + costCashiercallbackDomain.getPaynote()); costLogService.save(costNo, costCashiercallbackDomain.getPayuserid(), "被出纳驳回:" + costCashiercallbackDomain.getPaynote());
// } else { } else {
// logger.info("出纳驳回,费用单状态更改失败" + costCashiercallbackDomain); logger.info("出纳驳回,费用单状态更改失败" + costCashiercallbackDomain);
// } }
// result = "{result:true,msg:\"出纳驳回\"}"; result = "{result:true,msg:\"出纳驳回\"}";
// return result; return result;
// } else { } else {
// // 获取xx货币-->CNY的汇率 // 获取xx货币-->CNY的汇率
// toRmbRate = CurUtils.getCur(costCashiercallbackDomain.getCashierunitcode().toUpperCase(), "CNY", getExchangeRateApi); toRmbRate = CurUtils.getCur(costCashiercallbackDomain.getCashierunitcode().toUpperCase(), "CNY", getExchangeRateApi);
// costCashiercallbackDomain.setToRmbRate(toRmbRate); costCashiercallbackDomain.setToRmbRate(toRmbRate);
// } }
//
// // 保存出纳付款记录 // 保存出纳付款记录
// Integer integer = costCashiercallbackService.saveCostCashiercallbackResponse(costCashiercallbackDomain); Integer integer = costCashiercallbackService.saveCostCashiercallbackResponse(costCashiercallbackDomain);
// logger.warn("保存出纳付款信息成功:" + integer + " " + costCashiercallbackDomain); logger.warn("保存出纳付款信息成功:" + integer + " " + costCashiercallbackDomain);
// } catch (IOException e) { } catch (IOException e) {
// logger.error("保存出纳付款信息发生错误:" + line); logger.error("保存出纳付款信息发生错误:" + line);
// result = "{result:false,msg:\"发生错误\"}"; result = "{result:false,msg:\"发生错误\"}";
// return result; return result;
// } }
// // 付款成功,更改费用单信息,否则返回失败 // 付款成功,更改费用单信息,否则返回失败
// CostDomain costDomain = costService.getCostDomainByNo(costCashiercallbackDomain.getCostNo()); CostDomain costDomain = costService.getCostDomainByNo(costCashiercallbackDomain.getCostNo());
// costDomain.setCostStatus(4); costDomain.setCostStatus(4);
//
// if (null != costDomain.getIsLend()) { if (null != costDomain.getIsLend()) {
// if (costDomain.getIsLend() == 1 && BigDecimal.ZERO.compareTo(costDomain.getHadPay()) >= 0) { if (costDomain.getIsLend() == 1 && BigDecimal.ZERO.compareTo(costDomain.getHadPay()) >= 0) {
// costDomain.setLendStatus(1); costDomain.setLendStatus(1);
// } }
// } }
//
// costDomain.setPayUserId(costCashiercallbackDomain.getPayuserid()); costDomain.setPayUserId(costCashiercallbackDomain.getPayuserid());
// costDomain.setPayTime(new Date()); costDomain.setPayTime(new Date());
// costDomain.setAmountRmb(costCashiercallbackDomain.getCashierpaymoneyrmb()); costDomain.setAmountRmb(costCashiercallbackDomain.getCashierpaymoneyrmb());
// costDomain.setToRmbRate(toRmbRate); costDomain.setToRmbRate(toRmbRate);
// Map<String, Object> map = costService.updateCost(costDomain); Map<String, Object> map = costService.updateCost(costDomain);
//
// if (null != map) { if (null != map) {
// result = "{result:true,msg:\"保存成功\"}"; result = "{result:true,msg:\"保存成功\"}";
// costLogService.save(costCashiercallbackDomain.getCostNo(), costCashiercallbackDomain.getPayuserid(), "出纳收/付款成功:" + costCashiercallbackDomain.getPaynote()); costLogService.save(costCashiercallbackDomain.getCostNo(), costCashiercallbackDomain.getPayuserid(), "出纳收/付款成功:" + costCashiercallbackDomain.getPaynote());
// } else { } else {
// result = "{result:false,msg:\"发生错误\"}"; result = "{result:false,msg:\"发生错误\"}";
// } }
// } catch (IOException e) { } catch (IOException e) {
// logger.error(IpUtil.getIpAddr(request) + " CashierCallbackUrl " + " 出纳付款反馈信息获取失败"); logger.error(IpUtil.getIpAddr(request) + " CashierCallbackUrl " + " 出纳付款反馈信息获取失败");
// result = "{result:false,msg:\"发生错误\"}"; result = "{result:false,msg:\"发生错误\"}";
// return result; return result;
// } }
// return result; return result;
// } }
//
// /** /**
// * 出纳驳回 * 出纳驳回
// * *
// * @param domain * @param domain
// * @return * @return
// */ */
// private boolean finansysReject(CostCashiercallbackDomain domain) { private boolean finansysReject(CostCashiercallbackDomain domain) {
// // 保存驳回信息 // 保存驳回信息
// Integer integer = costCashiercallbackService.saveCostCashiercallbackResponse(domain); Integer integer = costCashiercallbackService.saveCostCashiercallbackResponse(domain);
// if (null != integer && integer >= 1) { if (null != integer && integer >= 1) {
// // 费用单状态改为审核驳回,添加驳回理由 // 费用单状态改为审核驳回,添加驳回理由
// // 修复驳回后提交出现费用单已存在的问题 // 修复驳回后提交出现费用单已存在的问题
// // 将后缀添加到 detail_key 字段 // 将后缀添加到 detail_key 字段
// CostDomain oldCost = costService.getByNo(domain.getCostNo()); CostDomain oldCost = costService.getByNo(domain.getCostNo());
// String oldDetailKey = oldCost.getDetailKey(); String oldDetailKey = oldCost.getDetailKey();
// CostDomain costDomain = new CostDomain(); CostDomain costDomain = new CostDomain();
// costDomain.setId(oldCost.getId()); costDomain.setId(oldCost.getId());
// if (null != oldDetailKey && oldDetailKey.contains("-")) { if (null != oldDetailKey && oldDetailKey.contains("-")) {
// String[] split = oldDetailKey.split("-"); String[] split = oldDetailKey.split("-");
// if (split.length > 1) { if (split.length > 1) {
// int i = Integer.parseInt(split[1]) + 1; int i = Integer.parseInt(split[1]) + 1;
// costDomain.setDetailKey(split[0] + "-" + i); costDomain.setDetailKey(split[0] + "-" + i);
// } }
// } else { } else {
// costDomain.setDetailKey(oldCost.getCostNo() + "-" + 1); costDomain.setDetailKey(oldCost.getCostNo() + "-" + 1);
// } }
// costDomain.setRejectReason(domain.getPaynote()); costDomain.setRejectReason(domain.getPaynote());
// costDomain.setCostStatus(3); costDomain.setCostStatus(3);
// costDomain.setRejectType(2); costDomain.setRejectType(2);
// Integer result = costService.updateById(costDomain); Integer result = costService.updateById(costDomain);
// } }
// return true; return true;
// } }
//
// /** /**
// * 改变费用单状态 * 改变费用单状态
// * *
// * @param costNo * @param costNo
// * @param costStatus * @param costStatus
// * @return * @return
// */ */
// private Map<String, Object> changeStatus(String costNo, Integer costStatus) { private Map<String, Object> changeStatus(String costNo, Integer costStatus) {
// CostDomain costDomain = costService.getCostDomainByNo(costNo); CostDomain costDomain = costService.getCostDomainByNo(costNo);
// costDomain.setCostNo(costNo); costDomain.setCostNo(costNo);
// costDomain.setCostStatus(costStatus); costDomain.setCostStatus(costStatus);
// if (costStatus == 2) { if (costStatus == 2) {
// costDomain.setAuditTime(new Date()); costDomain.setAuditTime(new Date());
// } }
// if (null != costDomain.getIsLend()) { if (null != costDomain.getIsLend()) {
// if (1 == costDomain.getIsLend() && 4 == costStatus) { if (1 == costDomain.getIsLend() && 4 == costStatus) {
// costDomain.setLendStatus(1); costDomain.setLendStatus(1);
// } }
// } }
// Map<String, Object> map = costService.updateCost(costDomain); Map<String, Object> map = costService.updateCost(costDomain);
//
// return map; return map;
//
// } }
//
// /** /**
// * 提交出纳系统 * 提交出纳系统
// * *
// * @param costNo * @param costNo
// * @return * @return
// */ */
// public boolean tofinanceMethod(String costNo) { public boolean tofinanceMethod(String costNo) {
// // 获取费用单信息 // 获取费用单信息
// List<ApplyMoneyDetail> applyMoneyDetailList = new ArrayList<>(); List<ApplyMoneyDetail> applyMoneyDetailList = new ArrayList<>();
// ApplyMoneyDetail applyMoneyDetail = new ApplyMoneyDetail(); ApplyMoneyDetail applyMoneyDetail = new ApplyMoneyDetail();
// CostDomain cost = costService.getCostDomainByNo(costNo); CostDomain cost = costService.getCostDomainByNo(costNo);
//
// CostCompanyDomain companyByCompanyNo = costCompanyService.getCompanyByCompanyNo(cost.getCompanyNo()); CostCompanyDomain companyByCompanyNo = costCompanyService.getCompanyByCompanyNo(cost.getCompanyNo());
//
// // 提交财务 // 提交财务
// MultiValueMap<String, Object> requestEntity = new LinkedMultiValueMap<>(); MultiValueMap<String, Object> requestEntity = new LinkedMultiValueMap<>();
//
// requestEntity.add("CompanyMainName", cost.getCompanyName()); // 公司主体(CompanyMainName)不可为空; requestEntity.add("CompanyMainName", cost.getCompanyName()); // 公司主体(CompanyMainName)不可为空;
// // 借支单补差额的付款单,单独设置回调地址; // 借支单补差额的付款单,单独设置回调地址;
// requestEntity.add("Title", cost.getCostNo()); requestEntity.add("Title", cost.getCostNo());
// if (costNo.startsWith("S")) { if (costNo.startsWith("S")) {
// logger.info("补差额的付款单:" + costNo); logger.info("补差额的付款单:" + costNo);
// applyMoneyDetail.setName("借支单补差额"); applyMoneyDetail.setName("借支单补差额");
// requestEntity.add("ApplyCallbackUrl", lendCostApplyCallBackUrlPost); // 审核回调地址(ApplyCallbackUrl)不可为空; requestEntity.add("ApplyCallbackUrl", lendCostApplyCallBackUrlPost); // 审核回调地址(ApplyCallbackUrl)不可为空;
// requestEntity.add("CashierCallbackUrl", lendCostCashierCallbackUrlPost); // 出纳回调地址(CashierCallbackUrl)不可为空; requestEntity.add("CashierCallbackUrl", lendCostCashierCallbackUrlPost); // 出纳回调地址(CashierCallbackUrl)不可为空;
//
// } else { } else {
// requestEntity.add("ApplyCallbackUrl", costApplyCallbackUrlPost); // 审核回调地址(ApplyCallbackUrl)不可为空; requestEntity.add("ApplyCallbackUrl", costApplyCallbackUrlPost); // 审核回调地址(ApplyCallbackUrl)不可为空;
// requestEntity.add("CashierCallbackUrl", costCashierCallbackUrlPost); // 出纳回调地址(CashierCallbackUrl)不可为空; requestEntity.add("CashierCallbackUrl", costCashierCallbackUrlPost); // 出纳回调地址(CashierCallbackUrl)不可为空;
// } }
// requestEntity.add("UnitCode", cost.getDic()); // 币种编号(UnitCode)不可为空; requestEntity.add("UnitCode", cost.getDic()); // 币种编号(UnitCode)不可为空;
// requestEntity.add("UnitName", cost.getDic()); // 币种名称(UnitName)不可为空; requestEntity.add("UnitName", cost.getDic()); // 币种名称(UnitName)不可为空;
// // 交易对象改为付款/收款单位 // 交易对象改为付款/收款单位
// requestEntity.add("TradeObjectID", companyByCompanyNo.getValue() + ""); requestEntity.add("TradeObjectID", companyByCompanyNo.getValue() + "");
// requestEntity.add("TradeObjectName", cost.getBankCompany() + ""); // 交易对象(TradeObjectID/TradeObjectName)不可为空; requestEntity.add("TradeObjectName", cost.getBankCompany() + ""); // 交易对象(TradeObjectID/TradeObjectName)不可为空;
// requestEntity.add("BankNameto", "" + cost.getBankName()); requestEntity.add("BankNameto", "" + cost.getBankName());
// requestEntity.add("BankCardto", "" + cost.getBankCard()); requestEntity.add("BankCardto", "" + cost.getBankCard());
// requestEntity.add("BankCardUserto", "" + cost.getBankCardUser()); // 交易对象账户(BankNameto/BankCardto/BankCardUserto)资料不完整; requestEntity.add("BankCardUserto", "" + cost.getBankCardUser()); // 交易对象账户(BankNameto/BankCardto/BankCardUserto)资料不完整;
// requestEntity.add("SourceCode", "newCost"); requestEntity.add("SourceCode", "newCost");
// requestEntity.add("SourceTypeCode", "newCostType"); // newOtherPurchase申请来源(SourceCode/SourceTypeCode)不可为空; requestEntity.add("SourceTypeCode", "newCostType"); // newOtherPurchase申请来源(SourceCode/SourceTypeCode)不可为空;
// // 账期 0 PayDay // 账期 0 PayDay
// requestEntity.add("PayDay", 0); requestEntity.add("PayDay", 0);
// // 预计付款时间 ExpectPayTime // 预计付款时间 ExpectPayTime
// requestEntity.add("ExpectPayTime", new Date()); requestEntity.add("ExpectPayTime", new Date());
//
// applyMoneyDetail.setMoney(cost.getAmount()); applyMoneyDetail.setMoney(cost.getAmount());
// applyMoneyDetail.setMoneyRmb(cost.getAmount()); applyMoneyDetail.setMoneyRmb(cost.getAmount());
//
// if (1 == cost.getCostForm()) { if (1 == cost.getCostForm()) {
// requestEntity.add("ApplyType", "" + 1); // 申请类型(ApplyType)不存在;申请类型:1#付款;2#收款;3#无需付款; requestEntity.add("ApplyType", "" + 1); // 申请类型(ApplyType)不存在;申请类型:1#付款;2#收款;3#无需付款;
// applyMoneyDetail.setName("费用单付款"); applyMoneyDetail.setName("费用单付款");
// } else if (2 == cost.getCostForm()) { } else if (2 == cost.getCostForm()) {
// requestEntity.add("ApplyType", "" + 2); // 申请类型(ApplyType)不存在;申请类型:1#付款;2#收款;3#无需付款; requestEntity.add("ApplyType", "" + 2); // 申请类型(ApplyType)不存在;申请类型:1#付款;2#收款;3#无需付款;
// applyMoneyDetail.setName("费用单收款"); applyMoneyDetail.setName("费用单收款");
// } else if (3 == cost.getCostForm() && 1 == cost.getIsLend()) { } else if (3 == cost.getCostForm() && 1 == cost.getIsLend()) {
// requestEntity.add("ApplyType", "" + 1); // 申请类型(ApplyType)不存在;申请类型:1#付款;2#收款;3#无需付款; requestEntity.add("ApplyType", "" + 1); // 申请类型(ApplyType)不存在;申请类型:1#付款;2#收款;3#无需付款;
// applyMoneyDetail.setName("借支单付款"); applyMoneyDetail.setName("借支单付款");
// } }
// requestEntity.add("UserAcctID", "" + cost.getCreateUserid()); requestEntity.add("UserAcctID", "" + cost.getCreateUserid());
// requestEntity.add("UserAcctName", "" + cost.getCreateUsername()); // 申请人(UserAcctID/UserAcctName)不存在; requestEntity.add("UserAcctName", "" + cost.getCreateUsername()); // 申请人(UserAcctID/UserAcctName)不存在;
//
// applyMoneyDetail.setRemark(""); applyMoneyDetail.setRemark("");
// applyMoneyDetailList.add(applyMoneyDetail); applyMoneyDetailList.add(applyMoneyDetail);
//
// requestEntity.add("MoneyDetail", applyMoneyDetailList); // 出纳申请金额明细(MoneyDetail)不可为空; requestEntity.add("MoneyDetail", applyMoneyDetailList); // 出纳申请金额明细(MoneyDetail)不可为空;
//
// // 设置 detailKey // 设置 detailKey
// String detailKey = cost.getDetailKey(); String detailKey = cost.getDetailKey();
// if (null == detailKey || !detailKey.contains("F")) { if (null == detailKey || !detailKey.contains("F")) {
// detailKey = cost.getCostNo(); detailKey = cost.getCostNo();
// } }
// requestEntity.add("DetailKey", detailKey); // 回调必要的key参数(DetailKey)不能为空; requestEntity.add("DetailKey", detailKey); // 回调必要的key参数(DetailKey)不能为空;
// // 吴通 增加费用大类 // 吴通 增加费用大类
// requestEntity.add("TypeName", cost.getTypeName()); requestEntity.add("TypeName", cost.getTypeName());
// Map<String, Object> map = requestEntity.toSingleValueMap(); Map<String, Object> map = requestEntity.toSingleValueMap();
// String s = JSON.toJSONString(map); String s = JSON.toJSONString(map);
// logger.info(cost.getCostNo() + " 费用单提交财务审核信息:" + s); logger.info(cost.getCostNo() + " 费用单提交财务审核信息:" + s);
// HttpHeaders headers = new HttpHeaders(); HttpHeaders headers = new HttpHeaders();
// headers.setContentType(MediaType.APPLICATION_JSON); headers.setContentType(MediaType.APPLICATION_JSON);
//
// HttpEntity<String> entity = new HttpEntity<>(s, headers); HttpEntity<String> entity = new HttpEntity<>(s, headers);
// ResponseEntity<String> response = restTemplate.postForEntity(postApplyApi, entity, String.class); ResponseEntity<String> response = restTemplate.postForEntity(postApplyApi, entity, String.class);
// logger.info(cost.getCostNo() + " 费用单提交审核反馈信息:" + response); logger.info(cost.getCostNo() + " 费用单提交审核反馈信息:" + response);
//
// String strBody = null; String strBody = null;
// if (response.getStatusCodeValue() == 200) { if (response.getStatusCodeValue() == 200) {
// strBody = response.getBody(); strBody = response.getBody();
// strBody = strBody.replace("\\", ""); strBody = strBody.replace("\\", "");
// strBody = strBody.toLowerCase(); strBody = strBody.toLowerCase();
// if (strBody.contains("申请单已存在")) { if (strBody.contains("申请单已存在")) {
// logger.info(cost.getCostNo() + " 申请单已存在:" + strBody); logger.info(cost.getCostNo() + " 申请单已存在:" + strBody);
// return true; return true;
// } else if (strBody.contains("创建")) { } else if (strBody.contains("创建")) {
// // 将 strBody 保存到数据库 costTofinance 表 // 将 strBody 保存到数据库 costTofinance 表
// ObjectMapper mapper = new ObjectMapper(); ObjectMapper mapper = new ObjectMapper();
// try { try {
// // 将 strBody 转作为标准 JSONString 格式 // 将 strBody 转作为标准 JSONString 格式
// int i = strBody.lastIndexOf("data\":"); int i = strBody.lastIndexOf("data\":");
// String substring1 = strBody.substring(0, i + 6); String substring1 = strBody.substring(0, i + 6);
// String substring2 = strBody.substring(i + 7, strBody.length() - 2); String substring2 = strBody.substring(i + 7, strBody.length() - 2);
// strBody = substring1 + substring2 + "}"; strBody = substring1 + substring2 + "}";
// logger.warn(strBody); logger.warn(strBody);
// ApplyCallbackVo applyCallbackVo = mapper.readValue(strBody, ApplyCallbackVo.class); ApplyCallbackVo applyCallbackVo = mapper.readValue(strBody, ApplyCallbackVo.class);
//
// // 将反馈信息保存到数据库 // 将反馈信息保存到数据库
// if (null != applyCallbackVo && applyCallbackVo.isSuccess()) { if (null != applyCallbackVo && applyCallbackVo.isSuccess()) {
// CostTofinanceDomain costTofinanceDomain = new CostTofinanceDomain(); CostTofinanceDomain costTofinanceDomain = new CostTofinanceDomain();
// BeanUtils.copyProperties(applyCallbackVo.getData(), costTofinanceDomain); BeanUtils.copyProperties(applyCallbackVo.getData(), costTofinanceDomain);
// costTofinanceDomain.setCostNo(cost.getCostNo().toUpperCase()); costTofinanceDomain.setCostNo(cost.getCostNo().toUpperCase());
// costTofinanceDomain.setCode(costTofinanceDomain.getCode().toUpperCase()); costTofinanceDomain.setCode(costTofinanceDomain.getCode().toUpperCase());
// // 执行 insert 流程 // 执行 insert 流程
// Integer integer = costTofinanceService.saveCostTofinanceMsg(costTofinanceDomain); Integer integer = costTofinanceService.saveCostTofinanceMsg(costTofinanceDomain);
// return true; return true;
// } }
// } catch (IOException e) { } catch (IOException e) {
// logger.error("财务审核申请单信息保存到数据库失败" + strBody); logger.error("财务审核申请单信息保存到数据库失败" + strBody);
// return false; return false;
// } }
//
// } }
// } }
// return false; return false;
// } }
//
// // ================================== 结束费用 ====================================================== // ================================== 结束费用 ======================================================
// @PostMapping("finish") @PostMapping("finish")
// public Map<String, Object> finish(HttpServletRequest request, HttpServletResponse response) { public Map<String, Object> finish(HttpServletRequest request, HttpServletResponse response) {
// AxiosUtil.setCors(response, request); AxiosUtil.setCors(response, request);
//
// String costNo = request.getParameter("costNo"); String costNo = request.getParameter("costNo");
// Map<String, Object> map = changeStatus(costNo, 7); Map<String, Object> map = changeStatus(costNo, 7);
//
// return map; return map;
// } }
//
// // ================================== 文件下载 ====================================================== // ================================== 文件下载 ======================================================
// @GetMapping("download") @GetMapping("download")
// public ResponseEntity<InputStreamResource> download(HttpServletRequest request, HttpServletResponse response) throws IOException { public ResponseEntity<InputStreamResource> download(HttpServletRequest request, HttpServletResponse response) throws IOException {
//// AxiosUtil.setCors(response,request); // AxiosUtil.setCors(response,request);
// String costNo = request.getParameter("costNo"); String costNo = request.getParameter("costNo");
// String fileType = request.getParameter("fileType"); String fileType = request.getParameter("fileType");
// CostDomain costByCostNo = costService.getCostByCostNo(costNo); CostDomain costByCostNo = costService.getCostByCostNo(costNo);
// CostDto cost = costByCostNo.castToDto(); CostDto cost = costByCostNo.castToDto();
//
// String filePath = null; String filePath = null;
// String fileName = null; String fileName = null;
// if ("file".equals(fileType)) { if ("file".equals(fileType)) {
// filePath = cost.getFilePath(); filePath = cost.getFilePath();
// fileName = cost.getFileName(); fileName = cost.getFileName();
// } else if ("morFile".equals(fileType)) { } else if ("morFile".equals(fileType)) {
// filePath = cost.getMorFilePath(); filePath = cost.getMorFilePath();
// fileName = cost.getMorFileName(); fileName = cost.getMorFileName();
// } }
// FileSystemResource file = new FileSystemResource(filePath); FileSystemResource file = new FileSystemResource(filePath);
// HttpHeaders headers = new HttpHeaders(); HttpHeaders headers = new HttpHeaders();
// headers.add("Cache-Control", "no-cache, no-store, must-revalidate"); headers.add("Cache-Control", "no-cache, no-store, must-revalidate");
// // new String(fileName.getBytes("UTF-8"),"iso-8859-1") 解决文件下载的时候文件名乱码的问题 // 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("Content-Disposition", String.format("attachment; filename=\"%s\"", new String(fileName.getBytes("UTF-8"), "iso-8859-1")));
// headers.add("Pragma", "no-cache"); headers.add("Pragma", "no-cache");
// headers.add("Expires", "0"); headers.add("Expires", "0");
//
// return ResponseEntity return ResponseEntity
// .ok() .ok()
// .headers(headers) .headers(headers)
// .contentLength(file.contentLength()) .contentLength(file.contentLength())
// .contentType(MediaType.parseMediaType("application/octet-stream")) .contentType(MediaType.parseMediaType("application/octet-stream"))
// .body(new InputStreamResource(file.getInputStream())); .body(new InputStreamResource(file.getInputStream()));
// } }
//
// /** /**
// * 借支单结清 * 借支单结清
// * *
// * @param response * @param response
// * @param request * @param request
// * @return * @return
// */ */
// @ApiOperation("借支单结清") @ApiOperation("借支单结清")
// @PostMapping("/finishLend") @PostMapping("/finishLend")
// public Map<String, Object> finishLend(HttpServletResponse response, HttpServletRequest request) { public Map<String, Object> finishLend(HttpServletResponse response, HttpServletRequest request) {
// AxiosUtil.setCors(response, request); AxiosUtil.setCors(response, request);
// Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
// String costNo = request.getParameter("costNo"); String costNo = request.getParameter("costNo");
// String updateuserid = request.getParameter("updateuserid"); String updateuserid = request.getParameter("updateuserid");
// CostDomain costDomain = new CostDomain(); CostDomain costDomain = new CostDomain();
// costDomain.setCostNo(costNo); costDomain.setCostNo(costNo);
// costDomain.setLendStatus(4); costDomain.setLendStatus(4);
// result = costService.updateCost(costDomain); result = costService.updateCost(costDomain);
// result.put("success", true); result.put("success", true);
// result.put("msg", "已结清"); result.put("msg", "已结清");
// costLogService.save(costNo, Integer.parseInt(updateuserid), "操作结清"); costLogService.save(costNo, Integer.parseInt(updateuserid), "操作结清");
// return result; return result;
// } }
//
// @GetMapping("downCashierAnnex") @GetMapping("downCashierAnnex")
// public Map<String, Object> downCashierAnnex(HttpServletRequest request, HttpServletResponse response) { public Map<String, Object> downCashierAnnex(HttpServletRequest request, HttpServletResponse response) {
// AxiosUtil.setCors(response, request); AxiosUtil.setCors(response, request);
// Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();
// List<String> list = costCashiercallbackService.downCashierAnnex(); List<String> list = costCashiercallbackService.downCashierAnnex();
// result.put("success", true); result.put("success", true);
// result.put("msg", "出纳单附件下载完成"); result.put("msg", "出纳单附件下载完成");
// return result; return result;
// } }
//} }
...@@ -176,7 +176,7 @@ public class CostController { ...@@ -176,7 +176,7 @@ public class CostController {
CostContext costContext = new CostContext(costNo, costDomain.getCreateUserid()); CostContext costContext = new CostContext(costNo, costDomain.getCreateUserid());
costContext.setCostState(unSubmitState); costContext.setCostState(unSubmitState);
costContext.nexState(); costContext.handle();
CostApiDto.UpdateCostResp resp = new CostApiDto.UpdateCostResp(); CostApiDto.UpdateCostResp resp = new CostApiDto.UpdateCostResp();
......
...@@ -124,7 +124,6 @@ public interface CostService { ...@@ -124,7 +124,6 @@ public interface CostService {
void finalCheck(String costNo, Integer currentUserId); void finalCheck(String costNo, Integer currentUserId);
/** /**
* 审核费用单列表 * 审核费用单列表
* *
...@@ -135,4 +134,13 @@ public interface CostService { ...@@ -135,4 +134,13 @@ public interface CostService {
* @return 费用单列表 * @return 费用单列表
*/ */
IPage<CostDto> checkCostList(Integer userid, Integer pageNum, Integer pageSize, Integer type); 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; ...@@ -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.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.CostReviewer;
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.CostCompanyDao; import com.blt.other.module.cost.dao.CostCompanyDao;
import com.blt.other.module.cost.dao.CostDao; import com.blt.other.module.cost.dao.CostDao;
...@@ -24,6 +23,8 @@ import com.blt.other.module.cost.model.CostTemplate; ...@@ -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.CostLogService;
import com.blt.other.module.cost.service.CostService; import com.blt.other.module.cost.service.CostService;
import com.blt.other.module.cost.service.ICostTemplateService; 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.CostCompanyDomain;
import com.blt.other.module.database.model.CostLogDomain; import com.blt.other.module.database.model.CostLogDomain;
import com.blt.other.module.database.model.CostTypeKindDomain; import com.blt.other.module.database.model.CostTypeKindDomain;
...@@ -184,37 +185,17 @@ public abstract class AbstractCostService implements CostService { ...@@ -184,37 +185,17 @@ public abstract class AbstractCostService implements CostService {
} }
@Resource
DepartmentCheckState departmentCheckState;
@Transactional @Transactional
@Override @Override
public void departmentCheck(String costNo, Integer currentUserId) { public void departmentCheck(String costNo, Integer currentUserId) {
CostDomain costDomain = costDao.selectByCostNo(costNo); CostContext costContext = new CostContext(costNo, currentUserId);
CostTemplate costTemplate = costTemplateService.queryDetail(costDomain.getCostTemplateId()); costContext.setCostState(departmentCheckState);
//需要自动审核
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.handle();
}
@Transactional @Transactional
...@@ -223,46 +204,11 @@ public abstract class AbstractCostService implements CostService { ...@@ -223,46 +204,11 @@ public abstract class AbstractCostService implements CostService {
CostDomain costDomain = costDao.selectByCostNo(costNo); CostDomain costDomain = costDao.selectByCostNo(costNo);
CostTemplate costTemplate = costTemplateService.queryDetail(costDomain.getCostTemplateId()); 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) { 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 { ...@@ -23,6 +23,6 @@ public class CostSubscribe {
@Async @Async
public void subscribe(CostContext costContext) { public void subscribe(CostContext costContext) {
costContext.nexState(); costContext.handle();
} }
} }
package com.blt.other.module.cost.service.impl.cost; 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 com.blt.other.module.cost.service.CostService;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -17,4 +18,9 @@ public class PayCostServiceImpl extends AbstractCostService implements CostServi ...@@ -17,4 +18,9 @@ public class PayCostServiceImpl extends AbstractCostService implements CostServi
public void finalCheck(String costNo, Integer currentUserId) { public void finalCheck(String costNo, Integer currentUserId) {
} }
@Override
public void toFinancial(CostDomain costDomain) {
}
} }
package com.blt.other.module.cost.service.impl.costcheck; 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.model.CostDomain;
import com.blt.other.module.cost.service.CostService; 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.cost.CostServiceFactory;
/** /**
* <p> * <p>
* * 费用单上下文
* </p> * </p>
* *
* @author robbendev * @author robbendev
...@@ -33,11 +31,11 @@ public class CostContext { ...@@ -33,11 +31,11 @@ public class CostContext {
public CostContext(String costNo, Integer currentUserId) { public CostContext(String costNo, Integer currentUserId) {
this.costService = CostServiceFactory.getCostService(costNo); this.costService = CostServiceFactory.getCostService(costNo);
this.currentUserId = currentUserId; this.currentUserId = currentUserId;
this.costDomain = SpringContextUtil.getBean(CostDao.class).selectByCostNo(costNo); this.costDomain = costService.getCostByCostNo(costNo);
} }
public void nexState() { public void handle() {
costState.handle(); costState.handle();
} }
...@@ -45,5 +43,4 @@ public class CostContext { ...@@ -45,5 +43,4 @@ public class CostContext {
costState.refuse(); costState.refuse();
} }
} }
...@@ -27,8 +27,13 @@ public class DepartmentCheckState extends CostState { ...@@ -27,8 +27,13 @@ public class DepartmentCheckState extends CostState {
public void handle() { public void handle() {
CostDomain costDomain = costContext.costDomain; CostDomain costDomain = costContext.costDomain;
Integer currentUserId = costContext.currentUserId; Integer currentUserId = costContext.currentUserId;
CostTemplate costTemplate = costTemplateService.queryDetail(costDomain.getCostTemplateId()); CostTemplate costTemplate = costTemplateService.queryDetail(costDomain.getCostTemplateId());
//check status
if (!costDomain.getCostStatus().equals(CostDomain.STATUS_DEPARTMENT_CHECK)) {
throw new BizRuntimeException("invalid status");
}
//需要自动审核 //需要自动审核
if (costTemplate.shouldDepartmentAutoCheck()) { if (costTemplate.shouldDepartmentAutoCheck()) {
//自动审核通过 //自动审核通过
...@@ -54,8 +59,7 @@ public class DepartmentCheckState extends CostState { ...@@ -54,8 +59,7 @@ public class DepartmentCheckState extends CostState {
costLogService.save(costDomain.getCostNo(), currentUserId, "部门审核通过", CostLogDomain.MANUAL_CHECK); costLogService.save(costDomain.getCostNo(), currentUserId, "部门审核通过", CostLogDomain.MANUAL_CHECK);
nextState(financialCheckState); nextState(financialCheckState);
//发布到总线尝试下个环节的自动审核
//发布到总线尝试审核
costSubscribe.subscribe(costContext); costSubscribe.subscribe(costContext);
} }
//人工审核没权限 //人工审核没权限
......
package com.blt.other.module.cost.service.impl.costcheck; 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> * <p>
...@@ -12,9 +20,67 @@ import org.springframework.stereotype.Component; ...@@ -12,9 +20,67 @@ import org.springframework.stereotype.Component;
*/ */
public class FinalCheckState extends CostState { public class FinalCheckState extends CostState {
@Resource
UnPayState unPayState;
@Resource
CostCompanyDao costCompanyDao;
@Override @Override
public void handle() { 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 @Override
......
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 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 org.springframework.stereotype.Component;
import javax.annotation.Resource;
/** /**
* <p> * <p>
* *
...@@ -13,9 +22,57 @@ import org.springframework.stereotype.Component; ...@@ -13,9 +22,57 @@ import org.springframework.stereotype.Component;
@Component @Component
public class FinancialCheckState extends CostState { public class FinancialCheckState extends CostState {
@Resource
FinalCheckState finalCheckState;
@Resource
CostCompanyDao costCompanyDao;
@Override @Override
public void handle() { 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 @Override
......
package com.blt.other.module.cost.service.impl.costcheck; package com.blt.other.module.cost.service.impl.costcheck;
import org.springframework.stereotype.Component;
/** /**
* <p> * <p>
* *
......
...@@ -41,7 +41,7 @@ public class UnSubmitState extends CostState { ...@@ -41,7 +41,7 @@ public class UnSubmitState extends CostState {
//并且流转到下一个状态 //并且流转到下一个状态
costContext.setCostState(departmentCheckState); costContext.setCostState(departmentCheckState);
//尝试审核(由于清空了审核人,这里只会走自动审核) //尝试审核(由于清空了审核人,这里只会走自动审核)
costContext.nexState(); costContext.handle();
} }
@Override @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