diff --git a/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/SltAgreementInfo.java b/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/SltAgreementInfo.java index 63692b90..3c191aa7 100644 --- a/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/SltAgreementInfo.java +++ b/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/SltAgreementInfo.java @@ -1,8 +1,10 @@ package com.bonus.sgzb.base.api.domain; +import com.bonus.sgzb.common.core.annotation.Excel; import lombok.Data; import java.math.BigDecimal; +import java.util.List; /** * @author c liu @@ -14,6 +16,10 @@ public class SltAgreementInfo { * */ private Long id; + /** + * + */ + private String ids; /** *协议id */ @@ -41,14 +47,17 @@ public class SltAgreementInfo { /** *领料数量 */ + @Excel(name = "数量") private String num; /** *领料时间 */ + @Excel(name = "开始日期") private String startTime; /** *退料时间 */ + @Excel(name = "结算日期") private String endTime; /** *0在用1退回 @@ -65,6 +74,7 @@ public class SltAgreementInfo { /** *租赁单价 */ + @Excel(name = "台班费单价(元/天)") private String leasePrice; /** *原值 @@ -77,34 +87,50 @@ public class SltAgreementInfo { /** * 项目名称 */ + @Excel(name = "领用单位") private String unitName; /** * 工程名称 */ + @Excel(name = "工程名称") private String projectName; /** * 设备名称 */ + @Excel(name = "设备名称") private String typeName; /** * 规格型号 */ + @Excel(name = "规格型号") private String modelName; /** * 计量单位 */ + @Excel(name = "单位") private String nuitName; /** * 租赁天数 */ + @Excel(name = "结算天数") private String leaseDays; /** * 租赁费用 */ + @Excel(name = "结算金额") private String costs; + /** + * 配件总价 + */ + private String partAllCosts; + /** + * 总价 + */ + private String allCosts; /** * 真实租赁费用 */ + @Excel(name = "本月暂计金额") private String realCosts; /** * 类型(0不收费,1收费) @@ -127,6 +153,7 @@ public class SltAgreementInfo { /** * 费用承担方 */ + @Excel(name = "费用承担方") private String costBearingParty; /** * 调整天数 @@ -140,5 +167,23 @@ public class SltAgreementInfo { * 是否结算(0 未结算 1已结算) */ private String isSlt; - + /** + * 月份 + */ + private String month; + /** + * 月份 + */ + private String nextMonth; + /** + * 委外维修费用 + */ + private String outSourceCosts; + private String beginTime; + private String offTime; + private String partModelName; + private String partName; + private Integer codeNum; + private List node; + } diff --git a/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/SltInfoVo.java b/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/SltInfoVo.java index 5a47bd85..e8566cff 100644 --- a/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/SltInfoVo.java +++ b/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/SltInfoVo.java @@ -13,6 +13,7 @@ public class SltInfoVo { /** * 租赁费用列表(01、03) */ + List leaseList; List leaseListOne; List leaseListThree; /** @@ -23,6 +24,10 @@ public class SltInfoVo { * 报废费用列表 */ List scrapList; + /** + * 预报废费用列表 + */ + List preScrapList; /** * 丢失费用列表 */ diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/controller/SltAgreementInfoController.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/controller/SltAgreementInfoController.java index 395488c6..c3c61bb7 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/controller/SltAgreementInfoController.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/controller/SltAgreementInfoController.java @@ -1,5 +1,6 @@ package com.bonus.sgzb.material.controller; +import cn.hutool.core.collection.CollUtil; import cn.hutool.core.convert.Convert; import com.bonus.sgzb.base.api.domain.SltAgreementApply; import com.bonus.sgzb.base.api.domain.SltAgreementDetails; @@ -11,10 +12,7 @@ import com.bonus.sgzb.common.core.web.domain.AjaxResult; import com.bonus.sgzb.common.core.web.page.TableDataInfo; import com.bonus.sgzb.common.log.annotation.Log; import com.bonus.sgzb.common.log.enums.BusinessType; -import com.bonus.sgzb.material.domain.AgreementInfo; -import com.bonus.sgzb.material.domain.LeaseInfo; -import com.bonus.sgzb.material.domain.LoseInfo; -import com.bonus.sgzb.material.domain.ScrapInfo; +import com.bonus.sgzb.material.domain.*; import com.bonus.sgzb.material.service.SltAgreementInfoService; import io.swagger.annotations.ApiOperation; import org.springframework.beans.factory.annotation.Autowired; @@ -47,7 +45,7 @@ public class SltAgreementInfoController extends BaseController { } /** - * 根据协议获取完工结算清单 + * 根据协议获取结算清单 */ @ApiOperation(value = "根据协议获取结算清单") @PostMapping("/getSltInfo") @@ -57,13 +55,41 @@ public class SltAgreementInfoController extends BaseController { } /** - * 根据协议获取完工结算清单 + * 根据协议获取月结算清单 */ - @ApiOperation(value = "根据协议获取结算清单") + @ApiOperation(value = "根据协议获取月结算清单") @PostMapping("/getSltInfoMonth") public AjaxResult getSltInfoMonth(@RequestBody List list) { - SltInfoVo bean = sltAgreementInfoService.getSltInfo(list); - return AjaxResult.success(bean); + return AjaxResult.success(sltAgreementInfoService.getSltInfoMonth(list)); + } + + @ApiOperation(value = "月结明细导出") + @PostMapping("/exportSltInfoMonth") + public void exportSltInfoMonth(HttpServletResponse response, @RequestBody List list) { + List sltInfoMonth = sltAgreementInfoService.getSltInfoMonth(list); + for (AgreementInfo agreementInfo : list) { + for (SltAgreementInfo sltAgreementInfo : sltInfoMonth) { + String[] split = agreementInfo.getCodeNum().split(","); + for (String s : split) { + if (s.equals(sltAgreementInfo.getCodeNum().toString())) { + List node = sltAgreementInfo.getNode(); + ExcelUtil util = new ExcelUtil(SltAgreementInfo.class); + util.exportExcel(response, node, "月结明细导出数据"); + } + } + } + } + } + + @ApiOperation(value = "批量月结明细导出") + @PostMapping("/exportBatchSltInfoMonth") + public void exportBatchSltInfoMonth(HttpServletResponse response, @RequestBody List list) { + List sltInfoMonth = sltAgreementInfoService.getSltInfoMonth(list); + for (SltAgreementInfo sltAgreementInfo : sltInfoMonth) { + List node = sltAgreementInfo.getNode(); + ExcelUtil util = new ExcelUtil(SltAgreementInfo.class); + util.exportExcel(response, node, "月结明细导出数据"); + } } /** @@ -122,8 +148,8 @@ public class SltAgreementInfoController extends BaseController { @PostMapping("/exportRepair") public void exportRepair(HttpServletResponse response, List list) { List explist = sltAgreementInfoService.getRepairList(list); - List leaseInfoList = Convert.toList(LeaseInfo.class, explist); - ExcelUtil util = new ExcelUtil(LeaseInfo.class); + List leaseInfoList = Convert.toList(RepairInfo.class, explist); + ExcelUtil util = new ExcelUtil(RepairInfo.class); util.exportExcel(response, leaseInfoList, "维修明细导出"); } @@ -139,6 +165,18 @@ public class SltAgreementInfoController extends BaseController { util.exportExcel(response, leaseInfoList, "维修明细导出"); } + /** + * 预报废明细导出 + */ + @Log(title = "预报废明细导出", businessType = BusinessType.EXPORT) + @PostMapping("/exportPreScrap") + public void exportPreScrap(HttpServletResponse response, List list) { + List explist = sltAgreementInfoService.getPreScrapList(list); + List leaseInfoList = Convert.toList(preScrapInfo.class, explist); + ExcelUtil util = new ExcelUtil(preScrapInfo.class); + util.exportExcel(response, leaseInfoList, "维修明细导出"); + } + /** * 费用结算提交 */ @@ -148,6 +186,24 @@ public class SltAgreementInfoController extends BaseController { return sltAgreementInfoService.submitFee(apply); } + /** + * 费用结算提交 + */ + @ApiOperation(value = "委外费用修改") + @PostMapping("/updateOutSourceCosts") + public AjaxResult updateOutSourceCosts(@RequestBody List apply) { + if (CollUtil.isEmpty(apply)) { + return AjaxResult.error("请选择设备维修单"); + } + for (SltAgreementInfo sltAgreementInfo : apply) { + int res = sltAgreementInfoService.updateOutSourceCosts(sltAgreementInfo); + if (res == 0) { + return AjaxResult.error("修改失败"); + } + } + return AjaxResult.success("修改成功"); + } + /** * 费用结算提交 */ diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/AgreementInfo.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/AgreementInfo.java index bf75bae8..991459ef 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/AgreementInfo.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/AgreementInfo.java @@ -15,7 +15,7 @@ import java.util.List; @Data public class AgreementInfo extends BaseEntity { private static final long serialVersionUID = 1L; - + private String ids; /** * 协议ID */ @@ -112,6 +112,12 @@ public class AgreementInfo extends BaseEntity { @ApiModelProperty(value = "关键字") private String keyWord; + @ApiModelProperty(value = "开始时间") + private String startTime; + @ApiModelProperty(value = "结束时间") + private String endTime; + @ApiModelProperty(value = "结算月份") + private String month; /** * 备注 @@ -130,8 +136,17 @@ public class AgreementInfo extends BaseEntity { private String cost; @ApiModelProperty(value = "结算状态") private String sltStatus; + @ApiModelProperty(value = "费用承担方") + private String costBearingParty; + private String codeNum; + /** + * 是否结算 + */ + private Integer isSlt; - /** 导出选中列表 */ + /** + * 导出选中列表 + */ @ApiModelProperty(value = "导出选中列表") private List dataCondition; diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/LeaseInfo.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/LeaseInfo.java index a4dddf20..5fda1ac9 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/LeaseInfo.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/LeaseInfo.java @@ -47,6 +47,14 @@ public class LeaseInfo { * */ private String companyId; + /** + * 配件名称 + */ + private String partName; + /** + *配件型号 + */ + private String partModelName; /** * 项目名称 */ diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/RepairInfo.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/RepairInfo.java index 16725ba5..e3140e1a 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/RepairInfo.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/RepairInfo.java @@ -46,6 +46,16 @@ public class RepairInfo { * */ private String companyId; + /** + * 配件名称 + */ + @Excel(name = "配件名称") + private String partName; + /** + *配件型号 + */ + @Excel(name = "配件型号") + private String partModelName; /** * 项目名称 */ @@ -78,7 +88,7 @@ public class RepairInfo { /** *领料数量 */ - @Excel(name = "维修数量") + @Excel(name = "数量") private String num; /** *领料时间 @@ -93,14 +103,41 @@ public class RepairInfo { */ private String leaseDays; /** - * 租赁费用 + * 实际结算天数 */ - @Excel(name = "维修费用") + private String realDays; + /** + * 应结算金额 + */ + @Excel(name = "配件单价") private String costs; + /** + * 实际结算金额 + */ + @Excel(name = "实际结算金额(元)") + private String realCosts; + /** + * 配件总价 + */ + @Excel(name = "配件总价(元)") + private String partAllCosts; + /** + * 费用总价 + */ + @Excel(name = "费用总价") + private String allCosts; + /** + * 委外维修费用 + */ + @Excel(name = "委外维修费用") + private String outSourceCosts; + /** + * 实际结算金额 + */ + private String trimDay; /** * 类型(0不收费,1收费) */ - @Excel(name = "是否收费") private String partType; /** * 维修审核:0未审核,1已审核,2已驳回 diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/ScrapInfo.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/ScrapInfo.java index 3fed14c1..548205dd 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/ScrapInfo.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/ScrapInfo.java @@ -25,6 +25,11 @@ public class ScrapInfo { *机具id */ private String maId; + /** + *设备编码 + */ + @Excel(name = "设备编码") + private String maCode; /** *0在用1退回 @@ -41,6 +46,7 @@ public class ScrapInfo { /** *原值 */ + @Excel(name = "赔偿单价") private String buyPrice; /** * @@ -95,7 +101,6 @@ public class ScrapInfo { /** * (0自然,1人为) */ - @Excel(name = "报废原因") private String scrapType; /** * 租赁费用 diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/preScrapInfo.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/preScrapInfo.java new file mode 100644 index 00000000..0e64ad45 --- /dev/null +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/preScrapInfo.java @@ -0,0 +1,122 @@ +package com.bonus.sgzb.material.domain; + +import com.bonus.sgzb.common.core.annotation.Excel; +import lombok.Data; + +/** + * @author c liu + * @date 2024/2/21 + */ +@Data +public class preScrapInfo { + /** + * + */ + private Long id; + /** + *协议id + */ + private String agreementId; + /** + *机具规格id + */ + private String typeId; + /** + *机具id + */ + private String maId; + /** + *设备编码 + */ + @Excel(name = "设备编码") + private String maCode; + + /** + *0在用1退回 + */ + private String status; + /** + *领料id + */ + private String leaseId; + /** + *退料id + */ + private String backId; + /** + *原值 + */ + private String buyPrice; + /** + * + */ + private String companyId; + /** + * 项目名称 + */ + private String unitName; + /** + * 工程名称 + */ + private String projectName; + /** + * 设备名称 + */ + @Excel(name = "设备名称") + private String typeName; + /** + * 规格型号 + */ + @Excel(name = "规格型号") + private String modelName; + /** + * 计量单位 + */ + @Excel(name = "计量单位") + private String nuitName; + /** + *租赁单价 + */ + private String leasePrice; + /** + *领料数量 + */ + @Excel(name = "报废数量") + private String num; + /** + *领料时间 + */ + private String startTime; + /** + *退料时间 + */ + private String endTime; + /** + * 租赁天数 + */ + private String leaseDays; + /** + * (0自然,1人为) + */ + private String scrapType; + /** + * 租赁费用 + */ + private String costs; + /** + * 类型(0不收费,1收费) + */ + private String partType; + /** + * 维修审核:0未审核,1已审核,2已驳回 + */ + private String repairStatus; + + /** + * 费用类型:1租赁2丢失3维修4报废 + */ + private String sltType; + private String applyId; + + +} diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/mapper/SltAgreementInfoMapper.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/mapper/SltAgreementInfoMapper.java index d66d39aa..0530ee47 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/mapper/SltAgreementInfoMapper.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/mapper/SltAgreementInfoMapper.java @@ -56,4 +56,18 @@ public interface SltAgreementInfoMapper { int updateTrimDay(SltAgreementInfo sltAgreementInfo); int updateInfoOneStatus(SltAgreementInfo apply); + + List getLeaseListOneMonth(@Param("bean") AgreementInfo bean, @Param("ids") List idList); + + List getLeaseListThreeMonth(AgreementInfo bean); + + List getLeaseListMonth(AgreementInfo bean); + + List getLeaseListMonthNotNull(AgreementInfo bean); + + List getPreScrapDetailsList(@Param("taskList") List taskList); + + int updateOutSourceCosts(SltAgreementInfo sltAgreementInfo); + + int updateBmAgreementInfo(@Param("agreementId") String agreementId); } diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/SltAgreementInfoService.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/SltAgreementInfoService.java index 3477d3c5..25b6998c 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/SltAgreementInfoService.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/SltAgreementInfoService.java @@ -35,6 +35,11 @@ public interface SltAgreementInfoService { List getRepairList(List list); List getScrapList(List list); + List getPreScrapList(List list); int updateTrimDay(List sltAgreementInfo); + + List getSltInfoMonth(List list); + + int updateOutSourceCosts(SltAgreementInfo sltAgreementInfo); } diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/ScrapApplyDetailsServiceImpl.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/ScrapApplyDetailsServiceImpl.java index 69506db2..afd58e87 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/ScrapApplyDetailsServiceImpl.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/ScrapApplyDetailsServiceImpl.java @@ -492,7 +492,8 @@ public class ScrapApplyDetailsServiceImpl implements IScrapApplyDetailsService { if (notScrapList.size() == scrapApplyDetailsList.size()) { task.setTaskStatus(59); } - } else { + } else + { status = "2"; List backList = new ArrayList<>(); List repairList = new ArrayList<>(); diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/SltAgreementInfoServiceImpl.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/SltAgreementInfoServiceImpl.java index 7e57f452..40e6953d 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/SltAgreementInfoServiceImpl.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/SltAgreementInfoServiceImpl.java @@ -15,6 +15,7 @@ import com.bonus.sgzb.material.domain.TmTask; import com.bonus.sgzb.material.mapper.SltAgreementInfoMapper; import com.bonus.sgzb.material.service.SltAgreementInfoService; import com.bonus.sgzb.material.vo.GlobalContants; +import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -50,18 +51,50 @@ public class SltAgreementInfoServiceImpl implements SltAgreementInfoService { List repairList = getRepairList(list); //报废费用列表 List scrapList = getScrapList(list); + //预报废费用列表 + List preScrapList = getPreScrapList(list); //丢失费用列表 List loseList = getLoseList(list); sltInfoVo.setLeaseListOne(leaseListOne); sltInfoVo.setLeaseListThree(leaseListThree); sltInfoVo.setRepairList(repairList); sltInfoVo.setScrapList(scrapList); + sltInfoVo.setPreScrapList(preScrapList); sltInfoVo.setLoseList(loseList); List relations = getRelations(leaseListOne, leaseListThree, repairList, scrapList, loseList, list); sltInfoVo.setRelations(relations); return sltInfoVo; } + public List getPreScrapList(List list) { + List scrapList = new ArrayList<>(); + String taskType = "57"; + for (AgreementInfo bean : list) { + List taskList = sltAgreementInfoMapper.getTaskList(bean, taskType); + if (taskList != null && taskList.size() > 0) { + List scrapDetailsList = sltAgreementInfoMapper.getPreScrapDetailsList(taskList); + scrapList.addAll(scrapDetailsList); + } + } + + if (scrapList != null && scrapList.size() > 0) { + for (SltAgreementInfo bean : scrapList) { + if (bean.getBuyPrice() == null) { + bean.setBuyPrice("0"); + } + if (bean.getNum() == null) { + bean.setNum("0"); + } + BigDecimal buyPrice = new BigDecimal(bean.getBuyPrice()); + BigDecimal num = new BigDecimal(bean.getNum()); + BigDecimal costs = buyPrice.multiply(num); + bean.setCosts(String.valueOf(costs)); + } + } + + return scrapList; + } + @Override public SltInfoVo getSltExamInfo(SltAgreementApply apply) { SltInfoVo sltInfoVo = new SltInfoVo(); @@ -219,8 +252,8 @@ public class SltAgreementInfoServiceImpl implements SltAgreementInfoService { } for (SltAgreementInfo repair : repairList) { if (repair.getAgreementId().equals(info.getAgreementId().toString())) { - BigDecimal cost = new BigDecimal(repair.getCosts()); - repairCost = repairCost.add(cost); + BigDecimal allCost = new BigDecimal(repair.getAllCosts()); + repairCost = repairCost.add(allCost); } } for (SltAgreementInfo scrap : scrapList) { @@ -267,80 +300,13 @@ public class SltAgreementInfoServiceImpl implements SltAgreementInfoService { @Override @Transactional public AjaxResult submitFee(SltAgreementApply apply) { - List relations = apply.getRelations(); - List list = new ArrayList<>(); - Long userid = SecurityUtils.getLoginUser().getUserid(); - String code = sltCodeRule("JS"); - apply.setCreator(String.valueOf(userid)); - apply.setCode(code); - apply.setCompanyId(relations.get(0).getCompanyId()); - int i = sltAgreementInfoMapper.insApply(apply); + sltAgreementInfoMapper.updateInfoStatus(apply.getAgreementId()); + int i = sltAgreementInfoMapper.updateBmAgreementInfo(apply.getAgreementId()); if (i > 0) { - for (SltAgreementRelation relation : relations) { - AgreementInfo info = new AgreementInfo(); - info.setAgreementId(Long.valueOf(relation.getAgreementId())); - list.add(info); - relation.setApplyId(String.valueOf(apply.getId())); - sltAgreementInfoMapper.updateInfoStatus(relation.getAgreementId()); - int j = sltAgreementInfoMapper.insRelation(relation); - if (j < 0) { - throw new ServiceException("新增协议结算记录失败"); - //throw new ServiceException(ExceptionDict.NEW_AGREEMENT_SETTLEMENT_ERROR_MSG,ExceptionDict.NEW_AGREEMENT_SETTLEMENT_ERROR); - } - } - List leaseListOne = getLeaseListOne(list); - List leaseListThree = getLeaseListThree(list); - List repairList = getRepairList(list); - List scrapList = getScrapList(list); - List loseList = getLoseList(list); - for (SltAgreementInfo info : leaseListOne) { - info.setSltType("1"); - //info.setSltType(CostTypeEnum.LEASE_COST.getCode()); - info.setApplyId(String.valueOf(apply.getId())); - info.setPartType("1"); - //info.setPartType(PartTypeEnum.CHARGE.getCode()); - sltAgreementInfoMapper.insDetails(info); - } - for (SltAgreementInfo info : leaseListThree) { - info.setSltType("1"); - //info.setSltType(CostTypeEnum.LEASE_COST.getCode()); - info.setApplyId(String.valueOf(apply.getId())); - info.setPartType("1"); - //info.setPartType(PartTypeEnum.CHARGE.getCode()); - sltAgreementInfoMapper.insDetails(info); - } - for (SltAgreementInfo info : repairList) { - info.setSltType("3"); - //info.setSltType(CostTypeEnum.MAINTENANCE_COST.getCode()); - info.setApplyId(String.valueOf(apply.getId())); - //对是否收费进行转换 - //info.setPartType(PartTypeEnum.getCodeByInfo(info.getPartType())); - info.setPartType(info.getPartType().equals("不收费") ? "0" : "1"); - sltAgreementInfoMapper.insDetails(info); - } - for (SltAgreementInfo info : scrapList) { - info.setSltType("4"); - //info.setSltType(CostTypeEnum.SCRAP_COST.getCode()); - info.setApplyId(String.valueOf(apply.getId())); - //info.setPartType(info.getScrapType()); - //info.setPartType(ScrapTypeEnum.getCodeByInfo(info.getScrapType())); - info.setPartType(info.getScrapType().equals("自然") ? "0" : "1"); - sltAgreementInfoMapper.insDetails(info); - } - for (SltAgreementInfo info : loseList) { - info.setSltType("2"); - //info.setSltType(CostTypeEnum.LOSE_COST.getCode()); - info.setApplyId(String.valueOf(apply.getId())); - info.setPartType("1"); - //info.setPartType(PartTypeEnum.CHARGE.getCode()); - sltAgreementInfoMapper.insDetails(info); - } - + return AjaxResult.success("结算成功"); } else { - throw new ServiceException("新增结算单号失败"); - //throw new ServiceException(ExceptionDict.NEW_SETTLEMENT_NUMBER_ERROR_MSG,ExceptionDict.NEW_SETTLEMENT_NUMBER_ERROR); + return AjaxResult.error("结算失败"); } - return AjaxResult.success(); } @Override @@ -401,7 +367,6 @@ public class SltAgreementInfoServiceImpl implements SltAgreementInfoService { if (scrapList != null && scrapList.size() > 0) { for (SltAgreementInfo bean : scrapList) { - if (bean.getBuyPrice() == null) { bean.setBuyPrice("0"); } @@ -411,13 +376,6 @@ public class SltAgreementInfoServiceImpl implements SltAgreementInfoService { BigDecimal buyPrice = new BigDecimal(bean.getBuyPrice()); BigDecimal num = new BigDecimal(bean.getNum()); BigDecimal costs = buyPrice.multiply(num); - //计算总金额 - /*BigDecimal costs = BigDecimal.ZERO; - if (bean.getBuyPrice() != null && bean.getBuyPrice() != null){ - BigDecimal buyPrice = new BigDecimal(bean.getBuyPrice()); - BigDecimal num = new BigDecimal(bean.getNum()); - costs = buyPrice.multiply(num); - }*/ bean.setCosts(String.valueOf(costs)); } } @@ -438,6 +396,96 @@ public class SltAgreementInfoServiceImpl implements SltAgreementInfoService { return i; } + @Override + public List getSltInfoMonth(List list) { + //租赁费用列表 + List leaseListMonth = getLeaseListMonth(list); + return leaseListMonth; + } + + @Override + public int updateOutSourceCosts(SltAgreementInfo sltAgreementInfo) { + return sltAgreementInfoMapper.updateOutSourceCosts(sltAgreementInfo); + } + + private List getLeaseListMonth(List list) { + List leaseList = new ArrayList<>(); + int num = 0; + for (AgreementInfo bean : list) { + if (StringUtils.isNotBlank(bean.getStartTime()) && StringUtils.isNotBlank(bean.getEndTime())) { + List monthList = sltAgreementInfoMapper.getLeaseListMonthNotNull(bean); + for (SltAgreementInfo sltAgreementInfo : monthList) { + AgreementInfo agreementInfo = new AgreementInfo(); + agreementInfo.setAgreementId(bean.getAgreementId()); + agreementInfo.setCostBearingParty(sltAgreementInfo.getCostBearingParty()); + agreementInfo.setStartTime(sltAgreementInfo.getBeginTime()); + agreementInfo.setIds(sltAgreementInfo.getIds()); + sltAgreementInfo.setMonth(bean.getMonth()); + sltAgreementInfo.setCodeNum(num++); + agreementInfo.setEndTime(sltAgreementInfo.getOffTime()); + List leaseListOneMonth = getLeaseListOneMonth(agreementInfo, sltAgreementInfo); + sltAgreementInfo.setNode(leaseListOneMonth); + } + leaseList.addAll(monthList); + } else { + List oneOfList = sltAgreementInfoMapper.getLeaseListMonth(bean); + for (SltAgreementInfo sltAgreementInfo : oneOfList) { + AgreementInfo agreementInfo = new AgreementInfo(); + agreementInfo.setAgreementId(bean.getAgreementId()); + agreementInfo.setIds(sltAgreementInfo.getIds()); + agreementInfo.setCostBearingParty(sltAgreementInfo.getCostBearingParty()); + agreementInfo.setStartTime(sltAgreementInfo.getBeginTime()); + sltAgreementInfo.setCodeNum(num++); + agreementInfo.setEndTime(sltAgreementInfo.getOffTime()); + List leaseListOneMonth = getLeaseListOneMonth(agreementInfo, sltAgreementInfo); + sltAgreementInfo.setNode(leaseListOneMonth); + } + leaseList.addAll(oneOfList); + } + } + return leaseList; + } + + private List getLeaseListOneMonth(AgreementInfo list, SltAgreementInfo sltAgreementInfo) { + ArrayList idList = new ArrayList<>(); + String[] ids = list.getIds().split(","); + for (String id : ids) { + idList.add(id); + } + List leaseList = sltAgreementInfoMapper.getLeaseListOneMonth(list, idList); + BigDecimal leaseCostOne = BigDecimal.ZERO; + for (SltAgreementInfo bean : leaseList) { + if (bean.getLeasePrice() == null) { + bean.setLeasePrice("0"); + } + if (bean.getNum() == null) { + bean.setNum("0"); + } + if (bean.getLeaseDays() == null) { + bean.setLeaseDays("0"); + } + if (bean.getTrimDay() == null) { + bean.setTrimDay(0); + } + BigDecimal leasePrice = new BigDecimal(bean.getLeasePrice()); + BigDecimal num = new BigDecimal(bean.getNum()); + BigDecimal leaseDays = new BigDecimal(bean.getLeaseDays()); + // 实际结算天数(领料天数 + 调整天数(可以为负整数)) + BigDecimal realDays = leaseDays.add(new BigDecimal(bean.getTrimDay())); + // 实际结算金额 + BigDecimal realCosts = leasePrice.multiply(num).multiply(realDays); + // 应结算金额 + BigDecimal costs = leasePrice.multiply(num).multiply(leaseDays); + bean.setCosts(String.valueOf(costs)); + bean.setRealDays(realDays); + bean.setRealCosts(String.valueOf(realCosts)); + leaseCostOne = leaseCostOne.add(costs); + bean.setMonth(sltAgreementInfo.getMonth()); + } + sltAgreementInfo.setCosts(String.valueOf(leaseCostOne)); + return leaseList; + } + public List getRepairList(List list) { List repairList = new ArrayList<>(); String taskType = "41"; diff --git a/sgzb-modules/sgzb-material/src/main/resources/mapper/material/SltAgreementInfoMapper.xml b/sgzb-modules/sgzb-material/src/main/resources/mapper/material/SltAgreementInfoMapper.xml index db15081e..d0f7ff7a 100644 --- a/sgzb-modules/sgzb-material/src/main/resources/mapper/material/SltAgreementInfoMapper.xml +++ b/sgzb-modules/sgzb-material/src/main/resources/mapper/material/SltAgreementInfoMapper.xml @@ -109,11 +109,17 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" AND sai.lease_type = 0 AND lai.cost_bearing_party = #{costBearingParty} + + update repair_cost set out_source_costs = #{outSourceCosts} where id = #{id} + + + update bm_agreement_info set is_slt = 1 where agreement_id = #{agreementId} + @@ -201,17 +199,26 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" bui.unit_name as unitName, bp.lot_name as projectName, rc.type_id as typeId, + rc.id, rc.ma_id as maId, mt1.type_name as typeName, mt.type_name as modelName, mt.unit_name as nuitName, - sum(rc.repair_num) as num, - sum(rc.costs) as costs, + rc.repair_num as num, + rc.costs as costs, + rc.out_source_costs as outSourceCosts, + ROUND(rc.repair_num * rc.costs, 2) AS partAllCosts, + ROUND(rc.repair_num * rc.costs + IFNULL(rc.out_source_costs ,0), 2) AS allCosts, + mpt.pa_name partModelName, + mpt2.pa_name partName, case rc.part_type when '0' then '不收费' when '1' then '收费' else '' end as partType, rc.status as repairStatus, rc.company_id as companyId from repair_cost rc left join tm_task_agreement tta on rc.task_id = tta.task_id + LEFT JOIN repair_part_details rpd on rc.task_id = rpd.task_id and rc.type_id = rpd.type_id and (rc.ma_id = rpd.ma_id OR rpd.ma_id IS NULL) + LEFT JOIN ma_part_type mpt on rpd.part_id = mpt.pa_id + LEFT JOIN ma_part_type mpt2 on mpt.parent_id = mpt2.pa_id LEFT JOIN bm_agreement_info bai on tta.agreement_id = bai.agreement_id LEFT JOIN bm_project_lot bp ON bp.lot_id = bai.project_id LEFT JOIN bm_unit_info bui ON bui.unit_id = bai.unit_id @@ -224,7 +231,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{task.taskId} - group by rc.type_id,rc.ma_id,rc.part_type,rc.status + + + + + \ No newline at end of file