Compare commits

...

2 Commits

Author SHA1 Message Date
furongxin
77d7620898 feat(factory-info): 增加工厂扣款明细展示
- 在 FactoryProfitVO 中添加扣款明细相关字段
- 在 FactoryInfoServiceImpl 中实现扣款明细的获取和设置
- 更新 FactoryInfoMapper 和 XML 文件,移除不再使用的其他扣款字段
- 在 RpcConfiguration 中添加 SettlementApi 的 Feign客户端配置
2025-06-01 10:08:03 +08:00
furongxin
9a50fa9697 feat(system): 添加结算扣款明细接口
- 新增 SettlementApi接口,提供获取结算扣款明细的功能
- 添加 SettlementItemDTO 数据传输对象,用于结算项的传输
- 在 CustomerSettlementMapper 中实现结算扣款明细的查询方法
- 在 CustomerSettlementService 接口中添加获取结算扣款明细的方法
- 实现 CustomerSettlementServiceImpl 中的结算扣款明细查询逻辑
- 添加 SettlementApiImpl 类,实现 SettlementApi 接口
2025-06-01 10:07:25 +08:00
10 changed files with 257 additions and 26 deletions

View File

@ -0,0 +1,26 @@
package cn.iocoder.yudao.module.system.api.customersettlement;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.system.api.customersettlement.dto.SettlementItemDTO;
import cn.iocoder.yudao.module.system.enums.ApiConstants;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
@FeignClient(name = ApiConstants.NAME) // TODO 芋艿fallbackFactory =
@Tag(name = "RPC 服务 - 结算")
public interface SettlementApi {
String PREFIX = ApiConstants.PREFIX + "/customer-settlement";
@GetMapping(PREFIX + "/get-deductionItems")
@Operation(summary = "获得结算扣款明细")
CommonResult<List<SettlementItemDTO>> getDeductionItems(@RequestParam(value = "factoryId", required = false) Long factoryId,
@RequestParam(value = "month", required = false) String month);
}

View File

@ -0,0 +1,35 @@
package cn.iocoder.yudao.module.system.api.customersettlement.dto;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.math.BigDecimal;
import java.util.List;
@Schema(description = "管理后台 - 工厂结算项VO")
@Data
public class SettlementItemDTO {
@Schema(description = "工厂编号")
private Long factoryId;
@Schema(description = "结算月份")
private String month;
@Schema(description = "业务类型")
private Integer businessType;
@Schema(description = "扣款明细")
private List<Deduction> deductionItems;
/**
* 扣款明细
*/
@Data
public static class Deduction {
private String key;
private BigDecimal value;
}
}

View File

@ -0,0 +1,26 @@
package cn.iocoder.yudao.module.system.api.customersettlement;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.system.api.customersettlement.dto.SettlementItemDTO;
import cn.iocoder.yudao.module.system.service.customersettlement.CustomerSettlementService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.List;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
@RestController // 提供 RESTful API 接口 Feign 调用
@Validated
public class SettlementApiImpl implements SettlementApi {
@Resource
private CustomerSettlementService customerSettlementService;
@Override
public CommonResult<List<SettlementItemDTO>> getDeductionItems(Long factoryId, String month) {
return success( customerSettlementService.getDeductionItems(factoryId, month));
}
}

View File

@ -3,12 +3,17 @@ package cn.iocoder.yudao.module.system.dal.mysql.customersettlement;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.MPJLambdaWrapperX;
import cn.iocoder.yudao.module.system.api.customersettlement.dto.SettlementItemDTO;
import cn.iocoder.yudao.module.system.controller.admin.customersettlement.vo.CustomerSettlementPageReqVO; import cn.iocoder.yudao.module.system.controller.admin.customersettlement.vo.CustomerSettlementPageReqVO;
import cn.iocoder.yudao.module.system.controller.admin.customersettlement.vo.StatisticsVO; import cn.iocoder.yudao.module.system.controller.admin.customersettlement.vo.StatisticsVO;
import cn.iocoder.yudao.module.system.dal.dataobject.customersettlement.CustomerSettlementDO; import cn.iocoder.yudao.module.system.dal.dataobject.customersettlement.CustomerSettlementDO;
import cn.iocoder.yudao.module.system.dal.dataobject.customersettlement.SettlementItemDO;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.List;
/** /**
* 客户结算信息 Mapper * 客户结算信息 Mapper
* *
@ -25,4 +30,18 @@ public interface CustomerSettlementMapper extends BaseMapperX<CustomerSettlement
} }
StatisticsVO selectTotal(@Param("reqVO") CustomerSettlementPageReqVO pageReqVO); StatisticsVO selectTotal(@Param("reqVO") CustomerSettlementPageReqVO pageReqVO);
default List<SettlementItemDTO> selectDeductionItems(Long factoryId, String month) {
MPJLambdaWrapperX<CustomerSettlementDO> queryWrapper = new MPJLambdaWrapperX<CustomerSettlementDO>();
queryWrapper.selectAs(CustomerSettlementDO::getCustomerId, SettlementItemDTO::getFactoryId);
queryWrapper.selectAs(CustomerSettlementDO::getSettlementMonth, SettlementItemDTO::getMonth);
queryWrapper.selectAs(SettlementItemDO::getBusinessType, SettlementItemDTO::getBusinessType);
queryWrapper.selectAs(SettlementItemDO::getDeductionItems, SettlementItemDTO::getDeductionItems);
queryWrapper.leftJoin(SettlementItemDO.class, SettlementItemDO::getSettlementId, CustomerSettlementDO::getId);
queryWrapper.eqIfPresent(CustomerSettlementDO::getCustomerId, factoryId);
queryWrapper.eqIfPresent(CustomerSettlementDO::getSettlementMonth, month);
return selectJoinList(SettlementItemDTO.class, queryWrapper);
}
} }

View File

@ -1,6 +1,7 @@
package cn.iocoder.yudao.module.system.service.customersettlement; package cn.iocoder.yudao.module.system.service.customersettlement;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.system.api.customersettlement.dto.SettlementItemDTO;
import cn.iocoder.yudao.module.system.controller.admin.customersettlement.vo.CustomerSettlementPageReqVO; import cn.iocoder.yudao.module.system.controller.admin.customersettlement.vo.CustomerSettlementPageReqVO;
import cn.iocoder.yudao.module.system.controller.admin.customersettlement.vo.CustomerSettlementSaveReqVO; import cn.iocoder.yudao.module.system.controller.admin.customersettlement.vo.CustomerSettlementSaveReqVO;
import cn.iocoder.yudao.module.system.controller.admin.customersettlement.vo.StatisticsVO; import cn.iocoder.yudao.module.system.controller.admin.customersettlement.vo.StatisticsVO;
@ -78,4 +79,12 @@ public interface CustomerSettlementService {
* @return 统计信息 * @return 统计信息
*/ */
StatisticsVO getCustomerSettlementTotal(CustomerSettlementPageReqVO pageReqVO); StatisticsVO getCustomerSettlementTotal(CustomerSettlementPageReqVO pageReqVO);
/**
* 获得结算扣款明细
* @param factoryId 工厂id
* @param month 月份
* @return 结算扣款明细
*/
List<SettlementItemDTO> getDeductionItems(Long factoryId, String month);
} }

View File

@ -5,6 +5,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils; import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.infra.api.file.FileApi; import cn.iocoder.yudao.module.infra.api.file.FileApi;
import cn.iocoder.yudao.module.system.api.customersettlement.dto.SettlementItemDTO;
import cn.iocoder.yudao.module.system.controller.admin.customersettlement.vo.CustomerSettlementPageReqVO; import cn.iocoder.yudao.module.system.controller.admin.customersettlement.vo.CustomerSettlementPageReqVO;
import cn.iocoder.yudao.module.system.controller.admin.customersettlement.vo.CustomerSettlementSaveReqVO; import cn.iocoder.yudao.module.system.controller.admin.customersettlement.vo.CustomerSettlementSaveReqVO;
import cn.iocoder.yudao.module.system.controller.admin.customersettlement.vo.StatisticsVO; import cn.iocoder.yudao.module.system.controller.admin.customersettlement.vo.StatisticsVO;
@ -170,4 +171,9 @@ public class CustomerSettlementServiceImpl implements CustomerSettlementService
return customerSettlementMapper.selectTotal(pageReqVO); return customerSettlementMapper.selectTotal(pageReqVO);
} }
@Override
public List<SettlementItemDTO> getDeductionItems(Long factoryId, String month) {
return customerSettlementMapper.selectDeductionItems(factoryId, month);
}
} }

View File

@ -42,14 +42,23 @@ public class FactoryProfitVO {
@Schema(description = "搬运扣款") @Schema(description = "搬运扣款")
private BigDecimal porterageDeduction; private BigDecimal porterageDeduction;
@Schema(description = "叉车扣款明细")
private Deduction forkliftDeductionItem;
@Schema(description = "打包扣款明细")
private Deduction packageDeductionItem;
@Schema(description = "搬运扣款明细")
private Deduction porterageDeductionItem;
@Schema(description = "水电扣款") @Schema(description = "水电扣款")
private BigDecimal hydropower; private BigDecimal hydropower;
@Schema(description = "工伤保险") // @Schema(description = "工伤保险")
private BigDecimal employment; // private BigDecimal employment;
//
@Schema(description = "其他(理赔、扣点)") // @Schema(description = "其他(理赔、扣点)")
private BigDecimal other; // private BigDecimal other;
@Schema(description = "叉车工资") @Schema(description = "叉车工资")
private BigDecimal forkliftSalary; private BigDecimal forkliftSalary;
@ -104,4 +113,20 @@ public class FactoryProfitVO {
@Schema(description = "搬运毛利") @Schema(description = "搬运毛利")
private BigDecimal porterageGrossProfit; 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;
}
} }

View File

@ -1,11 +1,11 @@
package cn.iocoder.yudao.module.smartfactory.framework.rpc.config; 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.bpm.api.oa.BpmOALoanApi;
import cn.iocoder.yudao.module.infra.api.config.ConfigApi; import cn.iocoder.yudao.module.infra.api.config.ConfigApi;
import cn.iocoder.yudao.module.infra.api.file.FileApi; 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.assets.AssetsTypeApi;
import cn.iocoder.yudao.module.system.api.auth.AdminOauthUserOtherInfoApi; 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.DeptApi;
import cn.iocoder.yudao.module.system.api.dept.PostApi; import cn.iocoder.yudao.module.system.api.dept.PostApi;
import cn.iocoder.yudao.module.system.api.dict.DictDataApi; import cn.iocoder.yudao.module.system.api.dict.DictDataApi;
@ -21,7 +21,8 @@ import org.springframework.context.annotation.Configuration;
@Configuration(proxyBeanMethods = false) @Configuration(proxyBeanMethods = false)
@EnableFeignClients(clients = {FileApi.class, RoleApi.class, DeptApi.class, PostApi.class, AdminUserApi.class, SmsSendApi.class, DictDataApi.class, NotifyMessageSendApi.class, @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 { public class RpcConfiguration {
} }

View File

@ -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.Area;
import cn.iocoder.yudao.framework.ip.core.utils.AreaUtils; import cn.iocoder.yudao.framework.ip.core.utils.AreaUtils;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; 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.*;
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.screendata.factory.vo.FactoryRollDataRespVO; 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.controller.admin.screendata.factory.vo.ProvincesDataRespVO;
import cn.iocoder.yudao.module.smartfactory.dal.dataobject.factoryinfo.FactoryInfoDO; 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.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.DeptApi;
import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO;
import cn.iocoder.yudao.module.system.api.permission.PermissionApi; 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 org.springframework.validation.annotation.Validated;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.*; import java.util.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; 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.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.FACTORY_INFO_NOT_EXISTS;
import static cn.iocoder.yudao.module.smartfactory.enums.ErrorCodeConstants.FACTOYRY_EXISTS_STAFF; import static cn.iocoder.yudao.module.smartfactory.enums.ErrorCodeConstants.FACTOYRY_EXISTS_STAFF;
@ -58,6 +58,9 @@ public class FactoryInfoServiceImpl implements FactoryInfoService {
@Resource @Resource
private PermissionApi permissionApi; private PermissionApi permissionApi;
@Resource
private SettlementApi settlementApi;
@Override @Override
public Long createFactoryInfo(FactoryInfoSaveReqVO createReqVO) { public Long createFactoryInfo(FactoryInfoSaveReqVO createReqVO) {
// 插入 // 插入
@ -286,6 +289,11 @@ public class FactoryInfoServiceImpl implements FactoryInfoService {
public List<FactoryProfitVO> getProfit(Long factoryId, String month) { public List<FactoryProfitVO> getProfit(Long factoryId, String month) {
List<FactoryProfitVO> result = factoryInfoMapper.selectProfit(factoryId, 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)) { if (CollUtil.isNotEmpty(result)) {
// 设置叉车毛利打包毛利搬运毛利 = 收入 - 扣款 - 人员工资 - 支出 // 设置叉车毛利打包毛利搬运毛利 = 收入 - 扣款 - 人员工资 - 支出
result.forEach(vo -> { result.forEach(vo -> {
@ -304,12 +312,88 @@ public class FactoryInfoServiceImpl implements FactoryInfoService {
.subtract(vo.getPorterageDeduction()) .subtract(vo.getPorterageDeduction())
.subtract(vo.getPorterageSalary()) .subtract(vo.getPorterageSalary())
.subtract(vo.getTransportationExpenses())); .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; 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 @Override
public List<FactoryInfoDO> getCompanyFactoryList() { public List<FactoryInfoDO> getCompanyFactoryList() {

View File

@ -33,16 +33,16 @@
</select> </select>
<select id="selectProfit" resultType="cn.iocoder.yudao.module.smartfactory.controller.admin.factoryinfo.vo.FactoryProfitVO"> <select id="selectProfit" resultType="cn.iocoder.yudao.module.smartfactory.controller.admin.factoryinfo.vo.FactoryProfitVO">
WITH json_extracted AS ( -- WITH json_extracted AS (
SELECT -- SELECT
scs.id AS settlement_id,-- 提取 JSON 中的值,将 NULL 替换为 0.00 -- 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, '$[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, '$[1].value' )), '0.00' ) AS employment,
COALESCE ( JSON_UNQUOTE( JSON_EXTRACT( scs.other_deductions, '$[2].value' )), '0.00' ) AS other, -- COALESCE ( JSON_UNQUOTE( JSON_EXTRACT( scs.other_deductions, '$[2].value' )), '0.00' ) AS other,
scs.tenant_id -- scs.tenant_id
FROM -- FROM
system_customer_settlement scs -- system_customer_settlement scs
) -- )
SELECT SELECT
sf.id AS factoryId, sf.id AS factoryId,
sf.short_name AS factoryName, 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 = 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 = 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,-- 搬运扣款 SUM( CASE WHEN ssi.business_type = 3 THEN ssi.deduction_amount ELSE 0 END ) AS porterageDeduction,-- 搬运扣款
je.hydropower AS hydropower,-- 水电扣款 -- je.hydropower AS hydropower,-- 水电扣款
je.employment AS employment,-- 工商扣款 -- je.employment AS employment,-- 工商扣款
je.other AS other,-- 其他(理赔、扣点) -- je.other AS other,-- 其他(理赔、扣点)
COALESCE ( sss.forkliftSalary, 0.00 ) AS forkliftSalary,-- 叉车实发工资 COALESCE ( sss.forkliftSalary, 0.00 ) AS forkliftSalary,-- 叉车实发工资
COALESCE ( sss.packageSalary, 0.00 ) AS packageSalary,-- 打包实发工资 COALESCE ( sss.packageSalary, 0.00 ) AS packageSalary,-- 打包实发工资
COALESCE ( sss.porterageSalary, 0.00 ) AS porterageSalary,-- 搬运实发工资 COALESCE ( sss.porterageSalary, 0.00 ) AS porterageSalary,-- 搬运实发工资
@ -77,7 +77,7 @@
sf_factory_info sf sf_factory_info sf
LEFT JOIN system_customer_settlement scs ON sf.id = scs.customer_id AND scs.settlement_month = #{month} 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 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 ( LEFT JOIN (
SELECT SELECT
s.factory_id, s.factory_id,