package com.steerinfo.dil.service.impl; import com.steerinfo.dil.mapper.StatisticalReportMapper; import com.steerinfo.dil.service.IStatisticalReportService; import com.steerinfo.dil.util.DataChange; import oracle.sql.DATE; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.web.bind.annotation.RequestBody; import java.math.BigDecimal; import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.Map; /** * @ author :TXF * @ time :2021/12/14 15:26 */ @Service public class StatisticalReportImpl implements IStatisticalReportService { @Autowired StatisticalReportMapper statisticalReportMapper; /** * 计算相差时间 * @return */ public void calculateDifferenceTime(Map mesMap){ Object resultEntryGateTime = mesMap.get("resultEntryGateTime"); Object resultOutGateTime = mesMap.get("resultOutGateTime"); if(resultEntryGateTime != null && resultOutGateTime != null){ Date enterDate = (Date) resultEntryGateTime; Date outDate = (Date) resultOutGateTime; //计算相差时间 long dTime = outDate.getTime() - enterDate.getTime(); mesMap.put("inPlantDwellTime", dTime / 60000 + "分钟"); } if(resultEntryGateTime != null && resultOutGateTime == null){ //如果没有出厂时间则以当前时间减去进厂时间 Date enterDate = (Date) resultEntryGateTime; long dTime = new Date().getTime() - enterDate.getTime(); mesMap.put("inPlantDwellTime", dTime / 60000 + "分钟"); } } /** * 查询采购统计报表 * @Author TXF * @Date 2022/1/6 9:52 * @param map * @return **/ public List> getRLFLReport(Map map){ List> mapList = null; if(DataChange.dataToBigDecimal(map.get("orderTypee")).intValue() == 5){ mapList = statisticalReportMapper.getFuPurchaseFLRLReport(map); }else { mapList = statisticalReportMapper.getAllPurchaseFLRLReport(map); } return mapList; } @Override public List> getAllPurchaseFLRLReport(Map map) { return statisticalReportMapper.getAllPurchaseFLRLReport(map); } /** * 查询销售统计报表 * @param map * @return */ @Override public List> getAllSaleReport(Map map) { List> mapList = statisticalReportMapper.getAllSaleReport(map); for(Map map1 : mapList) { if ( map1.get("resultEntryGateTime") == null) { map1.put("transportStatus", "未进厂"); continue; } if (map1.get("resultOutGateTime") == null) { map1.put("transportStatus", "已进厂"); continue; } if (map1.get("arrivalAddress") == null) { map1.put("transportStatus", "已出厂"); continue; } if (map1.get("receiptAddress") == null) { map1.put("transportStatus", "已抵达"); continue; } else{ map1.put("transportStatus", "已签收"); } } for (Map mesMap : mapList) { calculateDifferenceTime(mesMap); } return mapList; } @Override public List> getAllSaleReportNum(Map map) { List> listMap = statisticalReportMapper.getAllSaleReport(map); return listMap; } /** * 查询零星物资进厂统计报表 */ @Override public List> getSporadicSuppliesReportNum1(Map mapValue) { return statisticalReportMapper.getSporadicSuppliesReport1(mapValue); } @Override public List> getSporadicSuppliesReport1(Map mapValue) { List> mapList = statisticalReportMapper.getSporadicSuppliesReport1(mapValue); for (Map mesMap : mapList) { calculateDifferenceTime(mesMap); } return mapList; } /** * 查询零星物资出厂统计报表 */ @Override public List> getSporadicSuppliesReportNum2(Map mapValue) { return statisticalReportMapper.getSporadicSuppliesReport2(mapValue); } @Override public List> getSporadicSuppliesReport2(Map mapValue) { List> mapList = statisticalReportMapper.getSporadicSuppliesReport2(mapValue); for (Map mesMap : mapList) { calculateDifferenceTime(mesMap); } return mapList; } //采购内转统计报表 @Override public List> getPurInwardReport( Map mapValue) { List> inwardReportResult = statisticalReportMapper.getInwardReportResult(mapValue); for (MapinwardReport:inwardReportResult ) { if(DataChange.dataToBigDecimal(inwardReport.get("orderType")).intValue() == 10){ inwardReport.put("transRange","化工园区铁专线-焦化二厂"); }else{ inwardReport.put("transRange","化工园区铁专线-达钢厂区"); } BigDecimal netWeightSecond = DataChange.dataToBigDecimal(inwardReport.get("netWeightSecond")); BigDecimal netWeightFirst = DataChange.dataToBigDecimal(inwardReport.get("netWeightFirst")); BigDecimal netTract = netWeightSecond.subtract(netWeightFirst).divide(new BigDecimal(1), 2, 4); //第二次净重减第一次净重 inwardReport.put("newTract",netTract); calculateDifferenceTime(inwardReport); } return inwardReportResult; } //采购内转统计报表 @Override public List> getLXInwardReport( Map mapValue) { List> lxReportResult = statisticalReportMapper.getLXReportResult(mapValue); for (MapinwardReport:lxReportResult ) { BigDecimal netWeightSecond = DataChange.dataToBigDecimal(inwardReport.get("netWeightSecond")); BigDecimal netWeightFirst = DataChange.dataToBigDecimal(inwardReport.get("netWeightFirst")); BigDecimal netTract = netWeightSecond.subtract(netWeightFirst).divide(new BigDecimal(1), 2, 4); //第二次净重减第一次净重 inwardReport.put("newTract",netTract); calculateDifferenceTime(inwardReport); } return lxReportResult; } @Override public List> getInwardReport(Map mapValue) { return statisticalReportMapper.getInwardReport(mapValue); } @Override public List> getLoading(Map mapValue) { return statisticalReportMapper.getLoading(mapValue); } @Override public List> getUnLoading(Map mapValue) { return statisticalReportMapper.getUnLoading(mapValue); } @Override public List> getLoaderResult(Map mapValue) { return statisticalReportMapper.getLoaderResult(mapValue); } @Override public List> getCapacityByDefend(Map map) { return statisticalReportMapper.getCapacityByDefend(map); } @Override public List> getInwardReportForAssemble(Map mapValue) { return statisticalReportMapper.getInwardReportForAssemble(mapValue); } @Override public List> getLoaderForResultDetail(Map mapValue) { //判断是否含有装机备注 return statisticalReportMapper.getLoaderForResultDetail(mapValue); } //查看该组织架构下的销售订单统计报表 @Override public List> getSaleOrderList(Map mapValue) { return statisticalReportMapper.getSaleOrderList(mapValue); } //查看该组织架构下的采购订单统计报表 @Override public List> getPurchaseOrderList(Map mapValue) { return statisticalReportMapper.getPurchaseOrderList(mapValue); } //查看该组织架构下的采购内转统计报表 @Override public List> getPurchaseInwardList(Map mapValue) { return statisticalReportMapper.getPurchaseInwardList(mapValue); } //查看该组织架构下的内转统计报表 @Override public List> getInwardInFactory(Map mapValue) { return statisticalReportMapper.getInwardInFactory(mapValue); } @Override public List> getOutFactoryInwardList(Map mapValue) { return statisticalReportMapper.getOutFactoryInwardList(mapValue); } @Override public List> getSaleSteelReport(Map mapValue) { List> saleSteelReport = statisticalReportMapper.getSaleSteelReport(mapValue); return saleSteelReport; } @Override public List> getInwardSaleSteelReport(Map map) { return statisticalReportMapper.getInwardSaleSteelReport(map); } @Override public List> getInwardSaleSteelOrder(Map map) { return statisticalReportMapper.getInwardSaleSteelOrder(map); } }