| | |
| | | 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; |
| | | @Autowired |
| | | private HInoutReportService hiberReportService; |
| | | @Autowired |
| | | private JInoutReportService jdbcReportService; |
| | | @Autowired |
| | | private SysDeptService sysDeptService; |
| | | |
| | | /** |
| | | * inoutReportPR#getQuery 根据报表类型,获取默认查询信息,比如表头信息等 |
| | | * |
| | | * @param |
| | | * @return |
| | | */ |
| | | @DataProvider |
| | | public Map<String, Object> getQuery(Map<String, Object> param) { |
| | | Map<String, Object> result = new HashMap<String, Object>(); |
| | | //获取参数中报表类型 |
| | | String type = (String)param.get("type"); |
| | | //获取参数中分库编码 |
| | | String deptId = (String)param.get("deptId"); |
| | | //获取分库编码对应的分库名称 |
| | | String deptName = ""; |
| | | List<DefaultDept> 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); |
| | | } |
| | | /** |
| | | * inoutReportPR#getQuery 根据报表类型,获取默认查询信息,比如表头信息等 |
| | | * |
| | | * @param |
| | | * @return |
| | | */ |
| | | @DataProvider |
| | | public Map<String, Object> getQuery(Map<String, Object> param) { |
| | | Map<String, Object> result = new HashMap<String, Object>(); |
| | | //获取参数中报表类型 |
| | | String type = (String) param.get("type"); |
| | | //获取参数中分库编码 |
| | | String deptId = (String) param.get("deptId"); |
| | | //获取分库编码对应的分库名称 |
| | | String deptName = ""; |
| | | List<DefaultDept> 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("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")); |
| | | } |
| | | 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); |
| | | } |
| | | /** |
| | | * 每日出库统计 |
| | | */ |
| | | 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); |
| | | } |
| | | 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); |
| | | } |
| | | /** |
| | | * 每日入库汇总统计 |
| | | */ |
| | | 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("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 ("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("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("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; |
| | | } |
| | | 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<InoutRecord> listRecord(Map<String, Object> param) |
| | | throws Exception { |
| | | /** |
| | | * 出入库汇总表 |
| | | * inoutReportPR#listRecord 报表数据,只获取已经完成的,并且非异常数据和删除数据 |
| | | * |
| | | * @param param |
| | | * @return |
| | | */ |
| | | @DataProvider |
| | | public List<InoutRecord> listRecord(Map<String, Object> param) |
| | | throws Exception { |
| | | |
| | | if (null == param) { |
| | | param = new HashMap<String, Object>(); |
| | | param.put("progress", InoutConstant.PROGRESS_RECORD); |
| | | } |
| | | if (null == param) { |
| | | param = new HashMap<String, Object>(); |
| | | param.put("progress", InoutConstant.PROGRESS_RECORD); |
| | | } |
| | | |
| | | List<InoutRecord> result = hiberReportService.listRecord(param); |
| | | if (null == result || result.isEmpty()) |
| | | return result; |
| | | List<InoutRecord> result = hiberReportService.listRecord(param); |
| | | if (null == result || result.isEmpty()) |
| | | return result; |
| | | |
| | | // 添加统计信息 |
| | | double emptyWeightSum = 0.0, fullWeightSum = 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(); |
| | | // 添加统计信息 |
| | | 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); |
| | | 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; |
| | | } |
| | | sum.setDeHandle(deHandleSum); |
| | | sum.setDeOther(deOtherSum); |
| | | // sum.setDeSum(deSumSum); |
| | | sum.setNetWeight(netWeightSum); |
| | | sum.setSettleWeight(settleWeightSum); |
| | | result.add(sum); |
| | | |
| | | /** |
| | | * inoutReportPR#inoutDepotData 分仓粮油收支存 |
| | | * @param param |
| | | * @return |
| | | */ |
| | | @DataProvider |
| | | public List<ReportInoutDepotData> inoutDepotData(Map<String, Object> param)throws Exception { |
| | | List<ReportInoutDepotData> result = jdbcReportService.getInoutDepotData(param); |
| | | return result; |
| | | } |
| | | /** |
| | | * inoutReportPR#inoutFoodVarietyData 分品种粮油收支存 |
| | | * @param param |
| | | * @return |
| | | */ |
| | | @DataProvider |
| | | public List<ReportInoutDepotData> inoutFoodVarietyData(Map<String, Object> param) |
| | | throws Exception { |
| | | List<ReportInoutDepotData> result = jdbcReportService.getFoodVarietyData(param); |
| | | return result; |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * 船运明细汇总 |
| | | * inoutReportPR#listShipDetail |
| | | * |
| | | * @param param |
| | | * @return |
| | | */ |
| | | @DataProvider |
| | | public List<ReportInoutShipData> listShipDetail(Map<String, Object> param) throws Exception { |
| | | /** |
| | | * inoutReportPR#inoutDepotData 分仓粮油收支存 |
| | | * |
| | | * @param param |
| | | * @return |
| | | */ |
| | | @DataProvider |
| | | public List<ReportInoutDepotData> inoutDepotData(Map<String, Object> param) throws Exception { |
| | | List<ReportInoutDepotData> result = jdbcReportService.getInoutDepotData(param); |
| | | return result; |
| | | } |
| | | |
| | | if (null == param) { |
| | | param = new HashMap<String, Object>(); |
| | | } |
| | | /** |
| | | * inoutReportPR#inoutFoodVarietyData 分品种粮油收支存 |
| | | * |
| | | * @param param |
| | | * @return |
| | | */ |
| | | @DataProvider |
| | | public List<ReportInoutDepotData> inoutFoodVarietyData(Map<String, Object> param) |
| | | throws Exception { |
| | | List<ReportInoutDepotData> result = jdbcReportService.getFoodVarietyData(param); |
| | | return result; |
| | | } |
| | | |
| | | return jdbcReportService.listShipDetail(param); |
| | | } |
| | | /** |
| | | * 船运明细汇总 |
| | | * inoutReportPR#listShipDetail |
| | | * |
| | | * @param param |
| | | * @return |
| | | */ |
| | | @DataProvider |
| | | public List<ReportInoutShipData> listShipDetail(Map<String, Object> param) throws Exception { |
| | | |
| | | if (null == param) { |
| | | param = new HashMap<String, Object>(); |
| | | } |
| | | |
| | | return jdbcReportService.listShipDetail(param); |
| | | } |
| | | } |