diff --git a/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/controller/admin/factoryinfo/vo/FactoryProfitVO.java b/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/controller/admin/factoryinfo/vo/FactoryProfitVO.java index 8aaf611c..3d9e33c3 100644 --- a/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/controller/admin/factoryinfo/vo/FactoryProfitVO.java +++ b/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/controller/admin/factoryinfo/vo/FactoryProfitVO.java @@ -42,14 +42,23 @@ public class FactoryProfitVO { @Schema(description = "搬运扣款") private BigDecimal porterageDeduction; + @Schema(description = "叉车扣款明细") + private Deduction forkliftDeductionItem; + + @Schema(description = "打包扣款明细") + private Deduction packageDeductionItem; + + @Schema(description = "搬运扣款明细") + private Deduction porterageDeductionItem; + @Schema(description = "水电扣款") private BigDecimal hydropower; - @Schema(description = "工伤保险") - private BigDecimal employment; - - @Schema(description = "其他(理赔、扣点)") - private BigDecimal other; +// @Schema(description = "工伤保险") +// private BigDecimal employment; +// +// @Schema(description = "其他(理赔、扣点)") +// private BigDecimal other; @Schema(description = "叉车工资") private BigDecimal forkliftSalary; @@ -104,4 +113,20 @@ public class FactoryProfitVO { @Schema(description = "搬运毛利") private BigDecimal porterageGrossProfit; + + @Data + public static class Deduction { + + @Schema(description = "行政罚款") + private BigDecimal administrativePenalty; + + @Schema(description = "破损罚款") + private BigDecimal damagePenalty; + + @Schema(description = "少件扣款") + private BigDecimal missPenalty; + + @Schema(description = "其他扣款") + private BigDecimal otherPenalty; + } } diff --git a/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/framework/rpc/config/RpcConfiguration.java b/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/framework/rpc/config/RpcConfiguration.java index eeaec6cd..60b3b610 100644 --- a/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/framework/rpc/config/RpcConfiguration.java +++ b/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/framework/rpc/config/RpcConfiguration.java @@ -1,11 +1,11 @@ package cn.iocoder.yudao.module.smartfactory.framework.rpc.config; -import cn.iocoder.yudao.framework.common.pojo.BpmOALeaveDTO; import cn.iocoder.yudao.module.bpm.api.oa.BpmOALoanApi; import cn.iocoder.yudao.module.infra.api.config.ConfigApi; import cn.iocoder.yudao.module.infra.api.file.FileApi; import cn.iocoder.yudao.module.system.api.assets.AssetsTypeApi; import cn.iocoder.yudao.module.system.api.auth.AdminOauthUserOtherInfoApi; +import cn.iocoder.yudao.module.system.api.customersettlement.SettlementApi; import cn.iocoder.yudao.module.system.api.dept.DeptApi; import cn.iocoder.yudao.module.system.api.dept.PostApi; import cn.iocoder.yudao.module.system.api.dict.DictDataApi; @@ -21,7 +21,8 @@ import org.springframework.context.annotation.Configuration; @Configuration(proxyBeanMethods = false) @EnableFeignClients(clients = {FileApi.class, RoleApi.class, DeptApi.class, PostApi.class, AdminUserApi.class, SmsSendApi.class, DictDataApi.class, NotifyMessageSendApi.class, - SubscribeMessageSendApi.class, ConfigApi.class, PermissionApi.class, AssetsTypeApi.class, LoanApi.class, BpmOALoanApi.class, AdminOauthUserOtherInfoApi.class + SubscribeMessageSendApi.class, ConfigApi.class, PermissionApi.class, AssetsTypeApi.class, LoanApi.class, BpmOALoanApi.class, AdminOauthUserOtherInfoApi.class, + SettlementApi.class }) public class RpcConfiguration { } diff --git a/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/service/factoryinfo/FactoryInfoServiceImpl.java b/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/service/factoryinfo/FactoryInfoServiceImpl.java index 47639c44..f45d0964 100644 --- a/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/service/factoryinfo/FactoryInfoServiceImpl.java +++ b/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/service/factoryinfo/FactoryInfoServiceImpl.java @@ -9,14 +9,13 @@ import cn.iocoder.yudao.framework.common.util.object.BeanUtils; import cn.iocoder.yudao.framework.ip.core.Area; import cn.iocoder.yudao.framework.ip.core.utils.AreaUtils; import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; -import cn.iocoder.yudao.module.smartfactory.controller.admin.factoryinfo.vo.FactoryInfoPageReqVO; -import cn.iocoder.yudao.module.smartfactory.controller.admin.factoryinfo.vo.FactoryInfoSaveReqVO; -import cn.iocoder.yudao.module.smartfactory.controller.admin.factoryinfo.vo.FactoryProfitVO; -import cn.iocoder.yudao.module.smartfactory.controller.admin.factoryinfo.vo.FactoryUpdateStatusReqVO; +import cn.iocoder.yudao.module.smartfactory.controller.admin.factoryinfo.vo.*; import cn.iocoder.yudao.module.smartfactory.controller.admin.screendata.factory.vo.FactoryRollDataRespVO; import cn.iocoder.yudao.module.smartfactory.controller.admin.screendata.factory.vo.ProvincesDataRespVO; import cn.iocoder.yudao.module.smartfactory.dal.dataobject.factoryinfo.FactoryInfoDO; import cn.iocoder.yudao.module.smartfactory.dal.mysql.factoryinfo.FactoryInfoMapper; +import cn.iocoder.yudao.module.system.api.customersettlement.SettlementApi; +import cn.iocoder.yudao.module.system.api.customersettlement.dto.SettlementItemDTO; import cn.iocoder.yudao.module.system.api.dept.DeptApi; import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; import cn.iocoder.yudao.module.system.api.permission.PermissionApi; @@ -28,11 +27,12 @@ import org.springframework.stereotype.Service; import org.springframework.validation.annotation.Validated; import javax.annotation.Resource; +import java.math.BigDecimal; import java.util.*; import java.util.stream.Collectors; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; -import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList; +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; import static cn.iocoder.yudao.module.smartfactory.enums.ErrorCodeConstants.FACTORY_INFO_NOT_EXISTS; import static cn.iocoder.yudao.module.smartfactory.enums.ErrorCodeConstants.FACTOYRY_EXISTS_STAFF; @@ -58,6 +58,9 @@ public class FactoryInfoServiceImpl implements FactoryInfoService { @Resource private PermissionApi permissionApi; + @Resource + private SettlementApi settlementApi; + @Override public Long createFactoryInfo(FactoryInfoSaveReqVO createReqVO) { // 插入 @@ -286,6 +289,11 @@ public class FactoryInfoServiceImpl implements FactoryInfoService { public List getProfit(Long factoryId, String month) { List result = factoryInfoMapper.selectProfit(factoryId, month); + + // 获取结算扣款明细 + List itemList = settlementApi.getDeductionItems(factoryId, month).getCheckedData(); + Map> itemMap = convertMultiMap(itemList, SettlementItemDTO::getFactoryId); + if (CollUtil.isNotEmpty(result)) { // 设置叉车毛利、打包毛利、搬运毛利 = 收入 - 扣款 - 人员工资 - 支出 result.forEach(vo -> { @@ -304,12 +312,88 @@ public class FactoryInfoServiceImpl implements FactoryInfoService { .subtract(vo.getPorterageDeduction()) .subtract(vo.getPorterageSalary()) .subtract(vo.getTransportationExpenses())); + + // 设置扣款明细 + List item = itemMap.get(vo.getFactoryId()); + if (CollUtil.isNotEmpty(item)) { + // 获取打包扣款明细 + List packageDeduction = item.stream() + .filter(data -> data.getBusinessType() == 1) + .flatMap( data -> data.getDeductionItems().stream()) + .collect(Collectors.toList()); + + // 获取叉车扣款明细 + List forkliftDeduction = item.stream() + .filter(data -> data.getBusinessType() == 2) + .flatMap( data -> data.getDeductionItems().stream()) + .collect(Collectors.toList()); + + // 获取搬运扣款明细 + List porterageDeduction = item.stream() + .filter(data -> data.getBusinessType() == 3) + .flatMap( data -> data.getDeductionItems().stream()) + .collect(Collectors.toList()); + + // 设置打包扣款 + vo.setPackageDeductionItem(getDeduction(packageDeduction)); + // 设置叉车扣款 + vo.setForkliftDeductionItem(getDeduction(forkliftDeduction)); + // 设置搬运扣款 + vo.setPorterageDeductionItem(getDeduction(porterageDeduction)); + }else { + // 设置打包扣款 + vo.setPackageDeductionItem(getDeduction(null)); + // 设置叉车扣款 + vo.setForkliftDeductionItem(getDeduction(null)); + // 设置搬运扣款 + vo.setPorterageDeductionItem(getDeduction(null)); + } }); } return result; } + private FactoryProfitVO.Deduction getDeduction(List item) { + + FactoryProfitVO.Deduction deduction = new FactoryProfitVO.Deduction(); + if (CollUtil.isNotEmpty(item)) { + BigDecimal administrativePenalty = item.stream() + .filter(data -> "xzfk".equals(data.getKey())) + .map(SettlementItemDTO.Deduction::getValue) + .reduce(BigDecimal.ZERO, BigDecimal::add); + + BigDecimal damagePenalty = item.stream() + .filter(data -> "psfk".equals(data.getKey())) + .map(SettlementItemDTO.Deduction::getValue) + .reduce(BigDecimal.ZERO, BigDecimal::add); + + BigDecimal missPenalty = item.stream() + .filter(data -> "sjkk".equals(data.getKey())) + .map(SettlementItemDTO.Deduction::getValue) + .reduce(BigDecimal.ZERO, BigDecimal::add); + + BigDecimal other = item.stream() + .filter(data -> !"xzfk".equals(data.getKey()) && !"psfk".equals(data.getKey()) && !"sjkk".equals(data.getKey())) + .map(SettlementItemDTO.Deduction::getValue) + .reduce(BigDecimal.ZERO, BigDecimal::add); + + // 设置扣款项,默认为 0 + deduction.setAdministrativePenalty(administrativePenalty); + deduction.setDamagePenalty(damagePenalty); + deduction.setMissPenalty(missPenalty); + deduction.setOtherPenalty(other); + } else { + // 如果 item 为空,则所有值设为 0 + deduction.setAdministrativePenalty(BigDecimal.ZERO); + deduction.setDamagePenalty(BigDecimal.ZERO); + deduction.setMissPenalty(BigDecimal.ZERO); + deduction.setOtherPenalty(BigDecimal.ZERO); + } + + return deduction; + } + @Override public List getCompanyFactoryList() { diff --git a/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/resources/mapper/factoryinfo/FactoryInfoMapper.xml b/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/resources/mapper/factoryinfo/FactoryInfoMapper.xml index 3d898a4f..9ecf2c44 100644 --- a/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/resources/mapper/factoryinfo/FactoryInfoMapper.xml +++ b/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/resources/mapper/factoryinfo/FactoryInfoMapper.xml @@ -33,16 +33,16 @@