From 49b8fdf34762b937e7fe5ad235f4bf182c050f72 Mon Sep 17 00:00:00 2001 From: sxu <602087911@qq.com> Date: Thu, 15 Aug 2024 15:08:21 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=8C=E6=AD=A5=E9=87=8D=E5=BA=86=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sgzb/base/api/domain/MaInputRecord.java | 8 +- .../base/api/domain/SltAgreementApply.java | 5 +- .../base/api/domain/SltAgreementInfo.java | 10 +- .../base/api/domain/SltAgreementRelation.java | 1 + .../common/core/constant/RoleConstans.java | 46 ++++++ .../common/core/utils/DateTimeHelper.java | 50 +++++- .../bonus/sgzb/app/domain/LeaseApplyInfo.java | 2 +- .../com/bonus/sgzb/app/domain/TmTask.java | 2 +- .../app/service/impl/TmTaskServiceImpl.java | 13 +- .../base/controller/MaReceiveController.java | 2 +- .../sgzb/base/domain/RepairApplyRecord.java | 1 + .../bonus/sgzb/base/mapper/MaTypeMapper.java | 4 +- .../bonus/sgzb/base/mapper/RepairMapper.java | 2 + .../base/service/impl/ExcelServiceImpl.java | 53 ++----- .../base/service/impl/RepairServiceImpl.java | 44 +++-- .../controller/IotMachineController.java | 38 +++-- .../PurchaseMacodeInfoController.java | 1 + .../sgzb/material/domain/AgreementInfo.java | 2 +- .../sgzb/material/domain/IotLocationVo.java | 8 +- .../material/domain/ProjectMonthCosts.java | 6 +- .../material/domain/ProjectMonthDetail.java | 2 +- .../sgzb/material/domain/ReportAlarm.java | 49 ++++++ .../material/mapper/CalMonthlyMapper.java | 2 + .../material/mapper/IotMachineMapper.java | 2 + .../mapper/PurchaseCheckDetailsMapper.java | 2 +- .../mapper/RepairAuditDetailsMapper.java | 4 + .../material/mapper/ReportAlarmMapper.java | 25 +++ .../mapper/SltAgreementInfoMapper.java | 2 + .../bonus/sgzb/material/remind/Inform.java | 21 ++- .../remind/service/CalcMonthlyServiceImp.java | 66 ++++---- .../service/IPurchaseCheckDetailsService.java | 2 +- .../material/service/IotMachineService.java | 24 ++- .../service/impl/IotMachineServiceImpl.java | 150 ++++++++++++++---- .../impl/PurchaseCheckDetailsServiceImpl.java | 2 +- .../impl/PurchaseMacodeInfoServiceImpl.java | 34 ++-- .../impl/RepairAuditDetailsServiceImpl.java | 6 + .../impl/SltAgreementInfoServiceImpl.java | 125 +++++++++------ 37 files changed, 589 insertions(+), 227 deletions(-) create mode 100644 sgzb-common/sgzb-common-core/src/main/java/com/bonus/sgzb/common/core/constant/RoleConstans.java create mode 100644 sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/ReportAlarm.java create mode 100644 sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/mapper/ReportAlarmMapper.java diff --git a/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/MaInputRecord.java b/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/MaInputRecord.java index 1a78e0a..4cf7a97 100644 --- a/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/MaInputRecord.java +++ b/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/MaInputRecord.java @@ -2,6 +2,7 @@ package com.bonus.sgzb.base.api.domain; import com.bonus.sgzb.common.core.web.domain.BaseEntity; import io.swagger.annotations.ApiModelProperty; +import lombok.Data; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; @@ -13,6 +14,7 @@ import java.math.BigDecimal; * @author bonus * @date 2023-12-15 */ +@Data public class MaInputRecord extends BaseEntity { private static final long serialVersionUID = 1L; @@ -61,7 +63,11 @@ public class MaInputRecord extends BaseEntity @ApiModelProperty(value = "机具编号") private String maCode; - + /** + * 机具类型,1:数量;0:编码 + */ + @ApiModelProperty(value = "管理类型") + private String manageType; public void setId(Long id) { diff --git a/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/SltAgreementApply.java b/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/SltAgreementApply.java index c97fc19..2f356a3 100644 --- a/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/SltAgreementApply.java +++ b/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/SltAgreementApply.java @@ -2,8 +2,6 @@ package com.bonus.sgzb.base.api.domain; import lombok.Data; -import java.util.List; - /** * @author c liu * @date 2024/2/21 @@ -59,7 +57,8 @@ public class SltAgreementApply { *结算总费用 */ private String cost; + private String repairIds; - private List relations; + private SltAgreementRelation relation; } 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 5ffd4cd..558bf9b 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 @@ -44,6 +44,10 @@ public class SltAgreementInfo { *机具id */ private String maId; + /** + *配件单价 + */ + private String partPrice; /** *领料数量 */ @@ -67,6 +71,10 @@ public class SltAgreementInfo { *领料id */ private String leaseId; + /** + *配件数量 + */ + private String partNum; /** *退料id */ @@ -153,7 +161,7 @@ public class SltAgreementInfo { /** * 费用承担方 */ - @Excel(name = "费用承担方") + @Excel(name = "费用承担方(01项目,03分包)") private String costBearingParty; /** * 调整天数 diff --git a/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/SltAgreementRelation.java b/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/SltAgreementRelation.java index d96e40e..b3bf5fb 100644 --- a/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/SltAgreementRelation.java +++ b/sgzb-api/sgzb-api-system/src/main/java/com/bonus/sgzb/base/api/domain/SltAgreementRelation.java @@ -45,6 +45,7 @@ public class SltAgreementRelation { private String leaseCostOne; private String leaseCostThree; private String scrapCost; + private String preScrapCost; private String repairCost; private String isSltOne; private String isSltThree; diff --git a/sgzb-common/sgzb-common-core/src/main/java/com/bonus/sgzb/common/core/constant/RoleConstans.java b/sgzb-common/sgzb-common-core/src/main/java/com/bonus/sgzb/common/core/constant/RoleConstans.java new file mode 100644 index 0000000..c730ae4 --- /dev/null +++ b/sgzb-common/sgzb-common-core/src/main/java/com/bonus/sgzb/common/core/constant/RoleConstans.java @@ -0,0 +1,46 @@ +package com.bonus.sgzb.common.core.constant; + +public class RoleConstans { + + private RoleConstans() { + throw new IllegalStateException("Utility class"); + } + + /** + * 管理员 + */ + public static final String STRING_ADMIN = "admin"; + /** + * 机具设备分公司--机具库管员 + */ + public static final String STRING_JJFGS = "jjfgs"; + /** + * 机具设备分公司--班长 + */ + public static final String STRING_JJBZ = "jjbz"; + /** + * 副班长 + */ + public static final String STRING_FBZ = "fbz"; + /** + *机具设备分公司--机具经理/书记 + */ + public static final String STRING_EM01 = "em01"; + /** + * 机具设备分公司--机具副经理 + */ + public static final String STRING_EM02 = "em02"; + /** + * 机具设备分公司--安全员 + */ + public static final String STRING_EM03 = "em03"; + /** + * 调试分公司--调试经理 + */ + public static final String STRING_DM01 = "dm01"; + + /** + * 调试分公司--调试库管员 + */ + public static final String STRING_DM05 = "dm05"; +} diff --git a/sgzb-common/sgzb-common-core/src/main/java/com/bonus/sgzb/common/core/utils/DateTimeHelper.java b/sgzb-common/sgzb-common-core/src/main/java/com/bonus/sgzb/common/core/utils/DateTimeHelper.java index fa1177a..2565729 100644 --- a/sgzb-common/sgzb-common-core/src/main/java/com/bonus/sgzb/common/core/utils/DateTimeHelper.java +++ b/sgzb-common/sgzb-common-core/src/main/java/com/bonus/sgzb/common/core/utils/DateTimeHelper.java @@ -4,6 +4,7 @@ import org.apache.commons.lang3.time.DateUtils; import java.text.*; import java.time.LocalDate; +import java.time.YearMonth; import java.time.format.DateTimeFormatter; import java.time.temporal.ChronoUnit; import java.time.temporal.TemporalAdjusters; @@ -795,6 +796,19 @@ public class DateTimeHelper { return lastDayOfMonth; } + // 获取上个月的年月 + public static String getLastMonthYearMonth() { + // 获取当前时间的年月 + YearMonth now = YearMonth.now(); + + // 减去一个月 + YearMonth lastMonth = now.minusMonths(1); + + // 将YearMonth对象格式化为字符串 + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM"); + return lastMonth.format(formatter); + } + public static void main(String[] args) { System.err.println(getTimeAfterThirtyDay()); System.err.println(getNowTime()); @@ -926,16 +940,46 @@ public class DateTimeHelper { return list; } - public static String getCalStartDay() { + public static String getPreMonthFirstDay() { SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); + // 获取当前月第一天: Calendar c = Calendar.getInstance(); c.add(Calendar.MONTH, -1); - c.set(Calendar.DAY_OF_MONTH, 21); + c.set(Calendar.DAY_OF_MONTH, 1);// 设置为1号,当前日期既为本月第一天 String first = format.format(c.getTime()); return first; } - public static String getCalDay(int day) { + public static String getCurrentMonthFirstDay() { + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); + // 获取当前月第一天: + Calendar c = Calendar.getInstance(); + c.add(Calendar.MONTH, 0); + c.set(Calendar.DAY_OF_MONTH, 1);// 设置为1号,当前日期既为本月第一天 + String first = format.format(c.getTime()); + return first; + } + + public static String getPreLastDay() { + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); + // 获取当前月最后一天 + Calendar c = Calendar.getInstance(); + c.add(Calendar.MONTH, -1); + c.set(Calendar.DAY_OF_MONTH, c.getActualMaximum(Calendar.DAY_OF_MONTH)); + String last = format.format(c.getTime()); + return last; + } + + public static String getPreMonthCalStartDay(int day) { + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); + Calendar c = Calendar.getInstance(); + c.add(Calendar.MONTH, -1); + c.set(Calendar.DAY_OF_MONTH, day); + String first = format.format(c.getTime()); + return first; + } + + public static String getCurrentMonthCalEndDay(int day) { SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd"); Calendar c = Calendar.getInstance(); c.add(Calendar.MONTH, 0); diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/app/domain/LeaseApplyInfo.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/app/domain/LeaseApplyInfo.java index c3f3f6c..f5bab20 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/app/domain/LeaseApplyInfo.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/app/domain/LeaseApplyInfo.java @@ -55,7 +55,7 @@ public class LeaseApplyInfo implements Serializable { /** * 费用承担方 */ - @ApiModelProperty(value = "费用承担方") + @ApiModelProperty(value = "费用承担方(01项目,03分包)") private String costBearingParty; /** diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/app/domain/TmTask.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/app/domain/TmTask.java index 09d5594..1701377 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/app/domain/TmTask.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/app/domain/TmTask.java @@ -69,7 +69,7 @@ public class TmTask implements Serializable { /** * 费用承担方 */ - @ApiModelProperty(value = "费用承担方") + @ApiModelProperty(value = "费用承担方(01项目,03分包)") private String costBearingParty; /** * 编号 diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/app/service/impl/TmTaskServiceImpl.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/app/service/impl/TmTaskServiceImpl.java index fd9d2da..a37eae3 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/app/service/impl/TmTaskServiceImpl.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/app/service/impl/TmTaskServiceImpl.java @@ -1090,15 +1090,15 @@ public class TmTaskServiceImpl implements TmTaskService { remark = leaseApplyInfo1.getRemark(); phone = leaseApplyInfo1.getPhone(); } - List leaseApplyDetails = task.getLeaseApplyDetails(); + List LeaseApplyInfoList = task.getLeaseApplyInfoList(); Long taskId = task.getTaskId(); - if (CollUtil.isNotEmpty(leaseApplyDetails)) { - for (LeaseApplyDetails leaseApplyDetail : leaseApplyDetails) { + if (CollUtil.isNotEmpty(LeaseApplyInfoList)) { + for (LeaseApplyInfo leaseApply : LeaseApplyInfoList) { LeaseApplyInfo leaseApplyInfos = new LeaseApplyInfo(); - if (leaseApplyDetail.getCompanyId() == null) { + if (leaseApply.getCompanyId() == null) { leaseApplyInfos = leaseApplyInfoMapper.selectByTaskIdAndCompIdCq(String.valueOf(taskId)); } else { - leaseApplyInfos = leaseApplyInfoMapper.selectByTaskIdAndCompId(String.valueOf(taskId), leaseApplyDetail.getCompanyId()); + leaseApplyInfos = leaseApplyInfoMapper.selectByTaskIdAndCompId(String.valueOf(taskId), leaseApply.getCompanyId()); } if (leaseApplyInfos == null) { LeaseApplyInfo leaseApplyInfo = new LeaseApplyInfo(); @@ -1115,9 +1115,10 @@ public class TmTaskServiceImpl implements TmTaskService { } leaseApplyInfo.setRemark(remark); leaseApplyInfo.setType(task.getLeaseApplyInfoList().get(0).getType()); - leaseApplyInfo.setCompanyId(leaseApplyDetail.getCompanyId()); + leaseApplyInfo.setCompanyId(leaseApply.getCompanyId()); leaseApplyInfo.setEstimateLeaseTime(task.getEstimateLeaseTime()); leaseApplyInfo.setLeaseType(task.getLeaseType()); + leaseApplyInfo.setCostBearingParty(leaseApply.getCostBearingParty()); res = leaseApplyInfoMapper.insert(leaseApplyInfo); } } diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/controller/MaReceiveController.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/controller/MaReceiveController.java index 791bf62..f309528 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/controller/MaReceiveController.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/controller/MaReceiveController.java @@ -21,7 +21,7 @@ import java.util.List; */ @RestController -@RequestMapping("/base/receive") +@RequestMapping("/receive") public class MaReceiveController extends BaseController { @Resource diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/domain/RepairApplyRecord.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/domain/RepairApplyRecord.java index eb51bd1..ab0931a 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/domain/RepairApplyRecord.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/domain/RepairApplyRecord.java @@ -119,6 +119,7 @@ public class RepairApplyRecord implements Serializable { private List partList; private String partStrList; private Long companyId; + private Integer partId; /** * 损坏照片id */ diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/mapper/MaTypeMapper.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/mapper/MaTypeMapper.java index 0777ba3..dda795a 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/mapper/MaTypeMapper.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/mapper/MaTypeMapper.java @@ -12,7 +12,7 @@ import java.util.List; /** * 工机具类型管理 数据层 - * + * * @author ruoyi */ @Mapper @@ -84,4 +84,6 @@ public interface MaTypeMapper { int deletePropSetByTypeId(Long typeId); int updateTypeNum(MaMachine maMachine); + + List selectMaTypeByUserId(Long userId); } \ No newline at end of file diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/mapper/RepairMapper.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/mapper/RepairMapper.java index 5f8700f..666bed5 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/mapper/RepairMapper.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/mapper/RepairMapper.java @@ -161,4 +161,6 @@ public interface RepairMapper { List exportRepairTaskList(RepairTask bean); int addRepairCost(@Param("bean") RepairApplyRecord bean, @Param("costs") BigDecimal costs,@Param("partType") String partType); + + String selectPartPrice(Long partId); } diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/service/impl/ExcelServiceImpl.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/service/impl/ExcelServiceImpl.java index af0e5fb..e2fae7d 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/service/impl/ExcelServiceImpl.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/service/impl/ExcelServiceImpl.java @@ -161,74 +161,47 @@ public class ExcelServiceImpl implements ExcelService { } } - private void printLevel3Relation(Map>> level3Relation) { for (Map.Entry>> firstLevel : level3Relation.entrySet()) { - boolean outExist = true; System.out.println("level_1: " + firstLevel.getKey()); - //TODO, sql查询:是否有此名字 + parentId=0, select * from ma_part_type where name=? and parent_id=0; MaPartType maPartType_level1 = excelMapper.selectMa(firstLevel.getKey(),0); - //TODO, 以上返回 maPartType_level1 if (Objects.nonNull(maPartType_level1)) { - loopInner(firstLevel, outExist,maPartType_level1.getPaId()); + loopInner(firstLevel, maPartType_level1.getPaId()); } else { - //TODO, insert firstLevel, get id MaPartType maPartType = new MaPartType(); maPartType.setPaName(firstLevel.getKey()); maPartType.setCreateBy(SecurityUtils.getLoginUser().getUserid().toString()); maPartType.setParentId(0L); maPartType.setLevel("1"); excelMapper.insertPaName(maPartType);//如果第一层在数据库中查询不到则插入数据,并且读取到parent_id - outExist = outExist && false; - loopInner(firstLevel, outExist, maPartType.getPaId()); + loopInner(firstLevel, maPartType.getPaId()); } } } - private void loopInner(Map.Entry>> firstLevel, boolean outExist, long firstLevelId) { + private void loopInner(Map.Entry>> firstLevel, long firstLevelId) { for (Map.Entry> secondLevel : firstLevel.getValue().entrySet()) { System.out.println("\tlevel_2: " + secondLevel.getKey()); - //TODO, sql查询:是否有此名字 + parentId=firstLevelId, select * from ma_part_type where name=? and parent_id = firstLevelId; MaPartType maPartType_level2 = excelMapper.selectMa(secondLevel.getKey(),firstLevelId); - //TODO, 以上返回 maPartType_level2 if (Objects.nonNull(maPartType_level2)) { - looplevel3(secondLevel, outExist, maPartType_level2.getPaId()); + looplevel3(secondLevel, maPartType_level2.getPaId()); } else { - //TODO, insert firstLevel, get id - if (!outExist) { - MaPartType maPartType = new MaPartType(); - maPartType.setPaName(secondLevel.getKey()); - maPartType.setCreateBy(SecurityUtils.getLoginUser().getUserid().toString()); - maPartType.setParentId(firstLevelId); - maPartType.setLevel("2"); - excelMapper.insertPaName(maPartType);//如果第一层在数据库中查询不到则插入数据,并且读取到parent_id - outExist = outExist && false; - looplevel3(secondLevel, outExist, maPartType.getPaId()); - } + MaPartType maPartType = new MaPartType(); + maPartType.setPaName(secondLevel.getKey()); + maPartType.setCreateBy(SecurityUtils.getLoginUser().getUserid().toString()); + maPartType.setParentId(firstLevelId); + maPartType.setLevel("2"); + excelMapper.insertPaName(maPartType);//如果第一层在数据库中查询不到则插入数据,并且读取到parent_id + looplevel3(secondLevel, maPartType.getPaId()); } } } - private void looplevel3(Map.Entry> secondLevel, boolean outExist, long secondLevelId) { + private void looplevel3(Map.Entry> secondLevel, long secondLevelId) { for (MapType thirdLevel : secondLevel.getValue()) { System.out.println("\t\tlevel_3: " + thirdLevel); - //TODO, sql查询:是否有此名字 + parentId=secondLevelId, select * from ma_part_type where name=? and parent_id = secondLevelId; MaPartType maPartType_level3 = excelMapper.selectMa(thirdLevel.getPaName(),secondLevelId); - //TODO, 以上返回 maPartType_level3 - if (Objects.nonNull(maPartType_level3)) { - if (!outExist) { - //TODO insert - MaPartType maPartType = new MaPartType(); - maPartType.setPaName(thirdLevel.getPaName()); - maPartType.setCreateBy(SecurityUtils.getLoginUser().getUserid().toString()); - maPartType.setUnitId(thirdLevel.getUnitId()); - maPartType.setBuyPrice(thirdLevel.getBuyPrice()); - maPartType.setParentId(secondLevelId); - maPartType.setLevel("3"); - excelMapper.insertPaName(maPartType);//如果第一层在数据库中查询不到则插入数据,并且读取到parent_id - } - } else { - //TODO insert + if (Objects.isNull(maPartType_level3)) { MaPartType maPartType = new MaPartType(); maPartType.setPaName(thirdLevel.getPaName()); maPartType.setCreateBy(SecurityUtils.getLoginUser().getUserid().toString()); diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/service/impl/RepairServiceImpl.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/service/impl/RepairServiceImpl.java index a39d8b5..78d8a91 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/service/impl/RepairServiceImpl.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/base/service/impl/RepairServiceImpl.java @@ -8,11 +8,11 @@ import com.bonus.sgzb.base.domain.vo.DictVo; import com.bonus.sgzb.base.mapper.RepairMapper; import com.bonus.sgzb.base.service.RepairService; import com.bonus.sgzb.common.core.exception.ServiceException; -import com.bonus.sgzb.common.core.utils.StringUtils; import com.bonus.sgzb.common.core.web.domain.AjaxResult; import com.bonus.sgzb.common.security.utils.SecurityUtils; import com.bonus.sgzb.system.api.domain.SysUser; import com.bonus.sgzb.system.api.model.LoginUser; +import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -58,8 +58,6 @@ public class RepairServiceImpl implements RepairService { bean.setCreateBy(loginUser.getUserid()); List partList = bean.getPartList(); BigDecimal sfCosts = new BigDecimal("0"); - BigDecimal bsfCosts = new BigDecimal("0"); - Integer partNum = 0; String nbType = "1"; String fcType = "2"; String sfPart = "1"; @@ -103,6 +101,7 @@ public class RepairServiceImpl implements RepairService { if (nbType.equals(bean.getRepairType())) { for (RepairPartDetails partDetails : partList) { if (partDetails.getPartId() != null) { + // 有维修配件时 if (partDetails.getPartCost() == null || partDetails.getPartCost().isEmpty()) { partDetails.setPartCost("0"); } @@ -111,11 +110,21 @@ public class RepairServiceImpl implements RepairService { partDetails.setTypeId(bean.getTypeId()); partDetails.setCreateBy(loginUser.getUserid()); partDetails.setCompanyId(bean.getCompanyId()); + // 根据partid 找到配件单价 + String partPrice = mapper.selectPartPrice(partDetails.getPartId()); + partDetails.setPartCost(partPrice); mapper.addPart(partDetails); - partNum += partDetails.getPartNum(); + bean.setPartPrice(partDetails.getPartCost()); + bean.setPartId(partDetails.getPartId().intValue()); + bean.setPartNum(partDetails.getPartNum()); + bean.setRepairContent(partDetails.getRepairContent()); + bean.setPartType(partDetails.getPartType()); + mapper.addRecord(bean); + } else { + // 不选维修配件时 + mapper.addRecord(bean); } } - bean.setPartNum(partNum); } if (fcType.equals(bean.getRepairType())) { bean.setPartName(partList.get(0).getPartName()); @@ -126,39 +135,26 @@ public class RepairServiceImpl implements RepairService { } else { bean.setSupplierId(partList.get(0).getSupplierId()); } - if (bean.getPartPrice() == null || bean.getPartPrice().isEmpty()) { + if (partList.get(0).getPartPrice() == null || partList.get(0).getPartPrice().isEmpty()) { bean.setPartPrice("0"); } else { bean.setPartPrice(partList.get(0).getPartPrice()); } bean.setPartNum(partList.get(0).getPartNum()); + mapper.addRecord(bean); } for (RepairPartDetails partDetails : partList) { - - if (sfPart.equals(partDetails.getPartType())) { - if (StringUtils.isEmpty(partDetails.getPartCost())) { - partDetails.setPartCost("0"); - } + if (StringUtils.isNotBlank(partDetails.getPartCost())) { BigDecimal partCost = new BigDecimal(partDetails.getPartCost()); - sfCosts = sfCosts.add(partCost); - } else if (bsfPart.equals(partDetails.getPartType())) { - if (StringUtils.isEmpty(partDetails.getPartCost())) { - partDetails.setPartCost("0"); - } - BigDecimal partCost = new BigDecimal(partDetails.getPartCost()); - bsfCosts = bsfCosts.add(partCost); - } else { - throw new ServiceException("请选择配件收费类型"); + BigDecimal partNumber = new BigDecimal(partDetails.getPartNum()); + sfCosts = sfCosts.add(partCost.multiply(partNumber)); } } + if (!"0".equals(sfCosts.toString())) { mapper.addRepairCost(bean, sfCosts, sfPart); } - if (!"0".equals(bsfCosts.toString())) { - mapper.addRepairCost(bean, bsfCosts, bsfPart); - } } - mapper.addRecord(bean); return AjaxResult.success(); } diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/controller/IotMachineController.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/controller/IotMachineController.java index 992fa8f..47c0abf 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/controller/IotMachineController.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/controller/IotMachineController.java @@ -3,10 +3,7 @@ package com.bonus.sgzb.material.controller; import com.bonus.sgzb.common.core.web.controller.BaseController; import com.bonus.sgzb.common.core.web.domain.AjaxResult; import com.bonus.sgzb.common.core.web.page.TableDataInfo; -import com.bonus.sgzb.material.domain.IotDto; -import com.bonus.sgzb.material.domain.IotLocationVo; -import com.bonus.sgzb.material.domain.IotRecordVo; -import com.bonus.sgzb.material.domain.IotVo; +import com.bonus.sgzb.material.domain.*; import com.bonus.sgzb.material.service.IotMachineService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -162,29 +159,50 @@ public class IotMachineController extends BaseController { @ApiOperation("获取定位") @PostMapping("/getLocation") - public AjaxResult getLocation(@Validated @RequestBody IotDto iotDto) { - log.info("获取定位接口:{}", iotDto); - return iotMachineService.getLocation(iotDto); + public AjaxResult getLocation(@Validated @RequestBody IotLocationVo iotLocationVo) { + log.info("获取定位接口:{}", iotLocationVo); + return AjaxResult.success(iotMachineService.getLocation(iotLocationVo)); } @ApiOperation("查询行程") @PostMapping("/searchItinerary") public AjaxResult searchItinerary(@Validated @RequestBody IotLocationVo iotLocationVo) { log.info("查询行程接口:{}", iotLocationVo); - return iotMachineService.searchItinerary(iotLocationVo); + return AjaxResult.success(iotMachineService.searchItinerary(iotLocationVo)); } @ApiOperation("查询停留点") @PostMapping("/reportParkDetailByTime") public AjaxResult reportParkDetailByTime(@Validated @RequestBody IotLocationVo iotLocationVo) { log.info("查询停留点接口:{}", iotLocationVo); - return iotMachineService.reportParkDetailByTime(iotLocationVo); + return AjaxResult.success(iotMachineService.reportParkDetailByTime(iotLocationVo)); } @ApiOperation("报警记录") @PostMapping("/reportAlarm") public AjaxResult reportAlarm(@Validated @RequestBody IotLocationVo iotLocationVo) { log.info("报警记录接口:{}", iotLocationVo); - return iotMachineService.reportAlarm(iotLocationVo); + return AjaxResult.success(iotMachineService.reportAlarm(iotLocationVo)); + } + + @ApiOperation("报警推送") + @GetMapping("/alarmPush") + public AjaxResult alarmPush() { + log.info("报警推送:======="); + return AjaxResult.success(iotMachineService.alarmPush()); + } + + @ApiOperation("报警列表") + @PostMapping("/alarmList") + public AjaxResult alarmList(@Validated @RequestBody IotLocationVo iotLocationVo) { + log.info("报警列表:======="); + return AjaxResult.success(iotMachineService.alarmList(iotLocationVo)); + } + + @ApiOperation("报警处置") + @PostMapping("/alarmManagement") + public AjaxResult alarmManagement(@Validated @RequestBody ReportAlarm reportAlarm) { + log.info("报警处置:======="); + return AjaxResult.success(iotMachineService.alarmManagement(reportAlarm)); } } diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/controller/PurchaseMacodeInfoController.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/controller/PurchaseMacodeInfoController.java index 07ec0ed..921bff0 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/controller/PurchaseMacodeInfoController.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/controller/PurchaseMacodeInfoController.java @@ -83,6 +83,7 @@ public class PurchaseMacodeInfoController extends BaseController { @GetMapping(value = "/putinDetails") public TableDataInfo putinDetails(PurchaseMacodeInfo purchaseMacodeInfo) { startPage(); + return getDataTable(purchaseMacodeInfoService.selectPutinDetails(purchaseMacodeInfo)); } 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 991459e..58bf8fb 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 @@ -136,7 +136,7 @@ public class AgreementInfo extends BaseEntity { private String cost; @ApiModelProperty(value = "结算状态") private String sltStatus; - @ApiModelProperty(value = "费用承担方") + @ApiModelProperty(value = "费用承担方(01项目,03分包)") private String costBearingParty; private String codeNum; /** diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/IotLocationVo.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/IotLocationVo.java index 84afef0..1ef938e 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/IotLocationVo.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/IotLocationVo.java @@ -10,7 +10,7 @@ public class IotLocationVo { /** iot设备ID */ @ApiModelProperty(value = "iot设备ID") - private Long iotId; + private String iotId; /** 经度 */ @ApiModelProperty(value = "经度") @@ -40,4 +40,10 @@ public class IotLocationVo { /** 报警内容 */ @ApiModelProperty(value = "报警内容") private String startAlarm; + + /** + * 记录的uuid 唯一确定这一条记录 + */ + @ApiModelProperty(value = "记录的uuid 唯一确定这一条记录") + private String deviceAlarmId; } diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/ProjectMonthCosts.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/ProjectMonthCosts.java index 0a8878e..f9de886 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/ProjectMonthCosts.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/ProjectMonthCosts.java @@ -23,6 +23,10 @@ public class ProjectMonthCosts { * 结算记录关联id */ private Integer sltMonthId; + /** + * 结算记录关联 task id + */ + private Integer taskId; /** * 单位id */ @@ -36,7 +40,7 @@ public class ProjectMonthCosts { */ private String month; /** - * 费用承担方 + * 费用承担方(01项目,03分包) */ private String costBearingParty; /** diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/ProjectMonthDetail.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/ProjectMonthDetail.java index 5a0b37c..3ac12f2 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/ProjectMonthDetail.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/ProjectMonthDetail.java @@ -63,7 +63,7 @@ public class ProjectMonthDetail { */ private String leasePrice; /** - * 费用承担方 + * 费用承担方(01项目,03分包) */ private String costBearingParty; private String leaseDays; diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/ReportAlarm.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/ReportAlarm.java new file mode 100644 index 0000000..ac21e60 --- /dev/null +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/domain/ReportAlarm.java @@ -0,0 +1,49 @@ +package com.bonus.sgzb.material.domain; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.Date; + +@Data +public class ReportAlarm { + + + /** + * 主键 + */ + private int id; + + /** iot设备编码 */ + @ApiModelProperty(value = "iot设备编码") + private String iotCode; + + /** + * 记录的uuid 唯一确定这一条记录 + */ + private String deviceAlarmId; + + /** 报警时间 */ + @ApiModelProperty(value = "报警时间") + private Date startAlarmTime; + + /** 报警内容 */ + @ApiModelProperty(value = "报警内容") + private String startAlarm; + + /** 是否推送 0:否,1:是 */ + @ApiModelProperty(value = "是否推送 0:否,1:是") + private Integer whetherPush; + + /** 是否核实 0:否,1:是 */ + @ApiModelProperty(value = "是否核实 0:否,1:是") + private String whetherVerify; + + /** 核实人 */ + @ApiModelProperty(value = "核实人") + private Long StringBy; + + /** 核实时间 */ + @ApiModelProperty(value = "核实时间") + private Date verifyTime; +} diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/mapper/CalMonthlyMapper.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/mapper/CalMonthlyMapper.java index ffdc51f..f17cd44 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/mapper/CalMonthlyMapper.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/mapper/CalMonthlyMapper.java @@ -28,6 +28,8 @@ public interface CalMonthlyMapper { int deleteCalcRecord(CalMonthlyBean bean); + int deleteMonthlyDetail(CalMonthlyBean bean); + int deleteMonthlyCosts(CalMonthlyBean bean); int insertProMonCosts(ProjectMonthCosts projectMonthCosts); diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/mapper/IotMachineMapper.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/mapper/IotMachineMapper.java index 3b64019..ba7f803 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/mapper/IotMachineMapper.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/mapper/IotMachineMapper.java @@ -117,4 +117,6 @@ public interface IotMachineMapper { * @return */ List getRecordList(IotDto iotDto); + + List selectListByTypeId(Long typeId); } diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/mapper/PurchaseCheckDetailsMapper.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/mapper/PurchaseCheckDetailsMapper.java index d545a92..e5a8e3e 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/mapper/PurchaseCheckDetailsMapper.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/mapper/PurchaseCheckDetailsMapper.java @@ -21,7 +21,7 @@ public interface PurchaseCheckDetailsMapper { * @param taskId 新购验收任务详细purchase_check_details主键 * @return 新购验收任务详细purchase_check_details */ - public PurchaseCheckDetails selectPurchaseCheckDetailsByTaskId(Long taskId); + public List selectPurchaseCheckDetailsByTaskId(Long taskId); /** * 查询新购验收任务详细purchase_check_details列表 diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/mapper/RepairAuditDetailsMapper.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/mapper/RepairAuditDetailsMapper.java index 7573f38..1918db0 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/mapper/RepairAuditDetailsMapper.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/mapper/RepairAuditDetailsMapper.java @@ -145,4 +145,8 @@ public interface RepairAuditDetailsMapper List getPartRecord(RepairAuditDetails bean); int updateRepairCost(@Param("inputDetails")RepairAuditDetails inputDetails, @Param("status") String status); + + List getRepairApplyRecordId(Long repairId); + + void updateRecodeStatus(String id); } diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/mapper/ReportAlarmMapper.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/mapper/ReportAlarmMapper.java new file mode 100644 index 0000000..dd78eee --- /dev/null +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/mapper/ReportAlarmMapper.java @@ -0,0 +1,25 @@ +package com.bonus.sgzb.material.mapper; + +import com.bonus.sgzb.material.domain.IotLocationVo; +import com.bonus.sgzb.material.domain.ReportAlarm; +import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +@Mapper +public interface ReportAlarmMapper { + + int add(ReportAlarm reportAlarm); + + + int deleteById(Long id); + + + int update(ReportAlarm reportAlarm); + + + ReportAlarm selectByDeviceAlarmId(@Param("DeviceAlarmId") String DeviceAlarmId); + + List selectByIotCode(IotLocationVo iotLocationVo); +} 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 0530ee4..bc1700d 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 @@ -70,4 +70,6 @@ public interface SltAgreementInfoMapper { int updateOutSourceCosts(SltAgreementInfo sltAgreementInfo); int updateBmAgreementInfo(@Param("agreementId") String agreementId); + + int updateRecodeIsSlt(String id); } diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/remind/Inform.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/remind/Inform.java index 308baac..5194e5a 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/remind/Inform.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/remind/Inform.java @@ -1,28 +1,35 @@ package com.bonus.sgzb.material.remind; +import com.bonus.sgzb.common.core.utils.StringUtils; import com.bonus.sgzb.material.remind.service.CalcMonthlyService; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.scheduling.annotation.Async; import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; - @Component public class Inform { @Autowired - private CalcMonthlyService calcfourCostService; + private CalcMonthlyService calcMonthlyService; - private final int CAL_DAY = 6; + @Value("${sgzb.job.settlementJobDay}") + private String settlementJobDay; -// @Scheduled(cron = "0 */1 * * * ? ") // 间隔5分钟执行 -// @Scheduled(cron = "0 0 1 22 * ? ") // 每个月22日凌晨1点执行 + //@Scheduled(cron = "0 */3 * * * ? ") // 间隔3分钟执行 + @Scheduled(cron = "${sgzb.job.settlementJobCron}") // 结算日次日凌晨执行 @Async public void taskCycle() { System.out.println("===springMVC定时器启动===="); try { - // 生成每月数据 (上月21日---本月20日) - calcfourCostService.calcMonthInfo(CAL_DAY); + + if (StringUtils.isEmpty(settlementJobDay)) { + calcMonthlyService.calcMonthInfo(1); + } else { + int calDay = Integer.parseInt(settlementJobDay); + calcMonthlyService.calcMonthInfo(calDay); + } } catch (Exception e) { e.printStackTrace(); diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/remind/service/CalcMonthlyServiceImp.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/remind/service/CalcMonthlyServiceImp.java index 777d495..3c0cea1 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/remind/service/CalcMonthlyServiceImp.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/remind/service/CalcMonthlyServiceImp.java @@ -34,22 +34,27 @@ public class CalcMonthlyServiceImp implements CalcMonthlyService { @Override public void calcMonthInfo(int day) { - String time = DateTimeHelper.getNowDate(); - String calDay = DateTimeHelper.getCalDay(day); - if (time.equals(calDay)) { - CalMonthlyBean record = new CalMonthlyBean(); - String month = DateTimeHelper.getCurrentMonth(); - record.setMonth(month); -// cleanSameMonthOldRecords(record); - List list = agreementInfoService.getAllAgreementId(); - String startTime = DateTimeHelper.getCalStartDay(); - String endTime = DateTimeHelper.getCalDay(day - 1); - list.forEach(t -> { - t.setStartTime(startTime); - t.setEndTime(endTime); - }); - getLeaseListMonth(list, record); + String month; + String startTime; + String endTime; + if (day == 1) { + month = DateTimeHelper.getPrevMonth(); + startTime = DateTimeHelper.getPreMonthFirstDay(); + endTime = DateTimeHelper.getCurrentMonthFirstDay(); + } else { + month = DateTimeHelper.getCurrentMonth(); + startTime = DateTimeHelper.getPreMonthCalStartDay(day); + endTime = DateTimeHelper.getCurrentMonthCalEndDay(day); } + CalMonthlyBean record = new CalMonthlyBean(); + record.setMonth(month); + cleanSameMonthOldRecords(record); + List list = agreementInfoService.getAllAgreementId(); + list.forEach(t -> { + t.setStartTime(startTime); + t.setEndTime(endTime); + }); + addProjectMonthCosts(list, record); } private void cleanSameMonthOldRecords(CalMonthlyBean record) { @@ -59,26 +64,27 @@ public class CalcMonthlyServiceImp implements CalcMonthlyService { //清除上月之前计算过的记录 calc_project_month calMonthlyMapper.deleteCalcRecord(bean); - //清除上月之前计算过的记录 project_month_costs(表名待定) + //清除上月之前计算过的记录 project_month_detail, project_month_costs + calMonthlyMapper.deleteMonthlyDetail(bean); calMonthlyMapper.deleteMonthlyCosts(bean); } } } - private List getLeaseListMonth(List list, CalMonthlyBean record) { + private List addProjectMonthCosts(List list, CalMonthlyBean record) { List leaseList = new ArrayList<>(); - + calMonthlyMapper.insertCalcRecord(record); + String taskId = record.getId(); for (AgreementInfo bean : list) { if (StringUtils.isNotBlank(bean.getStartTime()) && StringUtils.isNotBlank(bean.getEndTime())) { List monthList = sltAgreementInfoMapper.getLeaseListMonthNotNull(bean); monthList.stream().filter(Objects::nonNull); + for (SltAgreementInfo sltAgreementInfo : monthList) { - calMonthlyMapper.insertCalcRecord(record); - // slt_project_month的主键id - String spmId = record.getId(); ProjectMonthCosts projectMonthCosts = new ProjectMonthCosts(); projectMonthCosts.setAgreementId(Integer.parseInt(sltAgreementInfo.getAgreementId())); - projectMonthCosts.setSltMonthId(Integer.parseInt(spmId)); + projectMonthCosts.setSltMonthId(Integer.parseInt(taskId)); + projectMonthCosts.setTaskId(Integer.parseInt(taskId)); projectMonthCosts.setUnitId(sltAgreementInfo.getUnitId()); projectMonthCosts.setProjectId(sltAgreementInfo.getLotId()); projectMonthCosts.setMonth(record.getMonth()); @@ -94,7 +100,7 @@ public class CalcMonthlyServiceImp implements CalcMonthlyService { agreementInfo.setIds(sltAgreementInfo.getIds()); sltAgreementInfo.setMonth(bean.getMonth()); agreementInfo.setEndTime(sltAgreementInfo.getOffTime()); - List leaseListOneMonth = getLeaseListOneMonth(agreementInfo, sltAgreementInfo, pmcId); + List leaseListOneMonth = addProjectMonthDetail(agreementInfo, sltAgreementInfo, pmcId); projectMonthCosts.setCosts(sltAgreementInfo.getCosts()); calMonthlyMapper.updateProMonCosts(projectMonthCosts); sltAgreementInfo.setNode(leaseListOneMonth); @@ -106,25 +112,25 @@ public class CalcMonthlyServiceImp implements CalcMonthlyService { } - private List getLeaseListOneMonth(AgreementInfo list, SltAgreementInfo sltAgreementInfo, Integer pmcId) { + private List addProjectMonthDetail(AgreementInfo agreementInfo, SltAgreementInfo sltAgreementInfo, Integer pmcId) { ArrayList idList = new ArrayList<>(); - String[] ids = list.getIds().split(","); + String[] ids = agreementInfo.getIds().split(","); for (String id : ids) { idList.add(id); } - List leaseList = sltAgreementInfoMapper.getLeaseListOneMonth(list, idList); + List leaseList = sltAgreementInfoMapper.getLeaseListOneMonth(agreementInfo, idList); BigDecimal leaseCostOne = BigDecimal.ZERO; for (SltAgreementInfo bean : leaseList) { - if (bean.getLeasePrice() == null) { + if (StringUtils.isEmpty(bean.getLeasePrice())) { bean.setLeasePrice("0"); } - if (bean.getNum() == null) { + if (StringUtils.isEmpty(bean.getNum())) { bean.setNum("0"); } - if (bean.getLeaseDays() == null) { + if (StringUtils.isEmpty(bean.getLeaseDays())) { bean.setLeaseDays("0"); } - if (bean.getTrimDay() == null) { + if (Objects.isNull(bean.getTrimDay())) { bean.setTrimDay(0); } BigDecimal leasePrice = new BigDecimal(bean.getLeasePrice()); diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/IPurchaseCheckDetailsService.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/IPurchaseCheckDetailsService.java index 94f87b2..7f80fd4 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/IPurchaseCheckDetailsService.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/IPurchaseCheckDetailsService.java @@ -18,7 +18,7 @@ public interface IPurchaseCheckDetailsService * @param taskId 新购验收任务详细purchase_check_details主键 * @return 新购验收任务详细purchase_check_details */ - public PurchaseCheckDetails selectPurchaseCheckDetailsByTaskId(Long taskId); + public List selectPurchaseCheckDetailsByTaskId(Long taskId); /** * 查询新购验收任务详细purchase_check_details列表 diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/IotMachineService.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/IotMachineService.java index 6a4aad5..44de1b6 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/IotMachineService.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/IotMachineService.java @@ -1,10 +1,7 @@ package com.bonus.sgzb.material.service; import com.bonus.sgzb.common.core.web.domain.AjaxResult; -import com.bonus.sgzb.material.domain.IotDto; -import com.bonus.sgzb.material.domain.IotLocationVo; -import com.bonus.sgzb.material.domain.IotRecordVo; -import com.bonus.sgzb.material.domain.IotVo; +import com.bonus.sgzb.material.domain.*; import java.util.List; @@ -83,21 +80,21 @@ public interface IotMachineService { * @param iotDto * @return */ - AjaxResult getLocation(IotDto iotDto); + IotLocationVo getLocation(IotLocationVo iotLocationVo); /** * 查询行程 * @param iotLocationVo * @return */ - AjaxResult searchItinerary(IotLocationVo iotLocationVo); + String searchItinerary(IotLocationVo iotLocationVo); /** * 查询停留点 * @param iotLocationVo * @return */ - AjaxResult reportParkDetailByTime(IotLocationVo iotLocationVo); + List reportParkDetailByTime(IotLocationVo iotLocationVo); /** * App绑定设备 @@ -111,5 +108,16 @@ public interface IotMachineService { * @param iotLocationVo * @return */ - AjaxResult reportAlarm(IotLocationVo iotLocationVo); + List reportAlarm(IotLocationVo iotLocationVo); + + /** + * 报警推送 + * @param + * @return + */ + int alarmPush(); + + List alarmList(IotLocationVo iotLocationVo); + + int alarmManagement(ReportAlarm reportAlarm); } diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/IotMachineServiceImpl.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/IotMachineServiceImpl.java index 76378df..d901570 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/IotMachineServiceImpl.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/IotMachineServiceImpl.java @@ -3,9 +3,12 @@ package com.bonus.sgzb.material.service.impl; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson2.JSONObject; +import com.bonus.sgzb.base.domain.MaTypeKeeper; +import com.bonus.sgzb.base.mapper.MaTypeMapper; import com.bonus.sgzb.common.core.constant.HttpStatus; import com.bonus.sgzb.common.core.constant.TokenConstants; import com.bonus.sgzb.common.core.exception.ServiceException; +import com.bonus.sgzb.common.core.utils.DateUtils; import com.bonus.sgzb.common.core.utils.HttpHelper; import com.bonus.sgzb.common.core.utils.StringHelper; import com.bonus.sgzb.common.core.web.domain.AjaxResult; @@ -15,17 +18,20 @@ import com.bonus.sgzb.material.config.ExceptionEnum; import com.bonus.sgzb.material.config.FieldGenerator; import com.bonus.sgzb.material.domain.*; import com.bonus.sgzb.material.mapper.IotMachineMapper; +import com.bonus.sgzb.material.mapper.ReportAlarmMapper; import com.bonus.sgzb.material.service.IotMachineService; +import com.bonus.sgzb.system.api.domain.SysUser; +import lombok.Data; import lombok.extern.slf4j.Slf4j; +import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.interceptor.TransactionAspectSupport; import javax.annotation.Resource; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; +import java.text.ParseException; +import java.text.SimpleDateFormat; +import java.util.*; import java.util.concurrent.TimeUnit; /** @@ -42,6 +48,12 @@ public class IotMachineServiceImpl implements IotMachineService { @Resource private RedisService redisService; + @Resource + private MaTypeMapper maTypeMapper; + + @Resource + private ReportAlarmMapper reportAlarmMapper; + /** * 添加设备-保存 * @@ -108,14 +120,14 @@ public class IotMachineServiceImpl implements IotMachineService { iotDto.setUpdateBy(SecurityUtils.getLoginUser().getUserid().toString()); try { //设备修改 - int res = iotMachineMapper.update(iotDto); - if (res == 0) { - // 如果修改失败,返回修改到数据库异常的错误信息 - throw new ServiceException(ExceptionEnum.UPDATE_TO_DATABASE.getMsg()); - } else { - // 修改成功,返回成功的消息和修改的记录数 - return AjaxResult.success(ExceptionEnum.SUCCESS.getMsg(), res); - } + int res = iotMachineMapper.update(iotDto); + if (res == 0) { + // 如果修改失败,返回修改到数据库异常的错误信息 + throw new ServiceException(ExceptionEnum.UPDATE_TO_DATABASE.getMsg()); + } else { + // 修改成功,返回成功的消息和修改的记录数 + return AjaxResult.success(ExceptionEnum.SUCCESS.getMsg(), res); + } } catch (Exception e) { log.error("Error updating to database: " + e.getMessage()); //捕获异常 @@ -281,13 +293,13 @@ public class IotMachineServiceImpl implements IotMachineService { /** * 获取定位 - * @param iotDto + * @param iotLocationVo * @return */ @Override - public AjaxResult getLocation(IotDto iotDto) { - log.info("getLocation:{}", iotDto); - if (iotDto == null || iotDto.getIotId() == null) { + public IotLocationVo getLocation(IotLocationVo iotLocationVo) { + log.info("getLocation:{}", iotLocationVo); + if (iotLocationVo == null || iotLocationVo.getIotId() == null) { throw new ServiceException(ExceptionEnum.PARAM_NULL.getMsg()); } List list=new ArrayList<>(); @@ -300,14 +312,14 @@ public class IotMachineServiceImpl implements IotMachineService { redisService.setCacheObject(TokenConstants.TOKEN_LOCATION,redisCode,23L, TimeUnit.HOURS); } map.clear(); - list.add(iotDto.getIotId().toString()); + list.add(iotLocationVo.getIotId()); map.put("deviceids",list); String param = JSON.toJSONString(map); String res = HttpHelper.doPost(HttpStatus.LAST_POSITION_URL+redisCode,param); //对返回的结果进行解析 - IotLocationVo iotLocationVo = resultDataHandler(res); - log.info("返回结果resultDataHandler:{}", iotLocationVo); - return AjaxResult.success(iotLocationVo); + IotLocationVo iotLocationVoRes = resultDataHandler(res); + log.info("返回结果resultDataHandler:{}", iotLocationVoRes); + return iotLocationVoRes; } /** @@ -316,7 +328,7 @@ public class IotMachineServiceImpl implements IotMachineService { * @return */ @Override - public AjaxResult searchItinerary(IotLocationVo iotLocationVo) { + public String searchItinerary(IotLocationVo iotLocationVo) { log.info("searchItinerary:{}", iotLocationVo); if (iotLocationVo == null || iotLocationVo.getBeginTime() == null || iotLocationVo.getEndTime() == null) { throw new ServiceException(ExceptionEnum.PARAM_NULL.getMsg()); @@ -335,7 +347,7 @@ public class IotMachineServiceImpl implements IotMachineService { map.put("endtime",iotLocationVo.getEndTime()); String param = JSON.toJSONString(map); String res = HttpHelper.doPost(HttpStatus.QUERY_TRIPS_URL+redisCode,param); - return AjaxResult.success(res); + return res; } /** @@ -344,7 +356,7 @@ public class IotMachineServiceImpl implements IotMachineService { * @return */ @Override - public AjaxResult reportParkDetailByTime(IotLocationVo iotLocationVo) { + public List reportParkDetailByTime(IotLocationVo iotLocationVo) { log.info("reportParkDetailByTime:{}", iotLocationVo); if (iotLocationVo == null || iotLocationVo.getBeginTime() == null || iotLocationVo.getEndTime() == null) { @@ -366,8 +378,8 @@ public class IotMachineServiceImpl implements IotMachineService { String res = HttpHelper.doPost(HttpStatus.REPORT_PARK_DETAIL_BY_TIME_URL+redisCode,param); //对返回的结果进行解析 List iotLocationVoList = resultReportParkDetailByTime(res); - log.info("resultDataHandler:{}", iotLocationVo); - return AjaxResult.success(iotLocationVoList); + log.info("resultReportParkDetailByTime:{}", iotLocationVoList); + return iotLocationVoList; } /** @@ -447,7 +459,7 @@ public class IotMachineServiceImpl implements IotMachineService { * @return */ @Override - public AjaxResult reportAlarm(IotLocationVo iotLocationVo) { + public List reportAlarm(IotLocationVo iotLocationVo) { log.info("reportAlarm:{}", iotLocationVo); if (iotLocationVo == null || iotLocationVo.getIotId() == null || iotLocationVo.getBeginTime() == null || iotLocationVo.getEndTime() == null) { throw new ServiceException(ExceptionEnum.PARAM_NULL.getMsg()); @@ -463,7 +475,7 @@ public class IotMachineServiceImpl implements IotMachineService { redisService.setCacheObject(TokenConstants.TOKEN_LOCATION,redisCode,23L, TimeUnit.HOURS); } map.clear(); - list.add(iotLocationVo.getIotId().toString()); + list.add(iotLocationVo.getIotId()); map.put("devices",list); map.put("startday",iotLocationVo.getBeginTime()); map.put("endday",iotLocationVo.getEndTime()); @@ -474,9 +486,87 @@ public class IotMachineServiceImpl implements IotMachineService { //对返回的结果进行解析 List iotLocationVoList = resultReportAlarm(res); log.info("resultDataHandler:{}", iotLocationVo); - return AjaxResult.success(iotLocationVoList); + return iotLocationVoList; } + /** + * 报警推送 + * @param + * @return + * 每三个小时执行一次(3 * 60 * 60 * 1000 毫秒 = 10800000 毫秒) + */ + @Override + @Transactional(rollbackFor = Exception.class) + @Scheduled(fixedRate = 10800000) + public int alarmPush() { + log.info("开始获取报警信息===="); + //获取当前登录用户的所有信息 + Long userId = SecurityUtils.getLoginUser().getUserid(); + //查看当前用户名下有哪些类型的设备 + List maTypeKeeperList = maTypeMapper.selectMaTypeByUserId(userId); + List iotLocationVoAll = new ArrayList<>(); + for (int i = 0; i < maTypeKeeperList.size(); i++) { + //查询该类机具有哪些设备绑定的iot设备 + List iotVoList = iotMachineMapper.selectListByTypeId(maTypeKeeperList.get(i).getTypeId()); + for (IotVo iotVo:iotVoList) { + IotLocationVo iotLocationVo = new IotLocationVo(); + iotLocationVo.setIotId(iotVo.getIotCode()); + iotLocationVo.setBeginTime(DateUtils.getDate()); + iotLocationVo.setEndTime(DateUtils.getDate()); + //获取当前设备的报警信息 + List iotLocationVoList = reportAlarm(iotLocationVo); + //保存所有的报警信息 + iotLocationVoAll.addAll(iotLocationVoList); + } + } + int count = handlingAlarmInformation(iotLocationVoAll); + return count; + } + + @Override + public List alarmList(IotLocationVo iotLocationVo) { + log.info("alarmList:{}", iotLocationVo); + return reportAlarmMapper.selectByIotCode(iotLocationVo); + } + + @Override + public int alarmManagement(ReportAlarm reportAlarm) { + log.info("alarmManagement:{}", reportAlarm); + return reportAlarmMapper.update(reportAlarm); + } + + /** + * 处理报警信息 + * @param iotLocationVoAll + * @return + */ + private int handlingAlarmInformation(List iotLocationVoAll) { + log.info("处理报警信息===="); + int fly = 0; + if (iotLocationVoAll != null && iotLocationVoAll.size() > 0) { + for (IotLocationVo iotLocationVo : iotLocationVoAll) { + //根据当前的报警uuid查看是否有这条记录 + ReportAlarm reportAlarm = reportAlarmMapper.selectByDeviceAlarmId(iotLocationVo.getDeviceAlarmId()); + if (reportAlarm == null) { + reportAlarm.setIotCode(iotLocationVo.getIotId()); + reportAlarm.setDeviceAlarmId(iotLocationVo.getDeviceAlarmId()); + reportAlarm.setStartAlarm(iotLocationVo.getStartAlarm()); + SimpleDateFormat sdf = new SimpleDateFormat(DateUtils.YYYY_MM_DD_HH_MM_SS); + try { + reportAlarm.setStartAlarmTime(sdf.parse(iotLocationVo.getStartAlarmTime())); + } catch (ParseException e) { + log.error("日期转换异常!!!"); + } + //异常信息保存到数据库 + reportAlarmMapper.add(reportAlarm); + fly=1; + } + } + } + return fly; + } + + /** * 解析报警返回报文 * @param res @@ -500,6 +590,8 @@ public class IotMachineServiceImpl implements IotMachineService { IotLocationVo iotLocationVo = new IotLocationVo(); iotLocationVo.setStartAlarmTime(jsonObject.getString("startalarmtime")); iotLocationVo.setStartAlarm(jsonObject.getString("stralarm")); + iotLocationVo.setDeviceAlarmId(jsonObject.getString("devicealarmid")); + iotLocationVo.setIotId(jsonObject.getString("deviceid")); iotLocationVoList.add(iotLocationVo); } } @@ -528,7 +620,7 @@ public class IotMachineServiceImpl implements IotMachineService { JSONArray jsonArray = JSON.parseArray(records); for (int i = 0; i < jsonArray.size(); i++) { JSONObject jsonObject = JSONObject.from(jsonArray.getJSONObject(i)); - iotLocationVo.setIotId(StringHelper.conversionLong(jsonObject.getString("deviceid"))); + iotLocationVo.setIotId(jsonObject.getString("deviceid")); iotLocationVo.setCallat(StringHelper.conversionBigDecimal(jsonObject.getString("callat"))); iotLocationVo.setCallon(StringHelper.conversionBigDecimal(jsonObject.getString("callon"))); } diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/PurchaseCheckDetailsServiceImpl.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/PurchaseCheckDetailsServiceImpl.java index 5b04b89..386a2c5 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/PurchaseCheckDetailsServiceImpl.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/PurchaseCheckDetailsServiceImpl.java @@ -38,7 +38,7 @@ public class PurchaseCheckDetailsServiceImpl implements IPurchaseCheckDetailsSer * @return 新购验收任务详细purchase_check_details */ @Override - public PurchaseCheckDetails selectPurchaseCheckDetailsByTaskId(Long taskId) { + public List selectPurchaseCheckDetailsByTaskId(Long taskId) { return purchaseCheckDetailsMapper.selectPurchaseCheckDetailsByTaskId(taskId); } diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/PurchaseMacodeInfoServiceImpl.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/PurchaseMacodeInfoServiceImpl.java index d7b3855..dc271ec 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/PurchaseMacodeInfoServiceImpl.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/PurchaseMacodeInfoServiceImpl.java @@ -302,6 +302,7 @@ public class PurchaseMacodeInfoServiceImpl implements IPurchaseMacodeInfoService * 通过/不通过 */ @Override + @Transactional(rollbackFor = Exception.class) public int modifyManageStatus(MaInputVO maInputVO) { Long taskId = maInputVO.getTaskId(); String checkResult = maInputVO.getCheckResult(); @@ -378,20 +379,35 @@ public class PurchaseMacodeInfoServiceImpl implements IPurchaseMacodeInfoService purchaseMacodeInfoMapper.deleteMaLabelBindByMaId(maInputRecord.getMaId()); //修改purchase_macode_info表 purchaseMacodeInfoMapper.updatetePurchaseMaCodeInfoByMaCodeAndTaskIdAndTypeId(taskId, typeId, maInputRecord.getMaCode()); - //修改purchase_check_details表 - checkDetailsMapper.updatePurchaseCheckDetailsByTaskId(taskId, typeId); + if ("1".equals(maInputRecord.getManageType())){ + //修改purchase_check_details表 + checkDetailsMapper.updatePurchaseCheckDetailsByTaskId(taskId, typeId); + } } } //判断是否全部已操作(通过或不通过) int count=purchaseMacodeInfoMapper.isOperateAll(taskId); if (count<=0){ - //全部审核任务状态改为已审核 - TmTask task = new TmTask(); - task.setTaskId(taskId); - task.setTaskStatus(28); - task.setUpdateBy(String.valueOf(SecurityUtils.getLoginUser().getUserid())); - task.setUpdateTime(DateUtils.getNowDate()); - taskMapper.updateTmTask(task); + //获取该订单下所有的装备信息 + List purchaseCheckDetailsList=checkDetailsMapper.selectPurchaseCheckDetailsByTaskId(taskId); + //判断每种设备的验收数量和绑定数量一致 + for (PurchaseCheckDetails purchaseCheckDetails : purchaseCheckDetailsList) { + if (StringUtils.isNotNull(purchaseCheckDetails.getBindNum())){ + if (purchaseCheckDetails.getCheckNum().compareTo(BigDecimal.valueOf(purchaseCheckDetails.getBindNum()))!=0){ + //全部操作以后如果还有未绑定的,则不改变状态 + count=1; + } + } + } + if (count==0){ + //全部审核任务状态改为已审核 + TmTask task = new TmTask(); + task.setTaskId(taskId); + task.setTaskStatus(28); + task.setUpdateBy(String.valueOf(SecurityUtils.getLoginUser().getUserid())); + task.setUpdateTime(DateUtils.getNowDate()); + taskMapper.updateTmTask(task); + } } return 1; } diff --git a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/RepairAuditDetailsServiceImpl.java b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/RepairAuditDetailsServiceImpl.java index a1fbc60..de4cc20 100644 --- a/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/RepairAuditDetailsServiceImpl.java +++ b/sgzb-modules/sgzb-material/src/main/java/com/bonus/sgzb/material/service/impl/RepairAuditDetailsServiceImpl.java @@ -241,6 +241,12 @@ public class RepairAuditDetailsServiceImpl implements IRepairAuditDetailsService repairTestInputMapper.insertRepairInputDetails(repairInputDetails); } repairAuditDetailsMapper.updateRepairCost(inputDetails,status); + // 根据repairId找到taskId和 typeId 、maid + List repairApplyRecordId = repairAuditDetailsMapper.getRepairApplyRecordId(inputDetails.getRepairId()); + // 再去repair_apply_record 中查,并给一个标识表示审核完成 + for (String id : repairApplyRecordId) { + repairAuditDetailsMapper.updateRecodeStatus(id); + } } } if (scrapNumList != null && scrapNumList.size() > 0) { 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 39ead00..f1889fa 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 @@ -30,6 +30,7 @@ import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; import java.util.List; +import java.util.Objects; /** * @author c liu @@ -58,6 +59,7 @@ public class SltAgreementInfoServiceImpl implements SltAgreementInfoService { //维修费用列表 List repairList = getRepairList(list); //报废费用列表 + List scrapList = getScrapList(list); //预报废费用列表 List preScrapList = getPreScrapList(list); @@ -69,11 +71,12 @@ public class SltAgreementInfoServiceImpl implements SltAgreementInfoService { sltInfoVo.setScrapList(scrapList); sltInfoVo.setPreScrapList(preScrapList); sltInfoVo.setLoseList(loseList); - List relations = getRelations(leaseListOne, leaseListThree, repairList, scrapList, loseList, list); + List relations = getRelations(leaseListOne, leaseListThree, repairList, scrapList, preScrapList, loseList, list); sltInfoVo.setRelations(relations); return sltInfoVo; } + @Override public List getPreScrapList(List list) { List scrapList = new ArrayList<>(); String taskType = "57"; @@ -87,10 +90,10 @@ public class SltAgreementInfoServiceImpl implements SltAgreementInfoService { if (scrapList != null && scrapList.size() > 0) { for (SltAgreementInfo bean : scrapList) { - if (bean.getBuyPrice() == null) { + if (StringUtils.isEmpty(bean.getBuyPrice())) { bean.setBuyPrice("0"); } - if (bean.getNum() == null) { + if (StringUtils.isEmpty(bean.getNum())) { bean.setNum("0"); } BigDecimal buyPrice = new BigDecimal(bean.getBuyPrice()); @@ -166,15 +169,18 @@ public class SltAgreementInfoServiceImpl implements SltAgreementInfoService { leaseList.addAll(oneOfList); } for (SltAgreementInfo bean : leaseList) { - if (bean.getLeasePrice() == null) { + if (StringUtils.isEmpty(bean.getLeasePrice())) { bean.setLeasePrice("0"); } - if (bean.getNum() == null) { + if (StringUtils.isEmpty(bean.getNum())) { bean.setNum("0"); } - if (bean.getLeaseDays() == null) { + if (StringUtils.isEmpty(bean.getLeaseDays())) { bean.setLeaseDays("0"); } + if (Objects.isNull(bean.getTrimDay())) { + bean.setTrimDay(0); + } BigDecimal leasePrice = new BigDecimal(bean.getLeasePrice()); BigDecimal num = new BigDecimal(bean.getNum()); BigDecimal leaseDays = new BigDecimal(bean.getLeaseDays()); @@ -201,16 +207,16 @@ public class SltAgreementInfoServiceImpl implements SltAgreementInfoService { leaseList.addAll(oneOfList); } for (SltAgreementInfo bean : leaseList) { - if (bean.getLeasePrice() == null) { + if (StringUtils.isEmpty(bean.getLeasePrice())) { bean.setLeasePrice("0"); } - if (bean.getNum() == null) { + if (StringUtils.isEmpty(bean.getNum())) { bean.setNum("0"); } - if (bean.getLeaseDays() == null) { + if (StringUtils.isEmpty(bean.getLeaseDays())) { bean.setLeaseDays("0"); } - if (bean.getTrimDay() == null) { + if (Objects.isNull(bean.getTrimDay())) { bean.setTrimDay(0); } BigDecimal leasePrice = new BigDecimal(bean.getLeasePrice()); @@ -223,13 +229,15 @@ public class SltAgreementInfoServiceImpl implements SltAgreementInfoService { // 应结算金额 BigDecimal costs = leasePrice.multiply(num).multiply(leaseDays); bean.setCosts(String.valueOf(costs)); + //实际结算天数 bean.setRealDays(realDays); + // 实际结算金额 bean.setRealCosts(String.valueOf(realCosts)); } return leaseList; } - private List getRelations(List leaseListOne, List leaseListThree, List repairList, List scrapList, List loseList, List list) { + private List getRelations(List leaseListOne, List leaseListThree, List repairList, List scrapList, List preScrapList, List loseList, List list) { List relations = new ArrayList<>(); for (AgreementInfo info : list) { SltAgreementRelation relation = new SltAgreementRelation(); @@ -237,6 +245,7 @@ public class SltAgreementInfoServiceImpl implements SltAgreementInfoService { BigDecimal leaseCostOne = BigDecimal.ZERO; BigDecimal leaseCostThree = BigDecimal.ZERO; BigDecimal scrapCost = BigDecimal.ZERO; + BigDecimal preScrapCost = BigDecimal.ZERO; BigDecimal repairCost = BigDecimal.ZERO; for (SltAgreementInfo lease : leaseListOne) { if (lease.getAgreementId().equals(info.getAgreementId().toString())) { @@ -260,7 +269,8 @@ public class SltAgreementInfoServiceImpl implements SltAgreementInfoService { } for (SltAgreementInfo repair : repairList) { if (repair.getAgreementId().equals(info.getAgreementId().toString())) { - BigDecimal allCost = new BigDecimal(repair.getAllCosts()); + // 暂时先计算配件总价,后期需要加上委外维修费用 + BigDecimal allCost = new BigDecimal(repair.getPartAllCosts()); repairCost = repairCost.add(allCost); } } @@ -270,6 +280,12 @@ public class SltAgreementInfoServiceImpl implements SltAgreementInfoService { scrapCost = scrapCost.add(cost); } } + for (SltAgreementInfo scrap : preScrapList) { + if (scrap.getAgreementId().equals(info.getAgreementId().toString())) { + BigDecimal cost = new BigDecimal(scrap.getCosts()); + preScrapCost = preScrapCost.add(cost); + } + } for (SltAgreementInfo lose : loseList) { if (lose.getAgreementId().equals(info.getAgreementId().toString())) { //TODO 上面已经set过值,这里为什么还要set值 @@ -299,6 +315,7 @@ public class SltAgreementInfoServiceImpl implements SltAgreementInfoService { relation.setLeaseCostThree(leaseCostThree.toString()); relation.setRepairCost(repairCost.toString()); relation.setScrapCost(scrapCost.toString()); + relation.setPreScrapCost(preScrapCost.toString()); relation.setLoseCost(loseCost.toString()); relations.add(relation); } @@ -308,8 +325,16 @@ public class SltAgreementInfoServiceImpl implements SltAgreementInfoService { @Override @Transactional public AjaxResult submitFee(SltAgreementApply apply) { + SltAgreementRelation relation = apply.getRelation(); + if (StringUtils.isNotBlank(apply.getRepairIds())) { + for (String id : apply.getRepairIds().split(",")) { + sltAgreementInfoMapper.updateRecodeIsSlt(id); + } + } sltAgreementInfoMapper.updateInfoStatus(apply.getAgreementId()); - int i = sltAgreementInfoMapper.updateBmAgreementInfo(apply.getAgreementId()); + sltAgreementInfoMapper.updateBmAgreementInfo(apply.getAgreementId()); + relation.setAgreementId(apply.getAgreementId()); + int i = sltAgreementInfoMapper.insRelation(relation); if (i > 0) { return AjaxResult.success("结算成功"); } else { @@ -333,6 +358,7 @@ public class SltAgreementInfoServiceImpl implements SltAgreementInfoService { } + @Override public List getLoseList(List list) { List loseList = new ArrayList<>(); for (AgreementInfo bean : list) { @@ -340,10 +366,10 @@ public class SltAgreementInfoServiceImpl implements SltAgreementInfoService { loseList.addAll(oneOfList); } for (SltAgreementInfo bean : loseList) { - if (bean.getBuyPrice() == null) { + if (StringUtils.isEmpty(bean.getBuyPrice())) { bean.setBuyPrice("0"); } - if (bean.getNum() == null) { + if (StringUtils.isEmpty(bean.getNum())) { bean.setNum("0"); } BigDecimal buyPrice = new BigDecimal(bean.getBuyPrice()); @@ -361,6 +387,7 @@ public class SltAgreementInfoServiceImpl implements SltAgreementInfoService { return loseList; } + @Override public List getScrapList(List list) { List scrapList = new ArrayList<>(); String taskType = "57"; @@ -375,10 +402,10 @@ public class SltAgreementInfoServiceImpl implements SltAgreementInfoService { if (scrapList != null && scrapList.size() > 0) { for (SltAgreementInfo bean : scrapList) { - if (bean.getBuyPrice() == null) { + if (StringUtils.isEmpty(bean.getBuyPrice())) { bean.setBuyPrice("0"); } - if (bean.getNum() == null) { + if (StringUtils.isEmpty(bean.getNum())) { bean.setNum("0"); } BigDecimal buyPrice = new BigDecimal(bean.getBuyPrice()); @@ -410,12 +437,12 @@ public class SltAgreementInfoServiceImpl implements SltAgreementInfoService { Integer num = 0; //租赁费用列表 for (AgreementInfo agreementInfo : list) { - // 如果不选择具体日期或者选择了最新月份则需要查数据 - if (agreementInfo.getStartTime() == null || DateTimeHelper.getNowMonth().equals(DateTimeHelper.getNowMonth(DateTimeHelper.parse(agreementInfo.getEndTime(), "yyyy-MM")))) { + // 如果选择了最新月份则需要查数据 + if (StringUtils.isNotBlank(agreementInfo.getStartTime()) && StringUtils.isNotBlank(agreementInfo.getEndTime()) && DateTimeHelper.getNowMonth().equals(DateTimeHelper.getNowMonth(DateTimeHelper.parse(agreementInfo.getEndTime(), "yyyy-MM")))) { List listMonth = getLeaseListMonth(agreementInfo, num); leaseListMonth.addAll(listMonth); } else { - // 查定时任务记录的数据 + // 如果不传日期或传以往日期 则查定时任务记录的数据 List listMonth = getLeaseJobListMonth(agreementInfo); leaseListMonth.addAll(listMonth); } @@ -424,6 +451,10 @@ public class SltAgreementInfoServiceImpl implements SltAgreementInfoService { } private List getLeaseJobListMonth(AgreementInfo agreementInfo) { + if (StringUtils.isBlank(agreementInfo.getEndTime())) { + String lastMonthYearMonth = DateTimeHelper.getLastMonthYearMonth(); + agreementInfo.setEndTime(lastMonthYearMonth); + } List monthCosts = calMonthlyMapper.getMonthCosts(agreementInfo); int num = 0; for (SltAgreementInfo monthCost : monthCosts) { @@ -442,22 +473,22 @@ public class SltAgreementInfoServiceImpl implements SltAgreementInfoService { private List getLeaseListMonth(AgreementInfo bean, Integer num) { List leaseList = new ArrayList<>(); // 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 { +// 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(); @@ -471,7 +502,7 @@ public class SltAgreementInfoServiceImpl implements SltAgreementInfoService { sltAgreementInfo.setNode(leaseListOneMonth); } leaseList.addAll(oneOfList); - } + }*/ // } return leaseList; } @@ -485,16 +516,16 @@ public class SltAgreementInfoServiceImpl implements SltAgreementInfoService { List leaseList = sltAgreementInfoMapper.getLeaseListOneMonth(list, idList); BigDecimal leaseCostOne = BigDecimal.ZERO; for (SltAgreementInfo bean : leaseList) { - if (bean.getLeasePrice() == null) { + if (StringUtils.isEmpty(bean.getLeasePrice())) { bean.setLeasePrice("0"); } - if (bean.getNum() == null) { + if (StringUtils.isEmpty(bean.getNum())) { bean.setNum("0"); } - if (bean.getLeaseDays() == null) { + if (StringUtils.isEmpty(bean.getLeaseDays())) { bean.setLeaseDays("0"); } - if (bean.getTrimDay() == null) { + if (Objects.isNull(bean.getTrimDay())) { bean.setTrimDay(0); } BigDecimal leasePrice = new BigDecimal(bean.getLeasePrice()); @@ -516,6 +547,7 @@ public class SltAgreementInfoServiceImpl implements SltAgreementInfoService { return leaseList; } + @Override public List getRepairList(List list) { List repairList = new ArrayList<>(); String taskType = "41"; @@ -530,6 +562,7 @@ public class SltAgreementInfoServiceImpl implements SltAgreementInfoService { return repairList; } + @Override public List getLeaseListOne(List list) { List leaseList = new ArrayList<>(); for (AgreementInfo bean : list) { @@ -537,16 +570,16 @@ public class SltAgreementInfoServiceImpl implements SltAgreementInfoService { leaseList.addAll(oneOfList); } for (SltAgreementInfo bean : leaseList) { - if (bean.getLeasePrice() == null) { + if (StringUtils.isEmpty(bean.getLeasePrice())) { bean.setLeasePrice("0"); } - if (bean.getNum() == null) { + if (StringUtils.isEmpty(bean.getNum())) { bean.setNum("0"); } - if (bean.getLeaseDays() == null) { + if (StringUtils.isEmpty(bean.getLeaseDays())) { bean.setLeaseDays("0"); } - if (bean.getTrimDay() == null) { + if (Objects.isNull(bean.getTrimDay())) { bean.setTrimDay(0); } BigDecimal leasePrice = new BigDecimal(bean.getLeasePrice()); @@ -559,7 +592,9 @@ public class SltAgreementInfoServiceImpl implements SltAgreementInfoService { // 应结算金额 BigDecimal costs = leasePrice.multiply(num).multiply(leaseDays); bean.setCosts(String.valueOf(costs)); + //实际结算天数 bean.setRealDays(realDays); + // 实际结算金额 bean.setRealCosts(String.valueOf(realCosts)); } return leaseList;