增加已结算费用查询功能,优化领料明细获取逻辑

This commit is contained in:
syruan 2025-09-25 17:54:00 +08:00
parent fc24c9d576
commit 5cec3ddecf
5 changed files with 53 additions and 15 deletions

View File

@ -290,11 +290,7 @@ public class SltAgreementInfoController extends BaseController {
/**
* 导出结算单
* @param response
* @param list
* @param filename
* @throws Exception
* @throws Exception 异常
*/
private void expOutExcel(HttpServletResponse response, List<SltLeaseInfo> list, String filename,String projectName,String unitName,BigDecimal totalCost,int type) throws Exception {
if (list != null) {
@ -332,7 +328,7 @@ public class SltAgreementInfoController extends BaseController {
/**
* 导出结算单--all
* @throws Exception
* @throws Exception 异常信息
*/
private void expOutExcelAll(HttpServletResponse response, List<SltLeaseInfo> lease,List<SltLeaseInfo> lose,List<SltLeaseInfo> repair,List<SltLeaseInfo> scrap,List<SltLeaseInfo> reduction,
String filename,String projectName,String unitName,BigDecimal totalCostLease,BigDecimal totalCostLose,BigDecimal totalCostRepair,BigDecimal totalCostScrap,BigDecimal totalCostReduction)
@ -388,7 +384,6 @@ public class SltAgreementInfoController extends BaseController {
workbook.write(out);
out.flush();
out.close();
}

View File

@ -8,21 +8,21 @@ import com.fasterxml.jackson.annotation.JsonFormat;
import com.bonus.common.core.annotation.Excel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import com.bonus.common.core.web.domain.BaseEntity;
import lombok.experimental.Accessors;
/**
* 结算信息对象 slt_agreement_info
*
* @author xsheng
* @date 2024-10-16
*/
@EqualsAndHashCode(callSuper = false)
@Data
@ToString
@Accessors(chain = true)
public class SltAgreementInfo extends BaseEntity {
private static final long serialVersionUID = 1L;
private static final long serialVersionUID = -3531370525106104195L;
/** ID */
private Long id;
@ -159,7 +159,6 @@ public class SltAgreementInfo extends BaseEntity {
@ApiModelProperty(value = "租赁费用")
private BigDecimal costs;
/**
* 项目名称
*/
@ -253,5 +252,10 @@ public class SltAgreementInfo extends BaseEntity {
private String unitValue;
/**
* 是否查询已结算的费用
*/
private Boolean enableQuerySltData = false;
}

View File

@ -93,6 +93,9 @@ public interface SltAgreementInfoMapper {
int insSltInfo(@Param("record") LeaseOutDetails record, @Param("agreementId")String agreementId, @Param("ma") Type ma);
// 查询一个协议号的已结算领料详情
List<SltAgreementInfo> getLeaseSltDetails(SltAgreementInfo record);
// 查询一个协议号的领料详情
List<SltAgreementInfo> getLeaseList(SltAgreementInfo bean);

View File

@ -381,7 +381,13 @@ public class SltAgreementInfoServiceImpl implements ISltAgreementInfoService {
* 获取单个协议的领料明细
*/
public List<SltAgreementInfo> getLeaseList(SltAgreementInfo info) {
List<SltAgreementInfo> oneOfList = sltAgreementInfoMapper.getLeaseList(info);
List<SltAgreementInfo> oneOfList;
// 如果开启了查询已结算数据那么就从结算记录📝里面查询已结算的租赁费用明细
if (info != null && info.getEnableQuerySltData() != null && info.getEnableQuerySltData()) {
oneOfList = sltAgreementInfoMapper.getLeaseSltDetails(info);
} else {
oneOfList = sltAgreementInfoMapper.getLeaseList(info);
}
List<SltAgreementInfo> leaseList = new ArrayList<>(oneOfList);
for (SltAgreementInfo bean : leaseList) {
@ -402,9 +408,12 @@ public class SltAgreementInfoServiceImpl implements ISltAgreementInfoService {
if (leaseDays.compareTo(BigDecimal.ZERO) < 0) {
leaseDays = BigDecimal.ZERO;
}
// 如果费用是空的null0 那么就根据数量和单价计算
if (bean.getCosts() == null || bean.getCosts().compareTo(BigDecimal.ZERO) < 0 || bean.getCosts().equals(BigDecimal.ZERO)) {
BigDecimal costs = leasePrice.multiply(num).multiply(leaseDays).setScale(GlobalConstants.INT_2, RoundingMode.DOWN);
bean.setCosts(costs);
}
}
return leaseList;
}

View File

@ -1393,4 +1393,31 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</if>
</select>
<select id="getLeaseSltDetails" resultType="com.bonus.material.settlement.domain.SltAgreementInfo">
SELECT
bai.agreement_id AS agreementId,
bui.unit_name as unitName,
bp.pro_name as projectName,
sad.type_id as typeId,
sad.ma_id as maId,
sad.money as costs,
mt1.type_name as typeName,
mt.type_name as modelName,
mt.unit_name as mtUnitName,
sad.price as leasePrice,
sad.num as num,
DATE(sad.start_time) as startTime,
DATE(sad.end_time) as endTime,
DATEDIFF(IF(sad.end_time is null,CURDATE(),sad.end_time), sad.start_time) + 1 as leaseDays
FROM
bm_agreement_info bai
LEFT JOIN slt_agreement_apply saa ON bai.agreement_id = saa.agreement_id AND saa.settlement_type = #{settlementType}
LEFT JOIN slt_agreement_details sad ON saa.id = sad.apply_id AND sad.slt_type = '1'
LEFT JOIN bm_project bp ON bp.pro_id = bai.project_id
LEFT JOIN bm_unit bui ON bui.unit_id = bai.unit_id
left join ma_type mt on sad.type_id = mt.type_id
left join ma_type mt1 on mt.parent_id = mt1.type_id
where
bai.agreement_id = #{agreementId}
</select>
</mapper>