更新
This commit is contained in:
parent
c39663d616
commit
3c8d315876
@ -16,4 +16,13 @@ public class RepairConstants {
|
||||
* 维修类型B
|
||||
*/
|
||||
public static final String REPAIR_TYPE_B = "02";
|
||||
|
||||
/**
|
||||
* 子表类型 -工时项目
|
||||
*/
|
||||
public static final String ITEM_TYPE_WORK = "01";
|
||||
/**
|
||||
* 子表类型 -配件项目
|
||||
*/
|
||||
public static final String ITEM_TYPE_WARE = "02";
|
||||
}
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package cn.iocoder.yudao.module.base.service;
|
||||
|
||||
import cn.iocoder.yudao.module.base.entity.StaffStatisticsResp;
|
||||
import cn.iocoder.yudao.module.base.service.impl.InventoryStatisticsVO;
|
||||
import cn.iocoder.yudao.module.base.vo.*;
|
||||
import cn.iocoder.yudao.module.tickets.entity.DlRepairTickets;
|
||||
import cn.iocoder.yudao.module.tickets.vo.DlRepairTicketsRespVO;
|
||||
|
||||
@ -90,4 +90,10 @@ public class DlRepairSoi extends TenantBaseDO {
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private String houseName;
|
||||
|
||||
/**
|
||||
* 销售价格
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private BigDecimal salePrice;
|
||||
}
|
||||
|
||||
@ -490,12 +490,14 @@ public class DlRepairSoServiceImpl extends ServiceImpl<DlRepairSoMapper, DlRepai
|
||||
//工单现有配件中就有这个领取的配件,需要更新这个配件的数量、价格
|
||||
DlRepairTitem item = itemMap.get(repairSoi.getGoodsId());
|
||||
item.setItemCount(item.getItemCount() + repairSoi.getGoodsCount());
|
||||
item.setItemMoney(item.getItemPrice().multiply(BigDecimal.valueOf(item.getItemCount())).multiply(item.getItemDiscount()));
|
||||
BigDecimal itemPrice = repairSoi.getGoodsPrice() != null ? repairSoi.getGoodsPrice() : item.getItemPrice();
|
||||
item.setItemPrice(itemPrice);
|
||||
item.setItemMoney(itemPrice.multiply(BigDecimal.valueOf(item.getItemCount())).multiply(item.getItemDiscount()));
|
||||
item.setItemStatus(TicketsItemStatusEnum.RECEIVED.getCode());
|
||||
|
||||
|
||||
// 获取配件的售价和进价
|
||||
BigDecimal salePrice = repairWaresMap.get(repairSoi.getGoodsId()).getPrice(); // 售价
|
||||
BigDecimal salePrice = repairSoi.getGoodsPrice() != null ? repairSoi.getGoodsPrice() : repairWaresMap.get(repairSoi.getGoodsId()).getPrice(); // 售价
|
||||
BigDecimal purchasePrice = repairWaresMap.get(repairSoi.getGoodsId()).getPurPrice(); // 进价
|
||||
|
||||
//计算利润
|
||||
@ -514,11 +516,13 @@ public class DlRepairSoServiceImpl extends ServiceImpl<DlRepairSoMapper, DlRepai
|
||||
if (item.getItemCount() > repairSoi.getGoodsCount()) {
|
||||
//现有数量大于要退的数量,扣掉
|
||||
item.setItemCount(item.getItemCount() - repairSoi.getGoodsCount());
|
||||
BigDecimal itemPrice = repairSoi.getGoodsPrice() != null ? repairSoi.getGoodsPrice() : item.getItemPrice();
|
||||
item.setItemPrice(itemPrice);
|
||||
item.setItemMoney(item.getItemPrice().multiply(BigDecimal.valueOf(item.getItemCount())).multiply(item.getItemDiscount()));
|
||||
item.setItemStatus(TicketsItemStatusEnum.RECEIVED.getCode());
|
||||
|
||||
// 重新计算利润和利润率
|
||||
BigDecimal salePrice = repairWaresMap.get(repairSoi.getGoodsId()).getPrice(); // 售价
|
||||
BigDecimal salePrice = repairSoi.getGoodsPrice() != null ? repairSoi.getGoodsPrice() : repairWaresMap.get(repairSoi.getGoodsId()).getPrice(); // 售价
|
||||
BigDecimal purchasePrice = repairWaresMap.get(repairSoi.getGoodsId()).getPurPrice(); // 进价
|
||||
|
||||
//计算利润
|
||||
@ -561,7 +565,7 @@ public class DlRepairSoServiceImpl extends ServiceImpl<DlRepairSoMapper, DlRepai
|
||||
titem.setItemStatus(TicketsItemStatusEnum.RECEIVED.getCode());
|
||||
|
||||
// 获取售价和进价
|
||||
BigDecimal salePrice = waresItem.getPrice(); // 售价
|
||||
BigDecimal salePrice = titem.getItemPrice(); // 售价
|
||||
BigDecimal purchasePrice = waresItem.getPurPrice(); // 进价
|
||||
|
||||
//计算利润
|
||||
|
||||
@ -212,4 +212,16 @@ public class DlRepairTitemController {
|
||||
public CommonResult<?> getTeamProgressWithItems(@RequestParam("ticketId") String ticketId) {
|
||||
return success(dlRepairTicketsService.getTeamProgressWithItems(ticketId));
|
||||
}
|
||||
|
||||
/**
|
||||
* @description : 查询未完成项目根据工单id
|
||||
* @author xyc
|
||||
* @date 10:20 2025/11/24
|
||||
* @param [ticketId]
|
||||
* @return cn.iocoder.yudao.framework.common.pojo.CommonResult<?>
|
||||
**/
|
||||
@GetMapping("/getUnfinishedProjectsByTicketId")
|
||||
public CommonResult<?> getUnfinishedProjectsByTicketId(@RequestParam("ticketId") String ticketId) {
|
||||
return success(dlRepairTitemService.getProjectsByTicketId(ticketId, SecurityFrameworkUtils.getLoginUserId()));
|
||||
}
|
||||
}
|
||||
|
||||
@ -61,6 +61,15 @@ public interface DlRepairTitemMapper extends BaseMapper<DlRepairTitem> {
|
||||
* @return java.util.List<cn.iocoder.yudao.module.tickets.entity.DlRepairTitem>
|
||||
**/
|
||||
List<DlRepairTitem> selectProjectByTicketIds(@Param("ticketIds") List<String> ticketIds);
|
||||
|
||||
/**
|
||||
* @description : 查询未完成项目
|
||||
* @author xyc
|
||||
* @date 10:33 2025/11/24
|
||||
* @param [ticketId, userId]
|
||||
* @return java.util.List<cn.iocoder.yudao.module.tickets.entity.DlRepairTitem>
|
||||
**/
|
||||
List<DlRepairTitem> getProjectsByTicketId(@Param("ticketId") String ticketId, @Param("userId") Long userId);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -83,4 +83,13 @@ public interface DlRepairTitemService extends IService<DlRepairTitem> {
|
||||
* @return java.util.List<cn.iocoder.yudao.module.tickets.entity.DlRepairTitem>
|
||||
**/
|
||||
List<DlRepairTitemRespVO> getProjList(String ticketId,String isOpen);
|
||||
|
||||
/**
|
||||
* @description : 查询未完成项目
|
||||
* @author xyc
|
||||
* @date 10:22 2025/11/24
|
||||
* @param [ticketId, userId]
|
||||
* @return java.util.List<cn.iocoder.yudao.module.tickets.entity.DlRepairTitem>
|
||||
**/
|
||||
List<DlRepairTitem> getProjectsByTicketId(String ticketId, Long userId);
|
||||
}
|
||||
|
||||
@ -322,6 +322,8 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl<DlRepairTicketsMappe
|
||||
ticketsRespVO.setTicketsStatus(TicketsStatusEnum.OVER.getCode());
|
||||
// 支付状态 默认是已收款
|
||||
ticketsRespVO.setPayStatus(TicketsPayStatusEnum.RECEIVED.getCode());
|
||||
// 完成
|
||||
ticketsRespVO.setIsFinish("1");
|
||||
}
|
||||
|
||||
// 新增主表
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
package cn.iocoder.yudao.module.tickets.service.impl;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.iocoder.yudao.common.RepairConstants;
|
||||
import cn.iocoder.yudao.common.TicketsItemStatusEnum;
|
||||
import cn.iocoder.yudao.module.tickets.entity.DlRepairTitem;
|
||||
import cn.iocoder.yudao.module.tickets.mapper.DlRepairTitemMapper;
|
||||
import cn.iocoder.yudao.module.tickets.service.DlRepairTicketsService;
|
||||
@ -10,6 +12,7 @@ import cn.iocoder.yudao.module.tickets.vo.DlRepairTitemRespVO;
|
||||
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -17,6 +20,7 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception0;
|
||||
@ -163,6 +167,18 @@ public class DlRepairTitemServiceImpl extends ServiceImpl<DlRepairTitemMapper, D
|
||||
public List<DlRepairTitemRespVO> getProjList(String ticketId,String isOpen) {
|
||||
return dlRepairTitemMapper.selectProjList(ticketId,isOpen);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param ticketId
|
||||
* @return java.util.List<cn.iocoder.yudao.module.tickets.entity.DlRepairTitem>
|
||||
* @description : 查询未完成项目
|
||||
* @author xyc
|
||||
* @date 10:22 2025/11/24
|
||||
**/
|
||||
@Override
|
||||
public List<DlRepairTitem> getProjectsByTicketId(String ticketId, Long userId) {
|
||||
return baseMapper.getProjectsByTicketId(ticketId,userId);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -397,35 +397,44 @@ public class DlTicketWaresServiceImpl extends ServiceImpl<DlTicketWaresMapper, D
|
||||
// 把单据类型先取出来(02是领料,04是退料)
|
||||
String type = respVO.getRepairSo().getSoType();
|
||||
// 查工单子表中的配件信息
|
||||
List<DlRepairTitem> list = repairTitemService.list(new LambdaQueryWrapper<DlRepairTitem>().and(i -> {
|
||||
i.eq(DlRepairTitem::getTicketId, respVO.getTicketId())
|
||||
.in(DlRepairTitem::getPartId, respVO.getRepairSois()
|
||||
.stream()
|
||||
.map(DlRepairSoi::getGoodsId)
|
||||
.collect(Collectors.toList()));
|
||||
})
|
||||
);
|
||||
// 计算总价 (通知领料的数量可能和请求的不一样,所以需要这样计算)
|
||||
BigDecimal reduce = list.stream()
|
||||
/*
|
||||
item:维修工单子表中的每一个配件
|
||||
map中是找到与item对应的领料单子表的配件,记soi
|
||||
将item的价格设置给soi的价格
|
||||
*/
|
||||
.map(item -> {
|
||||
DlRepairSoi repairSoi = respVO.getRepairSois().stream()
|
||||
.filter(i -> i.getGoodsId().equals(item.getPartId())).findFirst()
|
||||
.orElse(null);
|
||||
if (repairSoi != null) {
|
||||
repairSoi.setGoodsPrice(item.getItemPrice());
|
||||
}
|
||||
return repairSoi;
|
||||
})
|
||||
// List<DlRepairTitem> list = repairTitemService.list(new LambdaQueryWrapper<DlRepairTitem>().and(i -> {
|
||||
// i.eq(DlRepairTitem::getTicketId, respVO.getTicketId())
|
||||
// .in(DlRepairTitem::getPartId, respVO.getRepairSois()
|
||||
// .stream()
|
||||
// .map(DlRepairSoi::getGoodsId)
|
||||
// .collect(Collectors.toList()));
|
||||
// })
|
||||
// );
|
||||
// // 计算总价 (通知领料的数量可能和请求的不一样,所以需要这样计算)
|
||||
// BigDecimal reduce = list.stream()
|
||||
// /*
|
||||
// item:维修工单子表中的每一个配件
|
||||
// map中是找到与item对应的领料单子表的配件,记soi
|
||||
// 将item的价格设置给soi的价格
|
||||
// */
|
||||
// .map(item -> {
|
||||
// DlRepairSoi repairSoi = respVO.getRepairSois().stream()
|
||||
// .filter(i -> i.getGoodsId().equals(item.getPartId())).findFirst()
|
||||
// .orElse(null);
|
||||
// if (repairSoi != null) {
|
||||
// repairSoi.setGoodsPrice(item.getItemPrice());
|
||||
// }
|
||||
// return repairSoi;
|
||||
// })
|
||||
// .filter(Objects::nonNull)
|
||||
// // 计算soi的价格
|
||||
// .map(i -> new BigDecimal(i.getGoodsCount()).multiply(i.getGoodsPrice()))
|
||||
// // 计算总价
|
||||
// .reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
// 修改计算逻辑 根据getRepairSois中的salePrice金额来计算总价
|
||||
BigDecimal reduce = respVO.getRepairSois().stream()
|
||||
// 过滤出非空的 repairSoi 项
|
||||
.filter(Objects::nonNull)
|
||||
// 计算soi的价格
|
||||
// 计算 salePrice 与 goodsCount 的乘积
|
||||
.map(i -> new BigDecimal(i.getGoodsCount()).multiply(i.getGoodsPrice()))
|
||||
// 计算总价
|
||||
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
|
||||
// 生成领料单、退料单
|
||||
respVO.getRepairSo().setTotalPrice(reduce);
|
||||
respVO.getRepairSo().setItemCount(respVO.getRepairSois().stream().mapToInt(DlRepairSoi::getGoodsCount).sum());
|
||||
|
||||
@ -116,4 +116,5 @@ public class DlRepairTicketsRespVO extends DlRepairTickets {
|
||||
/** 开票备注 */
|
||||
private String billedRemark;
|
||||
private Integer hasChildTickets;
|
||||
private List<DlRepairTicketsRespVO> bTickets;
|
||||
}
|
||||
|
||||
@ -139,6 +139,7 @@
|
||||
<result property="hasChildTickets" column="hasChildTickets" />
|
||||
<association property="booking" javaType="cn.iocoder.yudao.module.booking.entity.DlRepairBooking" select="selectBookingById" column="id"/>
|
||||
<collection property="itemList" column="id" ofType="cn.iocoder.yudao.module.tickets.entity.DlRepairTitem" select="selectItemList" />
|
||||
<collection property="bTickets" column="id" ofType="cn.iocoder.yudao.module.tickets.entity.DlRepairTickets" select="selectATicketsList" />
|
||||
</resultMap>
|
||||
|
||||
<sql id="Base_SQL">
|
||||
@ -434,6 +435,13 @@
|
||||
order by drt.update_time desc
|
||||
</select>
|
||||
|
||||
<select id="selectATicketsList" resultType="cn.iocoder.yudao.module.tickets.entity.DlRepairTickets">
|
||||
select drt.*
|
||||
from dl_repair_tickets drt
|
||||
where drt.deleted = '0'
|
||||
and drt.parent_ticket_id = #{id}
|
||||
</select>
|
||||
|
||||
<select id="selectItemList" resultType="cn.iocoder.yudao.module.tickets.entity.DlRepairTitem">
|
||||
select drti.*,drw.work_type AS workerType
|
||||
from dl_repair_titem drti
|
||||
@ -613,6 +621,9 @@
|
||||
<if test="map.insuranceCompany != null and map.insuranceCompany != ''">
|
||||
AND drt.insurance_company = #{map.insuranceCompany}
|
||||
</if>
|
||||
<if test="map.ticketType != null and map.ticketType != ''">
|
||||
AND drt.ticket_type = #{map.ticketType}
|
||||
</if>
|
||||
<if test="map.accessoriesType != null and map.accessoriesType != ''">
|
||||
<if test="map.accessoriesType == 'request'">
|
||||
/*查询配件申请单不能为空的*/
|
||||
|
||||
@ -154,4 +154,12 @@
|
||||
AND r.id IS NULL
|
||||
AND t.deleted = b'0';
|
||||
</select>
|
||||
<select id="getProjectsByTicketId" resultType="cn.iocoder.yudao.module.tickets.entity.DlRepairTitem">
|
||||
SELECT *
|
||||
FROM dl_repair_titem
|
||||
WHERE ticket_id = #{ticketId}
|
||||
AND item_type = '01'
|
||||
AND item_status != '03'
|
||||
AND FIND_IN_SET(#{userId}, repair_ids) > 0
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user