feat(factory-info): 增加工厂扣款明细展示
- 在 FactoryProfitVO 中添加扣款明细相关字段 - 在 FactoryInfoServiceImpl 中实现扣款明细的获取和设置 - 更新 FactoryInfoMapper 和 XML 文件,移除不再使用的其他扣款字段 - 在 RpcConfiguration 中添加 SettlementApi 的 Feign客户端配置
This commit is contained in:
parent
9a50fa9697
commit
77d7620898
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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 {
|
||||
}
|
||||
|
@ -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<FactoryProfitVO> getProfit(Long factoryId, String month) {
|
||||
|
||||
List<FactoryProfitVO> result = factoryInfoMapper.selectProfit(factoryId, month);
|
||||
|
||||
// 获取结算扣款明细
|
||||
List<SettlementItemDTO> itemList = settlementApi.getDeductionItems(factoryId, month).getCheckedData();
|
||||
Map<Long, List<SettlementItemDTO>> 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<SettlementItemDTO> item = itemMap.get(vo.getFactoryId());
|
||||
if (CollUtil.isNotEmpty(item)) {
|
||||
// 获取打包扣款明细
|
||||
List<SettlementItemDTO.Deduction> packageDeduction = item.stream()
|
||||
.filter(data -> data.getBusinessType() == 1)
|
||||
.flatMap( data -> data.getDeductionItems().stream())
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 获取叉车扣款明细
|
||||
List<SettlementItemDTO.Deduction> forkliftDeduction = item.stream()
|
||||
.filter(data -> data.getBusinessType() == 2)
|
||||
.flatMap( data -> data.getDeductionItems().stream())
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 获取搬运扣款明细
|
||||
List<SettlementItemDTO.Deduction> 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<SettlementItemDTO.Deduction> 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<FactoryInfoDO> getCompanyFactoryList() {
|
||||
|
||||
|
@ -33,16 +33,16 @@
|
||||
</select>
|
||||
|
||||
<select id="selectProfit" resultType="cn.iocoder.yudao.module.smartfactory.controller.admin.factoryinfo.vo.FactoryProfitVO">
|
||||
WITH json_extracted AS (
|
||||
SELECT
|
||||
scs.id AS settlement_id,-- 提取 JSON 中的值,将 NULL 替换为 0.00
|
||||
COALESCE ( JSON_UNQUOTE( JSON_EXTRACT( scs.other_deductions, '$[0].value' )), '0.00' ) AS hydropower,
|
||||
COALESCE ( JSON_UNQUOTE( JSON_EXTRACT( scs.other_deductions, '$[1].value' )), '0.00' ) AS employment,
|
||||
COALESCE ( JSON_UNQUOTE( JSON_EXTRACT( scs.other_deductions, '$[2].value' )), '0.00' ) AS other,
|
||||
scs.tenant_id
|
||||
FROM
|
||||
system_customer_settlement scs
|
||||
)
|
||||
-- WITH json_extracted AS (
|
||||
-- SELECT
|
||||
-- scs.id AS settlement_id,-- 提取 JSON 中的值,将 NULL 替换为 0.00
|
||||
-- COALESCE ( JSON_UNQUOTE( JSON_EXTRACT( scs.other_deductions, '$[0].value' )), '0.00' ) AS hydropower,
|
||||
-- COALESCE ( JSON_UNQUOTE( JSON_EXTRACT( scs.other_deductions, '$[1].value' )), '0.00' ) AS employment,
|
||||
-- COALESCE ( JSON_UNQUOTE( JSON_EXTRACT( scs.other_deductions, '$[2].value' )), '0.00' ) AS other,
|
||||
-- scs.tenant_id
|
||||
-- FROM
|
||||
-- system_customer_settlement scs
|
||||
-- )
|
||||
SELECT
|
||||
sf.id AS factoryId,
|
||||
sf.short_name AS factoryName,
|
||||
@ -55,9 +55,9 @@
|
||||
SUM( CASE WHEN ssi.business_type = 1 THEN ssi.deduction_amount ELSE 0 END ) AS forkliftDeduction,-- 叉车扣款
|
||||
SUM( CASE WHEN ssi.business_type = 2 THEN ssi.deduction_amount ELSE 0 END ) AS packageDeduction,-- 打包扣款
|
||||
SUM( CASE WHEN ssi.business_type = 3 THEN ssi.deduction_amount ELSE 0 END ) AS porterageDeduction,-- 搬运扣款
|
||||
je.hydropower AS hydropower,-- 水电扣款
|
||||
je.employment AS employment,-- 工商扣款
|
||||
je.other AS other,-- 其他(理赔、扣点)
|
||||
-- je.hydropower AS hydropower,-- 水电扣款
|
||||
-- je.employment AS employment,-- 工商扣款
|
||||
-- je.other AS other,-- 其他(理赔、扣点)
|
||||
COALESCE ( sss.forkliftSalary, 0.00 ) AS forkliftSalary,-- 叉车实发工资
|
||||
COALESCE ( sss.packageSalary, 0.00 ) AS packageSalary,-- 打包实发工资
|
||||
COALESCE ( sss.porterageSalary, 0.00 ) AS porterageSalary,-- 搬运实发工资
|
||||
@ -77,7 +77,7 @@
|
||||
sf_factory_info sf
|
||||
LEFT JOIN system_customer_settlement scs ON sf.id = scs.customer_id AND scs.settlement_month = #{month}
|
||||
LEFT JOIN system_settlement_item ssi ON scs.id = ssi.settlement_id
|
||||
LEFT JOIN json_extracted je ON scs.id = je.settlement_id
|
||||
-- LEFT JOIN json_extracted je ON scs.id = je.settlement_id
|
||||
LEFT JOIN (
|
||||
SELECT
|
||||
s.factory_id,
|
||||
|
Loading…
Reference in New Issue
Block a user