Commit bee0a147 by huluobin

update

parent be146fc5
//package com.blt.other.module.cost.controller.cost;
//
//import com.blt.other.common.util.AxiosUtil;
//import com.blt.other.module.cost.model.CostDomain;
//import com.blt.other.module.cost.service.*;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.web.bind.annotation.PostMapping;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RestController;
//import org.springframework.web.client.RestTemplate;
//
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import java.math.BigDecimal;
//import java.util.Map;
//
//@RestController
//@RequestMapping("cost/check/lend")
//public class CostCheckLendController {
//
// private static Logger logger = LoggerFactory.getLogger(CostCheckLendController.class);
//
// @Autowired
// private CostService costService;
// @Autowired
// private CostLogService costLogService;
// @Autowired
// private CostCompanyService costCompanyService;
// @Autowired
// private RestTemplate restTemplate;
// @Autowired
// private CostTofinanceService costTofinanceService;
// @Autowired
// private CostApplycallbackService costApplycallbackService;
// @Autowired
// private CostCashiercallbackService costCashiercallbackService;
//
// ///http://api.fee.bailuntec.com/purchase/other/cost/check/lend/ApplyCallbackUrl
// @Value("${url.my.lendCostApplyCallBackUrlPost}")
// private String lendCostApplyCallBackUrlPost;
//
// ///purchase/other/cost/check/lend/CashierCallbackUrl
// @Value("${url.my.lendCostCashierCallbackUrlPost}")
// private String lendCostCashierCallbackUrlPost;
//
// //http://cw.bailuntec.com/API/API/Apply
// @Value("${url.api.postApplyApi}")
// private String postApplyApi;
//
// //http://oa.bailuntec.com/api/ExchangeRate/GetExchangeRate
// @Value("${url.api.getExchangeRateApi}")
// private String getExchangeRateApi;
//
//
//
//
//}
//package com.blt.other.module.cost.controller.cost;
//
//import com.blt.other.common.util.AxiosUtil;
//import com.blt.other.common.util.MyMapperUtil;
//import com.blt.other.module.cost.service.CostCheckSearchService;
//import com.blt.other.module.cost.vo.CostCheckSearchKeysVo;
//import com.blt.other.module.cost.model.CostDomain;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.web.bind.annotation.GetMapping;
//import org.springframework.web.bind.annotation.PostMapping;
//import org.springframework.web.bind.annotation.RequestMapping;
//import org.springframework.web.bind.annotation.RestController;
//
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import java.util.Enumeration;
//import java.util.List;
//import java.util.Map;
//
//@RestController
//@RequestMapping("cost/check/search")
//public class CostCheckSearchController {
// private Logger logger = LoggerFactory.getLogger(CostCheckSearchController.class);
//
// @Autowired
// private CostCheckSearchService costCheckSearchService;
//
// /**
// * 获取费用系统 财务审核列表
// * @param request
// * @param response
// * @return
// */
// @GetMapping("getCostCheckList")
// public Map<String,Object> getCostCheckList(HttpServletRequest request, HttpServletResponse response){
// AxiosUtil.setCors(response,request);
//
// String pageNumStr = request.getParameter("pageNum");
// Integer pageNum = null;
// if (null != pageNumStr && !pageNumStr.isEmpty()){
// pageNum = Integer.parseInt(pageNumStr);
// }
// String pageSizeStr = request.getParameter("pageSize");
// Integer pageSize = null;
// if (null != pageSizeStr && !pageSizeStr.isEmpty()){
// pageSize = Integer.parseInt(pageSizeStr);
// }
//
// Integer userId = Integer.valueOf(request.getParameter("userId"));
// String authority = costCheckSearchService.findAuthorityByUserid(userId);
// Map<String, Object> all = costCheckSearchService.getAll(pageNum, pageSize, authority);
// return all;
// }
//
// /**
// * 根据关键字模糊查询
// * @param response
// * @param request
// * @return
// */
// @PostMapping("/key")
// public Map<String,Object> getListByKey(HttpServletResponse response,HttpServletRequest request){
// AxiosUtil.setCors(response,request);
// String key = request.getParameter("key");
// String pageSizeStr = request.getParameter("pageSize");
// String pageNumStr = request.getParameter("pageNum");
// Integer userId = Integer.valueOf(request.getParameter("userId"));
// String authority = costCheckSearchService.findAuthorityByUserid(userId);
// Map<String, Object> map = costCheckSearchService.seachByKey(key,Integer.parseInt(pageNumStr),Integer.parseInt(pageSizeStr), authority);
// map.put("success",true);
// return map;
// }
//
// @PostMapping("/keys")
// public Map<String,Object> getListByKeys(HttpServletResponse response,HttpServletRequest request){
// AxiosUtil.setCors(response,request);
// Enumeration<String> parameterNames = request.getParameterNames();
// if (null != parameterNames && parameterNames.hasMoreElements()){
// String s = parameterNames.nextElement();
// CostCheckSearchKeysVo searchKeysVo = (CostCheckSearchKeysVo)MyMapperUtil.getObject(s, CostCheckSearchKeysVo.class);
// if (null != searchKeysVo.getParams().getKeys().getCostForm() && 3 ==searchKeysVo.getParams().getKeys().getCostForm()){
// searchKeysVo.getParams().getKeys().setIsLend(1);
// } else if (null != searchKeysVo.getParams().getKeys().getCostForm() && 4 ==searchKeysVo.getParams().getKeys().getCostForm()){
// searchKeysVo.getParams().getKeys().setCostForm(3);
// searchKeysVo.getParams().getKeys().setIsLend(2);
// }
// String authority = costCheckSearchService.findAuthorityByUserid(searchKeysVo.getParams().getKeys().getUserId());
// searchKeysVo.getParams().getKeys().setAuthority(authority);
// Map<String, Object> map = costCheckSearchService.searchByKeys(searchKeysVo);
// map.put("success",true);
// return map;
// }
// return null;
// }
//
// @GetMapping("/getLinkCost")
// public List<CostDomain> getLinkCost(HttpServletResponse response, HttpServletRequest request){
// AxiosUtil.setCors(response,request);
// List<CostDomain> list = costCheckSearchService.getLinkCost();
// return list;
// }
//}
//package com.blt.other.module.cost.controller.cost;
//
//import com.bailuntec.cost.api.dto.CostDto;
//import com.bailuntec.cost.api.dto.CostListPrintDto;
//import com.blt.other.common.util.AxiosUtil;
//import com.blt.other.common.util.MoneyUtil;
//import com.blt.other.common.util.MyMapperUtil;
//import com.blt.other.common.util.PathUtil;
//import com.blt.other.module.auth.service.UserService;
//import com.blt.other.module.cost.service.*;
//import com.blt.other.module.cost.utils.CostFileUtil;
//import com.blt.other.module.cost.utils.CostUtils;
//import com.blt.other.module.cost.vo.CostExportVo;
//import com.blt.other.module.cost.vo.CostListPrintVo;
//import com.blt.other.module.cost.vo.CostListSearchKeysVo;
//import com.blt.other.module.cost.vo.CostResp;
//import com.blt.other.module.cost.model.CostDomain;
//import com.blt.other.module.database.model.CostExpDomain;
//import com.blt.other.module.database.model.UserCostFinansysDomain;
//import com.blt.other.module.database.model.UserDomain;
//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 org.springframework.web.multipart.MultipartFile;
//
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import java.io.IOException;
//import java.util.*;
//
//@Deprecated
//@Api(tags = "费用单接口")
//@RestController
//@RequestMapping("cost/list/")
//public class CostListController {
//
// @Autowired
// private CostListSearchService costListSearchService;
// @Autowired
// private CostService costService;
// @Autowired
// private UserCostFinansysService userCostFinansysService;
// @Autowired
// private CostExportService costExportService;
// @Autowired
// private CostLogService costLogService;
// @Autowired
// private UserService userService;
//
// @ApiOperation("获取前端要打印的费用单列表")
// @PostMapping("/print/list")
// public Map<String, Object> printList(HttpServletResponse response, HttpServletRequest request) {
// AxiosUtil.setCors(response, request);
// // 获取前端要打印的费用单列表
// Enumeration<String> parameterNames = request.getParameterNames();
// if (null != parameterNames && parameterNames.hasMoreElements()) {
// String s = parameterNames.nextElement();
// CostListPrintVo printVo = (CostListPrintVo) MyMapperUtil.getObject(s, CostListPrintVo.class);
// List<String> printNos = printVo.getPrintNos();
// // 遍历获取费用单详情
// if (null != printNos && printNos.size() >= 1) {
// List<CostListPrintDto> printDtoList = new ArrayList<>();
// for (String costNo : printNos) {
// CostListPrintDto dto = getPrintDto(costNo);
// printDtoList.add(dto);
// }
//
// Map<String, Object> result = new HashMap<>();
// result.put("success", true);
// result.put("printList", printDtoList);
// return result;
// }
// }
// return null;
// }
//
// private CostListPrintDto getPrintDto(String costNo) {
// CostListPrintDto print = new CostListPrintDto();
// CostDto cost = costService.getCostDtoByNo(costNo);
// UserDomain user = userService.findByUserid(cost.getCreateUserid());
// if (user == null) {
// print.setDepartment("");
// print.setCreateUsername(cost.getCreateUsername() + "【注销】");
// } else {
// print.setDepartment(user.getDepartmentname1());
// print.setCreateUsername(cost.getCreateUsername());
// }
// print.setId(cost.getId());
// print.setCompanyName(cost.getCompanyName());
// //print.setDepartment(user.getDepartmentname1());
// print.setCostNo(costNo);
// print.setCreateTime(cost.getCreateTime());
// print.setBankCompany(cost.getBankCompany());
// print.setBankCardUser(cost.getBankCardUser());
// print.setBankCard(cost.getBankCard());
// print.setCostReason(cost.getCostReason());
// print.setDic(cost.getDicDto());
// print.setAmount(cost.getAmountDto());
// print.setTxtAmount(MoneyUtil.getCnNum(cost.getAmount()));
//// dic='null', amount=null, txtAmount='null'}
// if (1 == cost.getCostForm()) {
// // 付款单
// print.setCostFormStr("付");
// print.setBankCompanyStr("收款单位");
// print.setBankCardUserStr("收款户名");
// print.setFeeTypeStr("付款方式");
// print.setBankCardStr("收款账户");
// print.setCostReasonStr("付款理由");
// print.setCostReason(cost.getTypeName() + "/" + cost.getKindName() + "; " + cost.getCostRemark());
// // 差额单的付款理由需详细说明
// if (null != cost.getIsLend() && 2 == cost.getIsLend()) {
// print.setCostReason("【差额单(关联借支单:" + cost.getSupCostNo() + ")】 " + cost.getTypeName() + " " + cost.getCostRemark());
// }
// print.setCostAmountStr("付款金额");
// }
// if (2 == cost.getCostForm()) {
// // 收款单
// print.setCostFormStr("收");
// print.setBankCompanyStr("付款单位");
// print.setBankCardUserStr("付款户名");
// print.setFeeTypeStr("收款方式");
// print.setBankCardStr("付款账户");
// print.setCostReasonStr("收款理由");
// print.setCostAmountStr("收款金额");
// }
//
// if (3 == cost.getCostForm() && 1 == cost.getIsLend()) {
// // 借支单
// print.setCostFormStr("借支");
// print.setBankCompanyStr("收款单位");
// print.setBankCardUserStr("收款户名");
// print.setFeeTypeStr("付款方式");
// print.setBankCardStr("收款账户");
// print.setCostReasonStr("付款理由");
// print.setCostAmountStr("付款金额");
// }
//
// if (3 == cost.getCostForm() && 2 == cost.getIsLend()) {
// // 借还单
// print.setCostFormStr("借还");
// print.setBankCompanyStr("付款单位");
// print.setBankCardUserStr("付款户名");
// print.setFeeTypeStr("收款方式");
// print.setBankCardStr("付款账户");
// print.setCostReasonStr("收款理由");
// print.setCostAmountStr("收款金额");
// print.setDic(cost.getPayDicDto());
// print.setAmount(cost.getPayPlanAmountDto());
// print.setTxtAmount(MoneyUtil.getCnNum(cost.getPayPlanAmount()));
// }
// return print;
// }
//
//
// @PostMapping("/search/key")
// public Map<String, Object> getByKey(HttpServletResponse response,
// HttpServletRequest request) {
//
// AxiosUtil.setCors(response, request);
// String key = request.getParameter("key");
// String pageNumStr = request.getParameter("pageNum");
// String pageSizeStr = request.getParameter("pageSize");
//
// Map<String, Object> map = costListSearchService.searchByKey(key, Integer.parseInt(pageNumStr), Integer.parseInt(pageSizeStr));
// map.put("success", true);
// return map;
// }
//
// @PostMapping("/search/keys")
// public Map<String, Object> getByKeys(HttpServletResponse response, HttpServletRequest request) {
// AxiosUtil.setCors(response, request);
// Enumeration<String> parameterNames = request.getParameterNames();
// if (null != parameterNames && parameterNames.hasMoreElements()) {
// String s = parameterNames.nextElement();
// Object object = MyMapperUtil.getObject(s, CostListSearchKeysVo.class);
// CostListSearchKeysVo searchKeysVo = (CostListSearchKeysVo) object;
// if (null != searchKeysVo.getParams().getKeys().getCostForm() && 3 == searchKeysVo.getParams().getKeys().getCostForm()) {
// searchKeysVo.getParams().getKeys().setIsLend(1);
// }
// if (null != searchKeysVo.getParams().getKeys().getCostForm() && 4 == searchKeysVo.getParams().getKeys().getCostForm()) {
// searchKeysVo.getParams().getKeys().setCostForm(3);
// searchKeysVo.getParams().getKeys().setIsLend(2);
// }
// Map<String, Object> result = costListSearchService.searchByKeys(searchKeysVo);
// result.put("success", true);
// return result;
// }
// return null;
// }
//
// @GetMapping("/search/getLinkCost")
// public List<CostDomain> getLinkCost(HttpServletResponse response, HttpServletRequest request) {
// AxiosUtil.setCors(response, request);
// return costListSearchService.getLinkCost();
// }
//
//
// @ApiOperation("获取所有费用单")
// @GetMapping("/getAllCost")
// public Map<String, Object> getAllCost(@RequestParam Integer pageNum,
// @RequestParam Integer pageSize,
// @RequestParam Integer userId,
// @RequestParam(defaultValue = "0", required = false) Integer authType,
// @RequestParam(required = false) String projectTypes) {
// if (authType != 0) {
// userId = null;
// }
// Map<String, Object> result = costService.getAllCost(pageNum, pageSize, userId, projectTypes);
// result.put("success", true);
// return result;
// }
//
// @ApiOperation("获取费用详情")
// @PostMapping("/getCostDetail")
// public CostResp.GetCostDetailResp getCostDetail(@RequestParam String costNo) {
// CostResp.GetCostDetailResp resp = new CostResp.GetCostDetailResp();
//
// CostDomain costDomain = costService.getCostByCostNo(costNo);
// resp.setMsg("success");
// resp.setCost(costDomain.castToDto());
// return resp;
// }
//
// @ApiOperation("修改发票附件")
// @PostMapping("reset/resetInvoice")
// public Map<String, Object> resetInvoice(@RequestParam String costNo,
// @RequestParam("fileSelect") MultipartFile file) {
//
// CostDomain costDomain = new CostDomain();
// costDomain.setCostNo(costNo);
// costDomain.setHasInvoice(1);
// // 文件上传的路径
// String filePath = PathUtil.getBasePath() + PathUtil.getPath("cost/" + costDomain.getCostNo() + "/");
// // 调用工具类执行保存,并返回 path
// String path = CostFileUtil.upload(file, filePath);
// costDomain.setFilePath(path);
// Map<String, Object> map = costService.upadateCost(costDomain);
// costLogService.save(costNo, costService.getCostDomainByNo(costNo).getCreateUserid(), "修改发票信息");
// map.put("success", true);
// return map;
// }
//
//
// /**
// * 信息修改,带附件
// *
// * @param response
// * @param request
// * @param file
// * @return
// */
// @PostMapping("reset/resetFile")
// public Map<String, Object> resetFile(HttpServletResponse response, HttpServletRequest request, @RequestParam("fileSelect") MultipartFile file) {
// AxiosUtil.setCors(response, request);
//
// String costNo = request.getParameter("costNo");
// CostDomain costDomain = CostUtils.createCostDomain(request, costNo);
// boolean saveRecord = saveRecord(costDomain);
// if (saveRecord) {
// Integer integer = doSaveFinansyRecord(costDomain);
// }
// // 文件上传的路径
// String filePath = PathUtil.getBasePath() + PathUtil.getPath("cost/" + costDomain.getCostNo() + "/");
// // 调用工具类执行保存,并返回 path
// String path = CostFileUtil.upload(file, filePath);
// costDomain.setFilePath(path);
// Map<String, Object> map = costService.upadateCost(costDomain);
// costLogService.save(costNo, costService.getCostDomainByNo(costNo).getCreateUserid(), "修改费用单");
// map.put("success", true);
// return map;
// }
//
//
// @ApiOperation("信息修改,不带附件")
// @PostMapping("reset/resetNoFile")
// public Map<String, Object> resetNoFile(HttpServletResponse response, HttpServletRequest request) {
// AxiosUtil.setCors(response, request);
//
// CostDomain costDomain = CostUtils.createCostDomain(request, request.getParameter("costNo"));
// boolean saveRecord = saveRecord(costDomain);
// if (saveRecord) {
// Integer integer = doSaveFinansyRecord(costDomain);
// }
//
// Map<String, Object> map = costService.upadateCost(costDomain);
// costLogService.save(costDomain.getCostNo(), costService.getCostDomainByNo(costDomain.getCostNo()).getCreateUserid(), "修改费用单");
// map.put("success", true);
// return map;
// }
//
// @PostMapping("submitAudit")
// public Map<String, Object> submitAudit(HttpServletResponse response, HttpServletRequest request) {
// AxiosUtil.setCors(response, request);
//
// String costNo = request.getParameter("costNo");
// CostDomain costDomainByNo = costService.getCostDomainByNo(costNo);
// costDomainByNo.setCostStatus(1);
//
// Map<String, Object> map = costService.upadateCost(costDomainByNo);
// costLogService.save(costNo, costDomainByNo.getCreateUserid(), "提交费用单");
// return map;
// }
//
// /**
// * 获取借支单列表
// *
// * @param request
// * @param response
// * @return
// */
// @GetMapping("/getAllLendCost")
// public Map<String, Object> getAllLendCost(HttpServletRequest request, HttpServletResponse response) {
// AxiosUtil.setCors(response, request);
// String createuserid = request.getParameter("createuserid");
// Map<String, Object> result = new HashMap<>();
// List<CostDto> costDtos = costService.getLinkLendCost(Integer.valueOf(createuserid));
//
// result.put("success", true);
// result.put("lends", costDtos);
// result.put("msg", "");
// return result;
// }
//
// @PostMapping("/getCostByCostPlanNo")
// public Map<String, Object> getCostByCostPlanNo(HttpServletResponse response, HttpServletRequest request) {
// AxiosUtil.setCors(response, request);
//
// Map<String, Object> result = new HashMap<>();
//
// String costPlanNo = request.getParameter("costPlanNo");
// List<CostDto> costDtos = costService.getByCostPlanNo(costPlanNo);
//
// result.put("costs", costDtos);
// return result;
// }
//
// /**
// * 保存填写的财务信息
// *
// * @return
// */
// private Integer doSaveFinansyRecord(CostDomain costDomain) {
// UserCostFinansysDomain finansyRecordByCostDomain = userCostFinansysService.createFinansyRecordByCostDomain(costDomain);
// Integer integer = userCostFinansysService.saveFinansysRecord(finansyRecordByCostDomain);
// return integer;
// }
//
// /**
// * 判断是否存在相同记录
// *
// * @param costDomain
// * @return
// */
// private boolean saveRecord(CostDomain costDomain) {
// UserCostFinansysDomain finansyRecordByCostDomain = userCostFinansysService.createFinansyRecordByCostDomain(costDomain);
// UserCostFinansysDomain byUserCostFinansysDetail = userCostFinansysService.getByUserCostFinansysDetail(finansyRecordByCostDomain);
// if (null != byUserCostFinansysDetail && null != byUserCostFinansysDetail.getId()) {
// return false;
// } else {
// return true;
// }
// }
//
// @PostMapping("/deleted")
// public Map<String, Object> deleted(HttpServletResponse response, HttpServletRequest request) {
// AxiosUtil.setCors(response, request);
// Map<String, Object> result = new HashMap<>();
//
// String costNo = request.getParameter("costNo");
// Integer set = costService.setStatus(costNo, 5);
// if (null != set && set >= 1) {
// result.put("success", true);
// costLogService.save(costNo, costService.getCostDomainByNo(costNo).getCreateUserid(), "作废费用单");
// }
// return result;
// }
//
// @PostMapping("/exportList")
// public String exportList(HttpServletResponse response, HttpServletRequest request) throws IOException {
// AxiosUtil.setCors(response, 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("/exportListAll")
// public String exportListAll(HttpServletResponse response, HttpServletRequest request) throws IOException {
// AxiosUtil.setCors(response, request);
// Enumeration<String> parameterNames = request.getParameterNames();
//
// if (null != parameterNames && parameterNames.hasMoreElements()) {
// String s = parameterNames.nextElement();
// CostExportVo costExportVo = (CostExportVo) MyMapperUtil.getObject(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);
// }
// List<String> costNo = costService.listCostNoAll(costExportVo);
// exportNos = costNo;
// String filePath = costExportService.exportFees(exportNos);
// // 保存下载记录
// CostExpDomain exp = costExportService.saveRecord(costExportVo, filePath);
// return exp.getExpNo();
// }
// return null;
// }
//
// @GetMapping("download")
// public ResponseEntity<InputStreamResource> download(HttpServletRequest request, HttpServletResponse response) throws IOException {
//// AxiosUtil.setCors(response,request);
// 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("downloadCashierAnnex")
// public ResponseEntity<InputStreamResource> downCashierAnnex(HttpServletRequest request, HttpServletResponse response) throws IOException {
// String detailNo = request.getParameter("detailNo");
// CostDomain cost = costService.getByNo(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()));
// }
//}
......@@ -40,7 +40,37 @@ public class Lend2PayCostServiceImpl extends AbstractCostService implements Cost
@Override
public void toFinancial(CostDomain cost) {
if (cost.getLendBalance().compareTo(BigDecimal.ZERO) <= 0) {
throw new BizRuntimeException("invalid amount");
// 付款成功,更改借还单信息,否则返回失败
String sonNo = cost.getCostNo().toUpperCase();
cost.setCostStatus(CostDomain.STATUS_PAYED);
cost.setPayTime(new Date());
BigDecimal toRmbRate = CurUtils.getCur(cost.getDic(), "CNY");
cost.setToRmbRate(toRmbRate);
cost.setAmountRmb(cost.getAmount().multiply(toRmbRate).setScale(2, BigDecimal.ROUND_HALF_UP));
cost.setAuditTime(new Date());
costDao.updateById(cost);
//借还单
if (!sonNo.contains("S")) {
//关联借支单
CostDomain supCostDomain = this.getCostByCostNo(cost.getSupCostNo());
// 借还单在出纳完成收付款后,不用直接获取返回的金额(使用费用系统中记录的提交金额,出纳系统结算的实时汇率和费用系统不一定一致)
supCostDomain.setHadPay(supCostDomain.getHadPay().add(cost.getAmount()));
if (supCostDomain.getHadPay().compareTo(supCostDomain.getAmount()) == 0) {
//结清
supCostDomain.setLendStatus(4);
} else if (supCostDomain.getHadPay().compareTo(supCostDomain.getAmount()) < 0) {
//部分结清
supCostDomain.setLendStatus(2);
} else if (supCostDomain.getHadPay().compareTo(supCostDomain.getAmount()) > 0) {
//todo 邮件通知
log.error("金额异常 联系管理员,costNo:{}", supCostDomain.getCostNo());
}
costDao.updateById(supCostDomain);
}
return;
}
PostApplyReq req = super.buildPostApplyReq(cost);
......
......@@ -74,11 +74,11 @@ public class CostPlanNewLend2ServiceImpl extends AbstractCostPlanService impleme
return 1;
}
//确认冲销金额
private void affirmCounteract(String costPlanNo) {
CostPlanDomain costPlanDomain = costPlanDao.selectByNo(costPlanNo);
//已确认
costPlanDomain.setCostPlanStatus(1);
costPlanDao.updateById(costPlanDomain);
......@@ -93,12 +93,13 @@ public class CostPlanNewLend2ServiceImpl extends AbstractCostPlanService impleme
//借还单冲销金额 (借支单币种)
BigDecimal counteract = costPlanDomain.getCounteract();
if (counteract.compareTo(BigDecimal.ZERO) < 0) {
if (counteract.compareTo(BigDecimal.ZERO) <= 0) {
return;
}
// 2.1、冲销刚好抵消差额 / 冲销小于差额 ===== 生成一张无需推送财务系统的借还单
if (counteract.compareTo(subtract) <= 0) {
costPlanDomain.setLendBalance(BigDecimal.ZERO);
CostDomain costDomain = planToCost(costPlanDomain.getCostPlanNo());
costDomain.setCostNo(getCostNo());
//待提交
......@@ -122,6 +123,7 @@ public class CostPlanNewLend2ServiceImpl extends AbstractCostPlanService impleme
// 冲销大于差额 ===== 生成一张无需收款的借还单 + 一张付款单(出纳回调接口和财务审核接口改为借还出纳回调接口,费用单号以 “S” 打头)
else {
log.info("冲销大于差额 ===== 准备生成一张无需收款的借还单 + 一张付款单(出纳回调接口和财务审核接口改为借还出纳回调接口,费用单号以 “S” 打头)");
costPlanDomain.setLendBalance(BigDecimal.ZERO);
CostDomain costDomain = planToCost(costPlanDomain.getCostPlanNo());
costDomain.setCostNo(getCostNo());
costDomain.setCostStatus(0);
......@@ -215,7 +217,7 @@ public class CostPlanNewLend2ServiceImpl extends AbstractCostPlanService impleme
BigDecimal subtract = supCost.getAmount().subtract(supCost.getHadPay());
//借还单余额
BigDecimal lendBalance = costPlanDomain.getLendBalance();
if (lendBalance.compareTo(BigDecimal.ZERO) < 0) {
if (lendBalance.compareTo(BigDecimal.ZERO) <= 0) {
return;
}
......@@ -223,6 +225,7 @@ public class CostPlanNewLend2ServiceImpl extends AbstractCostPlanService impleme
throw new BizRuntimeException("冲销后归还金额 > 借支单待归还金额");
}
costPlanDomain.setCounteract(BigDecimal.ZERO);
CostDomain costDomain = planToCost(costPlanDomain.getCostPlanNo());
costDomain.setCostNo(getCostNo());
costDomain.setCostStatus(0);
......
......@@ -79,7 +79,6 @@ public class OtherApplicationTests {
oaUserService.saveBatch(oaUserList);
// oaDepartmentService.saveBatch(oaDepartmentList);
}
private OaDepartment getPrimaryDepartment(Map<Integer, OaDepartment> departmentMap, OaDepartment oaDepartment) {
......
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