feature: 实现设计成本维护页面相关接口
This commit is contained in:
parent
ab7df1140b
commit
ca874cf904
|
|
@ -15,12 +15,9 @@ import nflg.product.common.vo.ResultVO;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
|
import javax.validation.Valid;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
|
||||||
* @author 曹鹏飞
|
|
||||||
* @date 2024/11/23 09:25:45
|
|
||||||
*/
|
|
||||||
@Api(tags = "设计成本维护")
|
@Api(tags = "设计成本维护")
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("cost/config")
|
@RequestMapping("cost/config")
|
||||||
|
|
@ -57,13 +54,13 @@ public class CostConfigApi extends BaseApi {
|
||||||
|
|
||||||
@PostMapping("saveMonthlyWorkingHoursConfig")
|
@PostMapping("saveMonthlyWorkingHoursConfig")
|
||||||
@ApiOperation("保存每月理论满负荷工时")
|
@ApiOperation("保存每月理论满负荷工时")
|
||||||
public ResultVO saveMonthlyWorkingHoursConfig(@RequestBody MonthlyWorkingHoursConfigQuery query) {
|
public ResultVO saveMonthlyWorkingHoursConfig(@Valid @RequestBody MonthlyWorkingHoursConfigQuery query) {
|
||||||
costConfigService.saveMonthlyWorkingHoursConfig(query);
|
costConfigService.saveMonthlyWorkingHoursConfig(query);
|
||||||
return ResultVO.success();
|
return ResultVO.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("getMonthlyWorkingHoursConfig")
|
@GetMapping("getMonthlyWorkingHoursConfig")
|
||||||
@ApiOperation("获取工时类型")
|
@ApiOperation("获取每月理论满负荷工时")
|
||||||
public ResultVO<MonthlyWorkingHoursConfigVO> getMonthlyWorkingHoursConfig() {
|
public ResultVO<MonthlyWorkingHoursConfigVO> getMonthlyWorkingHoursConfig() {
|
||||||
return ResultVO.success(costConfigService.getMonthlyWorkingHoursConfig());
|
return ResultVO.success(costConfigService.getMonthlyWorkingHoursConfig());
|
||||||
}
|
}
|
||||||
|
|
@ -71,7 +68,7 @@ public class CostConfigApi extends BaseApi {
|
||||||
@PostMapping("saveCostConfig")
|
@PostMapping("saveCostConfig")
|
||||||
@ApiOperation("保存价格配置")
|
@ApiOperation("保存价格配置")
|
||||||
public ResultVO saveCost(@RequestBody CostConfigQuery query) {
|
public ResultVO saveCost(@RequestBody CostConfigQuery query) {
|
||||||
costConfigService.saveCost(query);
|
costConfigService.saveCostConfig(query);
|
||||||
return ResultVO.success();
|
return ResultVO.success();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
package com.nflg.product.technology.constant;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Getter
|
||||||
|
public enum TechnologyConfigEnum implements ValueEnum<String> {
|
||||||
|
|
||||||
|
HOURLY_WAGES("hourlyWages", "计件人工工时工资(一线)"),
|
||||||
|
BENEFIT("benefit", "一线人工福利"),
|
||||||
|
USER_NUM("userNum", "车间一线人数"),
|
||||||
|
THEORETICAL_DAILY_WORKING_HOURS("theoreticalDailyWorkingHours", "每人每日理论工时数"),
|
||||||
|
THEORETICAL_WORKING_DAYS_PER_MONTH("theoreticalWorkingDaysPerMonth", "每月理论工作天数"),
|
||||||
|
CORRECTION_FACTOR("correctionFactor", "工时修正系数K值"),
|
||||||
|
MONTHLY_THEORETICAL_FULL_LOAD_WORKING_HOURS("monthlyTheoreticalFullLoadWorkingHours", "每月理论满负荷工时");
|
||||||
|
|
||||||
|
private final String value;
|
||||||
|
private final String description;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
package com.nflg.product.technology.mapper.master;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.nflg.product.technology.pojo.entity.PaintCostConfigEntity;
|
||||||
|
|
||||||
|
public interface PaintCostConfigMapper extends BaseMapper<PaintCostConfigEntity> {
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
package com.nflg.product.technology.mapper.master;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.nflg.product.technology.pojo.entity.SteelsCostConfigEntity;
|
||||||
|
|
||||||
|
public interface SteelsCostConfigMapper extends BaseMapper<SteelsCostConfigEntity> {
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,7 @@
|
||||||
|
package com.nflg.product.technology.mapper.master;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.nflg.product.technology.pojo.entity.WorkingTypeEntity;
|
||||||
|
|
||||||
|
public interface WorkingTypeMapper extends BaseMapper<WorkingTypeEntity> {
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,28 @@
|
||||||
|
package com.nflg.product.technology.pojo.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Accessors(chain = true)
|
||||||
|
@ApiModel(value = "com-nflg-product-technology-pojo-entity-PaintCostConfigEntity")
|
||||||
|
@TableName(value = "t_technology_paint_price_config")
|
||||||
|
public class PaintCostConfigEntity extends EntityBase implements Serializable {
|
||||||
|
|
||||||
|
@TableId(value = "name", type = IdType.INPUT)
|
||||||
|
@ApiModelProperty(value = "标签名称")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@TableField(value = "cost")
|
||||||
|
@ApiModelProperty(value = "价格")
|
||||||
|
private BigDecimal cost;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,32 @@
|
||||||
|
package com.nflg.product.technology.pojo.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Accessors(chain = true)
|
||||||
|
@ApiModel(value = "com-nflg-product-technology-pojo-entity-SteelsCostConfigEntity")
|
||||||
|
@TableName(value = "t_technology_steels_cost_config")
|
||||||
|
public class SteelsCostConfigEntity extends EntityBase implements Serializable {
|
||||||
|
|
||||||
|
@TableId(value = "name", type = IdType.INPUT)
|
||||||
|
@ApiModelProperty(value = "分类名称")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@TableField(value = "cost")
|
||||||
|
@ApiModelProperty(value = "钢材价格")
|
||||||
|
private BigDecimal cost;
|
||||||
|
|
||||||
|
@TableField(value = "wastage")
|
||||||
|
@ApiModelProperty(value = "损耗")
|
||||||
|
private BigDecimal wastage;
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,32 @@
|
||||||
|
package com.nflg.product.technology.pojo.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableField;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@Accessors(chain = true)
|
||||||
|
@ApiModel(value = "com-nflg-product-technology-pojo-entity-WorkingTypeEntity")
|
||||||
|
@TableName(value = "t_technology_working_type")
|
||||||
|
public class WorkingTypeEntity implements Serializable {
|
||||||
|
|
||||||
|
@TableId(value = "name", type = IdType.INPUT)
|
||||||
|
@ApiModelProperty(value = "名称")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@TableField(value = "create_by")
|
||||||
|
@ApiModelProperty(value = "创建人")
|
||||||
|
private String createBy;
|
||||||
|
|
||||||
|
@TableField(value = "create_time")
|
||||||
|
@ApiModelProperty(value = "创建时间")
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
}
|
||||||
|
|
@ -5,7 +5,6 @@ import io.swagger.annotations.ApiModelProperty;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.experimental.Accessors;
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
import javax.validation.constraints.NotNull;
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
@ -19,7 +18,6 @@ import java.util.List;
|
||||||
public class VirtualWorkingSaveQuery implements Serializable {
|
public class VirtualWorkingSaveQuery implements Serializable {
|
||||||
|
|
||||||
@ApiModelProperty("人工")
|
@ApiModelProperty("人工")
|
||||||
@NotNull(message = "人工信息不能为空")
|
|
||||||
private VirtualWorkingManday manday;
|
private VirtualWorkingManday manday;
|
||||||
|
|
||||||
@ApiModelProperty("虚拟工作中心")
|
@ApiModelProperty("虚拟工作中心")
|
||||||
|
|
|
||||||
|
|
@ -8,18 +8,14 @@ import lombok.experimental.Accessors;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
/**
|
|
||||||
* @author 曹鹏飞
|
|
||||||
* @date 2024/11/23 14:31:29
|
|
||||||
*/
|
|
||||||
@Data
|
@Data
|
||||||
@Accessors(chain = true)
|
@Accessors(chain = true)
|
||||||
@ApiModel(value = "com-nflg-product-technology-pojo-vo-CostConfigVO")
|
@ApiModel(value = "com-nflg-product-technology-pojo-vo-CostConfigVO")
|
||||||
public class CostConfigVO implements Serializable {
|
public class CostConfigVO implements Serializable {
|
||||||
|
|
||||||
@ApiModelProperty("钢材价格")
|
@ApiModelProperty("钢材价格")
|
||||||
private List<SteelsCostConfigVO> steelsCost;
|
private List<SteelsCostConfigVO> steelsCostConfig;
|
||||||
|
|
||||||
@ApiModelProperty("油漆价格")
|
@ApiModelProperty("油漆价格")
|
||||||
private List<PaintCostConfigVO> paintCost;
|
private List<PaintCostConfigVO> paintCostConfig;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -7,11 +7,8 @@ import lombok.experimental.Accessors;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
|
||||||
* @author 曹鹏飞
|
|
||||||
* @date 2024/11/23 13:58:16
|
|
||||||
*/
|
|
||||||
@Data
|
@Data
|
||||||
@Accessors(chain = true)
|
@Accessors(chain = true)
|
||||||
@ApiModel(value = "com-nflg-product-technology-pojo-vo-MonthlyWorkingHoursConfigVO")
|
@ApiModel(value = "com-nflg-product-technology-pojo-vo-MonthlyWorkingHoursConfigVO")
|
||||||
|
|
@ -21,10 +18,21 @@ public class MonthlyWorkingHoursConfigVO implements Serializable {
|
||||||
private BigDecimal monthlyWorkingHoursCost;
|
private BigDecimal monthlyWorkingHoursCost;
|
||||||
|
|
||||||
public BigDecimal getMonthlyWorkingHoursCost() {
|
public BigDecimal getMonthlyWorkingHoursCost() {
|
||||||
|
if (Objects.isNull(this.getCorrectionFactor())) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
return this.getCorrectionFactor()
|
return this.getCorrectionFactor()
|
||||||
.multiply(BigDecimal.valueOf(this.getUserNum()))
|
.multiply(BigDecimal.valueOf(nullToOne(this.getUserNum())))
|
||||||
.multiply(BigDecimal.valueOf(this.getDailyHours()))
|
.multiply(BigDecimal.valueOf(nullToOne(this.getDailyHours())))
|
||||||
.multiply(BigDecimal.valueOf(this.getMonthlyWorkingDays()));
|
.multiply(BigDecimal.valueOf(nullToOne(this.getMonthlyWorkingDays())));
|
||||||
|
}
|
||||||
|
|
||||||
|
private Integer nullToOne(Integer value) {
|
||||||
|
if (Objects.isNull(value)) {
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ApiModelProperty("车间一线人数")
|
@ApiModelProperty("车间一线人数")
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package com.nflg.product.technology.pojo.vo;
|
package com.nflg.product.technology.pojo.vo;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.NumberUtil;
|
||||||
import com.nflg.product.technology.pojo.query.VirtualWorking;
|
import com.nflg.product.technology.pojo.query.VirtualWorking;
|
||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
|
@ -7,6 +8,7 @@ import lombok.Data;
|
||||||
import lombok.experimental.Accessors;
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -18,6 +20,20 @@ import java.time.LocalDateTime;
|
||||||
@ApiModel(value = "com-nflg-product-technology-pojo-vo-VirtualWorkingItemVO")
|
@ApiModel(value = "com-nflg-product-technology-pojo-vo-VirtualWorkingItemVO")
|
||||||
public class VirtualWorkingItemVO extends VirtualWorking implements Serializable {
|
public class VirtualWorkingItemVO extends VirtualWorking implements Serializable {
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "每小时辅助费用")
|
||||||
|
private BigDecimal hourlyAuxiliaryFee;
|
||||||
|
|
||||||
|
public BigDecimal getHourlyAuxiliaryFee() {
|
||||||
|
return NumberUtil.add(getAuxiliaryMaterialsAndConsumables(), getFeeEquipmentDepreciation()
|
||||||
|
, getFeeWorkshopLaborCost(), getFeeWorkshopOffice(), getAuxiliaryDepartmentLaborCosts(), getFeeAssistant());
|
||||||
|
}
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "水电及生产辅料耗材")
|
||||||
|
private BigDecimal auxiliaryMaterialsAndConsumables;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "辅助部门人工费")
|
||||||
|
private BigDecimal auxiliaryDepartmentLaborCosts;
|
||||||
|
|
||||||
@ApiModelProperty(value = "创建人")
|
@ApiModelProperty(value = "创建人")
|
||||||
private String createBy;
|
private String createBy;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,23 +1,25 @@
|
||||||
package com.nflg.product.technology.service;
|
package com.nflg.product.technology.service;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
|
import cn.hutool.core.convert.Convert;
|
||||||
|
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.CostConfigQuery;
|
||||||
import com.nflg.product.technology.pojo.query.MonthlyWorkingHoursConfigQuery;
|
import com.nflg.product.technology.pojo.query.MonthlyWorkingHoursConfigQuery;
|
||||||
import com.nflg.product.technology.pojo.query.VirtualWorkingManday;
|
import com.nflg.product.technology.pojo.query.VirtualWorkingManday;
|
||||||
import com.nflg.product.technology.pojo.query.VirtualWorkingSaveQuery;
|
import com.nflg.product.technology.pojo.query.VirtualWorkingSaveQuery;
|
||||||
import com.nflg.product.technology.pojo.vo.*;
|
import com.nflg.product.technology.pojo.vo.*;
|
||||||
import com.nflg.product.technology.util.RandomUtil;
|
import com.nflg.product.technology.util.BigDecimalUtil;
|
||||||
|
import com.nflg.product.technology.util.MapUtil;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.time.LocalDateTime;
|
import java.math.BigDecimal;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author 曹鹏飞
|
|
||||||
* @date 2024/11/23 10:07:22
|
|
||||||
*/
|
|
||||||
@Component
|
@Component
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class CostConfigService {
|
public class CostConfigService {
|
||||||
|
|
@ -25,107 +27,100 @@ public class CostConfigService {
|
||||||
@Resource
|
@Resource
|
||||||
private TechnologyConfigService technologyConfigService;
|
private TechnologyConfigService technologyConfigService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private WorkingTypeService workingTypeService;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private VirtualWorkingService virtualWorkingService;
|
private VirtualWorkingService virtualWorkingService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private SteelsCostConfigService steelsCostConfigService;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private PaintCostConfigService paintCostConfigService;
|
||||||
|
|
||||||
|
@Transactional
|
||||||
public void saveVirtualWorking(VirtualWorkingSaveQuery query) {
|
public void saveVirtualWorking(VirtualWorkingSaveQuery query) {
|
||||||
// TODO 待实现
|
VirtualWorkingManday manday = query.getManday();
|
||||||
|
Map<String, BigDecimal> configs = new HashMap<>(MapUtil.calculateInitialCapacity(2));
|
||||||
|
if (Objects.nonNull(manday)) {
|
||||||
|
if (Objects.nonNull(manday.getHourlyWages())) {
|
||||||
|
configs.put(TechnologyConfigEnum.HOURLY_WAGES.getValue(), query.getManday().getHourlyWages());
|
||||||
|
}
|
||||||
|
if (Objects.nonNull(manday.getBenefit())) {
|
||||||
|
configs.put(TechnologyConfigEnum.BENEFIT.getValue(), query.getManday().getBenefit());
|
||||||
|
}
|
||||||
|
if (CollectionUtil.isNotEmpty(configs)) {
|
||||||
|
technologyConfigService.save(configs);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
virtualWorkingService.save(query.getVirtualWorking());
|
||||||
}
|
}
|
||||||
|
|
||||||
public VirtualWorkingVO getVirtualWorking() {
|
public VirtualWorkingVO getVirtualWorking() {
|
||||||
// TODO 待实现
|
|
||||||
VirtualWorkingVO vo = new VirtualWorkingVO();
|
VirtualWorkingVO vo = new VirtualWorkingVO();
|
||||||
vo.setManday(new VirtualWorkingManday()
|
VirtualWorkingManday manday = new VirtualWorkingManday();
|
||||||
.setHourlyWages(RandomUtil.randomBigDecimal(0, 10000, 2))
|
manday.setHourlyWages(technologyConfigService.getHourlyWages());
|
||||||
.setBenefit(RandomUtil.randomBigDecimal(1000, 2)));
|
manday.setBenefit(technologyConfigService.getBenefit());
|
||||||
int count = RandomUtil.randomInt(0, 20);
|
vo.setManday(manday);
|
||||||
List<VirtualWorkingItemVO> virtualWorkings = new ArrayList<>();
|
List<VirtualWorkingEntity> virtualWorkingEntities = virtualWorkingService.list();
|
||||||
for (int i = 0; i < count; i++) {
|
if (CollectionUtil.isNotEmpty(virtualWorkingEntities)) {
|
||||||
VirtualWorkingItemVO virtualWorking = new VirtualWorkingItemVO();
|
List<VirtualWorkingItemVO> virtualWorkingItemVOS = Convert.toList(VirtualWorkingItemVO.class, virtualWorkingEntities);
|
||||||
virtualWorking.setName("工时类型" + i);
|
virtualWorkingItemVOS.forEach(vw -> {
|
||||||
virtualWorking.setUserNum(RandomUtil.randomInt(1, 10000));
|
vw.setAuxiliaryMaterialsAndConsumables(BigDecimalUtil.divide(vw.getFeeTotalYear()
|
||||||
virtualWorking.setFeeTotalYear(RandomUtil.randomBigDecimal(1000000, 2));
|
, new BigDecimal("12"), BigDecimalUtil.nullToDefault(technologyConfigService.getUserNum(), BigDecimal.ONE)
|
||||||
virtualWorking.setFeeEquipmentDepreciation(RandomUtil.randomBigDecimal(10000000, 2));
|
, BigDecimalUtil.nullToDefault(technologyConfigService.getTheoreticalDailyWorkingHours(), BigDecimal.ONE)
|
||||||
virtualWorking.setFeeWorkshopLaborCost(RandomUtil.randomBigDecimal(10000000, 2));
|
, BigDecimalUtil.nullToDefault(technologyConfigService.getTheoreticalWorkingDaysPerMonth(), BigDecimal.ONE)
|
||||||
virtualWorking.setFeeWorkshopOffice(RandomUtil.randomBigDecimal(10000000, 2));
|
, BigDecimalUtil.nullToDefault(technologyConfigService.getCorrectionFactor(), BigDecimal.ONE)));
|
||||||
virtualWorking.setFeeAssistantLaborCostTotal(RandomUtil.randomBigDecimal(10000000, 2));
|
vw.setAuxiliaryDepartmentLaborCosts(BigDecimalUtil.divide(vw.getFeeAssistantLaborCostTotal()
|
||||||
virtualWorking.setFeeAssistant(RandomUtil.randomBigDecimal(10000000, 2));
|
, new BigDecimal("12")
|
||||||
virtualWorking.setCreateBy(RandomUtil.randomString(10));
|
, BigDecimalUtil.nullToDefault(technologyConfigService.getMonthlyTheoreticalFullLoadWorkingHours(), BigDecimal.ONE)));
|
||||||
virtualWorking.setCreateTime(LocalDateTime.now().minusMinutes(RandomUtil.randomInt(0, 1000)));
|
});
|
||||||
virtualWorking.setUpdateBy(RandomUtil.randomString(10));
|
vo.setVirtualWorking(virtualWorkingItemVOS);
|
||||||
virtualWorking.setUpdateTime(LocalDateTime.now());
|
|
||||||
virtualWorkings.add(virtualWorking);
|
|
||||||
}
|
}
|
||||||
vo.setVirtualWorking(virtualWorkings);
|
|
||||||
return vo;
|
return vo;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<WorkingTypeVO> getWorkingTypes() {
|
public List<WorkingTypeVO> getWorkingTypes() {
|
||||||
// TODO 待实现
|
List<WorkingTypeEntity> list = workingTypeService.list();
|
||||||
List<WorkingTypeVO> list = new ArrayList<>();
|
if (CollectionUtil.isEmpty(list)) {
|
||||||
int count = RandomUtil.randomInt(0, 20);
|
return Collections.emptyList();
|
||||||
for (int i = 0; i < count; i++) {
|
|
||||||
WorkingTypeVO vo = new WorkingTypeVO();
|
|
||||||
vo.setName("工时类型" + i);
|
|
||||||
vo.setCreateBy(RandomUtil.randomString(5));
|
|
||||||
vo.setCreateTime(LocalDateTime.now().minusMinutes(RandomUtil.randomInt(500)));
|
|
||||||
list.add(vo);
|
|
||||||
}
|
}
|
||||||
return list;
|
return Convert.toList(WorkingTypeVO.class, list);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void saveWorkingTypes(List<String> types) {
|
public void saveWorkingTypes(List<String> types) {
|
||||||
// TODO 待实现
|
workingTypeService.save(types);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void saveMonthlyWorkingHoursConfig(MonthlyWorkingHoursConfigQuery query) {
|
public void saveMonthlyWorkingHoursConfig(MonthlyWorkingHoursConfigQuery query) {
|
||||||
// TODO 待实现
|
Map<String, BigDecimal> configs = new HashMap<>(MapUtil.calculateInitialCapacity(4));
|
||||||
|
configs.put(TechnologyConfigEnum.USER_NUM.getValue(), BigDecimal.valueOf(query.getUserNum()));
|
||||||
|
configs.put(TechnologyConfigEnum.THEORETICAL_DAILY_WORKING_HOURS.getValue(), BigDecimal.valueOf(query.getDailyHours()));
|
||||||
|
configs.put(TechnologyConfigEnum.THEORETICAL_WORKING_DAYS_PER_MONTH.getValue(), BigDecimal.valueOf(query.getMonthlyWorkingDays()));
|
||||||
|
configs.put(TechnologyConfigEnum.CORRECTION_FACTOR.getValue(), query.getCorrectionFactor());
|
||||||
|
technologyConfigService.save(configs);
|
||||||
}
|
}
|
||||||
|
|
||||||
public MonthlyWorkingHoursConfigVO getMonthlyWorkingHoursConfig() {
|
public MonthlyWorkingHoursConfigVO getMonthlyWorkingHoursConfig() {
|
||||||
// TODO 待实现
|
|
||||||
MonthlyWorkingHoursConfigVO vo = new MonthlyWorkingHoursConfigVO();
|
MonthlyWorkingHoursConfigVO vo = new MonthlyWorkingHoursConfigVO();
|
||||||
vo.setUserNum(RandomUtil.randomInt(500));
|
vo.setUserNum(BigDecimalUtil.toInteger(technologyConfigService.getUserNum()));
|
||||||
vo.setDailyHours(RandomUtil.randomInt(1, 24));
|
vo.setDailyHours(BigDecimalUtil.toInteger(technologyConfigService.getTheoreticalDailyWorkingHours()));
|
||||||
vo.setMonthlyWorkingDays(RandomUtil.randomInt(1, 30));
|
vo.setMonthlyWorkingDays(BigDecimalUtil.toInteger(technologyConfigService.getTheoreticalWorkingDaysPerMonth()));
|
||||||
vo.setCorrectionFactor(RandomUtil.randomBigDecimal(1, 2));
|
vo.setCorrectionFactor(technologyConfigService.getCorrectionFactor());
|
||||||
return vo;
|
return vo;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void saveCost(CostConfigQuery query) {
|
@Transactional
|
||||||
// TODO 待实现
|
public void saveCostConfig(CostConfigQuery query) {
|
||||||
|
steelsCostConfigService.save(query.getSteelsCostConfig());
|
||||||
|
paintCostConfigService.save(query.getPaintCostConfig());
|
||||||
}
|
}
|
||||||
|
|
||||||
public CostConfigVO getCostConfig() {
|
public CostConfigVO getCostConfig() {
|
||||||
// TODO 待实现
|
|
||||||
CostConfigVO vo = new CostConfigVO();
|
CostConfigVO vo = new CostConfigVO();
|
||||||
List<SteelsCostConfigVO> steelsCost = new ArrayList<>();
|
vo.setSteelsCostConfig(Convert.toList(SteelsCostConfigVO.class, steelsCostConfigService.list()));
|
||||||
int count = RandomUtil.randomInt(0, 20);
|
vo.setPaintCostConfig(Convert.toList(PaintCostConfigVO.class, paintCostConfigService.list()));
|
||||||
for (int i = 0; i < count; i++) {
|
|
||||||
SteelsCostConfigVO steelCost = new SteelsCostConfigVO();
|
|
||||||
steelCost.setName("钢材" + i);
|
|
||||||
steelCost.setCost(RandomUtil.randomBigDecimal(100000, 2));
|
|
||||||
steelCost.setWastage(RandomUtil.randomBigDecimal(100, 2));
|
|
||||||
steelCost.setCreateBy(RandomUtil.randomString(10));
|
|
||||||
steelCost.setCreateTime(LocalDateTime.now().minusMinutes(RandomUtil.randomInt(0, 1000)));
|
|
||||||
steelCost.setUpdateBy(RandomUtil.randomString(10));
|
|
||||||
steelCost.setUpdateTime(LocalDateTime.now());
|
|
||||||
steelsCost.add(steelCost);
|
|
||||||
}
|
|
||||||
vo.setSteelsCost(steelsCost);
|
|
||||||
List<PaintCostConfigVO> paintCost = new ArrayList<>();
|
|
||||||
count = RandomUtil.randomInt(0, count);
|
|
||||||
for (int i = 0; i < count; i++) {
|
|
||||||
PaintCostConfigVO paintCostConfigVO = new PaintCostConfigVO();
|
|
||||||
paintCostConfigVO.setName("油漆" + i);
|
|
||||||
paintCostConfigVO.setCost(RandomUtil.randomBigDecimal(100000, 2));
|
|
||||||
paintCostConfigVO.setCreateBy(RandomUtil.randomString(10));
|
|
||||||
paintCostConfigVO.setCreateTime(LocalDateTime.now().minusMinutes(RandomUtil.randomInt(0, 1000)));
|
|
||||||
paintCostConfigVO.setUpdateBy(RandomUtil.randomString(10));
|
|
||||||
paintCostConfigVO.setUpdateTime(LocalDateTime.now());
|
|
||||||
paintCost.add(paintCostConfigVO);
|
|
||||||
}
|
|
||||||
vo.setPaintCost(paintCost);
|
|
||||||
return vo;
|
return vo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,47 @@
|
||||||
|
package com.nflg.product.technology.service;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
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;
|
||||||
|
import com.nflg.product.technology.pojo.entity.PaintCostConfigEntity;
|
||||||
|
import com.nflg.product.technology.pojo.query.PaintCostConfig;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@Slf4j
|
||||||
|
public class PaintCostConfigService extends ServiceImpl<PaintCostConfigMapper, PaintCostConfigEntity> {
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
public void save(List<PaintCostConfig> configs) {
|
||||||
|
List<PaintCostConfigEntity> all = list();
|
||||||
|
remove(new QueryWrapper<>());
|
||||||
|
List<PaintCostConfigEntity> forSave = 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();
|
||||||
|
entity.setName(c.getName());
|
||||||
|
entity.setCreateBy(SessionUtil.getRealName());
|
||||||
|
entity.setCreateTime(LocalDateTime.now());
|
||||||
|
} else {
|
||||||
|
entity.setUpdateBy(SessionUtil.getUserName());
|
||||||
|
entity.setUpdateTime(LocalDateTime.now());
|
||||||
|
}
|
||||||
|
entity.setCost(c.getCost());
|
||||||
|
forSave.add(entity);
|
||||||
|
});
|
||||||
|
saveOrUpdateBatch(forSave);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,48 @@
|
||||||
|
package com.nflg.product.technology.service;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.StrUtil;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
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;
|
||||||
|
import com.nflg.product.technology.pojo.entity.SteelsCostConfigEntity;
|
||||||
|
import com.nflg.product.technology.pojo.query.SteelsCostConfig;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@Slf4j
|
||||||
|
public class SteelsCostConfigService extends ServiceImpl<SteelsCostConfigMapper, SteelsCostConfigEntity> {
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
public void save(List<SteelsCostConfig> configs) {
|
||||||
|
List<SteelsCostConfigEntity> all = list();
|
||||||
|
remove(new QueryWrapper<>());
|
||||||
|
List<SteelsCostConfigEntity> forSave = 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();
|
||||||
|
entity.setName(c.getName());
|
||||||
|
entity.setCreateBy(SessionUtil.getRealName());
|
||||||
|
entity.setCreateTime(LocalDateTime.now());
|
||||||
|
} else {
|
||||||
|
entity.setUpdateBy(SessionUtil.getUserName());
|
||||||
|
entity.setUpdateTime(LocalDateTime.now());
|
||||||
|
}
|
||||||
|
entity.setCost(c.getCost());
|
||||||
|
entity.setWastage(c.getWastage());
|
||||||
|
forSave.add(entity);
|
||||||
|
});
|
||||||
|
saveOrUpdateBatch(forSave);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,10 +1,21 @@
|
||||||
package com.nflg.product.technology.service;
|
package com.nflg.product.technology.service;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
|
import cn.hutool.core.util.NumberUtil;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.nflg.product.base.core.conmon.util.SessionUtil;
|
||||||
|
import com.nflg.product.technology.constant.TechnologyConfigEnum;
|
||||||
import com.nflg.product.technology.mapper.master.TechnologyConfigMapper;
|
import com.nflg.product.technology.mapper.master.TechnologyConfigMapper;
|
||||||
import com.nflg.product.technology.pojo.entity.TechnologyConfigEntity;
|
import com.nflg.product.technology.pojo.entity.TechnologyConfigEntity;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author 曹鹏飞
|
* @author 曹鹏飞
|
||||||
|
|
@ -14,5 +25,95 @@ import org.springframework.stereotype.Service;
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class TechnologyConfigService extends ServiceImpl<TechnologyConfigMapper, TechnologyConfigEntity> {
|
public class TechnologyConfigService extends ServiceImpl<TechnologyConfigMapper, TechnologyConfigEntity> {
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
public boolean save(Map<String, BigDecimal> configs) {
|
||||||
|
if (CollectionUtil.isEmpty(configs)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
List<TechnologyConfigEntity> datas = list();
|
||||||
|
for (Map.Entry<String, BigDecimal> entry : configs.entrySet()) {
|
||||||
|
TechnologyConfigEntity entity = datas.stream()
|
||||||
|
.filter(data -> data.getCode().equals(entry.getKey()))
|
||||||
|
.findFirst()
|
||||||
|
.orElse(null);
|
||||||
|
if (Objects.nonNull(entity)) {
|
||||||
|
entity.setUpdateBy(SessionUtil.getRealName());
|
||||||
|
entity.setUpdateTime(LocalDateTime.now());
|
||||||
|
} else {
|
||||||
|
entity = new TechnologyConfigEntity();
|
||||||
|
entity.setCode(entry.getKey());
|
||||||
|
entity.setCreateBy(SessionUtil.getRealName());
|
||||||
|
entity.setCreateTime(LocalDateTime.now());
|
||||||
|
datas.add(entity);
|
||||||
|
}
|
||||||
|
entity.setValue(entry.getValue());
|
||||||
|
}
|
||||||
|
return saveOrUpdateBatch(datas);
|
||||||
|
}
|
||||||
|
|
||||||
|
public TechnologyConfigEntity get(String code) {
|
||||||
|
return lambdaQuery().eq(TechnologyConfigEntity::getCode, code).one();
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getHourlyWages() {
|
||||||
|
TechnologyConfigEntity entity = lambdaQuery().eq(TechnologyConfigEntity::getCode, TechnologyConfigEnum.HOURLY_WAGES.getValue()).one();
|
||||||
|
if (Objects.isNull(entity)) {
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
return entity.getValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getBenefit() {
|
||||||
|
TechnologyConfigEntity entity = lambdaQuery().eq(TechnologyConfigEntity::getCode, TechnologyConfigEnum.BENEFIT.getValue()).one();
|
||||||
|
if (Objects.isNull(entity)) {
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
return entity.getValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getUserNum() {
|
||||||
|
TechnologyConfigEntity entity = lambdaQuery().eq(TechnologyConfigEntity::getCode, TechnologyConfigEnum.USER_NUM.getValue()).one();
|
||||||
|
if (Objects.isNull(entity)) {
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
return entity.getValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getTheoreticalDailyWorkingHours() {
|
||||||
|
TechnologyConfigEntity entity = lambdaQuery().eq(TechnologyConfigEntity::getCode, TechnologyConfigEnum.THEORETICAL_DAILY_WORKING_HOURS.getValue()).one();
|
||||||
|
if (Objects.isNull(entity)) {
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
return entity.getValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getTheoreticalWorkingDaysPerMonth() {
|
||||||
|
TechnologyConfigEntity entity = lambdaQuery().eq(TechnologyConfigEntity::getCode, TechnologyConfigEnum.THEORETICAL_WORKING_DAYS_PER_MONTH.getValue()).one();
|
||||||
|
if (Objects.isNull(entity)) {
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
return entity.getValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getCorrectionFactor() {
|
||||||
|
TechnologyConfigEntity entity = lambdaQuery().eq(TechnologyConfigEntity::getCode, TechnologyConfigEnum.CORRECTION_FACTOR.getValue()).one();
|
||||||
|
if (Objects.isNull(entity)) {
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
return entity.getValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public BigDecimal getMonthlyTheoreticalFullLoadWorkingHours() {
|
||||||
|
if (Objects.isNull(getUserNum()) || Objects.isNull(getTheoreticalDailyWorkingHours())
|
||||||
|
|| Objects.isNull(getTheoreticalWorkingDaysPerMonth()) || Objects.isNull(getCorrectionFactor())) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return NumberUtil.mul(getUserNum(), getTheoreticalDailyWorkingHours(), getTheoreticalWorkingDaysPerMonth(), getCorrectionFactor());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,22 @@
|
||||||
package com.nflg.product.technology.service;
|
package com.nflg.product.technology.service;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
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;
|
import com.nflg.product.technology.mapper.master.VirtualWorkingMapper;
|
||||||
import com.nflg.product.technology.pojo.entity.VirtualWorkingEntity;
|
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 lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author 曹鹏飞
|
* @author 曹鹏飞
|
||||||
|
|
@ -13,4 +25,46 @@ import org.springframework.stereotype.Service;
|
||||||
@Service
|
@Service
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class VirtualWorkingService extends ServiceImpl<VirtualWorkingMapper, VirtualWorkingEntity> {
|
public class VirtualWorkingService extends ServiceImpl<VirtualWorkingMapper, VirtualWorkingEntity> {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private WorkingTypeService workingTypeService;
|
||||||
|
|
||||||
|
@Transactional()
|
||||||
|
public void save(List<VirtualWorking> list) {
|
||||||
|
List<VirtualWorkingEntity> all = list();
|
||||||
|
remove(new QueryWrapper<>());
|
||||||
|
if (CollectionUtil.isEmpty(list)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
List<WorkingTypeEntity> types = workingTypeService.list();
|
||||||
|
List<VirtualWorkingEntity> forSave = 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)) {
|
||||||
|
entity = new VirtualWorkingEntity();
|
||||||
|
entity.setName(vw.getName());
|
||||||
|
entity.setCreateBy(SessionUtil.getRealName());
|
||||||
|
entity.setCreateTime(LocalDateTime.now());
|
||||||
|
} else {
|
||||||
|
entity.setUpdateBy(SessionUtil.getRealName());
|
||||||
|
entity.setUpdateTime(LocalDateTime.now());
|
||||||
|
}
|
||||||
|
entity.setUserNum(vw.getUserNum());
|
||||||
|
entity.setFeeTotalYear(vw.getFeeTotalYear());
|
||||||
|
entity.setFeeEquipmentDepreciation(vw.getFeeEquipmentDepreciation());
|
||||||
|
entity.setFeeWorkshopLaborCost(vw.getFeeWorkshopLaborCost());
|
||||||
|
entity.setFeeWorkshopOffice(vw.getFeeWorkshopOffice());
|
||||||
|
entity.setFeeAssistantLaborCostTotal(vw.getFeeAssistantLaborCostTotal());
|
||||||
|
entity.setFeeAssistant(vw.getFeeAssistant());
|
||||||
|
forSave.add(entity);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (CollectionUtil.isNotEmpty(forSave)) {
|
||||||
|
saveOrUpdateBatch(forSave);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,46 @@
|
||||||
|
package com.nflg.product.technology.service;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
|
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 lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
@Slf4j
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
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 -> {
|
||||||
|
WorkingTypeEntity entity = new WorkingTypeEntity();
|
||||||
|
entity.setName(d);
|
||||||
|
entity.setCreateBy(SessionUtil.getRealName());
|
||||||
|
entity.setCreateTime(LocalDateTime.now());
|
||||||
|
adds.add(entity);
|
||||||
|
});
|
||||||
|
saveBatch(adds);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,45 @@
|
||||||
|
package com.nflg.product.technology.util;
|
||||||
|
|
||||||
|
import cn.hutool.core.util.ArrayUtil;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
import java.math.RoundingMode;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
public class BigDecimalUtil {
|
||||||
|
|
||||||
|
public static BigDecimal divide(BigDecimal... values) {
|
||||||
|
if (ArrayUtil.isEmpty(values)) {
|
||||||
|
return BigDecimal.ZERO;
|
||||||
|
} else {
|
||||||
|
BigDecimal value = values[0];
|
||||||
|
BigDecimal result = null == value ? BigDecimal.ZERO : value;
|
||||||
|
for (int i = 1; i < values.length; ++i) {
|
||||||
|
value = values[i];
|
||||||
|
if (null != value) {
|
||||||
|
if (value.compareTo(BigDecimal.ZERO) == 0) {
|
||||||
|
throw new ArithmeticException("被除数不能为零");
|
||||||
|
}
|
||||||
|
result = result.divide(value, 4, RoundingMode.HALF_UP);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static BigDecimal nullToDefault(BigDecimal v1, BigDecimal def) {
|
||||||
|
if (Objects.isNull(v1) || v1.compareTo(BigDecimal.ZERO) == 0) {
|
||||||
|
return def;
|
||||||
|
} else {
|
||||||
|
return v1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Integer toInteger(BigDecimal value) {
|
||||||
|
if (Objects.isNull(value)) {
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
return value.intValue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,10 @@
|
||||||
|
package com.nflg.product.technology.util;
|
||||||
|
|
||||||
|
public class MapUtil {
|
||||||
|
|
||||||
|
public static int calculateInitialCapacity(int size) {
|
||||||
|
float loadFactor = 0.75f;
|
||||||
|
int initialCapacity = (int) Math.ceil(size / loadFactor);
|
||||||
|
return Integer.highestOneBit(initialCapacity - 1) << 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.nflg.product.technology.mapper.master.PaintCostConfigMapper">
|
||||||
|
|
||||||
|
</mapper>
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.nflg.product.technology.mapper.master.SteelsCostConfigMapper">
|
||||||
|
|
||||||
|
</mapper>
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.nflg.product.technology.mapper.master.WorkingTypeMapper">
|
||||||
|
|
||||||
|
</mapper>
|
||||||
Loading…
Reference in New Issue