bugfix: 修复发现的问题
This commit is contained in:
parent
ca874cf904
commit
d98099c16e
|
|
@ -4,6 +4,7 @@ import com.nflg.product.base.core.api.BaseApi;
|
|||
import com.nflg.product.technology.pojo.query.CostConfigQuery;
|
||||
import com.nflg.product.technology.pojo.query.MonthlyWorkingHoursConfigQuery;
|
||||
import com.nflg.product.technology.pojo.query.VirtualWorkingSaveQuery;
|
||||
import com.nflg.product.technology.pojo.query.WorkingTypeQuery;
|
||||
import com.nflg.product.technology.pojo.vo.CostConfigVO;
|
||||
import com.nflg.product.technology.pojo.vo.MonthlyWorkingHoursConfigVO;
|
||||
import com.nflg.product.technology.pojo.vo.VirtualWorkingVO;
|
||||
|
|
@ -41,7 +42,7 @@ public class CostConfigApi extends BaseApi {
|
|||
|
||||
@PostMapping("saveWorkingTypes")
|
||||
@ApiOperation("保存工时类型")
|
||||
public ResultVO saveVirtualWorking(@RequestBody List<String> types) {
|
||||
public ResultVO saveVirtualWorking(@RequestBody List<WorkingTypeQuery> types) {
|
||||
costConfigService.saveWorkingTypes(types);
|
||||
return ResultVO.success();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,11 @@ import java.math.BigDecimal;
|
|||
@TableName(value = "t_technology_paint_price_config")
|
||||
public class PaintCostConfigEntity extends EntityBase implements Serializable {
|
||||
|
||||
@TableId(value = "name", type = IdType.INPUT)
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
@ApiModelProperty(value = "主键行id")
|
||||
private Integer id;
|
||||
|
||||
@TableField(value = "name")
|
||||
@ApiModelProperty(value = "标签名称")
|
||||
private String name;
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,11 @@ import java.math.BigDecimal;
|
|||
@TableName(value = "t_technology_steels_cost_config")
|
||||
public class SteelsCostConfigEntity extends EntityBase implements Serializable {
|
||||
|
||||
@TableId(value = "name", type = IdType.INPUT)
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
@ApiModelProperty(value = "主键行id")
|
||||
private Integer id;
|
||||
|
||||
@TableField(value = "name")
|
||||
@ApiModelProperty(value = "分类名称")
|
||||
private String name;
|
||||
|
||||
|
|
|
|||
|
|
@ -22,7 +22,11 @@ import java.math.BigDecimal;
|
|||
@TableName(value = "t_technology_virtual_working")
|
||||
public class VirtualWorkingEntity extends EntityBase implements Serializable {
|
||||
|
||||
@TableId(value = "name", type = IdType.INPUT)
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
@ApiModelProperty(value = "主键行id")
|
||||
private Integer id;
|
||||
|
||||
@TableField(value = "name")
|
||||
@ApiModelProperty(value = "工时类型")
|
||||
private String name;
|
||||
|
||||
|
|
|
|||
|
|
@ -18,7 +18,11 @@ import java.time.LocalDateTime;
|
|||
@TableName(value = "t_technology_working_type")
|
||||
public class WorkingTypeEntity implements Serializable {
|
||||
|
||||
@TableId(value = "name", type = IdType.INPUT)
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
@ApiModelProperty(value = "主键行id")
|
||||
private Integer id;
|
||||
|
||||
@TableField(value = "name")
|
||||
@ApiModelProperty(value = "名称")
|
||||
private String name;
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import io.swagger.annotations.ApiModel;
|
|||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
|
||||
import javax.validation.constraints.Min;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
|
|
@ -19,8 +20,12 @@ import java.math.BigDecimal;
|
|||
@ApiModel(value = "com-nflg-product-technology-pojo-query-PaintCostConfig")
|
||||
public class PaintCostConfig implements Serializable {
|
||||
|
||||
@ApiModelProperty(value = "主键行id")
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty("标签名称")
|
||||
@NotBlank(message = "标签名称不能为空")
|
||||
@Length(max = 10, message = "标签名称不能超过10个字")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty("价格")
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import io.swagger.annotations.ApiModel;
|
|||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
|
||||
import javax.validation.constraints.Min;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
|
|
@ -19,8 +20,12 @@ import java.math.BigDecimal;
|
|||
@ApiModel(value = "com-nflg-product-technology-pojo-query-SteelsCostConfig")
|
||||
public class SteelsCostConfig implements Serializable {
|
||||
|
||||
@ApiModelProperty(value = "主键行id")
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty("分类名称")
|
||||
@NotBlank(message = "分类名称不能为空")
|
||||
@Length(max = 10, message = "分类名称不能超过10个字")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty("钢材价格")
|
||||
|
|
|
|||
|
|
@ -20,6 +20,9 @@ import java.math.BigDecimal;
|
|||
@ApiModel(value = "com-nflg-product-technology-pojo-query-VirtualWorking")
|
||||
public class VirtualWorking implements Serializable {
|
||||
|
||||
@ApiModelProperty(value = "主键行id")
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty("工时类型")
|
||||
@NotBlank(message = "工时类型不能为空")
|
||||
private String name;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,24 @@
|
|||
package com.nflg.product.technology.pojo.query;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
import org.hibernate.validator.constraints.Length;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import java.io.Serializable;
|
||||
|
||||
@Data
|
||||
@Accessors(chain = true)
|
||||
@ApiModel(value = "com-nflg-product-technology-pojo-query-WorkingTypeQuery")
|
||||
public class WorkingTypeQuery implements Serializable {
|
||||
|
||||
@ApiModelProperty(value = "主键行id")
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty("名称")
|
||||
@NotBlank(message = "名称不能为空")
|
||||
@Length(max = 10, message = "名称不能超过10个字")
|
||||
private String name;
|
||||
}
|
||||
|
|
@ -1,5 +1,8 @@
|
|||
package com.nflg.product.technology.pojo.vo;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.nflg.product.base.core.config.BigDecimalSerializer;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
|
@ -15,6 +18,8 @@ import java.util.Objects;
|
|||
public class MonthlyWorkingHoursConfigVO implements Serializable {
|
||||
|
||||
@ApiModelProperty("每月理论满负荷工时")
|
||||
@JsonFormat(pattern = "#.####")
|
||||
@JsonSerialize(using = BigDecimalSerializer.class)
|
||||
private BigDecimal monthlyWorkingHoursCost;
|
||||
|
||||
public BigDecimal getMonthlyWorkingHoursCost() {
|
||||
|
|
|
|||
|
|
@ -18,6 +18,9 @@ import java.math.BigDecimal;
|
|||
@ApiModel(value = "com-nflg-product-technology-pojo-vo-PaintCostConfigVO")
|
||||
public class PaintCostConfigVO extends EntityBase implements Serializable {
|
||||
|
||||
@ApiModelProperty(value = "主键行id")
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty("标签名称")
|
||||
private String name;
|
||||
|
||||
|
|
|
|||
|
|
@ -18,6 +18,9 @@ import java.math.BigDecimal;
|
|||
@ApiModel(value = "com-nflg-product-technology-pojo-vo-SteelsCostConfigVO")
|
||||
public class SteelsCostConfigVO extends EntityBase implements Serializable {
|
||||
|
||||
@ApiModelProperty(value = "主键行id")
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty("分类名称")
|
||||
private String name;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,9 @@
|
|||
package com.nflg.product.technology.pojo.vo;
|
||||
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.nflg.product.base.core.config.BigDecimalSerializer;
|
||||
import com.nflg.product.technology.pojo.query.VirtualWorking;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
|
@ -21,6 +24,8 @@ import java.time.LocalDateTime;
|
|||
public class VirtualWorkingItemVO extends VirtualWorking implements Serializable {
|
||||
|
||||
@ApiModelProperty(value = "每小时辅助费用")
|
||||
@JsonFormat(pattern = "#.####")
|
||||
@JsonSerialize(using = BigDecimalSerializer.class)
|
||||
private BigDecimal hourlyAuxiliaryFee;
|
||||
|
||||
public BigDecimal getHourlyAuxiliaryFee() {
|
||||
|
|
@ -29,9 +34,13 @@ public class VirtualWorkingItemVO extends VirtualWorking implements Serializable
|
|||
}
|
||||
|
||||
@ApiModelProperty(value = "水电及生产辅料耗材")
|
||||
@JsonFormat(pattern = "#.####")
|
||||
@JsonSerialize(using = BigDecimalSerializer.class)
|
||||
private BigDecimal auxiliaryMaterialsAndConsumables;
|
||||
|
||||
@ApiModelProperty(value = "辅助部门人工费")
|
||||
@JsonFormat(pattern = "#.####")
|
||||
@JsonSerialize(using = BigDecimalSerializer.class)
|
||||
private BigDecimal auxiliaryDepartmentLaborCosts;
|
||||
|
||||
@ApiModelProperty(value = "创建人")
|
||||
|
|
|
|||
|
|
@ -17,6 +17,9 @@ import java.time.LocalDateTime;
|
|||
@ApiModel(value = "com-nflg-product-technology-pojo-vo-WorkingTypeVO")
|
||||
public class WorkingTypeVO implements Serializable {
|
||||
|
||||
@ApiModelProperty(value = "主键行id")
|
||||
private Integer id;
|
||||
|
||||
@ApiModelProperty("工时类型")
|
||||
private String name;
|
||||
|
||||
|
|
|
|||
|
|
@ -2,13 +2,11 @@ package com.nflg.product.technology.service;
|
|||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.nflg.product.technology.constant.TechnologyConfigEnum;
|
||||
import com.nflg.product.technology.pojo.entity.VirtualWorkingEntity;
|
||||
import com.nflg.product.technology.pojo.entity.WorkingTypeEntity;
|
||||
import com.nflg.product.technology.pojo.query.CostConfigQuery;
|
||||
import com.nflg.product.technology.pojo.query.MonthlyWorkingHoursConfigQuery;
|
||||
import com.nflg.product.technology.pojo.query.VirtualWorkingManday;
|
||||
import com.nflg.product.technology.pojo.query.VirtualWorkingSaveQuery;
|
||||
import com.nflg.product.technology.pojo.query.*;
|
||||
import com.nflg.product.technology.pojo.vo.*;
|
||||
import com.nflg.product.technology.util.BigDecimalUtil;
|
||||
import com.nflg.product.technology.util.MapUtil;
|
||||
|
|
@ -19,6 +17,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|||
import javax.annotation.Resource;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
|
|
@ -64,15 +63,26 @@ public class CostConfigService {
|
|||
manday.setBenefit(technologyConfigService.getBenefit());
|
||||
vo.setManday(manday);
|
||||
List<VirtualWorkingEntity> virtualWorkingEntities = virtualWorkingService.list();
|
||||
List<WorkingTypeEntity> list = workingTypeService.list();
|
||||
list.forEach(l -> {
|
||||
if (virtualWorkingEntities.stream().noneMatch(v -> StrUtil.equals(l.getName(), v.getName()))) {
|
||||
VirtualWorkingEntity entity = new VirtualWorkingEntity();
|
||||
entity.setName(l.getName());
|
||||
virtualWorkingEntities.add(entity);
|
||||
}
|
||||
});
|
||||
if (CollectionUtil.isNotEmpty(virtualWorkingEntities)) {
|
||||
List<VirtualWorkingItemVO> virtualWorkingItemVOS = Convert.toList(VirtualWorkingItemVO.class, virtualWorkingEntities);
|
||||
virtualWorkingItemVOS.forEach(vw -> {
|
||||
vw.setAuxiliaryMaterialsAndConsumables(BigDecimalUtil.divide(vw.getFeeTotalYear()
|
||||
, new BigDecimal("12"), BigDecimalUtil.nullToDefault(technologyConfigService.getUserNum(), BigDecimal.ONE)
|
||||
vw.setAuxiliaryMaterialsAndConsumables(BigDecimalUtil.divide(
|
||||
vw.getFeeTotalYear()
|
||||
, new BigDecimal("12")
|
||||
, BigDecimalUtil.nullToDefault(technologyConfigService.getUserNum(), BigDecimal.ONE)
|
||||
, BigDecimalUtil.nullToDefault(technologyConfigService.getTheoreticalDailyWorkingHours(), BigDecimal.ONE)
|
||||
, BigDecimalUtil.nullToDefault(technologyConfigService.getTheoreticalWorkingDaysPerMonth(), BigDecimal.ONE)
|
||||
, BigDecimalUtil.nullToDefault(technologyConfigService.getCorrectionFactor(), BigDecimal.ONE)));
|
||||
vw.setAuxiliaryDepartmentLaborCosts(BigDecimalUtil.divide(vw.getFeeAssistantLaborCostTotal()
|
||||
vw.setAuxiliaryDepartmentLaborCosts(BigDecimalUtil.divide(
|
||||
vw.getFeeAssistantLaborCostTotal()
|
||||
, new BigDecimal("12")
|
||||
, BigDecimalUtil.nullToDefault(technologyConfigService.getMonthlyTheoreticalFullLoadWorkingHours(), BigDecimal.ONE)));
|
||||
});
|
||||
|
|
@ -89,8 +99,10 @@ public class CostConfigService {
|
|||
return Convert.toList(WorkingTypeVO.class, list);
|
||||
}
|
||||
|
||||
public void saveWorkingTypes(List<String> types) {
|
||||
@Transactional
|
||||
public void saveWorkingTypes(List<WorkingTypeQuery> types) {
|
||||
workingTypeService.save(types);
|
||||
virtualWorkingService.deleteNotInNames(types.stream().map(WorkingTypeQuery::getName).collect(Collectors.toList()));
|
||||
}
|
||||
|
||||
public void saveMonthlyWorkingHoursConfig(MonthlyWorkingHoursConfigQuery query) {
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
package com.nflg.product.technology.service;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.nflg.product.base.core.conmon.util.SessionUtil;
|
||||
import com.nflg.product.technology.mapper.master.PaintCostConfigMapper;
|
||||
|
|
@ -15,6 +16,7 @@ import java.time.LocalDateTime;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
|
|
@ -22,26 +24,33 @@ public class PaintCostConfigService extends ServiceImpl<PaintCostConfigMapper, P
|
|||
|
||||
@Transactional
|
||||
public void save(List<PaintCostConfig> configs) {
|
||||
List<PaintCostConfigEntity> all = list();
|
||||
remove(new QueryWrapper<>());
|
||||
List<PaintCostConfigEntity> forSave = new ArrayList<>();
|
||||
if (CollectionUtil.isEmpty(configs)) {
|
||||
remove(new QueryWrapper<>());
|
||||
return;
|
||||
}
|
||||
baseMapper.delete(Wrappers.lambdaQuery(PaintCostConfigEntity.class).notIn(PaintCostConfigEntity::getId, configs.stream().map(PaintCostConfig::getId).filter(Objects::nonNull).collect(Collectors.toSet())));
|
||||
List<PaintCostConfigEntity> forAdd = new ArrayList<>();
|
||||
List<PaintCostConfigEntity> forUpdate = new ArrayList<>();
|
||||
configs.forEach(c -> {
|
||||
PaintCostConfigEntity entity = all.stream()
|
||||
.filter(f -> StrUtil.equals(c.getName(), f.getName()))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
if (Objects.isNull(entity)) {
|
||||
entity = new PaintCostConfigEntity();
|
||||
PaintCostConfigEntity entity = new PaintCostConfigEntity();
|
||||
if (Objects.isNull(c.getId()) || 0 == c.getId()) {
|
||||
entity.setName(c.getName());
|
||||
entity.setCreateBy(SessionUtil.getRealName());
|
||||
entity.setCreateTime(LocalDateTime.now());
|
||||
forAdd.add(entity);
|
||||
} else {
|
||||
entity.setUpdateBy(SessionUtil.getUserName());
|
||||
entity.setId(c.getId());
|
||||
entity.setUpdateBy(SessionUtil.getRealName());
|
||||
entity.setUpdateTime(LocalDateTime.now());
|
||||
forUpdate.add(entity);
|
||||
}
|
||||
entity.setCost(c.getCost());
|
||||
forSave.add(entity);
|
||||
});
|
||||
saveOrUpdateBatch(forSave);
|
||||
if (CollectionUtil.isNotEmpty(forAdd)) {
|
||||
saveBatch(forAdd);
|
||||
}
|
||||
if (CollectionUtil.isNotEmpty(forUpdate)) {
|
||||
updateBatchById(forUpdate);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
package com.nflg.product.technology.service;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.nflg.product.base.core.conmon.util.SessionUtil;
|
||||
import com.nflg.product.technology.mapper.master.SteelsCostConfigMapper;
|
||||
|
|
@ -15,6 +16,7 @@ import java.time.LocalDateTime;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
|
|
@ -22,27 +24,34 @@ public class SteelsCostConfigService extends ServiceImpl<SteelsCostConfigMapper,
|
|||
|
||||
@Transactional
|
||||
public void save(List<SteelsCostConfig> configs) {
|
||||
List<SteelsCostConfigEntity> all = list();
|
||||
remove(new QueryWrapper<>());
|
||||
List<SteelsCostConfigEntity> forSave = new ArrayList<>();
|
||||
if (CollectionUtil.isEmpty(configs)) {
|
||||
remove(new QueryWrapper<>());
|
||||
return;
|
||||
}
|
||||
baseMapper.delete(Wrappers.lambdaQuery(SteelsCostConfigEntity.class).notIn(SteelsCostConfigEntity::getId, configs.stream().map(SteelsCostConfig::getId).filter(Objects::nonNull).collect(Collectors.toSet())));
|
||||
List<SteelsCostConfigEntity> forAdd = new ArrayList<>();
|
||||
List<SteelsCostConfigEntity> forUpdate = new ArrayList<>();
|
||||
configs.forEach(c -> {
|
||||
SteelsCostConfigEntity entity = all.stream()
|
||||
.filter(f -> StrUtil.equals(c.getName(), f.getName()))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
if (Objects.isNull(entity)) {
|
||||
entity = new SteelsCostConfigEntity();
|
||||
SteelsCostConfigEntity entity = new SteelsCostConfigEntity();
|
||||
if (Objects.isNull(c.getId()) || 0 == c.getId()) {
|
||||
entity.setName(c.getName());
|
||||
entity.setCreateBy(SessionUtil.getRealName());
|
||||
entity.setCreateTime(LocalDateTime.now());
|
||||
forAdd.add(entity);
|
||||
} else {
|
||||
entity.setUpdateBy(SessionUtil.getUserName());
|
||||
entity.setId(c.getId());
|
||||
entity.setUpdateBy(SessionUtil.getRealName());
|
||||
entity.setUpdateTime(LocalDateTime.now());
|
||||
forUpdate.add(entity);
|
||||
}
|
||||
entity.setCost(c.getCost());
|
||||
entity.setWastage(c.getWastage());
|
||||
forSave.add(entity);
|
||||
});
|
||||
saveOrUpdateBatch(forSave);
|
||||
if (CollectionUtil.isNotEmpty(forAdd)) {
|
||||
saveBatch(forAdd);
|
||||
}
|
||||
if (CollectionUtil.isNotEmpty(forUpdate)) {
|
||||
updateBatchById(forUpdate);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package com.nflg.product.technology.service;
|
|||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.nflg.product.base.core.conmon.util.SessionUtil;
|
||||
import com.nflg.product.technology.mapper.master.VirtualWorkingMapper;
|
||||
|
|
@ -9,6 +10,7 @@ import com.nflg.product.technology.pojo.entity.VirtualWorkingEntity;
|
|||
import com.nflg.product.technology.pojo.entity.WorkingTypeEntity;
|
||||
import com.nflg.product.technology.pojo.query.VirtualWorking;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
|
|
@ -17,6 +19,7 @@ import java.time.LocalDateTime;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author 曹鹏飞
|
||||
|
|
@ -31,27 +34,28 @@ public class VirtualWorkingService extends ServiceImpl<VirtualWorkingMapper, Vir
|
|||
|
||||
@Transactional()
|
||||
public void save(List<VirtualWorking> list) {
|
||||
List<VirtualWorkingEntity> all = list();
|
||||
remove(new QueryWrapper<>());
|
||||
if (CollectionUtil.isEmpty(list)) {
|
||||
remove(new QueryWrapper<>());
|
||||
return;
|
||||
}
|
||||
baseMapper.delete(Wrappers.lambdaQuery(VirtualWorkingEntity.class).notIn(VirtualWorkingEntity::getId, list.stream().map(VirtualWorking::getId).filter(Objects::nonNull).collect(Collectors.toSet())));
|
||||
List<WorkingTypeEntity> types = workingTypeService.list();
|
||||
List<VirtualWorkingEntity> forSave = new ArrayList<>();
|
||||
List<VirtualWorkingEntity> forAdd = new ArrayList<>();
|
||||
List<VirtualWorkingEntity> forUpdate = new ArrayList<>();
|
||||
list.forEach(vw -> {
|
||||
if (types.stream().anyMatch(t -> Objects.equals(t.getName(), vw.getName()))) {
|
||||
VirtualWorkingEntity entity = all.stream()
|
||||
.filter(a -> Objects.equals(a.getName(), vw.getName()))
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
if (Objects.isNull(entity)) {
|
||||
VirtualWorkingEntity entity = new VirtualWorkingEntity();
|
||||
if (Objects.isNull(vw.getId()) || 0 == vw.getId()) {
|
||||
entity = new VirtualWorkingEntity();
|
||||
entity.setName(vw.getName());
|
||||
entity.setCreateBy(SessionUtil.getRealName());
|
||||
entity.setCreateTime(LocalDateTime.now());
|
||||
forAdd.add(entity);
|
||||
} else {
|
||||
entity.setId(vw.getId());
|
||||
entity.setUpdateBy(SessionUtil.getRealName());
|
||||
entity.setUpdateTime(LocalDateTime.now());
|
||||
forUpdate.add(entity);
|
||||
}
|
||||
entity.setUserNum(vw.getUserNum());
|
||||
entity.setFeeTotalYear(vw.getFeeTotalYear());
|
||||
|
|
@ -60,11 +64,18 @@ public class VirtualWorkingService extends ServiceImpl<VirtualWorkingMapper, Vir
|
|||
entity.setFeeWorkshopOffice(vw.getFeeWorkshopOffice());
|
||||
entity.setFeeAssistantLaborCostTotal(vw.getFeeAssistantLaborCostTotal());
|
||||
entity.setFeeAssistant(vw.getFeeAssistant());
|
||||
forSave.add(entity);
|
||||
}
|
||||
});
|
||||
if (CollectionUtil.isNotEmpty(forSave)) {
|
||||
saveOrUpdateBatch(forSave);
|
||||
if (CollectionUtil.isNotEmpty(forAdd)) {
|
||||
saveBatch(forAdd);
|
||||
}
|
||||
if (CollectionUtil.isNotEmpty(forUpdate)) {
|
||||
updateBatchById(forUpdate);
|
||||
}
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void deleteNotInNames(@NotNull List<String> collect) {
|
||||
baseMapper.delete(Wrappers.lambdaQuery(VirtualWorkingEntity.class).notIn(VirtualWorkingEntity::getName, collect));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,13 @@
|
|||
package com.nflg.product.technology.service;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.nflg.product.base.core.conmon.util.SessionUtil;
|
||||
import com.nflg.product.technology.mapper.master.WorkingTypeMapper;
|
||||
import com.nflg.product.technology.pojo.entity.WorkingTypeEntity;
|
||||
import com.nflg.product.technology.util.MapUtil;
|
||||
import com.nflg.product.technology.pojo.query.WorkingTypeQuery;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
|
@ -13,6 +15,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
|
|
@ -20,27 +23,24 @@ import java.util.stream.Collectors;
|
|||
public class WorkingTypeService extends ServiceImpl<WorkingTypeMapper, WorkingTypeEntity> {
|
||||
|
||||
@Transactional
|
||||
public void save(List<String> list) {
|
||||
List<String> datas = list().stream().map(WorkingTypeEntity::getName).collect(Collectors.toList());
|
||||
List<String> difference = datas.stream()
|
||||
.filter(element -> !list.contains(element))
|
||||
.collect(Collectors.toList());
|
||||
if (CollectionUtil.isNotEmpty(difference)) {
|
||||
removeByIds(difference);
|
||||
public void save(List<WorkingTypeQuery> list) {
|
||||
if (CollectionUtil.isEmpty(list)) {
|
||||
remove(new QueryWrapper<>());
|
||||
return;
|
||||
}
|
||||
difference = list.stream()
|
||||
.filter(element -> !datas.contains(element))
|
||||
.collect(Collectors.toList());
|
||||
if (CollectionUtil.isNotEmpty(difference)) {
|
||||
List<WorkingTypeEntity> adds = new ArrayList<>(MapUtil.calculateInitialCapacity(difference.size()));
|
||||
difference.forEach(d -> {
|
||||
baseMapper.delete(Wrappers.lambdaQuery(WorkingTypeEntity.class).notIn(WorkingTypeEntity::getId, list.stream().map(WorkingTypeQuery::getId).filter(Objects::nonNull).collect(Collectors.toSet())));
|
||||
List<WorkingTypeEntity> forAdd = new ArrayList<>();
|
||||
list.forEach(l -> {
|
||||
if (Objects.isNull(l.getId()) || 0 == l.getId()) {
|
||||
WorkingTypeEntity entity = new WorkingTypeEntity();
|
||||
entity.setName(d);
|
||||
entity.setName(l.getName());
|
||||
entity.setCreateBy(SessionUtil.getRealName());
|
||||
entity.setCreateTime(LocalDateTime.now());
|
||||
adds.add(entity);
|
||||
});
|
||||
saveBatch(adds);
|
||||
forAdd.add(entity);
|
||||
}
|
||||
});
|
||||
if (CollectionUtil.isNotEmpty(forAdd)) {
|
||||
saveBatch(forAdd);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ public class BigDecimalUtil {
|
|||
if (value.compareTo(BigDecimal.ZERO) == 0) {
|
||||
throw new ArithmeticException("被除数不能为零");
|
||||
}
|
||||
result = result.divide(value, 4, RoundingMode.HALF_UP);
|
||||
result = result.divide(value, 8, RoundingMode.HALF_UP);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,20 @@
|
|||
import com.nflg.product.technology.util.BigDecimalUtil;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
public class BigDecimalUtilTest {
|
||||
|
||||
@Test
|
||||
public void test1() {
|
||||
BigDecimal feeTotalYear = new BigDecimal("4714.3424");
|
||||
BigDecimal monthOfYear = new BigDecimal("12");
|
||||
BigDecimal userNum = new BigDecimal("595.0000");
|
||||
BigDecimal theoreticalDailyWorkingHours = new BigDecimal("12");
|
||||
BigDecimal theoreticalWorkingDaysPerMonth = new BigDecimal("6");
|
||||
BigDecimal correctionFactor = new BigDecimal("0.06");
|
||||
BigDecimal result = BigDecimalUtil.divide(feeTotalYear, monthOfYear, userNum, theoreticalDailyWorkingHours, theoreticalWorkingDaysPerMonth, correctionFactor);
|
||||
//BigDecimal result = BigDecimalUtil.divide(feeTotalYear, monthOfYear);
|
||||
System.out.println(result);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue