/* * 取消成本审核 */ @ModuleName(value = "提货成本管理取消成本审核", logType = LogType.fi) public void saveQxFiAudit(List<FiDeliverycost> aa) throws Exception { List<Long> fiDelivAll = new ArrayList<Long>(); // 取消审核的ID集合 for (FiDeliverycost fd : aa) { fiDelivAll.add(fd.getId()); } List<FiDeliverycost> listAa = new ArrayList<FiDeliverycost>(); for (FiDeliverycost fiDeliverycost : aa) { // 验证时间戳 FiDeliverycost fiDeli = fiDeliverycostDao.get(fiDeliverycost.getId()); List<Long> faxIdList = getPksByIds(fiDeli.getFaxId()); for (Long faxIdLong : faxIdList) { OprFaxMain fiMain = oprFaxMainService.get(faxIdLong); fiMain.setCostAuditStatus(0l); oprFaxMainService.save(fiMain); // fiCostService.sumCostBySourceDataId("提货成本", fiDeliverycost.getId()); //总 List<OprFaxIn> listFax = oprFaxInDao.find( "from OprFaxIn oi where oi.faxMainId=? and oi.status=1 ", fiMain.getId()); // 找到配送单号 for (OprFaxIn oin : listFax) { double totalCost = fiCostService.sumCostBySourceDataId("提货成本", oin.getDno()); // 所有配送单号提货成本 FiCost fiCostNew = new FiCost(); fiCostNew.setCostType("提货成本"); fiCostNew.setCostTypeDetail("撤销审核"); fiCostNew.setCostAmount(-totalCost); fiCostNew.setDataSource("提货成本"); fiCostNew.setDno(oin.getDno()); fiCostNew.setSourceSignNo(fiDeliverycost.getId() + ""); fiCostNew.setStatus(1l); fiCostService.save(fiCostNew); // 重新 oprHistoryService.saveLog( oin.getDno(), "提货成本审核撤销,撤销金额:" + totalCost, log_qxAuditCost); // 操作日志 } } if (faxIdList.size() == 1) { List<FiDeliverycost> lisd = find( "from FiDeliverycost fd where fd.departId=? and fd.faxId=? and fd.id<> ? ", fiDeli.getDepartId(), fiDeli.getFaxId(), fiDeli.getId()); List<Long> idsLongList = new ArrayList<Long>(); for (FiDeliverycost fiDt2 : lisd) { idsLongList.add(fiDt2.getId()); } if (!fiDelivAll.containsAll(idsLongList)) { throw new ServiceException("存在多条黄单记录匹配一条主单号的记录,请一起取消审核"); } } if (fiDeli.getPayStatus() == 1l) { throw new ServiceException("不能撤销会计审核,存在已支付的数据"); } fiDeli.setTs(fiDeliverycost.getTs()); fiDeliverycostDao.save(fiDeli); listAa.add(fiDeli); } List<FiDeliverycost> list = fiDeliverycostDao.find( "from FiDeliverycost f where f.batchNo=? ", listAa.get(0).getBatchNo()); if (list.size() == listAa.size()) { // 如果是一个批次的数据全部撤销 for (FiDeliverycost fiDeliverycost : listAa) { // 财务接口 List<FiInterfaceProDto> listfiInterfaceDto = new ArrayList<FiInterfaceProDto>(); FiInterfaceProDto fiIn = new FiInterfaceProDto(); fiIn.setSourceData("提货成本"); fiIn.setSourceNo(fiDeliverycost.getBatchNo()); fiIn.setAmount(fiDeliverycost.getAmount()); listfiInterfaceDto.add(fiIn); fiInterfaceImpl.changePaymentAmount(listfiInterfaceDto); fiDeliverycost.setReviewDept(null); fiDeliverycost.setReviewDate(null); fiDeliverycost.setBatchNo(null); fiDeliverycost.setReviewUser(null); fiDeliverycost.setBatchNo(null); fiDeliverycost.setStatus(0l); save(fiDeliverycost); // 更新会计审核信息 } } else { // 如果只撤销一部分 double totalChange = 0.0; for (int i = 0; i < listAa.size(); i++) { totalChange = DoubleUtil.add(listAa.get(i).getAmount(), totalChange); // 修改的总金额 } // 财务接口 撤销部分应收应入 List<FiInterfaceProDto> listfiInterfaceDto = new ArrayList<FiInterfaceProDto>(); FiInterfaceProDto fiIn = new FiInterfaceProDto(); fiIn.setSourceData("提货成本"); fiIn.setSourceNo(listAa.get(0).getBatchNo()); fiIn.setAmount(totalChange); listfiInterfaceDto.add(fiIn); fiInterfaceImpl.revocationFiDeliveryCost(listfiInterfaceDto); // throw new ServiceException("正在开发中..."); for (FiDeliverycost fiDeliverycost : listAa) { fiDeliverycost.setReviewDept(null); fiDeliverycost.setReviewDate(null); fiDeliverycost.setReviewUser(null); fiDeliverycost.setBatchNo(null); fiDeliverycost.setStatus(0l); save(fiDeliverycost); // 更新会计审核信息 } } }