diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/domain/lease/MaterialLeaseApplyDetails.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/domain/lease/MaterialLeaseApplyDetails.java index 21e210fa..8e2a352c 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/domain/lease/MaterialLeaseApplyDetails.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/clz/domain/lease/MaterialLeaseApplyDetails.java @@ -180,6 +180,9 @@ public class MaterialLeaseApplyDetails extends BaseEntity { private String maIds; private String maCodes; + @ApiModelProperty("机具类型(1机具,2安全工器具)") + private int jiJuType; + public MaterialLeaseApplyDetails(Long id, Long parentId, Long typeId, BigDecimal preNum, BigDecimal auditNum, BigDecimal alNum, String status, Long companyId) { this.id = id; this.parentId = parentId; diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/push/controller/CostPushController.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/push/controller/CostPushController.java index 194bd019..b13724ea 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/push/controller/CostPushController.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/push/controller/CostPushController.java @@ -13,10 +13,7 @@ import com.bonus.material.push.domain.CostPushBean; import com.bonus.material.push.service.CostPushService; import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.bind.annotation.ResponseBody; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; @@ -82,6 +79,17 @@ public class CostPushController extends BaseController { } } + @GetMapping(value = "getConsumeDetailsByAgreementId") + public TableDataInfo getConsumeDetailsByAgreementId(CostPushBean o) { + try { + List results = service.getConsumeDetailsByAgreementId(o); + return getDataTable(results); + } catch (Exception e) { + logger.error(e.toString(), e); + throw new ServiceException("数据查询异常,请联系运维人员查询日志处理"); + } + } + /** * 查询消耗费用推送审核--列表 diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/push/controller/IwsCostPushController.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/push/controller/IwsCostPushController.java index 1cf205c0..3c1ea6e6 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/push/controller/IwsCostPushController.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/push/controller/IwsCostPushController.java @@ -1,5 +1,6 @@ package com.bonus.material.push.controller; +import cn.hutool.core.bean.BeanUtil; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.bonus.common.biz.utils.AesEncryptUtils; @@ -143,7 +144,7 @@ public class IwsCostPushController extends BaseController { } //startPage(); 取消分页 try { - List list = iwsCostPushService.getLeaseCostsByAgreementIdAndMonth(obj); + List list = iwsCostPushService.getLeaseCostsByAgreementIdAndMonthCountDay(obj); return getDataTable(list); } catch (Exception e) { System.err.println("数据查询异常 = " + e.getMessage()); @@ -186,7 +187,7 @@ public class IwsCostPushController extends BaseController { } SltAgreementInfo sltAgreementInfo = new SltAgreementInfo(); try { - sltAgreementInfo.setAgreementId(obj.getAgreementId()); + BeanUtil.copyProperties(obj, sltAgreementInfo); List loseList = sltAgreementInfoService.getLoseList(sltAgreementInfo); return getDataTable(loseList); } catch (NumberFormatException e) { @@ -208,7 +209,7 @@ public class IwsCostPushController extends BaseController { } SltAgreementInfo sltAgreementInfo = new SltAgreementInfo(); try { - sltAgreementInfo.setAgreementId(obj.getAgreementId()); + BeanUtil.copyProperties(obj, sltAgreementInfo); List scrapList = sltAgreementInfoService.getScrapList(sltAgreementInfo); return getDataTable(scrapList); } catch (NumberFormatException e) { diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/push/mapper/CostPushMapper.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/push/mapper/CostPushMapper.java index 9752de94..39d676f2 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/push/mapper/CostPushMapper.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/push/mapper/CostPushMapper.java @@ -59,4 +59,9 @@ public interface CostPushMapper { int updatePushXHStatus(CostPushBean bean); List getCostPushLeaseList(CostPushBean o); + + /** + * 查询已生成的消耗品明细费用 + */ + List getConsumeDetailsByAgreementId(CostPushBean o); } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/push/service/CostPushService.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/push/service/CostPushService.java index 2a2fee94..42c11fe4 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/push/service/CostPushService.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/push/service/CostPushService.java @@ -57,4 +57,6 @@ public interface CostPushService { int updatePushXHStatus(CostPushBean bean); List getCostPushLeaseList(CostPushBean o); + + List getConsumeDetailsByAgreementId(CostPushBean o); } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/push/service/IwsCostPushService.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/push/service/IwsCostPushService.java index eb99e0d4..6661a718 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/push/service/IwsCostPushService.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/push/service/IwsCostPushService.java @@ -31,10 +31,15 @@ public interface IwsCostPushService { AjaxResult computeTheMonthCost(IwsCostPushBean costDto); /** - * 根据协议ID及月份查询当月租赁费用明细 + * 根据协议ID及月份查询当月租赁费用明细(不计算天数) */ List getLeaseCostsByAgreementIdAndMonth(IwsCostPushBean record); + /** + * 根据协议ID及月份查询当月租赁费用明细(计算天数) + */ + List getLeaseCostsByAgreementIdAndMonthCountDay(IwsCostPushBean record); + /** * 根据工程查询领用信息 */ diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/push/service/impl/CostPushServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/push/service/impl/CostPushServiceImpl.java index 98834e16..89aff22c 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/push/service/impl/CostPushServiceImpl.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/push/service/impl/CostPushServiceImpl.java @@ -84,10 +84,12 @@ public class CostPushServiceImpl implements CostPushService { */ @Override public List getCostPushLeaseList(CostPushBean o) { - return dao.getCostPushLeaseList(o); } + public List getConsumeDetailsByAgreementId(CostPushBean o) { + return dao.getConsumeDetailsByAgreementId(o); + } @Override diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/push/service/impl/IwsCostPushServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/push/service/impl/IwsCostPushServiceImpl.java index 634f9351..394f823f 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/push/service/impl/IwsCostPushServiceImpl.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/push/service/impl/IwsCostPushServiceImpl.java @@ -1,5 +1,6 @@ package com.bonus.material.push.service.impl; +import cn.hutool.core.util.ArrayUtil; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.alibaba.nacos.common.utils.CollectionUtils; @@ -96,22 +97,16 @@ public class IwsCostPushServiceImpl implements IwsCostPushService { @Override public AjaxResult computeTheMonthCost(IwsCostPushBean costDto) { // 获取当前年月 例如:2025-01 - // todo String month = DateTimeHelper.getNowMonth(); -// String month = "2025-08"; // 获取当月第一天的日期和最后一天日期 LocalDateTime firstDayOfMonth = getFirstDayOfMonth(month); LocalDateTime lastDayOfMonth = getLastDayOfMonthZ(month); ZoneId zone = ZoneId.systemDefault(); // 当月第一天 LocalDate firstDay = LocalDate.now().withDayOfMonth(1); - // todo 测试用 -// LocalDate firstDay = LocalDate.of(2025, 8, 1); Date firstDate = Date.from(firstDay.atStartOfDay(zone).toInstant()); // 当月最后一天 LocalDate lastDay = LocalDate.now().withDayOfMonth(LocalDate.now().lengthOfMonth()); - // todo 测试用 -// LocalDate lastDay = LocalDate.of(2025, 8, 31); Date lastDate = Date.from(lastDay.atStartOfDay(zone).toInstant()); // 塞入当前年月到参数中 @@ -399,6 +394,71 @@ public class IwsCostPushServiceImpl implements IwsCostPushService { } } + + /** + * 根据协议ID及月份查询当月租赁费用明细(计算天数) + * + * @param record 传入查询的年月:yyyy-MM 及 协议ID + */ + @Override + public List getLeaseCostsByAgreementIdAndMonthCountDay(IwsCostPushBean record) { + if (Objects.isNull(record) || Objects.isNull(record.getMonth()) || Objects.isNull(record.getAgreementId())) { + System.err.println("查询信息为空 = " + record); + return Collections.emptyList(); + } + + // 获取前端传入年月对应的第一天与最后一天 LocalDateTime对象 + //LocalDateTime queryStartTime = getFirstDayOfMonth(record.getMonth()); + //LocalDateTime queryEndTime = getLastDayOfMonthZ(record.getMonth()); + + //List theMonthAgreementLeaseList = iwsCostPushMapper.getPaidSltBaseInfo(record); + List theMonthAgreementLeaseList = iwsCostPushMapper.getLeaseCostsByAgreementIdAndMonth(record); + if (CollectionUtils.isEmpty(theMonthAgreementLeaseList)) { + return Collections.emptyList(); + } else { + // 过滤异常数据 + theMonthAgreementLeaseList.removeIf(item -> + Objects.isNull(item) || + Objects.isNull(item.getTypeId()) || + Objects.isNull(item.getLeaseNum()) || + Objects.isNull(item.getLeasePrice()) + ); + for (IwsCostPushBean leaseCostInfo : theMonthAgreementLeaseList) { +// if (null == leaseCostInfo.getLeaseDate()) { continue; } +// if (null == leaseCostInfo.getBackDate()) { leaseCostInfo.setBackDate(queryEndTime); } +// +// // 校准计算后的日期 +// if (leaseCostInfo.getLeaseDate().isBefore(queryStartTime)) { +// leaseCostInfo.setLeaseDate(queryStartTime); +// } else if (leaseCostInfo.getLeaseDate().isAfter(queryEndTime)) { +// leaseCostInfo.setLeaseDays(0); +// leaseCostInfo.setDelFlag(true); +// continue; +// } +// if (leaseCostInfo.getBackDate().isAfter(queryEndTime)) { +// leaseCostInfo.setBackDate(queryEndTime); +// } else if (leaseCostInfo.getBackDate().isBefore(queryStartTime)) { +// leaseCostInfo.setLeaseDays(0); +// leaseCostInfo.setDelFlag(true); +// continue; +// } +// +// // 计算天数 + leaseCostInfo.setLeaseDays(Math.toIntExact(calculateDaysInclusive(leaseCostInfo.getLeaseDate(), leaseCostInfo.getBackDate()))); +// // 计算费用 +// leaseCostInfo.setLeaseMoney(new BigDecimal(leaseCostInfo.getLeaseDays()) +// .multiply(leaseCostInfo.getLeasePrice()) +// .multiply(leaseCostInfo.getLeaseNum()).setScale(2, RoundingMode.HALF_UP) +// ); +// + } + + // 删除标记的非期间段数据 + // theMonthAgreementLeaseList.removeIf(IwsCostPushBean::isDelFlag); + return theMonthAgreementLeaseList; + } + } + /** * 计算月结费用详情 * @param agreementList 协议集合 @@ -797,8 +857,6 @@ public class IwsCostPushServiceImpl implements IwsCostPushService { rentalCostsBean.setPushRemark(resultPushRemark); rentalCostsBean.setPushStatus(pushStatus); list.set(j, rentalCostsBean); - } else { - continue; } } } @@ -849,7 +907,7 @@ public class IwsCostPushServiceImpl implements IwsCostPushService { @Override public AjaxResult safetyMaterialCostPush(IwsCostPushBean costDto) { List proIdsBeans = new ArrayList<>(); - if(costDto.getAgreementIds().length>0){ + if (ArrayUtil.isNotEmpty(costDto.getAgreementIds())) { // 将协议合并成工程 proIdsBeans = iwsCostPushMapper.getProIdsByAgreementIds(costDto.getAgreementIds()); String month = iwsCostPushMapper.getMonth(costDto); @@ -860,10 +918,9 @@ public class IwsCostPushServiceImpl implements IwsCostPushService { proIdsBean.setTaskId(costDto.getTaskId()); proIdsBean.setMonth(month); List list = getSafetyMonthCosts(proIdsBean); - if(CollectionUtils.isNotEmpty(list)){ + if (CollectionUtils.isNotEmpty(list)) { //分段推送 forHttpYouerSafety(list,proIdsBean); - } } } @@ -871,10 +928,10 @@ public class IwsCostPushServiceImpl implements IwsCostPushService { } - public List getSafetyMonthCosts(IwsCostPushBean proIdsBean){ + public List getSafetyMonthCosts(IwsCostPushBean proIdsBean) { List list = new ArrayList<>(); //确定各个工程下的协议有哪些 - proIdsBean.setAgreementIds(proIdsBean.getAgreementIdsStr().split( ",")); + proIdsBean.setAgreementIds(proIdsBean.getAgreementIdsStr().split(",")); proIdsBean.setType("1"); proIdsBean.setSettlementType(2); proIdsBean.setComsumeType(0); @@ -899,7 +956,6 @@ public class IwsCostPushServiceImpl implements IwsCostPushService { /** * 安全工机具分段推送 - * */ private void forHttpYouerSafety(List list,IwsCostPushBean proIdsBean) { System.err.println("list-=========:" + list.toString()); @@ -909,12 +965,12 @@ public class IwsCostPushServiceImpl implements IwsCostPushService { // 数据推送,http请求 encrypt = AesEncryptUtils.encrypt(content, HttpHelper.KEY); System.err.println("租赁费、维修费用、报废费推送数据解密======:" + AesEncryptUtils.decrypt(encrypt, HttpHelper.KEY)); - Map map = new HashMap(); + Map map = new HashMap<>(); map.put("body", encrypt); String body = JSONObject.toJSONString(map); String url = "http://10.138.55.113:8036/micro-server/zzaqgjf/syncSafetyTool"; - // String url = "http://10.138.55.105:8097/micro-server/zzaqgjf/syncSafetyTool"; -// String url = "http://192.168.1.121:8036/micro-server/zzaqgjf/syncSafetyTool"; + // String url = "http://10.138.55.105:8097/micro-server/zzaqgjf/syncSafetyTool"; + // String url = "http://192.168.1.121:8036/micro-server/zzaqgjf/syncSafetyTool"; String data = HttpHelper.sendHttpPostPushCost(url, body); JSONObject object = JSONObject.parseObject(data); System.err.println(data); @@ -923,10 +979,9 @@ public class IwsCostPushServiceImpl implements IwsCostPushService { // 创建数据更新参数 IwsCostPushBean pushBean = new IwsCostPushBean(); // 推送完成,循环更新本次审核的数据 - for (int i = 0; i < list.size(); i++) { + for (IwsCostPushBean bean : list) { // 获取单个数据 - IwsCostPushBean bean = list.get(i); - String pushStatus = "0"; + String pushStatus; String pushStatuString = bean.getPushStatus(); if (StringHelper.isEmpty(pushStatuString)) { pushStatus = "1"; @@ -947,10 +1002,9 @@ public class IwsCostPushServiceImpl implements IwsCostPushService { } } } catch (Exception e) { - // TODO Auto-generated catch block - e.printStackTrace(); + log.error(e.getMessage()); + System.err.println(e.getMessage()); } - } @@ -984,8 +1038,7 @@ public class IwsCostPushServiceImpl implements IwsCostPushService { } - public List getSafetyConsumeMonthCosts(IwsCostPushBean proIdsBean){ - List list = new ArrayList<>(); + public List getSafetyConsumeMonthCosts(IwsCostPushBean proIdsBean) { //确定各个工程下的协议有哪些 proIdsBean.setAgreementIds(proIdsBean.getAgreementIdsStr().split( ",")); proIdsBean.setType("1"); @@ -994,11 +1047,8 @@ public class IwsCostPushServiceImpl implements IwsCostPushService { // 获取租赁详情列表 List rentalCostList = iwsCostPushMapper.getSafetyConsumeCostList(proIdsBean); - - list.addAll(rentalCostList); - - - return list; + // 修改为构造化函数创建 + return new ArrayList<>(rentalCostList); } diff --git a/bonus-modules/bonus-material/src/main/resources/mapper/material/clz/MaterialLeaseInfoMapper.xml b/bonus-modules/bonus-material/src/main/resources/mapper/material/clz/MaterialLeaseInfoMapper.xml index e4ec2891..55c7d4f3 100644 --- a/bonus-modules/bonus-material/src/main/resources/mapper/material/clz/MaterialLeaseInfoMapper.xml +++ b/bonus-modules/bonus-material/src/main/resources/mapper/material/clz/MaterialLeaseInfoMapper.xml @@ -117,7 +117,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" IFNULL(lad.pre_num,0) as pre_num, IFNULL(lad.audit_num,0) as audit_num, IFNULL(lad.al_num,0) as al_num, - IFNULL(lad.status,0) as status, mt.unit_name ,mt.unit_value, + IFNULL(lad.status,0) as status, mt.unit_name ,mt.unit_value,mt.jiju_type as jijuType, lad.create_by, lad.create_time, lad.update_by, lad.update_time, lad.remark as remark, lad.company_id from clz_lease_apply_details lad @@ -642,6 +642,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" SUM( IFNULL(lod.out_num, 0) ) AS preNum, mt.manage_type AS manageType, mt.type_id AS typeId, + mt.jiju_type AS jijuType, lod.parent_id AS parentId FROM clz_lease_out_details lod diff --git a/bonus-modules/bonus-material/src/main/resources/mapper/material/push/MybatisGenerator.xml b/bonus-modules/bonus-material/src/main/resources/mapper/material/push/MybatisGenerator.xml index ebc1d22f..6c57b0ec 100644 --- a/bonus-modules/bonus-material/src/main/resources/mapper/material/push/MybatisGenerator.xml +++ b/bonus-modules/bonus-material/src/main/resources/mapper/material/push/MybatisGenerator.xml @@ -250,17 +250,17 @@ pmi.leaseDate as leaseDate, pmi.returnDate as backDate, pmi.leasePrice as leasePrice, - pmi.leaseNum as leaseNum, + pmi.leaseNum as num, + (DATEDIFF(pmi.returnDate, pmi.leaseDate) + 1) AS dayNum, pmi.leaseMoney as leaseMoney, saa.audit_time as sltTime from project_month_info pmi - left join slt_agreement_apply saa on pmi.agreementId = sas.agreement_id - left join ma_type mt1 on pmi.type_id = mt1.type_id + left join slt_agreement_apply saa on pmi.agreementId = saa.agreement_id + left join ma_type mt1 on pmi.typeId = mt1.type_id left join ma_type mt2 on mt1.parent_id = mt2.type_id where pmi.agreementId = #{agreementId} and pmi.taskId = #{taskId} and - pmi.type = 1 and pmi.jiju_type = 2 and mt1.type_name LIKE CONCAT('%',#{typeName},'%') @@ -269,4 +269,17 @@ and mt2.type_name LIKE CONCAT('%',#{modelName},'%') + + \ No newline at end of file