TFeeServiceImpl.java 100 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278
  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. String billstatus = "";
  748. if (isApprove) {
  749. billstatus = "4";
  750. } else {
  751. billstatus = "6";
  752. }
  753. if (StringUtils.isNull(tFee.getfId())) {
  754. // 如果是新数据
  755. tFee.setCreateBy(loginUser.getUser().getUserName());
  756. tFee.setfDeptid(loginUser.getUser().getDeptId());
  757. tFee.setfBilltype(fBilltype);
  758. tFee.setfBillstatus(billstatus);
  759. // 业务编码
  760. Date time = new Date();
  761. String billNo = billnoSerialServiceImpl.getBillNo(fBilltype, time);
  762. tFee.setfBillno(billNo);
  763. tFeeMapper.insertTFee(tFee);
  764. } else {
  765. tFee.setUpdateBy(loginUser.getUser().getUserName());
  766. tFee.setUpdateTime(new Date());
  767. tFee.setfBillstatus(billstatus);
  768. tFeeMapper.updateTFee(tFee);
  769. }
  770. // 删除从表
  771. tFeeDoMapper.deleteByFPid(tFee.getfId());
  772. messageMap.put("tFee", tFee);
  773. // 声明业务编号 list
  774. List<String> fSrcBillnos = new ArrayList<>();
  775. // 财务从表
  776. if (StringUtils.isNotNull(tfeeDo) && !"[]".equals(tfeeDo)) {
  777. JSONArray jsonDrArray = JSONArray.parseArray(tfeeDo);
  778. List<TFeeDo> tFeeDoList = JSONObject.parseArray(jsonDrArray.toJSONString(), TFeeDo.class);
  779. for (TFeeDo tFeeDo : tFeeDoList) {
  780. Map<String, Object> map = this.judgeMoney(tFeeDo.getfSrcid(), tFeeDo.getfAmt(), fBilltype, tFeeDo.getfFeeid());
  781. if (!(Boolean) map.get("flag")) {
  782. TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
  783. return AjaxResult.error(map.get("message").toString());
  784. }
  785. tFeeDo.setfPid(tFee.getfId());
  786. tFeeDo.setCreateBy(loginUser.getUser().getUserName());
  787. tFeeDo.setCreateTime(new Date());
  788. tFeeDo.setfStatus(billstatus);
  789. tFeeDoMapper.insertTFeeDo(tFeeDo);
  790. if (StringUtils.isNotNull(tFeeDo.getfSrcBillno())) { // 判断是否有来源单据编号(业务编号)
  791. // 装载业务编号传递
  792. fSrcBillnos.add(tFeeDo.getfSrcBillno());
  793. }
  794. }
  795. }
  796. // 点击对账、收费、付费提交审核时去掉费用
  797. if (actId >= 210L && actId <= 230L) {
  798. AjaxResult ajaxResult = this.billsfeesFollow(tFee.getfId());
  799. String code = ajaxResult.get("code").toString();
  800. if ("500".equals(code)) {
  801. TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
  802. return ajaxResult;
  803. }
  804. }
  805. //凯和收费提交审核时去掉钱
  806. if (actId >= 430 && actId <= 450){
  807. AjaxResult ajaxResult = this.billsfeesFollow(tFee.getfId());
  808. String code = ajaxResult.get("code").toString();
  809. if ("500".equals(code)) {
  810. TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
  811. return ajaxResult;
  812. }
  813. }
  814. // 这里加个判断取系统参数来确定是否需要启用审批流
  815. if (isApprove) {
  816. AuditItems auditItems = new AuditItems();
  817. auditItems.setLevelId(0L);
  818. auditItems.setBillId(tFee.getfId());
  819. auditItems.setActId(actId);
  820. auditItems.setIffinalItem("F");
  821. auditItems.setBillNo(tFee.getfBillno()); // 业务编号
  822. auditItems.setRefno1(String.valueOf(tFee.getfCorpid())); // 货权方
  823. auditItems.setRefno2(fBilltype);// 财务类型
  824. auditItems.setRefno3(tFee.gettMblno());// 提单号
  825. auditItems.setSendUserId(loginUser.getUser().getUserId()); // 请核人 ID
  826. auditItems.setSendName(loginUser.getUsername()); // 请核人名称
  827. auditItems.setSendTime(new Date()); // 请核时间
  828. auditItems.setAuditUserId(loginUser.getUser().getUserId());// 审核人 ID
  829. auditItems.setAuditItem(new Date());// 审核通过时间
  830. auditItems.setAuditOpTime(new Date());// 审核时间
  831. auditItems.setFidStatus("f_billstatus");// 存储对应审批字段
  832. auditItems.setTimes(1L);// 第几次提交审批
  833. auditItems.setAuditMsg("提交");
  834. auditItems.setAuditStatus("O");// 提交状态
  835. auditItems.setfSrcBillnos(fSrcBillnos);// 装载业务编号数据(来源单据编号)
  836. AjaxResult approvalFlow = auditItemsService.createApprovalFlow(auditItems);// 生成审批流
  837. Long code = Long.valueOf(String.valueOf(approvalFlow.get("code"))).longValue();
  838. if (code.equals(500L)) {
  839. TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
  840. return AjaxResult.error("发票申请提交审核失败,请找管理员");
  841. }
  842. } else {
  843. if (StringUtils.isNotNull(tfeeDo) && !"[]".equals(tfeeDo)) {
  844. JSONArray jsonDrArray = JSONArray.parseArray(tfeeDo);
  845. List<TFeeDo> tFeeDoList = JSONObject.parseArray(jsonDrArray.toJSONString(), TFeeDo.class);
  846. for (TFeeDo tFeeDo : tFeeDoList) {
  847. // 跟新费用明细
  848. int m = updateBillsFees(tFee.getfId(), tFeeDo, fBilltype);
  849. if (m == 0) {
  850. TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
  851. return AjaxResult.error("更新费用明细失败");
  852. }
  853. }
  854. }
  855. AjaxResult ajaxResult = tfeeFollow(tFee.getfId(), 6L);
  856. Long code = Long.valueOf(String.valueOf(ajaxResult.get("code"))).longValue();
  857. if (code.equals(500L)) {
  858. TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
  859. return AjaxResult.error("发票申请提交审核失败,请找管理员");
  860. }
  861. //凯和系统 修改订单的实收实付费用
  862. if ("KHSF".equals(fBilltype) || "KHFF".equals(fBilltype)){
  863. this.updateMessage(tFee.getfId());
  864. }
  865. }
  866. return AjaxResult.success("成功", messageMap);
  867. }
  868. @Override
  869. @Transactional
  870. public AjaxResult webVersionConfirm(Long[] fIds, String billsType, LoginUser loginUser) {
  871. String key = "";
  872. boolean isApprove = false;
  873. long actId = 0L;
  874. if ("DZ".equals(billsType)) {
  875. actId = 210L;
  876. key = "warehouse.contrast.ApprovalFlow";
  877. } else if ("SF".equals(billsType)) {
  878. actId = 220L;
  879. key = "warehouse.charge.ApprovalFlow";
  880. } else if ("FF".equals(billsType)) {
  881. actId = 230L;
  882. key = "warehouse.payment.ApprovalFlow";
  883. } else if ("KHDZ".equals(billsType)) {
  884. actId = 430L;
  885. key = "warehouse.kaiHeContrast.ApprovalFlow";
  886. } else if ("KHSF".equals(billsType)) {
  887. actId = 440L;
  888. key = "warehouse.kaiHeCharge.ApprovalFlow";
  889. } else if ("KHFF".equals(billsType)) {
  890. actId = 450L;
  891. key = "warehouse.kaiHePayment.ApprovalFlow";
  892. }
  893. SysConfig sysConfig = sysConfigMapper.checkConfigKeyUnique(key);
  894. if (StringUtils.isNull(sysConfig)) {
  895. TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
  896. return AjaxResult.error("系统参数异常,未找到开启审批流参数");
  897. }
  898. if ("0".equals(sysConfig.getConfigValue())) {
  899. isApprove = true;
  900. }
  901. String billStatus = null;
  902. if (isApprove) {
  903. billStatus = "4";
  904. } else {
  905. billStatus = "6";
  906. }
  907. for (Long fId : fIds) {
  908. TFee tFee = tFeeMapper.selectTFeeById(fId);
  909. if (tFee == null) {
  910. return AjaxResult.error("对账数据有误请确认");
  911. }
  912. boolean change = this.change(tFee.getfId());
  913. if (change == false) {
  914. return AjaxResult.error("数据正在审批或审批通过,不允许提交审核");
  915. }
  916. //更新主表数据状态
  917. TFee fee = new TFee();
  918. fee.setfId(fId);
  919. fee.setfBillstatus(billStatus);
  920. int i = tFeeMapper.updateTFee(fee);
  921. //更新从表数据状态
  922. int update = tFeeDoMapper.tfeeDoFollowUpdate(fId, Long.valueOf(billStatus));
  923. if (isApprove) {
  924. AuditItems auditItems = new AuditItems();
  925. auditItems.setLevelId(0L);
  926. auditItems.setBillId(tFee.getfId());
  927. auditItems.setActId(actId);
  928. auditItems.setIffinalItem("F");
  929. auditItems.setBillNo(tFee.getfBillno()); // 业务编号
  930. auditItems.setRefno1(String.valueOf(tFee.getfCorpid())); // 货权方
  931. auditItems.setRefno2(billsType);// 财务类型
  932. auditItems.setRefno3(tFee.gettMblno());// 提单号
  933. auditItems.setSendUserId(loginUser.getUser().getUserId());
  934. auditItems.setSendName(loginUser.getUsername());
  935. auditItems.setSendTime(new Date());
  936. auditItems.setAuditUserId(loginUser.getUser().getUserId());
  937. auditItems.setAuditItem(new Date());
  938. auditItems.setAuditOpTime(new Date());
  939. auditItems.setFidStatus("f_billstatus");
  940. auditItems.setTimes(1L);
  941. auditItems.setAuditMsg("提交");
  942. auditItems.setAuditStatus("O");
  943. AjaxResult approvalFlow = auditItemsService.createApprovalFlow(auditItems);
  944. Long code = Long.valueOf(String.valueOf(approvalFlow.get("code"))).longValue();
  945. if (code.equals(500L)) {
  946. TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
  947. }
  948. return approvalFlow;
  949. } else {
  950. TFeeDo tFeeDo = new TFeeDo();
  951. tFeeDo.setfPid(fId);
  952. List<TFeeDo> tFeeDoList = tFeeDoMapper.selectTFeeDoList(tFeeDo);
  953. for (TFeeDo feeDo : tFeeDoList) {
  954. // 跟新费用明细
  955. int m = updateBillsFees(fId, feeDo, billsType);
  956. if (m == 0) {
  957. TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
  958. return AjaxResult.error("更新费用明细失败");
  959. }
  960. }
  961. }
  962. AjaxResult ajaxResult = tfeeFollow(tFee.getfId(), 6L);
  963. Long code = Long.valueOf(String.valueOf(ajaxResult.get("code"))).longValue();
  964. return ajaxResult;
  965. }
  966. return AjaxResult.success();
  967. }
  968. @Override
  969. @Transactional
  970. public AjaxResult confirmKaiHe(String tfee, String tfeeDo, String tFeeInvoice, LoginUser loginUser, String fBilltype) {
  971. Long fPid = null;
  972. TFee tFee = JSONArray.parseObject(tfee, TFee.class);
  973. Map<String, Object> messageMap = new HashMap<>();
  974. String key = "";
  975. boolean isApprove = false;
  976. long actId = 0L;
  977. String billStatus = "";
  978. if ("DZ".equals(fBilltype)) {
  979. actId = 210L;
  980. key = "warehouse.contrast.ApprovalFlow";
  981. } else if ("SF".equals(fBilltype)) {
  982. actId = 220L;
  983. key = "warehouse.charge.ApprovalFlow";
  984. } else if ("FF".equals(fBilltype)) {
  985. actId = 230L;
  986. key = "warehouse.payment.ApprovalFlow";
  987. } else if ("KHDZ".equals(fBilltype)) {
  988. actId = 430L;
  989. key = "warehouse.kaiHeContrast.ApprovalFlow";
  990. } else if ("KHSF".equals(fBilltype)) {
  991. actId = 440L;
  992. key = "warehouse.kaiHeCharge.ApprovalFlow";
  993. } else if ("KHFF".equals(fBilltype)) {
  994. actId = 450L;
  995. key = "warehouse.kaiHePayment.ApprovalFlow";
  996. } else if ("ApplyFP".equals(fBilltype)) {
  997. actId = 470L;
  998. key = "warehouse.kaiHeApplyFP.ApprovalFlow";
  999. }
  1000. SysConfig sysConfig = sysConfigMapper.checkConfigKeyUnique(key);
  1001. if (StringUtils.isNull(sysConfig)) {
  1002. TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
  1003. return AjaxResult.error("系统参数异常,未找到开启审批流参数");
  1004. }
  1005. if ("0".equals(sysConfig.getConfigValue())) {
  1006. isApprove = true;
  1007. }
  1008. if (isApprove) {
  1009. billStatus = "4";
  1010. } else {
  1011. billStatus = "6";
  1012. }
  1013. if (StringUtils.isNull(tFee.getfId())) {
  1014. // 如果是新数据
  1015. tFee.setCreateBy(loginUser.getUser().getUserName());
  1016. tFee.setfDeptid(loginUser.getUser().getDeptId());
  1017. tFee.setfBilltype(fBilltype);
  1018. // 业务编码
  1019. Date time = new Date();
  1020. String billNo = billnoSerialServiceImpl.getBillNo(fBilltype, time);
  1021. tFee.setfBillno(billNo);
  1022. tFee.setfBillstatus(billStatus);
  1023. tFeeMapper.insertTFee(tFee);
  1024. fPid = tFee.getfId();
  1025. } else {
  1026. fPid = tFee.getfId();
  1027. boolean change = this.change(fPid);
  1028. if (!change) {
  1029. return AjaxResult.error("当前数据不支持修改");
  1030. }
  1031. tFee.setUpdateBy(loginUser.getUser().getUserName());
  1032. tFee.setUpdateTime(new Date());
  1033. tFee.setfBillstatus(billStatus);
  1034. tFeeMapper.updateTFee(tFee);
  1035. // 删除从表
  1036. tFeeDoMapper.deleteByFPid(tFee.getfId());
  1037. //删除开票从表
  1038. tFeeInvoiceMapper.deleteByFPid(tFee.getfId());
  1039. }
  1040. messageMap.put("tFee", tFee);
  1041. // 财务从表
  1042. if (StringUtils.isNotNull(tfeeDo) && !"[]".equals(tfeeDo)) {
  1043. JSONArray jsonDrArray = JSONArray.parseArray(tfeeDo);
  1044. List<TFeeDo> tFeeDoList = JSONObject.parseArray(jsonDrArray.toJSONString(), TFeeDo.class);
  1045. for (TFeeDo tFeeDo : tFeeDoList) {
  1046. Map<String, Object> map = this.judgeMoney(tFeeDo.getfSrcid(), tFeeDo.getfAmt(), fBilltype, tFeeDo.getfFeeid());
  1047. boolean b = (Boolean) map.get("flag");
  1048. if (b == false) {
  1049. TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
  1050. return AjaxResult.error(map.get("message").toString());
  1051. }
  1052. tFeeDo.setfPid(tFee.getfId());
  1053. tFeeDo.setCreateBy(loginUser.getUser().getUserName());
  1054. tFeeDo.setCreateTime(new Date());
  1055. tFeeDo.setfStatus(billStatus);
  1056. tFeeDoMapper.insertTFeeDo(tFeeDo);
  1057. }
  1058. }
  1059. if (!"".equals(tFeeInvoice) && tFeeInvoice != null && !"null".equals(tFeeInvoice)) {
  1060. JSONArray jsonDrArray = JSONArray.parseArray(tFeeInvoice);
  1061. List<TFeeInvoice> tFeeInvoiceList = JSONObject.parseArray(jsonDrArray.toJSONString(), TFeeInvoice.class);
  1062. for (TFeeInvoice feeInvoice : tFeeInvoiceList) {
  1063. feeInvoice.setfPid(fPid);
  1064. feeInvoice.setCreateBy(loginUser.getUser().getUserName());
  1065. feeInvoice.setCreateTime(new Date());
  1066. feeInvoice.setfBillstatus(billStatus);
  1067. tFeeInvoiceMapper.insertTFeeInvoice(feeInvoice);
  1068. }
  1069. }
  1070. // 这里加个判断取系统参数来确定是否需要启用审批流
  1071. if (isApprove) {
  1072. AuditItems auditItems = new AuditItems();
  1073. auditItems.setLevelId(0L);
  1074. auditItems.setBillId(tFee.getfId());
  1075. auditItems.setActId(actId);
  1076. auditItems.setIffinalItem("F");
  1077. auditItems.setBillNo(tFee.getfBillno()); // 业务编号
  1078. auditItems.setRefno1(String.valueOf(tFee.getfCorpid())); // 货权方
  1079. auditItems.setRefno2(fBilltype);// 财务类型
  1080. auditItems.setRefno3(tFee.gettMblno());// 提单号
  1081. auditItems.setSendUserId(loginUser.getUser().getUserId());
  1082. auditItems.setSendName(loginUser.getUsername());
  1083. auditItems.setSendTime(new Date());
  1084. auditItems.setAuditUserId(loginUser.getUser().getUserId());
  1085. auditItems.setAuditItem(new Date());
  1086. auditItems.setAuditOpTime(new Date());
  1087. auditItems.setFidStatus("f_billstatus");
  1088. auditItems.setTimes(1L);
  1089. auditItems.setAuditMsg("提交");
  1090. auditItems.setAuditStatus("O");
  1091. AjaxResult approvalFlow = auditItemsService.createApprovalFlow(auditItems);
  1092. Long code = Long.valueOf(String.valueOf(approvalFlow.get("code"))).longValue();
  1093. if (code.equals(500L)) {
  1094. TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
  1095. return AjaxResult.error("发票申请提交审核失败,请找管理员");
  1096. }
  1097. } else {
  1098. if (StringUtils.isNotNull(tfeeDo) && !"[]".equals(tfeeDo)) {
  1099. JSONArray jsonDrArray = JSONArray.parseArray(tfeeDo);
  1100. List<TFeeDo> tFeeDoList = JSONObject.parseArray(jsonDrArray.toJSONString(), TFeeDo.class);
  1101. for (TFeeDo tFeeDo : tFeeDoList) {
  1102. // 跟新费用明细
  1103. int m = updateBillsFees(tFee.getfId(), tFeeDo, fBilltype);
  1104. if (m == 0) {
  1105. TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
  1106. return AjaxResult.error("更新费用明细失败");
  1107. }
  1108. }
  1109. }
  1110. AjaxResult ajaxResult = tfeeFollow(tFee.getfId(), 6L);
  1111. Long code = Long.valueOf(String.valueOf(ajaxResult.get("code"))).longValue();
  1112. if (code.equals(500L)) {
  1113. TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
  1114. return AjaxResult.error("发票申请提交审核失败,请找管理员");
  1115. }
  1116. }
  1117. return AjaxResult.success("成功", messageMap);
  1118. }
  1119. /**
  1120. * 根据财务主表id 更新对应明细表状态
  1121. *
  1122. * @param fPid 财务主表id
  1123. * @return 结果
  1124. */
  1125. @Transactional
  1126. public AjaxResult tfeeFollow(Long fPid, long fettle) {
  1127. if (StringUtils.isNull(fPid)) {
  1128. return AjaxResult.error("财务更新状态未找到主表信息,请与管理员联系");
  1129. }
  1130. TFee tFee = new TFee();
  1131. tFee.setfId(fPid);
  1132. tFee.setfBillstatus(String.valueOf(fettle));
  1133. int tFeeUpdateResult = tFeeMapper.updateTFee(tFee);
  1134. if (tFeeUpdateResult <= 0) {
  1135. TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
  1136. return AjaxResult.error("更新财务明细状态失败,请联系管理员");
  1137. }
  1138. try {
  1139. int itemUpdateResult = tFeeDoMapper.tfeeDoFollowUpdate(fPid, fettle);
  1140. } catch (Exception exception) {
  1141. TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
  1142. return AjaxResult.error("更新财务明细状态失败,请联系管理员");
  1143. }
  1144. TFeeInvoice invoice = new TFeeInvoice();
  1145. invoice.setfPid(fPid);
  1146. List<TFeeInvoice> tFeeInvoiceList = tFeeInvoiceMapper.selectTFeeInvoiceList(invoice);
  1147. if (CollectionUtils.isNotEmpty(tFeeInvoiceList)) {
  1148. try {
  1149. int itemUpdateResult = tFeeInvoiceMapper.tFeeInvoiceUpdate(fPid, fettle);
  1150. } catch (Exception exception) {
  1151. TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
  1152. return AjaxResult.error("更新开票明细状态失败,请联系管理员");
  1153. }
  1154. }
  1155. return AjaxResult.success();
  1156. }
  1157. @Transactional
  1158. public synchronized AjaxResult billsfeesFollow(Long fPid) {
  1159. if (StringUtils.isNull(fPid)) {
  1160. return AjaxResult.error("费用明细更新状态未找到主表信息,请与管理员联系");
  1161. }
  1162. TFee tFee = tFeeMapper.selectTFeeById(fPid);
  1163. // 查询从表数据
  1164. TFeeDo tFeeDo = new TFeeDo();
  1165. tFeeDo.setfPid(fPid);
  1166. List<TFeeDo> tFeeDoList = tFeeDoMapper.selectTFeeDoList(tFeeDo);
  1167. for (TFeeDo tFeeDo1 : tFeeDoList) {
  1168. // 跟新费用明细
  1169. Map<String, Object> map = this.judgeMoney(tFeeDo1.getfSrcid(), tFeeDo1.getfAmt(), tFee.getfBilltype(), tFeeDo1.getfFeeid());
  1170. if (!(Boolean) map.get("flag")) {
  1171. TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
  1172. return AjaxResult.error(map.get("message").toString());
  1173. }
  1174. int m = updateBillsFees(fPid, tFeeDo1, tFee.getfBilltype());
  1175. if (m == 0) {
  1176. TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
  1177. return AjaxResult.error("更新费用明细失败");
  1178. }
  1179. }
  1180. return AjaxResult.success();
  1181. }
  1182. /**
  1183. * 账单管理撤销对账、收费、付费
  1184. * @param fPid
  1185. * @param fBillType
  1186. * @return
  1187. */
  1188. @Transactional
  1189. public AjaxResult updateDSFMoney(Long fPid,String fBillType){
  1190. if (StringUtils.isNull(fPid)) {
  1191. return AjaxResult.error("费用明细更新状态未找到主表信息,请与管理员联系");
  1192. }
  1193. TFee tFee = tFeeMapper.selectTFeeById(fPid);
  1194. // 获取从表数据
  1195. TFeeDo tFeeDo = new TFeeDo();
  1196. tFeeDo.setfPid(fPid);
  1197. List<TFeeDo> tFeeDos = tFeeDoMapper.selectTFeeDoList(tFeeDo);
  1198. for (TFeeDo tFeeDo1 : tFeeDos) {
  1199. int m = updateBillsFees(fPid, tFeeDo1, fBillType);
  1200. if (m == 0) {
  1201. TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
  1202. return AjaxResult.error("更新费用明细失败");
  1203. }
  1204. }
  1205. return AjaxResult.success();
  1206. }
  1207. /**
  1208. * 凯和撤销收费 付费 对账
  1209. * @param fPid
  1210. * @param fBillType
  1211. * @return
  1212. */
  1213. @Transactional
  1214. public AjaxResult updateMoney(Long fPid,String fBillType) {
  1215. if (StringUtils.isNull(fPid)) {
  1216. return AjaxResult.error("费用明细更新状态未找到主表信息,请与管理员联系");
  1217. }
  1218. TFee tFee = tFeeMapper.selectTFeeById(fPid);
  1219. // 查询从表数据
  1220. TFeeDo tFeeDo = new TFeeDo();
  1221. tFeeDo.setfPid(fPid);
  1222. List<TFeeDo> tFeeDoList = tFeeDoMapper.selectTFeeDoList(tFeeDo);
  1223. for (TFeeDo tFeeDo1 : tFeeDoList) {
  1224. /* // 跟新费用明细
  1225. Map<String, Object> map = this.judgeMoney(tFeeDo1.getfSrcid(), tFeeDo1.getfAmt(), tFee.getfBilltype(), tFeeDo1.getfFeeid());
  1226. if (!(Boolean) map.get("flag")) {
  1227. TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
  1228. return AjaxResult.error(map.get("message").toString());
  1229. }*/
  1230. int m = updateBillsFees(fPid, tFeeDo1, fBillType);
  1231. if (m == 0) {
  1232. TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
  1233. return AjaxResult.error("更新费用明细失败");
  1234. }
  1235. }
  1236. return AjaxResult.success();
  1237. }
  1238. @Override
  1239. @Transactional
  1240. public AjaxResult revoke(String tfee, String tfeeDo, LoginUser loginUser, String fBilltype) {
  1241. // 更新 主表、从表
  1242. TFee tFee = JSONArray.parseObject(tfee, TFee.class);
  1243. if ("DZApplyFP".equals(fBilltype)) {
  1244. TFee fee = tFeeMapper.selectTFeeById(tFee.getfId());
  1245. if (fee.getfMake() == 1) {
  1246. return AjaxResult.error("该申请发票已开销项发票,不能撤销");
  1247. }
  1248. }
  1249. tFee.setUpdateBy(loginUser.getUser().getUserName());
  1250. tFee.setUpdateTime(new Date());
  1251. tFeeMapper.updateTFee(tFee);
  1252. // 删除从表
  1253. tFeeDoMapper.deleteByFPid(tFee.getfId());
  1254. // 财务从表
  1255. if (StringUtils.isNotNull(tfeeDo)) {
  1256. JSONArray jsonDrArray = JSONArray.parseArray(tfeeDo);
  1257. List<TFeeDo> tFeeDoList = JSONObject.parseArray(jsonDrArray.toJSONString(), TFeeDo.class);
  1258. for (TFeeDo tFeeDo : tFeeDoList) {
  1259. tFeeDo.setfPid(tFee.getfId());
  1260. tFeeDo.setCreateBy(loginUser.getUser().getUserName());
  1261. tFeeDo.setCreateTime(new Date());
  1262. tFeeDoMapper.insertTFeeDo(tFeeDo);
  1263. // 跟新费用明细
  1264. int m = updateBillsFees(tFee.getfId(), tFeeDo, fBilltype);
  1265. if (m == 0) {
  1266. TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
  1267. return AjaxResult.error("更新费用明细失败");
  1268. }
  1269. }
  1270. }
  1271. //修改主订单费用信息
  1272. if (fBilltype.equals("DCRevoke")) {
  1273. this.updateMessage(tFee.getfId());
  1274. }
  1275. return AjaxResult.success();
  1276. }
  1277. public void updateMessage(Long fid) {
  1278. List<TFeeDo> list = tFeeDoMapper.selectTFeeDoByfPid(fid);
  1279. if (CollectionUtils.isNotEmpty(list)){
  1280. List<Long> collect = list.stream().map(TFeeDo::getfSrcpid).collect(toList());
  1281. collect.stream().forEach(item ->{
  1282. TWarehouseBills warehouseBills = tWarehouseBillsMapper.selectTWarehousebillsById(item);
  1283. //获取订舱单位
  1284. TCorps tCorps = tCorpsMapper.selectTCorpsById(warehouseBills.getfCorpid());
  1285. //实收费用
  1286. List<TWarehousebillsfees> warehousebillsfees = tWarehousebillsfeesMapper.selectFeesByPId(item, "D");
  1287. //实付费用
  1288. List<TWarehousebillsfees> tWarehousebillsfees = tWarehousebillsfeesMapper.selectFeesByPId(item, "C");
  1289. TWarehouseBills tWarehouseBills = new TWarehouseBills();
  1290. tWarehouseBills.setfId(item);
  1291. tWarehouseBills.setfRecycle(warehousebillsfees.stream().filter(ei->ei.getfStlamount()!=null && ei.getfBillstatus().longValue() == 6L).map(TWarehousebillsfees::getfStlamount).reduce(BigDecimal.ZERO,BigDecimal::add));
  1292. tWarehouseBills.setfPay(tWarehousebillsfees.stream().filter(ei->ei.getfStlamount()!=null && ei.getfBillstatus().longValue() == 6L).map(TWarehousebillsfees::getfStlamount).reduce(BigDecimal.ZERO,BigDecimal::add));
  1293. //如果订舱单位是凯和 应收尾0 也是放货状态
  1294. //1: 未放货 应收>0 应收>实收
  1295. //2:放货 应收>0 应收=实收
  1296. if ((tCorps == null || tCorps.getfCname().equals("青岛凯和志诚物流有限公司")) && !warehouseBills.getfCaregoStatus().equals("3") ){
  1297. tWarehouseBills.setfCaregoStatus("2");
  1298. }else if (warehouseBills.getfReceivable().compareTo(BigDecimal.ZERO) > 0 && warehouseBills.getfReceivable().compareTo(tWarehouseBills.getfRecycle()) > 0){
  1299. tWarehouseBills.setfCaregoStatus("1");
  1300. }else if (warehouseBills.getfReceivable().compareTo(BigDecimal.ZERO) > 0 && warehouseBills.getfReceivable().compareTo(tWarehouseBills.getfRecycle()) <= 0){
  1301. tWarehouseBills.setfCaregoStatus("2");
  1302. }
  1303. tWarehouseBillsMapper.updateTWarehousebills(tWarehouseBills);
  1304. });
  1305. }
  1306. }
  1307. @Override
  1308. public AjaxResult queryRemove(Long fId) {
  1309. TFee tFee = tFeeMapper.selectTFeeById(fId);
  1310. TFeeDo tFeeDo = new TFeeDo();
  1311. tFeeDo.setfPid(tFee.getfId());
  1312. List<TFeeDo> tFeeDoList = tFeeDoMapper.selectTFeeDoList(tFeeDo);
  1313. if (StringUtils.isNull(tFee)) {
  1314. return AjaxResult.success("0");
  1315. } else if (StringUtils.isNotNull(tFee) && StringUtils.isEmpty(tFeeDoList)) {
  1316. return AjaxResult.success("1");
  1317. } else if (tFee.getfBilltype().equals("INV") && tFee.getfAccountId() != null) {
  1318. return AjaxResult.success("3");
  1319. } else {
  1320. return AjaxResult.success("2");
  1321. }
  1322. }
  1323. @Override
  1324. @Transactional
  1325. public AjaxResult remove(Long fId) {
  1326. TFee tFee = tFeeMapper.selectTFeeById(fId);
  1327. if ("4".equals(tFee.getfBillstatus())) {
  1328. return AjaxResult.error("数据已提交审批,暂不能删除");
  1329. } else if ("5".equals(tFee.getfBillstatus())) {
  1330. return AjaxResult.error("数据正在审批,暂不能删除");
  1331. } else if ("6".equals(tFee.getfBillstatus())) {
  1332. return AjaxResult.error("数据审批完成,不能删除");
  1333. } else {
  1334. try {
  1335. tFeeMapper.deleteTFeeById(fId);
  1336. tFeeDoMapper.deleteByFPid(fId);
  1337. tFeeInvoiceMapper.deleteByFPid(fId);
  1338. } catch (Exception e) {
  1339. TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
  1340. return AjaxResult.error("删除失败,请找管理员");
  1341. }
  1342. return AjaxResult.success();
  1343. }
  1344. }
  1345. @Override
  1346. public List<TWareHouseExcelItem> selectTWarehousebillsItemsList(Long fId) {
  1347. List<TWareHouseExcelItem> tWareHouseExcelItemList = tFeeMapper.selectTWarehousebillsItemsList(fId);
  1348. List<TWareHouseExcelItem> tWareHouseExcelItemList1 = new ArrayList<>();
  1349. for (TWareHouseExcelItem tWareHouseExcelItem : tWareHouseExcelItemList) {
  1350. if (StringUtils.isNotNull(tWareHouseExcelItem.getfBusinessType())) {
  1351. List<SysDictData> sysDictDataListIn = new ArrayList<>();
  1352. SysDictData sysDictData = new SysDictData();
  1353. if (tWareHouseExcelItem.getfBilltype().equals("入库")) {
  1354. sysDictData.setDictType(ST_IN_TYPE);
  1355. sysDictData.setDictValue(String.valueOf(tWareHouseExcelItem.getfBusinessType()));
  1356. sysDictData.setStatus("0");
  1357. sysDictDataListIn = iSysDictDataService.selectDictDataList(sysDictData);
  1358. } else if (tWareHouseExcelItem.getfBilltype().equals("出库")) {
  1359. sysDictData.setDictType(ST_OUT_TYPE);
  1360. sysDictData.setDictValue(String.valueOf(tWareHouseExcelItem.getfBusinessType()));
  1361. sysDictData.setStatus("0");
  1362. sysDictDataListIn = iSysDictDataService.selectDictDataList(sysDictData);
  1363. } else if (tWareHouseExcelItem.getfBilltype().equals("调拨") | tWareHouseExcelItem.getfBilltype().equals("货物通关")) {
  1364. sysDictData.setDictType(ST_TRANS_TYPE);
  1365. sysDictData.setDictValue(String.valueOf(tWareHouseExcelItem.getfBusinessType()));
  1366. sysDictData.setStatus("0");
  1367. sysDictDataListIn = iSysDictDataService.selectDictDataList(sysDictData);
  1368. }
  1369. if (null != sysDictDataListIn && sysDictDataListIn.size() > 0) {
  1370. tWareHouseExcelItem.setfBusinessType(sysDictDataListIn.get(0).getDictLabel());
  1371. }
  1372. }
  1373. tWareHouseExcelItemList1.add(tWareHouseExcelItem);
  1374. }
  1375. return tWareHouseExcelItemList1;
  1376. }
  1377. @Override
  1378. public String findCtrlcorpid(Long fId) {
  1379. TFee tFee = tFeeMapper.selectTFeeById(fId);
  1380. String exportName = tFee.getfCtrlcorpid() + "-" + tFee.getfBillno();
  1381. return exportName;
  1382. }
  1383. @Override
  1384. public List<Receivable> receivableExport(TWareHouseFees tWareHouseFees) throws Exception {
  1385. List<Map<String, Object>> list = tFeeMapper.warehouseBillsFeesList1(tWareHouseFees);
  1386. List<Receivable> list1 = ListMapToBeanUtils.castMapToBean(list, Receivable.class);
  1387. return list1;
  1388. }
  1389. @Override
  1390. public List<GeneralLedgerExcel> payableExport(TWareHouseFees tWareHouseFees) throws Exception {
  1391. List<GeneralLedgerExcel> ledgerExcelList = new ArrayList<>();
  1392. List<FeeVO> feeVOList = tFeeMapper.selectFinancialLedgerList(tWareHouseFees);
  1393. feeVOList.forEach(vo -> {
  1394. GeneralLedgerExcel ledgerExcel = new GeneralLedgerExcel();
  1395. ledgerExcel.setFAmount(vo.getFAmount());
  1396. ledgerExcel.setReviewDate(vo.getReviewDate());
  1397. ledgerExcel.setFFeesName(vo.getFFeesName());
  1398. ledgerExcel.setNnfinished(vo.getNnfinished());
  1399. ledgerExcel.setFStlamount(vo.getFStlamount());
  1400. ledgerExcelList.add(ledgerExcel);
  1401. });
  1402. return ledgerExcelList;
  1403. }
  1404. @Override
  1405. public List<Profit> profitExport(TWareHouseFees tWareHouseFees) throws Exception {
  1406. List<Map<String, Object>> list = tFeeMapper.warehouseBillsFeesProfitList(tWareHouseFees);
  1407. return ListMapToBeanUtils.castMapToBean(list, Profit.class);
  1408. }
  1409. @Override
  1410. public List<ProfitGeneralLedgerExcel> profitCustomExport(TWareHouseFees tWareHouseFees) throws Exception {
  1411. List<Map<String, Object>> list = tFeeMapper.warehouseBillsFeesCustomProfitList(tWareHouseFees);
  1412. return ListMapToBeanUtils.castMapToBean(list, ProfitGeneralLedgerExcel.class);
  1413. }
  1414. @Override
  1415. public List<Contrast> contrastExport(TFee tFee) throws Exception {
  1416. List<Map<String, Object>> list = tFeeMapper.selectTFeeList1(tFee);
  1417. List<Contrast> list1 = ListMapToBeanUtils.castMapToBean(list, Contrast.class);
  1418. return list1;
  1419. }
  1420. @Override
  1421. public List<Payment> paymentExport(TFee tFee) throws Exception {
  1422. List<Map<String, Object>> list = tFeeMapper.selectFeeList(tFee);
  1423. return ListMapToBeanUtils.castMapToBean(list, Payment.class);
  1424. }
  1425. @Override
  1426. public List<Charge> chargeExport(TFee tFee) throws Exception {
  1427. List<Map<String, Object>> list = tFeeMapper.selectFeeList(tFee);
  1428. return ListMapToBeanUtils.castMapToBean(list, Charge.class);
  1429. }
  1430. @Override
  1431. public List<Account> accountExport(TFee tFee) throws Exception {
  1432. List<Map<String, Object>> list = tFeeMapper.webVersionTFee(tFee);
  1433. return ListMapToBeanUtils.castMapToBean(list, Account.class);
  1434. }
  1435. @Override
  1436. public List<Detailed> selectDetailedList(Long fId) {
  1437. List<Detailed> detailedList = tFeeMapper.selectDetailedList(fId);
  1438. List<Detailed> detailedList1 = new ArrayList<>();
  1439. for (Detailed tWareHouseExcelItem : detailedList) {
  1440. if (StringUtils.isNotNull(tWareHouseExcelItem.getfBusinessType())) {
  1441. List<SysDictData> sysDictDataListIn = new ArrayList<>();
  1442. SysDictData sysDictData = new SysDictData();
  1443. if (tWareHouseExcelItem.getfBilltype().equals("入库")) {
  1444. sysDictData.setDictType(ST_IN_TYPE);
  1445. sysDictData.setDictValue(String.valueOf(tWareHouseExcelItem.getfBusinessType()));
  1446. sysDictData.setStatus("0");
  1447. sysDictDataListIn = iSysDictDataService.selectDictDataList(sysDictData);
  1448. } else if (tWareHouseExcelItem.getfBilltype().equals("出库")) {
  1449. sysDictData.setDictType(ST_OUT_TYPE);
  1450. sysDictData.setDictValue(String.valueOf(tWareHouseExcelItem.getfBusinessType()));
  1451. sysDictData.setStatus("0");
  1452. sysDictDataListIn = iSysDictDataService.selectDictDataList(sysDictData);
  1453. } else if (tWareHouseExcelItem.getfBilltype().equals("调拨") | tWareHouseExcelItem.getfBilltype().equals("货物通关")) {
  1454. sysDictData.setDictType(ST_TRANS_TYPE);
  1455. sysDictData.setDictValue(String.valueOf(tWareHouseExcelItem.getfBusinessType()));
  1456. sysDictData.setStatus("0");
  1457. sysDictDataListIn = iSysDictDataService.selectDictDataList(sysDictData);
  1458. }
  1459. if (CollectionUtils.isNotEmpty(sysDictDataListIn)) {
  1460. tWareHouseExcelItem.setfBusinessType(sysDictDataListIn.get(0).getDictLabel());
  1461. }
  1462. }
  1463. detailedList1.add(tWareHouseExcelItem);
  1464. }
  1465. return detailedList1;
  1466. }
  1467. @Override
  1468. public List<Map<String, Object>> selectdetailedList(TWarehousebill tWarehousebill) {
  1469. return tFeeMapper.selectDetailedList1(tWarehousebill);
  1470. }
  1471. /**
  1472. * 更新费用明细
  1473. *
  1474. * @param fid
  1475. * @param tFeeDo
  1476. * @param billsType
  1477. * @return
  1478. */
  1479. @Transactional
  1480. public int updateBillsFees(Long fid, TFeeDo tFeeDo, String billsType) {
  1481. // 查询从表数据
  1482. TFee tFee = tFeeMapper.selectTFeeById(fid);
  1483. if (billsType.equals("SF") || billsType.equals("FF")
  1484. || billsType.equals("KHSF") || billsType.equals("KHFF")) {
  1485. billsType = "DC";
  1486. }
  1487. Map<String, Object> map = new HashMap<>();
  1488. map.put("tFee", tFee);
  1489. map.put("billType", billsType);
  1490. map.put("tFeeDo", tFeeDo);
  1491. return tWarehousebillsfeesMapper.updateTWarehousebillsfee(map);
  1492. }
  1493. public boolean change(Long fId) {
  1494. boolean flag = false;
  1495. TFee tFee = tFeeMapper.selectTFeeById(fId);
  1496. if ("4".equals(tFee.getfBillstatus())
  1497. || "5".equals(tFee.getfBillstatus())
  1498. || "6".equals(tFee.getfBillstatus())) {
  1499. flag = false;
  1500. } else {
  1501. flag = true;
  1502. }
  1503. return flag;
  1504. }
  1505. @Override
  1506. @Transactional
  1507. public AjaxResult webVersionSubmitApplyFP(TFee tFee, LoginUser loginUser, String fBilltype) {
  1508. String key = "";
  1509. boolean isApprove = false;
  1510. long actId = 0L;
  1511. String billStatus = "";
  1512. if ("ApplyFP".equals(fBilltype)) {
  1513. actId = 470L;
  1514. key = "warehouse.kaiHeApplyFP.ApprovalFlow";
  1515. }
  1516. SysConfig sysConfig = sysConfigMapper.checkConfigKeyUnique(key);
  1517. if (StringUtils.isNull(sysConfig)) {
  1518. TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
  1519. return AjaxResult.error("系统参数异常,未找到开启审批流参数");
  1520. }
  1521. if ("0".equals(sysConfig.getConfigValue())) {
  1522. isApprove = true;
  1523. }
  1524. if (isApprove) {
  1525. billStatus = "4";
  1526. } else {
  1527. billStatus = "6";
  1528. }
  1529. /*for (Long getfId : tFee.getfIds()) {*/
  1530. TFee fee = tFeeMapper.selectTFeeById(tFee.getfId());
  1531. if (fee == null) {
  1532. return AjaxResult.error("财务主表数据有误,请确认");
  1533. }
  1534. boolean change = this.change(tFee.getfId());
  1535. if (change == false) {
  1536. return AjaxResult.error("数据正在审批或审批通过,不允许提交审核");
  1537. }
  1538. fee.setfId(tFee.getfId());
  1539. fee.setfBillstatus(billStatus);
  1540. fee.setUpdateBy(loginUser.getUser().getUserName());
  1541. fee.setUpdateTime(new Date());
  1542. int updateTFee = tFeeMapper.updateTFee(fee);
  1543. if (updateTFee <= 0) {
  1544. TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
  1545. return AjaxResult.error("更新财务主表数据出错,请找管理员");
  1546. }
  1547. TFeeDo tFeeDo = new TFeeDo();
  1548. tFeeDo.setfPid(tFee.getfId());
  1549. List<TFeeDo> tFeeDos = tFeeDoMapper.selectTFeeDoList(tFeeDo);
  1550. if (CollectionUtils.isEmpty(tFeeDos)) {
  1551. TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
  1552. return AjaxResult.error("财务从表数据有误,请确认");
  1553. }
  1554. for (TFeeDo feeDo : tFeeDos) {
  1555. feeDo.setfId(feeDo.getfId());
  1556. feeDo.setfStatus(billStatus);
  1557. feeDo.setUpdateBy(loginUser.getUser().getUserName());
  1558. feeDo.setUpdateTime(new Date());
  1559. int i = tFeeDoMapper.updateTFeeDo(feeDo);
  1560. if (i <= 0) {
  1561. TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
  1562. return AjaxResult.error("更新财务主表数据出错,请找管理员");
  1563. }
  1564. }
  1565. TFeeInvoice tFeeInvoice = new TFeeInvoice();
  1566. tFeeInvoice.setfPid(tFee.getfId());
  1567. List<TFeeInvoice> tFeeInvoiceList = tFeeInvoiceMapper.selectTFeeInvoiceList(tFeeInvoice);
  1568. if (CollectionUtils.isNotEmpty(tFeeInvoiceList)) {
  1569. for (TFeeInvoice invoice : tFeeInvoiceList) {
  1570. tFeeInvoice.setfBillstatus(billStatus);
  1571. tFeeInvoice.setfId(invoice.getfId());
  1572. tFeeInvoice.setUpdateBy(loginUser.getUser().getUserName());
  1573. tFeeInvoice.setUpdateTime(new Date());
  1574. tFeeInvoiceMapper.updateTFeeInvoice(tFeeInvoice);
  1575. }
  1576. }
  1577. //添加审批流
  1578. if (isApprove) {
  1579. AuditItems auditItems = new AuditItems();
  1580. auditItems.setLevelId(0L);
  1581. auditItems.setBillId(fee.getfId());
  1582. auditItems.setActId(actId);
  1583. auditItems.setIffinalItem("F");
  1584. auditItems.setBillNo(fee.getfBillno()); // 业务编号
  1585. auditItems.setRefno1(String.valueOf(fee.getfCorpid())); // 货权方
  1586. auditItems.setRefno2(fee.getfBilltype());// 财务类型
  1587. auditItems.setRefno3(fee.gettMblno());// 提单号
  1588. auditItems.setSendUserId(loginUser.getUser().getUserId());
  1589. auditItems.setSendName(loginUser.getUsername());
  1590. auditItems.setSendTime(new Date());
  1591. auditItems.setAuditUserId(loginUser.getUser().getUserId());
  1592. auditItems.setAuditItem(new Date());
  1593. auditItems.setAuditOpTime(new Date());
  1594. auditItems.setFidStatus("f_billstatus");
  1595. auditItems.setTimes(1L);
  1596. auditItems.setAuditMsg("提交");
  1597. auditItems.setAuditStatus("O");
  1598. AjaxResult approvalFlow = auditItemsService.createApprovalFlow(auditItems);
  1599. Long code = Long.valueOf(String.valueOf(approvalFlow.get("code"))).longValue();
  1600. if (code.equals(500L)) {
  1601. TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
  1602. return AjaxResult.error("提交审核失败,请找管理员");
  1603. }
  1604. return approvalFlow;
  1605. } else {
  1606. for (TFeeDo t : tFeeDos) {
  1607. // 跟新费用明细
  1608. int m = updateBillsFees(tFee.getfId(), t, fBilltype);
  1609. if (m == 0) {
  1610. TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
  1611. return AjaxResult.error("更新费用明细失败");
  1612. }
  1613. }
  1614. AjaxResult ajaxResult = tfeeFollow(tFee.getfId(), 6L);
  1615. Long code = Long.valueOf(String.valueOf(ajaxResult.get("code"))).longValue();
  1616. if (code.equals(500L)) {
  1617. TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
  1618. return AjaxResult.error("提交审核失败,请找管理员");
  1619. }
  1620. return ajaxResult;
  1621. }
  1622. /*}*/
  1623. //return AjaxResult.success();
  1624. }
  1625. @Override
  1626. public AjaxResult webVersionUpdateApplyFP(TFee tFee, LoginUser loginUser, String billType) {
  1627. TFeeInvoice tFeeInvoice = tFee.gettFeeInvoice();
  1628. tFeeInvoice.setfPid(tFee.getfId());
  1629. int i = 0;
  1630. if (tFeeInvoice.getfId() != null) {
  1631. tFeeInvoice.setUpdateBy(loginUser.getUser().getUserName());
  1632. tFeeInvoice.setUpdateTime(new Date());
  1633. i = tFeeInvoiceMapper.updateTFeeInvoice(tFeeInvoice);
  1634. } else {
  1635. return AjaxResult.error("开票信息为空,请找管理员");
  1636. }
  1637. if (i <= 0) {
  1638. return AjaxResult.error("更新数据失败,请找管理员");
  1639. } else {
  1640. return AjaxResult.success();
  1641. }
  1642. }
  1643. @Override
  1644. public List<FinancialTFee> selectFinancialTFeeList(TFee tFee) {
  1645. return tFeeMapper.selectFinancialTFeeList(tFee);
  1646. }
  1647. @Override
  1648. public List<Map<String, Object>> FinancialFeesList(TWareHouseFees tWareHouseFees) {
  1649. Map<String, Object> map = new HashMap<>();
  1650. map.put("tWareHouseFees", tWareHouseFees);
  1651. return tFeeMapper.FinancialFeesList(map);
  1652. }
  1653. @Override
  1654. public Map<String, Object> selectFinancialTFeeId(Long fId) {
  1655. Map<String, Object> map = new HashMap<>();
  1656. FinancialTFee financialTFee = tFeeMapper.selectFinancialTFeeId(fId);
  1657. List<FinancialTFeeDoExcel> financialTFeeDoExcels = tFeeDoMapper.selectFinancialTFeeDo(fId);
  1658. map.put("tFee", financialTFee);
  1659. map.put("tFeeDo", financialTFeeDoExcels);
  1660. return map;
  1661. }
  1662. @Override
  1663. public List<FinancialTFeeDoExcel> FinancialTFeeDoExcel(Long fId) {
  1664. return tFeeDoMapper.selectFinancialTFeeDo(fId);
  1665. }
  1666. @Override
  1667. @Transactional
  1668. public AjaxResult webVersionApplyFP(TFee tFee, LoginUser loginUser, String fBilltype, TFeeInvoice tFeeInvoice) {
  1669. Long fPid = null;
  1670. String billStatus = "2";
  1671. try {
  1672. /*for (Long getfId : tFee.getfIds()) {*/
  1673. TFee account = new TFee();
  1674. TFee fee = tFeeMapper.selectTFeeById(tFee.getfId());
  1675. if (fee == null) {
  1676. return AjaxResult.error("财务主表数据有误,请确认");
  1677. }
  1678. account.setfId(fee.getfId());
  1679. account.setfMake(1);
  1680. fee.setfBilltype(fBilltype);
  1681. fee.setfBillstatus(billStatus);
  1682. fee.setCreateBy(loginUser.getUser().getUserName());
  1683. fee.setCreateTime(new Date());
  1684. fee.setfDeptid(loginUser.getUser().getDeptId());
  1685. fee.setUpdateBy(null);
  1686. fee.setUpdateTime(null);
  1687. fee.setfInvoiceRise(tFee.getfInvoiceRise());
  1688. fee.setfAccountId(fee.getfId());
  1689. Date time = new Date();
  1690. String billNo = billnoSerialServiceImpl.getBillNo(fBilltype, time);
  1691. fee.setfBillno(billNo);
  1692. fee.setfAccbilldate(null);
  1693. fee.setfId(null);
  1694. tFeeMapper.insertTFee(fee);
  1695. tFeeMapper.updateTFee(account);
  1696. //修改原来的数据的开票金额
  1697. fPid = fee.getfId();
  1698. TFeeDo tFeeDo = new TFeeDo();
  1699. tFeeDo.setfPid(tFee.getfId());
  1700. List<TFeeDo> tFeeDos = tFeeDoMapper.selectTFeeDoList(tFeeDo);
  1701. if (CollectionUtils.isEmpty(tFeeDos)) {
  1702. TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
  1703. return AjaxResult.error("财务从表数据有误,请确认");
  1704. }
  1705. for (TFeeDo feeDo : tFeeDos) {
  1706. feeDo.setfPid(fPid);
  1707. feeDo.setfStatus(billStatus);
  1708. feeDo.setCreateBy(loginUser.getUser().getUserName());
  1709. feeDo.setCreateTime(new Date());
  1710. feeDo.setUpdateBy(null);
  1711. feeDo.setUpdateTime(null);
  1712. int i = tFeeDoMapper.insertTFeeDo(feeDo);
  1713. }
  1714. tFeeInvoice.setfBillstatus(billStatus);
  1715. tFeeInvoice.setfPid(fPid);
  1716. tFeeInvoice.setCreateBy(loginUser.getUser().getUserName());
  1717. tFeeInvoice.setCreateTime(new Date());
  1718. tFeeInvoiceMapper.insertTFeeInvoice(tFeeInvoice);
  1719. /*}*/
  1720. } catch (Exception e) {
  1721. TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
  1722. return AjaxResult.error("申请发票出错,请找管理员");
  1723. }
  1724. return AjaxResult.success();
  1725. }
  1726. /**
  1727. * 判断金额是否超过可用金额
  1728. *
  1729. * @param fid 费用明细表主键
  1730. * @param money 申请金额
  1731. * @param type DZ 对账 SF 收费 FF 付费 ApplyFP 开票申请 invoiceFP 开票
  1732. * @return
  1733. */
  1734. public Map<String, Object> judgeMoney(long fid, BigDecimal money, String type, Long feeId) {
  1735. Map<String, Object> map = new HashMap<>();
  1736. boolean flag = true;
  1737. TWarehousebillsfees warehousebillsfees = tWarehousebillsfeesMapper.selectTWarehousebillsfeesById(fid);
  1738. TFees tFees = tFeesMapper.selectTFeesById(feeId);
  1739. BigDecimal amount = warehousebillsfees.getfAmount();//金额
  1740. BigDecimal accamount = warehousebillsfees.getfAccamount();//对账金额
  1741. BigDecimal stlamount = warehousebillsfees.getfStlamount();//结算金额
  1742. BigDecimal invamount = warehousebillsfees.getfInvamount();//开票金额a
  1743. BigDecimal askamount = warehousebillsfees.getfAskamount();//申请金额
  1744. if (warehousebillsfees == null) {
  1745. map.put("message", "费用明细数据有误,请找管理员");
  1746. } else if ("DZ".equals(type) || "KHDZ".equals(type)) {
  1747. BigDecimal subtract = amount.subtract(accamount);
  1748. if (subtract.compareTo(money) < 0) {
  1749. flag = false;
  1750. map.put("message", tFees.getfName() + "对账金额超过可对账金额,当前可对账金额为" + subtract + "元");
  1751. }
  1752. } else if ("SF".equals(type) || "KHSF".equals(type)) {
  1753. BigDecimal subtract = amount.subtract(stlamount);
  1754. if (subtract.compareTo(money) < 0) {
  1755. flag = false;
  1756. map.put("message", tFees.getfName() + "收费金额超过可收费金额,当前可对账金额为" + subtract + "元");
  1757. }
  1758. } else if ("FF".equals(type) || "KHFF".equals(type)) {
  1759. BigDecimal subtract = amount.subtract(stlamount);
  1760. if (subtract.compareTo(money) < 0) {
  1761. flag = false;
  1762. map.put("message", tFees.getfName() + "付费金额超过可付费金额,当前可对账金额为" + subtract + "元");
  1763. }
  1764. } else if ("ApplyFP".equals(type)) {
  1765. BigDecimal subtract = amount.subtract(askamount);
  1766. if (subtract.compareTo(money) < 0) {
  1767. flag = false;
  1768. map.put("message", tFees.getfName() + "开票金额超过可开票金额,当前可对账金额为" + subtract + "元");
  1769. }
  1770. } else if ("invoiceFP".equals(type)) {
  1771. BigDecimal subtract = amount.subtract(invamount);
  1772. if (subtract.compareTo(money) < 0) {
  1773. flag = false;
  1774. map.put("message", tFees.getfName() + "开票金额超过可开票金额,当前可对账金额为" + subtract + "元");
  1775. }
  1776. }
  1777. map.put("flag", flag);
  1778. return map;
  1779. }
  1780. /**
  1781. * 申请发票审核成功复制数据到销项发票中
  1782. *
  1783. * @param fId 主表id
  1784. * @param fBilltype 类型
  1785. * @return
  1786. */
  1787. @Transactional
  1788. public AjaxResult copyInvoiceFp(Long fId, String fBilltype) {
  1789. //查询费用主表信息复制主表信息
  1790. Integer insert = null;
  1791. TFee fee = tFeeMapper.selectTFeeById(fId);
  1792. TFee tFee = new TFee();
  1793. tFee.setfId(fee.getfId());
  1794. Date time = new Date();
  1795. String billNo = billnoSerialServiceImpl.getBillNo(fBilltype, time);
  1796. //查询费用从表信息复制主表信息
  1797. fee.setfAccountId(fee.getfId());
  1798. fee.setfBillno(billNo);
  1799. fee.setfBilltype(fBilltype);
  1800. fee.setfId(null);
  1801. insert = tFeeMapper.insertTFee(fee);
  1802. tFee.setfMake(1);
  1803. //修改原发票数据代表已开销项发票
  1804. insert = tFeeMapper.updateTFee(tFee);
  1805. TFeeDo tFeeDo = new TFeeDo();
  1806. tFeeDo.setfPid(fId);
  1807. List<TFeeDo> tFeeDoList = tFeeDoMapper.selectTFeeDoList(tFeeDo);
  1808. if (CollectionUtils.isNotEmpty(tFeeDoList)) {
  1809. for (TFeeDo feeDo : tFeeDoList) {
  1810. feeDo.setfId(null);
  1811. feeDo.setfPid(fee.getfId());
  1812. feeDo.setfBilltype(fBilltype);
  1813. insert = tFeeDoMapper.insertTFeeDo(feeDo);
  1814. }
  1815. }
  1816. //查询开票信息复制主表信息
  1817. TFeeInvoice tFeeInvoice = new TFeeInvoice();
  1818. tFeeInvoice.setfPid(fId);
  1819. List<TFeeInvoice> tFeeInvoiceList = tFeeInvoiceMapper.selectTFeeInvoiceList(tFeeInvoice);
  1820. if (CollectionUtils.isNotEmpty(tFeeInvoiceList)) {
  1821. for (TFeeInvoice invoice : tFeeInvoiceList) {
  1822. invoice.setfId(null);
  1823. invoice.setfPid(fee.getfId());
  1824. insert = tFeeInvoiceMapper.insertTFeeInvoice(invoice);
  1825. }
  1826. }
  1827. if (insert != null && insert > 0) {
  1828. return AjaxResult.success();
  1829. } else {
  1830. return AjaxResult.error("生成销项发票失败,请找管理员");
  1831. }
  1832. }
  1833. /**
  1834. * 导出财务对账数据
  1835. *
  1836. * @param fId
  1837. * @return
  1838. */
  1839. @Override
  1840. public AjaxResult exportFinancial(Long fId) {
  1841. //获取数据
  1842. String shipsName = "";//船名
  1843. String voyage = "";//航次
  1844. String corpName = "";//客户
  1845. String fFromDate = "";//离港日期开始
  1846. String fToDate = "";//离港日期结束
  1847. BigDecimal fAmount = new BigDecimal(0);//合计
  1848. //查询财务主数据
  1849. SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
  1850. TFee fee = tFeeMapper.selectTFeeById(fId);
  1851. if (fee != null) {
  1852. corpName = fee.getfCtrlcorpid();
  1853. if (fee.getfFromDate() != null) {
  1854. fFromDate = simpleDateFormat.format(fee.getfFromDate());
  1855. }
  1856. if (fee.getfToDate() != null) {
  1857. fToDate = simpleDateFormat.format(fee.getfToDate());
  1858. }
  1859. if (fee.getfVslid() != null) {
  1860. TVessel vessel = tVesselMapper.selectTVesselById(fee.getfVslid());
  1861. if (vessel != null && StringUtils.isNotEmpty(vessel.getfName())) {
  1862. shipsName = vessel.getfName();
  1863. }
  1864. }
  1865. if (fee.getfVoyid() != null) {
  1866. TVoyage tVoyage = tVoyageMapper.selectTVoyageById(fee.getfVoyid());
  1867. if (tVoyage != null && StringUtils.isNotEmpty(tVoyage.getfNo())) {
  1868. voyage = tVoyage.getfNo();
  1869. }
  1870. }
  1871. }
  1872. //样式设置
  1873. //1.创建一个workbook,对应一个excel文件
  1874. HSSFWorkbook wb = new HSSFWorkbook();
  1875. //2.在workbook中添加一个sheet,对应Excel中的sheet
  1876. HSSFSheet sheet = wb.createSheet("对账");
  1877. //设置每一列的列宽
  1878. sheet.setColumnWidth(0, 256 * 15);
  1879. sheet.setColumnWidth(1, 256 * 20);
  1880. sheet.setColumnWidth(2, 256 * 20);
  1881. sheet.setColumnWidth(3, 256 * 20);
  1882. sheet.setColumnWidth(4, 256 * 15);
  1883. sheet.setColumnWidth(5, 256 * 15);
  1884. sheet.setColumnWidth(6, 256 * 15);
  1885. sheet.setColumnWidth(7, 100 * 35);
  1886. sheet.setColumnWidth(8, 256 * 15);
  1887. sheet.setColumnWidth(9, 256 * 15);
  1888. //3.设置样式以及字体样式
  1889. HSSFCellStyle titleStyle = ExcelUtils.createTitleCellStyle(wb);
  1890. HSSFCellStyle contentStyle = ExcelUtils.createContentCellStyle(wb);
  1891. HSSFCellStyle subheadingStyle = ExcelUtils.createSubheadingStyle(wb);
  1892. HSSFCellStyle endStyle = ExcelUtils.createEndStyle(wb);
  1893. //4.创建标题,合并标题单元格
  1894. //行号
  1895. int rowNum = 0;
  1896. //创建第一行,索引从0开始(标题行)
  1897. HSSFRow row0 = sheet.createRow(rowNum++);
  1898. row0.setHeight((short) 800);// 设置行高
  1899. for (int i = 0; i < 10; i++) {
  1900. HSSFCell tempCell = row0.createCell(i);
  1901. tempCell.setCellStyle(contentStyle);
  1902. }
  1903. String title = "青岛凯和志诚物流有限公司";
  1904. HSSFCell c00 = row0.createCell(0);
  1905. c00.setCellValue(title);
  1906. c00.setCellStyle(titleStyle);
  1907. // 合并单元格,参数依次为起始行,结束行,起始列,结束列 (索引0开始)
  1908. sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, 9));//标题合并单元格操作,总列数为9
  1909. //第2行
  1910. HSSFRow row1 = sheet.createRow(rowNum++);
  1911. row1.setHeight((short) 500);
  1912. String message1 = "客户确认单";
  1913. for (int i = 0; i < 10; i++) {
  1914. HSSFCell tempCell = row1.createCell(i);
  1915. tempCell.setCellStyle(contentStyle);
  1916. }
  1917. HSSFCell c01 = row1.createCell(0);
  1918. c01.setCellValue(message1);
  1919. c01.setCellStyle(subheadingStyle);
  1920. sheet.addMergedRegion(new CellRangeAddress(1, 1, 0, 9));//标题合并单元格操作,总列数为9
  1921. //第3行
  1922. HSSFRow row2 = sheet.createRow(rowNum++);
  1923. row2.setHeight((short) 500);
  1924. String message2 = "尊敬的客户";
  1925. HSSFCell c02 = row2.createCell(0);
  1926. c02.setCellValue(message2);
  1927. c02.setCellStyle(contentStyle);
  1928. //第3行
  1929. for (int i = 1; i < 10; i++) {
  1930. HSSFCell tempCell = row2.createCell(i);
  1931. tempCell.setCellStyle(contentStyle);
  1932. }
  1933. HSSFCell c03 = row2.createCell(1);
  1934. c03.setCellValue(corpName);
  1935. c03.setCellStyle(contentStyle);
  1936. sheet.addMergedRegion(new CellRangeAddress(2, 2, 1, 9));//标题合并单元格操作,总列数为9
  1937. //合并单元格
  1938. sheet.addMergedRegion(new CellRangeAddress(3, 3, 1, 2));
  1939. sheet.addMergedRegion(new CellRangeAddress(3, 3, 3, 4));
  1940. sheet.addMergedRegion(new CellRangeAddress(3, 3, 5, 9));
  1941. //第4行
  1942. HSSFRow row3 = sheet.createRow(rowNum++);
  1943. for (int i = 0; i < 1; i++) {
  1944. HSSFCell tempCell = row3.createCell(i);
  1945. tempCell.setCellStyle(contentStyle);
  1946. }
  1947. for (int i = 1; i < 3; i++) {
  1948. HSSFCell tempCell = row3.createCell(i);
  1949. tempCell.setCellStyle(contentStyle);
  1950. }
  1951. for (int i = 3; i < 5; i++) {
  1952. HSSFCell tempCell = row3.createCell(i);
  1953. tempCell.setCellStyle(contentStyle);
  1954. }
  1955. for (int i = 5; i < 10; i++) {
  1956. HSSFCell tempCell = row3.createCell(i);
  1957. tempCell.setCellStyle(contentStyle);
  1958. }
  1959. row3.setHeight((short) 500);
  1960. HSSFCell c05 = row3.createCell(0);
  1961. c05.setCellValue("船名航次:");
  1962. c05.setCellStyle(contentStyle);
  1963. HSSFCell c051 = row3.createCell(1);
  1964. c051.setCellValue(shipsName + voyage);
  1965. c051.setCellStyle(contentStyle);
  1966. HSSFCell c052 = row3.createCell(3);
  1967. c052.setCellValue("离港日期:");
  1968. c052.setCellStyle(contentStyle);
  1969. String message = "";
  1970. HSSFCell c053 = row3.createCell(5);
  1971. if (StringUtils.isNotEmpty(fFromDate)) {
  1972. if (StringUtils.isNotEmpty(fFromDate)) {
  1973. message = fFromDate + "-" + fToDate;
  1974. } else {
  1975. message = fFromDate;
  1976. }
  1977. } else if (StringUtils.isNotEmpty(fToDate)) {
  1978. message = fToDate;
  1979. }
  1980. c053.setCellValue(message);
  1981. c053.setCellStyle(contentStyle);
  1982. //第5行
  1983. HSSFRow row4 = sheet.createRow(rowNum++);
  1984. for (int i = 0; i < 10; i++) {
  1985. HSSFCell tempCell = row4.createCell(i);
  1986. tempCell.setCellStyle(contentStyle);
  1987. }
  1988. row4.setHeight((short) 500);
  1989. String message4 = "费用明细";
  1990. HSSFCell c04 = row4.createCell(0);
  1991. c04.setCellValue(message4);
  1992. c04.setCellStyle(contentStyle);
  1993. sheet.addMergedRegion(new CellRangeAddress(4, 4, 0, 9));//标题合并单元格操作,总列数为9
  1994. //第四行
  1995. HSSFRow row5 = sheet.createRow(rowNum++);
  1996. row5.setHeight((short) 500);
  1997. String[] row_third = {"序号", "提单号", "始发港", "目的港", "运输条款", "货名", "箱量", "规格", "单价", "合计"};
  1998. for (int i = 0; i < row_third.length; i++) {
  1999. HSSFCell tempCell = row5.createCell(i);
  2000. tempCell.setCellValue(row_third[i]);
  2001. tempCell.setCellStyle(contentStyle);
  2002. }
  2003. //查询费用明细数据
  2004. List<ExportFinancial> list = tFeeMapper.exportFinancial(fId);
  2005. if (CollectionUtils.isNotEmpty(list)) {
  2006. for (int i = 0; i < list.size(); i++) {
  2007. HSSFRow tempRow = sheet.createRow(rowNum++);
  2008. tempRow.setHeight((short) 500);
  2009. //循环单元格填入数据
  2010. for (int j = 0; j < 10; j++) {
  2011. HSSFCell tempCell = tempRow.createCell(j);
  2012. tempCell.setCellStyle(contentStyle);
  2013. String cellValue = "";
  2014. if (j == 0) {
  2015. //序号
  2016. cellValue = list.get(i).getRankNo().toString();
  2017. } else if (j == 1) {
  2018. //提单号
  2019. cellValue = list.get(i).getfMblNo();
  2020. } else if (j == 2) {
  2021. //始发港
  2022. cellValue = list.get(i).getPortOfDeparture();
  2023. } else if (j == 3) {
  2024. //目的港
  2025. cellValue = list.get(i).getDestinationPort();
  2026. } else if (j == 4) {
  2027. //运输条款
  2028. cellValue = list.get(i).getfServiceitems()+"-"+list.get(i).getfServiceitemsNew();
  2029. } else if (j == 5) {
  2030. //货名
  2031. cellValue = list.get(i).getGoodName();
  2032. } else if (j == 6) {
  2033. //箱量
  2034. cellValue = list.get(i).getfCnTrCount().toString();
  2035. } else if (j == 7) {
  2036. //规格
  2037. cellValue = list.get(i).getSpecification();
  2038. } else if (j == 8) {
  2039. //单价
  2040. cellValue = list.get(i).getfUnitPrice().toString();
  2041. } else if (j == 9) {
  2042. //合计
  2043. cellValue = list.get(i).getfAmount().toString();
  2044. }
  2045. tempCell.setCellValue(cellValue);
  2046. }
  2047. }
  2048. fAmount = list.stream().map(ExportFinancial::getfAmount).reduce(BigDecimal.ZERO, BigDecimal::add);//求所有和的合计
  2049. }
  2050. //倒数第二行
  2051. HSSFRow row6 = sheet.createRow(rowNum++);
  2052. for (int i = 0; i < 10; i++) {
  2053. HSSFCell tempCell = row6.createCell(i);
  2054. tempCell.setCellStyle(contentStyle);
  2055. }
  2056. row6.setHeight((short) 500);
  2057. String message6 = "合计:";
  2058. HSSFCell c06 = row6.createCell(0);
  2059. c06.setCellValue(message6);
  2060. c06.setCellStyle(contentStyle);
  2061. HSSFCell c061 = row6.createCell(9);
  2062. c061.setCellValue(fAmount.toString());
  2063. c061.setCellStyle(contentStyle);
  2064. //最后一行
  2065. HSSFRow row7 = sheet.createRow(rowNum++);
  2066. for (int i = 0; i < 10; i++) {
  2067. HSSFCell tempCell = row7.createCell(i);
  2068. tempCell.setCellStyle(contentStyle);
  2069. }
  2070. row7.setHeight((short) 1500);
  2071. String message7 = "纳税人识别号:91370202MA3UG1T04A\n" +
  2072. "人民币账号:3803020309100171855\n" +
  2073. "人民币开户行:工商银行青岛分行营业部";
  2074. HSSFCell c07 = row7.createCell(0);
  2075. c07.setCellValue(message7);
  2076. c07.setCellStyle(endStyle);
  2077. sheet.addMergedRegion(new CellRangeAddress(rowNum - 1, rowNum - 1, 0, 9));//标题合并单元格操作,总列数为9
  2078. //导出excel
  2079. String fileName = "客户对账单.xls";
  2080. try {
  2081. OutputStream out = null;
  2082. out = new FileOutputStream(getAbsoluteFile(fileName));
  2083. wb.write(out);
  2084. if (null != wb && null != out) {
  2085. wb.write(out);
  2086. wb.close();
  2087. out.close();
  2088. }
  2089. return AjaxResult.success(fileName);
  2090. } catch (Exception e) {
  2091. e.printStackTrace();
  2092. return AjaxResult.error("导出Excel失败");
  2093. }
  2094. }
  2095. /**
  2096. * 根据结算单位、费用状态、审核日期查询应付总帐明细
  2097. *
  2098. * @param feeDTO
  2099. * @return
  2100. */
  2101. @Override
  2102. public AjaxResult financialLedgerDetails(FeeDTO feeDTO) {
  2103. TFees ccf = tFeesMapper.seletFeesByCCF();
  2104. if (Objects.isNull(ccf)) {
  2105. throw new WarehouseException("未找到仓储费费用信息");
  2106. }
  2107. feeDTO.setFeesId(ccf.getfId());
  2108. List<FeeVO> feeVOList = tFeeMapper.selectFinancialLedgerDetails(feeDTO);
  2109. if (CollectionUtils.isNotEmpty(feeVOList)) {
  2110. List<FeeVO> voList = new ArrayList<>();
  2111. Map<Long, List<FeeVO>> map = feeVOList.stream().collect(Collectors.groupingBy(FeeVO::getFSrcpid));
  2112. map.forEach((key, value) -> {
  2113. FeeVO vo = new FeeVO();
  2114. FeeVO feeVO = value.stream().findFirst().orElseThrow(() ->
  2115. new WarehouseException("获取费用异常"));
  2116. BeanUtils.copyProperties(feeVO, vo);
  2117. // 仓储费
  2118. BigDecimal storageFee = value.stream().map(FeeVO::getStorageFee).reduce(BigDecimal::add).orElse(BigDecimal.ZERO);
  2119. // 其他费用
  2120. BigDecimal otherFee = value.stream().map(FeeVO::getOtherFee).reduce(BigDecimal::add).orElse(BigDecimal.ZERO);
  2121. // 应收费用
  2122. BigDecimal amount = value.stream().map(FeeVO::getFAmount).reduce(BigDecimal::add).orElse(BigDecimal.ZERO);
  2123. // 已收费用
  2124. BigDecimal stlamount = value.stream().map(FeeVO::getFStlamount).reduce(BigDecimal::add).orElse(BigDecimal.ZERO);
  2125. WarehouseTypeEnum storageType = WarehouseTypeEnum.fromTypeAndBusinessType(vo.getfBilltype(), "storageType");
  2126. vo.setfBilltype(storageType.getName());
  2127. vo.setStorageFee(storageFee);
  2128. vo.setFStlamount(stlamount);
  2129. vo.setOtherFee(otherFee);
  2130. vo.setFAmount(amount);
  2131. vo.setNnfinished(amount.subtract(stlamount));
  2132. voList.add(vo);
  2133. });
  2134. return AjaxResult.success(voList);
  2135. }
  2136. return AjaxResult.success(feeVOList);
  2137. }
  2138. /**
  2139. * 查询应付总帐明细
  2140. *
  2141. * @param feeDTO
  2142. * @return
  2143. */
  2144. @Override
  2145. public List<GeneralLedgerDetailExcel> financialLedgerDetailsExport(FeeDTO feeDTO) {
  2146. List<GeneralLedgerDetailExcel> detailExcelList = new ArrayList<>();
  2147. List<FeeVO> feeVOList = tFeeMapper.selectFinancialLedgerDetails(feeDTO);
  2148. feeVOList.forEach(vo -> {
  2149. GeneralLedgerDetailExcel detailExcel = new GeneralLedgerDetailExcel();
  2150. WarehouseTypeEnum storageType = WarehouseTypeEnum.fromTypeAndBusinessType(vo.getfBilltype(), "storageType");
  2151. detailExcel.setFMblno(vo.getFMblno());
  2152. detailExcel.setFMarks(vo.getFMarks());
  2153. detailExcel.setFAmount(vo.getFAmount());
  2154. detailExcel.setOtherFee(vo.getOtherFee());
  2155. detailExcel.setFFeesName(vo.getFFeesName());
  2156. detailExcel.setNnfinished(vo.getNnfinished());
  2157. detailExcel.setFStlamount(vo.getFStlamount());
  2158. detailExcel.setStorageFee(vo.getStorageFee());
  2159. detailExcel.setFBilltype(storageType.getName());
  2160. detailExcel.setFProductName(vo.getFProductName());
  2161. detailExcel.setFProductName(vo.getFProductName());
  2162. detailExcelList.add(detailExcel);
  2163. });
  2164. return detailExcelList;
  2165. }
  2166. @Override
  2167. public List<ReceivableExcel> receivable(TWareHouseFees tWareHouseFees) {
  2168. return tFeeMapper.receivable(tWareHouseFees);
  2169. }
  2170. @Override
  2171. public List<ProfitExcel> profit(TWareHouseFees tWareHouseFees) {
  2172. return tFeeMapper.profit(tWareHouseFees);
  2173. }
  2174. @Override
  2175. public List<HandleExcel> handle(TWareHouseFees tWareHouseFees) {
  2176. return tFeeMapper.handle(tWareHouseFees);
  2177. }
  2178. //下载路径
  2179. private String getAbsoluteFile(String fileName) {
  2180. String downloadPath = RuoYiConfig.getDownloadPath() + fileName;
  2181. File desc = new File(downloadPath);
  2182. if (!desc.getParentFile().exists()) {
  2183. desc.getParentFile().mkdirs();
  2184. }
  2185. return downloadPath;
  2186. }
  2187. }