From 67f56ecba2f6ca812c3f1ab96846670021b692b6 Mon Sep 17 00:00:00 2001 From: bonus <1203338439@qq.com> Date: Sun, 29 Jun 2025 14:43:51 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BB=93=E7=AE=97=E8=B4=B9=E7=94=A8=E5=BC=80?= =?UTF-8?q?=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/biz/config/DateTimeHelper.java | 10 + .../ma/controller/MachineController.java | 10 +- .../com/bonus/material/ma/domain/Machine.java | 4 + .../material/ma/mapper/MachineMapper.java | 2 + .../material/ma/service/IMachineService.java | 2 + .../ma/service/impl/MachineServiceImpl.java | 69 ++++- .../controller/RentalCostsController.java | 48 ++++ .../push/domain/AccProjectLeaseMoneyBean.java | 85 ++++++ .../domain/ConsProjectLeaseMoneyBean.java | 95 ++++++ .../material/push/domain/RentalCostsBean.java | 83 ++++++ .../mapper/AccProjectLeaseMoneyMapper.java | 25 ++ .../mapper/ConsProjectLeaseMoneyMapper.java | 35 +++ .../push/mapper/RentalCostsMapper.java | 19 ++ .../push/service/RentalCostsService.java | 19 ++ .../service/impl/RentalCostsServiceImpl.java | 270 ++++++++++++++++++ .../bonus/material/remind/InformMonthly.java | 54 ++++ .../mapper/material/ma/MachineMapper.xml | 64 ++++- .../push/AccProjectLeaseMoneylMapper.xml | 80 ++++++ .../push/ConsProjectLeaseMoneyMapper.xml | 200 +++++++++++++ 19 files changed, 1165 insertions(+), 9 deletions(-) create mode 100644 bonus-modules/bonus-material/src/main/java/com/bonus/material/push/controller/RentalCostsController.java create mode 100644 bonus-modules/bonus-material/src/main/java/com/bonus/material/push/domain/AccProjectLeaseMoneyBean.java create mode 100644 bonus-modules/bonus-material/src/main/java/com/bonus/material/push/domain/ConsProjectLeaseMoneyBean.java create mode 100644 bonus-modules/bonus-material/src/main/java/com/bonus/material/push/domain/RentalCostsBean.java create mode 100644 bonus-modules/bonus-material/src/main/java/com/bonus/material/push/mapper/AccProjectLeaseMoneyMapper.java create mode 100644 bonus-modules/bonus-material/src/main/java/com/bonus/material/push/mapper/ConsProjectLeaseMoneyMapper.java create mode 100644 bonus-modules/bonus-material/src/main/java/com/bonus/material/push/mapper/RentalCostsMapper.java create mode 100644 bonus-modules/bonus-material/src/main/java/com/bonus/material/push/service/RentalCostsService.java create mode 100644 bonus-modules/bonus-material/src/main/java/com/bonus/material/push/service/impl/RentalCostsServiceImpl.java create mode 100644 bonus-modules/bonus-material/src/main/java/com/bonus/material/remind/InformMonthly.java create mode 100644 bonus-modules/bonus-material/src/main/resources/mapper/material/push/AccProjectLeaseMoneylMapper.xml create mode 100644 bonus-modules/bonus-material/src/main/resources/mapper/material/push/ConsProjectLeaseMoneyMapper.xml diff --git a/bonus-common-biz/src/main/java/com/bonus/common/biz/config/DateTimeHelper.java b/bonus-common-biz/src/main/java/com/bonus/common/biz/config/DateTimeHelper.java index 816734fa..a742538c 100644 --- a/bonus-common-biz/src/main/java/com/bonus/common/biz/config/DateTimeHelper.java +++ b/bonus-common-biz/src/main/java/com/bonus/common/biz/config/DateTimeHelper.java @@ -600,5 +600,15 @@ public class DateTimeHelper { } } + /** + * 格式化 时间 + * @param + * @return + */ + public static String currentDateTime() { + SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + return df.format(new Date()); + } + } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/controller/MachineController.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/controller/MachineController.java index b7eff783..bbc8be88 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/controller/MachineController.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/controller/MachineController.java @@ -277,6 +277,14 @@ public class MachineController extends BaseController { return machineService.getHisByQrcode(machine); } - + /** + * 根据qrcode查询机具历史信息 + * @param machine + * @return + */ + @GetMapping("/getHisByCode") + public AjaxResult getHisByCode(Machine machine) { + return machineService.getHisByCode(machine); + } } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/domain/Machine.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/domain/Machine.java index 022b7868..894ea5b8 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/domain/Machine.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/domain/Machine.java @@ -233,4 +233,8 @@ public class Machine extends BaseEntity private String backTime; @ApiModelProperty(value = "任务") private Integer taskId; + @ApiModelProperty(value = "机具名称") + private String maName; + @ApiModelProperty(value = "机具规格") + private String maModel; } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/mapper/MachineMapper.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/mapper/MachineMapper.java index 22ad6bab..2700a693 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/mapper/MachineMapper.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/mapper/MachineMapper.java @@ -164,4 +164,6 @@ public interface MachineMapper Machine getScrapTimeByQrcode(Machine machine); Machine getLeaseInfoByQrcode(Machine machine); + + List getListByCode(Machine machine); } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/IMachineService.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/IMachineService.java index eb2d5aef..f98e44f7 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/IMachineService.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/IMachineService.java @@ -117,4 +117,6 @@ public interface IMachineService public int editAssetsCode(Machine machine); AjaxResult getHisByQrcode(Machine machine); + + AjaxResult getHisByCode(Machine machine); } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/impl/MachineServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/impl/MachineServiceImpl.java index 97405201..48c1ae7b 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/impl/MachineServiceImpl.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/ma/service/impl/MachineServiceImpl.java @@ -327,7 +327,7 @@ public class MachineServiceImpl implements IMachineService if (inTime != null){ Integer taskId = inTime.getTaskId(); if(taskId != null){ - baseInfo.setInTime(inTime.getInTime()+"新购"); + baseInfo.setInTime(inTime.getInTime()+"(新购)"); }else{ baseInfo.setInTime(inTime.getInTime()); } @@ -363,4 +363,71 @@ public class MachineServiceImpl implements IMachineService return success(baseInfo); } + @Override + public AjaxResult getHisByCode(Machine machine) { + List result = new ArrayList<>(); + List maList = machineMapper.getListByCode(machine); + if (CollectionUtils.isNotEmpty(maList)){ + if(maList.size() == 1){ + Machine baseInfo = maList.get(0); + machine.setMaId(baseInfo.getMaId()); + machine.setMaCode(baseInfo.getMaCode()); + //2根据二维码查询初次入库时间 + Machine inTime = machineMapper.getInTimeByQrcode(machine); + //服务工程次数,检验次数 + Machine serviceNum = machineMapper.getServiceNumByQrcode(machine); + //更换配件次数 + Machine checkNum = machineMapper.getCheckNumByQrcode(machine); + //报废时间 + Machine scrapTime = machineMapper.getScrapTimeByQrcode(machine); + //3根据机具id查询领退工程 + Machine leaseInfo = machineMapper.getLeaseInfoByQrcode(machine); + if (inTime != null){ + Integer taskId = inTime.getTaskId(); + if(taskId != null){ + baseInfo.setInTime(inTime.getInTime()+"(新购)"); + }else{ + baseInfo.setInTime(inTime.getInTime()); + } + + } + + if(serviceNum != null){ + baseInfo.setServiceNum(serviceNum.getServiceNum()); + }else{ + baseInfo.setServiceNum(0); + } + + if(checkNum != null){ + baseInfo.setCheckNum(checkNum.getCheckNum()); + }else{ + baseInfo.setCheckNum(0); + } + + if (scrapTime != null){ + baseInfo.setScrapTime(scrapTime.getScrapTime()); + }else{ + baseInfo.setScrapTime("暂无"); + } + + if(leaseInfo != null){ + baseInfo.setLeaseTime(leaseInfo.getLeaseTime()); + baseInfo.setLeaseUnit(leaseInfo.getLeaseUnit()); + baseInfo.setLeaseProject(leaseInfo.getLeaseProject()); + baseInfo.setBackTime(leaseInfo.getBackTime()); + baseInfo.setBackUnit(leaseInfo.getBackUnit()); + baseInfo.setBackProject(leaseInfo.getBackProject()); + } + result.add(baseInfo); + return success(result); + + }else{ + return success(maList); + } + }else{ + return error("暂无该设备信息"); + } + + } + } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/push/controller/RentalCostsController.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/push/controller/RentalCostsController.java new file mode 100644 index 00000000..aca2d037 --- /dev/null +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/push/controller/RentalCostsController.java @@ -0,0 +1,48 @@ +package com.bonus.material.push.controller; + +import com.bonus.common.core.exception.ServiceException; +import com.bonus.common.core.utils.poi.ExcelUtil; +import com.bonus.common.core.web.controller.BaseController; +import com.bonus.common.core.web.domain.AjaxResult; +import com.bonus.common.core.web.page.TableDataInfo; +import com.bonus.material.push.domain.IwsCostPushBean; +import com.bonus.material.push.domain.vo.IwsCostPushExportVo; +import com.bonus.material.push.service.IwsCostPushService; +import com.bonus.material.push.service.RentalCostsService; +import com.bonus.material.settlement.domain.SltAgreementInfo; +import com.bonus.material.settlement.service.impl.SltAgreementInfoServiceImpl; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.BeanUtils; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletResponse; +import javax.validation.Valid; +import java.math.BigDecimal; +import java.util.Collections; +import java.util.List; +import java.util.Objects; +import java.util.Optional; +import java.util.stream.Collectors; + +/** + * @author : 阮世耀 + * @version : 1.0 + * @PackagePath: com.bonus.material.push.controller + * @CreateTime: 2025-01-23 15:04 + * @Description: i皖送费用推送控制器 + */ +@RestController +@RequestMapping("/rental_cost") +@Validated +public class RentalCostsController extends BaseController { + + @Resource + private RentalCostsService rService; + + + + + +} diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/push/domain/AccProjectLeaseMoneyBean.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/push/domain/AccProjectLeaseMoneyBean.java new file mode 100644 index 00000000..0525a9df --- /dev/null +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/push/domain/AccProjectLeaseMoneyBean.java @@ -0,0 +1,85 @@ +package com.bonus.material.push.domain; + +import lombok.Data; + +import java.util.ArrayList; +import java.util.List; + +/** + * + * 描述:工程租赁费用查询 + * @table: + * @author + * @date 2021年11月23日 + */ +@Data +public class AccProjectLeaseMoneyBean implements java.io.Serializable { + + private static final long serialVersionUID = 1L; + + private Integer id; + + private String code; + + private String number; + + private String codeId; + + private String leaseType; + + private String typeId; + + private String leaseId; + + private String proId; //i8工程id + + private String proCode; //i8工程code + + private String projectId; + + private String leaseName; + + private String projectName; + + private String leasePrice; + + private String leaseMoney; + + private String deviceName; + + private String deviceModel; + + private String deviceUnit; + + private String leaseNum; + + private String leaseDay; + + private String startTime; + + private String endTime; + + private String keyWord; + + private String companyName; + + private String isSlt; + + private String modelId; + + private List chks; + + private String taskId; + + /** + * 费用结算时间 + */ + private String time; + + private String agreementId; + + private String buyPrice; + + private String money; + +} diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/push/domain/ConsProjectLeaseMoneyBean.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/push/domain/ConsProjectLeaseMoneyBean.java new file mode 100644 index 00000000..955563f8 --- /dev/null +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/push/domain/ConsProjectLeaseMoneyBean.java @@ -0,0 +1,95 @@ +package com.bonus.material.push.domain; + +import lombok.Data; + +import java.util.List; + +/** + * + * 描述:工程租赁费用查询 + * @table: + * @author + * @date 2021年11月23日 + */ +@Data +public class ConsProjectLeaseMoneyBean implements java.io.Serializable { + + private static final long serialVersionUID = 1L; + + private Integer id; + + private String code; + + private String number; + + private String codeId; + + private String leaseType; + + private String typeId; + + private String leaseId; + + private String proId; //i8工程id + + private String proCode; //i8工程code + + private String projectId; + + private String leaseName; + + private String projectName; + + private String buyPrice; + + private String leaseMoney; + + private String leasePrice; + + private String deviceName; + + private String deviceModel; + + private String deviceUnit; + + private String leaseNum; + + private String leaseDay; + + private String startTime; + + private String endTime; + + private String keyWord; + + private String companyName; + + private String isSlt; + + private String modelId; + + private List chks; + + private String taskId; + + private String type; + + private String leaseTotal; + + private String consTotal; + + private String scrapTotal; + + private String lostTotal; + + private String repairTotal; + + + private String time; + + private String agreementId; + + private int maId; + + private String month; +} diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/push/domain/RentalCostsBean.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/push/domain/RentalCostsBean.java new file mode 100644 index 00000000..6d6b26e6 --- /dev/null +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/push/domain/RentalCostsBean.java @@ -0,0 +1,83 @@ +package com.bonus.material.push.domain; + +import lombok.Data; +import org.apache.ibatis.type.Alias; + +import java.math.BigDecimal; + +@Data +@Alias("RentalCostsBean") +public class RentalCostsBean implements java.io.Serializable { + + /** + * + */ + private static final long serialVersionUID = 1L; + + private String id; + + private String taskId; + //i8工程id + private String proId; + //i8工程code + private String proCode; + //项目id + private String projectId; + //项目名称 + private String projectName; + //所属分公司 + private String companyName; + //单位id + private String unitId; + //单位名称 + private String unitName; + //领料单位 + private String leaseName; + + private String typeName; + + private String modelName; + + private String deviceName; + + private String deviceModel; + + private BigDecimal leaseNum; + + private String startTime; + + private String endTime; + + private BigDecimal num; + + private String leaseDate; + + private String backDate; + + private String money; + + private String leasePrice; + + private String time; + + private String month; + + private String type; + + private String buyPrice; + + private String leaseMoney; + + private String lostMoney; + + private String repairMoney; + + private String scrapMoney; + + private String charge; + + private String typeId; + + + +} diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/push/mapper/AccProjectLeaseMoneyMapper.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/push/mapper/AccProjectLeaseMoneyMapper.java new file mode 100644 index 00000000..2aac748d --- /dev/null +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/push/mapper/AccProjectLeaseMoneyMapper.java @@ -0,0 +1,25 @@ +package com.bonus.material.push.mapper; + +import com.bonus.material.push.domain.AccProjectLeaseMoneyBean; +import com.bonus.material.push.domain.RentalCostsBean; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +/** + * @author : 阮世耀 + * @version : 1.0 + * @PackagePath: com.bonus.material.push.mapper + * @CreateTime: 2025-01-23 14:40 + * @Description: i皖送费用推送mapper + */ +@Mapper +public interface AccProjectLeaseMoneyMapper { + + + int insertCalcRecord(RentalCostsBean o); + + List getLeaseMoneyDetail(AccProjectLeaseMoneyBean o); + + int insertProjectMonthInfo(List infos); +} diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/push/mapper/ConsProjectLeaseMoneyMapper.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/push/mapper/ConsProjectLeaseMoneyMapper.java new file mode 100644 index 00000000..6744a6c4 --- /dev/null +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/push/mapper/ConsProjectLeaseMoneyMapper.java @@ -0,0 +1,35 @@ +package com.bonus.material.push.mapper; + +import com.bonus.material.push.domain.ConsProjectLeaseMoneyBean; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * @author : 阮世耀 + * @version : 1.0 + * @PackagePath: com.bonus.material.push.mapper + * @CreateTime: 2025-01-23 14:40 + * @Description: i皖送费用推送mapper + */ +@Mapper +public interface ConsProjectLeaseMoneyMapper { + + + List getRealtionList(ConsProjectLeaseMoneyBean cons); + + List getConsMonthMoney(ConsProjectLeaseMoneyBean o); + + int insertProjectConsMonthInfo(@Param("list") List infos); + + List getScrapMoney(ConsProjectLeaseMoneyBean o); + + int insertProjectOthersMonthInfo(@Param("list") List infos); + + List getLostMoney(ConsProjectLeaseMoneyBean o); + + List getRepairMoney(ConsProjectLeaseMoneyBean o); + + int insertProjectMonthCosts(@Param("list") List total); +} diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/push/mapper/RentalCostsMapper.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/push/mapper/RentalCostsMapper.java new file mode 100644 index 00000000..b9c26cb0 --- /dev/null +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/push/mapper/RentalCostsMapper.java @@ -0,0 +1,19 @@ +package com.bonus.material.push.mapper; + +import com.bonus.material.push.domain.IwsCostPushBean; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +/** + * @author : 阮世耀 + * @version : 1.0 + * @PackagePath: com.bonus.material.push.mapper + * @CreateTime: 2025-01-23 14:40 + * @Description: i皖送费用推送mapper + */ +@Mapper +public interface RentalCostsMapper { + + +} diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/push/service/RentalCostsService.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/push/service/RentalCostsService.java new file mode 100644 index 00000000..0a892688 --- /dev/null +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/push/service/RentalCostsService.java @@ -0,0 +1,19 @@ +package com.bonus.material.push.service; + +import com.bonus.common.core.web.domain.AjaxResult; +import com.bonus.material.push.domain.IwsCostPushBean; + +import java.util.List; + +/** + * @author : 阮世耀 + * @version : 1.0 + * @PackagePath: com.bonus.material.push.service + * @CreateTime: 2025-01-23 14:48 + * @Description: i皖送推送server 接口 + */ +public interface RentalCostsService { + + + void calcMonthInfo(); +} diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/push/service/impl/RentalCostsServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/push/service/impl/RentalCostsServiceImpl.java new file mode 100644 index 00000000..5d309e9a --- /dev/null +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/push/service/impl/RentalCostsServiceImpl.java @@ -0,0 +1,270 @@ +package com.bonus.material.push.service.impl; + +import com.alibaba.nacos.common.utils.CollectionUtils; +import com.bonus.common.biz.config.DateTimeHelper; +import com.bonus.common.core.utils.StringUtils; +import com.bonus.common.core.web.domain.AjaxResult; +import com.bonus.material.push.domain.AccProjectLeaseMoneyBean; +import com.bonus.material.push.domain.ConsProjectLeaseMoneyBean; +import com.bonus.material.push.domain.IwsCostPushBean; +import com.bonus.material.push.domain.RentalCostsBean; +import com.bonus.material.push.mapper.AccProjectLeaseMoneyMapper; +import com.bonus.material.push.mapper.ConsProjectLeaseMoneyMapper; +import com.bonus.material.push.mapper.IwsCostPushMapper; +import com.bonus.material.push.mapper.RentalCostsMapper; +import com.bonus.material.push.service.IwsCostPushService; +import com.bonus.material.push.service.RentalCostsService; +import com.bonus.material.settlement.domain.SltAgreementInfo; +import com.bonus.material.settlement.domain.vo.SltInfoVo; +import com.bonus.material.settlement.service.ISltAgreementInfoService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import javax.annotation.Resource; +import java.math.BigDecimal; +import java.math.RoundingMode; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; +import java.time.temporal.ChronoUnit; +import java.time.temporal.TemporalAdjusters; +import java.util.*; +import java.util.stream.Collectors; + +/** + * @author : 阮世耀 + * @version : 1.0 + * @PackagePath: com.bonus.material.push.service.impl + * @CreateTime: 2025-01-23 14:48 + * @Description: 描述 + */ +@Service +public class RentalCostsServiceImpl implements RentalCostsService { + + @Autowired + private RentalCostsMapper dao; + + @Autowired + private AccProjectLeaseMoneyMapper accDao; + + @Autowired + ConsProjectLeaseMoneyMapper consDao; + + @Override + @Transactional(rollbackFor = Exception.class) + public void calcMonthInfo() { + RentalCostsBean o = new RentalCostsBean(); + // yyyy-MM 获取上个月的月份 + o.setMonth(DateTimeHelper.getPrevMonth()); + + int res = accDao.insertCalcRecord(o); + if (res == 0) { + throw new RuntimeException("新增calc_project_month失败"); + } + String taskId = o.getId(); + + // 获取上个月的第一天日期:2024-05-01 + String startTime = DateTimeHelper.getPreFirstDay(); + // 获取上个月的最后一天:2024-05-31 + String endTime = DateTimeHelper.getPreLastDay(); + + ConsProjectLeaseMoneyBean cons = new ConsProjectLeaseMoneyBean(); + cons.setStartTime(startTime); + cons.setEndTime(endTime); + + List list = consDao.getRealtionList(cons); + calcMonthInfoDetails(list, startTime, endTime, taskId); + } + + + private void calcMonthInfoDetails(List list, String startTime, String endTime, String taskId) { + int res; + LocalDate date = LocalDate.parse(startTime, DateTimeFormatter.ISO_DATE); + String month = date.format(DateTimeFormatter.ofPattern("yyyy-MM")); + List total = new ArrayList<>(); + for(ConsProjectLeaseMoneyBean bean : list){ + String agreementId = bean.getAgreementId(); + String projectId = bean.getProjectId(); + String leaseType = bean.getLeaseType(); + String leaseName = bean.getLeaseName(); + + // 机具部分,中转表 project_month_info + float leaseTotal = generatePushData4Machines(leaseName,agreementId,projectId,leaseType, startTime, endTime, taskId); + + //消耗品部分,中转表 project_month_info + float consTotal = generatePushData4Consumables(leaseName,agreementId,projectId,leaseType, startTime, endTime, taskId); + + //报废费用,中转表 project_month_info + float scrapTotal = generatePushData4Scrap(leaseName,agreementId,projectId,leaseType, startTime, endTime, taskId); + + //丢失费用,中转表 project_month_info + float lostTotal = generatePushData4Lost(leaseName,agreementId,projectId,leaseType, startTime, endTime, taskId); + + //维修费用,中转表 project_month_info + float repairTotal = generatePushData4Repair(leaseName,agreementId,projectId,leaseType, startTime, endTime, taskId); + if (leaseTotal > 0 || consTotal > 0 || scrapTotal > 0 || lostTotal > 0) { + bean.setLeaseTotal(leaseTotal + ""); + bean.setConsTotal(consTotal + ""); + bean.setScrapTotal(scrapTotal + ""); + bean.setLostTotal(lostTotal + ""); + bean.setRepairTotal(repairTotal + ""); + bean.setTaskId(taskId); + bean.setMonth(month); + total.add(bean); + } + } + res = consDao.insertProjectMonthCosts(total); + if (res == 0) { + throw new RuntimeException("新增project_month_costs失败"); + } + } + + private float generatePushData4Machines(String leaseName,String agreementId,String projectId,String leaseType,String startTime, String endTime, String taskId) { + System.out.println("开始机具费用数据收集定时任务"); + AccProjectLeaseMoneyBean o = new AccProjectLeaseMoneyBean(); + o.setStartTime(startTime); + o.setEndTime(endTime); + o.setAgreementId(agreementId); + o.setProjectId(projectId); + o.setLeaseType(leaseType); + + BigDecimal total = new BigDecimal("0"); + List infos = accDao.getLeaseMoneyDetail(o); + if (infos != null && infos.size() > 0) { + for(AccProjectLeaseMoneyBean info : infos){ + info.setTaskId(taskId); + info.setAgreementId(agreementId); + info.setLeaseType(leaseType); + info.setProjectId(projectId); + info.setLeaseName(leaseName); + + total = total.add(new BigDecimal(info.getLeaseMoney())); + } + int res = accDao.insertProjectMonthInfo(infos); + if (res == 0) { + throw new RuntimeException("新增project_month_info失败"); + } + } + + return total.setScale(2).floatValue(); + + } + + private float generatePushData4Consumables(String leaseName,String agreementId,String projectId,String leaseType,String startTime, String endTime, String taskId) { + System.out.println("开始消耗品费用数据收集定时任务"); + ConsProjectLeaseMoneyBean o = new ConsProjectLeaseMoneyBean(); + o.setStartTime(startTime); + o.setEndTime(endTime); + o.setAgreementId(agreementId); + o.setProjectId(projectId); + o.setLeaseType(leaseType); + + BigDecimal total = new BigDecimal("0"); + List infos = consDao.getConsMonthMoney(o); + if (infos != null && infos.size() > 0) { + for(ConsProjectLeaseMoneyBean info : infos){ + info.setTaskId(taskId); + info.setAgreementId(agreementId); + info.setLeaseType(leaseType); + info.setProjectId(projectId); + info.setLeaseName(leaseName); + + total = total.add(new BigDecimal(info.getLeaseMoney())); + } + int res = consDao.insertProjectConsMonthInfo(infos); + if (res == 0) { + throw new RuntimeException("新增project_month_info失败"); + } + } + return total.setScale(2).floatValue(); + } + + private float generatePushData4Scrap(String leaseName,String agreementId,String projectId,String leaseType,String startTime, String endTime, String taskId) { + System.out.println("开始报废费用数据收集定时任务"); + ConsProjectLeaseMoneyBean o = new ConsProjectLeaseMoneyBean(); + o.setStartTime(startTime); + o.setEndTime(endTime); + o.setAgreementId(agreementId); + o.setProjectId(projectId); + o.setLeaseType(leaseType); + + BigDecimal total = new BigDecimal("0"); + List infos = consDao.getScrapMoney(o); + if (infos != null && infos.size() > 0) { + for(ConsProjectLeaseMoneyBean info : infos){ + info.setTaskId(taskId); + info.setAgreementId(agreementId); + info.setLeaseType(leaseType); + info.setProjectId(projectId); + info.setLeaseName(leaseName); + info.setType("4"); + total = total.add(new BigDecimal(info.getLeaseMoney())); + } + int res = consDao.insertProjectOthersMonthInfo(infos); + if (res == 0) { + throw new RuntimeException("新增project_month_info失败"); + } + } + return total.setScale(2).floatValue(); + } + + private float generatePushData4Lost(String leaseName,String agreementId,String projectId,String leaseType,String startTime, String endTime, String taskId) { + System.out.println("开始丢失费用数据收集定时任务"); + ConsProjectLeaseMoneyBean o = new ConsProjectLeaseMoneyBean(); + o.setStartTime(startTime); + o.setEndTime(endTime); + o.setAgreementId(agreementId); + o.setProjectId(projectId); + o.setLeaseType(leaseType); + + BigDecimal total = new BigDecimal("0"); + List infos = consDao.getLostMoney(o); + if (infos != null && infos.size() > 0) { + for(ConsProjectLeaseMoneyBean info : infos){ + info.setTaskId(taskId); + info.setAgreementId(agreementId); + info.setLeaseType(leaseType); + info.setProjectId(projectId); + info.setLeaseName(leaseName); + info.setType("2"); + total = total.add(new BigDecimal(info.getLeaseMoney())); + } + int res = consDao.insertProjectOthersMonthInfo(infos); + if (res == 0) { + throw new RuntimeException("新增project_month_info失败"); + } + } + return total.setScale(2).floatValue(); + } + + private float generatePushData4Repair(String leaseName, String agreementId, String projectId, String leaseType, String startTime, String endTime, String taskId) { + System.out.println("开始维修费用数据收集定时任务"); + ConsProjectLeaseMoneyBean o = new ConsProjectLeaseMoneyBean(); + o.setStartTime(startTime); + o.setEndTime(endTime); + o.setAgreementId(agreementId); + o.setProjectId(projectId); + o.setLeaseType(leaseType); + + BigDecimal total = new BigDecimal("0"); + List infos = consDao.getRepairMoney(o); + if (infos != null && infos.size() > 0) { + for(ConsProjectLeaseMoneyBean info : infos){ + info.setTaskId(taskId); + info.setAgreementId(agreementId); + info.setLeaseType(leaseType); + info.setProjectId(projectId); + info.setLeaseName(leaseName); + info.setType("3"); + total = total.add(new BigDecimal(info.getLeaseMoney())); + } + int res = consDao.insertProjectOthersMonthInfo(infos); + if (res == 0) { + throw new RuntimeException("新增project_month_info失败"); + } + } + return total.setScale(2).floatValue(); + } + +} diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/remind/InformMonthly.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/remind/InformMonthly.java new file mode 100644 index 00000000..05557718 --- /dev/null +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/remind/InformMonthly.java @@ -0,0 +1,54 @@ +package com.bonus.material.remind; + +import com.bonus.common.biz.config.DateTimeHelper; +import com.bonus.material.push.service.RentalCostsService; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Component; + +@Component +public class InformMonthly { + + + + + @Autowired + RentalCostsService service; + + + /** + * 定时任务注解,用于配置任务的执行周期。 + * 该任务被安排在每月的第一天凌晨3点执行。 + * cron表达式解释: + * - "0 0 3 1 * ?" 表示在每月的第一天的3点0分0秒执行。 + * - 分钟(0):表示分钟,这里指定为0分钟。 + * - 小时(0):表示小时,这里指定为3点。 + * - 日期(1):表示日期,这里指定为每月的第一天。 + * - 月份(*):表示月份,这里使用通配符*表示所有月份。 + * - 星期(?):表示星期,由于每月第一天的星期不固定,因此使用?表示。 + * - 年份(空):不指定年份,表示每年都执行。 + */ + @Scheduled(cron = "0 0 1 * * ?") + public void taskCycle() { + System.out.println("使用SpringMVC框架配置定时任务"); + try { + System.out.println("执行每月初1号的一次的定时任务...执行时间:" + DateTimeHelper.currentDateTime()); + } catch (Exception e) { + System.err.println("定时任务获取时间报错:" + e.getMessage()); + } + + String time = DateTimeHelper.getNowDate(); + String firstDay = DateTimeHelper.getFirstDay(); + if (time.equals(firstDay)) { + // 执行业务逻辑 + service.calcMonthInfo(); + + } + try { + System.out.println("本月的定时任务已结束:" + DateTimeHelper.currentDateTime()); + } catch (Exception e) { + System.err.println("定时任务获取时间报错:" + e.getMessage()); + } + } +} diff --git a/bonus-modules/bonus-material/src/main/resources/mapper/material/ma/MachineMapper.xml b/bonus-modules/bonus-material/src/main/resources/mapper/material/ma/MachineMapper.xml index 3b97d73e..d206374f 100644 --- a/bonus-modules/bonus-material/src/main/resources/mapper/material/ma/MachineMapper.xml +++ b/bonus-modules/bonus-material/src/main/resources/mapper/material/ma/MachineMapper.xml @@ -355,7 +355,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" UPDATE ma_machine SET - ma_status = #{status} + ma_status = #{status}, + in_out_num = ifnull(in_out_num,0) + 1 where ma_id = #{maId} @@ -551,7 +552,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - SELECT mm.ma_id as maId, mt2.type_name as maName, @@ -578,7 +579,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - SELECT bqi.qr_code as qrCode, bqi.task_id as taskId, @@ -588,14 +589,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" WHERE bqi.qr_code = #{qrCode} - SELECT COUNT(DISTINCT sai.agreement_id) as serviceNum FROM slt_agreement_info sai WHERE sai.ma_id = #{maId} - SELECT COUNT(rp.ma_id ) as checkNum @@ -604,7 +605,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" WHERE rp.ma_id = #{maId} and rp.is_ds = 0 - SELECT sd.ma_id, sd.task_id, @@ -615,6 +616,55 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - + SELECT + sai.id, + bu.unit_name AS leaseUnit, + bp.pro_name AS leaseProject, + sai.start_time AS leaseTime, + IF( sai.status = 1, bu.unit_name,"") AS backUnit, + IF( sai.status = 1, bp.pro_name ,"") AS backProject, + IF( sai.status = 1, sai.end_time ,"") AS backTime, + + sai.status + FROM + slt_agreement_info sai + LEFT JOIN bm_agreement_info bai on sai.agreement_id = bai.agreement_id + LEFT JOIN bm_unit bu on bai.unit_id = bu.unit_id + LEFT JOIN bm_project bp on bai.project_id = bp.pro_id + WHERE sai.ma_id = #{maId} + ORDER BY sai.ID desc + limit 1 + + + diff --git a/bonus-modules/bonus-material/src/main/resources/mapper/material/push/AccProjectLeaseMoneylMapper.xml b/bonus-modules/bonus-material/src/main/resources/mapper/material/push/AccProjectLeaseMoneylMapper.xml new file mode 100644 index 00000000..7d7fb23e --- /dev/null +++ b/bonus-modules/bonus-material/src/main/resources/mapper/material/push/AccProjectLeaseMoneylMapper.xml @@ -0,0 +1,80 @@ + + + + + + INSERT INTO calc_project_month (MONTH, create_time) VALUES (#{month}, now()) + + + + + + insert into project_month_info (agreementId,typeId,leaseNum,leaseDate,returnDate,leasePrice,leaseMoney, + taskId,push_status,push_time,push_remark,is_flag,type,buy_price,money) + VALUES + + ( + #{item.leaseName}, + #{item.typeId}, + #{item.leaseNum}, + #{item.leaseDate}, + #{item.returnDate}, + #{item.leasePrice}, + #{item.leaseMoney}, + #{item.taskId}, + #{item.pushStatus}, + #{item.pushTime}, + #{item.pushRemark}, + 0, + 1, + #{item.buyPrice}, + #{item.money} + ) + + + diff --git a/bonus-modules/bonus-material/src/main/resources/mapper/material/push/ConsProjectLeaseMoneyMapper.xml b/bonus-modules/bonus-material/src/main/resources/mapper/material/push/ConsProjectLeaseMoneyMapper.xml new file mode 100644 index 00000000..ace27e3c --- /dev/null +++ b/bonus-modules/bonus-material/src/main/resources/mapper/material/push/ConsProjectLeaseMoneyMapper.xml @@ -0,0 +1,200 @@ + + + + + + + + + + + + + insert into project_month_info (agreementId,typeId,leaseNum,leaseDate,returnDate,leasePrice,leaseMoney, + taskId,push_status,push_time,push_remark,is_flag,type,buy_price,money) + VALUES + + ( + #{item.leaseName}, + #{item.typeId}, + #{item.leaseNum}, + #{item.leaseDate}, + #{item.returnDate}, + #{item.leasePrice}, + #{item.leaseMoney}, + #{item.taskId}, + #{item.pushStatus}, + #{item.pushTime}, + #{item.pushRemark}, + 0, + 2, + #{item.buyPrice}, + #{item.money} + ) + + + + + + + insert into project_month_info (agreementId,typeId,leaseNum,leaseDate,returnDate,leasePrice,leaseMoney, + taskId,push_status,push_time,push_remark,is_flag,type,buy_price,money) + VALUES + + ( + #{item.leaseName}, + #{item.typeId}, + #{item.leaseNum}, + #{item.leaseDate}, + #{item.returnDate}, + #{item.leasePrice}, + #{item.leaseMoney}, + #{item.taskId}, + #{item.pushStatus}, + #{item.pushTime}, + #{item.pushRemark}, + 0, + #{item.type}, + #{item.buyPrice}, + #{item.money} + ) + + + + + + + + + insert into project_month_costs (agreement_id,lease_money,cons_money,scrap_money, + lost_money,repair_money,task_id,is_flag,month) + VALUES + + ( + #{item.agreementId}, + #{item.leaseTotal}, + #{item.consTotal}, + #{item.scrapTotal}, + #{item.lostTotal}, + #{item.repairTotal}, + #{item.taskId}, + 0, + #{item.month} + ) + + +