|
|
@@ -243,30 +243,30 @@ public class RouteCostServiceImpl extends ServiceImpl<RouteCostMapper, RouteCost
|
|
|
routeCost.setOtherProfit(totalProfit(routeCost.getCostItemList(), "other"));
|
|
|
routeCost.setTotalProfit(routeCost.getProfit20().add(routeCost.getProfit40()).add(routeCost.getProfitHc()).add(routeCost.getOtherProfit()));
|
|
|
|
|
|
- List<RouteCostItem> costItemList = routeCost.getCostItemList().stream().filter(e-> "0".equals(e.getDisable()))
|
|
|
+ List<RouteCostItem> costItemList = routeCost.getCostItemList().stream().filter(e -> "0".equals(e.getDisable()))
|
|
|
.collect(Collectors.toList());
|
|
|
- if (!costItemList.isEmpty()){
|
|
|
- if (new BigDecimal("0.00").compareTo(totalProfit(costItemList, "20")) == 0){
|
|
|
+ if (!costItemList.isEmpty()) {
|
|
|
+ if (new BigDecimal("0.00").compareTo(totalProfit(costItemList, "20")) == 0) {
|
|
|
routeCost.setProfit20Status("1");
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
routeCost.setProfit20Status("0");
|
|
|
}
|
|
|
- if (new BigDecimal("0.00").compareTo(totalProfit(costItemList, "40")) == 0){
|
|
|
+ if (new BigDecimal("0.00").compareTo(totalProfit(costItemList, "40")) == 0) {
|
|
|
routeCost.setProfit40Status("1");
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
routeCost.setProfit40Status("0");
|
|
|
}
|
|
|
- if (new BigDecimal("0.00").compareTo(totalProfit(costItemList, "40HC")) == 0){
|
|
|
+ if (new BigDecimal("0.00").compareTo(totalProfit(costItemList, "40HC")) == 0) {
|
|
|
routeCost.setProfitHcStatus("1");
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
routeCost.setProfitHcStatus("0");
|
|
|
}
|
|
|
- if (new BigDecimal("0.00").compareTo(totalProfit(costItemList, "other")) == 0){
|
|
|
+ if (new BigDecimal("0.00").compareTo(totalProfit(costItemList, "other")) == 0) {
|
|
|
routeCost.setOtherProfitStatus("1");
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
routeCost.setOtherProfitStatus("0");
|
|
|
}
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
routeCost.setProfit20Status("1");
|
|
|
routeCost.setProfit40Status("1");
|
|
|
routeCost.setProfitHcStatus("1");
|
|
|
@@ -1005,7 +1005,7 @@ public class RouteCostServiceImpl extends ServiceImpl<RouteCostMapper, RouteCost
|
|
|
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public R batchCopy(String ids, BigDecimal exrate, Date effectiveStartDate, Date effectiveEndDate,String type,String s) {
|
|
|
+ public R batchCopy(String ids, BigDecimal exrate, Date effectiveStartDate, Date effectiveEndDate, String type, String s) {
|
|
|
if (ObjectUtils.isNull(ids) || ObjectUtils.isNull(exrate) || ObjectUtils.isNull(effectiveStartDate)
|
|
|
|| ObjectUtils.isNull(effectiveEndDate)) {
|
|
|
throw new RuntimeException("缺少必要参数");
|
|
|
@@ -1061,15 +1061,15 @@ public class RouteCostServiceImpl extends ServiceImpl<RouteCostMapper, RouteCost
|
|
|
item.setEffectiveEndDate(effectiveEndDate);
|
|
|
routeCostListNew.add(item);
|
|
|
}
|
|
|
- if (!routeCostListNew.isEmpty()){
|
|
|
+ if (!routeCostListNew.isEmpty()) {
|
|
|
this.saveBatch(routeCostListNew);
|
|
|
List<RouteCostFee> costFeesListNew = new ArrayList<>();
|
|
|
List<RouteCostItem> costItemListNew = new ArrayList<>();
|
|
|
- for (RouteCost item : routeCostListNew){
|
|
|
- if (!costFeesList.isEmpty()){
|
|
|
+ for (RouteCost item : routeCostListNew) {
|
|
|
+ if (!costFeesList.isEmpty()) {
|
|
|
List<RouteCostFee> costFeesListNews = new ArrayList<>();
|
|
|
- List<RouteCostFee> costFees = costFeesList.stream().filter(e-> e.getPid().equals(item.getCopyId())).collect(Collectors.toList());
|
|
|
- for (RouteCostFee costFeeItem : costFees){
|
|
|
+ List<RouteCostFee> costFees = costFeesList.stream().filter(e -> e.getPid().equals(item.getCopyId())).collect(Collectors.toList());
|
|
|
+ for (RouteCostFee costFeeItem : costFees) {
|
|
|
costFeeItem.setId(null);
|
|
|
costFeeItem.setPid(item.getId());
|
|
|
costFeeItem.setCreateTime(new Date());
|
|
|
@@ -1078,7 +1078,7 @@ public class RouteCostServiceImpl extends ServiceImpl<RouteCostMapper, RouteCost
|
|
|
costFeeItem.setUpdateUser(null);
|
|
|
costFeeItem.setUpdateTime(null);
|
|
|
costFeeItem.setUpdateUserName(null);
|
|
|
- if (!exrateType.equals(costFeeItem.getCurCode())){
|
|
|
+ if (!exrateType.equals(costFeeItem.getCurCode())) {
|
|
|
costFeeItem.setExrate(exrate);
|
|
|
}
|
|
|
costFeesListNew.add(costFeeItem);
|
|
|
@@ -1086,10 +1086,10 @@ public class RouteCostServiceImpl extends ServiceImpl<RouteCostMapper, RouteCost
|
|
|
}
|
|
|
item.setCostFeeList(costFeesListNews.isEmpty() ? new ArrayList<>() : costFeesListNews);
|
|
|
}
|
|
|
- if (!costItemList.isEmpty()){
|
|
|
+ if (!costItemList.isEmpty()) {
|
|
|
List<RouteCostItem> costItemListNews = new ArrayList<>();
|
|
|
- List<RouteCostItem> costItems = costItemList.stream().filter(e-> e.getPid().equals(item.getCopyId())).collect(Collectors.toList());
|
|
|
- for (RouteCostItem costItem : costItems){
|
|
|
+ List<RouteCostItem> costItems = costItemList.stream().filter(e -> e.getPid().equals(item.getCopyId())).collect(Collectors.toList());
|
|
|
+ for (RouteCostItem costItem : costItems) {
|
|
|
costItem.setId(null);
|
|
|
costItem.setPid(item.getId());
|
|
|
costItem.setCreateTime(new Date());
|
|
|
@@ -1098,7 +1098,7 @@ public class RouteCostServiceImpl extends ServiceImpl<RouteCostMapper, RouteCost
|
|
|
costItem.setUpdateUser(null);
|
|
|
costItem.setUpdateTime(null);
|
|
|
costItem.setUpdateUserName(null);
|
|
|
- if (!exrateType.equals(costItem.getCurCode())){
|
|
|
+ if (!exrateType.equals(costItem.getCurCode())) {
|
|
|
costItem.setExrate(exrate);
|
|
|
}
|
|
|
costItemListNews.add(costItem);
|
|
|
@@ -1109,7 +1109,7 @@ public class RouteCostServiceImpl extends ServiceImpl<RouteCostMapper, RouteCost
|
|
|
int days = item.getNavigateDay() + item.getExistStationDay();
|
|
|
List<RouteCostFee> costFeeList = item.getCostFeeList();
|
|
|
for (RouteCostItem routeCostItem : item.getCostItemList()) {
|
|
|
- if (!exrateType.equals(routeCostItem.getCurCode())){
|
|
|
+ if (!exrateType.equals(routeCostItem.getCurCode())) {
|
|
|
routeCostItem.setExrate(exrate);
|
|
|
}
|
|
|
//一程POL杂费成本
|
|
|
@@ -1161,10 +1161,10 @@ public class RouteCostServiceImpl extends ServiceImpl<RouteCostMapper, RouteCost
|
|
|
item.setTotalProfit(item.getProfit20().add(item.getProfit40()).add(item.getProfitHc()).add(item.getOtherProfit()));
|
|
|
}
|
|
|
}
|
|
|
- if (!costFeesListNew.isEmpty()){
|
|
|
+ if (!costFeesListNew.isEmpty()) {
|
|
|
routeCostFeeService.saveBatch(costFeesListNew);
|
|
|
}
|
|
|
- if (!costItemListNew.isEmpty()){
|
|
|
+ if (!costItemListNew.isEmpty()) {
|
|
|
routeCostItemService.saveBatch(costItemListNew);
|
|
|
}
|
|
|
}
|
|
|
@@ -1191,6 +1191,46 @@ public class RouteCostServiceImpl extends ServiceImpl<RouteCostMapper, RouteCost
|
|
|
return R.data("操作成功");
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public R add(RouteCost routeCost) {
|
|
|
+ if (ObjectUtils.isNotNull(routeCost.getCostItemList())) {
|
|
|
+ List<RouteCostItem> costItemList = routeCostItemService.list(new LambdaQueryWrapper<RouteCostItem>()
|
|
|
+ .eq(RouteCostItem::getTenantId,AuthUtil.getTenantId())
|
|
|
+ .eq(RouteCostItem::getIsDeleted,0)
|
|
|
+ .eq(RouteCostItem::getDisable,"0")
|
|
|
+ .eq(RouteCostItem::getPid,routeCost.getId()));
|
|
|
+ if (!costItemList.isEmpty()) {
|
|
|
+ if (new BigDecimal("0.00").compareTo(totalProfit(costItemList, "20")) == 0) {
|
|
|
+ routeCost.setProfit20Status("1");
|
|
|
+ } else {
|
|
|
+ routeCost.setProfit20Status("0");
|
|
|
+ }
|
|
|
+ if (new BigDecimal("0.00").compareTo(totalProfit(costItemList, "40")) == 0) {
|
|
|
+ routeCost.setProfit40Status("1");
|
|
|
+ } else {
|
|
|
+ routeCost.setProfit40Status("0");
|
|
|
+ }
|
|
|
+ if (new BigDecimal("0.00").compareTo(totalProfit(costItemList, "40HC")) == 0) {
|
|
|
+ routeCost.setProfitHcStatus("1");
|
|
|
+ } else {
|
|
|
+ routeCost.setProfitHcStatus("0");
|
|
|
+ }
|
|
|
+ if (new BigDecimal("0.00").compareTo(totalProfit(costItemList, "other")) == 0) {
|
|
|
+ routeCost.setOtherProfitStatus("1");
|
|
|
+ } else {
|
|
|
+ routeCost.setOtherProfitStatus("0");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ routeCost.setProfit20Status("1");
|
|
|
+ routeCost.setProfit40Status("1");
|
|
|
+ routeCost.setProfitHcStatus("1");
|
|
|
+ routeCost.setOtherProfitStatus("1");
|
|
|
+ }
|
|
|
+ this.saveOrUpdate(routeCost);
|
|
|
+ }
|
|
|
+ return R.data(routeCost);
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
/**
|
|
|
* 合计费用成本
|
|
|
@@ -1202,7 +1242,7 @@ public class RouteCostServiceImpl extends ServiceImpl<RouteCostMapper, RouteCost
|
|
|
*/
|
|
|
public BigDecimal computationalCost(List<RouteCostFee> routeCostFeeList, String type, String boxType, BigDecimal exrate, String srcType) {
|
|
|
BigDecimal amount = new BigDecimal("0.00");
|
|
|
- if (ObjectUtils.isNotNull(routeCostFeeList)&&!routeCostFeeList.isEmpty()) {
|
|
|
+ if (ObjectUtils.isNotNull(routeCostFeeList) && !routeCostFeeList.isEmpty()) {
|
|
|
amount = routeCostFeeList.stream().filter(e -> boxType.equals(e.getBoxType())
|
|
|
&& type.equals(e.getBusType()) && srcType.equals(e.getSrcType())).reduce(BigDecimal.ZERO, (x, y) -> x.add(y.getExrate().multiply(y.getCostPrice())), BigDecimal::add);
|
|
|
if (new BigDecimal("0.00").compareTo(amount) != 0) {
|
|
|
@@ -1224,7 +1264,7 @@ public class RouteCostServiceImpl extends ServiceImpl<RouteCostMapper, RouteCost
|
|
|
*/
|
|
|
public BigDecimal computationalIncome(List<RouteCostFee> routeCostFeeList, String type, String boxType, BigDecimal exrate, String srcType) {
|
|
|
BigDecimal amount = new BigDecimal("0.00");
|
|
|
- if (ObjectUtils.isNotNull(routeCostFeeList)&&!routeCostFeeList.isEmpty()) {
|
|
|
+ if (ObjectUtils.isNotNull(routeCostFeeList) && !routeCostFeeList.isEmpty()) {
|
|
|
amount = routeCostFeeList.stream().filter(e -> boxType.equals(e.getBoxType())
|
|
|
&& type.equals(e.getBusType()) && srcType.equals(e.getSrcType())).reduce(BigDecimal.ZERO, (x, y) -> x.add(y.getExrate().multiply(y.getSalesPrice())), BigDecimal::add);
|
|
|
if (new BigDecimal("0.00").compareTo(amount) != 0) {
|
|
|
@@ -1244,7 +1284,7 @@ public class RouteCostServiceImpl extends ServiceImpl<RouteCostMapper, RouteCost
|
|
|
*/
|
|
|
public BigDecimal totalProfit(List<RouteCostItem> routeCostItemList, String type) {
|
|
|
BigDecimal profit;
|
|
|
- if (ObjectUtils.isNotNull(routeCostItemList)&&!routeCostItemList.isEmpty()) {
|
|
|
+ if (ObjectUtils.isNotNull(routeCostItemList) && !routeCostItemList.isEmpty()) {
|
|
|
if ("20".equals(type)) {
|
|
|
profit = routeCostItemList.stream().filter(e -> ObjectUtils.isNotNull(e.getBoxType()) && e.getBoxType().contains("20"))
|
|
|
.map(RouteCostItem::getProfit).reduce(BigDecimal.ZERO, BigDecimal::add);
|