12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558 |
- package com.ruoyi.finance.service.impl;
- import com.alibaba.fastjson.JSONArray;
- import com.alibaba.fastjson.JSONObject;
- import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
- import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
- import com.ruoyi.approvalFlow.domain.AuditItems;
- import com.ruoyi.approvalFlow.service.impl.AuditItemsAbout;
- import com.ruoyi.approvalFlow.service.impl.AuditItemsServiceImpl;
- import com.ruoyi.basicData.domain.TCorps;
- import com.ruoyi.basicData.domain.TFees;
- import com.ruoyi.basicData.mapper.TCorpsMapper;
- import com.ruoyi.basicData.mapper.TFeesMapper;
- import com.ruoyi.common.config.RuoYiConfig;
- import com.ruoyi.common.core.domain.AjaxResult;
- import com.ruoyi.common.core.domain.entity.SysDictData;
- import com.ruoyi.common.core.domain.model.LoginUser;
- import com.ruoyi.common.exception.WarehouseException;
- import com.ruoyi.common.utils.DateUtils;
- import com.ruoyi.common.utils.DictUtils;
- import com.ruoyi.common.utils.StringUtils;
- import com.ruoyi.common.utils.poi.ExcelUtils;
- import com.ruoyi.finance.domain.TFee;
- import com.ruoyi.finance.domain.TFeeDo;
- import com.ruoyi.finance.domain.TWareHouseFees;
- import com.ruoyi.finance.domain.dto.FeeDTO;
- import com.ruoyi.finance.domain.excel.GeneralLedgerDetailExcel;
- import com.ruoyi.finance.domain.excel.GeneralLedgerDetailTotalExcel;
- import com.ruoyi.finance.domain.excel.GeneralLedgerExcel;
- import com.ruoyi.finance.domain.excel.ProfitGeneralLedgerExcel;
- import com.ruoyi.finance.domain.vo.FeeVO;
- import com.ruoyi.finance.excel.Charge;
- import com.ruoyi.finance.excel.Contrast;
- import com.ruoyi.finance.excel.Detailed;
- import com.ruoyi.finance.excel.Payment;
- import com.ruoyi.finance.mapper.TFeeDoMapper;
- import com.ruoyi.finance.mapper.TFeeMapper;
- import com.ruoyi.finance.service.ITFeeService;
- import com.ruoyi.finance.shipping.*;
- import com.ruoyi.reportManagement.dto.TWarehousebill;
- import com.ruoyi.reportManagement.excel.Profit;
- import com.ruoyi.reportManagement.excel.Receivable;
- import com.ruoyi.shipping.domain.TAccount;
- import com.ruoyi.shipping.domain.TFeeInvoice;
- import com.ruoyi.shipping.domain.TVessel;
- import com.ruoyi.shipping.domain.TVoyage;
- import com.ruoyi.shipping.excel.Account;
- import com.ruoyi.shipping.excel.ExportFinancial;
- import com.ruoyi.shipping.mapper.TFeeInvoiceMapper;
- import com.ruoyi.shipping.mapper.TVesselMapper;
- import com.ruoyi.shipping.mapper.TVoyageMapper;
- import com.ruoyi.system.domain.SysConfig;
- import com.ruoyi.system.mapper.SysConfigMapper;
- import com.ruoyi.system.mapper.SysDictDataMapper;
- import com.ruoyi.system.service.ISysDictDataService;
- import com.ruoyi.warehouseBusiness.domain.BillnoDel;
- import com.ruoyi.warehouseBusiness.domain.TWarehouseBills;
- import com.ruoyi.warehouseBusiness.domain.TWarehousebillsfees;
- import com.ruoyi.warehouseBusiness.domain.enums.FeesTypeEnum;
- import com.ruoyi.warehouseBusiness.domain.enums.WarehouseTypeEnum;
- import com.ruoyi.warehouseBusiness.excel.ListMapToBeanUtils;
- import com.ruoyi.warehouseBusiness.excel.TWareHouseExcelItem;
- import com.ruoyi.warehouseBusiness.mapper.BillnoDelMapper;
- import com.ruoyi.warehouseBusiness.mapper.TWarehouseBillsMapper;
- import com.ruoyi.warehouseBusiness.mapper.TWarehousebillsfeesMapper;
- import com.ruoyi.warehouseBusiness.service.impl.BillnoSerialServiceImpl;
- import org.apache.commons.compress.utils.Lists;
- import org.apache.poi.hssf.usermodel.*;
- import org.apache.poi.ss.util.CellRangeAddress;
- import org.springframework.beans.BeanUtils;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Service;
- import org.springframework.transaction.annotation.Transactional;
- import org.springframework.transaction.interceptor.TransactionAspectSupport;
- import java.io.File;
- import java.io.FileOutputStream;
- import java.io.OutputStream;
- import java.math.BigDecimal;
- import java.text.SimpleDateFormat;
- import java.util.*;
- import java.util.stream.Collectors;
- import static java.util.stream.Collectors.toList;
- /**
- * 财务数据主Service业务层处理
- *
- * @author ruoyi
- * @date 2021-01-18
- */
- @Service
- public class TFeeServiceImpl implements ITFeeService {
- @Autowired
- private TFeeMapper tFeeMapper;
- @Autowired
- private TFeeDoMapper tFeeDoMapper;
- @Autowired
- private BillnoSerialServiceImpl billnoSerialServiceImpl;
- @Autowired
- private BillnoDelMapper billnoDelMapper;
- @Autowired
- private TCorpsMapper tCorpsMapper;
- @Autowired
- private TFeesMapper tFeesMapper;
- @Autowired
- private TWarehouseBillsMapper tWarehouseBillsMapper;
- @Autowired
- private TWarehousebillsfeesMapper tWarehousebillsfeesMapper;
- @Autowired
- private SysConfigMapper sysConfigMapper;
- @Autowired
- private AuditItemsServiceImpl auditItemsService;
- @Autowired
- private ISysDictDataService iSysDictDataService;
- @Autowired
- private SysDictDataMapper sysDictDataMapper;
- @Autowired
- private TFeeInvoiceMapper tFeeInvoiceMapper;
- @Autowired
- private TVesselMapper tVesselMapper;
- @Autowired
- private TVoyageMapper tVoyageMapper;
- private final String ST_IN_TYPE = "st_in_type";
- private final String ST_OUT_TYPE = "st_out_type";
- private final String ST_TRANS_TYPE = "st_trans_type";
- /**
- * 查询财务数据主
- *
- * @param fId 财务数据主ID
- * @return 财务数据主
- */
- @Override
- public Map<String, Object> selectTFeeById(Long fId) {
- Map<String, Object> map = new HashMap<>();
- // 客户表
- List<Long> corpsId = new ArrayList<>();
- // 费用
- List<Long> feesId = new ArrayList<>();
- //费用名称
- String feeName = null;
- TFee tFee = tFeeMapper.selectTFeeById(fId);
- if (StringUtils.isNotNull(tFee.getfCorpid())) {
- corpsId.add(tFee.getfCorpid());
- }
- corpsId.add(tFee.getfCorpid());
- // 查询从表数据
- TFeeDo tFeeDo = new TFeeDo();
- tFeeDo.setfPid(fId);
- List<TFeeDo> tFeeDoList = tFeeDoMapper.selectTFeeDoList(tFeeDo);
- List<Map<String, Object>> feeDoList = new ArrayList<>();
- if (StringUtils.isNotEmpty(tFeeDoList)) {
- for (TFeeDo fees : tFeeDoList) {
- Map<String, Object> map1 = new HashMap<>();
- feesId.add(fees.getfFeeid());
- // 查询主表
- TWarehouseBills tWarehousebills = tWarehouseBillsMapper.selectTWarehousebillsById(fees.getfSrcpid());
- if (Objects.isNull(tWarehousebills)) {
- throw new WarehouseException("未找到仓储信息");
- }
- // 费用名称
- TFees tFees = tFeesMapper.selectTFeesById(fees.getfFeeid());
- if (tFees != null) {
- feeName = tFees.getfName();
- }
- // 费用表数据
- TWarehousebillsfees tWarehousebillsfees = tWarehousebillsfeesMapper.selectTWarehousebillsfeesById(fees.getfSrcid());
- if (tWarehousebillsfees == null) {
- return AjaxResult.error("费用数据为空,请确认");
- }
- // 字典宝
- SysDictData sysDictData = new SysDictData();
- sysDictData.setDictType("data_unitfees");
- sysDictData.setDictValue(String.valueOf(tWarehousebillsfees.getfFeeunitid()));
- sysDictData.setStatus("0");
- List<SysDictData> sysDictDataList = iSysDictDataService.selectDictDataList(sysDictData);
- List<SysDictData> sysDictDataListIn = new ArrayList<>();
- if (StringUtils.isNotEmpty(tWarehousebillsfees.getfBilltype()) && tWarehousebillsfees.getfBilltype().equals("SJRK")) {
- sysDictData.setDictType(ST_IN_TYPE);
- sysDictData.setDictValue(String.valueOf(tWarehousebillsfees.getfBusinessType()));
- sysDictData.setStatus("0");
- sysDictDataListIn = iSysDictDataService.selectDictDataList(sysDictData);
- } else if (StringUtils.isNotEmpty(tWarehousebillsfees.getfBilltype()) && tWarehousebillsfees.getfBilltype().equals("SJCK")) {
- sysDictData.setDictType(ST_OUT_TYPE);
- sysDictData.setDictValue(String.valueOf(tWarehousebillsfees.getfBusinessType()));
- sysDictData.setStatus("0");
- sysDictDataListIn = iSysDictDataService.selectDictDataList(sysDictData);
- } else if (StringUtils.isNotEmpty(tWarehousebillsfees.getfBilltype()) && tWarehousebillsfees.getfBilltype().equals("CKDB") | tWarehousebillsfees.getfBilltype().equals("HWTG")) {
- sysDictData.setDictType(ST_TRANS_TYPE);
- sysDictData.setDictValue(String.valueOf(tWarehousebillsfees.getfBusinessType()));
- sysDictData.setStatus("0");
- sysDictDataListIn = iSysDictDataService.selectDictDataList(sysDictData);
- }
- // 之前遗留汉字特别处理
- FeesTypeEnum feesTypeEnum;
- if (fees.getfSrcdc().equals("收")) {
- feesTypeEnum = FeesTypeEnum.D;
- } else if (fees.getfSrcdc().equals("付")) {
- feesTypeEnum = FeesTypeEnum.C;
- } else {
- feesTypeEnum = FeesTypeEnum.fromType(fees.getfSrcdc());
- }
- map1.put("fSrcdcName", feesTypeEnum.getName());
- map1.put("fId", fees.getfId());
- map1.put("fSrcid", fees.getfSrcid());
- map1.put("fSrcpid", fees.getfSrcpid());
- map1.put("fMblno", tWarehousebillsfees.getfMblno());
- map1.put("fBscorpno", tWarehousebills.getfBscorpno());
- map1.put("fProductName", tWarehousebillsfees.getfProductName());
- map1.put("fBsdate", tWarehousebillsfees.getfBsdate());
- map1.put("fFeeid", fees.getfFeeid());
- map1.put("fFeeName", feeName);
- map1.put("fSrcdc", fees.getfSrcdc());
- map1.put("fAmt", fees.getfAmt());
- map1.put("fAmtdr", fees.getfAmtdr());
- map1.put("fRemarks", fees.getfRemarks());
- map1.put("srcBillNo", tWarehousebillsfees.getSrcId());
- map1.put("fMarks", tWarehousebillsfees.getfMarks());
- map1.put("fChargedate", tWarehousebillsfees.getfChargedate());
- map1.put("fBillingDeadline", tWarehousebillsfees.getfBillingDeadline());
- map1.put("fBillingDays", tWarehousebillsfees.getfBillingDays());
- map1.put("fInventoryDays", tWarehousebillsfees.getfInventoryDays());
- map1.put("fFeeunitid", sysDictDataList.get(0).getDictLabel());
- map1.put("fQty", tWarehousebillsfees.getfQty());
- map1.put("fUnitprice", tWarehousebillsfees.getfUnitprice());
- map1.put("fBillno", fees.getfSrcBillno());// 业务编号(单据编号)
- map1.put("invoiceNo", fees.getfInvoiceNo());// 发票号
- map1.put("fTaxrate", tWarehousebillsfees.getfTaxrateStr());// 税率--传递字符串数据
- if (StringUtils.isNotEmpty(tWarehousebillsfees.getfBilltype()) && tWarehousebillsfees.getfBilltype().equals("KHDD")) {
- map1.put("fBusinessType", "船运订单");
- } else if (CollectionUtils.isNotEmpty(sysDictDataListIn)) {
- map1.put("fBusinessType", sysDictDataListIn.get(0).getDictLabel());
- }
- if (StringUtils.isNotEmpty(tWarehousebills.getfBilltype()) && tWarehousebills.getfBilltype().equals("SJRK")) {
- map1.put("fBilltype", "入库");
- } else if (StringUtils.isNotEmpty(tWarehousebills.getfBilltype()) && tWarehousebills.getfBilltype().equals("SJCK")) {
- map1.put("fBilltype", "出库");
- } else if (StringUtils.isNotEmpty(tWarehousebills.getfBilltype()) && tWarehousebills.getfBilltype().equals("CKDB")) {
- map1.put("fBilltype", "调拨");
- } else if (StringUtils.isNotEmpty(tWarehousebills.getfBilltype()) && tWarehousebills.getfBilltype().equals("HWTG")) {
- map1.put("fBilltype", "货物通关");
- } else if (StringUtils.isNotEmpty(tWarehousebills.getfBilltype()) && tWarehousebills.getfBilltype().equals("HQZY")) {
- map1.put("fBilltype", "货权转移");
- } else if (StringUtils.isNotEmpty(tWarehousebills.getfBilltype()) && tWarehousebills.getfBilltype().equals("KHDD")) {
- map1.put("fBilltype", "船运订单");
- }
- feeDoList.add(map1);
- }
- }
- List<TCorps> corpsList = new ArrayList<>();
- List<Long> corpsIdList = StringUtils.integerDeduplication(corpsId);
- for (Long corpId : corpsIdList) {
- TCorps corps = tCorpsMapper.selectTCorpsById(corpId);
- if (StringUtils.isNotNull(corps)) {
- corpsList.add(corps);
- }
- }
- List<TFees> feesList = new ArrayList<>();
- List<Long> longList = StringUtils.integerDeduplication(feesId);
- for (Long fees : longList) {
- TFees tFees = tFeesMapper.selectTFeesById(fees);
- if (StringUtils.isNotNull(tFees)) {
- feesList.add(tFees);
- }
- }
- map.put("tFee", tFee);
- map.put("corps", corpsList);
- map.put("feesList", feesList);
- map.put("feeDoList", feeDoList);
- return map;
- }
- @Override
- public Map<String, Object> selectTFeeByIdNew(Long fId) {
- Map<String, Object> map = new HashMap<>();
- TFee tFee = tFeeMapper.selectTFeeByIdNew(fId);
- List<TFeeDo> feeDoList = tFeeDoMapper.selectTFeeDoByfPid(fId);
- TFeeInvoice tFeeInvoice = new TFeeInvoice();
- tFeeInvoice.setfPid(fId);
- List<TFeeInvoice> tFeeInvoiceList = tFeeInvoiceMapper.selectTFeeInvoiceList(tFeeInvoice);
- map.put("tFee", tFee);
- map.put("feeDoList", feeDoList);
- map.put("tFeeInvoiceList", tFeeInvoiceList);
- return map;
- }
- /**
- * 查询财务数据主列表
- *
- * @param tFee 财务数据主
- * @return 财务数据主
- */
- @Override
- public List<TFee> selectTFeeList(TFee tFee) {
- List<TFee> list = tFeeMapper.selectTFeeList(tFee);
- for (TFee tf : list) {
- List<TFeeDo> fd = tFeeDoMapper.selectTFeeDoByfPid(tf.getfId());
- StringBuilder strb = new StringBuilder();
- for (TFeeDo tFeeDo : fd) {
- if (StringUtils.isNotNull(tFeeDo.getfSrcBillno())) {
- strb.append(tFeeDo.getfSrcBillno()).append(",");
- }
- }
- tf.setfSrcBillno(StringUtils.objToStr(StringUtils.removeTheLastComma(strb)));
- }
- return list;
- }
- @Override
- public List<Map<String, Object>> selectTFeeList1(TFee tFee) {
- List<Map<String, Object>> list = tFeeMapper.selectTFeeList1(tFee);
- for (Map<String, Object> map : list) {
- List<TFeeDo> tfd = tFeeDoMapper.selectTFeeDoByfPid(Long.valueOf(map.get("fId").toString()));
- if (tfd.size() != 0) {
- StringBuilder stringBuilder = new StringBuilder();
- for (TFeeDo tFeeDo : tfd) {
- if (StringUtils.isNotNull(tFeeDo.getfSrcBillno())) {
- stringBuilder.append(tFeeDo.getfSrcBillno()).append(",");
- }
- }
- map.put("fSrcBillno", StringUtils.removeTheLastComma(stringBuilder));
- }
- }
- return list;
- }
- @Override
- public List<Map<String, Object>> webVersionTFee(TFee tFee) {
- return tFeeMapper.webVersionTFee(tFee);
- }
- @Override
- public List<Map<String, Object>> webVersionDetail(TAccount tAccount) {
- return tWarehousebillsfeesMapper.webVersionDetail(tAccount);
- }
- @Override
- public List<Map<String, Object>> webVersionInvoice(TFee tFee) {
- return tFeeMapper.webVersionInvoice(tFee);
- }
- @Override
- public List<Map<String, Object>> webVersionInvoiceDetail(TFee tFee) {
- List<Map<String, Object>> list = tFeeMapper.webVersionInvoice(tFee);
- if (CollectionUtils.isNotEmpty(list)) {
- for (Map<String, Object> map : list) {
- Long fId = Long.valueOf(map.get("fId").toString());
- List<TFeeDo> tFeeDos = tFeeDoMapper.selectTFeeDoByfPid(fId);
- map.put("tFeeDoList", tFeeDos);
- TFeeInvoice tFeeInvoice = new TFeeInvoice();
- tFeeInvoice.setfPid(fId);
- List<TFeeInvoice> tFeeInvoiceList = tFeeInvoiceMapper.selectTFeeInvoiceList(tFeeInvoice);
- map.put("tFeeInvoiceList", tFeeInvoiceList);
- }
- }
- return list;
- }
- @Override
- public List<Map<String, Object>> webVersionList(TAccount tAccount) {
- return tWarehousebillsfeesMapper.webVersionReconciliation(tAccount);
- }
- /**
- * 新增财务数据主
- *
- * @param tFee 财务数据主
- * @return 结果
- */
- @Override
- public int insertTFee(TFee tFee) {
- tFee.setCreateTime(DateUtils.getNowDate());
- return tFeeMapper.insertTFee(tFee);
- }
- /**
- * 新增对账 、收费、
- *
- * @param tfee
- * @param tfeeDo
- * @param loginUser
- * @param fBilltype
- * @return
- */
- @Override
- @Transactional
- public AjaxResult insertTFeeTFeeDo(String tfee, String tfeeDo, LoginUser loginUser, String fBilltype) {
- Long fPid = null;
- Map<String, Object> map = new HashMap<>();
- TFee tFee = JSONArray.parseObject(tfee, TFee.class);
- if (StringUtils.isNull(tFee.getfId())) {
- // 如果是新数据
- tFee.setCreateBy(loginUser.getUser().getUserName());
- tFee.setCreateTime(new Date());
- tFee.setfDeptid(loginUser.getUser().getDeptId());
- tFee.setfBilltype(fBilltype);
- // 业务编码
- Date time = new Date();
- String billNo = billnoSerialServiceImpl.getBillNo(fBilltype, time);
- tFee.setfBillno(billNo);
- tFee.setSrcBillNo(billNo);
- tFee.setfBillstatus("2");
- tFeeMapper.insertTFee(tFee);
- fPid = tFee.getfId();
- } else {
- fPid = tFee.getfId();
- tFee.setUpdateBy(loginUser.getUser().getUserName());
- tFee.setUpdateTime(new Date());
- tFeeMapper.updateTFee(tFee);
- tFee = tFeeMapper.selectTFeeById(fPid);
- tFee.setSrcBillNo(tFee.getfBillno());
- // 删除从表
- tFeeDoMapper.deleteByFPid(fPid);
- }
- // 财务从表
- if (StringUtils.isNotNull(tfeeDo)) {
- JSONArray jsonDrArray = JSONArray.parseArray(tfeeDo);
- List<TFeeDo> tFeeDoList = JSONObject.parseArray(jsonDrArray.toJSONString(), TFeeDo.class);
- for (TFeeDo tFeeDo : tFeeDoList) {
- tFeeDo.setfPid(fPid);
- tFeeDo.setCreateBy(loginUser.getUser().getUserName());
- tFeeDo.setCreateTime(new Date());
- tFeeDo.setfSrcBillno(tFeeDo.getfBillno());
- tFeeDo.setfStatus("2");
- tFeeDoMapper.insertTFeeDo(tFeeDo);
- }
- }
- List<FinancialTFeeDoExcel> list = tFeeDoMapper.selectFinancialTFeeDo(fPid);
- map.put("tFee", tFee);
- map.put("tFeeDo", list);
- return AjaxResult.success("成功", map);
- }
- @Override
- public AjaxResult insertWebVersion(String tfee, String tfeeDo, LoginUser loginUser, String fBilltype) {
- Long fPid = null;
- Map<String, Object> map = new HashMap<>();
- TFee tFee = JSONArray.parseObject(tfee, TFee.class);
- if (StringUtils.isNull(tFee.getfId())) {
- // 如果是新数据
- tFee.setCreateBy(loginUser.getUser().getUserName());
- tFee.setCreateTime(new Date());
- tFee.setfDeptid(loginUser.getUser().getDeptId());
- tFee.setfBilltype(fBilltype);
- // 业务编码
- Date time = new Date();
- String billNo = billnoSerialServiceImpl.getBillNo(fBilltype, time);
- tFee.setfBillno(billNo);
- tFee.setfBillstatus("2");
- tFee.setfAccbilldate(new Date());
- tFeeMapper.insertTFee(tFee);
- fPid = tFee.getfId();
- } else {
- fPid = tFee.getfId();
- tFee.setUpdateBy(loginUser.getUser().getUserName());
- tFee.setUpdateTime(new Date());
- tFeeMapper.updateTFee(tFee);
- // 删除从表
- tFeeDoMapper.deleteByFPid(fPid);
- }
- // 财务从表
- if (StringUtils.isNotNull(tfeeDo)) {
- JSONArray jsonDrArray = JSONArray.parseArray(tfeeDo);
- List<TAccount> tFeeDoList = JSONObject.parseArray(jsonDrArray.toJSONString(), TAccount.class);
- for (TAccount tAccount : tFeeDoList) {
- TFeeDo tFeeDo = new TFeeDo();
- tFeeDo.setfSrcid(tAccount.getfSrcid());
- tFeeDo.setfSrcpid(tAccount.getfSrcpid());
- tFeeDo.setfPid(fPid);
- tFeeDo.setCreateBy(loginUser.getUser().getUserName());
- tFeeDo.setCreateTime(new Date());
- tFeeDo.setfStatus("2");
- tFeeDo.setfSrcdc("D");
- tFeeDo.setfAmtdr(tAccount.getfAmtdr());
- tFeeDo.setfAmt(tAccount.getfAmt());
- tFeeDo.setfFeeid(tAccount.getfFeeid());
- tFeeDoMapper.insertTFeeDo(tFeeDo);
- }
- }
- map.put("tFee", tFee);
- return AjaxResult.success("成功", map);
- }
- /**
- * 新增对账 、收费、
- *
- * @param tfee
- * @param tfeeDo
- * @param loginUser
- * @param fBilltype
- * @return
- */
- @Override
- @Transactional
- public AjaxResult insertKHTFeeTFeeDo(String tfee, String tfeeDo, String tFeeInvoice, LoginUser loginUser, String fBilltype) {
- Long fPid = null;
- Map<String, Object> map = new HashMap<>();
- String billStatus = "2";
- if (fBilltype.equals("INV")) {
- billStatus = "6";
- }
- TFee tFee = JSONArray.parseObject(tfee, TFee.class);
- if (StringUtils.isNull(tFee.getfId())) {
- // 如果是新数据
- tFee.setCreateBy(loginUser.getUser().getUserName());
- tFee.setCreateTime(new Date());
- tFee.setfDeptid(loginUser.getUser().getDeptId());
- tFee.setfBilltype(fBilltype);
- // 业务编码
- Date time = new Date();
- String billNo = billnoSerialServiceImpl.getBillNo(fBilltype, time);
- tFee.setfBillno(billNo);
- tFee.setfBillstatus(billStatus);
- tFeeMapper.insertTFee(tFee);
- fPid = tFee.getfId();
- } else {
- fPid = tFee.getfId();
- boolean change = this.change(fPid);
- if (!change && !"INV".equals(fBilltype)) {
- return AjaxResult.error("当前数据不支持修改");
- }
- tFee.setUpdateBy(loginUser.getUser().getUserName());
- tFee.setUpdateTime(new Date());
- tFeeMapper.updateTFee(tFee);
- // 删除从表
- tFeeDoMapper.deleteByFPid(fPid);
- tFeeInvoiceMapper.deleteByFPid(fPid);
- }
- // 财务从表
- if (StringUtils.isNotNull(tfeeDo)) {
- JSONArray jsonDrArray = JSONArray.parseArray(tfeeDo);
- List<TFeeDo> tFeeDoList = JSONObject.parseArray(jsonDrArray.toJSONString(), TFeeDo.class);
- for (TFeeDo tFeeDo : tFeeDoList) {
- tFeeDo.setfPid(fPid);
- tFeeDo.setCreateBy(loginUser.getUser().getUserName());
- tFeeDo.setCreateTime(new Date());
- tFeeDo.setfStatus(billStatus);
- tFeeDoMapper.insertTFeeDo(tFeeDo);
- }
- }
- if (!"".equals(tFeeInvoice) && tFeeInvoice != null && !"null".equals(tFeeInvoice)) {
- JSONArray jsonDrArray = JSONArray.parseArray(tFeeInvoice);
- List<TFeeInvoice> tFeeInvoiceList = JSONObject.parseArray(jsonDrArray.toJSONString(), TFeeInvoice.class);
- for (TFeeInvoice feeInvoice : tFeeInvoiceList) {
- feeInvoice.setfPid(fPid);
- feeInvoice.setCreateBy(loginUser.getUser().getUserName());
- feeInvoice.setCreateTime(new Date());
- feeInvoice.setfBillstatus(billStatus);
- tFeeInvoiceMapper.insertTFeeInvoice(feeInvoice);
- }
- }
- map.put("tFee", tFee);
- return AjaxResult.success("成功", map);
- }
- /**
- * 修改财务数据主
- *
- * @param tFee 财务数据主
- * @return 结果
- */
- @Override
- public int updateTFee(TFee tFee) {
- tFee.setUpdateTime(DateUtils.getNowDate());
- return tFeeMapper.updateTFee(tFee);
- }
- /**
- * 批量删除财务数据主
- *
- * @param fIds 需要删除的财务数据主ID
- * @return 结果
- */
- @Override
- @Transactional
- public AjaxResult deleteWebVersionByIds(Long[] fIds) {
- // 取出业务编号、 放入 billno_del
- for (Long id : fIds) {
- // 1、查询主表信息
- TFee tFee = tFeeMapper.selectTFeeById(id);
- boolean change = this.change(id);
- if (change == false) {
- TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
- return AjaxResult.error("数据正在审批或审批通过,不允许删除");
- }
- // 2、业务编号、客存编号 放入 billno_del
- BillnoDel billnoDel = new BillnoDel();
- billnoDel.setBillType(tFee.getfBilltype());
- billnoDel.setBillNo(tFee.getfBillno());
- billnoDelMapper.insertBillnoDel(billnoDel);
- if (tFee.getfAccountId() != null) {
- TFee fee = tFeeMapper.selectTFeeById(tFee.getfAccountId());
- fee.setfMake(0);
- int updateTFee = tFeeMapper.updateTFee(fee);
- }
- }
- int i = tFeeMapper.deleteTFeeByIds(fIds);
- if (i <= 0) {
- TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
- return AjaxResult.error("删除发票申请失败,请找管理员");
- }
- return AjaxResult.success();
- }
- @Override
- public int deleteTFeeByIds(Long[] fIds) {
- // 取出业务编号、 放入 billno_del
- for (Long id : fIds) {
- // 1、查询主表信息
- TFee tFee = tFeeMapper.selectTFeeById(id);
- // 2、业务编号、客存编号 放入 billno_del
- BillnoDel billnoDel = new BillnoDel();
- billnoDel.setBillType(tFee.getfBilltype());
- billnoDel.setBillNo(tFee.getfBillno());
- billnoDelMapper.insertBillnoDel(billnoDel);
- if (tFee.getfAccountId() != null) {
- TFee fee = tFeeMapper.selectTFeeById(tFee.getfAccountId());
- fee.setfMake(0);
- tFeeMapper.updateTFee(fee);
- }
- }
- return tFeeMapper.deleteTFeeByIds(fIds);
- }
- /**
- * 删除财务数据主信息
- *
- * @param fId 财务数据主ID
- * @return 结果
- */
- @Override
- public int deleteTFeeById(Long fId) {
- return tFeeMapper.deleteTFeeById(fId);
- }
- @Override
- public List<Map<String, Object>> warehouseBillsFeesList(TWareHouseFees tWareHouseFees, String billsType) {
- Map<String, Object> map = new HashMap<>();
- map.put("tWareHouseFees", tWareHouseFees);
- List<Map<String, Object>> mapList;
- if (billsType.equals("DZ") || billsType.equals("KHDZ")) {
- mapList = tFeeMapper.warehouseBillsFeesListAccamount(map);
- updateBillTypeName(mapList, tWareHouseFees.getfBilltype());
- return mapList;
- } else if (billsType.equals("invoiceFP")) {
- mapList = tFeeMapper.warehouseInvoiceFPFeesList(map);
- return mapList;
- } else if (billsType.equals("ApplyFP")) {
- mapList = tFeeMapper.warehouseApplyFPFeesList(map);
- return mapList;
- } else if (FeesTypeEnum.INVOICE.getType().equals(billsType)) {
- // 查询发票
- mapList = tFeeMapper.queryApplyInvoiceFeesList(map);
- return mapList;
- } else {
- mapList = tFeeMapper.warehouseBillsFeesList(map);
- updateBillTypeName(mapList, tWareHouseFees.getfBilltype());
- return mapList;
- }
- }
- /**
- * 根据传入业务类型判断传入对应值
- *
- * @param mapList
- * @param type
- */
- private void updateBillTypeName(List<Map<String, Object>> mapList, String type) {
- if (CollectionUtils.isNotEmpty(mapList)) {
- List<String> typeList = Lists.newArrayList();
- typeList.add(ST_IN_TYPE);
- typeList.add(ST_OUT_TYPE);
- typeList.add(ST_TRANS_TYPE);
- List<SysDictData> sysDictDataList = sysDictDataMapper.selectByTypes(typeList);
- // 遍历map
- for (Map<String, Object> map : mapList) {
- // 如果类型为入库
- if (StringUtils.isEmpty(type) && Objects.nonNull(map.get("fBusinessType"))) {
- String fBusinessType = map.get("fBusinessType").toString();
- String dictLabel = sysDictDataList.stream().filter(li -> Objects.equals(li.getDictValue(), fBusinessType))
- .map(SysDictData::getDictLabel).findFirst().orElseThrow(() -> new WarehouseException("缺少字典表信息"));
- map.put("fBusinessType", dictLabel);
- } else if (StringUtils.isNotEmpty(type) && type.equals(WarehouseTypeEnum.SJRK.getType()) && Objects.nonNull(map.get("fBusinessType"))) {
- String dictLabel = DictUtils.getDictLabel(ST_IN_TYPE, map.get("fBusinessType").toString());
- if (StringUtils.isNotEmpty(dictLabel)) {
- map.put("fBusinessType", dictLabel);
- }
- } else if (StringUtils.isNotEmpty(type) && type.equals(WarehouseTypeEnum.SJCK.getType()) && Objects.nonNull(map.get("fBusinessType"))) {
- String dictLabel = DictUtils.getDictLabel(ST_OUT_TYPE, map.get("fBusinessType").toString());
- if (StringUtils.isNotEmpty(dictLabel)) {
- map.put("fBusinessType", dictLabel);
- }
- } else if (StringUtils.isNotEmpty(type) && type.equals(WarehouseTypeEnum.HQZY.getType()) && Objects.nonNull(map.get("fBusinessType"))) {
- String dictLabel = DictUtils.getDictLabel(ST_TRANS_TYPE, map.get("fBusinessType").toString());
- if (StringUtils.isNotEmpty(dictLabel)) {
- map.put("fBusinessType", dictLabel);
- }
- }
- }
- }
- }
- @Override
- public List<FeeVO> warehouseBillsFeesList(TWareHouseFees tWareHouseFees) {
- if (tWareHouseFees.getSwitchSection() == 1) {
- tWareHouseFees.setTimeExamine(tWareHouseFees.getTimeExamine());
- tWareHouseFees.setfBstimeExamine(null);
- } else {
- tWareHouseFees.setfBstimeExamine(tWareHouseFees.getTimeExamine());
- tWareHouseFees.setTimeExamine(null);
- }
- List<FeeVO> list = tFeeMapper.selectFinancialLedgerList(tWareHouseFees);
- for (int i = 0; i < list.size(); i++) {
- if(tWareHouseFees.getSwitchSection() == 0){
- list.get(i).setReviewDate(list.get(i).getBstime());
- }
- FeeDTO feeDTO = new FeeDTO();
- feeDTO.setFDc(tWareHouseFees.getfDc());
- feeDTO.setFCorpId(list.get(i).getfCorpid());
- BigDecimal amount = new BigDecimal("0.00");
- BigDecimal stlamount = new BigDecimal("0.00");
- if (ObjectUtils.isNotNull(list.get(i).getReviewDate())) {
- List<String> list1 = new ArrayList<>();
- list1.add(list.get(i).getReviewDate());
- list1.add(list.get(i).getReviewDate());
- if (tWareHouseFees.getSwitchSection() == 1) {
- feeDTO.setFAuditList(list1);
- } else {
- feeDTO.setFBstimeExamine(list1);
- }
- } else {
- feeDTO.setFAuditList(null);
- feeDTO.setFBstimeExamine(null);
- }
- List<FeeVO> feeVOList = tFeeMapper.selectFinancialLedgerDetails(feeDTO);
- // 应收费用
- amount = amount.add(feeVOList.stream().map(FeeVO::getFAmount).reduce(BigDecimal::add).orElse(BigDecimal.ZERO));
- // 已收费用
- stlamount = stlamount.add(feeVOList.stream().map(FeeVO::getFStlamount).reduce(BigDecimal::add).orElse(BigDecimal.ZERO));
- list.get(i).setFAmount(amount);
- list.get(i).setNnfinished(amount.subtract(stlamount));
- list.get(i).setFStlamount(stlamount);
- }
- return list;
- }
- @Override
- public List<Map<String, Object>> warehouseBillsFeesProfitList(TWareHouseFees tWareHouseFees) {
- if (tWareHouseFees.getGroupBy() == 0) {
- return tFeeMapper.warehouseBillsFeesProfitList(tWareHouseFees);
- }
- if (tWareHouseFees.getSwitchSection() == 0) {
- tWareHouseFees.setTimeExamine(tWareHouseFees.getTimeExamine());
- tWareHouseFees.setfBstimeExamine(null);
- } else {
- tWareHouseFees.setfBstimeExamine(tWareHouseFees.getTimeExamine());
- tWareHouseFees.setTimeExamine(null);
- }
- List<Map<String, Object>> mapList = tFeeMapper.warehouseBillsFeesCustomProfitList(tWareHouseFees);
- for (Map<String, Object> map : mapList) {
- FeeDTO feeDTO = new FeeDTO();
- feeDTO.setFToCorpid(Long.parseLong(map.get("fCorpid").toString()));
- BigDecimal amount = new BigDecimal("0.00");
- BigDecimal stlamount = new BigDecimal("0.00");
- // if (tWareHouseFees.getSwitchSection() == 0) {
- if (ObjectUtils.isNotNull(map.get("reviewDate"))) {
- List<String> list1 = new ArrayList<>();
- list1.add(map.get("reviewDate").toString());
- list1.add(map.get("reviewDate").toString());
- feeDTO.setFAuditList(list1);
- }
- /* } else {
- if (ObjectUtils.isNotNull(map.get("f_bstime"))) {
- List<String> list1 = new ArrayList<>();
- list1.add(map.get("f_bstime").toString());
- list1.add(map.get("f_bstime").toString());
- feeDTO.setFBstimeExamine(list1);
- }
- }*/
- List<FeeVO> feeVOList = tFeeMapper.selectFinancialLedgerDetails(feeDTO);
- for (FeeVO feeVO : feeVOList) {
- if ("D".equals(feeVO.getfDc())) {
- amount = amount.add(feeVO.getFAmount());
- } else {
- stlamount = stlamount.add(feeVO.getFAmount());
- }
- }
- map.put("fAmount", amount);
- map.put("fStlamount", stlamount);
- map.put("nnfinished", amount.subtract(stlamount));
- /*list.get(i).setFAmount(amount);
- list.get(i).setNnfinished(amount.subtract(stlamount));
- list.get(i).setFStlamount(stlamount);*/
- }
- return mapList;
- }
- public static BigDecimal calculation1(String fTotalgross, String fGrossweightblc) {
- BigDecimal num1 = new BigDecimal(fTotalgross);
- BigDecimal num2 = new BigDecimal(fGrossweightblc);
- BigDecimal result = num1.subtract(num2);
- return result.setScale(2, BigDecimal.ROUND_HALF_UP);
- }
- @Override
- @Transactional
- public AjaxResult confirm(String tfee, String tfeeDo, LoginUser loginUser, String fBilltype) {
- String key = "";
- boolean isApprove = false;
- Map<String, Object> messageMap = new HashMap<>();
- long actId = 0L;
- if (!fBilltype.equals(FeesTypeEnum.INVOICE.getType())) {
- if ("DZ".equals(fBilltype)) {
- actId = 210L;
- key = "warehouse.contrast.ApprovalFlow";
- } else if ("SF".equals(fBilltype)) {
- actId = 220L;
- key = "warehouse.charge.ApprovalFlow";
- } else if ("FF".equals(fBilltype)) {
- actId = 230L;
- key = "warehouse.payment.ApprovalFlow";
- } else if ("KHDZ".equals(fBilltype)) {
- actId = 430L;
- key = "warehouse.kaiHeContrast.ApprovalFlow";
- } else if ("KHSF".equals(fBilltype)) {
- actId = 440L;
- key = "warehouse.kaiHeCharge.ApprovalFlow";
- } else if ("KHFF".equals(fBilltype)) {
- actId = 450L;
- key = "warehouse.kaiHePayment.ApprovalFlow";
- }
- SysConfig sysConfig = sysConfigMapper.checkConfigKeyUnique(key);
- if (StringUtils.isNull(sysConfig)) {
- TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
- return AjaxResult.error("系统参数异常,未找到开启审批流参数");
- }
- if ("0".equals(sysConfig.getConfigValue())) {
- isApprove = true;
- }
- }
- TFee tFee = JSONArray.parseObject(tfee, TFee.class);
- String billstatus = "";
- if (isApprove) {
- billstatus = "4";
- } else {
- billstatus = "6";
- }
- if (StringUtils.isNull(tFee.getfId())) {
- // 如果是新数据
- tFee.setCreateBy(loginUser.getUser().getUserName());
- tFee.setfDeptid(loginUser.getUser().getDeptId());
- tFee.setfBilltype(fBilltype);
- tFee.setfBillstatus(billstatus);
- // 业务编码
- Date time = new Date();
- String billNo = billnoSerialServiceImpl.getBillNo(fBilltype, time);
- tFee.setfBillno(billNo);
- tFee.setfApplyMoney(tFee.getfAmtcr());
- tFeeMapper.insertTFee(tFee);
- } else {
- tFee.setUpdateBy(loginUser.getUser().getUserName());
- tFee.setUpdateTime(new Date());
- tFee.setfBillstatus(billstatus);
- tFee.setfApplyMoney(tFee.getfAmtcr());
- tFeeMapper.updateTFee(tFee);
- }
- // 删除从表
- tFeeDoMapper.deleteByFPid(tFee.getfId());
- messageMap.put("tFee", tFee);
- // 声明业务编号 list
- List<String> fSrcBillnos = new ArrayList<>();
- // 财务从表
- if (StringUtils.isNotNull(tfeeDo) && !"[]".equals(tfeeDo)) {
- JSONArray jsonDrArray = JSONArray.parseArray(tfeeDo);
- List<TFeeDo> tFeeDoList = JSONObject.parseArray(jsonDrArray.toJSONString(), TFeeDo.class);
- for (TFeeDo tFeeDo : tFeeDoList) {
- Map<String, Object> map = this.judgeMoney(tFeeDo.getfSrcid(), tFeeDo.getfAmt(), fBilltype, tFeeDo.getfFeeid());
- if (!(Boolean) map.get("flag")) {
- TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
- return AjaxResult.error(map.get("message").toString());
- }
- tFeeDo.setfPid(tFee.getfId());
- tFeeDo.setCreateBy(loginUser.getUser().getUserName());
- tFeeDo.setCreateTime(new Date());
- tFeeDo.setfStatus(billstatus);
- tFeeDo.setfSrcBillno(tFeeDo.getfBillno());
- if (StringUtils.isNotNull(tFeeDo.getfBillno())) {
- // 装载业务编号
- fSrcBillnos.add(tFeeDo.getfBillno());
- }
- tFeeDoMapper.insertTFeeDo(tFeeDo);
- }
- }
- if (isApprove) {
- // 点击对账、收费、付费提交审核时去掉费用
- if (actId >= 210L && actId <= 230L) {
- AjaxResult ajaxResult = this.billsfeesFollow(tFee.getfId());
- String code = ajaxResult.get("code").toString();
- if ("500".equals(code)) {
- TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
- return ajaxResult;
- }
- }
- }
- //凯和收费提交审核时去掉钱
- if (actId >= 430 && actId <= 450) {
- //判断明细客户是否为同一个
- List<TFeeDo> list = tFeeDoMapper.selectTFeeDoByfPid(tFee.getfId());
- if (CollectionUtils.isNotEmpty(list)) {
- List<Long> collect = list.stream().filter(e -> e.getfSrcid() != null).map(TFeeDo::getfSrcid).collect(toList());
- if (CollectionUtils.isNotEmpty(collect)) {
- List<Long> corpid = tWarehousebillsfeesMapper.getCorpid(collect);
- if (CollectionUtils.isNotEmpty(corpid)) {
- List<Long> longs = corpid.stream().distinct().collect(toList());
- if (CollectionUtils.isNotEmpty(longs) && longs.size() > 1) {
- TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
- return AjaxResult.error("费用明细的客户非同一个客户");
- }
- }
- }
- }
- AjaxResult ajaxResult = this.billsfeesFollow(tFee.getfId());
- String code = ajaxResult.get("code").toString();
- if ("500".equals(code)) {
- TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
- return ajaxResult;
- }
- }
- // 这里加个判断取系统参数来确定是否需要启用审批流
- BigDecimal amount = BigDecimal.ZERO;//财务对账金额
- //获取账单明细
- List<TFeeDo> list = tFeeDoMapper.selectTFeeDoByfPid(tFee.getfId());
- if (CollectionUtils.isNotEmpty(list)) {
- amount = list.stream().filter(e -> e.getfAmt() != null).map(TFeeDo::getfAmt).reduce(BigDecimal.ZERO, BigDecimal::add);
- }
- if (isApprove) {
- AuditItems auditItems = new AuditItems();
- auditItems.setLevelId(0L);
- auditItems.setBillId(tFee.getfId());
- auditItems.setActId(actId);
- auditItems.setIffinalItem("F");
- auditItems.setBillNo(tFee.getfBillno()); // 业务编号
- auditItems.setRefno1(String.valueOf(tFee.getfCorpid())); // 货权方
- auditItems.setRefno2(fBilltype);// 财务类型
- auditItems.setRefno3(tFee.gettMblno());// 提单号
- auditItems.setSendUserId(loginUser.getUser().getUserId()); // 请核人 ID
- auditItems.setSendName(loginUser.getUsername()); // 请核人名称
- auditItems.setSendTime(new Date()); // 请核时间
- auditItems.setAuditUserId(loginUser.getUser().getUserId());// 审核人 ID
- auditItems.setAuditItem(new Date());// 审核通过时间
- auditItems.setAuditOpTime(new Date());// 审核时间
- auditItems.setFidStatus("f_billstatus");// 存储对应审批字段
- auditItems.setTimes(1L);// 第几次提交审批
- auditItems.setAuditMsg("提交");
- auditItems.setAuditStatus("O");// 提交状态
- auditItems.setfSrcBillnos(fSrcBillnos);// 装载业务编号数据(来源单据编号)
- auditItems.setAmount(amount);//对账金额
- AjaxResult approvalFlow = auditItemsService.createApprovalFlow(auditItems);// 生成审批流
- Long code = Long.valueOf(String.valueOf(approvalFlow.get("code"))).longValue();
- if (code.equals(500L)) {
- TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
- return AjaxResult.error("发票申请提交审核失败,请找管理员");
- }
- } else {
- if (StringUtils.isNotNull(tfeeDo) && !"[]".equals(tfeeDo)) {
- JSONArray jsonDrArray = JSONArray.parseArray(tfeeDo);
- List<TFeeDo> tFeeDoList = JSONObject.parseArray(jsonDrArray.toJSONString(), TFeeDo.class);
- for (TFeeDo tFeeDo : tFeeDoList) {
- // 跟新费用明细
- int m = updateBillsFees(tFee.getfId(), tFeeDo, fBilltype);
- if (m == 0) {
- TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
- return AjaxResult.error("更新费用明细失败");
- }
- }
- }
- AjaxResult ajaxResult = tfeeFollow(tFee.getfId(), 6L);
- Long code = Long.valueOf(String.valueOf(ajaxResult.get("code"))).longValue();
- if (code.equals(500L)) {
- TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
- return AjaxResult.error("发票申请提交审核失败,请找管理员");
- }
- //凯和系统 修改订单的实收实付费用
- if ("KHSF".equals(fBilltype) || "KHFF".equals(fBilltype)) {
- this.updateMessage(tFee.getfId());
- }
- }
- return AjaxResult.success("成功", messageMap);
- }
- @Override
- @Transactional
- public AjaxResult webVersionConfirm(Long[] fIds, String billsType, LoginUser loginUser) {
- String key = "";
- boolean isApprove = false;
- long actId = 0L;
- if ("DZ".equals(billsType)) {
- actId = 210L;
- key = "warehouse.contrast.ApprovalFlow";
- } else if ("SF".equals(billsType)) {
- actId = 220L;
- key = "warehouse.charge.ApprovalFlow";
- } else if ("FF".equals(billsType)) {
- actId = 230L;
- key = "warehouse.payment.ApprovalFlow";
- } else if ("KHDZ".equals(billsType)) {
- actId = 430L;
- key = "warehouse.kaiHeContrast.ApprovalFlow";
- } else if ("KHSF".equals(billsType)) {
- actId = 440L;
- key = "warehouse.kaiHeCharge.ApprovalFlow";
- } else if ("KHFF".equals(billsType)) {
- actId = 450L;
- key = "warehouse.kaiHePayment.ApprovalFlow";
- }
- SysConfig sysConfig = sysConfigMapper.checkConfigKeyUnique(key);
- if (StringUtils.isNull(sysConfig)) {
- TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
- return AjaxResult.error("系统参数异常,未找到开启审批流参数");
- }
- if ("0".equals(sysConfig.getConfigValue())) {
- isApprove = true;
- }
- String billStatus = null;
- if (isApprove) {
- billStatus = "4";
- } else {
- billStatus = "6";
- }
- for (Long fId : fIds) {
- TFee tFee = tFeeMapper.selectTFeeById(fId);
- if (tFee == null) {
- return AjaxResult.error("对账数据有误请确认");
- }
- boolean change = this.change(tFee.getfId());
- if (change == false) {
- return AjaxResult.error("数据正在审批或审批通过,不允许提交审核");
- }
- //更新主表数据状态
- TFee fee = new TFee();
- fee.setfId(fId);
- fee.setfBillstatus(billStatus);
- int i = tFeeMapper.updateTFee(fee);
- //更新从表数据状态
- int update = tFeeDoMapper.tfeeDoFollowUpdate(fId, Long.valueOf(billStatus));
- if (isApprove) {
- AuditItems auditItems = new AuditItems();
- auditItems.setLevelId(0L);
- auditItems.setBillId(tFee.getfId());
- auditItems.setActId(actId);
- auditItems.setIffinalItem("F");
- auditItems.setBillNo(tFee.getfBillno()); // 业务编号
- auditItems.setRefno1(String.valueOf(tFee.getfCorpid())); // 货权方
- auditItems.setRefno2(billsType);// 财务类型
- auditItems.setRefno3(tFee.gettMblno());// 提单号
- auditItems.setSendUserId(loginUser.getUser().getUserId());
- auditItems.setSendName(loginUser.getUsername());
- auditItems.setSendTime(new Date());
- auditItems.setAuditUserId(loginUser.getUser().getUserId());
- auditItems.setAuditItem(new Date());
- auditItems.setAuditOpTime(new Date());
- auditItems.setFidStatus("f_billstatus");
- auditItems.setTimes(1L);
- auditItems.setAuditMsg("提交");
- auditItems.setAuditStatus("O");
- AjaxResult approvalFlow = auditItemsService.createApprovalFlow(auditItems);
- Long code = Long.valueOf(String.valueOf(approvalFlow.get("code"))).longValue();
- if (code.equals(500L)) {
- TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
- }
- return approvalFlow;
- } else {
- TFeeDo tFeeDo = new TFeeDo();
- tFeeDo.setfPid(fId);
- List<TFeeDo> tFeeDoList = tFeeDoMapper.selectTFeeDoList(tFeeDo);
- for (TFeeDo feeDo : tFeeDoList) {
- // 跟新费用明细
- int m = updateBillsFees(fId, feeDo, billsType);
- if (m == 0) {
- TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
- return AjaxResult.error("更新费用明细失败");
- }
- }
- }
- AjaxResult ajaxResult = tfeeFollow(tFee.getfId(), 6L);
- Long code = Long.valueOf(String.valueOf(ajaxResult.get("code"))).longValue();
- return ajaxResult;
- }
- return AjaxResult.success();
- }
- @Override
- @Transactional
- public AjaxResult confirmKaiHe(String tfee, String tfeeDo, String tFeeInvoice, LoginUser loginUser, String fBilltype) {
- Long fPid = null;
- TFee tFee = JSONArray.parseObject(tfee, TFee.class);
- Map<String, Object> messageMap = new HashMap<>();
- String key = "";
- boolean isApprove = false;
- long actId = 0L;
- String billStatus = "";
- if ("DZ".equals(fBilltype)) {
- actId = 210L;
- key = "warehouse.contrast.ApprovalFlow";
- } else if ("SF".equals(fBilltype)) {
- actId = 220L;
- key = "warehouse.charge.ApprovalFlow";
- } else if ("FF".equals(fBilltype)) {
- actId = 230L;
- key = "warehouse.payment.ApprovalFlow";
- } else if ("KHDZ".equals(fBilltype)) {
- actId = 430L;
- key = "warehouse.kaiHeContrast.ApprovalFlow";
- } else if ("KHSF".equals(fBilltype)) {
- actId = 440L;
- key = "warehouse.kaiHeCharge.ApprovalFlow";
- } else if ("KHFF".equals(fBilltype)) {
- actId = 450L;
- key = "warehouse.kaiHePayment.ApprovalFlow";
- } else if ("ApplyFP".equals(fBilltype)) {
- actId = 470L;
- key = "warehouse.kaiHeApplyFP.ApprovalFlow";
- }
- SysConfig sysConfig = sysConfigMapper.checkConfigKeyUnique(key);
- if (StringUtils.isNull(sysConfig)) {
- TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
- return AjaxResult.error("系统参数异常,未找到开启审批流参数");
- }
- if ("0".equals(sysConfig.getConfigValue())) {
- isApprove = true;
- }
- if (isApprove) {
- billStatus = "4";
- } else {
- billStatus = "6";
- }
- if (StringUtils.isNull(tFee.getfId())) {
- // 如果是新数据
- tFee.setCreateBy(loginUser.getUser().getUserName());
- tFee.setfDeptid(loginUser.getUser().getDeptId());
- tFee.setfBilltype(fBilltype);
- // 业务编码
- Date time = new Date();
- String billNo = billnoSerialServiceImpl.getBillNo(fBilltype, time);
- tFee.setfBillno(billNo);
- tFee.setfBillstatus(billStatus);
- tFeeMapper.insertTFee(tFee);
- fPid = tFee.getfId();
- } else {
- fPid = tFee.getfId();
- boolean change = this.change(fPid);
- if (!change) {
- return AjaxResult.error("当前数据不支持修改");
- }
- tFee.setUpdateBy(loginUser.getUser().getUserName());
- tFee.setUpdateTime(new Date());
- tFee.setfBillstatus(billStatus);
- tFeeMapper.updateTFee(tFee);
- // 删除从表
- tFeeDoMapper.deleteByFPid(tFee.getfId());
- //删除开票从表
- tFeeInvoiceMapper.deleteByFPid(tFee.getfId());
- }
- messageMap.put("tFee", tFee);
- // 财务从表
- if (StringUtils.isNotNull(tfeeDo) && !"[]".equals(tfeeDo)) {
- JSONArray jsonDrArray = JSONArray.parseArray(tfeeDo);
- List<TFeeDo> tFeeDoList = JSONObject.parseArray(jsonDrArray.toJSONString(), TFeeDo.class);
- for (TFeeDo tFeeDo : tFeeDoList) {
- Map<String, Object> map = this.judgeMoney(tFeeDo.getfSrcid(), tFeeDo.getfAmt(), fBilltype, tFeeDo.getfFeeid());
- boolean b = (Boolean) map.get("flag");
- if (b == false) {
- TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
- return AjaxResult.error(map.get("message").toString());
- }
- tFeeDo.setfPid(tFee.getfId());
- tFeeDo.setCreateBy(loginUser.getUser().getUserName());
- tFeeDo.setCreateTime(new Date());
- tFeeDo.setfStatus(billStatus);
- tFeeDoMapper.insertTFeeDo(tFeeDo);
- }
- }
- if (!"".equals(tFeeInvoice) && tFeeInvoice != null && !"null".equals(tFeeInvoice)) {
- JSONArray jsonDrArray = JSONArray.parseArray(tFeeInvoice);
- List<TFeeInvoice> tFeeInvoiceList = JSONObject.parseArray(jsonDrArray.toJSONString(), TFeeInvoice.class);
- for (TFeeInvoice feeInvoice : tFeeInvoiceList) {
- feeInvoice.setfPid(fPid);
- feeInvoice.setCreateBy(loginUser.getUser().getUserName());
- feeInvoice.setCreateTime(new Date());
- feeInvoice.setfBillstatus(billStatus);
- tFeeInvoiceMapper.insertTFeeInvoice(feeInvoice);
- }
- }
- // 这里加个判断取系统参数来确定是否需要启用审批流
- if (isApprove) {
- AuditItems auditItems = new AuditItems();
- auditItems.setLevelId(0L);
- auditItems.setBillId(tFee.getfId());
- auditItems.setActId(actId);
- auditItems.setIffinalItem("F");
- auditItems.setBillNo(tFee.getfBillno()); // 业务编号
- auditItems.setRefno1(String.valueOf(tFee.getfCorpid())); // 货权方
- auditItems.setRefno2(fBilltype);// 财务类型
- auditItems.setRefno3(tFee.gettMblno());// 提单号
- auditItems.setSendUserId(loginUser.getUser().getUserId());
- auditItems.setSendName(loginUser.getUsername());
- auditItems.setSendTime(new Date());
- auditItems.setAuditUserId(loginUser.getUser().getUserId());
- auditItems.setAuditItem(new Date());
- auditItems.setAuditOpTime(new Date());
- auditItems.setFidStatus("f_billstatus");
- auditItems.setTimes(1L);
- auditItems.setAuditMsg("提交");
- auditItems.setAuditStatus("O");
- AjaxResult approvalFlow = auditItemsService.createApprovalFlow(auditItems);
- Long code = Long.valueOf(String.valueOf(approvalFlow.get("code"))).longValue();
- if (code.equals(500L)) {
- TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
- return AjaxResult.error("发票申请提交审核失败,请找管理员");
- }
- } else {
- if (StringUtils.isNotNull(tfeeDo) && !"[]".equals(tfeeDo)) {
- JSONArray jsonDrArray = JSONArray.parseArray(tfeeDo);
- List<TFeeDo> tFeeDoList = JSONObject.parseArray(jsonDrArray.toJSONString(), TFeeDo.class);
- for (TFeeDo tFeeDo : tFeeDoList) {
- // 跟新费用明细
- int m = updateBillsFees(tFee.getfId(), tFeeDo, fBilltype);
- if (m == 0) {
- TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
- return AjaxResult.error("更新费用明细失败");
- }
- }
- }
- AjaxResult ajaxResult = tfeeFollow(tFee.getfId(), 6L);
- Long code = Long.valueOf(String.valueOf(ajaxResult.get("code"))).longValue();
- if (code.equals(500L)) {
- TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
- return AjaxResult.error("发票申请提交审核失败,请找管理员");
- }
- }
- return AjaxResult.success("成功", messageMap);
- }
- /**
- * 根据财务主表id 更新对应明细表状态
- *
- * @param fPid 财务主表id
- * @return 结果
- */
- @Transactional
- public AjaxResult tfeeFollow(Long fPid, long fettle) {
- if (StringUtils.isNull(fPid)) {
- return AjaxResult.error("财务更新状态未找到主表信息,请与管理员联系");
- }
- TFee tFee = new TFee();
- tFee.setfId(fPid);
- tFee.setfBillstatus(String.valueOf(fettle));
- int tFeeUpdateResult = tFeeMapper.updateTFee(tFee);
- if (tFeeUpdateResult <= 0) {
- TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
- return AjaxResult.error("更新财务明细状态失败,请联系管理员");
- }
- try {
- int itemUpdateResult = tFeeDoMapper.tfeeDoFollowUpdate(fPid, fettle);
- } catch (Exception exception) {
- TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
- return AjaxResult.error("更新财务明细状态失败,请联系管理员");
- }
- TFeeInvoice invoice = new TFeeInvoice();
- invoice.setfPid(fPid);
- List<TFeeInvoice> tFeeInvoiceList = tFeeInvoiceMapper.selectTFeeInvoiceList(invoice);
- if (CollectionUtils.isNotEmpty(tFeeInvoiceList)) {
- try {
- int itemUpdateResult = tFeeInvoiceMapper.tFeeInvoiceUpdate(fPid, fettle);
- } catch (Exception exception) {
- TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
- return AjaxResult.error("更新开票明细状态失败,请联系管理员");
- }
- }
- return AjaxResult.success();
- }
- @Transactional
- public synchronized AjaxResult billsfeesFollow(Long fPid) {
- if (StringUtils.isNull(fPid)) {
- return AjaxResult.error("费用明细更新状态未找到主表信息,请与管理员联系");
- }
- TFee tFee = tFeeMapper.selectTFeeById(fPid);
- // 查询从表数据
- TFeeDo tFeeDo = new TFeeDo();
- tFeeDo.setfPid(fPid);
- List<TFeeDo> tFeeDoList = tFeeDoMapper.selectTFeeDoList(tFeeDo);
- for (TFeeDo tFeeDo1 : tFeeDoList) {
- // 跟新费用明细
- Map<String, Object> map = this.judgeMoney(tFeeDo1.getfSrcid(), tFeeDo1.getfAmt(), tFee.getfBilltype(), tFeeDo1.getfFeeid());
- if (!(Boolean) map.get("flag")) {
- TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
- return AjaxResult.error(map.get("message").toString());
- }
- int m = updateBillsFees(fPid, tFeeDo1, tFee.getfBilltype());
- if (m == 0) {
- TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
- return AjaxResult.error("更新费用明细失败");
- }
- }
- return AjaxResult.success();
- }
- /**
- * 账单管理撤销对账、收费、付费
- *
- * @param fPid
- * @param fBillType
- * @return
- */
- @Transactional
- public AjaxResult updateDSFMoney(Long fPid, String fBillType) {
- if (StringUtils.isNull(fPid)) {
- return AjaxResult.error("费用明细更新状态未找到主表信息,请与管理员联系");
- }
- // 获取从表数据
- TFeeDo tFeeDo = new TFeeDo();
- tFeeDo.setfPid(fPid);
- List<TFeeDo> tFeeDos = tFeeDoMapper.selectTFeeDoList(tFeeDo);
- for (TFeeDo tFeeDo1 : tFeeDos) {
- int m = updateBillsFees(fPid, tFeeDo1, fBillType);
- if (m == 0) {
- TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
- return AjaxResult.error("更新费用明细失败");
- }
- }
- return AjaxResult.success();
- }
- /**
- * 凯和撤销收费 付费 对账
- *
- * @param fPid
- * @param fBillType
- * @return
- */
- @Transactional
- public AjaxResult updateMoney(Long fPid, String fBillType) {
- if (StringUtils.isNull(fPid)) {
- return AjaxResult.error("费用明细更新状态未找到主表信息,请与管理员联系");
- }
- TFee tFee = tFeeMapper.selectTFeeById(fPid);
- // 查询从表数据
- TFeeDo tFeeDo = new TFeeDo();
- tFeeDo.setfPid(fPid);
- List<TFeeDo> tFeeDoList = tFeeDoMapper.selectTFeeDoList(tFeeDo);
- for (TFeeDo tFeeDo1 : tFeeDoList) {
- /* // 跟新费用明细
- Map<String, Object> map = this.judgeMoney(tFeeDo1.getfSrcid(), tFeeDo1.getfAmt(), tFee.getfBilltype(), tFeeDo1.getfFeeid());
- if (!(Boolean) map.get("flag")) {
- TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
- return AjaxResult.error(map.get("message").toString());
- }*/
- int m = updateBillsFees(fPid, tFeeDo1, fBillType);
- if (m == 0) {
- TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
- return AjaxResult.error("更新费用明细失败");
- }
- }
- return AjaxResult.success();
- }
- @Override
- @Transactional
- public AjaxResult revoke(String tfee, String tfeeDo, LoginUser loginUser, String fBilltype) {
- // 更新 主表、从表
- TFee tFee = JSONArray.parseObject(tfee, TFee.class);
- if ("DZApplyFP".equals(fBilltype)) {
- TFee fee = tFeeMapper.selectTFeeById(tFee.getfId());
- if (fee.getfMake() == 1) {
- return AjaxResult.error("该申请发票已开销项发票,不能撤销");
- }
- }
- tFee.setUpdateBy(loginUser.getUser().getUserName());
- tFee.setUpdateTime(new Date());
- tFeeMapper.updateTFee(tFee);
- // 删除从表
- // tFeeDoMapper.deleteByFPid(tFee.getfId());
- // 财务从表
- if (StringUtils.isNotNull(tfeeDo)) {
- Map<String, Object> map = new HashMap<>();
- map.put("tFee", tFee);
- map.put("billType", fBilltype);
- JSONArray jsonDrArray = JSONArray.parseArray(tfeeDo);
- List<TFeeDo> tFeeDoList = JSONObject.parseArray(jsonDrArray.toJSONString(), TFeeDo.class);
- for (TFeeDo tFeeDo : tFeeDoList) {
- if (StringUtils.isNull(tFeeDo.getfId())) { // 需写入数据
- tFeeDo.setfPid(tFee.getfId());
- tFeeDo.setCreateBy(loginUser.getUser().getUserName());
- tFeeDo.setCreateTime(new Date());
- tFeeDoMapper.insertTFeeDo(tFeeDo);
- // 跟新费用明细
- int m = updateBillsFees(tFee.getfId(), tFeeDo, fBilltype);
- if (m == 0) {
- TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
- return AjaxResult.error("更新费用明细失败");
- }
- } else { // 需更改数据
- TFeeDo tfdo = tFeeDoMapper.selectTFeeDoById(tFeeDo.getfId());
- tfdo.setUpdateBy(loginUser.getUser().getUserName());
- tfdo.setUpdateTime(new Date());
- tFeeDoMapper.updateTFeeDo(tfdo);
- }
- map.put("tFeeDo", tFeeDo);
- tWarehousebillsfeesMapper.updateTWarehousebillsfee(map);
- }
- }
- //修改主订单费用信息
- if (fBilltype.equals("DCRevoke")) {
- this.updateMessage(tFee.getfId());
- }
- // 撤销对账时更改费用明细数据
- /*if (fBilltype.equals("DZRevoke")) {
- this.updateDSFMoney(tFee.getfId(),fBilltype);
- }*/
- // 根据业务财务数据 id 删除对应的审批流数据
- AuditItemsAbout.deleteAuditItemsData(tFee.getfId());
- return AjaxResult.success();
- }
- public void updateMessage(Long fid) {
- List<TFeeDo> list = tFeeDoMapper.selectTFeeDoByfPid(fid);
- if (CollectionUtils.isNotEmpty(list)) {
- List<Long> collect = list.stream().map(TFeeDo::getfSrcpid).collect(toList());
- collect.stream().forEach(item -> {
- TWarehouseBills warehouseBills = tWarehouseBillsMapper.selectTWarehousebillsById(item);
- //获取订舱单位
- TCorps tCorps = tCorpsMapper.selectTCorpsById(warehouseBills.getfCorpid());
- //实收费用
- List<TWarehousebillsfees> warehousebillsfees = tWarehousebillsfeesMapper.selectFeesByPId(item, "D");
- //实付费用
- List<TWarehousebillsfees> tWarehousebillsfees = tWarehousebillsfeesMapper.selectFeesByPId(item, "C");
- TWarehouseBills tWarehouseBills = new TWarehouseBills();
- tWarehouseBills.setfId(item);
- tWarehouseBills.setfRecycle(warehousebillsfees.stream().filter(ei -> ei.getfStlamount() != null && ei.getfBillstatus().longValue() == 6L).map(TWarehousebillsfees::getfStlamount).reduce(BigDecimal.ZERO, BigDecimal::add));
- tWarehouseBills.setfPay(tWarehousebillsfees.stream().filter(ei -> ei.getfStlamount() != null && ei.getfBillstatus().longValue() == 6L).map(TWarehousebillsfees::getfStlamount).reduce(BigDecimal.ZERO, BigDecimal::add));
- //如果订舱单位是凯和 应收尾0 也是放货状态
- //1: 未放货 应收>0 应收>实收
- //2:放货 应收>0 应收=实收
- if ((tCorps == null || tCorps.getfCname().equals("青岛凯和志诚物流有限公司")) && !warehouseBills.getfCaregoStatus().equals("3")) {
- tWarehouseBills.setfCaregoStatus("2");
- } else if (warehouseBills.getfReceivable().compareTo(BigDecimal.ZERO) > 0 && warehouseBills.getfReceivable().compareTo(tWarehouseBills.getfRecycle()) > 0) {
- tWarehouseBills.setfCaregoStatus("1");
- } else if (warehouseBills.getfReceivable().compareTo(BigDecimal.ZERO) > 0 && warehouseBills.getfReceivable().compareTo(tWarehouseBills.getfRecycle()) <= 0) {
- tWarehouseBills.setfCaregoStatus("2");
- }
- tWarehouseBillsMapper.updateTWarehousebills(tWarehouseBills);
- });
- }
- }
- @Override
- public AjaxResult queryRemove(Long fId) {
- TFee tFee = tFeeMapper.selectTFeeById(fId);
- TFeeDo tFeeDo = new TFeeDo();
- tFeeDo.setfPid(tFee.getfId());
- List<TFeeDo> tFeeDoList = tFeeDoMapper.selectTFeeDoList(tFeeDo);
- if (StringUtils.isNull(tFee)) {
- return AjaxResult.success("0");
- } else if (StringUtils.isNotNull(tFee) && StringUtils.isEmpty(tFeeDoList)) {
- return AjaxResult.success("1");
- } else if (tFee.getfBilltype().equals("INV") && tFee.getfAccountId() != null) {
- return AjaxResult.success("3");
- } else {
- return AjaxResult.success("2");
- }
- }
- @Override
- @Transactional
- public AjaxResult remove(Long fId) {
- TFee tFee = tFeeMapper.selectTFeeById(fId);
- if ("4".equals(tFee.getfBillstatus())) {
- return AjaxResult.error("数据已提交审批,暂不能删除");
- } else if ("5".equals(tFee.getfBillstatus())) {
- return AjaxResult.error("数据正在审批,暂不能删除");
- } else if ("6".equals(tFee.getfBillstatus())) {
- return AjaxResult.error("数据审批完成,不能删除");
- } else {
- try {
- tFeeMapper.deleteTFeeById(fId);
- tFeeDoMapper.deleteByFPid(fId);
- tFeeInvoiceMapper.deleteByFPid(fId);
- } catch (Exception e) {
- TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
- return AjaxResult.error("删除失败,请找管理员");
- }
- return AjaxResult.success();
- }
- }
- @Override
- public List<TWareHouseExcelItem> selectTWarehousebillsItemsList(Long fId) {
- List<TWareHouseExcelItem> tWareHouseExcelItemList = tFeeMapper.selectTWarehousebillsItemsList(fId);
- List<TWareHouseExcelItem> tWareHouseExcelItemList1 = new ArrayList<>();
- for (TWareHouseExcelItem tWareHouseExcelItem : tWareHouseExcelItemList) {
- if (StringUtils.isNotNull(tWareHouseExcelItem.getfBusinessType())) {
- List<SysDictData> sysDictDataListIn = new ArrayList<>();
- SysDictData sysDictData = new SysDictData();
- if (tWareHouseExcelItem.getfBilltype().equals("入库")) {
- sysDictData.setDictType(ST_IN_TYPE);
- sysDictData.setDictValue(String.valueOf(tWareHouseExcelItem.getfBusinessType()));
- sysDictData.setStatus("0");
- sysDictDataListIn = iSysDictDataService.selectDictDataList(sysDictData);
- } else if (tWareHouseExcelItem.getfBilltype().equals("出库")) {
- sysDictData.setDictType(ST_OUT_TYPE);
- sysDictData.setDictValue(String.valueOf(tWareHouseExcelItem.getfBusinessType()));
- sysDictData.setStatus("0");
- sysDictDataListIn = iSysDictDataService.selectDictDataList(sysDictData);
- } else if (tWareHouseExcelItem.getfBilltype().equals("调拨") | tWareHouseExcelItem.getfBilltype().equals("货物通关")) {
- sysDictData.setDictType(ST_TRANS_TYPE);
- sysDictData.setDictValue(String.valueOf(tWareHouseExcelItem.getfBusinessType()));
- sysDictData.setStatus("0");
- sysDictDataListIn = iSysDictDataService.selectDictDataList(sysDictData);
- }
- if (null != sysDictDataListIn && sysDictDataListIn.size() > 0) {
- tWareHouseExcelItem.setfBusinessType(sysDictDataListIn.get(0).getDictLabel());
- }
- }
- tWareHouseExcelItemList1.add(tWareHouseExcelItem);
- }
- return tWareHouseExcelItemList1;
- }
- @Override
- public String findCtrlcorpid(Long fId) {
- TFee tFee = tFeeMapper.selectTFeeById(fId);
- //String exportName = tFee.getfCtrlcorpid() + "-" + tFee.getfBillno();
- String exportName = tFee.getfCorpidName() + "-" + tFee.getfBillno();
- return exportName;
- }
- @Override
- public List<Receivable> receivableExport(TWareHouseFees tWareHouseFees) throws Exception {
- List<Map<String, Object>> list = tFeeMapper.warehouseBillsFeesList1(tWareHouseFees);
- List<Receivable> list1 = ListMapToBeanUtils.castMapToBean(list, Receivable.class);
- return list1;
- }
- @Override
- public List<GeneralLedgerExcel> payableExport(TWareHouseFees tWareHouseFees) throws Exception {
- List<GeneralLedgerExcel> ledgerExcelList = new ArrayList<>();
- List<FeeVO> feeVOList = tFeeMapper.selectFinancialLedgerList(tWareHouseFees);
- feeVOList.forEach(vo -> {
- GeneralLedgerExcel ledgerExcel = new GeneralLedgerExcel();
- ledgerExcel.setFAmount(vo.getFAmount());
- ledgerExcel.setReviewDate(vo.getReviewDate());
- ledgerExcel.setFFeesName(vo.getFFeesName());
- ledgerExcel.setNnfinished(vo.getNnfinished());
- ledgerExcel.setFStlamount(vo.getFStlamount());
- ledgerExcelList.add(ledgerExcel);
- });
- return ledgerExcelList;
- }
- @Override
- public List<Profit> profitExport(TWareHouseFees tWareHouseFees) throws Exception {
- List<Map<String, Object>> list = tFeeMapper.warehouseBillsFeesProfitList(tWareHouseFees);
- return ListMapToBeanUtils.castMapToBean(list, Profit.class);
- }
- @Override
- public List<ProfitGeneralLedgerExcel> profitCustomExport(TWareHouseFees tWareHouseFees) throws Exception {
- List<Map<String, Object>> list = tFeeMapper.warehouseBillsFeesCustomProfitList(tWareHouseFees);
- return ListMapToBeanUtils.castMapToBean(list, ProfitGeneralLedgerExcel.class);
- }
- @Override
- public List<Contrast> contrastExport(TFee tFee) throws Exception {
- List<Map<String, Object>> list = tFeeMapper.selectTFeeList1(tFee);
- for (Map<String, Object> map : list) {
- List<TFeeDo> tfd = tFeeDoMapper.selectTFeeDoByfPid(Long.valueOf(map.get("fId").toString()));
- if (tfd.size() != 0) {
- StringBuilder stringBuilder = new StringBuilder();
- for (TFeeDo tFeeDo : tfd) {
- if (StringUtils.isNotNull(tFeeDo.getfSrcBillno())) {
- stringBuilder.append(tFeeDo.getfSrcBillno()).append(",");
- }
- }
- map.put("fSrcBillno", StringUtils.removeTheLastComma(stringBuilder));
- }
- }
- return ListMapToBeanUtils.castMapToBean(list, Contrast.class);
- }
- @Override
- public List<Payment> paymentExport(TFee tFee) throws Exception {
- List<Map<String, Object>> list = tFeeMapper.selectFeeList(tFee);
- return ListMapToBeanUtils.castMapToBean(list, Payment.class);
- }
- @Override
- public List<Charge> chargeExport(TFee tFee) throws Exception {
- List<Map<String, Object>> list = tFeeMapper.selectFeeList(tFee);
- return ListMapToBeanUtils.castMapToBean(list, Charge.class);
- }
- @Override
- public List<Account> accountExport(TFee tFee) throws Exception {
- List<Map<String, Object>> list = tFeeMapper.webVersionTFee(tFee);
- return ListMapToBeanUtils.castMapToBean(list, Account.class);
- }
- @Override
- public List<Detailed> selectDetailedList(Long fId) {
- List<Detailed> detailedList = tFeeMapper.selectDetailedList(fId);
- List<Detailed> detailedList1 = new ArrayList<>();
- for (Detailed tWareHouseExcelItem : detailedList) {
- if (StringUtils.isNotNull(tWareHouseExcelItem.getfBusinessType())) {
- List<SysDictData> sysDictDataListIn = new ArrayList<>();
- SysDictData sysDictData = new SysDictData();
- if (tWareHouseExcelItem.getfBilltype().equals("入库")) {
- sysDictData.setDictType(ST_IN_TYPE);
- sysDictData.setDictValue(String.valueOf(tWareHouseExcelItem.getfBusinessType()));
- sysDictData.setStatus("0");
- sysDictDataListIn = iSysDictDataService.selectDictDataList(sysDictData);
- } else if (tWareHouseExcelItem.getfBilltype().equals("出库")) {
- sysDictData.setDictType(ST_OUT_TYPE);
- sysDictData.setDictValue(String.valueOf(tWareHouseExcelItem.getfBusinessType()));
- sysDictData.setStatus("0");
- sysDictDataListIn = iSysDictDataService.selectDictDataList(sysDictData);
- } else if (tWareHouseExcelItem.getfBilltype().equals("调拨") | tWareHouseExcelItem.getfBilltype().equals("货物通关")) {
- sysDictData.setDictType(ST_TRANS_TYPE);
- sysDictData.setDictValue(String.valueOf(tWareHouseExcelItem.getfBusinessType()));
- sysDictData.setStatus("0");
- sysDictDataListIn = iSysDictDataService.selectDictDataList(sysDictData);
- }
- if (CollectionUtils.isNotEmpty(sysDictDataListIn)) {
- tWareHouseExcelItem.setfBusinessType(sysDictDataListIn.get(0).getDictLabel());
- }
- }
- detailedList1.add(tWareHouseExcelItem);
- }
- return detailedList1;
- }
- @Override
- public List<Map<String, Object>> selectdetailedList(TWarehousebill tWarehousebill) {
- return tFeeMapper.selectDetailedList1(tWarehousebill);
- }
- /**
- * 更新费用明细
- *
- * @param fid
- * @param tFeeDo
- * @param billsType
- * @return
- */
- @Transactional
- public int updateBillsFees(Long fid, TFeeDo tFeeDo, String billsType) {
- // 查询从表数据
- TFee tFee = tFeeMapper.selectTFeeById(fid);
- if (billsType.equals("SF") || billsType.equals("FF")
- || billsType.equals("KHSF") || billsType.equals("KHFF")) {
- billsType = "DC";
- }
- Map<String, Object> map = new HashMap<>();
- map.put("tFee", tFee);
- map.put("billType", billsType);
- map.put("tFeeDo", tFeeDo);
- return tWarehousebillsfeesMapper.updateTWarehousebillsfee(map);
- }
- public boolean change(Long fId) {
- boolean flag = false;
- TFee tFee = tFeeMapper.selectTFeeById(fId);
- if ("4".equals(tFee.getfBillstatus())
- || "5".equals(tFee.getfBillstatus())
- || "6".equals(tFee.getfBillstatus())) {
- flag = false;
- } else {
- flag = true;
- }
- return flag;
- }
- @Override
- @Transactional
- public AjaxResult webVersionSubmitApplyFP(TFee tFee, LoginUser loginUser, String fBilltype) {
- String key = "";
- boolean isApprove = false;
- long actId = 0L;
- String billStatus = "";
- if ("ApplyFP".equals(fBilltype)) {
- actId = 470L;
- key = "warehouse.kaiHeApplyFP.ApprovalFlow";
- }
- SysConfig sysConfig = sysConfigMapper.checkConfigKeyUnique(key);
- if (StringUtils.isNull(sysConfig)) {
- TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
- return AjaxResult.error("系统参数异常,未找到开启审批流参数");
- }
- if ("0".equals(sysConfig.getConfigValue())) {
- isApprove = true;
- }
- if (isApprove) {
- billStatus = "4";
- } else {
- billStatus = "6";
- }
- /*for (Long getfId : tFee.getfIds()) {*/
- TFee fee = tFeeMapper.selectTFeeById(tFee.getfId());
- if (fee == null) {
- return AjaxResult.error("财务主表数据有误,请确认");
- }
- boolean change = this.change(tFee.getfId());
- if (change == false) {
- return AjaxResult.error("数据正在审批或审批通过,不允许提交审核");
- }
- fee.setfId(tFee.getfId());
- fee.setfBillstatus(billStatus);
- fee.setUpdateBy(loginUser.getUser().getUserName());
- fee.setUpdateTime(new Date());
- int updateTFee = tFeeMapper.updateTFee(fee);
- if (updateTFee <= 0) {
- TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
- return AjaxResult.error("更新财务主表数据出错,请找管理员");
- }
- TFeeDo tFeeDo = new TFeeDo();
- tFeeDo.setfPid(tFee.getfId());
- List<TFeeDo> tFeeDos = tFeeDoMapper.selectTFeeDoList(tFeeDo);
- if (CollectionUtils.isEmpty(tFeeDos)) {
- TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
- return AjaxResult.error("财务从表数据有误,请确认");
- }
- for (TFeeDo feeDo : tFeeDos) {
- feeDo.setfId(feeDo.getfId());
- feeDo.setfStatus(billStatus);
- feeDo.setUpdateBy(loginUser.getUser().getUserName());
- feeDo.setUpdateTime(new Date());
- int i = tFeeDoMapper.updateTFeeDo(feeDo);
- if (i <= 0) {
- TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
- return AjaxResult.error("更新财务主表数据出错,请找管理员");
- }
- }
- TFeeInvoice tFeeInvoice = new TFeeInvoice();
- tFeeInvoice.setfPid(tFee.getfId());
- List<TFeeInvoice> tFeeInvoiceList = tFeeInvoiceMapper.selectTFeeInvoiceList(tFeeInvoice);
- if (CollectionUtils.isNotEmpty(tFeeInvoiceList)) {
- for (TFeeInvoice invoice : tFeeInvoiceList) {
- tFeeInvoice.setfBillstatus(billStatus);
- tFeeInvoice.setfId(invoice.getfId());
- tFeeInvoice.setUpdateBy(loginUser.getUser().getUserName());
- tFeeInvoice.setUpdateTime(new Date());
- tFeeInvoiceMapper.updateTFeeInvoice(tFeeInvoice);
- }
- }
- //添加审批流
- if (isApprove) {
- AuditItems auditItems = new AuditItems();
- auditItems.setLevelId(0L);
- auditItems.setBillId(fee.getfId());
- auditItems.setActId(actId);
- auditItems.setIffinalItem("F");
- auditItems.setBillNo(fee.getfBillno()); // 业务编号
- auditItems.setRefno1(String.valueOf(fee.getfCorpid())); // 货权方
- auditItems.setRefno2(fee.getfBilltype());// 财务类型
- auditItems.setRefno3(fee.gettMblno());// 提单号
- auditItems.setSendUserId(loginUser.getUser().getUserId());
- auditItems.setSendName(loginUser.getUsername());
- auditItems.setSendTime(new Date());
- auditItems.setAuditUserId(loginUser.getUser().getUserId());
- auditItems.setAuditItem(new Date());
- auditItems.setAuditOpTime(new Date());
- auditItems.setFidStatus("f_billstatus");
- auditItems.setTimes(1L);
- auditItems.setAuditMsg("提交");
- auditItems.setAuditStatus("O");
- AjaxResult approvalFlow = auditItemsService.createApprovalFlow(auditItems);
- Long code = Long.valueOf(String.valueOf(approvalFlow.get("code"))).longValue();
- if (code.equals(500L)) {
- TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
- return AjaxResult.error("提交审核失败,请找管理员");
- }
- return approvalFlow;
- } else {
- for (TFeeDo t : tFeeDos) {
- // 跟新费用明细
- int m = updateBillsFees(tFee.getfId(), t, fBilltype);
- if (m == 0) {
- TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
- return AjaxResult.error("更新费用明细失败");
- }
- }
- AjaxResult ajaxResult = tfeeFollow(tFee.getfId(), 6L);
- Long code = Long.valueOf(String.valueOf(ajaxResult.get("code"))).longValue();
- if (code.equals(500L)) {
- TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
- return AjaxResult.error("提交审核失败,请找管理员");
- }
- return ajaxResult;
- }
- /*}*/
- //return AjaxResult.success();
- }
- @Override
- public AjaxResult webVersionUpdateApplyFP(TFee tFee, LoginUser loginUser, String billType) {
- TFeeInvoice tFeeInvoice = tFee.gettFeeInvoice();
- tFeeInvoice.setfPid(tFee.getfId());
- int i = 0;
- if (tFeeInvoice.getfId() != null) {
- tFeeInvoice.setUpdateBy(loginUser.getUser().getUserName());
- tFeeInvoice.setUpdateTime(new Date());
- i = tFeeInvoiceMapper.updateTFeeInvoice(tFeeInvoice);
- } else {
- return AjaxResult.error("开票信息为空,请找管理员");
- }
- if (i <= 0) {
- return AjaxResult.error("更新数据失败,请找管理员");
- } else {
- return AjaxResult.success();
- }
- }
- @Override
- public List<FinancialTFee> selectFinancialTFeeList(TFee tFee) {
- return tFeeMapper.selectFinancialTFeeList(tFee);
- }
- @Override
- public List<Map<String, Object>> FinancialFeesList(TWareHouseFees tWareHouseFees) {
- Map<String, Object> map = new HashMap<>();
- map.put("tWareHouseFees", tWareHouseFees);
- return tFeeMapper.FinancialFeesList(map);
- }
- @Override
- public Map<String, Object> selectFinancialTFeeId(Long fId) {
- Map<String, Object> map = new HashMap<>();
- FinancialTFee financialTFee = tFeeMapper.selectFinancialTFeeId(fId);
- List<FinancialTFeeDoExcel> financialTFeeDoExcels = tFeeDoMapper.selectFinancialTFeeDo(fId);
- map.put("tFee", financialTFee);
- map.put("tFeeDo", financialTFeeDoExcels);
- return map;
- }
- @Override
- public List<FinancialTFeeDoExcel> FinancialTFeeDoExcel(Long fId) {
- return tFeeDoMapper.selectFinancialTFeeDo(fId);
- }
- @Override
- @Transactional
- public AjaxResult webVersionApplyFP(TFee tFee, LoginUser loginUser, String fBilltype, TFeeInvoice tFeeInvoice) {
- Long fPid = null;
- String billStatus = "2";
- try {
- /*for (Long getfId : tFee.getfIds()) {*/
- TFee account = new TFee();
- TFee fee = tFeeMapper.selectTFeeById(tFee.getfId());
- if (fee == null) {
- return AjaxResult.error("财务主表数据有误,请确认");
- }
- account.setfId(fee.getfId());
- account.setfMake(1);
- fee.setfBilltype(fBilltype);
- fee.setfBillstatus(billStatus);
- fee.setCreateBy(loginUser.getUser().getUserName());
- fee.setCreateTime(new Date());
- fee.setfDeptid(loginUser.getUser().getDeptId());
- fee.setUpdateBy(null);
- fee.setUpdateTime(null);
- fee.setfInvoiceRise(tFee.getfInvoiceRise());
- fee.setfAccountId(fee.getfId());
- Date time = new Date();
- String billNo = billnoSerialServiceImpl.getBillNo(fBilltype, time);
- fee.setfBillno(billNo);
- fee.setfAccbilldate(null);
- fee.setfId(null);
- tFeeMapper.insertTFee(fee);
- tFeeMapper.updateTFee(account);
- //修改原来的数据的开票金额
- fPid = fee.getfId();
- TFeeDo tFeeDo = new TFeeDo();
- tFeeDo.setfPid(tFee.getfId());
- List<TFeeDo> tFeeDos = tFeeDoMapper.selectTFeeDoList(tFeeDo);
- if (CollectionUtils.isEmpty(tFeeDos)) {
- TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
- return AjaxResult.error("财务从表数据有误,请确认");
- }
- for (TFeeDo feeDo : tFeeDos) {
- feeDo.setfPid(fPid);
- feeDo.setfStatus(billStatus);
- feeDo.setCreateBy(loginUser.getUser().getUserName());
- feeDo.setCreateTime(new Date());
- feeDo.setUpdateBy(null);
- feeDo.setUpdateTime(null);
- int i = tFeeDoMapper.insertTFeeDo(feeDo);
- }
- tFeeInvoice.setfBillstatus(billStatus);
- tFeeInvoice.setfPid(fPid);
- tFeeInvoice.setCreateBy(loginUser.getUser().getUserName());
- tFeeInvoice.setCreateTime(new Date());
- tFeeInvoiceMapper.insertTFeeInvoice(tFeeInvoice);
- /*}*/
- } catch (Exception e) {
- TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
- return AjaxResult.error("申请发票出错,请找管理员");
- }
- return AjaxResult.success();
- }
- /**
- * 判断金额是否超过可用金额
- *
- * @param fid 费用明细表主键
- * @param money 申请金额
- * @param type DZ 对账 SF 收费 FF 付费 ApplyFP 开票申请 invoiceFP 开票
- * @return
- */
- public Map<String, Object> judgeMoney(long fid, BigDecimal money, String type, Long feeId) {
- Map<String, Object> map = new HashMap<>();
- boolean flag = true;
- TWarehousebillsfees warehousebillsfees = tWarehousebillsfeesMapper.selectTWarehousebillsfeesById(fid);
- TWarehouseBills bills = tWarehouseBillsMapper.selectTWarehousebillsById(warehousebillsfees.getfPid());
- TFees tFees = tFeesMapper.selectTFeesById(feeId);
- BigDecimal amount = warehousebillsfees.getfAmount();//金额
- BigDecimal accamount = warehousebillsfees.getfAccamount();//对账金额
- BigDecimal stlamount = warehousebillsfees.getfStlamount();//结算金额
- BigDecimal invamount = warehousebillsfees.getfInvamount();//开票金额a
- BigDecimal askamount = warehousebillsfees.getfAskamount();//申请金额
- if (bills == null) {
- flag = false;
- map.put("message", "费用明细数据有误,请找管理员");
- } else if (warehousebillsfees == null) {
- flag = false;
- map.put("message", "费用明细数据有误,请找管理员");
- } else if ("DZ".equals(type) || "KHDZ".equals(type)) {
- BigDecimal subtract = amount.subtract(accamount);
- if (subtract.compareTo(new BigDecimal(0)) == 0) {
- if (subtract.compareTo(money) <= 0) {
- flag = false;
- map.put("message", "提单号" + bills.getfMblno() + "的" + tFees.getfName() + "对账金额超过可对账金额,当前可对账金额为" + subtract + "元");
- }
- }
- } else if ("SF".equals(type) || "KHSF".equals(type)) {
- BigDecimal subtract = amount.subtract(stlamount);
- if (subtract.compareTo(money) < 0) {
- flag = false;
- map.put("message", "提单号" + bills.getfMblno() + "的" + tFees.getfName() + "收费金额超过可收费金额,当前可对账金额为" + subtract + "元");
- }
- } else if ("FF".equals(type) || "KHFF".equals(type)) {
- BigDecimal subtract = amount.subtract(stlamount);
- if (subtract.compareTo(money) < 0) {
- flag = false;
- map.put("message", "提单号" + bills.getfMblno() + "的" + tFees.getfName() + "付费金额超过可付费金额,当前可对账金额为" + subtract + "元");
- }
- } else if ("ApplyFP".equals(type)) {
- BigDecimal subtract = amount.subtract(askamount);
- if (subtract.compareTo(money) < 0) {
- flag = false;
- map.put("message", "提单号" + bills.getfMblno() + "的" + tFees.getfName() + "开票金额超过可开票金额,当前可对账金额为" + subtract + "元");
- }
- } else if ("invoiceFP".equals(type)) {
- BigDecimal subtract = amount.subtract(invamount);
- if (subtract.compareTo(money) < 0) {
- flag = false;
- map.put("message", "提单号" + bills.getfMblno() + "的" + tFees.getfName() + "开票金额超过可开票金额,当前可对账金额为" + subtract + "元");
- }
- }
- map.put("flag", flag);
- return map;
- }
- /**
- * 申请发票审核成功复制数据到销项发票中
- *
- * @param fId 主表id
- * @param fBilltype 类型
- * @return
- */
- @Transactional
- public AjaxResult copyInvoiceFp(Long fId, String fBilltype) {
- //查询费用主表信息复制主表信息
- Integer insert = null;
- TFee fee = tFeeMapper.selectTFeeById(fId);
- TFee tFee = new TFee();
- tFee.setfId(fee.getfId());
- Date time = new Date();
- String billNo = billnoSerialServiceImpl.getBillNo(fBilltype, time);
- //查询费用从表信息复制主表信息
- fee.setfAccountId(fee.getfId());
- fee.setfBillno(billNo);
- fee.setfBilltype(fBilltype);
- fee.setfId(null);
- insert = tFeeMapper.insertTFee(fee);
- tFee.setfMake(1);
- //修改原发票数据代表已开销项发票
- insert = tFeeMapper.updateTFee(tFee);
- TFeeDo tFeeDo = new TFeeDo();
- tFeeDo.setfPid(fId);
- List<TFeeDo> tFeeDoList = tFeeDoMapper.selectTFeeDoList(tFeeDo);
- if (CollectionUtils.isNotEmpty(tFeeDoList)) {
- for (TFeeDo feeDo : tFeeDoList) {
- feeDo.setfId(null);
- feeDo.setfPid(fee.getfId());
- feeDo.setfBilltype(fBilltype);
- insert = tFeeDoMapper.insertTFeeDo(feeDo);
- }
- }
- //查询开票信息复制主表信息
- TFeeInvoice tFeeInvoice = new TFeeInvoice();
- tFeeInvoice.setfPid(fId);
- List<TFeeInvoice> tFeeInvoiceList = tFeeInvoiceMapper.selectTFeeInvoiceList(tFeeInvoice);
- if (CollectionUtils.isNotEmpty(tFeeInvoiceList)) {
- for (TFeeInvoice invoice : tFeeInvoiceList) {
- invoice.setfId(null);
- invoice.setfPid(fee.getfId());
- insert = tFeeInvoiceMapper.insertTFeeInvoice(invoice);
- }
- }
- if (insert != null && insert > 0) {
- return AjaxResult.success();
- } else {
- return AjaxResult.error("生成销项发票失败,请找管理员");
- }
- }
- /**
- * 导出财务对账数据
- *
- * @param fId
- * @return
- */
- @Override
- public AjaxResult exportFinancial(Long fId) {
- //获取数据
- String shipsName = "";//船名
- String voyage = "";//航次
- String corpName = "";//客户
- String fFromDate = "";//离港日期开始
- String fToDate = "";//离港日期结束
- BigDecimal fAmount = new BigDecimal(0);//合计
- //查询财务主数据
- SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
- TFee fee = tFeeMapper.selectTFeeById(fId);
- if (fee != null) {
- corpName = fee.getfCtrlcorpid();
- /* if (fee.getfFromDate() != null) {
- fFromDate = simpleDateFormat.format(fee.getfFromDate());
- }*/
- if (fee.getfToDate() != null) {
- fToDate = simpleDateFormat.format(fee.getfToDate());
- }
- if (fee.getfVslid() != null) {
- TVessel vessel = tVesselMapper.selectTVesselById(fee.getfVslid());
- if (vessel != null && StringUtils.isNotEmpty(vessel.getfName())) {
- shipsName = vessel.getfName();
- }
- }
- if (fee.getfVoyid() != null) {
- TVoyage tVoyage = tVoyageMapper.selectTVoyageById(fee.getfVoyid());
- if (tVoyage != null && StringUtils.isNotEmpty(tVoyage.getfNo())) {
- voyage = tVoyage.getfNo();
- }
- }
- }
- //样式设置
- //1.创建一个workbook,对应一个excel文件
- HSSFWorkbook wb = new HSSFWorkbook();
- //2.在workbook中添加一个sheet,对应Excel中的sheet
- HSSFSheet sheet = wb.createSheet("对账");
- //设置每一列的列宽
- sheet.setColumnWidth(0, 256 * 15);
- sheet.setColumnWidth(1, 256 * 20);
- sheet.setColumnWidth(2, 256 * 20);
- sheet.setColumnWidth(3, 256 * 20);
- sheet.setColumnWidth(4, 256 * 15);
- sheet.setColumnWidth(5, 256 * 15);
- sheet.setColumnWidth(6, 256 * 15);
- sheet.setColumnWidth(7, 100 * 35);
- sheet.setColumnWidth(8, 256 * 15);
- sheet.setColumnWidth(9, 256 * 15);
- //3.设置样式以及字体样式
- HSSFCellStyle titleStyle = ExcelUtils.createTitleCellStyle(wb);
- HSSFCellStyle contentStyle = ExcelUtils.createContentCellStyle(wb);
- HSSFCellStyle subheadingStyle = ExcelUtils.createSubheadingStyle(wb);
- HSSFCellStyle endStyle = ExcelUtils.createEndStyle(wb);
- //4.创建标题,合并标题单元格
- //行号
- int rowNum = 0;
- //创建第一行,索引从0开始(标题行)
- HSSFRow row0 = sheet.createRow(rowNum++);
- row0.setHeight((short) 800);// 设置行高
- for (int i = 0; i < 10; i++) {
- HSSFCell tempCell = row0.createCell(i);
- tempCell.setCellStyle(contentStyle);
- }
- String title = "青岛凯和志诚物流有限公司";
- HSSFCell c00 = row0.createCell(0);
- c00.setCellValue(title);
- c00.setCellStyle(titleStyle);
- // 合并单元格,参数依次为起始行,结束行,起始列,结束列 (索引0开始)
- sheet.addMergedRegion(new CellRangeAddress(0, 0, 0, 9));//标题合并单元格操作,总列数为9
- //第2行
- HSSFRow row1 = sheet.createRow(rowNum++);
- row1.setHeight((short) 500);
- String message1 = "客户确认单";
- for (int i = 0; i < 10; i++) {
- HSSFCell tempCell = row1.createCell(i);
- tempCell.setCellStyle(contentStyle);
- }
- HSSFCell c01 = row1.createCell(0);
- c01.setCellValue(message1);
- c01.setCellStyle(subheadingStyle);
- sheet.addMergedRegion(new CellRangeAddress(1, 1, 0, 9));//标题合并单元格操作,总列数为9
- //第3行
- HSSFRow row2 = sheet.createRow(rowNum++);
- row2.setHeight((short) 500);
- String message2 = "尊敬的客户";
- HSSFCell c02 = row2.createCell(0);
- c02.setCellValue(message2);
- c02.setCellStyle(contentStyle);
- //第3行
- for (int i = 1; i < 10; i++) {
- HSSFCell tempCell = row2.createCell(i);
- tempCell.setCellStyle(contentStyle);
- }
- HSSFCell c03 = row2.createCell(1);
- c03.setCellValue(corpName);
- c03.setCellStyle(contentStyle);
- sheet.addMergedRegion(new CellRangeAddress(2, 2, 1, 9));//标题合并单元格操作,总列数为9
- //合并单元格
- sheet.addMergedRegion(new CellRangeAddress(3, 3, 1, 2));
- sheet.addMergedRegion(new CellRangeAddress(3, 3, 3, 4));
- sheet.addMergedRegion(new CellRangeAddress(3, 3, 5, 9));
- //第4行
- HSSFRow row3 = sheet.createRow(rowNum++);
- for (int i = 0; i < 1; i++) {
- HSSFCell tempCell = row3.createCell(i);
- tempCell.setCellStyle(contentStyle);
- }
- for (int i = 1; i < 3; i++) {
- HSSFCell tempCell = row3.createCell(i);
- tempCell.setCellStyle(contentStyle);
- }
- for (int i = 3; i < 5; i++) {
- HSSFCell tempCell = row3.createCell(i);
- tempCell.setCellStyle(contentStyle);
- }
- for (int i = 5; i < 10; i++) {
- HSSFCell tempCell = row3.createCell(i);
- tempCell.setCellStyle(contentStyle);
- }
- row3.setHeight((short) 500);
- HSSFCell c05 = row3.createCell(0);
- c05.setCellValue("船名航次:");
- c05.setCellStyle(contentStyle);
- HSSFCell c051 = row3.createCell(1);
- c051.setCellValue(shipsName + voyage);
- c051.setCellStyle(contentStyle);
- HSSFCell c052 = row3.createCell(3);
- c052.setCellValue("离港日期:");
- c052.setCellStyle(contentStyle);
- String message = "";
- HSSFCell c053 = row3.createCell(5);
- /* if (StringUtils.isNotEmpty(fFromDate)) {
- if (StringUtils.isNotEmpty(fFromDate)) {
- message = fFromDate + "-" + fToDate;
- } else {
- message = fFromDate;
- }
- } else if (StringUtils.isNotEmpty(fToDate)) {
- message = fToDate;
- }*/
- if (StringUtils.isNotEmpty(fToDate)) {
- message = fToDate;
- } else {
- message = "无";
- }
- c053.setCellValue(message);
- c053.setCellStyle(contentStyle);
- //第5行
- HSSFRow row4 = sheet.createRow(rowNum++);
- for (int i = 0; i < 10; i++) {
- HSSFCell tempCell = row4.createCell(i);
- tempCell.setCellStyle(contentStyle);
- }
- row4.setHeight((short) 500);
- String message4 = "费用明细";
- HSSFCell c04 = row4.createCell(0);
- c04.setCellValue(message4);
- c04.setCellStyle(contentStyle);
- sheet.addMergedRegion(new CellRangeAddress(4, 4, 0, 9));//标题合并单元格操作,总列数为9
- //第四行
- HSSFRow row5 = sheet.createRow(rowNum++);
- row5.setHeight((short) 500);
- String[] row_third = {"序号", "提单号", "始发港", "目的港", "运输条款", "货名", "箱量", "规格", "单价", "合计"};
- for (int i = 0; i < row_third.length; i++) {
- HSSFCell tempCell = row5.createCell(i);
- tempCell.setCellValue(row_third[i]);
- tempCell.setCellStyle(contentStyle);
- }
- //查询费用明细数据
- List<ExportFinancial> list = tFeeMapper.exportFinancial(fId);
- if (CollectionUtils.isNotEmpty(list)) {
- for (int i = 0; i < list.size(); i++) {
- HSSFRow tempRow = sheet.createRow(rowNum++);
- tempRow.setHeight((short) 500);
- //循环单元格填入数据
- for (int j = 0; j < 10; j++) {
- HSSFCell tempCell = tempRow.createCell(j);
- tempCell.setCellStyle(contentStyle);
- String cellValue = "";
- if (j == 0) {
- //序号
- cellValue = list.get(i).getRankNo().toString();
- } else if (j == 1) {
- //提单号
- cellValue = list.get(i).getfMblNo();
- } else if (j == 2) {
- //始发港
- cellValue = list.get(i).getPortOfDeparture();
- } else if (j == 3) {
- //目的港
- cellValue = list.get(i).getDestinationPort();
- } else if (j == 4) {
- //运输条款
- cellValue = list.get(i).getfServiceitems() + "-" + list.get(i).getfServiceitemsNew();
- } else if (j == 5) {
- //货名
- cellValue = list.get(i).getGoodName();
- } else if (j == 6) {
- //箱量
- cellValue = list.get(i).getfCnTrCount().toString();
- } else if (j == 7) {
- //规格
- cellValue = list.get(i).getSpecification();
- } else if (j == 8) {
- //单价
- cellValue = list.get(i).getfUnitPrice().toString();
- } else if (j == 9) {
- //合计
- cellValue = list.get(i).getfAmount().toString();
- }
- tempCell.setCellValue(cellValue);
- }
- }
- fAmount = list.stream().map(ExportFinancial::getfAmount).reduce(BigDecimal.ZERO, BigDecimal::add);//求所有和的合计
- }
- //倒数第二行
- HSSFRow row6 = sheet.createRow(rowNum++);
- for (int i = 0; i < 10; i++) {
- HSSFCell tempCell = row6.createCell(i);
- tempCell.setCellStyle(contentStyle);
- }
- row6.setHeight((short) 500);
- String message6 = "合计:";
- HSSFCell c06 = row6.createCell(0);
- c06.setCellValue(message6);
- c06.setCellStyle(contentStyle);
- HSSFCell c061 = row6.createCell(9);
- c061.setCellValue(fAmount.toString());
- c061.setCellStyle(contentStyle);
- //最后一行
- HSSFRow row7 = sheet.createRow(rowNum++);
- for (int i = 0; i < 10; i++) {
- HSSFCell tempCell = row7.createCell(i);
- tempCell.setCellStyle(contentStyle);
- }
- row7.setHeight((short) 1500);
- String message7 = "纳税人识别号:91370202MA3UG1T04A\n" +
- "人民币账号:3803020309100171855\n" +
- "人民币开户行:工商银行青岛分行营业部";
- HSSFCell c07 = row7.createCell(0);
- c07.setCellValue(message7);
- c07.setCellStyle(endStyle);
- sheet.addMergedRegion(new CellRangeAddress(rowNum - 1, rowNum - 1, 0, 9));//标题合并单元格操作,总列数为9
- //导出excel
- String fileName = "客户对账单.xls";
- try {
- OutputStream out = null;
- out = new FileOutputStream(getAbsoluteFile(fileName));
- wb.write(out);
- if (null != wb && null != out) {
- wb.write(out);
- wb.close();
- out.close();
- }
- return AjaxResult.success(fileName);
- } catch (Exception e) {
- e.printStackTrace();
- return AjaxResult.error("导出Excel失败");
- }
- }
- /**
- * 根据结算单位、费用状态、审核日期查询应付总帐明细
- *
- * @param feeDTO
- * @return
- */
- @Override
- public AjaxResult financialLedgerDetails(FeeDTO feeDTO) {
- /*TFees ccf = tFeesMapper.seletFeesByCCF();
- if (Objects.isNull(ccf)) {
- throw new WarehouseException("未找到仓储费费用信息");
- }
- feeDTO.setFeesId(ccf.getfId());*/
- List<FeeVO> feeVOList = tFeeMapper.selectFinancialLedgerDetails(feeDTO);
- if (CollectionUtils.isNotEmpty(feeVOList)) {
- List<FeeVO> voList = new ArrayList<>();
- Map<Long, List<FeeVO>> map = feeVOList.stream().collect(Collectors.groupingBy(FeeVO::getFSrcpid));
- map.forEach((key, value) -> {
- FeeVO vo = new FeeVO();
- FeeVO feeVO = value.stream().findFirst().orElseThrow(() ->
- new WarehouseException("获取费用异常"));
- BeanUtils.copyProperties(feeVO, vo);
- // 仓储费
- BigDecimal storageFee = value.stream().map(FeeVO::getStorageFee).reduce(BigDecimal::add).orElse(BigDecimal.ZERO);
- // 其他费用
- BigDecimal otherFee = value.stream().map(FeeVO::getOtherFee).reduce(BigDecimal::add).orElse(BigDecimal.ZERO);
- // 应收费用
- BigDecimal amount = value.stream().map(FeeVO::getFAmount).reduce(BigDecimal::add).orElse(BigDecimal.ZERO);
- // 已收费用
- BigDecimal stlamount = value.stream().map(FeeVO::getFStlamount).reduce(BigDecimal::add).orElse(BigDecimal.ZERO);
- WarehouseTypeEnum storageType = WarehouseTypeEnum.fromTypeAndBusinessType(vo.getfBilltype(), "storageType");
- vo.setfBilltype(storageType.getName());
- vo.setStorageFee(storageFee);
- vo.setFStlamount(stlamount);
- vo.setOtherFee(otherFee);
- vo.setFAmount(amount);
- vo.setNnfinished(amount.subtract(stlamount));
- voList.add(vo);
- });
- return AjaxResult.success(voList);
- }
- return AjaxResult.success(feeVOList);
- }
- /**
- * 查询应付总帐明细
- *
- * @param feeDTO
- * @return
- */
- @Override
- public List<GeneralLedgerDetailExcel> financialLedgerDetailsExport(FeeDTO feeDTO) {
- List<GeneralLedgerDetailExcel> detailExcelList = new ArrayList<>();
- List<FeeVO> feeVOList = tFeeMapper.selectFinancialLedgerDetails(feeDTO);
- feeVOList.forEach(vo -> {
- GeneralLedgerDetailExcel detailExcel = new GeneralLedgerDetailExcel();
- WarehouseTypeEnum storageType = WarehouseTypeEnum.fromTypeAndBusinessType(vo.getfBilltype(), "storageType");
- detailExcel.setFMblno(vo.getFMblno());
- detailExcel.setFMarks(vo.getFMarks());
- detailExcel.setFAmount(vo.getFAmount());
- detailExcel.setOtherFee(vo.getOtherFee());
- detailExcel.setFFeesName(vo.getFFeesName());
- detailExcel.setNnfinished(vo.getNnfinished());
- detailExcel.setFStlamount(vo.getFStlamount());
- detailExcel.setStorageFee(vo.getStorageFee());
- detailExcel.setFBilltype(storageType.getName());
- detailExcel.setFProductName(vo.getFProductName());
- detailExcel.setFProductName(vo.getFProductName());
- detailExcelList.add(detailExcel);
- });
- return detailExcelList;
- }
- @Override
- public AjaxResult financialLedgerDetailsTotal(FeeDTO feeDTO) {
- feeDTO.setFToCorpid(feeDTO.getFCorpId());
- feeDTO.setFCorpId(null);
- if (ObjectUtils.isNotNull(feeDTO.getFBstimeExamine())){
- feeDTO.setFAuditList(feeDTO.getFBstimeExamine());
- feeDTO.setFBstimeExamine(null);
- }
- List<FeeVO> feeVOList = tFeeMapper.selectFinancialLedgerDetails(feeDTO);
- feeDTO.setFDc("D");
- List<FeeVO> feeVOListD = tFeeMapper.selectFinancialLedgerDetails(feeDTO);
- feeDTO.setFDc("C");
- List<FeeVO> feeVOListC = tFeeMapper.selectFinancialLedgerDetails(feeDTO);
- if (CollectionUtils.isNotEmpty(feeVOList)) {
- List<FeeVO> voList = new ArrayList<>();
- Map<Long, List<FeeVO>> map = feeVOList.stream().collect(Collectors.groupingBy(FeeVO::getFSrcpid));
- map.forEach((key, value) -> {
- List<FeeVO> feeVODList = feeVOListD.stream().filter(e -> e.getFSrcpid().equals(key)).collect(Collectors.toList());
- FeeVO feeVOD = feeVOListD.stream().filter(e -> e.getFSrcpid().equals(key)).findFirst().orElse(null);
- List<FeeVO> feeVOCList = feeVOListC.stream().filter(e -> e.getFSrcpid().equals(key)).collect(Collectors.toList());
- FeeVO feeVOC = feeVOListC.stream().filter(e -> e.getFSrcpid().equals(key)).findFirst().orElse(null);
- FeeVO vo = new FeeVO();
- FeeVO feeVO = value.stream().findFirst().orElseThrow(() ->
- new WarehouseException("获取费用异常"));
- BeanUtils.copyProperties(feeVO, vo);
- BigDecimal D = new BigDecimal("0.00");
- BigDecimal C = new BigDecimal("0.00");
- if (ObjectUtils.isNotNull(feeVOD)) {
- if (ObjectUtils.isNotNull(feeVOD)) {
- D = feeVODList.stream().map(FeeVO::getFAmount).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
- vo.setReceivableAmount(D);
- } else {
- vo.setReceivableAmount(D);
- }
- vo.setReceivableFQty(feeVOD.getFQty());
- vo.setReceivablePrice(feeVOD.getPrice());
- /*WarehouseTypeEnum storageType = WarehouseTypeEnum.fromTypeAndBusinessType(feeVOD.getfBilltype(), "storageType");
- vo.setfBilltype(storageType.getName());*/
- vo.setfBilltype(feeVOD.getFFeesName());
- vo.setFBillingDays(feeVOD.getFBillingDays());
- }
- if (ObjectUtils.isNotNull(feeVOC)) {
- if (ObjectUtils.isNotNull(feeVOC.getFAmount())) {
- C = feeVOCList.stream().map(FeeVO::getFAmount).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);;
- vo.setCopeWithAmount(C);
- } else {
- vo.setCopeWithAmount(C);
- }
- /* WarehouseTypeEnum storageType = WarehouseTypeEnum.fromTypeAndBusinessType(feeVOC.getfBilltype(), "storageType");
- vo.setFBilltypeC(storageType.getName());*/
- vo.setfBilltype(feeVOC.getFFeesName());
- vo.setCopeWithFQty(feeVOC.getFQty());
- vo.setCopeWithPrice(feeVOC.getPrice());
- }
- vo.setNnfinished(D.subtract(C));
- voList.add(vo);
- });
- return AjaxResult.success(voList);
- }
- return AjaxResult.success(feeVOList);
- }
- @Override
- public List<GeneralLedgerDetailTotalExcel> financialLedgerDetailsTotalExport(FeeDTO feeDTO) {
- List<GeneralLedgerDetailTotalExcel> list = new ArrayList<>();
- feeDTO.setFToCorpid(feeDTO.getFCorpId());
- feeDTO.setFCorpId(null);
- if (ObjectUtils.isNotNull(feeDTO.getFBstimeExamine())){
- feeDTO.setFAuditList(feeDTO.getFBstimeExamine());
- feeDTO.setFBstimeExamine(null);
- }
- List<FeeVO> feeVOList = tFeeMapper.selectFinancialLedgerDetails(feeDTO);
- feeDTO.setFDc("D");
- List<FeeVO> feeVOListD = tFeeMapper.selectFinancialLedgerDetails(feeDTO);
- feeDTO.setFDc("C");
- List<FeeVO> feeVOListC = tFeeMapper.selectFinancialLedgerDetails(feeDTO);
- if (CollectionUtils.isNotEmpty(feeVOList)) {
- Map<Long, List<FeeVO>> map = feeVOList.stream().collect(Collectors.groupingBy(FeeVO::getFSrcpid));
- map.forEach((key, value) -> {
- GeneralLedgerDetailTotalExcel generalLedgerDetailTotalExcel = new GeneralLedgerDetailTotalExcel();
- List<FeeVO> feeVODList = feeVOListD.stream().filter(e -> e.getFSrcpid().equals(key)).collect(Collectors.toList());
- FeeVO feeVOD = feeVOListD.stream().filter(e -> e.getFSrcpid().equals(key)).findFirst().orElse(null);
- List<FeeVO> feeVOCList = feeVOListC.stream().filter(e -> e.getFSrcpid().equals(key)).collect(Collectors.toList());
- FeeVO feeVOC = feeVOListC.stream().filter(e -> e.getFSrcpid().equals(key)).findFirst().orElse(null);
- FeeVO feeVO = value.stream().findFirst().orElseThrow(() ->
- new WarehouseException("获取费用异常"));
- BeanUtils.copyProperties(feeVO, generalLedgerDetailTotalExcel);
- BigDecimal D = new BigDecimal("0.00");
- BigDecimal C = new BigDecimal("0.00");
- if (ObjectUtils.isNotNull(feeVOD)) {
- if (ObjectUtils.isNotNull(feeVOD)) {
- D = feeVODList.stream().map(FeeVO::getFAmount).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
- generalLedgerDetailTotalExcel.setReceivableAmount(D);
- } else {
- generalLedgerDetailTotalExcel.setReceivableAmount(D);
- }
- generalLedgerDetailTotalExcel.setReceivableFQty(feeVOD.getFQty());
- generalLedgerDetailTotalExcel.setReceivablePrice(feeVOD.getPrice());
- /*WarehouseTypeEnum storageType = WarehouseTypeEnum.fromTypeAndBusinessType(feeVOD.getfBilltype(), "storageType");
- generalLedgerDetailTotalExcel.setFBilltype(storageType.getName());*/
- generalLedgerDetailTotalExcel.setFBilltype(feeVOD.getFFeesName());
- generalLedgerDetailTotalExcel.setFBillingDays(feeVOD.getFBillingDays());
- }
- if (ObjectUtils.isNotNull(feeVOC)) {
- if (ObjectUtils.isNotNull(feeVOC.getFAmount())) {
- C = feeVOCList.stream().map(FeeVO::getFAmount).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);;
- generalLedgerDetailTotalExcel.setCopeWithAmount(C);
- } else {
- generalLedgerDetailTotalExcel.setCopeWithAmount(C);
- }
- /*WarehouseTypeEnum storageType = WarehouseTypeEnum.fromTypeAndBusinessType(feeVOC.getfBilltype(), "storageType");
- generalLedgerDetailTotalExcel.setFBilltypeC(storageType.getName());*/
- generalLedgerDetailTotalExcel.setFBilltypeC(feeVOC.getFFeesName());
- generalLedgerDetailTotalExcel.setCopeWithFQty(feeVOC.getFQty());
- generalLedgerDetailTotalExcel.setCopeWithPrice(feeVOC.getPrice());
- }
- generalLedgerDetailTotalExcel.setNnfinished(D.subtract(C));
- list.add(generalLedgerDetailTotalExcel);
- });
- return list;
- }
- return list;
- }
- @Override
- public List<ReceivableExcel> receivable(TWareHouseFees tWareHouseFees) {
- return tFeeMapper.receivable(tWareHouseFees);
- }
- @Override
- public List<ProfitExcel> profit(TWareHouseFees tWareHouseFees) {
- return tFeeMapper.profit(tWareHouseFees);
- }
- @Override
- public List<HandleExcel> handle(TWareHouseFees tWareHouseFees) {
- return tFeeMapper.handle(tWareHouseFees);
- }
- //下载路径
- private String getAbsoluteFile(String fileName) {
- String downloadPath = RuoYiConfig.getDownloadPath() + fileName;
- File desc = new File(downloadPath);
- if (!desc.getParentFile().exists()) {
- desc.getParentFile().mkdirs();
- }
- return downloadPath;
- }
- }
|