package com.ld.igds.inout.view; import java.util.*; import com.ld.igds.inout.InoutConstant; import com.ld.igds.inout.dto.ReportInoutDepotData; import com.ld.igds.inout.dto.ReportInoutShipData; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.time.DateFormatUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import com.bstek.bdf2.core.model.DefaultDept; import com.bstek.dorado.annotation.DataProvider; import com.ld.igds.inout.service.HInoutReportService; import com.ld.igds.inout.service.JInoutReportService; import com.ld.igds.models.InoutRecord; import com.ld.igds.sys.service.SysDeptService; import com.ld.igds.util.ContextUtil; import com.ld.igds.util.DateUtil; /** * @author: andy.jia * @description: * @version: * @data:2020年3月13日 */ @Component public class InoutReportPR { @Autowired private HInoutReportService hiberReportService; @Autowired private JInoutReportService jdbcReportService; @Autowired private SysDeptService sysDeptService; /** * inoutReportPR#getQuery 根据报表类型,获取默认查询信息,比如表头信息等 * * @param * @return */ @DataProvider public Map getQuery(Map param) { Map result = new HashMap(); //获取参数中报表类型 String type = (String) param.get("type"); //获取参数中分库编码 String deptId = (String) param.get("deptId"); //获取分库编码对应的分库名称 String deptName = ""; List defaultDepts = sysDeptService.getCacheDept(ContextUtil.getCompanyId()); for (DefaultDept defaultDept : defaultDepts) { if (defaultDept.getId().equals(deptId)) { deptName = defaultDept.getName(); } } if ("INOUT_DETAIL".equals(type)) { result.put("title", "出入库明细汇总"); if (StringUtils.isNotEmpty(deptName)) { result.put("title", deptName + "出入库明细汇总"); result.put("deptId", deptId); } result.put("unit", "千克(KG)"); result.put("end", new Date()); Date start = DateUtil.getNewByDay(new Date(), -30); result.put("start", start); result.put("timeDesc", DateFormatUtils.format(start, "yyyy-MM-dd") + " 截至:" + DateFormatUtils.format(new Date(), "yyyy-MM-dd")); } /** * 每日出库统计 */ if ("OUT_DAY".equals(type)) { result.put("title", "每日出库汇总"); if (StringUtils.isNotEmpty(deptName)) { result.put("title", deptName + "每日出库汇总"); result.put("deptId", deptId); } result.put("unit", "千克(KG)"); result.put("day", new Date()); result.put("timeDesc", DateFormatUtils.format(new Date(), "yyyy-MM-dd")); result.put("type", InoutConstant.TYPE_OUT); } /** * 每日入库汇总统计 */ if ("IN_DAY".equals(type)) { result.put("title", "每日入库汇总"); if (StringUtils.isNotEmpty(deptName)) { result.put("title", deptName + "每日入库汇总"); result.put("deptId", deptId); } result.put("unit", "千克(KG)"); result.put("day", new Date()); result.put("timeDesc", DateFormatUtils.format(new Date(), "yyyy-MM-dd")); result.put("type", InoutConstant.TYPE_IN); } /** * 分仓收支存 */ if ("INOUTDEPOT".equals(type)) { result.put("title", "分仓粮油收支存"); if (StringUtils.isNotEmpty(deptName)) { result.put("title", deptName + "分仓粮油收支存"); result.put("deptId", deptId); } result.put("end", new Date()); Date start = DateUtil.getNewByDay(new Date(), -30); result.put("start", start); result.put("timeDesc", DateFormatUtils.format(start, "yyyy-MM-dd") + " 截至:" + DateFormatUtils.format(new Date(), "yyyy-MM-dd")); result.put("unit", "千克(KG)"); } /** * 分品种收支存 */ if ("INOUTFOODVARIETY".equals(type)) { result.put("title", "分品种粮油收支存"); if (StringUtils.isNotEmpty(deptName)) { result.put("title", deptName + "分品种粮油收支存"); result.put("deptId", deptId); } result.put("end", new Date()); Date start = DateUtil.getNewByDay(new Date(), -30); result.put("start", start); result.put("timeDesc", DateFormatUtils.format(start, "yyyy-MM-dd") + " 截至:" + DateFormatUtils.format(new Date(), "yyyy-MM-dd")); result.put("unit", "千克(KG)"); } if ("INOUT_SHIP_DETAIL".equals(type)) { result.put("title", "船运明细汇总"); if (StringUtils.isNotEmpty(deptName)) { result.put("title", deptName + "船运明细汇总"); result.put("deptId", deptId); } result.put("unit", "千克(KG)"); result.put("end", new Date()); Date start = DateUtil.getNewByDay(new Date(), -30); result.put("start", start); result.put("timeDesc", DateFormatUtils.format(start, "yyyy-MM-dd") + " 截至:" + DateFormatUtils.format(new Date(), "yyyy-MM-dd")); } return result; } /** * 出入库汇总表 * inoutReportPR#listRecord 报表数据,只获取已经完成的,并且非异常数据和删除数据 * * @param param * @return */ @DataProvider public List listRecord(Map param) throws Exception { if (null == param) { param = new HashMap(); param.put("progress", InoutConstant.PROGRESS_RECORD); } List result = hiberReportService.listRecord(param); if (null == result || result.isEmpty()) return result; // 添加统计信息 double emptyWeightSum = 0.0, fullWeightSum = 0.0, deCheck = 0.0, addCheck = 0.0, deWetSum = 0.0, deImpuritySum = 0.0, deHandleSum = 0.0, deOtherSum = 0.0, deSumSum = 0.0, netWeightSum = 0.0, settleWeightSum = 0.0; int index = 1; for (InoutRecord record : result) { record.setRemarks(String.valueOf(index)); emptyWeightSum += record.getEmptyWeight(); fullWeightSum += record.getFullWeight(); deCheck += record.getDeCheck(); addCheck += record.getAddCheck(); // deWetSum += record.getDeWet(); // deImpuritySum += record.getDeImpurity(); deHandleSum += record.getDeHandle(); deOtherSum += record.getDeOther(); // deSumSum += record.getDeSum(); netWeightSum += record.getNetWeight(); settleWeightSum += record.getSettleWeight(); index++; } InoutRecord sum = new InoutRecord(); sum.setId("合计"); sum.setEmptyWeight(emptyWeightSum); sum.setFullWeight(fullWeightSum); sum.setAddCheck(addCheck); sum.setDeCheck(deCheck); // sum.setDeWet(deWetSum); // sum.setDeImpurity(deImpuritySum); sum.setDeHandle(deHandleSum); sum.setDeOther(deOtherSum); // sum.setDeSum(deSumSum); sum.setNetWeight(netWeightSum); sum.setSettleWeight(settleWeightSum); result.add(sum); return result; } /** * inoutReportPR#inoutDepotData 分仓粮油收支存 * * @param param * @return */ @DataProvider public List inoutDepotData(Map param) throws Exception { List result = jdbcReportService.getInoutDepotData(param); return result; } /** * inoutReportPR#inoutFoodVarietyData 分品种粮油收支存 * * @param param * @return */ @DataProvider public List inoutFoodVarietyData(Map param) throws Exception { List result = jdbcReportService.getFoodVarietyData(param); return result; } /** * 船运明细汇总 * inoutReportPR#listShipDetail * * @param param * @return */ @DataProvider public List listShipDetail(Map param) throws Exception { if (null == param) { param = new HashMap(); } return jdbcReportService.listShipDetail(param); } }