This commit is contained in:
hongchao 2025-09-30 18:54:32 +08:00
commit 73f3c4bcbf
10 changed files with 134 additions and 44 deletions

View File

@ -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;

View File

@ -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<CostPushBean> results = service.getConsumeDetailsByAgreementId(o);
return getDataTable(results);
} catch (Exception e) {
logger.error(e.toString(), e);
throw new ServiceException("数据查询异常,请联系运维人员查询日志处理");
}
}
/**
* 查询消耗费用推送审核--列表

View File

@ -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<IwsCostPushBean> list = iwsCostPushService.getLeaseCostsByAgreementIdAndMonth(obj);
List<IwsCostPushBean> 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<SltAgreementInfo> 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<SltAgreementInfo> scrapList = sltAgreementInfoService.getScrapList(sltAgreementInfo);
return getDataTable(scrapList);
} catch (NumberFormatException e) {

View File

@ -59,4 +59,9 @@ public interface CostPushMapper {
int updatePushXHStatus(CostPushBean bean);
List<CostPushBean> getCostPushLeaseList(CostPushBean o);
/**
* 查询已生成的消耗品明细费用
*/
List<CostPushBean> getConsumeDetailsByAgreementId(CostPushBean o);
}

View File

@ -57,4 +57,6 @@ public interface CostPushService {
int updatePushXHStatus(CostPushBean bean);
List<CostPushBean> getCostPushLeaseList(CostPushBean o);
List<CostPushBean> getConsumeDetailsByAgreementId(CostPushBean o);
}

View File

@ -31,10 +31,15 @@ public interface IwsCostPushService {
AjaxResult computeTheMonthCost(IwsCostPushBean costDto);
/**
* 根据协议ID及月份查询当月租赁费用明细
* 根据协议ID及月份查询当月租赁费用明细不计算天数
*/
List<IwsCostPushBean> getLeaseCostsByAgreementIdAndMonth(IwsCostPushBean record);
/**
* 根据协议ID及月份查询当月租赁费用明细计算天数
*/
List<IwsCostPushBean> getLeaseCostsByAgreementIdAndMonthCountDay(IwsCostPushBean record);
/**
* 根据工程查询领用信息
*/

View File

@ -84,10 +84,12 @@ public class CostPushServiceImpl implements CostPushService {
*/
@Override
public List<CostPushBean> getCostPushLeaseList(CostPushBean o) {
return dao.getCostPushLeaseList(o);
}
public List<CostPushBean> getConsumeDetailsByAgreementId(CostPushBean o) {
return dao.getConsumeDetailsByAgreementId(o);
}
@Override

View File

@ -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<IwsCostPushBean> 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<IwsCostPushBean> theMonthAgreementLeaseList = iwsCostPushMapper.getPaidSltBaseInfo(record);
List<IwsCostPushBean> 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<IwsCostPushBean> 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<IwsCostPushBean> 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<IwsCostPushBean> getSafetyMonthCosts(IwsCostPushBean proIdsBean){
public List<IwsCostPushBean> getSafetyMonthCosts(IwsCostPushBean proIdsBean) {
List<IwsCostPushBean> 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<IwsCostPushBean> 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<String, String> map = new HashMap<String, String>();
Map<String, String> 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<IwsCostPushBean> getSafetyConsumeMonthCosts(IwsCostPushBean proIdsBean){
List<IwsCostPushBean> list = new ArrayList<>();
public List<IwsCostPushBean> getSafetyConsumeMonthCosts(IwsCostPushBean proIdsBean) {
//确定各个工程下的协议有哪些
proIdsBean.setAgreementIds(proIdsBean.getAgreementIdsStr().split( ","));
proIdsBean.setType("1");
@ -994,11 +1047,8 @@ public class IwsCostPushServiceImpl implements IwsCostPushService {
// 获取租赁详情列表
List<IwsCostPushBean> rentalCostList = iwsCostPushMapper.getSafetyConsumeCostList(proIdsBean);
list.addAll(rentalCostList);
return list;
// 修改为构造化函数创建
return new ArrayList<>(rentalCostList);
}

View File

@ -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

View File

@ -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
<if test="typeName != null and typeName != '' ">
and mt1.type_name LIKE CONCAT('%',#{typeName},'%')
@ -269,4 +269,17 @@
and mt2.type_name LIKE CONCAT('%',#{modelName},'%')
</if>
</select>
<select id="getConsumeDetailsByAgreementId" resultType="com.bonus.material.push.domain.CostPushBean">
SELECT
pmi.agreementId, pmi.typeId, pmi.leaseDate, pmi.returnDate as backDate,
pmi.money as consMoney, mt4.type_name as modelName, mt3.type_name as typeName,pmi.leaseNum as num
FROM
project_month_info pmi
LEFT JOIN ma_type mt4 ON pmi.typeId = mt4.type_id
LEFT JOIN ma_type mt3 ON mt4.parent_id = mt3.type_id
WHERE pmi.money > 0
AND pmi.agreementId = #{agreementId}
AND pmi.taskId = #{taskId}
</select>
</mapper>