feat(bpm): 优化合同和回款页面查询逻辑

-重构了合同和回款页面的查询逻辑,支持"我的"和"下属"两种关系的查询- 新增 UserLiveTreeApi接口,用于获取用户结构树
- 优化了 SQL 查询条件,提高了查询效率
- 新增厂区配件领用相关功能
This commit is contained in:
furongxin 2025-03-01 18:01:46 +08:00
parent c2db457a63
commit 6786ec0d3d
32 changed files with 891 additions and 48 deletions

View File

@ -3,13 +3,13 @@ package cn.iocoder.yudao.module.bpm.controller.admin.financialpayment;
import cn.hutool.core.collection.CollectionUtil;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.pojo.UploadUserFile;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.bpm.controller.admin.financialpayment.vo.FinancialPaymentPageReqVO;
import cn.iocoder.yudao.module.bpm.controller.admin.financialpayment.vo.FinancialPaymentRespVO;
import cn.iocoder.yudao.module.bpm.controller.admin.financialpayment.vo.FinancialPaymentSaveReqVO;
import cn.iocoder.yudao.module.bpm.controller.admin.financialpayment.vo.FinancialPaymentSaveVO;
import cn.iocoder.yudao.module.bpm.controller.admin.financialpaymentitem.vo.FinancialPaymentItemRespVO;
import cn.iocoder.yudao.framework.common.pojo.UploadUserFile;
import cn.iocoder.yudao.module.bpm.dal.dataobject.financialpayment.FinancialPaymentDO;
import cn.iocoder.yudao.module.bpm.dal.dataobject.financialpaymentitem.FinancialPaymentItemDO;
import cn.iocoder.yudao.module.bpm.service.financialpayment.FinancialPaymentService;
@ -17,7 +17,6 @@ import cn.iocoder.yudao.module.bpm.service.financialpaymentitem.FinancialPayment
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
@ -106,4 +105,10 @@ public class FinancialPaymentController {
return success(BeanUtils.toBean(pageResult, FinancialPaymentRespVO.class));
}
@GetMapping("/total")
@Operation(summary = "获得财务支付统计信息")
public CommonResult<FinancialPaymentRespVO> getPaymentTotal(@Valid FinancialPaymentPageReqVO pageReqVO) {
FinancialPaymentDO paymentDO = financialPaymentService.getPaymentTotal(pageReqVO);
return success(BeanUtils.toBean(paymentDO, FinancialPaymentRespVO.class));
}
}

View File

@ -28,4 +28,7 @@ public class BpmOAReceiptPageReqVO extends PageParam {
@Schema(description = "查询模式")
private String relation;
@Schema(description = "合同编号")
private Long contractId;
}

View File

@ -41,4 +41,6 @@ public interface FinancialPaymentMapper extends BaseMapperX<FinancialPaymentDO>
* @param ids
*/
void cancel(@Param("ids") List<Long> ids);
FinancialPaymentDO selectPaymentTotal(@Param("vo") FinancialPaymentPageReqVO pageReqVO);
}

View File

@ -23,7 +23,7 @@ import java.util.Objects;
@Mapper
public interface BpmOAContractMapper extends BaseMapperX<BpmOAContractDO> {
default PageResult<BpmOAContractRespVO> selectPage(BpmOAContractPageReqVO pageReqVO,
Long userId) {
List<Long> userIds) {
MPJLambdaWrapperX<BpmOAContractDO> query = new MPJLambdaWrapperX<>();
query.selectAll(BpmOAContractDO.class);
@ -39,25 +39,10 @@ public interface BpmOAContractMapper extends BaseMapperX<BpmOAContractDO> {
query.likeIfPresent(BpmOAContractDO::getCustomerName, pageReqVO.getCustomerName());
query.eqIfPresent(BpmOAContractDO::getStatus, pageReqVO.getStatus());
query.eqIfPresent(BpmOAContractDO::getResult, pageReqVO.getResult());
query.inIfPresent(BpmOAContractDO::getUserId, userIds);
query.apply(Objects.nonNull(pageReqVO.getSignatoryName()),"u.nickname Like CONCAT('%', {0}, '%')", pageReqVO.getSignatoryName());
query.apply(Objects.nonNull(pageReqVO.getCreateName()),"u1.nickname Like CONCAT('%', {0}, '%')", pageReqVO.getCreateName());
if ("my".equals(pageReqVO.getRelation())) {
query.eq(BpmOAContractDO::getUserId, userId);
}else if ("sub".equals(pageReqVO.getRelation())){
query.innerJoin("(" +
"\tSELECT DISTINCT\n" +
"\t\tu.id \n" +
"\tFROM\n" +
"\t\tsystem_users u\n" +
"\t\tINNER JOIN system_dept d ON d.leader_user_id = "+ userId +"\n" +
"\t\tINNER JOIN system_dept d1 ON d1.flag LIKE CONCAT( '%', d.id, '-' ) \n" +
"\t\tOR d1.flag LIKE CONCAT( '%-', d.id, '-%' ) \n" +
"\t\tOR d1.flag LIKE CONCAT( '-', d.id, '%' ) \n" +
"\tWHERE\n" +
"\t\tu.dept_id = d1.id \n" +
"\t\tAND u.STATUS = 0 \n" +
"\t) subordinate ON subordinate.id = t.user_id");
}
query.orderByDesc(BpmOAContractDO::getCreateTime);
return selectJoinPage(pageReqVO, BpmOAContractRespVO.class, query);

View File

@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.bpm.dal.mysql.oa;
import cn.hutool.core.collection.CollUtil;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.MPJLambdaWrapperX;
@ -18,7 +19,7 @@ import java.util.Objects;
@Mapper
public interface BpmOAReceiptMapper extends BaseMapperX<BpmOAReceiptDO> {
default PageResult<BpmOAReceiptRespVO> selectReceiptPage(BpmOAReceiptPageReqVO pageReqVO, Long userId) {
default PageResult<BpmOAReceiptRespVO> selectReceiptPage(BpmOAReceiptPageReqVO pageReqVO, List<Long> userIds) {
MPJLambdaWrapperX<BpmOAReceiptDO> query = new MPJLambdaWrapperX<>();
query.selectAll(BpmOAReceiptDO.class);
@ -29,26 +30,11 @@ public interface BpmOAReceiptMapper extends BaseMapperX<BpmOAReceiptDO> {
query.leftJoin(BpmOAContractDO.class, "c", BpmOAContractDO::getId, BpmOAReceiptDO::getContractId);
query.leftJoin("system_users u on u.id = t.creator");
query.eqIfPresent(BpmOAReceiptDO::getResult, pageReqVO.getResult());
query.in(CollUtil.isNotEmpty(userIds), BpmOAContractDO::getUserId, userIds);
query.apply(Objects.nonNull(pageReqVO.getContractId()), "c.id = {0}", pageReqVO.getContractId());
query.apply(Objects.nonNull(pageReqVO.getCustomerName()), "c.customer_name LIKE CONCAT('%', {0}, '%')", pageReqVO.getCustomerName());
query.apply(Objects.nonNull(pageReqVO.getContractName()), "c.contract_name LIKE CONCAT('%', {0}, '%')", pageReqVO.getContractName());
query.apply(Objects.nonNull(pageReqVO.getCreateName()),"u.nickname Like CONCAT('%', {0}, '%')", pageReqVO.getCreateName());
if ("my".equals(pageReqVO.getRelation())) {
query.eq(BpmOAContractDO::getUserId, userId);
}else if ("sub".equals(pageReqVO.getRelation())){
query.innerJoin("(" +
"\tSELECT DISTINCT\n" +
"\t\tu.id \n" +
"\tFROM\n" +
"\t\tsystem_users u\n" +
"\t\tINNER JOIN system_dept d ON d.leader_user_id = "+ userId +"\n" +
"\t\tINNER JOIN system_dept d1 ON d1.flag LIKE CONCAT( '%', d.id, '-' ) \n" +
"\t\tOR d1.flag LIKE CONCAT( '%-', d.id, '-%' ) \n" +
"\t\tOR d1.flag LIKE CONCAT( '-', d.id, '%' ) \n" +
"\tWHERE\n" +
"\t\tu.dept_id = d1.id \n" +
"\t\tAND u.STATUS = 0 \n" +
"\t) subordinate ON subordinate.id = t.user_id");
}
query.orderByDesc(BpmOAReceiptDO::getCreateTime);
return selectJoinPage(pageReqVO, BpmOAReceiptRespVO.class, query);

View File

@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.bpm.dal.mysql.task;
import cn.hutool.core.collection.CollUtil;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
@ -14,12 +15,10 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.commons.lang3.StringUtils;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.mapstruct.ap.internal.util.Strings;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Objects;
@Mapper
public interface BpmTaskExtMapper extends BaseMapperX<BpmTaskExtDO> {
@ -97,7 +96,7 @@ public interface BpmTaskExtMapper extends BaseMapperX<BpmTaskExtDO> {
queryWrapperX.innerJoin(BpmProcessInstanceExtDO.class, on -> on
.eq(BpmTaskExtDO::getProcessInstanceId, BpmProcessInstanceExtDO::getProcessInstanceId)
.in(Objects.nonNull(userIds), BpmProcessInstanceExtDO::getStartUserId, userIds)
.in(CollUtil.isNotEmpty(userIds), BpmProcessInstanceExtDO::getStartUserId, userIds)
.eq(StringUtils.isNotEmpty(pageVO.getName()), BpmProcessInstanceExtDO::getName, pageVO.getName()));
queryWrapperX.likeRight(BpmProcessInstanceExtDO::getProcessDefinitionId, "oa_");
queryWrapperX.eq(BpmTaskExtDO::getAssigneeUserId, userId);

View File

@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.bpm.framework.rpc.config;
import cn.iocoder.yudao.module.hrm.api.crmbusiness.BusinessApi;
import cn.iocoder.yudao.module.hrm.api.crmcontract.ContractApi;
import cn.iocoder.yudao.module.hrm.api.crmcustomer.CrmCustomerApi;
import cn.iocoder.yudao.module.hrm.api.userlivetree.UserLiveTreeApi;
import cn.iocoder.yudao.module.infra.api.config.ConfigApi;
import cn.iocoder.yudao.module.infra.api.file.FileApi;
import cn.iocoder.yudao.module.product.api.storeproduct.StoreProductApi;
@ -43,7 +44,7 @@ import org.springframework.context.annotation.Configuration;
SubscribeMessageSendApi.class, SocialClientApi.class, UsersExtApi.class, AttendanceApi.class, BankApi.class, ConfigApi.class, PositionApi.class, SupplierApi.class, AssetsApi.class,
AssetsTypeApi.class, AssetReceiveApi.class, AttendanceApi.class, AttendanceGroupApi.class, WorkOvertimeApi.class, HolidayApi.class,
RentalOrderApi.class, RentalDepositRecordApi.class, ProjectApi.class, RentalItemsRecordApi.class,AdminOauthUserOtherInfoApi.class, StoreProductAttrValueApi.class, StoreProductApi.class,
ContractApi.class, BusinessApi.class, CrmCustomerApi.class, StaffApi.class, LoanApi.class, FactoryInfoApi.class
ContractApi.class, BusinessApi.class, CrmCustomerApi.class, StaffApi.class, LoanApi.class, FactoryInfoApi.class, UserLiveTreeApi.class
})
public class RpcConfiguration {
}

View File

@ -88,4 +88,11 @@ public interface FinancialPaymentService {
* @return 支付信息列表
*/
List<FinancialPaymentDO> getFinancialPaymentList(List<String> processInstanceIds);
/**
* 获取支付信息 统计
* @param pageReqVO 查询条件
* @return 统计信息
*/
FinancialPaymentDO getPaymentTotal(FinancialPaymentPageReqVO pageReqVO);
}

View File

@ -252,4 +252,10 @@ public class FinancialPaymentServiceImpl implements FinancialPaymentService {
return financialPaymentMapper.selectList(FinancialPaymentDO::getProcessInstanceId, processInstanceIds);
}
@Override
public FinancialPaymentDO getPaymentTotal(FinancialPaymentPageReqVO pageReqVO) {
pageReqVO.setReceiveUserId(getLoginUserId());
return financialPaymentMapper.selectPaymentTotal(pageReqVO);
}
}

View File

@ -22,6 +22,7 @@ import cn.iocoder.yudao.module.hrm.api.crmcontract.ContractApi;
import cn.iocoder.yudao.module.hrm.api.crmcontract.dto.CrmContractProductDTO;
import cn.iocoder.yudao.module.hrm.api.crmcustomer.CrmCustomerApi;
import cn.iocoder.yudao.module.hrm.api.crmcustomer.dto.CrmCustomerDTO;
import cn.iocoder.yudao.module.hrm.api.userlivetree.UserLiveTreeApi;
import cn.iocoder.yudao.module.product.api.storeproduct.StoreProductApi;
import cn.iocoder.yudao.module.product.api.storeproductattrvalue.StoreProductAttrValueApi;
import cn.iocoder.yudao.module.product.api.storeproductattrvalue.dto.StoreProductAttrValueApiDTO;
@ -107,6 +108,9 @@ public class BpmOAContractServiceImpl extends BpmOABaseService implements BpmOAC
@Resource
private CrmCustomerApi customerApi;
@Resource
private UserLiveTreeApi userLiveTreeApi;
@Override
public Long createContract(Long userId, BpmOAContractCreateReqVO createReqVO) {
// 新增合同DO
@ -265,7 +269,15 @@ public class BpmOAContractServiceImpl extends BpmOABaseService implements BpmOAC
@Override
public PageResult<BpmOAContractRespVO> getContractPage(BpmOAContractPageReqVO pageReqVO) {
return contractMapper.selectPage(pageReqVO, getLoginUserId());
List<Long> userIds = new ArrayList<>();
if ("my".equals(pageReqVO.getRelation())) {
userIds.add(getLoginUserId());
}else if ("sub".equals(pageReqVO.getRelation())){
// 查询当前用户 所有下级用户编号
userIds.addAll(userLiveTreeApi.getItemIdsByUserId(getLoginUserId()).getCheckedData());
}
return contractMapper.selectPage(pageReqVO, userIds);
}
@Override

View File

@ -12,11 +12,15 @@ import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.receipt.BpmOAReceiptCr
import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.receipt.BpmOAReceiptPageReqVO;
import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.receipt.BpmOAReceiptRespVO;
import cn.iocoder.yudao.module.bpm.controller.admin.oa.vo.receipt.ReceiptStatisticsVO;
import cn.iocoder.yudao.module.bpm.dal.dataobject.oa.BpmOAContractDO;
import cn.iocoder.yudao.module.bpm.dal.dataobject.oa.BpmOAReceiptDO;
import cn.iocoder.yudao.module.bpm.dal.mysql.oa.BpmOAContractMapper;
import cn.iocoder.yudao.module.bpm.dal.mysql.oa.BpmOAReceiptMapper;
import cn.iocoder.yudao.module.bpm.enums.task.BpmProcessInstanceResultEnum;
import cn.iocoder.yudao.module.bpm.service.task.BpmHistoryProcessInstanceService;
import cn.iocoder.yudao.module.bpm.service.task.BpmProcessInstanceService;
import cn.iocoder.yudao.module.hrm.api.userlivetree.UserLiveTreeApi;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import org.flowable.engine.runtime.ProcessInstance;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
@ -25,6 +29,7 @@ import javax.annotation.Resource;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@ -60,6 +65,12 @@ public class BpmOAReceiptServiceImpl extends BpmOABaseService implements BpmOARe
@Resource
private BpmProcessInstanceService bpmProcessInstanceService;
@Resource
private UserLiveTreeApi userLiveTreeApi;
@Resource
private BpmOAContractMapper contractMapper;
@Override
public Long createReceipt(Long userId, BpmOAReceiptCreateReqVO createReqVO) {
@ -103,7 +114,10 @@ public class BpmOAReceiptServiceImpl extends BpmOABaseService implements BpmOARe
ProcessInstance instance = bpmProcessInstanceService.getProcessInstance(processInstanceId);
if (instance.isEnded()) {
// 更新合同表的回款金额
contractMapper.update(null, new LambdaUpdateWrapper<BpmOAContractDO>()
.setSql("return_money = return_money + " + receiptDO.getMoney())
.eq(BpmOAContractDO::getId, receiptDO.getContractId()));
}
}
@ -133,7 +147,15 @@ public class BpmOAReceiptServiceImpl extends BpmOABaseService implements BpmOARe
@Override
public PageResult<BpmOAReceiptRespVO> getReceiptPage(BpmOAReceiptPageReqVO pageReqVO) {
return receiptMapper.selectReceiptPage(pageReqVO, getLoginUserId());
List<Long> userIds = new ArrayList<>();
if ("my".equals(pageReqVO.getRelation())) {
userIds.add(getLoginUserId());
}else if ("sub".equals(pageReqVO.getRelation())){
// 查询当前用户 所有下级用户编号
userIds.addAll(userLiveTreeApi.getItemIdsByUserId(getLoginUserId()).getCheckedData());
}
return receiptMapper.selectReceiptPage(pageReqVO, userIds);
}
@Override

View File

@ -102,4 +102,65 @@
a.id = #{id}
</where>
</select>
<select id="selectPaymentTotal" resultType="cn.iocoder.yudao.module.bpm.dal.dataobject.financialpayment.FinancialPaymentDO">
SELECT
SUM(a.amount_payable) AS amountPayable,
SUM(a.actual_payment) AS actualPayment
FROM
bpm_financial_payment a
LEFT JOIN system_users b ON a.user_id = b.id
LEFT JOIN system_dept as c on b.dept_id = c.id
LEFT JOIN system_users as d on a.receive_user_id = d.id
WHERE
a.deleted = 0
<if test="vo.deptIds != null and vo.deptIds.size() > 0">
AND c.id IN
<foreach collection="vo.deptIds" item="deptId" open="(" separator="," close=")">
#{deptId}
</foreach>
</if>
<if test="vo.nickname != null and vo.nickname != ''">
and b.nickname like concat('%', #{vo.nickname}, '%')
</if>
<if test="vo.type != null">
and a.type = #{vo.type}
</if>
<if test="vo.status != null">
and a.status = #{vo.status}
</if>
<if test="vo.financeName != null and vo.financeName != ''">
and d.nickname like concat('%', #{vo.financeName}, '%')
</if>
<if test="vo.receiveType != null">
<if test="vo.receiveType == 1">
and a.receive_user_id is null
</if>
<if test="vo.receiveType == 2">
and a.receive_user_id is not null
</if>
<if test="vo.receiveType == 3">
and a.receive_user_id = #{vo.receiveUserId}
</if>
<if test="vo.receiveType == 4">
and a.receive_user_id != #{vo.receiveUserId}
</if>
</if>
<if test="vo.beginTime != null and vo.beginTime.length > 0">
<if test="vo.beginTime[0] != null">
and a.begin_time &gt;= #{vo.beginTime[0]}
</if>
<if test="vo.beginTime[1] != null">
and a.begin_time &lt;= #{vo.beginTime[1]}
</if>
</if>
<if test="vo.endTime != null and vo.endTime.length > 0">
<if test="vo.endTime[0] != null">
and a.end_time &gt;= #{vo.endTime[0]}
</if>
<if test="vo.endTime[1] != null">
and a.end_time &lt;= #{vo.endTime[1]}
</if>
</if>
</select>
</mapper>

View File

@ -0,0 +1,24 @@
package cn.iocoder.yudao.module.hrm.api.userlivetree;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.hrm.enums.ApiConstants;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
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 服务 - CRM用户结构树")
public interface UserLiveTreeApi {
String PREFIX = ApiConstants.PREFIX + "/crm/userLiveTree";
@GetMapping(PREFIX + "/get-list")
@Operation(summary = "通过用户id获取所有子集用户id")
@Parameter(name = "id", description = "用户编号", required = true, example = "1024")
CommonResult<List<Long>> getItemIdsByUserId(@RequestParam("id") Long id);
}

View File

@ -0,0 +1,29 @@
package cn.iocoder.yudao.module.crm.api.userlivetree;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.crm.service.userlivetree.UserLiveTreeService;
import cn.iocoder.yudao.module.hrm.api.userlivetree.UserLiveTreeApi;
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;
/**
* Flowable CRM Api 实现类
*/
@RestController
@Validated
public class UserLiveTreeApiImpl implements UserLiveTreeApi {
@Resource
private UserLiveTreeService userLiveTreeService;
@Override
public CommonResult<List<Long>> getItemIdsByUserId(Long id) {
return success(userLiveTreeService.getItemIdsByUserId(id));
}
}

View File

@ -14,7 +14,6 @@ public class RentalCustomerSaveReqVO {
private Long id;
@Schema(description = "客户名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "赵六")
@NotEmpty(message = "客户名称不能为空")
private String name;
@Schema(description = "手机号")

View File

@ -18,6 +18,7 @@ public interface ErrorCodeConstants {
ErrorCode SIZE_NOT_EXISTS = new ErrorCode(1_000_000_004, "规格不存在");
ErrorCode STAFF_NOT_EXISTS = new ErrorCode(1_000_000_005, "员工不存在");
ErrorCode ACCESSORIES_COLLAR_NOT_EXISTS = new ErrorCode(1_000_000_006, "配件费用不存在");
//打包线模块
ErrorCode PACKAGE_NOT_EXISTS = new ErrorCode(1_000_001_001, "打包线信息不存在");

View File

@ -0,0 +1,93 @@
package cn.iocoder.yudao.module.smartfactory.controller.admin.accessoriescollar;
import cn.hutool.core.collection.CollUtil;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.smartfactory.controller.admin.accessoriescollar.vo.AccessoriesCollarPageReqVO;
import cn.iocoder.yudao.module.smartfactory.controller.admin.accessoriescollar.vo.AccessoriesCollarRespVO;
import cn.iocoder.yudao.module.smartfactory.controller.admin.accessoriescollar.vo.AccessoriesCollarSaveReqVO;
import cn.iocoder.yudao.module.smartfactory.dal.dataobject.accessoriescollar.AccessoriesCollarDO;
import cn.iocoder.yudao.module.smartfactory.dal.dataobject.factoryinfo.FactoryInfoDO;
import cn.iocoder.yudao.module.smartfactory.service.accessoriescollar.AccessoriesCollarService;
import cn.iocoder.yudao.module.smartfactory.service.factoryinfo.FactoryInfoService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.Map;
import java.util.Set;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
@Tag(name = "管理后台 - 厂区配件领用")
@RestController
@RequestMapping("/smartfactory/accessories-collar")
@Validated
public class AccessoriesCollarController {
@Resource
private AccessoriesCollarService accessoriesCollarService;
@Resource
private FactoryInfoService factoryInfoService;
@PostMapping("/create")
@Operation(summary = "创建厂区配件领用")
@PreAuthorize("@ss.hasPermission('smartfactory:accessories-collar:create')")
public CommonResult<Long> createAccessoriesCollar(@Valid @RequestBody AccessoriesCollarSaveReqVO createReqVO) {
return success(accessoriesCollarService.createAccessoriesCollar(createReqVO));
}
@PutMapping("/update")
@Operation(summary = "更新厂区配件领用")
@PreAuthorize("@ss.hasPermission('smartfactory:accessories-collar:update')")
public CommonResult<Boolean> updateAccessoriesCollar(@Valid @RequestBody AccessoriesCollarSaveReqVO updateReqVO) {
accessoriesCollarService.updateAccessoriesCollar(updateReqVO);
return success(true);
}
@DeleteMapping("/delete")
@Operation(summary = "删除厂区配件领用")
@Parameter(name = "id", description = "编号", required = true)
@PreAuthorize("@ss.hasPermission('smartfactory:accessories-collar:delete')")
public CommonResult<Boolean> deleteAccessoriesCollar(@RequestParam("id") Long id) {
accessoriesCollarService.deleteAccessoriesCollar(id);
return success(true);
}
@GetMapping("/get")
@Operation(summary = "获得厂区配件领用")
@Parameter(name = "id", description = "编号", required = true, example = "1024")
@PreAuthorize("@ss.hasPermission('smartfactory:accessories-collar:query')")
public CommonResult<AccessoriesCollarRespVO> getAccessoriesCollar(@RequestParam("id") Long id) {
AccessoriesCollarDO accessoriesCollar = accessoriesCollarService.getAccessoriesCollar(id);
return success(BeanUtils.toBean(accessoriesCollar, AccessoriesCollarRespVO.class));
}
@GetMapping("/page")
@Operation(summary = "获得厂区配件领用分页")
@PreAuthorize("@ss.hasPermission('smartfactory:accessories-collar:query')")
public CommonResult<PageResult<AccessoriesCollarRespVO>> getAccessoriesCollarPage(@Valid AccessoriesCollarPageReqVO pageReqVO) {
PageResult<AccessoriesCollarRespVO> pageResult = BeanUtils.toBean(accessoriesCollarService.getAccessoriesCollarPage(pageReqVO), AccessoriesCollarRespVO.class);
if (CollUtil.isNotEmpty(pageResult.getList())) {
// 获取工厂编号
Set<Long> factoryIds = convertSet(pageResult.getList(), AccessoriesCollarRespVO::getFactoryId);
// 获取工厂信息
Map<Long, FactoryInfoDO> factoryMap = convertMap(factoryInfoService.getFactoryList(factoryIds), FactoryInfoDO::getId);
pageResult.getList().forEach(data -> {
// 设置工厂名称
data.setFactoryName(factoryMap.containsKey(data.getFactoryId()) ? factoryMap.get(data.getFactoryId()).getShortName() : null);
});
}
return success(BeanUtils.toBean(pageResult, AccessoriesCollarRespVO.class));
}
}

View File

@ -0,0 +1,33 @@
package cn.iocoder.yudao.module.smartfactory.controller.admin.accessoriescollar.vo;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.ToString;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@Schema(description = "管理后台 - 厂区配件领用分页 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class AccessoriesCollarPageReqVO extends PageParam {
@Schema(description = "工厂编号", example = "10000008")
private Long factoryId;
@Schema(description = "领用月份 | YYYY-MM")
private String month;
@Schema(description = "状态 | 0未确认 1已确认", example = "0")
private Integer status;
@Schema(description = "创建时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime;
}

View File

@ -0,0 +1,51 @@
package cn.iocoder.yudao.module.smartfactory.controller.admin.accessoriescollar.vo;
import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
import com.alibaba.excel.annotation.ExcelProperty;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.math.BigDecimal;
import java.time.LocalDateTime;
@Schema(description = "管理后台 - 厂区配件领用 Response VO")
@Data
@ExcelIgnoreUnannotated
public class AccessoriesCollarRespVO {
@Schema(description = "厂区配件领用表单主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
@ExcelProperty("厂区配件领用表单主键")
private Long id;
@Schema(description = "工厂编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10000008")
@ExcelProperty("工厂编号")
private Long factoryId;
@Schema(description = "工厂名称", example = "工厂名称")
private String factoryName;
@Schema(description = "领用月份 | YYYY-MM")
@ExcelProperty("领用月份 | YYYY-MM")
private String month;
@Schema(description = "叉车配件费用")
@ExcelProperty("叉车配件费用")
private BigDecimal forkliftAccessories;
@Schema(description = "打包配件费用")
@ExcelProperty("打包配件费用")
private BigDecimal packageAccessories;
@Schema(description = "搬运劳保费用")
@ExcelProperty("搬运劳保费用")
private BigDecimal transportationAmount;
@Schema(description = "状态 | 0未确认 1已确认", example = "0")
@ExcelProperty("状态 | 0未确认 1已确认")
private Integer status;
@Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
@ExcelProperty("创建时间")
private LocalDateTime createTime;
}

View File

@ -0,0 +1,35 @@
package cn.iocoder.yudao.module.smartfactory.controller.admin.accessoriescollar.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;
@Schema(description = "管理后台 - 厂区配件领用新增/修改 Request VO")
@Data
public class AccessoriesCollarSaveReqVO {
@Schema(description = "厂区配件领用表单主键", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
private Long id;
@Schema(description = "工厂编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "10000008")
@NotNull(message = "工厂编号不能为空")
private Long factoryId;
@Schema(description = "领用月份 | YYYY-MM")
private String month;
@Schema(description = "叉车配件费用")
private BigDecimal forkliftAccessories;
@Schema(description = "打包配件费用")
private BigDecimal packageAccessories;
@Schema(description = "搬运劳保费用")
private BigDecimal transportationAmount;
@Schema(description = "状态 | 0未确认 1已确认", example = "0")
private Integer status;
}

View File

@ -153,6 +153,17 @@ public class FactoryInfoController {
return success(BeanUtils.toBean(pageResult, FactoryInfoRespVO.class));
}
@GetMapping("/get-profit")
@Operation(summary = "获得工厂每月利润")
@Parameter(name = "factoryId", description = "工厂编号")
@Parameter(name = "month", description = "查询月份")
@PreAuthorize("@ss.hasPermission('smartfactory:factory-info:query')")
public CommonResult<List<FactoryProfitVO>> getProfit(@RequestParam(name = "factoryId", required = false) Long factoryId,
@RequestParam("month") String month) {
return success(factoryInfoService.getProfit(factoryId, month));
}
@GetMapping("/export-excel")
@Operation(summary = "导出工厂信息 Excel")
@PreAuthorize("@ss.hasPermission('smartfactory:factory-info:export')")

View File

@ -0,0 +1,107 @@
package cn.iocoder.yudao.module.smartfactory.controller.admin.factoryinfo.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.math.BigDecimal;
@Schema(description = "管理后台 - 工厂利润VO")
@Data
public class FactoryProfitVO {
@Schema(description = "工厂编号", example = "1024")
private Long factoryId;
@Schema(description = "工厂名称", example = "芋道")
private String factoryName;
@Schema(description = "结算月份", example = "2023-01")
private String settlementMonth;
@Schema(description = "叉车收入", example = "10000")
private BigDecimal forkliftRevenue;
@Schema(description = "打包收入", example = "10000")
private BigDecimal packageRevenue;
@Schema(description = "搬运收入")
private BigDecimal porterageRevenue;
@Schema(description = "叉车租赁收入")
private BigDecimal forkliftRentalRevenue;
@Schema(description = "运输收入")
private BigDecimal transportationRevenue;
@Schema(description = "叉车扣款")
private BigDecimal forkliftDeduction;
@Schema(description = "打包扣款")
private BigDecimal packageDeduction;
@Schema(description = "搬运扣款")
private BigDecimal porterageDeduction;
@Schema(description = "水电扣款")
private BigDecimal hydropower;
@Schema(description = "工伤保险")
private BigDecimal employment;
@Schema(description = "其他(理赔、扣点)")
private BigDecimal other;
@Schema(description = "叉车工资")
private BigDecimal forkliftSalary;
@Schema(description = "打包工资")
private BigDecimal packageSalary;
@Schema(description = "搬运工资")
private BigDecimal porterageSalary;
@Schema(description = "运输工资")
private BigDecimal transportSalary;
@Schema(description = "其他工资")
private BigDecimal otherSalary;
@Schema(description = "叉车配件")
private BigDecimal forkliftAccessories;
@Schema(description = "打包配件")
private BigDecimal packageAccessories;
@Schema(description = "搬运劳保")
private BigDecimal transportationAmount;
@Schema(description = "工伤赔偿")
private BigDecimal injuryAmount;
@Schema(description = "借支")
private BigDecimal loanAmount;
@Schema(description = "差旅费用")
private BigDecimal travelExpenses;
@Schema(description = "其他")
private BigDecimal otherAmount;
@Schema(description = "叉车支出")
private BigDecimal forkliftExpenses;
@Schema(description = "打包支出")
private BigDecimal packageExpenses;
@Schema(description = "搬运支出")
private BigDecimal transportationExpenses;
@Schema(description = "叉车毛利")
private BigDecimal forkliftGrossProfit;
@Schema(description = "打包毛利")
private BigDecimal packageGrossProfit;
@Schema(description = "搬运毛利")
private BigDecimal porterageGrossProfit;
}

View File

@ -110,7 +110,7 @@ public class StaffController {
Map<Long, FactoryInfoDO> factoryInfoMap = convertMap(factoryInfoService.getFactoryList(factoryIds), FactoryInfoDO::getId);
result.getList().forEach(data -> {
// 设置工厂名称
data.setFactoryName(factoryInfoMap.containsKey(data.getFactoryId()) ? factoryInfoMap.get(data.getFactoryId()).getName() : null);
data.setFactoryName(factoryInfoMap.containsKey(data.getFactoryId()) ? factoryInfoMap.get(data.getFactoryId()).getShortName() : null);
});
}

View File

@ -0,0 +1,56 @@
package cn.iocoder.yudao.module.smartfactory.dal.dataobject.accessoriescollar;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
import com.baomidou.mybatisplus.annotation.KeySequence;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.*;
import java.math.BigDecimal;
/**
* 厂区配件领用 DO
*
* @author 符溶馨
*/
@TableName("sf_accessories_collar")
@KeySequence("sf_accessories_collar_seq") // 用于 OraclePostgreSQLKingbaseDB2H2 数据库的主键自增如果是 MySQL 等数据库可不写
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class AccessoriesCollarDO extends BaseDO {
/**
* 厂区配件领用表单主键
*/
@TableId
private Long id;
/**
* 工厂编号
*/
private Long factoryId;
/**
* 领用月份 | YYYY-MM
*/
private String month;
/**
* 叉车配件费用
*/
private BigDecimal forkliftAccessories;
/**
* 打包配件费用
*/
private BigDecimal packageAccessories;
/**
* 搬运劳保费用
*/
private BigDecimal transportationAmount;
/**
* 状态 | 0未确认 1已确认
*/
private Integer status;
}

View File

@ -0,0 +1,27 @@
package cn.iocoder.yudao.module.smartfactory.dal.mysql.accessoriescollar;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.smartfactory.controller.admin.accessoriescollar.vo.AccessoriesCollarPageReqVO;
import cn.iocoder.yudao.module.smartfactory.dal.dataobject.accessoriescollar.AccessoriesCollarDO;
import org.apache.ibatis.annotations.Mapper;
/**
* 厂区配件领用 Mapper
*
* @author 符溶馨
*/
@Mapper
public interface AccessoriesCollarMapper extends BaseMapperX<AccessoriesCollarDO> {
default PageResult<AccessoriesCollarDO> selectPage(AccessoriesCollarPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<AccessoriesCollarDO>()
.eqIfPresent(AccessoriesCollarDO::getFactoryId, reqVO.getFactoryId())
.eqIfPresent(AccessoriesCollarDO::getMonth, reqVO.getMonth())
.eqIfPresent(AccessoriesCollarDO::getStatus, reqVO.getStatus())
.betweenIfPresent(AccessoriesCollarDO::getCreateTime, reqVO.getCreateTime())
.orderByDesc(AccessoriesCollarDO::getId));
}
}

View File

@ -5,6 +5,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
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.FactoryProfitVO;
import cn.iocoder.yudao.module.smartfactory.controller.admin.screendata.factory.vo.FactoryRollDataRespVO;
import cn.iocoder.yudao.module.smartfactory.dal.dataobject.factoryinfo.FactoryInfoDO;
import org.apache.ibatis.annotations.Mapper;
@ -53,4 +54,7 @@ public interface FactoryInfoMapper extends BaseMapperX<FactoryInfoDO> {
* @return 返回与给定工厂ID相关联的天气代码类型为String
*/
String getWeatherCodeByFactoryId(@Param("factoryId") Long factoryId, @Param("areaCode") String areaCode);
List<FactoryProfitVO> selectProfit(@Param("factoryId") Long factoryId,
@Param("month") String month);
}

View File

@ -0,0 +1,55 @@
package cn.iocoder.yudao.module.smartfactory.service.accessoriescollar;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.smartfactory.controller.admin.accessoriescollar.vo.AccessoriesCollarPageReqVO;
import cn.iocoder.yudao.module.smartfactory.controller.admin.accessoriescollar.vo.AccessoriesCollarSaveReqVO;
import cn.iocoder.yudao.module.smartfactory.dal.dataobject.accessoriescollar.AccessoriesCollarDO;
import javax.validation.Valid;
/**
* 厂区配件领用 Service 接口
*
* @author 符溶馨
*/
public interface AccessoriesCollarService {
/**
* 创建厂区配件领用
*
* @param createReqVO 创建信息
* @return 编号
*/
Long createAccessoriesCollar(@Valid AccessoriesCollarSaveReqVO createReqVO);
/**
* 更新厂区配件领用
*
* @param updateReqVO 更新信息
*/
void updateAccessoriesCollar(@Valid AccessoriesCollarSaveReqVO updateReqVO);
/**
* 删除厂区配件领用
*
* @param id 编号
*/
void deleteAccessoriesCollar(Long id);
/**
* 获得厂区配件领用
*
* @param id 编号
* @return 厂区配件领用
*/
AccessoriesCollarDO getAccessoriesCollar(Long id);
/**
* 获得厂区配件领用分页
*
* @param pageReqVO 分页查询
* @return 厂区配件领用分页
*/
PageResult<AccessoriesCollarDO> getAccessoriesCollarPage(AccessoriesCollarPageReqVO pageReqVO);
}

View File

@ -0,0 +1,71 @@
package cn.iocoder.yudao.module.smartfactory.service.accessoriescollar;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.smartfactory.controller.admin.accessoriescollar.vo.AccessoriesCollarPageReqVO;
import cn.iocoder.yudao.module.smartfactory.controller.admin.accessoriescollar.vo.AccessoriesCollarSaveReqVO;
import cn.iocoder.yudao.module.smartfactory.dal.dataobject.accessoriescollar.AccessoriesCollarDO;
import cn.iocoder.yudao.module.smartfactory.dal.mysql.accessoriescollar.AccessoriesCollarMapper;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import javax.annotation.Resource;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.module.smartfactory.enums.ErrorCodeConstants.ACCESSORIES_COLLAR_NOT_EXISTS;
/**
* 厂区配件领用 Service 实现类
*
* @author 符溶馨
*/
@Service
@Validated
public class AccessoriesCollarServiceImpl implements AccessoriesCollarService {
@Resource
private AccessoriesCollarMapper accessoriesCollarMapper;
@Override
public Long createAccessoriesCollar(AccessoriesCollarSaveReqVO createReqVO) {
// 插入
AccessoriesCollarDO accessoriesCollar = BeanUtils.toBean(createReqVO, AccessoriesCollarDO.class);
accessoriesCollarMapper.insert(accessoriesCollar);
// 返回
return accessoriesCollar.getId();
}
@Override
public void updateAccessoriesCollar(AccessoriesCollarSaveReqVO updateReqVO) {
// 校验存在
validateAccessoriesCollarExists(updateReqVO.getId());
// 更新
AccessoriesCollarDO updateObj = BeanUtils.toBean(updateReqVO, AccessoriesCollarDO.class);
accessoriesCollarMapper.updateById(updateObj);
}
@Override
public void deleteAccessoriesCollar(Long id) {
// 校验存在
validateAccessoriesCollarExists(id);
// 删除
accessoriesCollarMapper.deleteById(id);
}
private void validateAccessoriesCollarExists(Long id) {
if (accessoriesCollarMapper.selectById(id) == null) {
throw exception(ACCESSORIES_COLLAR_NOT_EXISTS);
}
}
@Override
public AccessoriesCollarDO getAccessoriesCollar(Long id) {
return accessoriesCollarMapper.selectById(id);
}
@Override
public PageResult<AccessoriesCollarDO> getAccessoriesCollarPage(AccessoriesCollarPageReqVO pageReqVO) {
return accessoriesCollarMapper.selectPage(pageReqVO);
}
}

View File

@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.smartfactory.service.factoryinfo;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
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.screendata.factory.vo.FactoryRollDataRespVO;
import cn.iocoder.yudao.module.smartfactory.controller.admin.screendata.factory.vo.ProvincesDataRespVO;
@ -136,4 +137,13 @@ public interface FactoryInfoService {
* @param updateReqVO 更新信息
*/
void updateFactoryStatus(FactoryUpdateStatusReqVO updateReqVO);
/**
* 工厂每月利润
*
* @param factoryId 工厂编号
* @param month 月份
* @return 利润列表
*/
List<FactoryProfitVO> getProfit(Long factoryId, String month);
}

View File

@ -1,5 +1,6 @@
package cn.iocoder.yudao.module.smartfactory.service.factoryinfo;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
import cn.iocoder.yudao.framework.common.enums.DeptTypeEnum;
@ -10,6 +11,7 @@ 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.screendata.factory.vo.FactoryRollDataRespVO;
import cn.iocoder.yudao.module.smartfactory.controller.admin.screendata.factory.vo.ProvincesDataRespVO;
@ -280,4 +282,32 @@ public class FactoryInfoServiceImpl implements FactoryInfoService {
deptRespDTO.setStatus(updateReqVO.getStatus());
deptApi.updateFactoryDept(deptRespDTO);
}
@Override
public List<FactoryProfitVO> getProfit(Long factoryId, String month) {
List<FactoryProfitVO> result = factoryInfoMapper.selectProfit(factoryId, month);
if (CollUtil.isNotEmpty(result)) {
// 设置叉车毛利打包毛利搬运毛利 = 收入 - 扣款 - 人员工资 - 支出
result.forEach(vo -> {
// 设置叉车毛利
vo.setForkliftGrossProfit(vo.getForkliftRevenue()
.subtract(vo.getForkliftDeduction())
.subtract(vo.getForkliftSalary())
.subtract(vo.getForkliftExpenses()));
// 设置打包毛利
vo.setPackageGrossProfit(vo.getPackageRevenue()
.subtract(vo.getPackageDeduction())
.subtract(vo.getPackageSalary())
.subtract(vo.getPackageExpenses()));
// 设置搬运毛利
vo.setPorterageGrossProfit(vo.getPorterageRevenue()
.subtract(vo.getPorterageDeduction())
.subtract(vo.getPorterageSalary())
.subtract(vo.getTransportationExpenses()));
});
}
return result;
}
}

View File

@ -110,7 +110,9 @@ public class StaffServiceImpl implements StaffService {
// 设置工种名称
dos.forEach(item -> {
item.setPostName(workTypeMap.getOrDefault(item.getWorkTypeId().toString(), ""));
if (item.getWorkTypeId() != null) {
item.setPostName(workTypeMap.getOrDefault(item.getWorkTypeId().toString(), ""));
}
});
vo.setTotal(dos.size());

View File

@ -31,4 +31,120 @@
left join sf_factory_info as b on a.code = #{areaCode}
where b.id = #{factoryId}
</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
)
SELECT
scs.customer_id AS factoryId,
factory.short_name AS factoryName,
scs.settlement_month,-- 收入明细
SUM( CASE WHEN ssi.business_type = 1 THEN ssi.settlement_amount ELSE 0 END ) AS forkliftRevenue,-- 叉车收入
SUM( CASE WHEN ssi.business_type = 2 THEN ssi.settlement_amount ELSE 0 END ) AS packageRevenue,-- 打包收入
SUM( CASE WHEN ssi.business_type = 3 THEN ssi.settlement_amount ELSE 0 END ) AS porterageRevenue,-- 搬运收入
SUM( CASE WHEN ssi.business_type = 4 THEN ssi.settlement_amount ELSE 0 END ) AS forkliftRentalRevenue,-- 叉车租赁收入
SUM( CASE WHEN ssi.business_type = 5 THEN ssi.settlement_amount ELSE 0 END ) AS transportationRevenue,-- 运输收入
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,-- 其他(理赔、扣点)
COALESCE ( sss.forkliftSalary, 0.00 ) AS forkliftSalary,-- 叉车实发工资
COALESCE ( sss.packageSalary, 0.00 ) AS packageSalary,-- 打包实发工资
COALESCE ( sss.porterageSalary, 0.00 ) AS porterageSalary,-- 搬运实发工资
COALESCE ( sss.transportSalary, 0.00 ) AS transportSalary,-- 运输实发工资
COALESCE ( sss.otherSalary, 0.00 ) AS otherSalary,-- 其他实发工资
COALESCE ( iii.forkliftAccessories + sac.forklift_accessories, 0.00 ) AS forkliftAccessories, -- 叉车配件
COALESCE ( iii.packageAccessories + sac.package_accessories, 0.00 ) AS packageAccessories, -- 打包配件
COALESCE ( iii.transportationAmount + sac.transportation_amount, 0.00 ) AS transportationAmount, -- 搬运劳保
COALESCE ( iii.injuryAmount, 0.00 ) AS injuryAmount, -- 工伤赔偿
COALESCE ( loan.loanAmount, 0.00 ) AS loanAmount, -- 工资及借支
COALESCE ( iii.travelExpenses, 0.00 ) AS travelExpenses, -- 差旅费用
COALESCE ( iii.otherAmount, 0.00 ) AS otherAmount, -- 其他
COALESCE ( iii.forkliftExpenses + sac.forklift_accessories, 0.00 ) AS forkliftExpenses, -- 叉车支出
COALESCE ( iii.packageExpenses + sac.package_accessories, 0.00 ) AS packageExpenses, -- 打包支出
COALESCE ( iii.transportationExpenses + sac.transportation_amount, 0.00 ) AS transportationExpenses -- 搬运支出
FROM
system_customer_settlement scs
LEFT JOIN sf_factory_info factory ON scs.customer_id = factory.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 (
SELECT
s.factory_id,
ss.month,
SUM( CASE WHEN s.business_type = 2 THEN ss.payable_amount - ss.deduction_amount ELSE 0 END ) AS forkliftSalary,-- 叉车实发工资
SUM( CASE WHEN s.business_type = 1 THEN ss.payable_amount - ss.deduction_amount ELSE 0 END ) AS packageSalary,-- 打包实发工资
SUM( CASE WHEN s.business_type = 3 THEN ss.payable_amount - ss.deduction_amount ELSE 0 END ) AS porterageSalary,-- 搬运实发工资
SUM( CASE WHEN s.business_type = 5 THEN ss.payable_amount - ss.deduction_amount ELSE 0 END ) AS transportSalary,-- 运输实发工资
SUM( CASE WHEN ISNULL( s.business_type ) THEN ss.payable_amount - ss.deduction_amount ELSE 0 END ) AS otherSalary -- 其他实发工资
FROM
sf_staff s
JOIN sf_staff_salary ss ON s.id = ss.staff_id
WHERE
1 = 1
GROUP BY
s.factory_id,
ss.month
) sss ON scs.customer_id = sss.factory_id
AND scs.settlement_month = sss.month
LEFT JOIN (
SELECT
boei.dept_id,
DATE_FORMAT( boei.application_date, '%Y-%m' ) AS month,
SUM( CASE WHEN boei.type = 1 THEN boei.total_money ELSE 0 END ) AS forkliftAccessories,-- 叉车配件
SUM( CASE WHEN boei.type = 2 THEN boei.total_money ELSE 0 END ) AS packageAccessories,-- 打包配件
SUM( CASE WHEN boei.type = 6 AND boei.cost_section = 3 THEN boei.total_money ELSE 0 END ) AS transportationAmount,-- 搬运劳保
SUM( CASE WHEN boei.type = 7 THEN boei.total_money ELSE 0 END ) AS injuryAmount,-- 工伤赔偿
SUM( CASE WHEN boei.type = 11 THEN boei.total_money ELSE 0 END ) AS travelExpenses,-- 差旅费用
SUM( CASE WHEN boei.type IN (3,4,5,8,9,10,12) AND ( boei.type = 6 AND boei.cost_section &lt;&gt; 3 ) THEN boei.total_money ELSE 0 END ) AS otherAmount, -- 其他
SUM( CASE WHEN boei.cost_section = 1 THEN boei.total_money ELSE 0 END ) AS forkliftExpenses, -- 叉车支出
SUM( CASE WHEN boei.cost_section = 2 THEN boei.total_money ELSE 0 END ) AS packageExpenses, -- 打包支出
SUM( CASE WHEN boei.cost_section = 3 THEN boei.total_money ELSE 0 END ) AS transportationExpenses -- 搬运支出
FROM
bpm_oa_expenses_item boei
JOIN bpm_oa_expenses boe ON boei.expenses_id = boe.id
WHERE
boe.deleted = 0
and boe.result = 2
GROUP BY
boei.dept_id,
DATE_FORMAT( boei.application_date, '%Y-%m' )
) iii ON scs.customer_id = iii.dept_id
AND scs.settlement_month = iii.MONTH
LEFT JOIN (
SELECT
oaLoan.total_money as loanAmount,
oaLoan.factory_id as factoryId,
DATE_FORMAT( bp.end_time, '%Y-%m' ) as endTime
FROM
bpm_oa_loan oaLoan,
bpm_process_instance_ext bp
WHERE
oaLoan.process_instance_id = bp.process_instance_id
AND oaLoan.deleted = 0
AND oaLoan.result = 2
) loan ON scs.customer_id = loan.factoryId
AND scs.settlement_month = loan.endTime
LEFT JOIN sf_accessories_collar sac ON sac.factory_id = scs.customer_id
AND scs.settlement_month = sac.month
AND sac.status = 1
AND sac.deleted = 0
WHERE
scs.settlement_month = #{month}
<if test="factoryId != null">
AND scs.customer_id = #{factoryId}
</if>
GROUP BY
scs.id;
</select>
</mapper>