From 9f5b4bc8ec3f2d90a23ab660fbbbf3d2ac68ba58 Mon Sep 17 00:00:00 2001 From: mashuai Date: Tue, 10 Feb 2026 17:00:19 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E7=AB=8B=E4=BD=93=E4=BB=93=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common}/utils/AutomaticHttpHelper.java | 18 +++++++-- .../impl/LeaseApplyInfoServiceImpl.java | 17 ++++++--- .../service/impl/LeaseTaskServiceImpl.java | 10 +++-- .../impl/PurchaseStorageServiceImpl.java | 36 +++++++----------- .../impl/RepairInputDetailsServiceImpl.java | 38 +++++++------------ 5 files changed, 58 insertions(+), 61 deletions(-) rename {bonus-common-biz/src/main/java/com/bonus/common/biz => bonus-modules/bonus-material/src/main/java/com/bonus/material/common}/utils/AutomaticHttpHelper.java (94%) diff --git a/bonus-common-biz/src/main/java/com/bonus/common/biz/utils/AutomaticHttpHelper.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/common/utils/AutomaticHttpHelper.java similarity index 94% rename from bonus-common-biz/src/main/java/com/bonus/common/biz/utils/AutomaticHttpHelper.java rename to bonus-modules/bonus-material/src/main/java/com/bonus/material/common/utils/AutomaticHttpHelper.java index d5533517..9540059b 100644 --- a/bonus-common-biz/src/main/java/com/bonus/common/biz/utils/AutomaticHttpHelper.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/common/utils/AutomaticHttpHelper.java @@ -1,7 +1,9 @@ -package com.bonus.common.biz.utils; +package com.bonus.material.common.utils; import com.alibaba.fastjson2.JSONObject; import com.bonus.common.biz.constant.MaterialConstants; +import com.bonus.common.biz.utils.StringHelper; +import com.bonus.material.ma.service.ITypeService; import lombok.extern.slf4j.Slf4j; import org.apache.http.HttpEntity; import org.apache.http.client.methods.CloseableHttpResponse; @@ -11,7 +13,9 @@ import org.apache.http.entity.mime.MultipartEntityBuilder; import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; import org.apache.http.util.EntityUtils; +import org.springframework.stereotype.Component; +import javax.annotation.Resource; import java.io.*; import java.net.HttpURLConnection; import java.net.MalformedURLException; @@ -22,8 +26,12 @@ import java.nio.charset.StandardCharsets; * @author bonus */ @Slf4j +@Component public class AutomaticHttpHelper { + @Resource + private ITypeService typeService; + public static final String KEY = "$jqgcYouote@c103"; public static String sendHttpPost(String url, String JSONBody) throws Exception { @@ -40,7 +48,7 @@ public class AutomaticHttpHelper { return responseContent; } - public static String sendHttpPostPushCost(String url, String JSONBody) throws Exception { + public String sendHttpPostPushCost(String url, String JSONBody) throws Exception { // 获取token String token = getToken(); if (StringHelper.isEmpty(token)) { @@ -187,11 +195,13 @@ public class AutomaticHttpHelper { * * @return */ - private static String getToken() { + private String getToken() { // 立体库本地测试token路径 //String tokenUrl = MaterialConstants.TEST_TOKEN_URL; // 立体库生产环境token路径 - String tokenUrl = MaterialConstants.PROD_TOKEN_URL; + //String tokenUrl = MaterialConstants.PROD_TOKEN_URL; + // 改为从数据库根据key直接获取,方便后期维护 + String tokenUrl = typeService.getAsToken(); log.info("立体仓获取token路径:{}", tokenUrl); try { String userName = "ZNXT"; diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/impl/LeaseApplyInfoServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/impl/LeaseApplyInfoServiceImpl.java index d5d52139..b1e4fb0f 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/impl/LeaseApplyInfoServiceImpl.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/impl/LeaseApplyInfoServiceImpl.java @@ -4,20 +4,18 @@ import java.io.OutputStream; import java.math.BigDecimal; import java.net.URLEncoder; import java.text.SimpleDateFormat; -import java.time.LocalDate; import java.util.*; import java.util.stream.Collectors; import com.alibaba.fastjson.JSONObject; import com.bonus.common.biz.constant.GlobalConstants; -import com.bonus.common.biz.domain.purchase.AutomaticInPutDto; import com.bonus.common.biz.domain.purchase.AutomaticOutPutDto; -import com.bonus.common.biz.domain.repair.RepairInputDetails; import com.bonus.common.biz.enums.*; -import com.bonus.common.biz.utils.AutomaticHttpHelper; +import com.bonus.material.common.utils.AutomaticHttpHelper; import com.bonus.material.basic.domain.BmAgreementInfo; import com.bonus.material.basic.mapper.BmAgreementInfoMapper; import com.bonus.material.common.mapper.SelectMapper; +import com.bonus.material.ma.service.ITypeService; import lombok.extern.slf4j.Slf4j; import cn.hutool.core.collection.CollectionUtil; @@ -97,6 +95,12 @@ public class LeaseApplyInfoServiceImpl implements ILeaseApplyInfoService { @Resource private BmAgreementInfoMapper bmAgreementInfoMapper; + @Resource + private AutomaticHttpHelper automaticHttpHelper; + + @Resource + private ITypeService typeService; + /** * 查询领料任务 * @@ -1655,9 +1659,10 @@ public class LeaseApplyInfoServiceImpl implements ILeaseApplyInfoService { // 立体库本地建立出库单接口路径 //String url = MaterialConstants.TEST_CREATE_OUT_URL; // 立体库生产建立出库单接口路径 - String url = MaterialConstants.PROD_CREATE_OUT_URL; + //String url = MaterialConstants.PROD_CREATE_OUT_URL; + String url = typeService.getAsOutUrl(); log.info("立体仓建立出库单路径:{}", url); - String data = AutomaticHttpHelper.sendHttpPostPushCost(url, body); + String data = automaticHttpHelper.sendHttpPostPushCost(url, body); log.info("传输立体仓返回data:{}", data); if (StringUtils.isEmpty(data)) { System.err.println("立体仓出库单创建失败"); diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/impl/LeaseTaskServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/impl/LeaseTaskServiceImpl.java index ad97782a..4fe3d2b8 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/impl/LeaseTaskServiceImpl.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/lease/service/impl/LeaseTaskServiceImpl.java @@ -11,7 +11,7 @@ import com.bonus.common.biz.domain.purchase.AutomaticOutPutDto; import com.bonus.common.biz.enums.HttpCodeEnum; import com.bonus.common.biz.enums.LeaseTaskStatusEnum; import com.bonus.common.biz.enums.TmTaskTypeEnum; -import com.bonus.common.biz.utils.AutomaticHttpHelper; +import com.bonus.material.common.utils.AutomaticHttpHelper; import com.bonus.common.core.exception.ServiceException; import com.bonus.common.core.utils.DateUtils; import com.bonus.common.core.utils.StringUtils; @@ -118,6 +118,9 @@ public class LeaseTaskServiceImpl implements ILeaseTaskService { @Resource private ITypeService typeService; + @Resource + private AutomaticHttpHelper automaticHttpHelper; + /** * 新增领用任务 @@ -1221,8 +1224,9 @@ public class LeaseTaskServiceImpl implements ILeaseTaskService { // 立体库本地建立出库单接口路径 //String url = MaterialConstants.TEST_CREATE_OUT_URL; // 立体库生产建立出库单接口路径 - String url = MaterialConstants.PROD_CREATE_OUT_URL; - String data = AutomaticHttpHelper.sendHttpPostPushCost(url, body); + //String url = MaterialConstants.PROD_CREATE_OUT_URL; + String url = typeService.getAsOutUrl(); + String data = automaticHttpHelper.sendHttpPostPushCost(url, body); if (StringUtils.isEmpty(data)) { throw new RuntimeException("立体仓出库单创建失败"); } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/purchase/service/impl/PurchaseStorageServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/purchase/service/impl/PurchaseStorageServiceImpl.java index 366d9910..0aa7b74c 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/purchase/service/impl/PurchaseStorageServiceImpl.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/purchase/service/impl/PurchaseStorageServiceImpl.java @@ -7,7 +7,7 @@ import com.bonus.common.biz.domain.purchase.AutomaticInPutDto; import com.bonus.common.biz.enums.HttpCodeEnum; import com.bonus.common.biz.enums.MaTypeManageTypeEnum; import com.bonus.common.biz.enums.PurchaseTaskStatusEnum; -import com.bonus.common.biz.utils.AutomaticHttpHelper; +import com.bonus.material.common.utils.AutomaticHttpHelper; import com.bonus.common.core.utils.StringUtils; import com.bonus.common.core.web.domain.AjaxResult; import com.bonus.material.lease.mapper.LeaseOutDetailsMapper; @@ -22,6 +22,7 @@ import com.bonus.material.purchase.service.IPurchaseStorageService; import com.bonus.material.purchase.domain.vo.PurchaseVo; import com.bonus.material.task.domain.TmTask; import com.bonus.material.task.mapper.TmTaskMapper; +import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import javax.annotation.Resource; @@ -36,6 +37,7 @@ import java.util.stream.Collectors; * @create 2024/10/21 13:53 */ @Service +@Slf4j public class PurchaseStorageServiceImpl implements IPurchaseStorageService { @Resource @@ -56,6 +58,9 @@ public class PurchaseStorageServiceImpl implements IPurchaseStorageService { @Resource private ITypeService typeService; + @Resource + private AutomaticHttpHelper automaticHttpHelper; + private final ReentrantLock lock = new ReentrantLock(true); /** @@ -277,33 +282,18 @@ public class PurchaseStorageServiceImpl implements IPurchaseStorageService { // 立体库本地建立入库单接口路径 //String url = MaterialConstants.TEST_CREATE_IN_URL; // 立体库生产建立入库单接口路径 - String url = MaterialConstants.PROD_CREATE_IN_URL; - String data = AutomaticHttpHelper.sendHttpPostPushCost(url, body); + //String url = MaterialConstants.PROD_CREATE_IN_URL; + String url = typeService.getAsInUrl(); + log.info("立体库获取建立新购入库单路径:{}", url); + String data = automaticHttpHelper.sendHttpPostPushCost(url, body); + log.info("立体库建立新购入库单返回data:{}", data); if (StringUtils.isEmpty(data)) { return AjaxResult.error(HttpCodeEnum.FAIL.getCode(), "立体仓入库单创建失败"); } JSONObject object = JSONObject.parseObject(data); String code = object.getString("code"); - if ("0".equals(code)) { - // 修改状态为待上架 - if (CollectionUtils.isEmpty(purchaseDto.getInPutList())) { - // 数量设备 - purchaseStorageMapper.updateNumById(PurchaseTaskStatusEnum.TO_UPLOAD.getStatus(), purchaseDto.getPurchaseId(), purchaseDto.getInputNum()); - } else { - // 修改上架数量 - purchaseStorageMapper.updateUpNum(Long.valueOf(purchaseDto.getPurchaseId()), BigDecimal.valueOf(purchaseDto.getInPutList().size())); - // 编码设备 - for (PurchaseDto dto : purchaseDto.getInPutList()) { - dto.setTypeId(purchaseDto.getTypeId()); - // 待上架 - dto.setMaStatus("19"); - purchaseStorageMapper.updateMaStatus(dto); - } - // 修改详情任务状态 - purchaseStorageMapper.updatePurchaseStatus(PurchaseTaskStatusEnum.TO_UPLOAD.getStatus(), Integer.parseInt(purchaseDto.getPurchaseId())); - } - return AjaxResult.success("立体仓入库单创建成功"); - } else { + log.info("立体库建立新购入库单返回code:{}", code); + if (!"0".equals(code)) { return AjaxResult.error(HttpCodeEnum.FAIL.getCode(), "立体仓入库单创建失败"); } } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/repair/service/impl/RepairInputDetailsServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/repair/service/impl/RepairInputDetailsServiceImpl.java index 9135ed41..4fc3c3f7 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/repair/service/impl/RepairInputDetailsServiceImpl.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/repair/service/impl/RepairInputDetailsServiceImpl.java @@ -15,7 +15,7 @@ import com.bonus.common.biz.domain.lease.LeaseOutDetails; import com.bonus.common.biz.domain.purchase.AutomaticInPutDto; import com.bonus.common.biz.domain.repair.RepairInputExportDetails; import com.bonus.common.biz.enums.*; -import com.bonus.common.biz.utils.AutomaticHttpHelper; +import com.bonus.material.common.utils.AutomaticHttpHelper; import com.bonus.common.core.exception.ServiceException; import com.bonus.common.core.utils.DateUtils; import com.bonus.common.core.utils.StringUtils; @@ -36,7 +36,7 @@ import com.bonus.material.task.domain.TmTask; import com.bonus.material.task.domain.TmTaskAgreement; import com.bonus.material.task.mapper.TmTaskAgreementMapper; import com.bonus.material.task.mapper.TmTaskMapper; -import org.springframework.dao.DataAccessException; +import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import com.bonus.material.repair.mapper.RepairInputDetailsMapper; import com.bonus.common.biz.domain.repair.RepairInputDetails; @@ -52,6 +52,7 @@ import javax.annotation.Resource; * @date 2024-10-16 */ @Service +@Slf4j public class RepairInputDetailsServiceImpl implements IRepairInputDetailsService { @Resource private RepairInputDetailsMapper repairInputDetailsMapper; @@ -75,6 +76,9 @@ public class RepairInputDetailsServiceImpl implements IRepairInputDetailsService @Resource private ITypeService typeService; + + @Resource + private AutomaticHttpHelper automaticHttpHelper; /** * 查询修试后入库 * @@ -674,34 +678,18 @@ public class RepairInputDetailsServiceImpl implements IRepairInputDetailsService // 立体库本地建立入库单接口路径 //String url = MaterialConstants.TEST_CREATE_IN_URL; // 立体库生产建立入库单接口路径 - String url = MaterialConstants.PROD_CREATE_IN_URL; - String data = AutomaticHttpHelper.sendHttpPostPushCost(url, body); + //String url = MaterialConstants.PROD_CREATE_IN_URL; + String url = typeService.getAsInUrl(); + log.info("立体库获取建立修试入库单路径:{}", url); + String data = automaticHttpHelper.sendHttpPostPushCost(url, body); + log.info("立体库建立修试入库单返回data:{}", data); if (StringUtils.isEmpty(data)) { return AjaxResult.error(HttpCodeEnum.FAIL.getCode(), "立体仓入库单创建失败"); } JSONObject object = JSONObject.parseObject(data); String code = object.getString("code"); - if ("0".equals(code)) { - if (CollectionUtils.isNotEmpty(repairInputDetails.getMaCodeList())) { - for (RepairInputDetails inputDetails : repairInputDetails.getMaCodeList()) { - inputDetails.setStatus(RepairInputStatusEnum.TO_UPLOAD.getStatus().toString()); - inputDetails.setTaskId(repairInputDetails.getTaskId()); - inputDetails.setTypeId(repairInputDetails.getTypeId()); - inputDetails.setUpdateBy(SecurityUtils.getLoginUser().getUserid().toString()); - inputDetails.setUpdateTime(DateUtils.getNowDate()); - result += repairInputDetailsMapper.updateRepairStatus(inputDetails); - // 待上架 - inputDetails.setStatus(MaMachineStatusEnum.TO_UPLOAD.getStatus().toString()); - repairInputDetailsMapper.updateStatus(inputDetails); - } - } else { - repairInputDetails.setStatus(RepairInputStatusEnum.TO_UPLOAD.getStatus().toString()); - repairInputDetails.setUpdateBy(SecurityUtils.getLoginUser().getUserid().toString()); - repairInputDetails.setUpdateTime(DateUtils.getNowDate()); - result += repairInputDetailsMapper.updateRepairStatus(repairInputDetails); - } - return AjaxResult.success("立体仓入库单创建成功"); - } else { + log.info("立体库建立修试入库单返回code:{}", code); + if (!"0".equals(code)) { return AjaxResult.error(HttpCodeEnum.FAIL.getCode(), "立体仓入库单创建失败"); } } From beb111c82734d792bb86c7062c54e6bc37250313 Mon Sep 17 00:00:00 2001 From: jiask <1069621233@qq.com> Date: Tue, 10 Feb 2026 17:10:48 +0800 Subject: [PATCH 2/2] =?UTF-8?q?jsk=20=20=E8=A7=A3=E5=86=B3=E5=AE=9A?= =?UTF-8?q?=E6=97=B6=E5=BD=95=E5=85=A5=E7=BB=93=E7=AE=97=E7=BB=8F=E5=B8=B8?= =?UTF-8?q?=E9=87=8D=E5=A4=8D=E5=BD=95=E5=85=A5=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../push/mapper/IwsCostPushMapper.java | 6 +- .../service/impl/IwsCostPushServiceImpl.java | 70 ++++++++++++++-- .../material/push/task/IwsCostPushTask.java | 44 ++++++++++- .../settlement/domain/SltAgreementInfo.java | 2 + .../mapper/SltAgreementInfoMapper.java | 5 ++ .../material/push/IwsCostPushMapper.xml | 79 ++++++++++++++----- .../settlement/SltAgreementInfoMapper.xml | 50 ++++++++++++ 7 files changed, 225 insertions(+), 31 deletions(-) diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/push/mapper/IwsCostPushMapper.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/push/mapper/IwsCostPushMapper.java index cb78185c..986f0bea 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/push/mapper/IwsCostPushMapper.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/push/mapper/IwsCostPushMapper.java @@ -40,16 +40,20 @@ public interface IwsCostPushMapper { */ int insertCalcMonthRecord(IwsCostPushBean record); + List selectCalcMonthRecord(IwsCostPushBean record); + /** * 插入项目月费用info数据 -- 批量 */ int insertProjectMonthCosts(List list); + int updateProjectMonthCosts(IwsCostPushBean vo); + List selectHaveProjectMonthCosts(IwsCostPushBean vo); /** * 插入项目月费用details数据 -- 批量 */ int insertProjectMonthCostsDetails(@Param("list") List list); - + List selectHaveProjectMonthCostsDetails(PeriodCostResultVo vo); /** * 根据协议ID查询领用物资数据 * @param record 协议信息及条件 diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/push/service/impl/IwsCostPushServiceImpl.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/push/service/impl/IwsCostPushServiceImpl.java index 3822a8da..2a770568 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/push/service/impl/IwsCostPushServiceImpl.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/push/service/impl/IwsCostPushServiceImpl.java @@ -122,7 +122,12 @@ public class IwsCostPushServiceImpl implements IwsCostPushService { //cleanSameMonthOldRecords(record); // 插入新的当前月份,并生成记录id - iwsCostPushMapper.insertCalcMonthRecord(costDto); + List monthList=iwsCostPushMapper.selectCalcMonthRecord(costDto); + if(monthList==null||monthList.size()==0){ + iwsCostPushMapper.insertCalcMonthRecord(costDto); + }else{ + costDto.setTaskId(monthList.get(0).getTaskId()); + } // 查询协议信息列表 List agreementList = iwsCostPushMapper.findAgreement(costDto); @@ -296,9 +301,24 @@ public class IwsCostPushServiceImpl implements IwsCostPushService { .setConsumeMoney(vo.getConsumeCost()) ); } - + List uplist=new ArrayList<>(); + List addlist=new ArrayList<>(); + //将已录入的数据筛选出来 + for(IwsCostPushBean vo:resultArray){ + List haveList=iwsCostPushMapper.selectHaveProjectMonthCosts(vo); + if(haveList!=null&&haveList.size()>0){ + uplist.add(vo); + }else{ + addlist.add(vo); + } + } // 批量插入 -- 存入数据库costs列表 - int addProjectMonthCostsMapperResult = iwsCostPushMapper.insertProjectMonthCosts(resultArray); + int addProjectMonthCostsMapperResult = iwsCostPushMapper.insertProjectMonthCosts(addlist); + try{ + for(IwsCostPushBean vo:uplist){ + iwsCostPushMapper.updateProjectMonthCosts(vo); + } + }catch (Exception e){} // 批量插入 -- 存入数据库租赁费用明细(project_month_info表) if (CollectionUtils.isNotEmpty(unsettlementEquipmentLeaseCostsDetails)) { // (工器具)未结算租赁费用的存入 @@ -306,7 +326,16 @@ public class IwsCostPushServiceImpl implements IwsCostPushService { item.setTaskId(costDto.getTaskId()); item.setEquipmentType((byte) 1); }); - iwsCostPushMapper.insertProjectMonthCostsDetails(unsettlementEquipmentLeaseCostsDetails); + List addDetailList=new ArrayList<>(); + //将已录入的数据筛选出来 + for(PeriodCostResultVo vo:unsettlementEquipmentLeaseCostsDetails){ + List haveList=iwsCostPushMapper.selectHaveProjectMonthCostsDetails(vo); + if(haveList!=null&&haveList.size()>0){ + }else{ + addDetailList.add(vo); + } + } + iwsCostPushMapper.insertProjectMonthCostsDetails(addDetailList); } if (CollectionUtils.isNotEmpty(settlementEquipmentCostsDetails)) { // (工器具)已结算租赁费用的存入 @@ -314,7 +343,16 @@ public class IwsCostPushServiceImpl implements IwsCostPushService { item.setTaskId(costDto.getTaskId()); item.setEquipmentType((byte) 1); }); - iwsCostPushMapper.insertProjectMonthCostsDetails(settlementEquipmentCostsDetails); + List addDetailList=new ArrayList<>(); + //将已录入的数据筛选出来 + for(PeriodCostResultVo vo:settlementEquipmentCostsDetails){ + List haveList=iwsCostPushMapper.selectHaveProjectMonthCostsDetails(vo); + if(haveList!=null&&haveList.size()>0){ + }else{ + addDetailList.add(vo); + } + } + iwsCostPushMapper.insertProjectMonthCostsDetails(addDetailList); } if (CollectionUtils.isNotEmpty(unsettlementSafetyEquipmentLeaseCostsDetails)) { // (安全工器具)未结算租赁费用的存入 @@ -322,7 +360,16 @@ public class IwsCostPushServiceImpl implements IwsCostPushService { item.setTaskId(costDto.getTaskId()); item.setEquipmentType((byte) 2); }); - iwsCostPushMapper.insertProjectMonthCostsDetails(unsettlementSafetyEquipmentLeaseCostsDetails); + List addDetailList=new ArrayList<>(); + //将已录入的数据筛选出来 + for(PeriodCostResultVo vo:unsettlementSafetyEquipmentLeaseCostsDetails){ + List haveList=iwsCostPushMapper.selectHaveProjectMonthCostsDetails(vo); + if(haveList!=null&&haveList.size()>0){ + }else{ + addDetailList.add(vo); + } + } + iwsCostPushMapper.insertProjectMonthCostsDetails(addDetailList); } if (CollectionUtils.isNotEmpty(settlementSafetyEquipmentCostsDetails)) { // (安全工器具)已结算租赁费用的存入 @@ -330,7 +377,16 @@ public class IwsCostPushServiceImpl implements IwsCostPushService { item.setTaskId(costDto.getTaskId()); item.setEquipmentType((byte) 2); }); - iwsCostPushMapper.insertProjectMonthCostsDetails(settlementSafetyEquipmentCostsDetails); + List addDetailList=new ArrayList<>(); + //将已录入的数据筛选出来 + for(PeriodCostResultVo vo:settlementSafetyEquipmentCostsDetails){ + List haveList=iwsCostPushMapper.selectHaveProjectMonthCostsDetails(vo); + if(haveList!=null&&haveList.size()>0){ + }else{ + addDetailList.add(vo); + } + } + iwsCostPushMapper.insertProjectMonthCostsDetails(addDetailList); } return 0 < addProjectMonthCostsMapperResult ? AjaxResult.success("月结费用计算成功") : AjaxResult.error("月结费用计算失败"); diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/push/task/IwsCostPushTask.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/push/task/IwsCostPushTask.java index 23497206..dfe49877 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/push/task/IwsCostPushTask.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/push/task/IwsCostPushTask.java @@ -56,6 +56,7 @@ public class IwsCostPushTask { * 定时任务 -- 计算月结费用 -- 每月最后一天的23点30分执行 */ @Scheduled(cron = "0 30 23 L * ?") +// @Scheduled(fixedDelay = 1000*60*30) public void computeTheMonthCostTask() { System.out.println("-----------开始计算四类未结算费用定时器-----------"); iwsCostPushService.computeTheMonthCost(new IwsCostPushBean()); @@ -66,6 +67,7 @@ public class IwsCostPushTask { /** * 定时任务 -- 保存未结算报表记录(工器具) -- 每月最后一天的23点00分执行 */ +// @Scheduled(fixedDelay = 1000*60*30) @Scheduled(cron = "0 00 23 L * ?", zone = "Asia/Shanghai") public void saveUnSltHistoryReport() { System.out.println("-----------开始执行保存未结算记录定时器-----------"); @@ -170,7 +172,14 @@ public class IwsCostPushTask { } try { - validRecords.forEach(vo -> vo.setYearMonth(DateTime.now().toString("yyyyMM"))); + // 根据 协议ID、结算类型、年月 删除多余数据 + for(SltInfoVo vo:validRecords){ + vo.setYearMonth(DateTime.now().toString("yyyyMM")); + List oldList=sltAgreementInfoMapper.selectOldHistoryReport(vo); + if(oldList!=null&&oldList.size()>0){ + sltAgreementInfoMapper.deleteOldHistoryReport(vo); + } + } int rows = sltAgreementInfoMapper.addSltHistoryReport(validRecords); log.info("未结算报表定时器:保存未结算报表记录完成,受影响行数:{}", rows); @@ -186,6 +195,14 @@ public class IwsCostPushTask { detail.setYearMonth(DateTime.now().toString("yyyyMM")); detail.setSettlementType(1); }); + // 根据 协议ID、结算类型、年月、(1租赁 2维修 3丢失 4报废) 删除多余数据 + for(SltAgreementInfo vo:leaseDetails){ + vo.setCostType("1"); + List oldList=sltAgreementInfoMapper.selectOldHistoryReportDetail(vo); + if(oldList!=null&&oldList.size()>0){ + sltAgreementInfoMapper.deleteOldHistoryReportDetail(vo); + } + } sltAgreementInfoMapper.addSltHistoryReportLeaseDetail(leaseDetails); } @@ -200,6 +217,14 @@ public class IwsCostPushTask { detail.setYearMonth(DateTime.now().toString("yyyyMM")); detail.setSettlementType(1); }); + // 根据 协议ID、结算类型、年月、(1租赁 2维修 3丢失 4报废) 删除多余数据 + for(SltAgreementInfo vo:leaseDetails){ + vo.setCostType("2"); + List oldList=sltAgreementInfoMapper.selectOldHistoryReportDetail(vo); + if(oldList!=null&&oldList.size()>0){ + sltAgreementInfoMapper.deleteOldHistoryReportDetail(vo); + } + } sltAgreementInfoMapper.addSltHistoryReportRepairDetail(repairDetails); } @@ -214,6 +239,14 @@ public class IwsCostPushTask { detail.setYearMonth(DateTime.now().toString("yyyyMM")); detail.setSettlementType(1); }); + // 根据 协议ID、结算类型、年月、(1租赁 2维修 3丢失 4报废) 删除多余数据 + for(SltAgreementInfo vo:leaseDetails){ + vo.setCostType("3"); + List oldList=sltAgreementInfoMapper.selectOldHistoryReportDetail(vo); + if(oldList!=null&&oldList.size()>0){ + sltAgreementInfoMapper.deleteOldHistoryReportDetail(vo); + } + } sltAgreementInfoMapper.addSltHistoryReportLoseDetail(loseDetails); } @@ -228,6 +261,14 @@ public class IwsCostPushTask { detail.setYearMonth(DateTime.now().toString("yyyyMM")); detail.setSettlementType(1); }); + // 根据 协议ID、结算类型、年月、(1租赁 2维修 3丢失 4报废) 删除多余数据 + for(SltAgreementInfo vo:leaseDetails){ + vo.setCostType("4"); + List oldList=sltAgreementInfoMapper.selectOldHistoryReportDetail(vo); + if(oldList!=null&&oldList.size()>0){ + sltAgreementInfoMapper.deleteOldHistoryReportDetail(vo); + } + } sltAgreementInfoMapper.addSltHistoryReportScrapDetail(scrapDetails); } @@ -248,7 +289,6 @@ public class IwsCostPushTask { sltAgreementInfoService.clearCache(); log.info("缓存已清理"); } - System.out.println("-----------保存未结算记录定时器执行完毕-----------"); } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/domain/SltAgreementInfo.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/domain/SltAgreementInfo.java index aa6a404d..80eba344 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/domain/SltAgreementInfo.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/domain/SltAgreementInfo.java @@ -335,4 +335,6 @@ public class SltAgreementInfo extends BaseEntity { * 领料工程id */ private String leaseProId; + + private String costType; } diff --git a/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/mapper/SltAgreementInfoMapper.java b/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/mapper/SltAgreementInfoMapper.java index 334c2158..a4d1cbcb 100644 --- a/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/mapper/SltAgreementInfoMapper.java +++ b/bonus-modules/bonus-material/src/main/java/com/bonus/material/settlement/mapper/SltAgreementInfoMapper.java @@ -32,6 +32,11 @@ public interface SltAgreementInfoMapper { int addSltHistoryReportScrapDetail(List list); + List selectOldHistoryReport(SltInfoVo vo); + int deleteOldHistoryReport(SltInfoVo vo); + List selectOldHistoryReportDetail(SltAgreementInfo vo); + int deleteOldHistoryReportDetail(SltAgreementInfo vo); + List selectSltHistoryReportList(SltHistoryReport sltHistoryReport); List selectSltHistoryLeaseDetail(SltHistoryReportDetail sltHistoryReportDetail); diff --git a/bonus-modules/bonus-material/src/main/resources/mapper/material/push/IwsCostPushMapper.xml b/bonus-modules/bonus-material/src/main/resources/mapper/material/push/IwsCostPushMapper.xml index 835069bb..fd1d1b46 100644 --- a/bonus-modules/bonus-material/src/main/resources/mapper/material/push/IwsCostPushMapper.xml +++ b/bonus-modules/bonus-material/src/main/resources/mapper/material/push/IwsCostPushMapper.xml @@ -148,6 +148,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" VALUES (#{month}) + + + select + AGREEMENT_ID as agreementId, + LEASE_MONEY as leaseMoney, + CONSUME_MONEY as consumeMoney, + LOST_MONEY as lostMoney, + REPAIR_MONEY as repairMoney, + SCRAP_MONEY as scrapMoney, + TASK_ID as taskId, + TYPE as settlementType + from project_month_costs where + AGREEMENT_ID=#{agreementId} and TASK_ID=#{taskId} and TYPE=#{settlementType} + + + + insert into project_month_info(agreementId, typeId, leaseNum, leaseDate, returnDate, + leasePrice, leaseMoney, taskId, buy_price, money, jiju_type) + values + + ( + #{item.agreementId}, + #{item.typeId}, + #{item.num}, + #{item.calcStartTime}, + #{item.calcEndTime}, + #{item.leasePrice}, + #{item.leaseCost}, + #{item.taskId}, + #{item.buyPrice}, + #{item.consumeCost}, + #{item.equipmentType} + ) + + + + - - insert into project_month_info(agreementId, typeId, leaseNum, leaseDate, returnDate, - leasePrice, leaseMoney, taskId, buy_price, money, jiju_type) - values - - ( - #{item.agreementId}, - #{item.typeId}, - #{item.num}, - #{item.calcStartTime}, - #{item.calcEndTime}, - #{item.leasePrice}, - #{item.leaseCost}, - #{item.taskId}, - #{item.buyPrice}, - #{item.consumeCost}, - #{item.equipmentType} - ) - - - + select a.agreement_id as agreementid,a.settlement_type as settlementtype,a.year_month as yearmonth + from slt_history_report a + where 1=1 + + and a.agreement_id=#{agreementId} + + + and a.settlement_type=#{settlementType} + + + and a.year_month=#{yearMonth} + + + + + delete from slt_history_report where + agreement_id=#{agreementId} + and settlement_type=#{settlementType} + and year_month=#{yearMonth} + + + + + + delete from slt_history_report_detail where + agreement_id=#{agreementId} + and settlement_type=#{settlementType} + and year_month=#{yearMonth} + and cost_type=#{costType} + + insert into slt_agreement_status (slt_task,slt_auditor,slt_status)