Commit b99c08a3 authored by lanbaoming's avatar lanbaoming

2024-06-10提交

parent 76812eb5
package cn.iocoder.yudao.framework.apollo.core.event.export;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
public class ShipmentLoadExcelExportPushEvent2 {
/**
* 操作用户
*/
private Long userId;
/**
* 端口
*/
private Integer userType;
/**
* 请求参数
*/
private String requestParams;
/**
* 国际化语言值,默认0中文, 具体取值I18nMessage.getLang()
*/
private Integer lang = 0;
/**
* 文件名称
*/
private String fileName;
/**
* 文件路径
*/
private String path;
/**
* 下载地址
*/
private String url;
/**
* 执行结果
*/
private String result;
@ApiModelProperty(value = "文件ID")
private Long fileId;
}
......@@ -118,4 +118,14 @@ public class WarehouseLineDO extends BaseDO {
@TableField(exist = false)
private String destQianzhui;
/*
落款信息 lanbm 2024-06-10 add
*/
private String lkLeft;
/*
落款信息 lanbm 2024-06-10 add
*/
private String lkRight;
}
......@@ -86,19 +86,19 @@ public class WarehouseServiceImpl implements WarehouseService {
String newTradeType = updateObj.getTradeType();
//判断是否修改了
if(!oldTradeType.equals(newTradeType)) {
if (!oldTradeType.equals(newTradeType)) {
//修改了贸易属性。修改成进出口则不用管
if(newTradeType.equals("3")) return;
if (newTradeType.equals("3")) return;
//老的是非进出口也不用管
if(oldTradeType.equals("0")) return;
if(oldTradeType.equals("3")) {
if (oldTradeType.equals("0")) return;
if (oldTradeType.equals("3")) {
//进出口改成了其他
if(newTradeType.equals("1")) {
if (newTradeType.equals("1")) {
//改成了进口,删除出口的线路
warehouseLineMapper.delete(new LambdaQueryWrapperX<WarehouseLineDO>()
.eq(WarehouseLineDO::getStartWarehouseId, id)
);
} else if(newTradeType.equals("2")) {
} else if (newTradeType.equals("2")) {
//改成了出口,删掉进口的线路
warehouseLineMapper.delete(new LambdaQueryWrapperX<WarehouseLineDO>()
.eq(WarehouseLineDO::getDestWarehouseId, id)
......@@ -153,7 +153,7 @@ public class WarehouseServiceImpl implements WarehouseService {
@Override
public List<WarehouseDO> getWarehouseList(Integer tradeType) {
List<String> tradeTypeList = null;
if(tradeType != null) {
if (tradeType != null) {
tradeTypeList = Arrays.asList("3", String.valueOf(tradeType));
}
return warehouseMapper.selectList(new LambdaQueryWrapperX<WarehouseDO>()
......@@ -239,7 +239,7 @@ public class WarehouseServiceImpl implements WarehouseService {
List<String> currentTransportList = new ArrayList<>(Arrays.asList(currentTransportArray));
for (String transportType : currentTransportList) {
//过滤掉禁用的运输方式
if(!existTypeList.contains(transportType)) continue;
if (!existTypeList.contains(transportType)) continue;
WarehouseDO warehouseItem = ObjectUtil.clone(warehouseDO);
//查看是否已经建立了关联关系
......@@ -264,11 +264,11 @@ public class WarehouseServiceImpl implements WarehouseService {
warehouseItem.setTempTitleZh(lineDO.getTempTitleZh());
String recipientInfo = lineDO.getRecipientInfo();
if(recipientInfo != null) {
if (recipientInfo != null) {
warehouseItem.setRecipientInfo(JSONObject.parseObject(recipientInfo, ContactInfoDTO.class));
}
String senderInfo = lineDO.getSenderInfo();
if(senderInfo != null) {
if (senderInfo != null) {
warehouseItem.setSenderInfo(JSONObject.parseObject(senderInfo, ContactInfoDTO.class));
}
} else {
......@@ -305,10 +305,10 @@ public class WarehouseServiceImpl implements WarehouseService {
RLock rLock = redissonClient.getLock(lockKey);
try {
boolean success = rLock.tryLock(2, 2, TimeUnit.SECONDS);
if(!success) throw new ServiceException(500, "操作忙,请稍后再试");
if (!success) throw new ServiceException(500, "操作忙,请稍后再试");
//从线路里面找这个线路
WarehouseLineDO warehouseLineDO = warehouseLineMapper.findOne(startWarehouseId, destWarehouseId, transportType);
if(warehouseLineDO == null) {
if (warehouseLineDO == null) {
//新增
WarehouseLineDO lineDO = new WarehouseLineDO();
lineDO.setTransportType(requestVO.getTransportType());
......@@ -347,7 +347,7 @@ public class WarehouseServiceImpl implements WarehouseService {
} catch (Exception e) {
e.printStackTrace();
} finally {
if(rLock.isLocked()) {
if (rLock.isLocked()) {
rLock.unlock();
}
}
......@@ -440,15 +440,16 @@ public class WarehouseServiceImpl implements WarehouseService {
@Override
public void serviceConfig(WarehouseLineServiceReqVO reqVO) {
String senderInfo = null;
if(reqVO.getSenderInfo() != null) {
if (reqVO.getSenderInfo() != null) {
senderInfo = JSON.toJSONString(reqVO.getSenderInfo());
}
String recipientInfo = null;
if(reqVO.getRecipientInfo() != null) {
if (reqVO.getRecipientInfo() != null) {
recipientInfo = JSON.toJSONString(reqVO.getRecipientInfo());
}
warehouseLineMapper.update(null, new LambdaUpdateWrapper<WarehouseLineDO>().eq(WarehouseLineDO::getId, reqVO.getLineId())
warehouseLineMapper.update(null,
new LambdaUpdateWrapper<WarehouseLineDO>().eq(WarehouseLineDO::getId, reqVO.getLineId())
.set(WarehouseLineDO::getOtherService, reqVO.getOtherService())
.set(StringUtils.isNotEmpty(reqVO.getMakeBillNode()), WarehouseLineDO::getMakeBillNode, reqVO.getMakeBillNode())
.set(reqVO.getIsClientShow() != null, WarehouseLineDO::getIsClientShow, reqVO.getIsClientShow())
......@@ -456,9 +457,13 @@ public class WarehouseServiceImpl implements WarehouseService {
.set(reqVO.getMinPrice() != null, WarehouseLineDO::getMinPrice, reqVO.getMinPrice())
.set(senderInfo != null, WarehouseLineDO::getSenderInfo, senderInfo)
.set(recipientInfo != null, WarehouseLineDO::getRecipientInfo, recipientInfo)
.set(StringUtils.isNotEmpty(reqVO.getTempTitleEn()),WarehouseLineDO::getTempTitleEn,reqVO.getTempTitleEn())
.set(StringUtils.isNotEmpty(reqVO.getTempTitleZh()),WarehouseLineDO::getTempTitleZh,reqVO.getTempTitleZh())
.set(reqVO.getControlStatus() != null, WarehouseLineDO::getControlStatus, reqVO.getControlStatus()));
.set(StringUtils.isNotEmpty(reqVO.getTempTitleEn()), WarehouseLineDO::getTempTitleEn, reqVO.getTempTitleEn())
.set(StringUtils.isNotEmpty(reqVO.getTempTitleZh()), WarehouseLineDO::getTempTitleZh, reqVO.getTempTitleZh())
.set(reqVO.getControlStatus() != null, WarehouseLineDO::getControlStatus, reqVO.getControlStatus())
.set(StringUtils.isNotEmpty(reqVO.getLkLeft()), WarehouseLineDO::getLkLeft, reqVO.getLkLeft())
.set(StringUtils.isNotEmpty(reqVO.getLkRight()), WarehouseLineDO::getLkRight, reqVO.getLkRight())
);
}
@Override
......@@ -477,7 +482,7 @@ public class WarehouseServiceImpl implements WarehouseService {
for (WarehouseLineReq req : list) {
String key = req.getStartWarehouseId() + "_" + req.getDestWarehouseId() + "_" + req.getTransportType();
WarehouseLineDO lineDO;
if(lineMap.containsKey(key)) {
if (lineMap.containsKey(key)) {
lineDO = lineMap.get(key);
} else {
lineDO = getLineInfo(req);
......@@ -515,10 +520,10 @@ public class WarehouseServiceImpl implements WarehouseService {
@Override
public List<WarehouseTreeRegionVO> getRegionList(Integer type, String regionId, String destCountryId, String objectiveId, String destWarehouseId) {
if(regionId.equals("")){
if (regionId.equals("")) {
return new ArrayList();
}
List<WarehouseTreeRegionVO> list = warehouseMapper.getRegionList(type,regionId,destCountryId,objectiveId,destWarehouseId);
List<WarehouseTreeRegionVO> list = warehouseMapper.getRegionList(type, regionId, destCountryId, objectiveId, destWarehouseId);
return list;
}
}
......@@ -47,4 +47,15 @@ public class WarehouseLineServiceReqVO {
*/
@ApiModelProperty(value = "模版标题中文")
private String tempTitleZh;
/*
落款信息 lanbm 2024-06-10 add
*/
private String lkLeft;
/*
落款信息 lanbm 2024-06-10 add
*/
private String lkRight;
}
......@@ -227,7 +227,8 @@ public class WarehouseController {
@PostMapping("/serviceConfig")
@ApiOperation("其他服务配置")
public CommonResult<Boolean> serviceConfig(@RequestBody WarehouseLineServiceReqVO reqVO) {
public CommonResult<Boolean> serviceConfig(
@RequestBody WarehouseLineServiceReqVO reqVO) {
warehouseService.serviceConfig(reqVO);
return success(true);
}
......
......@@ -3871,16 +3871,24 @@ public class OrderWarehouseInServiceImpl extends AbstractService<OrderWarehouseI
throw ServiceExceptionUtil.exception(ErrorCodeConstants.ORDER_NOT_EXISTS);
}
List<OrderItemDO> orderItemDOList = orderItemService.list(new LambdaQueryWrapper<OrderItemDO>()
List<OrderItemDO> orderItemDOList =
orderItemService.list(new LambdaQueryWrapper<OrderItemDO>()
.eq(OrderItemDO::getOrderId, orderId).orderByAsc(OrderItemDO::getOrderItemId));
List<OrderWarehouseInDO> orderWarehouseInDOList = orderWarehouseInMapper.selectList(new LambdaQueryWrapper<OrderWarehouseInDO>()
.eq(OrderWarehouseInDO::getOrderId, orderId).orderByAsc(OrderWarehouseInDO::getId));
List<OrderWarehouseInDO> orderWarehouseInDOList =
orderWarehouseInMapper.selectList(
new LambdaQueryWrapper<OrderWarehouseInDO>()
.eq(OrderWarehouseInDO::getOrderId,
orderId).orderByAsc(OrderWarehouseInDO::getId));
List<OrderLocationDO> orderLocationListByOrderId = orderLocationService.getOrderLocationListByOrderId(orderId);
//订单仓位
List<OrderLocationDO> orderLocationListByOrderId =
orderLocationService.getOrderLocationListByOrderId(orderId);
if (CollectionUtil.isNotEmpty(orderItemDOList)) {
return orderItemDOList.stream().map(orderItemDO -> {
return getOrderWarehouseInBackVO(orderItemDO, orderWarehouseInDOList, orderLocationListByOrderId);
return getOrderWarehouseInBackVO(orderItemDO,
orderWarehouseInDOList,
orderLocationListByOrderId);
}).collect(Collectors.toList());
}
......@@ -3902,16 +3910,24 @@ public class OrderWarehouseInServiceImpl extends AbstractService<OrderWarehouseI
return null;
}
private OrderWarehouseInBackVO getOrderWarehouseInBackVO(OrderItemDO orderItemDO, List<OrderWarehouseInDO> orderWarehouseInDOList, List<OrderLocationDO> orderLocationListByOrderId) {
OrderWarehouseInBackVO orderWarehouseInBackVO = OrderItemConvert.INSTANCE.convertToOrderWarehouseInBackVo(orderItemDO);
private OrderWarehouseInBackVO getOrderWarehouseInBackVO(
OrderItemDO orderItemDO,
List<OrderWarehouseInDO> orderWarehouseInDOList,
List<OrderLocationDO> orderLocationListByOrderId) {
OrderWarehouseInBackVO orderWarehouseInBackVO =
OrderItemConvert.INSTANCE.convertToOrderWarehouseInBackVo(orderItemDO);
List<OrderWarehouseInBackItemDo> orderWarehouseInBackItemDoList = orderWarehouseInDOList.stream()
List<OrderWarehouseInBackItemDo> orderWarehouseInBackItemDoList =
orderWarehouseInDOList.stream()
.filter(t -> t.getOrderItemId().equals(orderItemDO.getOrderItemId()))
.sorted(Comparator.comparing(OrderWarehouseInDO::getInTime))
.map(orderWarehouseInDO -> {
OrderWarehouseInBackItemDo orderWarehouseInBackItemDo = OrderWarehouseInConvert.INSTANCE.convert2(orderWarehouseInDO);
OrderWarehouseInBackItemDo orderWarehouseInBackItemDo =
OrderWarehouseInConvert.INSTANCE.convert2(orderWarehouseInDO);
List<OrderLocationBackVO> orderLocationBackVOS = orderLocationService.filterByWarehouseIn(orderLocationListByOrderId, orderWarehouseInDO);
List<OrderLocationBackVO> orderLocationBackVOS =
orderLocationService.filterByWarehouseIn(orderLocationListByOrderId, orderWarehouseInDO);
orderWarehouseInBackItemDo.setOrderLocationBackVOList(orderLocationBackVOS);
String orderLocationStr4Merge = orderLocationBackVOS.stream().map(item -> {
return (item.getAreaName() == null ? "" : item.getAreaName()) + (item.getLocationName() == null ? "" : item.getLocationName());
......@@ -3921,7 +3937,8 @@ public class OrderWarehouseInServiceImpl extends AbstractService<OrderWarehouseI
return orderWarehouseInBackItemDo;
}).collect(Collectors.toList());
orderWarehouseInBackItemDoList = orderWarehouseInBackItemDoList.stream().sorted(Comparator.comparing(OrderWarehouseInBackItemDo::getInTime).thenComparing(OrderWarehouseInBackItemDo::getUnit).thenComparing(OrderWarehouseInBackItemDo::getOrderLocationStr4Merge)).collect(Collectors.toList());
orderWarehouseInBackItemDoList =
orderWarehouseInBackItemDoList.stream().sorted(Comparator.comparing(OrderWarehouseInBackItemDo::getInTime).thenComparing(OrderWarehouseInBackItemDo::getUnit).thenComparing(OrderWarehouseInBackItemDo::getOrderLocationStr4Merge)).collect(Collectors.toList());
// 设置件数差
BigDecimal num = orderWarehouseInBackVO.getNum();
......@@ -3934,10 +3951,13 @@ public class OrderWarehouseInServiceImpl extends AbstractService<OrderWarehouseI
orderWarehouseInBackVO.setCartonsNumDiff(Math.abs(diff));
}
orderWarehouseInBackVO.setOrderWarehouseInBackItemDoList(orderWarehouseInBackItemDoList);
orderWarehouseInBackVO.setOrderWarehouseInBackItemDoList(
orderWarehouseInBackItemDoList);
// 设置入仓影像
List<String> pictureUrls = orderWarehousePictureService.getWarehousePictureUrlList(5, orderItemDO.getOrderItemId());
List<String> pictureUrls =
orderWarehousePictureService.getWarehousePictureUrlList(5,
orderItemDO.getOrderItemId());
if (CollectionUtil.isNotEmpty(pictureUrls)) {
orderWarehouseInBackVO.setPictureUrls(pictureUrls);
}
......
......@@ -23,9 +23,6 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_
@ApiModel("管理后台 - 入仓货物详情 Response VO")
public class OrderWarehouseInBackVO {
@ApiModelProperty(value = "订单ID", required = true)
@NotNull(message = "订单ID不能为空")
private Long orderId;
......@@ -136,7 +133,6 @@ public class OrderWarehouseInBackVO {
private Date updateTime;
/**
* 入仓货物信息
*/
......
......@@ -244,7 +244,8 @@ public class OrderWarehouseInController {
@ApiOperation("获得订单的入仓货物详情")
@ApiImplicitParam(name = "orderId", value = "订单id", required = true, example = "1024", dataTypeClass = Long.class)
public CommonResult<List<OrderWarehouseInBackVO>> getOrderWarehouseIn(@RequestParam("orderId") Long orderId) {
List<OrderWarehouseInBackVO> orderWarehouseInBackVOList = orderWarehouseInService.getOrderWarehouseInList(orderId);
List<OrderWarehouseInBackVO> orderWarehouseInBackVOList =
orderWarehouseInService.getOrderWarehouseInList(orderId);
return success(orderWarehouseInBackVOList);
}
......
......@@ -71,7 +71,7 @@ import static cn.iocoder.yudao.module.shipment.enums.ErrorCodeConstants.HAVE_NOT
/**
* 自编号订单excel导出监听
*
* 空运已装单数据导出 lanbm 2024-06-10 添加注释
* @author zhengYi
*/
@Component("ShipmentAirLoadExcelExportListener")
......@@ -161,7 +161,9 @@ public class ShipmentAirLoadExcelExportListener {
toString()).concat(StrUtil.DASHED).
concat(nowTime).concat("shipment_preload.xlsx");
InputStream inputStream = null;
inputStream = this.getClass().getClassLoader().getResourceAsStream(ueProperties.getTemplatesUrl() + "/airLoad.xlsx");
inputStream = this.getClass().getClassLoader().
getResourceAsStream(
ueProperties.getTemplatesUrl() + "/airLoad.xlsx");
JSONObject jsonObject = JSONObject.parseObject(event.getRequestParams());
Long shipmentId = jsonObject.getLong("shipmentId");
Map headMap = new HashMap();
......
......@@ -67,7 +67,8 @@ import static cn.iocoder.yudao.module.shipment.enums.ErrorCodeConstants.HAVE_NOT
/**
* 自编号订单excel导出监听
* lanbm 2024-06-05 修改模板样式和添加列字段
*
* 海运已装单数据导出
* NG2408045L
* @author zhengYi
*/
@Component("ShipmentLoadExcelExportListener")
......@@ -137,12 +138,15 @@ public class ShipmentLoadExcelExportListener {
Map headMap = new HashMap();
JSONObject jsonObject =
JSONObject.parseObject(event.getRequestParams());
Long shipmentId = jsonObject.getLong("shipmentId");
List<BoxPreloadGoodsBackVO> goodsItemList =
boxPreloadGoodsService.getShipGoodItemList(shipmentId);
if (CollectionUtil.isEmpty(goodsItemList)) {
event.setResult(HAVE_NOT_PRELOAD_GOODS.getMsg());
}
BoxDO box = boxService.getBox(shipmentId);
CabinetDO cabinet = cabinetService.getCabinet(box.getCabinetId());
BoxApprovalDO boxApprovalDO =
......@@ -417,17 +421,15 @@ public class ShipmentLoadExcelExportListener {
event.setUrl(fileDO.getUrl());
event.setFileId(fileDO.getId());
} catch(Exception e){
} catch (Exception e) {
e.printStackTrace();
event.setResult(e.getMessage());
}
} else
{
} else {
event.setResult("param fail");
}
}
}
/*
lanbm 2024-06-05 添加商品属性转换函数
......
......@@ -283,6 +283,8 @@ public class DownloadLogServiceImpl extends AbstractService<DownloadLogMapper, D
//已装单导出
case SHIPMENT_LOAD_EXCEL_EXPORT:
shipmentLoadExcelExportPushEvent(downloadLog);
//lanbm 2024-06-10 总体切换
//shipmentLoadExcelExportPushEvent2(downloadLog);
break;
//应收汇总导出 lanbm 2024-05-24 修改导出Excel样式
case SHIPMENT_RECEIVABLE_EXCEL_EXPORT:
......@@ -663,6 +665,24 @@ public class DownloadLogServiceImpl extends AbstractService<DownloadLogMapper, D
downloadLog.setFileId(event.getFileId());
}
/*
海运已装单导出 lanbm 2024-06-10 add
*/
private void shipmentLoadExcelExportPushEvent2(DownloadLogDO downloadLog) {
ShipmentLoadExcelExportPushEvent2 event =
new ShipmentLoadExcelExportPushEvent2();
event.setUserId(downloadLog.getUserId());
event.setUserType(downloadLog.getUserType());
event.setLang(downloadLog.getLang());
event.setRequestParams(downloadLog.getRequestParams());
applicationContext.publishEvent(event);
downloadLog.setFileName(event.getFileName());
downloadLog.setPath(event.getPath());
downloadLog.setDownloadUrl(event.getUrl());
downloadLog.setResult(event.getResult());
downloadLog.setFileId(event.getFileId());
}
private void shipmentPreloadExcelExportPushEvent(DownloadLogDO downloadLog) {
ShipmentPreloadExcelExportPushEvent event = new ShipmentPreloadExcelExportPushEvent();
event.setUserId(downloadLog.getUserId());
......
......@@ -7,7 +7,11 @@ import cn.iocoder.yudao.framework.mybatis.core.vo.PageVO;
import cn.iocoder.yudao.module.wealth.dal.dataobject.receiptAccount.ReceiptAccountDO;
import cn.iocoder.yudao.module.wealth.vo.receiptAccount.ReceiptAccountQueryVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultType;
import org.apache.ibatis.annotations.Select;
import java.math.BigDecimal;
import java.util.List;
/**
......@@ -50,4 +54,18 @@ public interface ReceiptAccountMapper extends AbstractMapper<ReceiptAccountDO> {
return null;
}
/*
获取核销基准金额 lanbm 2024-06-10 add
*/
@ResultType(BigDecimal.class)
@Select({
"<script>",
"select COALESCE(sum(r.write_off_amount),0) ",
"from ecw_receipt_account r ",
"where r.deleted = 0",
"AND r.receipt_id = #{receiptId} ",
"</script>"
})
BigDecimal getWriteOffAmountByReceiptId(@Param("receiptId") Long receiptId);
}
......@@ -69,6 +69,9 @@ public interface ReceiptItemMapper extends AbstractMapper<ReceiptItemDO> {
return null;
}
/*
获取已核销金额 lanbm 2024-06-10 添加注释
*/
@ResultType(BigDecimal.class)
@Select({
"<script>",
......
......@@ -79,6 +79,7 @@ public class ReceiptServiceImpl extends AbstractService<ReceiptMapper, ReceiptDO
@Resource
private ReceiptItemMapper receiptItemMapper;
@Autowired
private ApplicationContext applicationContext;
@Autowired
......
......@@ -6,8 +6,10 @@ import cn.iocoder.yudao.module.wealth.vo.receipt.FinanceReceiptItemCancelVo;
import cn.iocoder.yudao.module.wealth.vo.receipt.FinanceReceiptItemVo;
import cn.iocoder.yudao.module.wealth.vo.receiptItem.ReceiptItemCreateReqVO;
import cn.iocoder.yudao.module.wealth.vo.receiptItem.ReceiptItemUpdateReqVO;
import org.apache.ibatis.annotations.Param;
import javax.validation.Valid;
import java.math.BigDecimal;
import java.util.Collection;
import java.util.List;
......@@ -116,4 +118,7 @@ public interface ReceiptItemService extends IService<ReceiptItemDO> {
*/
void cancelFinanceReceiptItemWriteOffNo(FinanceReceiptItemCancelVo financeReceiptItemVo);
BigDecimal getWriteOffAmountByReceiptId( Long receiptId);
}
......@@ -539,4 +539,9 @@ public class ReceiptItemServiceImpl extends AbstractService<ReceiptItemMapper, R
}
}
}
public BigDecimal getWriteOffAmountByReceiptId(Long receiptId) {
return receiptItemMapper.getWriteOffAmountByReceiptId(receiptId);
}
}
......@@ -93,5 +93,10 @@ public class ReceiptItemBackVO {
@ApiModelProperty(value = "当前流程ID")
private String bmpId;
/*
剩余金额 lanbm 2024-06-10 add
*/
private String syValue;
}
......@@ -2,9 +2,16 @@ package cn.iocoder.yudao.module.wealth.controller.admin.receiptItem;
import cn.hutool.core.collection.CollectionUtil;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.util.collectors.CollectorsUtil;
import cn.iocoder.yudao.framework.common.util.io.FileModel;
import cn.iocoder.yudao.framework.idempotent.core.annotation.Idempotent;
import cn.iocoder.yudao.module.ecw.api.currency.CurrencyApi;
import cn.iocoder.yudao.module.ecw.api.currency.dto.CurrencyRespDTO;
import cn.iocoder.yudao.module.wealth.convert.receiptItem.ReceiptItemConvert;
import cn.iocoder.yudao.module.wealth.dal.dataobject.receiptAccount.ReceiptAccountDO;
import cn.iocoder.yudao.module.wealth.dal.dataobject.receiptItem.ReceiptItemDO;
import cn.iocoder.yudao.module.wealth.dal.mysql.receiptAccount.ReceiptAccountMapper;
import cn.iocoder.yudao.module.wealth.dal.mysql.receiptItem.ReceiptItemMapper;
import cn.iocoder.yudao.module.wealth.service.receiptItem.ReceiptItemService;
import cn.iocoder.yudao.module.wealth.vo.receipt.FinanceReceiptItemCancelVo;
import cn.iocoder.yudao.module.wealth.vo.receipt.FinanceReceiptItemVo;
......@@ -20,7 +27,11 @@ import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import javax.validation.Valid;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
......@@ -33,6 +44,20 @@ public class ReceiptItemController {
@Resource
private ReceiptItemService receiptItemService;
@Resource
private ReceiptAccountMapper receiptAccountMapper;
@Resource
private ReceiptItemMapper receiptItemMapper;
/*
币种 lanbm 2024-06-10 add
*/
@Resource
CurrencyApi currencyApi;
@PostMapping("/create")
@ApiOperation("创建收款明细")
//@PreAuthorize("@ss.hasPermission('ecw:receipt-item:create')")
......@@ -60,12 +85,67 @@ public class ReceiptItemController {
@GetMapping("/get")
@ApiOperation("获得收款明细详情")
@ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class)
//@PreAuthorize("@ss.hasPermission('ecw:receipt-item:query')")
public CommonResult<ReceiptItemBackVO> getReceiptItem(@RequestParam("id") Long id) {
ReceiptItemDO receiptItem = receiptItemService.getReceiptItem(id);
return success(ReceiptItemConvert.INSTANCE.convert(receiptItem));
ReceiptItemBackVO v = ReceiptItemConvert.INSTANCE.convert(receiptItem);
//计算剩余金额 lanbm 2024-06-10 add
//BigDecimal p = receiptItemService.getWriteOffAmountByReceiptId(id);
//BigDecimal t = receiptAccountMapper.getWriteOffAmountByReceiptId(id);
getSY(v, v.getReceiptId());
return success(v);
}
/*
获取剩余金额 lanbm 2024-06-10 add
*/
private BigDecimal getSY(ReceiptItemBackVO v, long id) {
Map<Integer, CurrencyRespDTO> currencyMap = currencyApi.getAllCurrency();
BigDecimal bResult = new BigDecimal(0);
LambdaQueryWrapper<ReceiptAccountDO> lambdaQueryWrapper2 =
new LambdaQueryWrapper<>();
lambdaQueryWrapper2.eq(ReceiptAccountDO::getReceiptId, id);
List<ReceiptAccountDO> ReceiptAccountList =
receiptAccountMapper.selectList(lambdaQueryWrapper2);
BigDecimal t = new BigDecimal(0);
Long currencyId = null;
if (CollectionUtil.isEmpty(ReceiptAccountList) == true) {
t = new BigDecimal(0);
} else {
//获取币种
currencyId = ReceiptAccountList.get(0).getCurrencyId();
t = ReceiptAccountList.stream().
collect(CollectorsUtil.summingBigDecimal(
ReceiptAccountDO::getWriteOffAmount));
}
LambdaQueryWrapper<ReceiptItemDO> lambdaQueryWrapper =
new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(ReceiptItemDO::getReceiptId, id);
List<ReceiptItemDO> listItem =
receiptItemMapper.selectList(lambdaQueryWrapper);
BigDecimal p = new BigDecimal(0);
if (CollectionUtil.isEmpty(listItem) == true) {
p = new BigDecimal(0);
} else {
//对指定列求和
p = listItem.stream().
collect(CollectorsUtil.summingBigDecimal(
ReceiptItemDO::getWriteOffAmount));
}
bResult = t.subtract(p);
String bzName = "";
if (currencyId != null) {
int iId=Integer.parseInt(currencyId.toString());
bzName = currencyMap.get(iId).getTitleZh();
}
v.setSyValue(bResult.toString() + bzName);
return bResult;
}
@GetMapping("/getReceivableItem")
@ApiOperation("根据收款单ID获得收款明细列表")
@ApiImplicitParam(name = "id", value = "编号", required = true, example = "1024", dataTypeClass = Long.class)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment