TFeeServiceImpl.java 101 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283
  1. package com.ruoyi.finance.service.impl;
  2. import com.alibaba.fastjson.JSONArray;
  3. import com.alibaba.fastjson.JSONObject;
  4. import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
  5. import com.ruoyi.approvalFlow.domain.AuditItems;
  6. import com.ruoyi.approvalFlow.service.impl.AuditItemsServiceImpl;
  7. import com.ruoyi.basicData.domain.TCorps;
  8. import com.ruoyi.basicData.domain.TFees;
  9. import com.ruoyi.basicData.mapper.TCorpsMapper;
  10. import com.ruoyi.basicData.mapper.TFeesMapper;
  11. import com.ruoyi.common.config.RuoYiConfig;
  12. import com.ruoyi.common.core.domain.AjaxResult;
  13. import com.ruoyi.common.core.domain.entity.SysDictData;
  14. import com.ruoyi.common.core.domain.model.LoginUser;
  15. import com.ruoyi.common.exception.WarehouseException;
  16. import com.ruoyi.common.utils.DateUtils;
  17. import com.ruoyi.common.utils.DictUtils;
  18. import com.ruoyi.common.utils.StringUtils;
  19. import com.ruoyi.common.utils.poi.ExcelUtils;
  20. import com.ruoyi.finance.domain.TFee;
  21. import com.ruoyi.finance.domain.TFeeDo;
  22. import com.ruoyi.finance.domain.TWareHouseFees;
  23. import com.ruoyi.finance.domain.dto.FeeDTO;
  24. import com.ruoyi.finance.domain.excel.GeneralLedgerDetailExcel;
  25. import com.ruoyi.finance.domain.excel.GeneralLedgerExcel;
  26. import com.ruoyi.finance.domain.excel.ProfitGeneralLedgerExcel;
  27. import com.ruoyi.finance.domain.vo.FeeVO;
  28. import com.ruoyi.finance.excel.Charge;
  29. import com.ruoyi.finance.excel.Contrast;
  30. import com.ruoyi.finance.excel.Detailed;
  31. import com.ruoyi.finance.excel.Payment;
  32. import com.ruoyi.finance.mapper.TFeeDoMapper;
  33. import com.ruoyi.finance.mapper.TFeeMapper;
  34. import com.ruoyi.finance.service.ITFeeService;
  35. import com.ruoyi.finance.shipping.*;
  36. import com.ruoyi.reportManagement.dto.TWarehousebill;
  37. import com.ruoyi.reportManagement.excel.Profit;
  38. import com.ruoyi.reportManagement.excel.Receivable;
  39. import com.ruoyi.shipping.domain.TAccount;
  40. import com.ruoyi.shipping.domain.TFeeInvoice;
  41. import com.ruoyi.shipping.domain.TVessel;
  42. import com.ruoyi.shipping.domain.TVoyage;
  43. import com.ruoyi.shipping.excel.Account;
  44. import com.ruoyi.shipping.excel.ExportFinancial;
  45. import com.ruoyi.shipping.mapper.TFeeInvoiceMapper;
  46. import com.ruoyi.shipping.mapper.TVesselMapper;
  47. import com.ruoyi.shipping.mapper.TVoyageMapper;
  48. import com.ruoyi.system.domain.SysConfig;
  49. import com.ruoyi.system.mapper.SysConfigMapper;
  50. import com.ruoyi.system.mapper.SysDictDataMapper;
  51. import com.ruoyi.system.service.ISysDictDataService;
  52. import com.ruoyi.warehouseBusiness.domain.BillnoDel;
  53. import com.ruoyi.warehouseBusiness.domain.TWarehouseBills;
  54. import com.ruoyi.warehouseBusiness.domain.TWarehousebillsfees;
  55. import com.ruoyi.warehouseBusiness.domain.enums.FeesTypeEnum;
  56. import com.ruoyi.warehouseBusiness.domain.enums.WarehouseTypeEnum;
  57. import com.ruoyi.warehouseBusiness.excel.ListMapToBeanUtils;
  58. import com.ruoyi.warehouseBusiness.excel.TWareHouseExcelItem;
  59. import com.ruoyi.warehouseBusiness.mapper.BillnoDelMapper;
  60. import com.ruoyi.warehouseBusiness.mapper.TWarehouseBillsMapper;
  61. import com.ruoyi.warehouseBusiness.mapper.TWarehousebillsfeesMapper;
  62. import com.ruoyi.warehouseBusiness.service.impl.BillnoSerialServiceImpl;
  63. import org.apache.commons.compress.utils.Lists;
  64. import org.apache.poi.hssf.usermodel.*;
  65. import org.apache.poi.ss.util.CellRangeAddress;
  66. import org.springframework.beans.BeanUtils;
  67. import org.springframework.beans.factory.annotation.Autowired;
  68. import org.springframework.stereotype.Service;
  69. import org.springframework.transaction.annotation.Transactional;
  70. import org.springframework.transaction.interceptor.TransactionAspectSupport;
  71. import java.io.File;
  72. import java.io.FileOutputStream;
  73. import java.io.OutputStream;
  74. import java.math.BigDecimal;
  75. import java.text.SimpleDateFormat;
  76. import java.util.*;
  77. import java.util.stream.Collectors;
  78. import static java.util.stream.Collectors.toList;
  79. /**
  80. * 财务数据主Service业务层处理
  81. *
  82. * @author ruoyi
  83. * @date 2021-01-18
  84. */
  85. @Service
  86. public class TFeeServiceImpl implements ITFeeService {
  87. @Autowired
  88. private TFeeMapper tFeeMapper;
  89. @Autowired
  90. private TFeeDoMapper tFeeDoMapper;
  91. @Autowired
  92. private BillnoSerialServiceImpl billnoSerialServiceImpl;
  93. @Autowired
  94. private BillnoDelMapper billnoDelMapper;
  95. @Autowired
  96. private TCorpsMapper tCorpsMapper;
  97. @Autowired
  98. private TFeesMapper tFeesMapper;
  99. @Autowired
  100. private TWarehouseBillsMapper tWarehouseBillsMapper;
  101. @Autowired
  102. private TWarehousebillsfeesMapper tWarehousebillsfeesMapper;
  103. @Autowired
  104. private SysConfigMapper sysConfigMapper;
  105. @Autowired
  106. private AuditItemsServiceImpl auditItemsService;
  107. @Autowired
  108. private ISysDictDataService iSysDictDataService;
  109. @Autowired
  110. private SysDictDataMapper sysDictDataMapper;
  111. @Autowired
  112. private TFeeInvoiceMapper tFeeInvoiceMapper;
  113. @Autowired
  114. private TVesselMapper tVesselMapper;
  115. @Autowired
  116. private TVoyageMapper tVoyageMapper;
  117. private final String ST_IN_TYPE = "st_in_type";
  118. private final String ST_OUT_TYPE = "st_out_type";
  119. private final String ST_TRANS_TYPE = "st_trans_type";
  120. /**
  121. * 查询财务数据主
  122. *
  123. * @param fId 财务数据主ID
  124. * @return 财务数据主
  125. */
  126. @Override
  127. public Map<String, Object> selectTFeeById(Long fId) {
  128. Map<String, Object> map = new HashMap<>();
  129. // 客户表
  130. List<Long> corpsId = new ArrayList<>();
  131. // 费用
  132. List<Long> feesId = new ArrayList<>();
  133. //费用名称
  134. String feeName = null;
  135. TFee tFee = tFeeMapper.selectTFeeById(fId);
  136. if (StringUtils.isNotNull(tFee.getfCorpid())) {
  137. corpsId.add(tFee.getfCorpid());
  138. }
  139. corpsId.add(tFee.getfCorpid());
  140. // 查询从表数据
  141. TFeeDo tFeeDo = new TFeeDo();
  142. tFeeDo.setfPid(fId);
  143. List<TFeeDo> tFeeDoList = tFeeDoMapper.selectTFeeDoList(tFeeDo);
  144. List<Map<String, Object>> feeDoList = new ArrayList<>();
  145. if (StringUtils.isNotEmpty(tFeeDoList)) {
  146. for (TFeeDo fees : tFeeDoList) {
  147. Map<String, Object> map1 = new HashMap<>();
  148. feesId.add(fees.getfFeeid());
  149. // 查询主表
  150. TWarehouseBills tWarehousebills = tWarehouseBillsMapper.selectTWarehousebillsById(fees.getfSrcpid());
  151. if (Objects.isNull(tWarehousebills)) {
  152. throw new WarehouseException("未找到仓储信息");
  153. }
  154. // 费用名称
  155. TFees tFees = tFeesMapper.selectTFeesById(fees.getfFeeid());
  156. if (tFees != null) {
  157. feeName = tFees.getfName();
  158. }
  159. // 费用表数据
  160. TWarehousebillsfees tWarehousebillsfees = tWarehousebillsfeesMapper.selectTWarehousebillsfeesById(fees.getfSrcid());
  161. if (tWarehousebillsfees == null) {
  162. return AjaxResult.error("费用数据为空,请确认");
  163. }
  164. // 字典宝
  165. SysDictData sysDictData = new SysDictData();
  166. sysDictData.setDictType("data_unitfees");
  167. sysDictData.setDictValue(String.valueOf(tWarehousebillsfees.getfFeeunitid()));
  168. sysDictData.setStatus("0");
  169. List<SysDictData> sysDictDataList = iSysDictDataService.selectDictDataList(sysDictData);
  170. List<SysDictData> sysDictDataListIn = new ArrayList<>();
  171. if (StringUtils.isNotEmpty(tWarehousebillsfees.getfBilltype()) && tWarehousebillsfees.getfBilltype().equals("SJRK")) {
  172. sysDictData.setDictType(ST_IN_TYPE);
  173. sysDictData.setDictValue(String.valueOf(tWarehousebillsfees.getfBusinessType()));
  174. sysDictData.setStatus("0");
  175. sysDictDataListIn = iSysDictDataService.selectDictDataList(sysDictData);
  176. } else if (StringUtils.isNotEmpty(tWarehousebillsfees.getfBilltype()) && tWarehousebillsfees.getfBilltype().equals("SJCK")) {
  177. sysDictData.setDictType(ST_OUT_TYPE);
  178. sysDictData.setDictValue(String.valueOf(tWarehousebillsfees.getfBusinessType()));
  179. sysDictData.setStatus("0");
  180. sysDictDataListIn = iSysDictDataService.selectDictDataList(sysDictData);
  181. } else if (StringUtils.isNotEmpty(tWarehousebillsfees.getfBilltype()) && tWarehousebillsfees.getfBilltype().equals("CKDB") | tWarehousebillsfees.getfBilltype().equals("HWTG")) {
  182. sysDictData.setDictType(ST_TRANS_TYPE);
  183. sysDictData.setDictValue(String.valueOf(tWarehousebillsfees.getfBusinessType()));
  184. sysDictData.setStatus("0");
  185. sysDictDataListIn = iSysDictDataService.selectDictDataList(sysDictData);
  186. }
  187. // 之前遗留汉字特别处理
  188. FeesTypeEnum feesTypeEnum;
  189. if (fees.getfSrcdc().equals("收")) {
  190. feesTypeEnum = FeesTypeEnum.D;
  191. } else if (fees.getfSrcdc().equals("付")) {
  192. feesTypeEnum = FeesTypeEnum.C;
  193. } else {
  194. feesTypeEnum = FeesTypeEnum.fromType(fees.getfSrcdc());
  195. }
  196. map1.put("fSrcdcName", feesTypeEnum.getName());
  197. map1.put("fId", fees.getfId());
  198. map1.put("fSrcid", fees.getfSrcid());
  199. map1.put("fSrcpid", fees.getfSrcpid());
  200. map1.put("fMblno", tWarehousebillsfees.getfMblno());
  201. map1.put("fBscorpno", tWarehousebills.getfBscorpno());
  202. map1.put("fProductName", tWarehousebillsfees.getfProductName());
  203. map1.put("fBsdate", tWarehousebillsfees.getfBsdate());
  204. map1.put("fFeeid", fees.getfFeeid());
  205. map1.put("fFeeName", feeName);
  206. map1.put("fSrcdc", fees.getfSrcdc());
  207. map1.put("fAmt", fees.getfAmt());
  208. map1.put("fAmtdr", fees.getfAmtdr());
  209. map1.put("fRemarks", fees.getfRemarks());
  210. map1.put("srcBillNo", tWarehousebillsfees.getSrcId());
  211. map1.put("fMarks", tWarehousebillsfees.getfMarks());
  212. map1.put("fChargedate", tWarehousebillsfees.getfChargedate());
  213. map1.put("fBillingDeadline", tWarehousebillsfees.getfBillingDeadline());
  214. map1.put("fBillingDays", tWarehousebillsfees.getfBillingDays());
  215. map1.put("fInventoryDays", tWarehousebillsfees.getfInventoryDays());
  216. map1.put("fFeeunitid", sysDictDataList.get(0).getDictLabel());
  217. map1.put("fQty", tWarehousebillsfees.getfQty());
  218. map1.put("fUnitprice", tWarehousebillsfees.getfUnitprice());
  219. map1.put("fBillno",fees.getfSrcBillno());// 业务编号(单据编号)
  220. map1.put("invoiceNo",fees.getfInvoiceNo());// 发票号
  221. if (StringUtils.isNotEmpty(tWarehousebillsfees.getfBilltype()) && tWarehousebillsfees.getfBilltype().equals("KHDD")) {
  222. map1.put("fBusinessType", "船运订单");
  223. } else if (CollectionUtils.isNotEmpty(sysDictDataListIn)) {
  224. map1.put("fBusinessType", sysDictDataListIn.get(0).getDictLabel());
  225. }
  226. if (StringUtils.isNotEmpty(tWarehousebills.getfBilltype()) && tWarehousebills.getfBilltype().equals("SJRK")) {
  227. map1.put("fBilltype", "入库");
  228. } else if (StringUtils.isNotEmpty(tWarehousebills.getfBilltype()) && tWarehousebills.getfBilltype().equals("SJCK")) {
  229. map1.put("fBilltype", "出库");
  230. } else if (StringUtils.isNotEmpty(tWarehousebills.getfBilltype()) && tWarehousebills.getfBilltype().equals("CKDB")) {
  231. map1.put("fBilltype", "调拨");
  232. } else if (StringUtils.isNotEmpty(tWarehousebills.getfBilltype()) && tWarehousebills.getfBilltype().equals("HWTG")) {
  233. map1.put("fBilltype", "货物通关");
  234. } else if (StringUtils.isNotEmpty(tWarehousebills.getfBilltype()) && tWarehousebills.getfBilltype().equals("HQZY")) {
  235. map1.put("fBilltype", "货权转移");
  236. } else if (StringUtils.isNotEmpty(tWarehousebills.getfBilltype()) && tWarehousebills.getfBilltype().equals("KHDD")) {
  237. map1.put("fBilltype", "船运订单");
  238. }
  239. feeDoList.add(map1);
  240. }
  241. }
  242. List<TCorps> corpsList = new ArrayList<>();
  243. List<Long> corpsIdList = StringUtils.integerDeduplication(corpsId);
  244. for (Long corpId : corpsIdList) {
  245. TCorps corps = tCorpsMapper.selectTCorpsById(corpId);
  246. if (StringUtils.isNotNull(corps)) {
  247. corpsList.add(corps);
  248. }
  249. }
  250. List<TFees> feesList = new ArrayList<>();
  251. List<Long> longList = StringUtils.integerDeduplication(feesId);
  252. for (Long fees : longList) {
  253. TFees tFees = tFeesMapper.selectTFeesById(fees);
  254. if (StringUtils.isNotNull(tFees)) {
  255. feesList.add(tFees);
  256. }
  257. }
  258. map.put("tFee", tFee);
  259. map.put("corps", corpsList);
  260. map.put("feesList", feesList);
  261. map.put("feeDoList", feeDoList);
  262. return map;
  263. }
  264. @Override
  265. public Map<String, Object> selectTFeeByIdNew(Long fId) {
  266. Map<String, Object> map = new HashMap<>();
  267. TFee tFee = tFeeMapper.selectTFeeByIdNew(fId);
  268. List<TFeeDo> feeDoList = tFeeDoMapper.selectTFeeDoByfPid(fId);
  269. TFeeInvoice tFeeInvoice = new TFeeInvoice();
  270. tFeeInvoice.setfPid(fId);
  271. List<TFeeInvoice> tFeeInvoiceList = tFeeInvoiceMapper.selectTFeeInvoiceList(tFeeInvoice);
  272. map.put("tFee", tFee);
  273. map.put("feeDoList", feeDoList);
  274. map.put("tFeeInvoiceList", tFeeInvoiceList);
  275. return map;
  276. }
  277. /**
  278. * 查询财务数据主列表
  279. *
  280. * @param tFee 财务数据主
  281. * @return 财务数据主
  282. */
  283. @Override
  284. public List<TFee> selectTFeeList(TFee tFee) {
  285. List<TFee> list = tFeeMapper.selectTFeeList(tFee);
  286. for (TFee tf : list) {
  287. List<TFeeDo> fd = tFeeDoMapper.selectTFeeDoByfPid(tf.getfId());
  288. StringBuilder strb = new StringBuilder();
  289. for (TFeeDo tFeeDo : fd) {
  290. if (StringUtils.isNotNull(tFeeDo.getfSrcBillno())) {
  291. strb.append(tFeeDo.getfSrcBillno()).append(",");
  292. }
  293. }
  294. tf.setfSrcBillno(StringUtils.objToStr(StringUtils.removeTheLastComma(strb)));
  295. }
  296. return list;
  297. }
  298. @Override
  299. public List<Map<String, Object>> selectTFeeList1(TFee tFee) {
  300. List<Map<String,Object>> list = tFeeMapper.selectTFeeList1(tFee);
  301. for (Map<String,Object> map : list) {
  302. List<TFeeDo> tfd = tFeeDoMapper.selectTFeeDoByfPid(Long.valueOf(map.get("fId").toString()));
  303. if (tfd.size()!=0) {
  304. StringBuilder stringBuilder = new StringBuilder();
  305. for (TFeeDo tFeeDo : tfd) {
  306. if (StringUtils.isNotNull(tFeeDo.getfSrcBillno())) {
  307. stringBuilder.append(tFeeDo.getfSrcBillno()).append(",");
  308. }
  309. }
  310. map.put("fSrcBillno",StringUtils.removeTheLastComma(stringBuilder));
  311. }
  312. }
  313. return list;
  314. }
  315. @Override
  316. public List<Map<String, Object>> webVersionTFee(TFee tFee) {
  317. return tFeeMapper.webVersionTFee(tFee);
  318. }
  319. @Override
  320. public List<Map<String, Object>> webVersionDetail(TAccount tAccount) {
  321. return tWarehousebillsfeesMapper.webVersionDetail(tAccount);
  322. }
  323. @Override
  324. public List<Map<String, Object>> webVersionInvoice(TFee tFee) {
  325. return tFeeMapper.webVersionInvoice(tFee);
  326. }
  327. @Override
  328. public List<Map<String, Object>> webVersionInvoiceDetail(TFee tFee) {
  329. List<Map<String, Object>> list = tFeeMapper.webVersionInvoice(tFee);
  330. if (CollectionUtils.isNotEmpty(list)) {
  331. for (Map<String, Object> map : list) {
  332. Long fId = Long.valueOf(map.get("fId").toString());
  333. List<TFeeDo> tFeeDos = tFeeDoMapper.selectTFeeDoByfPid(fId);
  334. map.put("tFeeDoList", tFeeDos);
  335. TFeeInvoice tFeeInvoice = new TFeeInvoice();
  336. tFeeInvoice.setfPid(fId);
  337. List<TFeeInvoice> tFeeInvoiceList = tFeeInvoiceMapper.selectTFeeInvoiceList(tFeeInvoice);
  338. map.put("tFeeInvoiceList", tFeeInvoiceList);
  339. }
  340. }
  341. return list;
  342. }
  343. @Override
  344. public List<Map<String, Object>> webVersionList(TAccount tAccount) {
  345. return tWarehousebillsfeesMapper.webVersionReconciliation(tAccount);
  346. }
  347. /**
  348. * 新增财务数据主
  349. *
  350. * @param tFee 财务数据主
  351. * @return 结果
  352. */
  353. @Override
  354. public int insertTFee(TFee tFee) {
  355. tFee.setCreateTime(DateUtils.getNowDate());
  356. return tFeeMapper.insertTFee(tFee);
  357. }
  358. /**
  359. * 新增对账 、收费、
  360. *
  361. * @param tfee
  362. * @param tfeeDo
  363. * @param loginUser
  364. * @param fBilltype
  365. * @return
  366. */
  367. @Override
  368. @Transactional
  369. public AjaxResult insertTFeeTFeeDo(String tfee, String tfeeDo, LoginUser loginUser, String fBilltype) {
  370. Long fPid = null;
  371. Map<String, Object> map = new HashMap<>();
  372. TFee tFee = JSONArray.parseObject(tfee, TFee.class);
  373. if (StringUtils.isNull(tFee.getfId())) {
  374. // 如果是新数据
  375. tFee.setCreateBy(loginUser.getUser().getUserName());
  376. tFee.setCreateTime(new Date());
  377. tFee.setfDeptid(loginUser.getUser().getDeptId());
  378. tFee.setfBilltype(fBilltype);
  379. // 业务编码
  380. Date time = new Date();
  381. String billNo = billnoSerialServiceImpl.getBillNo(fBilltype, time);
  382. tFee.setfBillno(billNo);
  383. tFee.setSrcBillNo(billNo);
  384. tFee.setfBillstatus("2");
  385. tFeeMapper.insertTFee(tFee);
  386. fPid = tFee.getfId();
  387. } else {
  388. fPid = tFee.getfId();
  389. tFee.setUpdateBy(loginUser.getUser().getUserName());
  390. tFee.setUpdateTime(new Date());
  391. tFeeMapper.updateTFee(tFee);
  392. tFee = tFeeMapper.selectTFeeById(fPid);
  393. tFee.setSrcBillNo(tFee.getfBillno());
  394. // 删除从表
  395. // tFeeDoMapper.deleteByFPid(fPid);
  396. }
  397. // 财务从表
  398. if (StringUtils.isNotNull(tfeeDo)) {
  399. JSONArray jsonDrArray = JSONArray.parseArray(tfeeDo);
  400. List<TFeeDo> tFeeDoList = JSONObject.parseArray(jsonDrArray.toJSONString(), TFeeDo.class);
  401. for (TFeeDo tFeeDo : tFeeDoList) {
  402. if (StringUtils.isNull(tFeeDo.getfId())) {
  403. tFeeDo.setfPid(fPid);
  404. tFeeDo.setCreateBy(loginUser.getUser().getUserName());
  405. tFeeDo.setCreateTime(new Date());
  406. tFeeDo.setfSrcBillno(tFeeDo.getfBillno());
  407. tFeeDo.setfStatus("2");
  408. tFeeDoMapper.insertTFeeDo(tFeeDo);
  409. } else {
  410. // 走了修改
  411. tFeeDo.setUpdateBy(loginUser.getUser().getUserName());
  412. tFeeDo.setUpdateTime(new Date());
  413. tFeeDoMapper.updateTFeeDo(tFeeDo);
  414. }
  415. }
  416. }
  417. List<FinancialTFeeDoExcel> list = tFeeDoMapper.selectFinancialTFeeDo(fPid);
  418. map.put("tFee", tFee);
  419. map.put("tFeeDo", list);
  420. return AjaxResult.success("成功", map);
  421. }
  422. @Override
  423. public AjaxResult insertWebVersion(String tfee, String tfeeDo, LoginUser loginUser, String fBilltype) {
  424. Long fPid = null;
  425. Map<String, Object> map = new HashMap<>();
  426. TFee tFee = JSONArray.parseObject(tfee, TFee.class);
  427. if (StringUtils.isNull(tFee.getfId())) {
  428. // 如果是新数据
  429. tFee.setCreateBy(loginUser.getUser().getUserName());
  430. tFee.setCreateTime(new Date());
  431. tFee.setfDeptid(loginUser.getUser().getDeptId());
  432. tFee.setfBilltype(fBilltype);
  433. // 业务编码
  434. Date time = new Date();
  435. String billNo = billnoSerialServiceImpl.getBillNo(fBilltype, time);
  436. tFee.setfBillno(billNo);
  437. tFee.setfBillstatus("2");
  438. tFee.setfAccbilldate(new Date());
  439. tFeeMapper.insertTFee(tFee);
  440. fPid = tFee.getfId();
  441. } else {
  442. fPid = tFee.getfId();
  443. tFee.setUpdateBy(loginUser.getUser().getUserName());
  444. tFee.setUpdateTime(new Date());
  445. tFeeMapper.updateTFee(tFee);
  446. // 删除从表
  447. tFeeDoMapper.deleteByFPid(fPid);
  448. }
  449. // 财务从表
  450. if (StringUtils.isNotNull(tfeeDo)) {
  451. JSONArray jsonDrArray = JSONArray.parseArray(tfeeDo);
  452. List<TAccount> tFeeDoList = JSONObject.parseArray(jsonDrArray.toJSONString(), TAccount.class);
  453. for (TAccount tAccount : tFeeDoList) {
  454. TFeeDo tFeeDo = new TFeeDo();
  455. tFeeDo.setfSrcid(tAccount.getfSrcid());
  456. tFeeDo.setfSrcpid(tAccount.getfSrcpid());
  457. tFeeDo.setfPid(fPid);
  458. tFeeDo.setCreateBy(loginUser.getUser().getUserName());
  459. tFeeDo.setCreateTime(new Date());
  460. tFeeDo.setfStatus("2");
  461. tFeeDo.setfSrcdc("D");
  462. tFeeDo.setfAmtdr(tAccount.getfAmtdr());
  463. tFeeDo.setfAmt(tAccount.getfAmt());
  464. tFeeDo.setfFeeid(tAccount.getfFeeid());
  465. tFeeDoMapper.insertTFeeDo(tFeeDo);
  466. }
  467. }
  468. map.put("tFee", tFee);
  469. return AjaxResult.success("成功", map);
  470. }
  471. /**
  472. * 新增对账 、收费、
  473. *
  474. * @param tfee
  475. * @param tfeeDo
  476. * @param loginUser
  477. * @param fBilltype
  478. * @return
  479. */
  480. @Override
  481. @Transactional
  482. public AjaxResult insertKHTFeeTFeeDo(String tfee, String tfeeDo, String tFeeInvoice, LoginUser loginUser, String fBilltype) {
  483. Long fPid = null;
  484. Map<String, Object> map = new HashMap<>();
  485. String billStatus = "2";
  486. if (fBilltype.equals("INV")) {
  487. billStatus = "6";
  488. }
  489. TFee tFee = JSONArray.parseObject(tfee, TFee.class);
  490. if (StringUtils.isNull(tFee.getfId())) {
  491. // 如果是新数据
  492. tFee.setCreateBy(loginUser.getUser().getUserName());
  493. tFee.setCreateTime(new Date());
  494. tFee.setfDeptid(loginUser.getUser().getDeptId());
  495. tFee.setfBilltype(fBilltype);
  496. // 业务编码
  497. Date time = new Date();
  498. String billNo = billnoSerialServiceImpl.getBillNo(fBilltype, time);
  499. tFee.setfBillno(billNo);
  500. tFee.setfBillstatus(billStatus);
  501. tFeeMapper.insertTFee(tFee);
  502. fPid = tFee.getfId();
  503. } else {
  504. fPid = tFee.getfId();
  505. boolean change = this.change(fPid);
  506. if (!change && !"INV".equals(fBilltype)) {
  507. return AjaxResult.error("当前数据不支持修改");
  508. }
  509. tFee.setUpdateBy(loginUser.getUser().getUserName());
  510. tFee.setUpdateTime(new Date());
  511. tFeeMapper.updateTFee(tFee);
  512. // 删除从表
  513. tFeeDoMapper.deleteByFPid(fPid);
  514. tFeeInvoiceMapper.deleteByFPid(fPid);
  515. }
  516. // 财务从表
  517. if (StringUtils.isNotNull(tfeeDo)) {
  518. JSONArray jsonDrArray = JSONArray.parseArray(tfeeDo);
  519. List<TFeeDo> tFeeDoList = JSONObject.parseArray(jsonDrArray.toJSONString(), TFeeDo.class);
  520. for (TFeeDo tFeeDo : tFeeDoList) {
  521. tFeeDo.setfPid(fPid);
  522. tFeeDo.setCreateBy(loginUser.getUser().getUserName());
  523. tFeeDo.setCreateTime(new Date());
  524. tFeeDo.setfStatus(billStatus);
  525. tFeeDoMapper.insertTFeeDo(tFeeDo);
  526. }
  527. }
  528. if (!"".equals(tFeeInvoice) && tFeeInvoice != null && !"null".equals(tFeeInvoice)) {
  529. JSONArray jsonDrArray = JSONArray.parseArray(tFeeInvoice);
  530. List<TFeeInvoice> tFeeInvoiceList = JSONObject.parseArray(jsonDrArray.toJSONString(), TFeeInvoice.class);
  531. for (TFeeInvoice feeInvoice : tFeeInvoiceList) {
  532. feeInvoice.setfPid(fPid);
  533. feeInvoice.setCreateBy(loginUser.getUser().getUserName());
  534. feeInvoice.setCreateTime(new Date());
  535. feeInvoice.setfBillstatus(billStatus);
  536. tFeeInvoiceMapper.insertTFeeInvoice(feeInvoice);
  537. }
  538. }
  539. map.put("tFee", tFee);
  540. return AjaxResult.success("成功", map);
  541. }
  542. /**
  543. * 修改财务数据主
  544. *
  545. * @param tFee 财务数据主
  546. * @return 结果
  547. */
  548. @Override
  549. public int updateTFee(TFee tFee) {
  550. tFee.setUpdateTime(DateUtils.getNowDate());
  551. return tFeeMapper.updateTFee(tFee);
  552. }
  553. /**
  554. * 批量删除财务数据主
  555. *
  556. * @param fIds 需要删除的财务数据主ID
  557. * @return 结果
  558. */
  559. @Override
  560. @Transactional
  561. public AjaxResult deleteWebVersionByIds(Long[] fIds) {
  562. // 取出业务编号、 放入 billno_del
  563. for (Long id : fIds) {
  564. // 1、查询主表信息
  565. TFee tFee = tFeeMapper.selectTFeeById(id);
  566. boolean change = this.change(id);
  567. if (change == false) {
  568. TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
  569. return AjaxResult.error("数据正在审批或审批通过,不允许删除");
  570. }
  571. // 2、业务编号、客存编号 放入 billno_del
  572. BillnoDel billnoDel = new BillnoDel();
  573. billnoDel.setBillType(tFee.getfBilltype());
  574. billnoDel.setBillNo(tFee.getfBillno());
  575. billnoDelMapper.insertBillnoDel(billnoDel);
  576. if (tFee.getfAccountId() != null) {
  577. TFee fee = tFeeMapper.selectTFeeById(tFee.getfAccountId());
  578. fee.setfMake(0);
  579. int updateTFee = tFeeMapper.updateTFee(fee);
  580. }
  581. }
  582. int i = tFeeMapper.deleteTFeeByIds(fIds);
  583. if (i <= 0) {
  584. TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
  585. return AjaxResult.error("删除发票申请失败,请找管理员");
  586. }
  587. return AjaxResult.success();
  588. }
  589. @Override
  590. public int deleteTFeeByIds(Long[] fIds) {
  591. // 取出业务编号、 放入 billno_del
  592. for (Long id : fIds) {
  593. // 1、查询主表信息
  594. TFee tFee = tFeeMapper.selectTFeeById(id);
  595. // 2、业务编号、客存编号 放入 billno_del
  596. BillnoDel billnoDel = new BillnoDel();
  597. billnoDel.setBillType(tFee.getfBilltype());
  598. billnoDel.setBillNo(tFee.getfBillno());
  599. billnoDelMapper.insertBillnoDel(billnoDel);
  600. if (tFee.getfAccountId() != null) {
  601. TFee fee = tFeeMapper.selectTFeeById(tFee.getfAccountId());
  602. fee.setfMake(0);
  603. tFeeMapper.updateTFee(fee);
  604. }
  605. }
  606. return tFeeMapper.deleteTFeeByIds(fIds);
  607. }
  608. /**
  609. * 删除财务数据主信息
  610. *
  611. * @param fId 财务数据主ID
  612. * @return 结果
  613. */
  614. @Override
  615. public int deleteTFeeById(Long fId) {
  616. return tFeeMapper.deleteTFeeById(fId);
  617. }
  618. @Override
  619. public List<Map<String, Object>> warehouseBillsFeesList(TWareHouseFees tWareHouseFees, String billsType) {
  620. Map<String, Object> map = new HashMap<>();
  621. map.put("tWareHouseFees", tWareHouseFees);
  622. List<Map<String, Object>> mapList;
  623. if (billsType.equals("DZ") || billsType.equals("KHDZ")) {
  624. mapList = tFeeMapper.warehouseBillsFeesListAccamount(map);
  625. updateBillTypeName(mapList, tWareHouseFees.getfBilltype());
  626. return mapList;
  627. } else if (billsType.equals("invoiceFP")) {
  628. mapList = tFeeMapper.warehouseInvoiceFPFeesList(map);
  629. return mapList;
  630. } else if (billsType.equals("ApplyFP")) {
  631. mapList = tFeeMapper.warehouseApplyFPFeesList(map);
  632. return mapList;
  633. } else if (FeesTypeEnum.INVOICE.getType().equals(billsType)) {
  634. // 查询发票
  635. mapList = tFeeMapper.queryApplyInvoiceFeesList(map);
  636. return mapList;
  637. } else {
  638. mapList = tFeeMapper.warehouseBillsFeesList(map);
  639. updateBillTypeName(mapList, tWareHouseFees.getfBilltype());
  640. return mapList;
  641. }
  642. }
  643. /**
  644. * 根据传入业务类型判断传入对应值
  645. *
  646. * @param mapList
  647. * @param type
  648. */
  649. private void updateBillTypeName(List<Map<String, Object>> mapList, String type) {
  650. if (CollectionUtils.isNotEmpty(mapList)) {
  651. List<String> typeList = Lists.newArrayList();
  652. typeList.add(ST_IN_TYPE);
  653. typeList.add(ST_OUT_TYPE);
  654. typeList.add(ST_TRANS_TYPE);
  655. List<SysDictData> sysDictDataList = sysDictDataMapper.selectByTypes(typeList);
  656. // 遍历map
  657. for (Map<String, Object> map : mapList) {
  658. // 如果类型为入库
  659. if (StringUtils.isEmpty(type) && Objects.nonNull(map.get("fBusinessType"))) {
  660. String fBusinessType = map.get("fBusinessType").toString();
  661. String dictLabel = sysDictDataList.stream().filter(li -> Objects.equals(li.getDictValue(), fBusinessType))
  662. .map(SysDictData::getDictLabel).findFirst().orElseThrow(() -> new WarehouseException("缺少字典表信息"));
  663. map.put("fBusinessType", dictLabel);
  664. } else if (StringUtils.isNotEmpty(type) && type.equals(WarehouseTypeEnum.SJRK.getType()) && Objects.nonNull(map.get("fBusinessType"))) {
  665. String dictLabel = DictUtils.getDictLabel(ST_IN_TYPE, map.get("fBusinessType").toString());
  666. if (StringUtils.isNotEmpty(dictLabel)) {
  667. map.put("fBusinessType", dictLabel);
  668. }
  669. } else if (StringUtils.isNotEmpty(type) && type.equals(WarehouseTypeEnum.SJCK.getType()) && Objects.nonNull(map.get("fBusinessType"))) {
  670. String dictLabel = DictUtils.getDictLabel(ST_OUT_TYPE, map.get("fBusinessType").toString());
  671. if (StringUtils.isNotEmpty(dictLabel)) {
  672. map.put("fBusinessType", dictLabel);
  673. }
  674. } else if (StringUtils.isNotEmpty(type) && type.equals(WarehouseTypeEnum.HQZY.getType()) && Objects.nonNull(map.get("fBusinessType"))) {
  675. String dictLabel = DictUtils.getDictLabel(ST_TRANS_TYPE, map.get("fBusinessType").toString());
  676. if (StringUtils.isNotEmpty(dictLabel)) {
  677. map.put("fBusinessType", dictLabel);
  678. }
  679. }
  680. }
  681. }
  682. }
  683. @Override
  684. public List<FeeVO> warehouseBillsFeesList(TWareHouseFees tWareHouseFees) {
  685. if (tWareHouseFees.getSwitchSection() == 1) {
  686. tWareHouseFees.setTimeExamine(tWareHouseFees.getTimeExamine());
  687. } else {
  688. tWareHouseFees.setfBstimeExamine(tWareHouseFees.getTimeExamine());
  689. }
  690. return tFeeMapper.selectFinancialLedgerList(tWareHouseFees);
  691. }
  692. @Override
  693. public List<Map<String, Object>> warehouseBillsFeesProfitList(TWareHouseFees tWareHouseFees) {
  694. if (tWareHouseFees.getGroupBy() == 0) {
  695. return tFeeMapper.warehouseBillsFeesProfitList(tWareHouseFees);
  696. }
  697. if (tWareHouseFees.getSwitchSection() == 1) {
  698. tWareHouseFees.setTimeExamine(tWareHouseFees.getTimeExamine());
  699. } else {
  700. tWareHouseFees.setfBstimeExamine(tWareHouseFees.getTimeExamine());
  701. }
  702. return tFeeMapper.warehouseBillsFeesCustomProfitList(tWareHouseFees);
  703. }
  704. public static BigDecimal calculation1(String fTotalgross, String fGrossweightblc) {
  705. BigDecimal num1 = new BigDecimal(fTotalgross);
  706. BigDecimal num2 = new BigDecimal(fGrossweightblc);
  707. BigDecimal result = num1.subtract(num2);
  708. return result.setScale(2, BigDecimal.ROUND_HALF_UP);
  709. }
  710. @Override
  711. @Transactional
  712. public AjaxResult confirm(String tfee, String tfeeDo, LoginUser loginUser, String fBilltype) {
  713. String key = "";
  714. boolean isApprove = false;
  715. Map<String, Object> messageMap = new HashMap<>();
  716. long actId = 0L;
  717. if (!fBilltype.equals(FeesTypeEnum.INVOICE.getType())) {
  718. if ("DZ".equals(fBilltype)) {
  719. actId = 210L;
  720. key = "warehouse.contrast.ApprovalFlow";
  721. } else if ("SF".equals(fBilltype)) {
  722. actId = 220L;
  723. key = "warehouse.charge.ApprovalFlow";
  724. } else if ("FF".equals(fBilltype)) {
  725. actId = 230L;
  726. key = "warehouse.payment.ApprovalFlow";
  727. } else if ("KHDZ".equals(fBilltype)) {
  728. actId = 430L;
  729. key = "warehouse.kaiHeContrast.ApprovalFlow";
  730. } else if ("KHSF".equals(fBilltype)) {
  731. actId = 440L;
  732. key = "warehouse.kaiHeCharge.ApprovalFlow";
  733. } else if ("KHFF".equals(fBilltype)) {
  734. actId = 450L;
  735. key = "warehouse.kaiHePayment.ApprovalFlow";
  736. }
  737. SysConfig sysConfig = sysConfigMapper.checkConfigKeyUnique(key);
  738. if (StringUtils.isNull(sysConfig)) {
  739. TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
  740. return AjaxResult.error("系统参数异常,未找到开启审批流参数");
  741. }
  742. if ("0".equals(sysConfig.getConfigValue())) {
  743. isApprove = true;
  744. }
  745. }
  746. TFee tFee = JSONArray.parseObject(tfee, TFee.class);
  747. // 声明业务编号 list
  748. List<String> fSrcBillnos = new ArrayList<>();
  749. String billstatus = "";
  750. if (isApprove) {
  751. billstatus = "4";
  752. } else {
  753. billstatus = "6";
  754. }
  755. if (StringUtils.isNull(tFee.getfId())) {
  756. // 如果是新数据
  757. tFee.setCreateBy(loginUser.getUser().getUserName());
  758. tFee.setfDeptid(loginUser.getUser().getDeptId());
  759. tFee.setfBilltype(fBilltype);
  760. tFee.setfBillstatus(billstatus);
  761. // 业务编码
  762. Date time = new Date();
  763. String billNo = billnoSerialServiceImpl.getBillNo(fBilltype, time);
  764. tFee.setfBillno(billNo);
  765. tFeeMapper.insertTFee(tFee);
  766. } else {
  767. tFee.setUpdateBy(loginUser.getUser().getUserName());
  768. tFee.setUpdateTime(new Date());
  769. tFee.setfBillstatus(billstatus);
  770. tFeeMapper.updateTFee(tFee);
  771. }
  772. // 删除从表
  773. //tFeeDoMapper.deleteByFPid(tFee.getfId());
  774. messageMap.put("tFee", tFee);
  775. fSrcBillnos.add(tFee.getfSrcBillno());
  776. // 财务从表
  777. if (StringUtils.isNotNull(tfeeDo) && !"[]".equals(tfeeDo)) {
  778. JSONArray jsonDrArray = JSONArray.parseArray(tfeeDo);
  779. List<TFeeDo> tFeeDoList = JSONObject.parseArray(jsonDrArray.toJSONString(), TFeeDo.class);
  780. for (TFeeDo tFeeDo : tFeeDoList) {
  781. if (StringUtils.isNull(tFeeDo.getfId())) {
  782. Map<String, Object> map = this.judgeMoney(tFeeDo.getfSrcid(), tFeeDo.getfAmt(), fBilltype, tFeeDo.getfFeeid());
  783. if (!(Boolean) map.get("flag")) {
  784. TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
  785. return AjaxResult.error(map.get("message").toString());
  786. }
  787. tFeeDo.setfPid(tFee.getfId());
  788. tFeeDo.setCreateBy(loginUser.getUser().getUserName());
  789. tFeeDo.setCreateTime(new Date());
  790. tFeeDo.setfStatus(billstatus);
  791. tFeeDo.setfSrcBillno(tFee.getfSrcBillno());
  792. tFeeDoMapper.insertTFeeDo(tFeeDo);
  793. } else {
  794. // 走了修改
  795. tFeeDo.setUpdateBy(loginUser.getUser().getUserName());
  796. tFeeDo.setUpdateTime(new Date());
  797. tFeeDoMapper.updateTFeeDo(tFeeDo);
  798. }
  799. }
  800. }
  801. // 点击对账、收费、付费提交审核时去掉费用
  802. if (actId >= 210L && actId <= 230L) {
  803. AjaxResult ajaxResult = this.billsfeesFollow(tFee.getfId());
  804. String code = ajaxResult.get("code").toString();
  805. if ("500".equals(code)) {
  806. TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
  807. return ajaxResult;
  808. }
  809. }
  810. //凯和收费提交审核时去掉钱
  811. if (actId >= 430 && actId <= 450){
  812. AjaxResult ajaxResult = this.billsfeesFollow(tFee.getfId());
  813. String code = ajaxResult.get("code").toString();
  814. if ("500".equals(code)) {
  815. TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
  816. return ajaxResult;
  817. }
  818. }
  819. // 这里加个判断取系统参数来确定是否需要启用审批流
  820. if (isApprove) {
  821. AuditItems auditItems = new AuditItems();
  822. auditItems.setLevelId(0L);
  823. auditItems.setBillId(tFee.getfId());
  824. auditItems.setActId(actId);
  825. auditItems.setIffinalItem("F");
  826. auditItems.setBillNo(tFee.getfBillno()); // 业务编号
  827. auditItems.setRefno1(String.valueOf(tFee.getfCorpid())); // 货权方
  828. auditItems.setRefno2(fBilltype);// 财务类型
  829. auditItems.setRefno3(tFee.gettMblno());// 提单号
  830. auditItems.setSendUserId(loginUser.getUser().getUserId()); // 请核人 ID
  831. auditItems.setSendName(loginUser.getUsername()); // 请核人名称
  832. auditItems.setSendTime(new Date()); // 请核时间
  833. auditItems.setAuditUserId(loginUser.getUser().getUserId());// 审核人 ID
  834. auditItems.setAuditItem(new Date());// 审核通过时间
  835. auditItems.setAuditOpTime(new Date());// 审核时间
  836. auditItems.setFidStatus("f_billstatus");// 存储对应审批字段
  837. auditItems.setTimes(1L);// 第几次提交审批
  838. auditItems.setAuditMsg("提交");
  839. auditItems.setAuditStatus("O");// 提交状态
  840. auditItems.setfSrcBillnos(fSrcBillnos);// 装载业务编号数据(来源单据编号)
  841. AjaxResult approvalFlow = auditItemsService.createApprovalFlow(auditItems);// 生成审批流
  842. Long code = Long.valueOf(String.valueOf(approvalFlow.get("code"))).longValue();
  843. if (code.equals(500L)) {
  844. TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
  845. return AjaxResult.error("发票申请提交审核失败,请找管理员");
  846. }
  847. } else {
  848. if (StringUtils.isNotNull(tfeeDo) && !"[]".equals(tfeeDo)) {
  849. JSONArray jsonDrArray = JSONArray.parseArray(tfeeDo);
  850. List<TFeeDo> tFeeDoList = JSONObject.parseArray(jsonDrArray.toJSONString(), TFeeDo.class);
  851. for (TFeeDo tFeeDo : tFeeDoList) {
  852. // 跟新费用明细
  853. int m = updateBillsFees(tFee.getfId(), tFeeDo, fBilltype);
  854. if (m == 0) {
  855. TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
  856. return AjaxResult.error("更新费用明细失败");
  857. }
  858. }
  859. }
  860. AjaxResult ajaxResult = tfeeFollow(tFee.getfId(), 6L);
  861. Long code = Long.valueOf(String.valueOf(ajaxResult.get("code"))).longValue();
  862. if (code.equals(500L)) {
  863. TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
  864. return AjaxResult.error("发票申请提交审核失败,请找管理员");
  865. }
  866. //凯和系统 修改订单的实收实付费用
  867. if ("KHSF".equals(fBilltype) || "KHFF".equals(fBilltype)){
  868. this.updateMessage(tFee.getfId());
  869. }
  870. }
  871. return AjaxResult.success("成功", messageMap);
  872. }
  873. @Override
  874. @Transactional
  875. public AjaxResult webVersionConfirm(Long[] fIds, String billsType, LoginUser loginUser) {
  876. String key = "";
  877. boolean isApprove = false;
  878. long actId = 0L;
  879. if ("DZ".equals(billsType)) {
  880. actId = 210L;
  881. key = "warehouse.contrast.ApprovalFlow";
  882. } else if ("SF".equals(billsType)) {
  883. actId = 220L;
  884. key = "warehouse.charge.ApprovalFlow";
  885. } else if ("FF".equals(billsType)) {
  886. actId = 230L;
  887. key = "warehouse.payment.ApprovalFlow";
  888. } else if ("KHDZ".equals(billsType)) {
  889. actId = 430L;
  890. key = "warehouse.kaiHeContrast.ApprovalFlow";
  891. } else if ("KHSF".equals(billsType)) {
  892. actId = 440L;
  893. key = "warehouse.kaiHeCharge.ApprovalFlow";
  894. } else if ("KHFF".equals(billsType)) {
  895. actId = 450L;
  896. key = "warehouse.kaiHePayment.ApprovalFlow";
  897. }
  898. SysConfig sysConfig = sysConfigMapper.checkConfigKeyUnique(key);
  899. if (StringUtils.isNull(sysConfig)) {
  900. TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
  901. return AjaxResult.error("系统参数异常,未找到开启审批流参数");
  902. }
  903. if ("0".equals(sysConfig.getConfigValue())) {
  904. isApprove = true;
  905. }
  906. String billStatus = null;
  907. if (isApprove) {
  908. billStatus = "4";
  909. } else {
  910. billStatus = "6";
  911. }
  912. for (Long fId : fIds) {
  913. TFee tFee = tFeeMapper.selectTFeeById(fId);
  914. if (tFee == null) {
  915. return AjaxResult.error("对账数据有误请确认");
  916. }
  917. boolean change = this.change(tFee.getfId());
  918. if (change == false) {
  919. return AjaxResult.error("数据正在审批或审批通过,不允许提交审核");
  920. }
  921. //更新主表数据状态
  922. TFee fee = new TFee();
  923. fee.setfId(fId);
  924. fee.setfBillstatus(billStatus);
  925. int i = tFeeMapper.updateTFee(fee);
  926. //更新从表数据状态
  927. int update = tFeeDoMapper.tfeeDoFollowUpdate(fId, Long.valueOf(billStatus));
  928. if (isApprove) {
  929. AuditItems auditItems = new AuditItems();
  930. auditItems.setLevelId(0L);
  931. auditItems.setBillId(tFee.getfId());
  932. auditItems.setActId(actId);
  933. auditItems.setIffinalItem("F");
  934. auditItems.setBillNo(tFee.getfBillno()); // 业务编号
  935. auditItems.setRefno1(String.valueOf(tFee.getfCorpid())); // 货权方
  936. auditItems.setRefno2(billsType);// 财务类型
  937. auditItems.setRefno3(tFee.gettMblno());// 提单号
  938. auditItems.setSendUserId(loginUser.getUser().getUserId());
  939. auditItems.setSendName(loginUser.getUsername());
  940. auditItems.setSendTime(new Date());
  941. auditItems.setAuditUserId(loginUser.getUser().getUserId());
  942. auditItems.setAuditItem(new Date());
  943. auditItems.setAuditOpTime(new Date());
  944. auditItems.setFidStatus("f_billstatus");
  945. auditItems.setTimes(1L);
  946. auditItems.setAuditMsg("提交");
  947. auditItems.setAuditStatus("O");
  948. AjaxResult approvalFlow = auditItemsService.createApprovalFlow(auditItems);
  949. Long code = Long.valueOf(String.valueOf(approvalFlow.get("code"))).longValue();
  950. if (code.equals(500L)) {
  951. TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
  952. }
  953. return approvalFlow;
  954. } else {
  955. TFeeDo tFeeDo = new TFeeDo();
  956. tFeeDo.setfPid(fId);
  957. List<TFeeDo> tFeeDoList = tFeeDoMapper.selectTFeeDoList(tFeeDo);
  958. for (TFeeDo feeDo : tFeeDoList) {
  959. // 跟新费用明细
  960. int m = updateBillsFees(fId, feeDo, billsType);
  961. if (m == 0) {
  962. TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
  963. return AjaxResult.error("更新费用明细失败");
  964. }
  965. }
  966. }
  967. AjaxResult ajaxResult = tfeeFollow(tFee.getfId(), 6L);
  968. Long code = Long.valueOf(String.valueOf(ajaxResult.get("code"))).longValue();
  969. return ajaxResult;
  970. }
  971. return AjaxResult.success();
  972. }
  973. @Override
  974. @Transactional
  975. public AjaxResult confirmKaiHe(String tfee, String tfeeDo, String tFeeInvoice, LoginUser loginUser, String fBilltype) {
  976. Long fPid = null;
  977. TFee tFee = JSONArray.parseObject(tfee, TFee.class);
  978. Map<String, Object> messageMap = new HashMap<>();
  979. String key = "";
  980. boolean isApprove = false;
  981. long actId = 0L;
  982. String billStatus = "";
  983. if ("DZ".equals(fBilltype)) {
  984. actId = 210L;
  985. key = "warehouse.contrast.ApprovalFlow";
  986. } else if ("SF".equals(fBilltype)) {
  987. actId = 220L;
  988. key = "warehouse.charge.ApprovalFlow";
  989. } else if ("FF".equals(fBilltype)) {
  990. actId = 230L;
  991. key = "warehouse.payment.ApprovalFlow";
  992. } else if ("KHDZ".equals(fBilltype)) {
  993. actId = 430L;
  994. key = "warehouse.kaiHeContrast.ApprovalFlow";
  995. } else if ("KHSF".equals(fBilltype)) {
  996. actId = 440L;
  997. key = "warehouse.kaiHeCharge.ApprovalFlow";
  998. } else if ("KHFF".equals(fBilltype)) {
  999. actId = 450L;
  1000. key = "warehouse.kaiHePayment.ApprovalFlow";
  1001. } else if ("ApplyFP".equals(fBilltype)) {
  1002. actId = 470L;
  1003. key = "warehouse.kaiHeApplyFP.ApprovalFlow";
  1004. }
  1005. SysConfig sysConfig = sysConfigMapper.checkConfigKeyUnique(key);
  1006. if (StringUtils.isNull(sysConfig)) {
  1007. TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
  1008. return AjaxResult.error("系统参数异常,未找到开启审批流参数");
  1009. }
  1010. if ("0".equals(sysConfig.getConfigValue())) {
  1011. isApprove = true;
  1012. }
  1013. if (isApprove) {
  1014. billStatus = "4";
  1015. } else {
  1016. billStatus = "6";
  1017. }
  1018. if (StringUtils.isNull(tFee.getfId())) {
  1019. // 如果是新数据
  1020. tFee.setCreateBy(loginUser.getUser().getUserName());
  1021. tFee.setfDeptid(loginUser.getUser().getDeptId());
  1022. tFee.setfBilltype(fBilltype);
  1023. // 业务编码
  1024. Date time = new Date();
  1025. String billNo = billnoSerialServiceImpl.getBillNo(fBilltype, time);
  1026. tFee.setfBillno(billNo);
  1027. tFee.setfBillstatus(billStatus);
  1028. tFeeMapper.insertTFee(tFee);
  1029. fPid = tFee.getfId();
  1030. } else {
  1031. fPid = tFee.getfId();
  1032. boolean change = this.change(fPid);
  1033. if (!change) {
  1034. return AjaxResult.error("当前数据不支持修改");
  1035. }
  1036. tFee.setUpdateBy(loginUser.getUser().getUserName());
  1037. tFee.setUpdateTime(new Date());
  1038. tFee.setfBillstatus(billStatus);
  1039. tFeeMapper.updateTFee(tFee);
  1040. // 删除从表
  1041. tFeeDoMapper.deleteByFPid(tFee.getfId());
  1042. //删除开票从表
  1043. tFeeInvoiceMapper.deleteByFPid(tFee.getfId());
  1044. }
  1045. messageMap.put("tFee", tFee);
  1046. // 财务从表
  1047. if (StringUtils.isNotNull(tfeeDo) && !"[]".equals(tfeeDo)) {
  1048. JSONArray jsonDrArray = JSONArray.parseArray(tfeeDo);
  1049. List<TFeeDo> tFeeDoList = JSONObject.parseArray(jsonDrArray.toJSONString(), TFeeDo.class);
  1050. for (TFeeDo tFeeDo : tFeeDoList) {
  1051. Map<String, Object> map = this.judgeMoney(tFeeDo.getfSrcid(), tFeeDo.getfAmt(), fBilltype, tFeeDo.getfFeeid());
  1052. boolean b = (Boolean) map.get("flag");
  1053. if (b == false) {
  1054. TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
  1055. return AjaxResult.error(map.get("message").toString());
  1056. }
  1057. tFeeDo.setfPid(tFee.getfId());
  1058. tFeeDo.setCreateBy(loginUser.getUser().getUserName());
  1059. tFeeDo.setCreateTime(new Date());
  1060. tFeeDo.setfStatus(billStatus);
  1061. tFeeDoMapper.insertTFeeDo(tFeeDo);
  1062. }
  1063. }
  1064. if (!"".equals(tFeeInvoice) && tFeeInvoice != null && !"null".equals(tFeeInvoice)) {
  1065. JSONArray jsonDrArray = JSONArray.parseArray(tFeeInvoice);
  1066. List<TFeeInvoice> tFeeInvoiceList = JSONObject.parseArray(jsonDrArray.toJSONString(), TFeeInvoice.class);
  1067. for (TFeeInvoice feeInvoice : tFeeInvoiceList) {
  1068. feeInvoice.setfPid(fPid);
  1069. feeInvoice.setCreateBy(loginUser.getUser().getUserName());
  1070. feeInvoice.setCreateTime(new Date());
  1071. feeInvoice.setfBillstatus(billStatus);
  1072. tFeeInvoiceMapper.insertTFeeInvoice(feeInvoice);
  1073. }
  1074. }
  1075. // 这里加个判断取系统参数来确定是否需要启用审批流
  1076. if (isApprove) {
  1077. AuditItems auditItems = new AuditItems();
  1078. auditItems.setLevelId(0L);
  1079. auditItems.setBillId(tFee.getfId());
  1080. auditItems.setActId(actId);
  1081. auditItems.setIffinalItem("F");
  1082. auditItems.setBillNo(tFee.getfBillno()); // 业务编号
  1083. auditItems.setRefno1(String.valueOf(tFee.getfCorpid())); // 货权方
  1084. auditItems.setRefno2(fBilltype);// 财务类型
  1085. auditItems.setRefno3(tFee.gettMblno());// 提单号
  1086. auditItems.setSendUserId(loginUser.getUser().getUserId());
  1087. auditItems.setSendName(loginUser.getUsername());
  1088. auditItems.setSendTime(new Date());
  1089. auditItems.setAuditUserId(loginUser.getUser().getUserId());
  1090. auditItems.setAuditItem(new Date());
  1091. auditItems.setAuditOpTime(new Date());
  1092. auditItems.setFidStatus("f_billstatus");
  1093. auditItems.setTimes(1L);
  1094. auditItems.setAuditMsg("提交");
  1095. auditItems.setAuditStatus("O");
  1096. AjaxResult approvalFlow = auditItemsService.createApprovalFlow(auditItems);
  1097. Long code = Long.valueOf(String.valueOf(approvalFlow.get("code"))).longValue();
  1098. if (code.equals(500L)) {
  1099. TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
  1100. return AjaxResult.error("发票申请提交审核失败,请找管理员");
  1101. }
  1102. } else {
  1103. if (StringUtils.isNotNull(tfeeDo) && !"[]".equals(tfeeDo)) {
  1104. JSONArray jsonDrArray = JSONArray.parseArray(tfeeDo);
  1105. List<TFeeDo> tFeeDoList = JSONObject.parseArray(jsonDrArray.toJSONString(), TFeeDo.class);
  1106. for (TFeeDo tFeeDo : tFeeDoList) {
  1107. // 跟新费用明细
  1108. int m = updateBillsFees(tFee.getfId(), tFeeDo, fBilltype);
  1109. if (m == 0) {
  1110. TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
  1111. return AjaxResult.error("更新费用明细失败");
  1112. }
  1113. }
  1114. }
  1115. AjaxResult ajaxResult = tfeeFollow(tFee.getfId(), 6L);
  1116. Long code = Long.valueOf(String.valueOf(ajaxResult.get("code"))).longValue();
  1117. if (code.equals(500L)) {
  1118. TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
  1119. return AjaxResult.error("发票申请提交审核失败,请找管理员");
  1120. }
  1121. }
  1122. return AjaxResult.success("成功", messageMap);
  1123. }
  1124. /**
  1125. * 根据财务主表id 更新对应明细表状态
  1126. *
  1127. * @param fPid 财务主表id
  1128. * @return 结果
  1129. */
  1130. @Transactional
  1131. public AjaxResult tfeeFollow(Long fPid, long fettle) {
  1132. if (StringUtils.isNull(fPid)) {
  1133. return AjaxResult.error("财务更新状态未找到主表信息,请与管理员联系");
  1134. }
  1135. TFee tFee = new TFee();
  1136. tFee.setfId(fPid);
  1137. tFee.setfBillstatus(String.valueOf(fettle));
  1138. int tFeeUpdateResult = tFeeMapper.updateTFee(tFee);
  1139. if (tFeeUpdateResult <= 0) {
  1140. TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
  1141. return AjaxResult.error("更新财务明细状态失败,请联系管理员");
  1142. }
  1143. try {
  1144. int itemUpdateResult = tFeeDoMapper.tfeeDoFollowUpdate(fPid, fettle);
  1145. } catch (Exception exception) {
  1146. TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
  1147. return AjaxResult.error("更新财务明细状态失败,请联系管理员");
  1148. }
  1149. TFeeInvoice invoice = new TFeeInvoice();
  1150. invoice.setfPid(fPid);
  1151. List<TFeeInvoice> tFeeInvoiceList = tFeeInvoiceMapper.selectTFeeInvoiceList(invoice);
  1152. if (CollectionUtils.isNotEmpty(tFeeInvoiceList)) {
  1153. try {
  1154. int itemUpdateResult = tFeeInvoiceMapper.tFeeInvoiceUpdate(fPid, fettle);
  1155. } catch (Exception exception) {
  1156. TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
  1157. return AjaxResult.error("更新开票明细状态失败,请联系管理员");
  1158. }
  1159. }
  1160. return AjaxResult.success();
  1161. }
  1162. @Transactional
  1163. public synchronized AjaxResult billsfeesFollow(Long fPid) {
  1164. if (StringUtils.isNull(fPid)) {
  1165. return AjaxResult.error("费用明细更新状态未找到主表信息,请与管理员联系");
  1166. }
  1167. TFee tFee = tFeeMapper.selectTFeeById(fPid);
  1168. // 查询从表数据
  1169. TFeeDo tFeeDo = new TFeeDo();
  1170. tFeeDo.setfPid(fPid);
  1171. List<TFeeDo> tFeeDoList = tFeeDoMapper.selectTFeeDoList(tFeeDo);
  1172. for (TFeeDo tFeeDo1 : tFeeDoList) {
  1173. // 跟新费用明细
  1174. Map<String, Object> map = this.judgeMoney(tFeeDo1.getfSrcid(), tFeeDo1.getfAmt(), tFee.getfBilltype(), tFeeDo1.getfFeeid());
  1175. if (!(Boolean) map.get("flag")) {
  1176. TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
  1177. return AjaxResult.error(map.get("message").toString());
  1178. }
  1179. int m = updateBillsFees(fPid, tFeeDo1, tFee.getfBilltype());
  1180. if (m == 0) {
  1181. TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
  1182. return AjaxResult.error("更新费用明细失败");
  1183. }
  1184. }
  1185. return AjaxResult.success();
  1186. }
  1187. /**
  1188. * 账单管理撤销对账、收费、付费
  1189. * @param fPid
  1190. * @param fBillType
  1191. * @return
  1192. */
  1193. @Transactional
  1194. public AjaxResult updateDSFMoney(Long fPid,String fBillType){
  1195. if (StringUtils.isNull(fPid)) {
  1196. return AjaxResult.error("费用明细更新状态未找到主表信息,请与管理员联系");
  1197. }
  1198. TFee tFee = tFeeMapper.selectTFeeById(fPid);
  1199. // 获取从表数据
  1200. TFeeDo tFeeDo = new TFeeDo();
  1201. tFeeDo.setfPid(fPid);
  1202. List<TFeeDo> tFeeDos = tFeeDoMapper.selectTFeeDoList(tFeeDo);
  1203. for (TFeeDo tFeeDo1 : tFeeDos) {
  1204. int m = updateBillsFees(fPid, tFeeDo1, fBillType);
  1205. if (m == 0) {
  1206. TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
  1207. return AjaxResult.error("更新费用明细失败");
  1208. }
  1209. }
  1210. return AjaxResult.success();
  1211. }
  1212. /**
  1213. * 凯和撤销收费 付费 对账
  1214. * @param fPid
  1215. * @param fBillType
  1216. * @return
  1217. */
  1218. @Transactional
  1219. public AjaxResult updateMoney(Long fPid,String fBillType) {
  1220. if (StringUtils.isNull(fPid)) {
  1221. return AjaxResult.error("费用明细更新状态未找到主表信息,请与管理员联系");
  1222. }
  1223. TFee tFee = tFeeMapper.selectTFeeById(fPid);
  1224. // 查询从表数据
  1225. TFeeDo tFeeDo = new TFeeDo();
  1226. tFeeDo.setfPid(fPid);
  1227. List<TFeeDo> tFeeDoList = tFeeDoMapper.selectTFeeDoList(tFeeDo);
  1228. for (TFeeDo tFeeDo1 : tFeeDoList) {
  1229. /* // 跟新费用明细
  1230. Map<String, Object> map = this.judgeMoney(tFeeDo1.getfSrcid(), tFeeDo1.getfAmt(), tFee.getfBilltype(), tFeeDo1.getfFeeid());
  1231. if (!(Boolean) map.get("flag")) {
  1232. TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
  1233. return AjaxResult.error(map.get("message").toString());
  1234. }*/
  1235. int m = updateBillsFees(fPid, tFeeDo1, fBillType);
  1236. if (m == 0) {
  1237. TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
  1238. return AjaxResult.error("更新费用明细失败");
  1239. }
  1240. }
  1241. return AjaxResult.success();
  1242. }
  1243. @Override
  1244. @Transactional
  1245. public AjaxResult revoke(String tfee, String tfeeDo, LoginUser loginUser, String fBilltype) {
  1246. // 更新 主表、从表
  1247. TFee tFee = JSONArray.parseObject(tfee, TFee.class);
  1248. if ("DZApplyFP".equals(fBilltype)) {
  1249. TFee fee = tFeeMapper.selectTFeeById(tFee.getfId());
  1250. if (fee.getfMake() == 1) {
  1251. return AjaxResult.error("该申请发票已开销项发票,不能撤销");
  1252. }
  1253. }
  1254. tFee.setUpdateBy(loginUser.getUser().getUserName());
  1255. tFee.setUpdateTime(new Date());
  1256. tFeeMapper.updateTFee(tFee);
  1257. // 删除从表
  1258. tFeeDoMapper.deleteByFPid(tFee.getfId());
  1259. // 财务从表
  1260. if (StringUtils.isNotNull(tfeeDo)) {
  1261. JSONArray jsonDrArray = JSONArray.parseArray(tfeeDo);
  1262. List<TFeeDo> tFeeDoList = JSONObject.parseArray(jsonDrArray.toJSONString(), TFeeDo.class);
  1263. for (TFeeDo tFeeDo : tFeeDoList) {
  1264. tFeeDo.setfPid(tFee.getfId());
  1265. tFeeDo.setCreateBy(loginUser.getUser().getUserName());
  1266. tFeeDo.setCreateTime(new Date());
  1267. tFeeDoMapper.insertTFeeDo(tFeeDo);
  1268. // 跟新费用明细
  1269. int m = updateBillsFees(tFee.getfId(), tFeeDo, fBilltype);
  1270. if (m == 0) {
  1271. TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
  1272. return AjaxResult.error("更新费用明细失败");
  1273. }
  1274. }
  1275. }
  1276. //修改主订单费用信息
  1277. if (fBilltype.equals("DCRevoke")) {
  1278. this.updateMessage(tFee.getfId());
  1279. }
  1280. return AjaxResult.success();
  1281. }
  1282. public void updateMessage(Long fid) {
  1283. List<TFeeDo> list = tFeeDoMapper.selectTFeeDoByfPid(fid);
  1284. if (CollectionUtils.isNotEmpty(list)){
  1285. List<Long> collect = list.stream().map(TFeeDo::getfSrcpid).collect(toList());
  1286. collect.stream().forEach(item ->{
  1287. TWarehouseBills warehouseBills = tWarehouseBillsMapper.selectTWarehousebillsById(item);
  1288. //获取订舱单位
  1289. TCorps tCorps = tCorpsMapper.selectTCorpsById(warehouseBills.getfCorpid());
  1290. //实收费用
  1291. List<TWarehousebillsfees> warehousebillsfees = tWarehousebillsfeesMapper.selectFeesByPId(item, "D");
  1292. //实付费用
  1293. List<TWarehousebillsfees> tWarehousebillsfees = tWarehousebillsfeesMapper.selectFeesByPId(item, "C");
  1294. TWarehouseBills tWarehouseBills = new TWarehouseBills();
  1295. tWarehouseBills.setfId(item);
  1296. tWarehouseBills.setfRecycle(warehousebillsfees.stream().filter(ei->ei.getfStlamount()!=null && ei.getfBillstatus().longValue() == 6L).map(TWarehousebillsfees::getfStlamount).reduce(BigDecimal.ZERO,BigDecimal::add));
  1297. tWarehouseBills.setfPay(tWarehousebillsfees.stream().filter(ei->ei.getfStlamount()!=null && ei.getfBillstatus().longValue() == 6L).map(TWarehousebillsfees::getfStlamount).reduce(BigDecimal.ZERO,BigDecimal::add));
  1298. //如果订舱单位是凯和 应收尾0 也是放货状态
  1299. //1: 未放货 应收>0 应收>实收
  1300. //2:放货 应收>0 应收=实收
  1301. if ((tCorps == null || tCorps.getfCname().equals("青岛凯和志诚物流有限公司")) && !warehouseBills.getfCaregoStatus().equals("3") ){
  1302. tWarehouseBills.setfCaregoStatus("2");
  1303. }else if (warehouseBills.getfReceivable().compareTo(BigDecimal.ZERO) > 0 && warehouseBills.getfReceivable().compareTo(tWarehouseBills.getfRecycle()) > 0){
  1304. tWarehouseBills.setfCaregoStatus("1");
  1305. }else if (warehouseBills.getfReceivable().compareTo(BigDecimal.ZERO) > 0 && warehouseBills.getfReceivable().compareTo(tWarehouseBills.getfRecycle()) <= 0){
  1306. tWarehouseBills.setfCaregoStatus("2");
  1307. }
  1308. tWarehouseBillsMapper.updateTWarehousebills(tWarehouseBills);
  1309. });
  1310. }
  1311. }
  1312. @Override
  1313. public AjaxResult queryRemove(Long fId) {
  1314. TFee tFee = tFeeMapper.selectTFeeById(fId);
  1315. TFeeDo tFeeDo = new TFeeDo();
  1316. tFeeDo.setfPid(tFee.getfId());
  1317. List<TFeeDo> tFeeDoList = tFeeDoMapper.selectTFeeDoList(tFeeDo);
  1318. if (StringUtils.isNull(tFee)) {
  1319. return AjaxResult.success("0");
  1320. } else if (StringUtils.isNotNull(tFee) && StringUtils.isEmpty(tFeeDoList)) {
  1321. return AjaxResult.success("1");
  1322. } else if (tFee.getfBilltype().equals("INV") && tFee.getfAccountId() != null) {
  1323. return AjaxResult.success("3");
  1324. } else {
  1325. return AjaxResult.success("2");
  1326. }
  1327. }
  1328. @Override
  1329. @Transactional
  1330. public AjaxResult remove(Long fId) {
  1331. TFee tFee = tFeeMapper.selectTFeeById(fId);
  1332. if ("4".equals(tFee.getfBillstatus())) {
  1333. return AjaxResult.error("数据已提交审批,暂不能删除");
  1334. } else if ("5".equals(tFee.getfBillstatus())) {
  1335. return AjaxResult.error("数据正在审批,暂不能删除");
  1336. } else if ("6".equals(tFee.getfBillstatus())) {
  1337. return AjaxResult.error("数据审批完成,不能删除");
  1338. } else {
  1339. try {
  1340. tFeeMapper.deleteTFeeById(fId);
  1341. tFeeDoMapper.deleteByFPid(fId);
  1342. tFeeInvoiceMapper.deleteByFPid(fId);
  1343. } catch (Exception e) {
  1344. TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
  1345. return AjaxResult.error("删除失败,请找管理员");
  1346. }
  1347. return AjaxResult.success();
  1348. }
  1349. }
  1350. @Override
  1351. public List<TWareHouseExcelItem> selectTWarehousebillsItemsList(Long fId) {
  1352. List<TWareHouseExcelItem> tWareHouseExcelItemList = tFeeMapper.selectTWarehousebillsItemsList(fId);
  1353. List<TWareHouseExcelItem> tWareHouseExcelItemList1 = new ArrayList<>();
  1354. for (TWareHouseExcelItem tWareHouseExcelItem : tWareHouseExcelItemList) {
  1355. if (StringUtils.isNotNull(tWareHouseExcelItem.getfBusinessType())) {
  1356. List<SysDictData> sysDictDataListIn = new ArrayList<>();
  1357. SysDictData sysDictData = new SysDictData();
  1358. if (tWareHouseExcelItem.getfBilltype().equals("入库")) {
  1359. sysDictData.setDictType(ST_IN_TYPE);
  1360. sysDictData.setDictValue(String.valueOf(tWareHouseExcelItem.getfBusinessType()));
  1361. sysDictData.setStatus("0");
  1362. sysDictDataListIn = iSysDictDataService.selectDictDataList(sysDictData);
  1363. } else if (tWareHouseExcelItem.getfBilltype().equals("出库")) {
  1364. sysDictData.setDictType(ST_OUT_TYPE);
  1365. sysDictData.setDictValue(String.valueOf(tWareHouseExcelItem.getfBusinessType()));
  1366. sysDictData.setStatus("0");
  1367. sysDictDataListIn = iSysDictDataService.selectDictDataList(sysDictData);
  1368. } else if (tWareHouseExcelItem.getfBilltype().equals("调拨") | tWareHouseExcelItem.getfBilltype().equals("货物通关")) {
  1369. sysDictData.setDictType(ST_TRANS_TYPE);
  1370. sysDictData.setDictValue(String.valueOf(tWareHouseExcelItem.getfBusinessType()));
  1371. sysDictData.setStatus("0");
  1372. sysDictDataListIn = iSysDictDataService.selectDictDataList(sysDictData);
  1373. }
  1374. if (null != sysDictDataListIn && sysDictDataListIn.size() > 0) {
  1375. tWareHouseExcelItem.setfBusinessType(sysDictDataListIn.get(0).getDictLabel());
  1376. }
  1377. }
  1378. tWareHouseExcelItemList1.add(tWareHouseExcelItem);
  1379. }
  1380. return tWareHouseExcelItemList1;
  1381. }
  1382. @Override
  1383. public String findCtrlcorpid(Long fId) {
  1384. TFee tFee = tFeeMapper.selectTFeeById(fId);
  1385. String exportName = tFee.getfCtrlcorpid() + "-" + tFee.getfBillno();
  1386. return exportName;
  1387. }
  1388. @Override
  1389. public List<Receivable> receivableExport(TWareHouseFees tWareHouseFees) throws Exception {
  1390. List<Map<String, Object>> list = tFeeMapper.warehouseBillsFeesList1(tWareHouseFees);
  1391. List<Receivable> list1 = ListMapToBeanUtils.castMapToBean(list, Receivable.class);
  1392. return list1;
  1393. }
  1394. @Override
  1395. public List<GeneralLedgerExcel> payableExport(TWareHouseFees tWareHouseFees) throws Exception {
  1396. List<GeneralLedgerExcel> ledgerExcelList = new ArrayList<>();
  1397. List<FeeVO> feeVOList = tFeeMapper.selectFinancialLedgerList(tWareHouseFees);
  1398. feeVOList.forEach(vo -> {
  1399. GeneralLedgerExcel ledgerExcel = new GeneralLedgerExcel();
  1400. ledgerExcel.setFAmount(vo.getFAmount());
  1401. ledgerExcel.setReviewDate(vo.getReviewDate());
  1402. ledgerExcel.setFFeesName(vo.getFFeesName());
  1403. ledgerExcel.setNnfinished(vo.getNnfinished());
  1404. ledgerExcel.setFStlamount(vo.getFStlamount());
  1405. ledgerExcelList.add(ledgerExcel);
  1406. });
  1407. return ledgerExcelList;
  1408. }
  1409. @Override
  1410. public List<Profit> profitExport(TWareHouseFees tWareHouseFees) throws Exception {
  1411. List<Map<String, Object>> list = tFeeMapper.warehouseBillsFeesProfitList(tWareHouseFees);
  1412. return ListMapToBeanUtils.castMapToBean(list, Profit.class);
  1413. }
  1414. @Override
  1415. public List<ProfitGeneralLedgerExcel> profitCustomExport(TWareHouseFees tWareHouseFees) throws Exception {
  1416. List<Map<String, Object>> list = tFeeMapper.warehouseBillsFeesCustomProfitList(tWareHouseFees);
  1417. return ListMapToBeanUtils.castMapToBean(list, ProfitGeneralLedgerExcel.class);
  1418. }
  1419. @Override
  1420. public List<Contrast> contrastExport(TFee tFee) throws Exception {
  1421. List<Map<String, Object>> list = tFeeMapper.selectTFeeList1(tFee);
  1422. List<Contrast> list1 = ListMapToBeanUtils.castMapToBean(list, Contrast.class);
  1423. return list1;
  1424. }
  1425. @Override
  1426. public List<Payment> paymentExport(TFee tFee) throws Exception {
  1427. List<Map<String, Object>> list = tFeeMapper.selectFeeList(tFee);
  1428. return ListMapToBeanUtils.castMapToBean(list, Payment.class);
  1429. }
  1430. @Override
  1431. public List<Charge> chargeExport(TFee tFee) throws Exception {
  1432. List<Map<String, Object>> list = tFeeMapper.selectFeeList(tFee);
  1433. return ListMapToBeanUtils.castMapToBean(list, Charge.class);
  1434. }
  1435. @Override
  1436. public List<Account> accountExport(TFee tFee) throws Exception {
  1437. List<Map<String, Object>> list = tFeeMapper.webVersionTFee(tFee);
  1438. return ListMapToBeanUtils.castMapToBean(list, Account.class);
  1439. }
  1440. @Override
  1441. public List<Detailed> selectDetailedList(Long fId) {
  1442. List<Detailed> detailedList = tFeeMapper.selectDetailedList(fId);
  1443. List<Detailed> detailedList1 = new ArrayList<>();
  1444. for (Detailed tWareHouseExcelItem : detailedList) {
  1445. if (StringUtils.isNotNull(tWareHouseExcelItem.getfBusinessType())) {
  1446. List<SysDictData> sysDictDataListIn = new ArrayList<>();
  1447. SysDictData sysDictData = new SysDictData();
  1448. if (tWareHouseExcelItem.getfBilltype().equals("入库")) {
  1449. sysDictData.setDictType(ST_IN_TYPE);
  1450. sysDictData.setDictValue(String.valueOf(tWareHouseExcelItem.getfBusinessType()));
  1451. sysDictData.setStatus("0");
  1452. sysDictDataListIn = iSysDictDataService.selectDictDataList(sysDictData);
  1453. } else if (tWareHouseExcelItem.getfBilltype().equals("出库")) {
  1454. sysDictData.setDictType(ST_OUT_TYPE);
  1455. sysDictData.setDictValue(String.valueOf(tWareHouseExcelItem.getfBusinessType()));
  1456. sysDictData.setStatus("0");
  1457. sysDictDataListIn = iSysDictDataService.selectDictDataList(sysDictData);
  1458. } else if (tWareHouseExcelItem.getfBilltype().equals("调拨") | tWareHouseExcelItem.getfBilltype().equals("货物通关")) {
  1459. sysDictData.setDictType(ST_TRANS_TYPE);
  1460. sysDictData.setDictValue(String.valueOf(tWareHouseExcelItem.getfBusinessType()));
  1461. sysDictData.setStatus("0");
  1462. sysDictDataListIn = iSysDictDataService.selectDictDataList(sysDictData);
  1463. }
  1464. if (CollectionUtils.isNotEmpty(sysDictDataListIn)) {
  1465. tWareHouseExcelItem.setfBusinessType(sysDictDataListIn.get(0).getDictLabel());
  1466. }
  1467. }
  1468. detailedList1.add(tWareHouseExcelItem);
  1469. }
  1470. return detailedList1;
  1471. }
  1472. @Override
  1473. public List<Map<String, Object>> selectdetailedList(TWarehousebill tWarehousebill) {
  1474. return tFeeMapper.selectDetailedList1(tWarehousebill);
  1475. }
  1476. /**
  1477. * 更新费用明细
  1478. *
  1479. * @param fid
  1480. * @param tFeeDo
  1481. * @param billsType
  1482. * @return
  1483. */
  1484. @Transactional
  1485. public int updateBillsFees(Long fid, TFeeDo tFeeDo, String billsType) {
  1486. // 查询从表数据
  1487. TFee tFee = tFeeMapper.selectTFeeById(fid);
  1488. if (billsType.equals("SF") || billsType.equals("FF")
  1489. || billsType.equals("KHSF") || billsType.equals("KHFF")) {
  1490. billsType = "DC";
  1491. }
  1492. Map<String, Object> map = new HashMap<>();
  1493. map.put("tFee", tFee);
  1494. map.put("billType", billsType);
  1495. map.put("tFeeDo", tFeeDo);
  1496. return tWarehousebillsfeesMapper.updateTWarehousebillsfee(map);
  1497. }
  1498. public boolean change(Long fId) {
  1499. boolean flag = false;
  1500. TFee tFee = tFeeMapper.selectTFeeById(fId);
  1501. if ("4".equals(tFee.getfBillstatus())
  1502. || "5".equals(tFee.getfBillstatus())
  1503. || "6".equals(tFee.getfBillstatus())) {
  1504. flag = false;
  1505. } else {
  1506. flag = true;
  1507. }
  1508. return flag;
  1509. }
  1510. @Override
  1511. @Transactional
  1512. public AjaxResult webVersionSubmitApplyFP(TFee tFee, LoginUser loginUser, String fBilltype) {
  1513. String key = "";
  1514. boolean isApprove = false;
  1515. long actId = 0L;
  1516. String billStatus = "";
  1517. if ("ApplyFP".equals(fBilltype)) {
  1518. actId = 470L;
  1519. key = "warehouse.kaiHeApplyFP.ApprovalFlow";
  1520. }
  1521. SysConfig sysConfig = sysConfigMapper.checkConfigKeyUnique(key);
  1522. if (StringUtils.isNull(sysConfig)) {
  1523. TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
  1524. return AjaxResult.error("系统参数异常,未找到开启审批流参数");
  1525. }
  1526. if ("0".equals(sysConfig.getConfigValue())) {
  1527. isApprove = true;
  1528. }
  1529. if (isApprove) {
  1530. billStatus = "4";
  1531. } else {
  1532. billStatus = "6";
  1533. }
  1534. /*for (Long getfId : tFee.getfIds()) {*/
  1535. TFee fee = tFeeMapper.selectTFeeById(tFee.getfId());
  1536. if (fee == null) {
  1537. return AjaxResult.error("财务主表数据有误,请确认");
  1538. }
  1539. boolean change = this.change(tFee.getfId());
  1540. if (change == false) {
  1541. return AjaxResult.error("数据正在审批或审批通过,不允许提交审核");
  1542. }
  1543. fee.setfId(tFee.getfId());
  1544. fee.setfBillstatus(billStatus);
  1545. fee.setUpdateBy(loginUser.getUser().getUserName());
  1546. fee.setUpdateTime(new Date());
  1547. int updateTFee = tFeeMapper.updateTFee(fee);
  1548. if (updateTFee <= 0) {
  1549. TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
  1550. return AjaxResult.error("更新财务主表数据出错,请找管理员");
  1551. }
  1552. TFeeDo tFeeDo = new TFeeDo();
  1553. tFeeDo.setfPid(tFee.getfId());
  1554. List<TFeeDo> tFeeDos = tFeeDoMapper.selectTFeeDoList(tFeeDo);
  1555. if (CollectionUtils.isEmpty(tFeeDos)) {
  1556. TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
  1557. return AjaxResult.error("财务从表数据有误,请确认");
  1558. }
  1559. for (TFeeDo feeDo : tFeeDos) {
  1560. feeDo.setfId(feeDo.getfId());
  1561. feeDo.setfStatus(billStatus);
  1562. feeDo.setUpdateBy(loginUser.getUser().getUserName());
  1563. feeDo.setUpdateTime(new Date());
  1564. int i = tFeeDoMapper.updateTFeeDo(feeDo);
  1565. if (i <= 0) {
  1566. TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
  1567. return AjaxResult.error("更新财务主表数据出错,请找管理员");
  1568. }
  1569. }
  1570. TFeeInvoice tFeeInvoice = new TFeeInvoice();
  1571. tFeeInvoice.setfPid(tFee.getfId());
  1572. List<TFeeInvoice> tFeeInvoiceList = tFeeInvoiceMapper.selectTFeeInvoiceList(tFeeInvoice);
  1573. if (CollectionUtils.isNotEmpty(tFeeInvoiceList)) {
  1574. for (TFeeInvoice invoice : tFeeInvoiceList) {
  1575. tFeeInvoice.setfBillstatus(billStatus);
  1576. tFeeInvoice.setfId(invoice.getfId());
  1577. tFeeInvoice.setUpdateBy(loginUser.getUser().getUserName());
  1578. tFeeInvoice.setUpdateTime(new Date());
  1579. tFeeInvoiceMapper.updateTFeeInvoice(tFeeInvoice);
  1580. }
  1581. }
  1582. //添加审批流
  1583. if (isApprove) {
  1584. AuditItems auditItems = new AuditItems();
  1585. auditItems.setLevelId(0L);
  1586. auditItems.setBillId(fee.getfId());
  1587. auditItems.setActId(actId);
  1588. auditItems.setIffinalItem("F");
  1589. auditItems.setBillNo(fee.getfBillno()); // 业务编号
  1590. auditItems.setRefno1(String.valueOf(fee.getfCorpid())); // 货权方
  1591. auditItems.setRefno2(fee.getfBilltype());// 财务类型
  1592. auditItems.setRefno3(fee.gettMblno());// 提单号
  1593. auditItems.setSendUserId(loginUser.getUser().getUserId());
  1594. auditItems.setSendName(loginUser.getUsername());
  1595. auditItems.setSendTime(new Date());
  1596. auditItems.setAuditUserId(loginUser.getUser().getUserId());
  1597. auditItems.setAuditItem(new Date());
  1598. auditItems.setAuditOpTime(new Date());
  1599. auditItems.setFidStatus("f_billstatus");
  1600. auditItems.setTimes(1L);
  1601. auditItems.setAuditMsg("提交");
  1602. auditItems.setAuditStatus("O");
  1603. AjaxResult approvalFlow = auditItemsService.createApprovalFlow(auditItems);
  1604. Long code = Long.valueOf(String.valueOf(approvalFlow.get("code"))).longValue();
  1605. if (code.equals(500L)) {
  1606. TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
  1607. return AjaxResult.error("提交审核失败,请找管理员");
  1608. }
  1609. return approvalFlow;
  1610. } else {
  1611. for (TFeeDo t : tFeeDos) {
  1612. // 跟新费用明细
  1613. int m = updateBillsFees(tFee.getfId(), t, fBilltype);
  1614. if (m == 0) {
  1615. TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
  1616. return AjaxResult.error("更新费用明细失败");
  1617. }
  1618. }
  1619. AjaxResult ajaxResult = tfeeFollow(tFee.getfId(), 6L);
  1620. Long code = Long.valueOf(String.valueOf(ajaxResult.get("code"))).longValue();
  1621. if (code.equals(500L)) {
  1622. TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
  1623. return AjaxResult.error("提交审核失败,请找管理员");
  1624. }
  1625. return ajaxResult;
  1626. }
  1627. /*}*/
  1628. //return AjaxResult.success();
  1629. }
  1630. @Override
  1631. public AjaxResult webVersionUpdateApplyFP(TFee tFee, LoginUser loginUser, String billType) {
  1632. TFeeInvoice tFeeInvoice = tFee.gettFeeInvoice();
  1633. tFeeInvoice.setfPid(tFee.getfId());
  1634. int i = 0;
  1635. if (tFeeInvoice.getfId() != null) {
  1636. tFeeInvoice.setUpdateBy(loginUser.getUser().getUserName());
  1637. tFeeInvoice.setUpdateTime(new Date());
  1638. i = tFeeInvoiceMapper.updateTFeeInvoice(tFeeInvoice);
  1639. } else {
  1640. return AjaxResult.error("开票信息为空,请找管理员");
  1641. }
  1642. if (i <= 0) {
  1643. return AjaxResult.error("更新数据失败,请找管理员");
  1644. } else {
  1645. return AjaxResult.success();
  1646. }
  1647. }
  1648. @Override
  1649. public List<FinancialTFee> selectFinancialTFeeList(TFee tFee) {
  1650. return tFeeMapper.selectFinancialTFeeList(tFee);
  1651. }
  1652. @Override
  1653. public List<Map<String, Object>> FinancialFeesList(TWareHouseFees tWareHouseFees) {
  1654. Map<String, Object> map = new HashMap<>();
  1655. map.put("tWareHouseFees", tWareHouseFees);
  1656. return tFeeMapper.FinancialFeesList(map);
  1657. }
  1658. @Override
  1659. public Map<String, Object> selectFinancialTFeeId(Long fId) {
  1660. Map<String, Object> map = new HashMap<>();
  1661. FinancialTFee financialTFee = tFeeMapper.selectFinancialTFeeId(fId);
  1662. List<FinancialTFeeDoExcel> financialTFeeDoExcels = tFeeDoMapper.selectFinancialTFeeDo(fId);
  1663. map.put("tFee", financialTFee);
  1664. map.put("tFeeDo", financialTFeeDoExcels);
  1665. return map;
  1666. }
  1667. @Override
  1668. public List<FinancialTFeeDoExcel> FinancialTFeeDoExcel(Long fId) {
  1669. return tFeeDoMapper.selectFinancialTFeeDo(fId);
  1670. }
  1671. @Override
  1672. @Transactional
  1673. public AjaxResult webVersionApplyFP(TFee tFee, LoginUser loginUser, String fBilltype, TFeeInvoice tFeeInvoice) {
  1674. Long fPid = null;
  1675. String billStatus = "2";
  1676. try {
  1677. /*for (Long getfId : tFee.getfIds()) {*/
  1678. TFee account = new TFee();
  1679. TFee fee = tFeeMapper.selectTFeeById(tFee.getfId());
  1680. if (fee == null) {
  1681. return AjaxResult.error("财务主表数据有误,请确认");
  1682. }
  1683. account.setfId(fee.getfId());
  1684. account.setfMake(1);
  1685. fee.setfBilltype(fBilltype);
  1686. fee.setfBillstatus(billStatus);
  1687. fee.setCreateBy(loginUser.getUser().getUserName());
  1688. fee.setCreateTime(new Date());
  1689. fee.setfDeptid(loginUser.getUser().getDeptId());
  1690. fee.setUpdateBy(null);
  1691. fee.setUpdateTime(null);
  1692. fee.setfInvoiceRise(tFee.getfInvoiceRise());
  1693. fee.setfAccountId(fee.getfId());
  1694. Date time = new Date();
  1695. String billNo = billnoSerialServiceImpl.getBillNo(fBilltype, time);
  1696. fee.setfBillno(billNo);
  1697. fee.setfAccbilldate(null);
  1698. fee.setfId(null);
  1699. tFeeMapper.insertTFee(fee);
  1700. tFeeMapper.updateTFee(account);
  1701. //修改原来的数据的开票金额
  1702. fPid = fee.getfId();
  1703. TFeeDo tFeeDo = new TFeeDo();
  1704. tFeeDo.setfPid(tFee.getfId());
  1705. List<TFeeDo> tFeeDos = tFeeDoMapper.selectTFeeDoList(tFeeDo);
  1706. if (CollectionUtils.isEmpty(tFeeDos)) {
  1707. TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
  1708. return AjaxResult.error("财务从表数据有误,请确认");
  1709. }
  1710. for (TFeeDo feeDo : tFeeDos) {
  1711. feeDo.setfPid(fPid);
  1712. feeDo.setfStatus(billStatus);
  1713. feeDo.setCreateBy(loginUser.getUser().getUserName());
  1714. feeDo.setCreateTime(new Date());
  1715. feeDo.setUpdateBy(null);
  1716. feeDo.setUpdateTime(null);
  1717. int i = tFeeDoMapper.insertTFeeDo(feeDo);
  1718. }
  1719. tFeeInvoice.setfBillstatus(billStatus);
  1720. tFeeInvoice.setfPid(fPid);
  1721. tFeeInvoice.setCreateBy(loginUser.getUser().getUserName());
  1722. tFeeInvoice.setCreateTime(new Date());
  1723. tFeeInvoiceMapper.insertTFeeInvoice(tFeeInvoice);
  1724. /*}*/
  1725. } catch (Exception e) {
  1726. TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
  1727. return AjaxResult.error("申请发票出错,请找管理员");
  1728. }
  1729. return AjaxResult.success();
  1730. }
  1731. /**
  1732. * 判断金额是否超过可用金额
  1733. *
  1734. * @param fid 费用明细表主键
  1735. * @param money 申请金额
  1736. * @param type DZ 对账 SF 收费 FF 付费 ApplyFP 开票申请 invoiceFP 开票
  1737. * @return
  1738. */
  1739. public Map<String, Object> judgeMoney(long fid, BigDecimal money, String type, Long feeId) {
  1740. Map<String, Object> map = new HashMap<>();
  1741. boolean flag = true;
  1742. TWarehousebillsfees warehousebillsfees = tWarehousebillsfeesMapper.selectTWarehousebillsfeesById(fid);
  1743. TFees tFees = tFeesMapper.selectTFeesById(feeId);
  1744. BigDecimal amount = warehousebillsfees.getfAmount();//金额
  1745. BigDecimal accamount = warehousebillsfees.getfAccamount();//对账金额
  1746. BigDecimal stlamount = warehousebillsfees.getfStlamount();//结算金额
  1747. BigDecimal invamount = warehousebillsfees.getfInvamount();//开票金额a
  1748. BigDecimal askamount = warehousebillsfees.getfAskamount();//申请金额
  1749. if (warehousebillsfees == null) {
  1750. map.put("message", "费用明细数据有误,请找管理员");
  1751. } else if ("DZ".equals(type) || "KHDZ".equals(type)) {
  1752. BigDecimal subtract = amount.subtract(accamount);
  1753. if (subtract.compareTo(money) < 0) {
  1754. flag = false;
  1755. map.put("message", tFees.getfName() + "对账金额超过可对账金额,当前可对账金额为" + subtract + "元");
  1756. }
  1757. } else if ("SF".equals(type) || "KHSF".equals(type)) {
  1758. BigDecimal subtract = amount.subtract(stlamount);
  1759. if (subtract.compareTo(money) < 0) {
  1760. flag = false;
  1761. map.put("message", tFees.getfName() + "收费金额超过可收费金额,当前可对账金额为" + subtract + "元");
  1762. }
  1763. } else if ("FF".equals(type) || "KHFF".equals(type)) {
  1764. BigDecimal subtract = amount.subtract(stlamount);
  1765. if (subtract.compareTo(money) < 0) {
  1766. flag = false;
  1767. map.put("message", tFees.getfName() + "付费金额超过可付费金额,当前可对账金额为" + subtract + "元");
  1768. }
  1769. } else if ("ApplyFP".equals(type)) {
  1770. BigDecimal subtract = amount.subtract(askamount);
  1771. if (subtract.compareTo(money) < 0) {
  1772. flag = false;
  1773. map.put("message", tFees.getfName() + "开票金额超过可开票金额,当前可对账金额为" + subtract + "元");
  1774. }
  1775. } else if ("invoiceFP".equals(type)) {
  1776. BigDecimal subtract = amount.subtract(invamount);
  1777. if (subtract.compareTo(money) < 0) {
  1778. flag = false;
  1779. map.put("message", tFees.getfName() + "开票金额超过可开票金额,当前可对账金额为" + subtract + "元");
  1780. }
  1781. }
  1782. map.put("flag", flag);
  1783. return map;
  1784. }
  1785. /**
  1786. * 申请发票审核成功复制数据到销项发票中
  1787. *
  1788. * @param fId 主表id
  1789. * @param fBilltype 类型
  1790. * @return
  1791. */
  1792. @Transactional
  1793. public AjaxResult copyInvoiceFp(Long fId, String fBilltype) {
  1794. //查询费用主表信息复制主表信息
  1795. Integer insert = null;
  1796. TFee fee = tFeeMapper.selectTFeeById(fId);
  1797. TFee tFee = new TFee();
  1798. tFee.setfId(fee.getfId());
  1799. Date time = new Date();
  1800. String billNo = billnoSerialServiceImpl.getBillNo(fBilltype, time);
  1801. //查询费用从表信息复制主表信息
  1802. fee.setfAccountId(fee.getfId());
  1803. fee.setfBillno(billNo);
  1804. fee.setfBilltype(fBilltype);
  1805. fee.setfId(null);
  1806. insert = tFeeMapper.insertTFee(fee);
  1807. tFee.setfMake(1);
  1808. //修改原发票数据代表已开销项发票
  1809. insert = tFeeMapper.updateTFee(tFee);
  1810. TFeeDo tFeeDo = new TFeeDo();
  1811. tFeeDo.setfPid(fId);
  1812. List<TFeeDo> tFeeDoList = tFeeDoMapper.selectTFeeDoList(tFeeDo);
  1813. if (CollectionUtils.isNotEmpty(tFeeDoList)) {
  1814. for (TFeeDo feeDo : tFeeDoList) {
  1815. feeDo.setfId(null);
  1816. feeDo.setfPid(fee.getfId());
  1817. feeDo.setfBilltype(fBilltype);
  1818. insert = tFeeDoMapper.insertTFeeDo(feeDo);
  1819. }
  1820. }
  1821. //查询开票信息复制主表信息
  1822. TFeeInvoice tFeeInvoice = new TFeeInvoice();
  1823. tFeeInvoice.setfPid(fId);
  1824. List<TFeeInvoice> tFeeInvoiceList = tFeeInvoiceMapper.selectTFeeInvoiceList(tFeeInvoice);
  1825. if (CollectionUtils.isNotEmpty(tFeeInvoiceList)) {
  1826. for (TFeeInvoice invoice : tFeeInvoiceList) {
  1827. invoice.setfId(null);
  1828. invoice.setfPid(fee.getfId());
  1829. insert = tFeeInvoiceMapper.insertTFeeInvoice(invoice);
  1830. }
  1831. }
  1832. if (insert != null && insert > 0) {
  1833. return AjaxResult.success();
  1834. } else {
  1835. return AjaxResult.error("生成销项发票失败,请找管理员");
  1836. }
  1837. }
  1838. /**
  1839. * 导出财务对账数据
  1840. *
  1841. * @param fId
  1842. * @return
  1843. */
  1844. @Override
  1845. public AjaxResult exportFinancial(Long fId) {
  1846. //获取数据
  1847. String shipsName = "";//船名
  1848. String voyage = "";//航次
  1849. String corpName = "";//客户
  1850. String fFromDate = "";//离港日期开始
  1851. String fToDate = "";//离港日期结束
  1852. BigDecimal fAmount = new BigDecimal(0);//合计
  1853. //查询财务主数据
  1854. SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
  1855. TFee fee = tFeeMapper.selectTFeeById(fId);
  1856. if (fee != null) {
  1857. corpName = fee.getfCtrlcorpid();
  1858. if (fee.getfFromDate() != null) {
  1859. fFromDate = simpleDateFormat.format(fee.getfFromDate());
  1860. }
  1861. if (fee.getfToDate() != null) {
  1862. fToDate = simpleDateFormat.format(fee.getfToDate());
  1863. }
  1864. if (fee.getfVslid() != null) {
  1865. TVessel vessel = tVesselMapper.selectTVesselById(fee.getfVslid());
  1866. if (vessel != null && StringUtils.isNotEmpty(vessel.getfName())) {
  1867. shipsName = vessel.getfName();
  1868. }
  1869. }
  1870. if (fee.getfVoyid() != null) {
  1871. TVoyage tVoyage = tVoyageMapper.selectTVoyageById(fee.getfVoyid());
  1872. if (tVoyage != null && StringUtils.isNotEmpty(tVoyage.getfNo())) {
  1873. voyage = tVoyage.getfNo();
  1874. }
  1875. }
  1876. }
  1877. //样式设置
  1878. //1.创建一个workbook,对应一个excel文件
  1879. HSSFWorkbook wb = new HSSFWorkbook();
  1880. //2.在workbook中添加一个sheet,对应Excel中的sheet
  1881. HSSFSheet sheet = wb.createSheet("对账");
  1882. //设置每一列的列宽
  1883. sheet.setColumnWidth(0, 256 * 15);
  1884. sheet.setColumnWidth(1, 256 * 20);
  1885. sheet.setColumnWidth(2, 256 * 20);
  1886. sheet.setColumnWidth(3, 256 * 20);
  1887. sheet.setColumnWidth(4, 256 * 15);
  1888. sheet.setColumnWidth(5, 256 * 15);
  1889. sheet.setColumnWidth(6, 256 * 15);
  1890. sheet.setColumnWidth(7, 100 * 35);
  1891. sheet.setColumnWidth(8, 256 * 15);
  1892. sheet.setColumnWidth(9, 256 * 15);
  1893. //3.设置样式以及字体样式
  1894. HSSFCellStyle titleStyle = ExcelUtils.createTitleCellStyle(wb);
  1895. HSSFCellStyle contentStyle = ExcelUtils.createContentCellStyle(wb);
  1896. HSSFCellStyle subheadingStyle = ExcelUtils.createSubheadingStyle(wb);
  1897. HSSFCellStyle endStyle = ExcelUtils.createEndStyle(wb);
  1898. //4.创建标题,合并标题单元格
  1899. //行号
  1900. int rowNum = 0;
  1901. //创建第一行,索引从0开始(标题行)
  1902. HSSFRow row0 = sheet.createRow(rowNum++);
  1903. row0.setHeight((short) 800);// 设置行高
  1904. for (int i = 0; i < 10; i++) {
  1905. HSSFCell tempCell = row0.createCell(i);
  1906. tempCell.setCellStyle(contentStyle);
  1907. }
  1908. String title = "青岛凯和志诚物流有限公司";
  1909. HSSFCell c00 = row0.createCell(0);
  1910. c00.setCellValue(title);
  1911. c00.setCellStyle(titleStyle);
  1912. // 合并单元格,参数依次为起始行,结束行,起始列,结束列 (索引0开始)
  1913. sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, 9));//标题合并单元格操作,总列数为9
  1914. //第2行
  1915. HSSFRow row1 = sheet.createRow(rowNum++);
  1916. row1.setHeight((short) 500);
  1917. String message1 = "客户确认单";
  1918. for (int i = 0; i < 10; i++) {
  1919. HSSFCell tempCell = row1.createCell(i);
  1920. tempCell.setCellStyle(contentStyle);
  1921. }
  1922. HSSFCell c01 = row1.createCell(0);
  1923. c01.setCellValue(message1);
  1924. c01.setCellStyle(subheadingStyle);
  1925. sheet.addMergedRegion(new CellRangeAddress(1, 1, 0, 9));//标题合并单元格操作,总列数为9
  1926. //第3行
  1927. HSSFRow row2 = sheet.createRow(rowNum++);
  1928. row2.setHeight((short) 500);
  1929. String message2 = "尊敬的客户";
  1930. HSSFCell c02 = row2.createCell(0);
  1931. c02.setCellValue(message2);
  1932. c02.setCellStyle(contentStyle);
  1933. //第3行
  1934. for (int i = 1; i < 10; i++) {
  1935. HSSFCell tempCell = row2.createCell(i);
  1936. tempCell.setCellStyle(contentStyle);
  1937. }
  1938. HSSFCell c03 = row2.createCell(1);
  1939. c03.setCellValue(corpName);
  1940. c03.setCellStyle(contentStyle);
  1941. sheet.addMergedRegion(new CellRangeAddress(2, 2, 1, 9));//标题合并单元格操作,总列数为9
  1942. //合并单元格
  1943. sheet.addMergedRegion(new CellRangeAddress(3, 3, 1, 2));
  1944. sheet.addMergedRegion(new CellRangeAddress(3, 3, 3, 4));
  1945. sheet.addMergedRegion(new CellRangeAddress(3, 3, 5, 9));
  1946. //第4行
  1947. HSSFRow row3 = sheet.createRow(rowNum++);
  1948. for (int i = 0; i < 1; i++) {
  1949. HSSFCell tempCell = row3.createCell(i);
  1950. tempCell.setCellStyle(contentStyle);
  1951. }
  1952. for (int i = 1; i < 3; i++) {
  1953. HSSFCell tempCell = row3.createCell(i);
  1954. tempCell.setCellStyle(contentStyle);
  1955. }
  1956. for (int i = 3; i < 5; i++) {
  1957. HSSFCell tempCell = row3.createCell(i);
  1958. tempCell.setCellStyle(contentStyle);
  1959. }
  1960. for (int i = 5; i < 10; i++) {
  1961. HSSFCell tempCell = row3.createCell(i);
  1962. tempCell.setCellStyle(contentStyle);
  1963. }
  1964. row3.setHeight((short) 500);
  1965. HSSFCell c05 = row3.createCell(0);
  1966. c05.setCellValue("船名航次:");
  1967. c05.setCellStyle(contentStyle);
  1968. HSSFCell c051 = row3.createCell(1);
  1969. c051.setCellValue(shipsName + voyage);
  1970. c051.setCellStyle(contentStyle);
  1971. HSSFCell c052 = row3.createCell(3);
  1972. c052.setCellValue("离港日期:");
  1973. c052.setCellStyle(contentStyle);
  1974. String message = "";
  1975. HSSFCell c053 = row3.createCell(5);
  1976. if (StringUtils.isNotEmpty(fFromDate)) {
  1977. if (StringUtils.isNotEmpty(fFromDate)) {
  1978. message = fFromDate + "-" + fToDate;
  1979. } else {
  1980. message = fFromDate;
  1981. }
  1982. } else if (StringUtils.isNotEmpty(fToDate)) {
  1983. message = fToDate;
  1984. }
  1985. c053.setCellValue(message);
  1986. c053.setCellStyle(contentStyle);
  1987. //第5行
  1988. HSSFRow row4 = sheet.createRow(rowNum++);
  1989. for (int i = 0; i < 10; i++) {
  1990. HSSFCell tempCell = row4.createCell(i);
  1991. tempCell.setCellStyle(contentStyle);
  1992. }
  1993. row4.setHeight((short) 500);
  1994. String message4 = "费用明细";
  1995. HSSFCell c04 = row4.createCell(0);
  1996. c04.setCellValue(message4);
  1997. c04.setCellStyle(contentStyle);
  1998. sheet.addMergedRegion(new CellRangeAddress(4, 4, 0, 9));//标题合并单元格操作,总列数为9
  1999. //第四行
  2000. HSSFRow row5 = sheet.createRow(rowNum++);
  2001. row5.setHeight((short) 500);
  2002. String[] row_third = {"序号", "提单号", "始发港", "目的港", "运输条款", "货名", "箱量", "规格", "单价", "合计"};
  2003. for (int i = 0; i < row_third.length; i++) {
  2004. HSSFCell tempCell = row5.createCell(i);
  2005. tempCell.setCellValue(row_third[i]);
  2006. tempCell.setCellStyle(contentStyle);
  2007. }
  2008. //查询费用明细数据
  2009. List<ExportFinancial> list = tFeeMapper.exportFinancial(fId);
  2010. if (CollectionUtils.isNotEmpty(list)) {
  2011. for (int i = 0; i < list.size(); i++) {
  2012. HSSFRow tempRow = sheet.createRow(rowNum++);
  2013. tempRow.setHeight((short) 500);
  2014. //循环单元格填入数据
  2015. for (int j = 0; j < 10; j++) {
  2016. HSSFCell tempCell = tempRow.createCell(j);
  2017. tempCell.setCellStyle(contentStyle);
  2018. String cellValue = "";
  2019. if (j == 0) {
  2020. //序号
  2021. cellValue = list.get(i).getRankNo().toString();
  2022. } else if (j == 1) {
  2023. //提单号
  2024. cellValue = list.get(i).getfMblNo();
  2025. } else if (j == 2) {
  2026. //始发港
  2027. cellValue = list.get(i).getPortOfDeparture();
  2028. } else if (j == 3) {
  2029. //目的港
  2030. cellValue = list.get(i).getDestinationPort();
  2031. } else if (j == 4) {
  2032. //运输条款
  2033. cellValue = list.get(i).getfServiceitems()+"-"+list.get(i).getfServiceitemsNew();
  2034. } else if (j == 5) {
  2035. //货名
  2036. cellValue = list.get(i).getGoodName();
  2037. } else if (j == 6) {
  2038. //箱量
  2039. cellValue = list.get(i).getfCnTrCount().toString();
  2040. } else if (j == 7) {
  2041. //规格
  2042. cellValue = list.get(i).getSpecification();
  2043. } else if (j == 8) {
  2044. //单价
  2045. cellValue = list.get(i).getfUnitPrice().toString();
  2046. } else if (j == 9) {
  2047. //合计
  2048. cellValue = list.get(i).getfAmount().toString();
  2049. }
  2050. tempCell.setCellValue(cellValue);
  2051. }
  2052. }
  2053. fAmount = list.stream().map(ExportFinancial::getfAmount).reduce(BigDecimal.ZERO, BigDecimal::add);//求所有和的合计
  2054. }
  2055. //倒数第二行
  2056. HSSFRow row6 = sheet.createRow(rowNum++);
  2057. for (int i = 0; i < 10; i++) {
  2058. HSSFCell tempCell = row6.createCell(i);
  2059. tempCell.setCellStyle(contentStyle);
  2060. }
  2061. row6.setHeight((short) 500);
  2062. String message6 = "合计:";
  2063. HSSFCell c06 = row6.createCell(0);
  2064. c06.setCellValue(message6);
  2065. c06.setCellStyle(contentStyle);
  2066. HSSFCell c061 = row6.createCell(9);
  2067. c061.setCellValue(fAmount.toString());
  2068. c061.setCellStyle(contentStyle);
  2069. //最后一行
  2070. HSSFRow row7 = sheet.createRow(rowNum++);
  2071. for (int i = 0; i < 10; i++) {
  2072. HSSFCell tempCell = row7.createCell(i);
  2073. tempCell.setCellStyle(contentStyle);
  2074. }
  2075. row7.setHeight((short) 1500);
  2076. String message7 = "纳税人识别号:91370202MA3UG1T04A\n" +
  2077. "人民币账号:3803020309100171855\n" +
  2078. "人民币开户行:工商银行青岛分行营业部";
  2079. HSSFCell c07 = row7.createCell(0);
  2080. c07.setCellValue(message7);
  2081. c07.setCellStyle(endStyle);
  2082. sheet.addMergedRegion(new CellRangeAddress(rowNum - 1, rowNum - 1, 0, 9));//标题合并单元格操作,总列数为9
  2083. //导出excel
  2084. String fileName = "客户对账单.xls";
  2085. try {
  2086. OutputStream out = null;
  2087. out = new FileOutputStream(getAbsoluteFile(fileName));
  2088. wb.write(out);
  2089. if (null != wb && null != out) {
  2090. wb.write(out);
  2091. wb.close();
  2092. out.close();
  2093. }
  2094. return AjaxResult.success(fileName);
  2095. } catch (Exception e) {
  2096. e.printStackTrace();
  2097. return AjaxResult.error("导出Excel失败");
  2098. }
  2099. }
  2100. /**
  2101. * 根据结算单位、费用状态、审核日期查询应付总帐明细
  2102. *
  2103. * @param feeDTO
  2104. * @return
  2105. */
  2106. @Override
  2107. public AjaxResult financialLedgerDetails(FeeDTO feeDTO) {
  2108. TFees ccf = tFeesMapper.seletFeesByCCF();
  2109. if (Objects.isNull(ccf)) {
  2110. throw new WarehouseException("未找到仓储费费用信息");
  2111. }
  2112. feeDTO.setFeesId(ccf.getfId());
  2113. List<FeeVO> feeVOList = tFeeMapper.selectFinancialLedgerDetails(feeDTO);
  2114. if (CollectionUtils.isNotEmpty(feeVOList)) {
  2115. List<FeeVO> voList = new ArrayList<>();
  2116. Map<Long, List<FeeVO>> map = feeVOList.stream().collect(Collectors.groupingBy(FeeVO::getFSrcpid));
  2117. map.forEach((key, value) -> {
  2118. FeeVO vo = new FeeVO();
  2119. FeeVO feeVO = value.stream().findFirst().orElseThrow(() ->
  2120. new WarehouseException("获取费用异常"));
  2121. BeanUtils.copyProperties(feeVO, vo);
  2122. // 仓储费
  2123. BigDecimal storageFee = value.stream().map(FeeVO::getStorageFee).reduce(BigDecimal::add).orElse(BigDecimal.ZERO);
  2124. // 其他费用
  2125. BigDecimal otherFee = value.stream().map(FeeVO::getOtherFee).reduce(BigDecimal::add).orElse(BigDecimal.ZERO);
  2126. // 应收费用
  2127. BigDecimal amount = value.stream().map(FeeVO::getFAmount).reduce(BigDecimal::add).orElse(BigDecimal.ZERO);
  2128. // 已收费用
  2129. BigDecimal stlamount = value.stream().map(FeeVO::getFStlamount).reduce(BigDecimal::add).orElse(BigDecimal.ZERO);
  2130. WarehouseTypeEnum storageType = WarehouseTypeEnum.fromTypeAndBusinessType(vo.getfBilltype(), "storageType");
  2131. vo.setfBilltype(storageType.getName());
  2132. vo.setStorageFee(storageFee);
  2133. vo.setFStlamount(stlamount);
  2134. vo.setOtherFee(otherFee);
  2135. vo.setFAmount(amount);
  2136. vo.setNnfinished(amount.subtract(stlamount));
  2137. voList.add(vo);
  2138. });
  2139. return AjaxResult.success(voList);
  2140. }
  2141. return AjaxResult.success(feeVOList);
  2142. }
  2143. /**
  2144. * 查询应付总帐明细
  2145. *
  2146. * @param feeDTO
  2147. * @return
  2148. */
  2149. @Override
  2150. public List<GeneralLedgerDetailExcel> financialLedgerDetailsExport(FeeDTO feeDTO) {
  2151. List<GeneralLedgerDetailExcel> detailExcelList = new ArrayList<>();
  2152. List<FeeVO> feeVOList = tFeeMapper.selectFinancialLedgerDetails(feeDTO);
  2153. feeVOList.forEach(vo -> {
  2154. GeneralLedgerDetailExcel detailExcel = new GeneralLedgerDetailExcel();
  2155. WarehouseTypeEnum storageType = WarehouseTypeEnum.fromTypeAndBusinessType(vo.getfBilltype(), "storageType");
  2156. detailExcel.setFMblno(vo.getFMblno());
  2157. detailExcel.setFMarks(vo.getFMarks());
  2158. detailExcel.setFAmount(vo.getFAmount());
  2159. detailExcel.setOtherFee(vo.getOtherFee());
  2160. detailExcel.setFFeesName(vo.getFFeesName());
  2161. detailExcel.setNnfinished(vo.getNnfinished());
  2162. detailExcel.setFStlamount(vo.getFStlamount());
  2163. detailExcel.setStorageFee(vo.getStorageFee());
  2164. detailExcel.setFBilltype(storageType.getName());
  2165. detailExcel.setFProductName(vo.getFProductName());
  2166. detailExcel.setFProductName(vo.getFProductName());
  2167. detailExcelList.add(detailExcel);
  2168. });
  2169. return detailExcelList;
  2170. }
  2171. @Override
  2172. public List<ReceivableExcel> receivable(TWareHouseFees tWareHouseFees) {
  2173. return tFeeMapper.receivable(tWareHouseFees);
  2174. }
  2175. @Override
  2176. public List<ProfitExcel> profit(TWareHouseFees tWareHouseFees) {
  2177. return tFeeMapper.profit(tWareHouseFees);
  2178. }
  2179. @Override
  2180. public List<HandleExcel> handle(TWareHouseFees tWareHouseFees) {
  2181. return tFeeMapper.handle(tWareHouseFees);
  2182. }
  2183. //下载路径
  2184. private String getAbsoluteFile(String fileName) {
  2185. String downloadPath = RuoYiConfig.getDownloadPath() + fileName;
  2186. File desc = new File(downloadPath);
  2187. if (!desc.getParentFile().exists()) {
  2188. desc.getParentFile().mkdirs();
  2189. }
  2190. return downloadPath;
  2191. }
  2192. }