diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/domain/DevInfo.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/domain/DevInfo.java index 1cab687..f0dd929 100644 --- a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/domain/DevInfo.java +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/domain/DevInfo.java @@ -76,7 +76,7 @@ public class DevInfo extends BaseEntity { private String ratioRange; @ApiModelProperty(value = "比率,比如: 80%") - private double ratio; + private BigDecimal ratio; @ApiModelProperty(value = "单位") @NotBlank(message = "单位不能为空") diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/domain/DevInfoDt.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/domain/DevInfoDt.java new file mode 100644 index 0000000..4f26836 --- /dev/null +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/domain/DevInfoDt.java @@ -0,0 +1,81 @@ +package com.bonus.material.device.domain; + +import com.bonus.common.core.annotation.Excel; +import com.bonus.common.core.web.domain.BaseEntity; +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; +import lombok.experimental.Accessors; +import org.springframework.format.annotation.DateTimeFormat; + +import java.util.Date; + +/** + * 设备信息对象 ma_dev_info + * + * @author syruan + */ +@EqualsAndHashCode(callSuper = false) +@Data +@ToString +@Accessors(chain = true) +public class DevInfoDt { + + private static final long serialVersionUID = 429270031714225761L; + + @ApiModelProperty(value = "主键id") + private Integer id; + + @ApiModelProperty(value = "装备名称") + @Excel(name = "装备名称") + private String deviceName; + + @ApiModelProperty(value = "装备类目") + @Excel(name = "装备类目") + private String categoryName; + + @ApiModelProperty(value = "装备单位") + @Excel(name = "装备单位") + private String unitName; + + /** 设备品牌 */ + @Excel(name = "装备品牌") + @ApiModelProperty(value = "设备品牌") + private String brand; + + /** 出厂日期 */ + @Excel(name = "出厂日期", width = 30, dateFormat = "yyyy-MM-dd") + @ApiModelProperty(value = "出厂日期") + @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") + private Date productionDate; + + @ApiModelProperty(value = "联系人") + @Excel(name = "联系人") + private String person; + + @ApiModelProperty(value = "联系人电话") + @Excel(name = "联系人电话") + private String personPhone; + + @Excel(name = "上架数量") + @ApiModelProperty(value = "设备数量") + private Integer deviceCount; + + + @ApiModelProperty(value = "录入人") + @Excel(name = "录入人") + private String creatorName; + + @ApiModelProperty(value = "录入时间") + @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") + @DateTimeFormat(pattern = "yyy-MM-dd HH:mm:ss") + @Excel(name = "录入时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss") + private Date createTime; + + @Excel(name = "所属公司") + @ApiModelProperty(value = "所属公司") + private String comName; + +} diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/domain/vo/DevInfoVo.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/domain/vo/DevInfoVo.java index 96177ec..1f4fdd3 100644 --- a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/domain/vo/DevInfoVo.java +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/domain/vo/DevInfoVo.java @@ -174,4 +174,11 @@ public class DevInfoVo extends DevInfo { @ApiModelProperty(value = "订单金额") private BigDecimal cost; + private String devicenewName; + + private String deviceId; + + private String deviceTypeName; + + } diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/mapper/BmFileInfoMapper.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/mapper/BmFileInfoMapper.java index c905c02..3a7ecc7 100644 --- a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/mapper/BmFileInfoMapper.java +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/mapper/BmFileInfoMapper.java @@ -3,6 +3,7 @@ package com.bonus.material.device.mapper; import com.bonus.common.biz.domain.BmFileInfo; import com.bonus.common.biz.domain.TypeInfo; import com.bonus.material.device.domain.MaDevQc; +import com.bonus.material.owner.domain.Ownerdomin; import org.apache.ibatis.annotations.Param; import java.util.List; @@ -86,4 +87,6 @@ public interface BmFileInfoMapper { Integer deleteBmFileInfoByFileId(@Param("fileId") Integer fileId, @Param("fileType") Integer fileType); List getInfoByMaIdAndTaskId(MaDevQc qc); + + int insertRentInfo(Ownerdomin ownerdomin); } diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/mapper/DevInfoMapper.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/mapper/DevInfoMapper.java index af29a4d..75e1f97 100644 --- a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/mapper/DevInfoMapper.java +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/mapper/DevInfoMapper.java @@ -10,6 +10,8 @@ import com.bonus.material.device.domain.dto.InfoMotionDto; import com.bonus.material.device.domain.vo.DevInfoPropertyVo; import com.bonus.material.device.domain.vo.DevInfoVo; import com.bonus.material.device.domain.vo.LeaseVo; +import com.bonus.material.largeScreen.entity.LeaseInfo; +import com.bonus.material.largeScreen.entity.RentInfo; import org.apache.ibatis.annotations.Param; import java.util.Date; @@ -262,5 +264,17 @@ public interface DevInfoMapper { List getMaTypeLeasingNumList(DevInfoVo devInfoVo); List getDevLeasingNumList(DevInfoVo devInfoVo); + + Integer getRentToalNum(); + + List getDevLeaseCount(); + + List getDevRentCount(); + + List getMaTypeLeasingDetail(DevInfoVo devInfoVo); + + List getDemandUnit(DevInfoVo devInfoVo); + + int updateTypeLeasePrice(DevInfo devInfo); } diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/service/impl/DevInfoServiceImpl.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/service/impl/DevInfoServiceImpl.java index 1dbd817..e7fc21e 100644 --- a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/service/impl/DevInfoServiceImpl.java +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/device/service/impl/DevInfoServiceImpl.java @@ -424,9 +424,11 @@ public class DevInfoServiceImpl implements DevInfoService { devInfo.setCompanyId(SecurityUtils.getLoginUser().getSysUser().getCompanyId().toString()); devInfo.setDeviceCount(devInfo.getDeviceCount()); devInfo.setIdentifyCode(devInfo.getTableList().get(i).getIdentifyCode()); - if (devInfoMapper.insertDevInfo(devInfo) == 0) { + int num = devInfoMapper.insertDevInfo(devInfo); + if (num == 0) { return AjaxResult.error("设备信息SQL保存失败,请修改后重试"); } + devInfoMapper.updateTypeLeasePrice(devInfo); code = ""; //保存自定义属性值 if (!CollectionUtils.isEmpty(devInfo.getDevInfoProperties())) { @@ -608,6 +610,7 @@ public class DevInfoServiceImpl implements DevInfoService { String identifyCode = tableList.get(0).getIdentifyCode(); devInfo.setIdentifyCode(identifyCode); int i = devInfoMapper.updateDevInfo(devInfo); + devInfoMapper.updateTypeLeasePrice(devInfo); if (i > 0) { BmFileInfo bmFileInfo = new BmFileInfo() diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/equipment/controller/DeptEquipmentConfigController.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/equipment/controller/DeptEquipmentConfigController.java new file mode 100644 index 0000000..ce64eec --- /dev/null +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/equipment/controller/DeptEquipmentConfigController.java @@ -0,0 +1,80 @@ +package com.bonus.material.equipment.controller; + +import com.bonus.common.core.utils.poi.ExcelUtil; +import com.bonus.common.core.web.controller.BaseController; +import com.bonus.common.core.web.domain.AjaxResult; +import com.bonus.common.log.annotation.SysLog; +import com.bonus.common.log.enums.OperaType; +import com.bonus.material.basic.domain.BmCompanyAddress; +import com.bonus.material.common.annotation.PreventRepeatSubmit; +import com.bonus.material.device.domain.vo.DevInfoVo; +import com.bonus.material.equipment.domain.DeptConfigTypeSummary; +import com.bonus.material.equipment.domain.DeptEquipmentConfig; +import com.bonus.material.equipment.domain.EquipmentDetail; +import com.bonus.material.equipment.service.IDeptEquipmentConfigService; +import com.bonus.material.equipment.service.ISysDeptService; +import io.swagger.annotations.ApiOperation; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import javax.servlet.http.HttpServletResponse; +import java.util.List; + + +@RestController +@RequestMapping("/equipmentConfig") + +public class DeptEquipmentConfigController extends BaseController { + + @Autowired + private IDeptEquipmentConfigService service; + + @Autowired + private ISysDeptService isyservice; + @GetMapping("/{deptId}") + public AjaxResult getConfigByDept(@PathVariable Long deptId) { + return AjaxResult.success(service.selectByDeptId(deptId)); + } + + @PostMapping("/saveEquitConfig") + public AjaxResult save(@RequestBody DeptEquipmentConfig configList) { + int i = service.saveBatch(configList); + if (i > 0){ + return AjaxResult.success("操作成功"); + }else { + return AjaxResult.error("操作失败"); + } + } + /** + * 导出企业信息列表 + */ + @ApiOperation(value = "导出机械化施工装备配置率") + @PreventRepeatSubmit + @SysLog(title = "机械化施工装备配置率信息", businessType = OperaType.EXPORT, logType = 1,module = "出租方管理->机械化施工装备配置率信息") + @PostMapping("/export") + public void export(HttpServletResponse response, @RequestBody EquipmentDetail equipmentDetail) { + try { + List list = isyservice.detailsInfo(equipmentDetail); + ExcelUtil util = new ExcelUtil(EquipmentDetail.class); + util.exportExcel(response, list, "装备详情数据"); + } catch (Exception e) { + logger.error(e.toString(), e); + } + + } + + /** + * + * 查询机械化施工装备 + * + * 自有装备数据的数量 + * @param devInfoVo + * @return + */ + @PostMapping("/getdeviceInfo") + public AjaxResult getdeviceInfo( @RequestBody DevInfoVo devInfoVo) { + List list = service.selectDevInfoLists(devInfoVo); + return AjaxResult.success(list); + } + +} diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/equipment/controller/SysDeptController.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/equipment/controller/SysDeptController.java new file mode 100644 index 0000000..6582b82 --- /dev/null +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/equipment/controller/SysDeptController.java @@ -0,0 +1,104 @@ +package com.bonus.material.equipment.controller; + +import com.bonus.common.core.web.controller.BaseController; +import com.bonus.common.core.web.domain.AjaxResult; +import com.bonus.common.core.web.page.TableDataInfo; +import com.bonus.common.log.annotation.SysLog; +import com.bonus.common.log.enums.OperaType; +import com.bonus.common.security.annotation.InnerAuth; +import com.bonus.common.security.annotation.RequiresPermissions; +import com.bonus.common.security.annotation.RequiresPermissionsOrInnerAuth; +import com.bonus.material.equipment.domain.DeptConfigRateSummary; +import com.bonus.material.equipment.domain.DeptConfigTypeSummary; +import com.bonus.material.equipment.domain.DeptEquipmentConfig; +import com.bonus.material.equipment.domain.EquipmentDetail; +import com.bonus.material.equipment.service.ISysDeptService; +import com.bonus.system.api.domain.SysDept; +import com.bonus.system.api.domain.SysUser; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.web.bind.annotation.*; + +import java.util.ArrayList; +import java.util.List; + +@RestController +@RequestMapping("/dept") +public class SysDeptController extends BaseController { + + @Autowired + private ISysDeptService service; + + /** + * 获取部门树列表 + */ + @RequiresPermissionsOrInnerAuth(innerAuth = @InnerAuth, requiresPermissions = @RequiresPermissions("system:user:list")) + @GetMapping("/deptTree") + public AjaxResult deptTree(SysDept dept) { + try { + return success(service.selectDeptTreeList(dept)); + } catch (Exception e) { + logger.error(e.toString(), e); + } + return error("系统异常,请联系管理员"); + } + + @GetMapping("/list") + @SysLog(title = "装备列表", businessType = OperaType.QUERY, logType = 0, module = "系统管理->装备列表", details = "查询装备列表") + public TableDataInfo list(DeptEquipmentConfig user) { + try { + startPage(); + List list = service.selectUserList(user); + return getDataTable(list); + } catch (Exception e) { + logger.error(e.toString(), e); + } + return getDataTableError(new ArrayList<>()); + } + + @GetMapping("/listRate") + @SysLog(title = "装备列表", businessType = OperaType.QUERY, logType = 0, module = "系统管理->装备列表", details = "查询装备列表") + public TableDataInfo listRate(DeptConfigRateSummary user) { + try { + List list = service.selectDeptConfigRatePivot(user); + return getDataTable(list); + } catch (Exception e) { + logger.error(e.toString(), e); + } + return getDataTableError(new ArrayList<>()); + } + + + @PostMapping("/selectConfigList") + public AjaxResult selectConfigList(@RequestBody DeptEquipmentConfig user) { + return service.selectConfigList(user); + } + //装备名称下拉框获取 + @PostMapping("/getTree") + public AjaxResult getTree() { + return service.getTree(); + } + + @GetMapping("/listConfigType") + @SysLog(title = "装备列表", businessType = OperaType.QUERY, logType = 0, module = "系统管理->装备列表", details = "查询装备列表") + public TableDataInfo listConfigType(DeptConfigTypeSummary user) { + try { + startPage(); + List list = service.selectDeptConfigTypeSummary(user); + return getDataTable(list); + } catch (Exception e) { + logger.error(e.toString(), e); + } + return getDataTableError(new ArrayList<>()); + } + @PostMapping("/detailsInfo") + @SysLog(title = "公司装备详情页面", businessType = OperaType.QUERY, logType = 0, module = "系统管理->装备列表", details = "公司装备详情页面") + public TableDataInfo detailsInfo(@RequestBody EquipmentDetail equipmentDetail) { + try { + List list = service.detailsInfo(equipmentDetail); + return getDataTable(list); + } catch (Exception e) { + logger.error(e.toString(), e); + } + return getDataTableError(new ArrayList<>()); + } + } diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/equipment/domain/ConfigEntity.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/equipment/domain/ConfigEntity.java new file mode 100644 index 0000000..7120d94 --- /dev/null +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/equipment/domain/ConfigEntity.java @@ -0,0 +1,23 @@ +package com.bonus.material.equipment.domain; + +import lombok.Data; + +@Data +public class ConfigEntity { + + private String basicConfig; + + private String configurationType; + + private String configurationRate; + + private String configurationDescription; + + private Long deptId; + + private String remark; + + private String typeId; + + +} diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/equipment/domain/DeptConfigRateSummary.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/equipment/domain/DeptConfigRateSummary.java new file mode 100644 index 0000000..a9c27c6 --- /dev/null +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/equipment/domain/DeptConfigRateSummary.java @@ -0,0 +1,38 @@ +package com.bonus.material.equipment.domain; + +import com.bonus.common.core.web.domain.BaseEntity; +import lombok.Data; + +import java.math.BigDecimal; + +@Data +public class DeptConfigRateSummary extends BaseEntity { + + /** 部门ID */ + private Long deptId; + + private String deptName; + //公司 + private String companyName; + + /** 配置类型A的装备配置率累计值 */ + private BigDecimal valueA; + + /** 配置类型B的装备配置率累计值 */ + private BigDecimal valueB; + + /** 配置类型C的装备配置率累计值 */ + private BigDecimal valueC; + + /** 配置类型D的装备配置率累计值 新型装备 */ + private BigDecimal valueD; + private BigDecimal configType; + private Long companyId; + private BigDecimal configValue; + //装备配置率赋值 + private BigDecimal configRate; + private BigDecimal orderCount; + private BigDecimal FullScore; + + private String typeId; +} diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/equipment/domain/DeptConfigTypeSummary.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/equipment/domain/DeptConfigTypeSummary.java new file mode 100644 index 0000000..c4159a6 --- /dev/null +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/equipment/domain/DeptConfigTypeSummary.java @@ -0,0 +1,23 @@ +package com.bonus.material.equipment.domain; + +import lombok.Data; +import java.math.BigDecimal; + +@Data +public class DeptConfigTypeSummary { + /** 部门ID */ + private Long deptId; + + /** 子类型名称(mt1.type_name) */ + private String typeName; + + /** 父类型名称(mt2.type_name) */ + private String parentTypeName; + + /** 配置率(已转数值) */ + private BigDecimal configRate; + + /** 配置说明 */ + private String configDescription; +} + diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/equipment/domain/DeptEquipmentConfig.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/equipment/domain/DeptEquipmentConfig.java new file mode 100644 index 0000000..7b33211 --- /dev/null +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/equipment/domain/DeptEquipmentConfig.java @@ -0,0 +1,25 @@ +package com.bonus.material.equipment.domain; + +import com.bonus.common.core.annotation.Excel; +import com.bonus.common.core.web.domain.BaseEntity; +import lombok.Data; + +import java.util.List; + +@Data +public class DeptEquipmentConfig extends BaseEntity { + private Long id; + private Long deptId; + private String typeId; + private String equipmentName; + private String equipmenttype; + private String basicConfig; //基础配置信息 + private String equipmentId; + private List configs; + private String configStatus; + + @Excel(name = "配置值") + private String configValue; + + private String remark; +} diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/equipment/domain/DeptTreeSelect.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/equipment/domain/DeptTreeSelect.java new file mode 100644 index 0000000..5833098 --- /dev/null +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/equipment/domain/DeptTreeSelect.java @@ -0,0 +1,114 @@ +package com.bonus.material.equipment.domain; + +import com.bonus.system.api.domain.SysDept; +import com.bonus.system.api.domain.SysMenu; +import com.fasterxml.jackson.annotation.JsonInclude; +import lombok.Data; + +import java.io.Serializable; +import java.util.List; +import java.util.stream.Collectors; + +/** + * Treeselect树结构实体类 + * + * @author bonus + */ +@Data +public class DeptTreeSelect implements Serializable { + private static final long serialVersionUID = 1L; + + /** + * 节点ID + */ + private Long id; + + private String name; + + /** 父部门ID */ + private Long parentId; + + /** + * 节点名称 + */ + private String label; + + private String status; + + private Integer level; + + + /** + * 子节点 + */ + @JsonInclude(JsonInclude.Include.NON_EMPTY) + private List children; + + public DeptTreeSelect() { + + } + + public DeptTreeSelect(SysDept dept) { + this.id = dept.getDeptId(); + this.parentId = dept.getParentId(); + this.status = dept.getStatus(); + this.label = dept.getDeptName(); + this.level = dept.getLevel(); + this.children = dept.getChildren().stream().map(DeptTreeSelect::new).collect(Collectors.toList()); + } + + public DeptTreeSelect(SysMenu menu) { + this.id = menu.getMenuId(); + this.label = menu.getMenuName(); + this.status = menu.getStatus(); + this.children = menu.getChildren().stream().map(DeptTreeSelect::new).collect(Collectors.toList()); + } + + public Integer getLevel() { + return level; + } + + public void setLevel(Integer level) { + this.level = level; + } + + public Long getId() { + return id; + } + + public void setId(Long id) { + this.id = id; + } + + public Long getParentId() { + return parentId; + } + + public void setParentId(Long parentId) { + this.parentId = parentId; + } + + public String getLabel() { + return label; + } + + public void setLabel(String label) { + this.label = label; + } + + public List getChildren() { + return children; + } + + public void setChildren(List children) { + this.children = children; + } + + public String getStatus() { + return status; + } + + public void setStatus(String status) { + this.status = status; + } +} diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/equipment/domain/EquipmentDetail.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/equipment/domain/EquipmentDetail.java new file mode 100644 index 0000000..0bc0677 --- /dev/null +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/equipment/domain/EquipmentDetail.java @@ -0,0 +1,60 @@ +package com.bonus.material.equipment.domain; + +import lombok.Data; + +/** + * 装备配置详情实体类 + */ +@Data +public class EquipmentDetail { + + /** 序号 */ + private Integer index; + + /** 工序 */ + private String process; + + /** 装备名称 */ + private String name; + + /** 基本配置标准(台/套) */ + private String standard; + + /** 装备种类 */ + private String type; + + /** 配置说明 */ + private String desc; + + /** 装备配置率赋值 */ + private String value; + + /** 自有装备数量 */ + private Integer own; + + /** 租赁装备数量 */ + private Integer rent; + + /** 装备实际配置率 */ + private String actual; + + /** 特殊装备配置率 */ + private String special; + + /** 特殊装备原因 */ + private String reason; + //公司 + private String companyId; + private String configType; + /*是否存在新型装备的标识 + * 是 → status = 1,否 → status = 0 + * + * */ + private String ifExist; + private String orderCount; + private String combinedName; + private String labelVol; + private String typeId; + + +} diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/equipment/domain/NewOwnerdomin.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/equipment/domain/NewOwnerdomin.java new file mode 100644 index 0000000..b076f41 --- /dev/null +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/equipment/domain/NewOwnerdomin.java @@ -0,0 +1,32 @@ +package com.bonus.material.equipment.domain; + +import lombok.Data; + +import java.math.BigDecimal; + +@Data +public class NewOwnerdomin { + private int companyId; // 公司ID + private String maName; // 装备类型ID或名称 + private String companyName; // 公司名称 + private Integer maNum; // 数量 + private String configType; + private String typeId; + private BigDecimal fullScore; + private BigDecimal baseNum; + private BigDecimal orderCount; + + public NewOwnerdomin() { + // 必须有无参构造函数 + } + // 构造函数(用于复制) + public NewOwnerdomin(NewOwnerdomin o) { + this.companyId = o.companyId; + this.maName = o.maName; + this.maNum = o.maNum; + this.companyName = o.companyName; + } + + + +} diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/equipment/domain/NewmydevInfo.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/equipment/domain/NewmydevInfo.java new file mode 100644 index 0000000..ce0ba97 --- /dev/null +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/equipment/domain/NewmydevInfo.java @@ -0,0 +1,11 @@ +package com.bonus.material.equipment.domain; + +import lombok.Data; + +@Data +public class NewmydevInfo { + private String companyId; + private String typeId; + private String typeName; + private Integer ownCount; +} diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/equipment/domain/SysDept.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/equipment/domain/SysDept.java new file mode 100644 index 0000000..9d57bd0 --- /dev/null +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/equipment/domain/SysDept.java @@ -0,0 +1,31 @@ +package com.bonus.material.equipment.domain; + +import com.bonus.common.core.web.domain.BaseEntity; +import lombok.Data; + +@Data +public class SysDept extends BaseEntity { + private Long deptId; + private Long parentId; + private String ancestors; + private String deptName; + private Integer orderNum; + private String leader; + private String phone; + private String email; + private String status; + private Integer isShow; + private String delFlag; + private String createBy; + private String updateBy; + private Long menuTemplateId; + private Long adminUserId; + private String initPassword; + private String province; + private String city; + private String district; + private String address; + private String deptAbbreviation; + private String remark; + private String logo; +} diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/equipment/mapper/DeptEquipmentConfigMapper.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/equipment/mapper/DeptEquipmentConfigMapper.java new file mode 100644 index 0000000..cdcdfa3 --- /dev/null +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/equipment/mapper/DeptEquipmentConfigMapper.java @@ -0,0 +1,16 @@ +package com.bonus.material.equipment.mapper; + +import com.bonus.material.device.domain.vo.DevInfoVo; +import com.bonus.material.equipment.domain.DeptEquipmentConfig; + +import java.util.List; + +public interface DeptEquipmentConfigMapper { + DeptEquipmentConfig selectConfig(Long deptId, Long typeId); + List selectConfigByDept(Long deptId); + int insertOrUpdateBatch( DeptEquipmentConfig deptEquipmentConfig); + + int deleteByDeptIdAndTypeId(DeptEquipmentConfig team); + + List selectDevInfoLists(DevInfoVo devInfoVo); +} diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/equipment/mapper/SysDeptMapper.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/equipment/mapper/SysDeptMapper.java new file mode 100644 index 0000000..f5763e9 --- /dev/null +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/equipment/mapper/SysDeptMapper.java @@ -0,0 +1,31 @@ +package com.bonus.material.equipment.mapper; + +import com.bonus.material.equipment.domain.ConfigEntity; +import com.bonus.material.equipment.domain.DeptEquipmentConfig; +import com.bonus.material.equipment.domain.DeptTreeSelect; +import com.bonus.material.equipment.domain.SysDept; +import com.bonus.material.equipment.domain.*; +import com.bonus.system.api.domain.SysUser; + +import java.util.List; + +public interface SysDeptMapper { + List selectDeptTree(); + + List selectDeptList(com.bonus.system.api.domain.SysDept dept); + + List selectUserList(DeptEquipmentConfig user); + + + List selectConfigList(DeptEquipmentConfig user); + + List selectDeptConfigRatePivot(DeptConfigRateSummary entity); + + List selectDeptConfigTypeSummary(DeptConfigTypeSummary entity); + + List getTree(); + + List detailsInfo(EquipmentDetail equipmentDetail); + + List listFromDevInfo(String companyId); +} diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/equipment/service/IDeptEquipmentConfigService.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/equipment/service/IDeptEquipmentConfigService.java new file mode 100644 index 0000000..9f26ce6 --- /dev/null +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/equipment/service/IDeptEquipmentConfigService.java @@ -0,0 +1,13 @@ +package com.bonus.material.equipment.service; + +import com.bonus.material.device.domain.vo.DevInfoVo; +import com.bonus.material.equipment.domain.DeptEquipmentConfig; + +import java.util.List; + +public interface IDeptEquipmentConfigService { + List selectByDeptId(Long deptId); + int saveBatch( DeptEquipmentConfig configList); + + List selectDevInfoLists(DevInfoVo devInfoVo); +} diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/equipment/service/ISysDeptService.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/equipment/service/ISysDeptService.java new file mode 100644 index 0000000..4933bdf --- /dev/null +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/equipment/service/ISysDeptService.java @@ -0,0 +1,28 @@ +package com.bonus.material.equipment.service; + +import com.bonus.common.core.web.domain.AjaxResult; +import com.bonus.material.equipment.domain.*; +import com.bonus.material.equipment.domain.DeptEquipmentConfig; +import com.bonus.material.equipment.domain.DeptTreeSelect; +import com.bonus.system.api.domain.SysDept; +import com.bonus.system.api.domain.SysUser; + +import java.util.List; + +public interface ISysDeptService { + + public List selectDeptTreeList(SysDept dept); + + List selectUserList(DeptEquipmentConfig user); + + + AjaxResult selectConfigList(DeptEquipmentConfig user); + + AjaxResult getTree(); + + List selectDeptConfigRatePivot(DeptConfigRateSummary entity); + + List selectDeptConfigTypeSummary(DeptConfigTypeSummary entity); + + List detailsInfo(EquipmentDetail equipmentDetail); +} diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/equipment/service/impl/DeptEquipmentConfigServiceImpl.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/equipment/service/impl/DeptEquipmentConfigServiceImpl.java new file mode 100644 index 0000000..7a3c9c9 --- /dev/null +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/equipment/service/impl/DeptEquipmentConfigServiceImpl.java @@ -0,0 +1,84 @@ +package com.bonus.material.equipment.service.impl; + +import com.bonus.material.device.domain.vo.DevInfoVo; +import com.bonus.material.equipment.domain.ConfigEntity; +import com.bonus.material.equipment.domain.DeptEquipmentConfig; +import com.bonus.material.equipment.mapper.DeptEquipmentConfigMapper; +import com.bonus.material.equipment.service.IDeptEquipmentConfigService; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.*; + +@Service +public class DeptEquipmentConfigServiceImpl implements IDeptEquipmentConfigService { + + @Autowired + private DeptEquipmentConfigMapper mapper; + + @Override + public List selectByDeptId(Long deptId) { + return mapper.selectConfigByDept(deptId); + } + + @Override + public int saveBatch(DeptEquipmentConfig configList) { + configList.setTypeId(configList.getEquipmentId()); + configList.setConfigValue(configList.getBasicConfig()); + DeptEquipmentConfig team = new DeptEquipmentConfig(); + team.setDeptId(configList.getDeptId()); + team.setTypeId(configList.getTypeId()); + mapper.deleteByDeptIdAndTypeId(team); + + List originalConfigs = configList.getConfigs(); + if (originalConfigs == null || originalConfigs.isEmpty()) { + return 1; // 只删除,无新增 + } + // 合并逻辑:以 deptId + typeId + configType 为 key,configValue 累加 + Map mergedMap = new LinkedHashMap<>(); + for (ConfigEntity item : originalConfigs) { + item.setDeptId(configList.getDeptId()); + item.setTypeId(configList.getTypeId()); + item.setRemark(configList.getRemark()); + String key = item.getDeptId() + "_" + item.getTypeId() + "_" + item.getConfigurationType(); + + if (mergedMap.containsKey(key)) { + ConfigEntity existing = mergedMap.get(key); + // configValue 是 String,需转数字再相加 + try { + double newVal = parseDoubleOrZero(item.getBasicConfig()); + double oldVal = parseDoubleOrZero(existing.getBasicConfig()); + double newrateVal = parseDoubleOrZero(item.getConfigurationRate()); + double oldrateVal = parseDoubleOrZero(existing.getConfigurationRate()); + existing.setBasicConfig(String.valueOf(newVal + oldVal)); + existing.setConfigurationRate(String.valueOf(newrateVal+oldrateVal)); + } catch (NumberFormatException e) { + e.printStackTrace(); + } + } else { + mergedMap.put(key, item); + } + } + + configList.setConfigs(new ArrayList<>(mergedMap.values())); + return mapper.insertOrUpdateBatch(configList); + } + + @Override + public List selectDevInfoLists(DevInfoVo devInfoVo) { + List list = mapper.selectDevInfoLists(devInfoVo); + return list; + } + + private double parseDoubleOrZero(String value) { + if (value == null || value.trim().isEmpty()) { + return 0.0; + } + try { + return Double.parseDouble(value.trim()); + } catch (NumberFormatException e) { + return 0.0; + } + } + +} diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/equipment/service/impl/SysDeptServiceImpl.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/equipment/service/impl/SysDeptServiceImpl.java new file mode 100644 index 0000000..325ce05 --- /dev/null +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/equipment/service/impl/SysDeptServiceImpl.java @@ -0,0 +1,470 @@ +package com.bonus.material.equipment.service.impl; + + +import com.bonus.common.core.utils.SpringUtils; +import com.bonus.common.core.utils.StringUtils; +import com.bonus.common.core.web.domain.AjaxResult; +import com.bonus.common.core.web.domain.BaseEntity; +import com.bonus.common.datascope.annotation.DataScope; +import com.bonus.common.datascope.utils.CommonDataPermissionInfo; +import com.bonus.common.security.utils.SecurityUtils; +import com.bonus.material.equipment.domain.*; +import com.bonus.material.equipment.mapper.SysDeptMapper; +import com.bonus.material.equipment.service.ISysDeptService; +import com.bonus.material.owner.domain.Ownerdomin; +import com.bonus.material.owner.mapper.OwnerMapper; +import com.bonus.system.api.domain.SysDept; +import com.bonus.system.api.domain.SysUser; +import org.apache.commons.lang3.ObjectUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.BeanUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.math.BigDecimal; +import java.math.RoundingMode; +import java.util.*; +import java.util.function.Function; +import javax.annotation.Resource; +import java.util.stream.Collectors; + +@Service +public class SysDeptServiceImpl implements ISysDeptService { + + private static final Logger log = LoggerFactory.getLogger(SysDeptServiceImpl.class); + @Autowired + private SysDeptMapper mapper; + + @Resource + private OwnerMapper ownerMapper; + + @Override + public List selectDeptTreeList(SysDept dept) { + List depts = SpringUtils.getAopProxy(this).selectDeptList(dept); + return buildDeptTreeSelect(depts); + } + + @Override + public List selectUserList(DeptEquipmentConfig user) { + List sysUsers = mapper.selectUserList(user); + return sysUsers; + } + + @Override + public AjaxResult selectConfigList(DeptEquipmentConfig user) { + try { + List configEntities = mapper.selectConfigList(user); + return ObjectUtils.isNotEmpty(configEntities) ? AjaxResult.success(configEntities) : AjaxResult.success(); + } catch (Exception e) { + log.error(e.getMessage()); + return AjaxResult.success(); + } + } + + @Override + public AjaxResult getTree() { + try { + List sysDepts = mapper.getTree(); + return ObjectUtils.isNotEmpty(sysDepts) ? AjaxResult.success(sysDepts) : AjaxResult.success(); + } catch (Exception e) { + log.error(e.getMessage()); + return AjaxResult.success(); + } + } + + @Override + public List selectDeptConfigRatePivot(DeptConfigRateSummary entity) { + // 1. 查询配置率项(每条代表一个公司+设备+评分项) + List configList = mapper.selectDeptConfigRatePivot(entity); + + // 2. 查询 ma_own_manage 表中原始设备数据 + List ownListFromManage = ownerMapper.list(null); + + // 3. 查询 ma_dev_info 表中聚合后的设备数据(包含公司名) + List ownListFromDevInfo = ownerMapper.listGrouped(); + + // 4. 构建设备索引 Map<公司ID_设备名, List> + Map> ownIndex = new HashMap<>(); + + /*从自己配置的自有、外租表里面进行遍历 目的是放到对应的键里面去*/ + for (Ownerdomin device : ownListFromManage) { + String key = device.getCompanyId() + "_" + device.getMaNameId(); + ownIndex.computeIfAbsent(key, k -> new ArrayList<>()).add(device); + } + /*去ma_dev_info装置配置表里面获取可有重复装备的数据*/ + for (NewOwnerdomin dev : ownListFromDevInfo) { + String key = dev.getCompanyId() + "_" + dev.getTypeId(); + List existList = ownIndex.get(key); + if (existList != null && !existList.isEmpty()) { + for (Ownerdomin device : existList) { + // 1. 累加设备数量 + device.setMaNum(device.getMaNum()+dev.getMaNum()); + + // 2. 只有当原类型不是 "1"(即不是“租赁”)时才改成 "2"自有 + if (!"1".equals(device.getType())) { + device.setType("2"); + } + } + } else { + Ownerdomin newDevice = new Ownerdomin(); + newDevice.setCompanyId((long) dev.getCompanyId()); + newDevice.setMaName(dev.getMaName()); + newDevice.setType("2"); + newDevice.setOrderCount(dev.getOrderCount()); + newDevice.setMaNum(dev.getMaNum()); + ownIndex.computeIfAbsent(key, k -> new ArrayList<>()).add(newDevice); + } + } + + // 5. 构建公司 → 汇总对象 Map + Map companyMap = new LinkedHashMap<>(); + + for (DeptConfigRateSummary config : configList) { + String company = config.getCompanyName(); + String type = config.getConfigType().toPlainString(); // 0:线路 1:电缆 2:变电 + String maName = config.getDeptName(); + String typeId = config.getTypeId(); + BigDecimal orderCount = config.getOrderCount(); + Long configCompanyId = config.getCompanyId(); + + String key = configCompanyId + "_" + typeId; + List sameCompanyDevices = ownIndex.getOrDefault(key, Collections.emptyList()); + BigDecimal score = computeScoreByMaName(orderCount, sameCompanyDevices, config,type); + BigDecimal newscore = null; + //针对订单数量大于0的进行计算(需要给外租也就是type=1的进行赋值) + if (orderCount.compareTo(BigDecimal.ZERO) > 0 + && (sameCompanyDevices == null || sameCompanyDevices.isEmpty())) { + newscore = computeScoreByOrder(config); + } + DeptConfigRateSummary dto = companyMap.computeIfAbsent(company, k -> { + DeptConfigRateSummary d = new DeptConfigRateSummary(); + d.setDeptName(config.getDeptName()); + d.setConfigType(config.getConfigType()); + d.setCompanyId(configCompanyId); + d.setCompanyName(company); + d.setValueA(BigDecimal.ZERO); + d.setValueB(BigDecimal.ZERO); + d.setValueC(BigDecimal.ZERO); + return d; + }); + + switch (type) { + case "0": + case "3": + dto.setValueA(dto.getValueA().add(score)); + dto.setValueA( + (dto.getValueA() == null ? BigDecimal.ZERO : dto.getValueA()) + .add(newscore == null ? BigDecimal.ZERO : newscore) + ); + + break; + case "1": + case "4": + dto.setValueB(dto.getValueB().add(score)); + dto.setValueB( + (dto.getValueB() == null ? BigDecimal.ZERO : dto.getValueB()) + .add(newscore == null ? BigDecimal.ZERO : newscore) + ); + break; + case "2": + case "5": + dto.setValueC(dto.getValueC().add(score)); + dto.setValueC( + (dto.getValueC() == null ? BigDecimal.ZERO : dto.getValueC()) + .add(newscore == null ? BigDecimal.ZERO : newscore) + ); + break; + } + } + + // 5.x:补充未出现在 configList 的公司/设备项 + Set configKeys = configList.stream() + .map(c -> c.getCompanyId() + "_" + c.getTypeId()) + .collect(Collectors.toSet()); + + for (Map.Entry> entry : ownIndex.entrySet()) { + String key = entry.getKey(); + if (configKeys.contains(key)) continue; + + List devices = entry.getValue(); + if (devices == null || devices.isEmpty()) continue; + + Ownerdomin first = devices.get(0); + Long companyId = first.getCompanyId(); + String maName = first.getMaName(); + + // 从 devInfo 中找公司名称 + Optional matchDev = ownListFromDevInfo.stream() + .filter(d -> d.getCompanyId() == companyId.intValue() && d.getMaName().equals(maName)) + .findFirst(); + + String companyName = matchDev.map(NewOwnerdomin::getCompanyName).orElse("未知公司"); + + // 获取或创建公司维度的汇总对象 如果这个公司没统计对象,就创建一个 + DeptConfigRateSummary dto = companyMap.computeIfAbsent(companyName, k -> { + DeptConfigRateSummary d = new DeptConfigRateSummary(); + d.setDeptName(companyName); +// d.setConfigType(entry.getValue().get(0).getCompanyId()); + d.setCompanyId(companyId); + d.setCompanyName(companyName); + d.setValueA(BigDecimal.ZERO); + d.setValueB(BigDecimal.ZERO); + d.setValueC(BigDecimal.ZERO); + return d; + }); + + // 汇总订单数量 + BigDecimal orderCount = devices.stream() + .map(d -> Optional.ofNullable(d.getOrderCount()).orElse(BigDecimal.ZERO)) + .reduce(BigDecimal.ZERO, BigDecimal::add); + + // 构造“临时配置项”用于计算 + DeptConfigRateSummary dummyConfig = new DeptConfigRateSummary(); + // 假设你已经找到了匹配的 NewOwnerdomin 对象 matchDev + BigDecimal fullScore = matchDev.map(NewOwnerdomin::getFullScore).orElse(BigDecimal.TEN); + BigDecimal baseNum = matchDev.map(NewOwnerdomin::getBaseNum).orElse(BigDecimal.ONE); + dummyConfig.setFullScore(fullScore); + dummyConfig.setOrderCount(orderCount); + dummyConfig.setDeptName(maName); + dummyConfig.setCompanyId(companyId); + dummyConfig.setCompanyName(companyName); + + // 计算得分 + BigDecimal score = computeScoreByMaName(orderCount, devices, dummyConfig, "0"); + + // 默认计入线路类 valueA + dto.setValueA(dto.getValueA().add(score)); + } + + + // 6. 返回汇总结果 + return new ArrayList<>(companyMap.values()); + + } + + private BigDecimal computeScoreByOrder(DeptConfigRateSummary config) { + + BigDecimal leaseNum ; + BigDecimal orderCount = config.getOrderCount() != null ? config.getOrderCount() : BigDecimal.ZERO; // 订单数量 + leaseNum =orderCount; + // BigDecimal configValue = config.getConfigValue();//自有人员数量 + BigDecimal configValue = BigDecimal.valueOf(0); + BigDecimal baseNum = config.getConfigValue(); // 基本配置数量(F列) + BigDecimal configRate = config.getConfigRate(); // 满分值(K列) + + // 权重 + BigDecimal leaseWeight = new BigDecimal("0.6"); + BigDecimal orderWeight = new BigDecimal("0.9"); + + // 实际值 = 自有 + 租赁×0.6 + 订单×0.9 + BigDecimal actual = configValue + .add(leaseNum.multiply(leaseWeight)) + .add(orderCount.multiply(orderWeight)); + + if (baseNum == null || baseNum.compareTo(BigDecimal.ZERO) == 0) { + return BigDecimal.ZERO; // 避免除以 0,可按需调整为 configRate + } + + // 计算比例 + BigDecimal ratio = actual.divide(baseNum, 4, RoundingMode.HALF_UP); + + // 最终得分 + if (ratio.compareTo(BigDecimal.ONE) >= 0) { + System.err.println("比例大于1,得分为满分"+config.getDeptName()+" "+config.toString()); + return configRate; // 满分 + } else { + System.err.println("比例 × 满分"+config.getDeptName()+" "+config.toString()); + return ratio.multiply(configRate).setScale(2, RoundingMode.HALF_UP); // 比例 × 满分 + } + } + + private BigDecimal computeScoreByMaName(BigDecimal ordercount,List owns, DeptConfigRateSummary config,String type) { + if (config == null || owns == null || owns.isEmpty()) return BigDecimal.ZERO; + + BigDecimal ownedTotal = BigDecimal.ZERO; + BigDecimal leasedTotal = BigDecimal.ZERO; + boolean limitedType = false; // 是否是 3/4/5 类型 + for (Ownerdomin own : owns) { + BigDecimal num = new BigDecimal(own.getMaNum()); + + // 判断是否为限制分数的类型 + if ("3".equals(own.getType()) || "4".equals(own.getType()) || "5".equals(own.getType())) { + limitedType = true; + } + //如果ordercount大于0,则计算得分leasedTotal+ordercount + if (ordercount.compareTo(BigDecimal.ZERO) > 0) { + leasedTotal = leasedTotal.add(ordercount); + } + if ("2".equals(own.getType())) { + ownedTotal = ownedTotal.add(num); // 自有 + } else if ("1".equals(own.getType())) { + leasedTotal = leasedTotal.add(num); // 租赁 + } + } + + BigDecimal base = config.getConfigValue(); // 基本配置数量 + BigDecimal score = config.getConfigRate(); // 满分值 + + if (base == null || base.compareTo(BigDecimal.ZERO) == 0) { + return BigDecimal.ZERO; + } + + +// 计算比例 = (自有 + 租赁×0.6 + 订单×0.9) / 基本配置标准数量 + BigDecimal rate = ownedTotal + .add(leasedTotal.multiply(new BigDecimal("0.6"))) + .add(ordercount.multiply(new BigDecimal("0.9"))) + .divide(base, 4, RoundingMode.HALF_UP); + +// 计算原始得分 + BigDecimal result = rate.multiply(score).setScale(2, RoundingMode.HALF_UP); + +// 限制得分不超过满分,且如果是 3/4/5 类型,不能超过 20 + if (rate.compareTo(BigDecimal.ONE) > 0) { + result = score.setScale(2, RoundingMode.HALF_UP); + } + + if (limitedType && result.compareTo(new BigDecimal("20")) > 0) { + result = new BigDecimal("20.00"); + } + System.out.println("【配置率计算明细】"); + System.err.println("类型:" + config.getConfigType()); + System.out.println("设备名:" + config.getDeptName()); + System.out.println("配置类型:" + config.getConfigType()); + System.out.println("自有数量合计(ownedTotal):" + ownedTotal); + System.out.println("租赁数量合计(leasedTotal):" + leasedTotal); + System.out.println("订单数量(ordercount):" + ordercount); + System.out.println("基本配置数量(base):" + base); + System.out.println("满分值(score):" + score); + System.out.println("得分比例(rate):" + rate); + System.out.println("是否为限制类型(3/4/5):" + limitedType); + System.out.println("最终得分(result):" + result); + System.out.println("--------------------------------------------------"); + + return result; + + } + + @Override + public List selectDeptConfigTypeSummary(DeptConfigTypeSummary entity) { + return mapper.selectDeptConfigTypeSummary(entity); + } + + @Override + public List detailsInfo(EquipmentDetail equipmentDetail) { + // 1. 原查询,返回 EquipmentDetail 列表 + List equipmentDetails = mapper.detailsInfo(equipmentDetail); + + // 2. 新增查询,返回 NewmydevInfo 列表(ma_dev_info 自有设备数据) + List devInfoList = mapper.listFromDevInfo(equipmentDetail.getCompanyId()); + + // 3. 建立原有设备索引,key = companyId + "_" + name + Map indexMap = new LinkedHashMap<>(); + for (EquipmentDetail item : equipmentDetails) { + String key = item.getCompanyId() + "_" + item.getTypeId(); + indexMap.put(key, item); + } + + // 4. 遍历 devInfoList,合并到 equipmentDetails + for (NewmydevInfo devItem : devInfoList) { + String key = devItem.getCompanyId() + "_" + devItem.getTypeId() ; + EquipmentDetail existing = indexMap.get(key); + + if (existing != null) { + // 已存在,累加自有数量 own + if (existing.getOwn() == null) { + existing.setOwn(devItem.getOwnCount()); + } else { + existing.setOwn( + existing.getOwn() + (devItem.getOwnCount() == null ? 0 : devItem.getOwnCount()) + ); + + } + } else { + /* // 不存在,新增一条 EquipmentDetail,赋值必要字段 + EquipmentDetail newItem = new EquipmentDetail(); + newItem.setCompanyId(devItem.getCompanyId()); + newItem.setName(devItem.getTypeName()); + newItem.setOwn(devItem.getOwnCount()); + // 其他字段可根据业务决定是否赋默认值 + newItem.setDesc("来自装备配置管理"); + equipmentDetails.add(newItem); + indexMap.put(key, newItem);*/ + } + } + + return equipmentDetails; + } + + + /** + * 查询部门管理数据 + * + * @param dept 部门信息 + * @return 部门信息集合 + */ + @DataScope(deptAlias = "d") + public List selectDeptList(SysDept dept) { + try { + BaseEntity entity = CommonDataPermissionInfo.backMissionInfo(dept.getParams().get("dataScope").toString()); + BeanUtils.copyProperties(entity, dept); + } catch (Exception e) { + e.printStackTrace(); + } + if (dept.getDeptName() != null) { + String str = dept.getDeptName().replace("\\", "\\\\").replace("%", "\\%").replace("_", "\\_"); + dept.setDeptName(str); + } + dept.setCompanyId(SecurityUtils.getLoginUser().getSysUser().getCompanyId()); + return mapper.selectDeptList(dept); + } + + public List buildDeptTreeSelect(List depts) { + List deptTrees = buildDeptTree(depts); + return deptTrees.stream().map(DeptTreeSelect::new).collect(Collectors.toList()); + } + + public List buildDeptTree(List depts) { + List returnList = new ArrayList(); + List tempList = depts.stream().map(SysDept::getDeptId).collect(Collectors.toList()); + for (SysDept dept : depts) { + // 如果是顶级节点, 遍历该父节点的所有子节点 + if (!tempList.contains(dept.getParentId())) { + recursionFn(depts, dept); + returnList.add(dept); + } + } + if (returnList.isEmpty()) { + returnList = depts; + } + return returnList; + } + + private void recursionFn(List list, SysDept t) { + // 得到子节点列表 + List childList = getChildList(list, t); + t.setChildren(childList); + for (SysDept tChild : childList) { + if (hasChild(list, tChild)) { + recursionFn(list, tChild); + } + } + } + + private List getChildList(List list, SysDept t) { + List tlist = new ArrayList(); + Iterator it = list.iterator(); + while (it.hasNext()) { + SysDept n = (SysDept) it.next(); + if (StringUtils.isNotNull(n.getParentId()) && n.getParentId().longValue() == t.getDeptId().longValue()) { + tlist.add(n); + } + } + return tlist; + } + + private boolean hasChild(List list, SysDept t) { + return getChildList(list, t).size() > 0 ? true : false; + } +} diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/largeScreen/controller/LargeScreenController.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/largeScreen/controller/LargeScreenController.java index ff89bc9..27483c5 100644 --- a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/largeScreen/controller/LargeScreenController.java +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/largeScreen/controller/LargeScreenController.java @@ -1,18 +1,18 @@ package com.bonus.material.largeScreen.controller; import cn.hutool.core.collection.CollectionUtil; +import com.bonus.common.biz.domain.SysDept; import com.bonus.common.biz.utils.MathUtil; import com.bonus.common.core.utils.StringUtils; +import com.bonus.common.core.utils.poi.ExcelUtil; import com.bonus.common.core.web.controller.BaseController; import com.bonus.common.core.web.domain.AjaxResult; import com.bonus.material.device.domain.DevInfo; +import com.bonus.material.device.domain.DevInfoDt; import com.bonus.material.device.domain.vo.DevInfoVo; import com.bonus.material.device.mapper.DevInfoMapper; import com.bonus.material.device.service.DevInfoService; -import com.bonus.material.largeScreen.entity.MaDevRateInfo; -import com.bonus.material.largeScreen.entity.MaLeaseAnswerInfo; -import com.bonus.material.largeScreen.entity.MaLeaseOnlyInfo; -import com.bonus.material.largeScreen.entity.OrderData; +import com.bonus.material.largeScreen.entity.*; import com.bonus.material.largeScreen.service.LargeScreenService; import com.bonus.material.lease.domain.MaLeaseInfo; import com.bonus.material.lease.mapper.MaLeaseInfoMapper; @@ -24,11 +24,10 @@ import com.bonus.material.order.service.OrderService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import org.springframework.util.CollectionUtils; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; +import javax.servlet.http.HttpServletResponse; import java.math.BigDecimal; import java.math.RoundingMode; import java.time.Instant; @@ -76,7 +75,7 @@ public class LargeScreenController extends BaseController { try { DevInfo list = largeScreenService.getIdleDevRatio(); return AjaxResult.success(list); - }catch (Exception e){ + } catch (Exception e) { return AjaxResult.error("闲置装备分析异常"); } } @@ -89,7 +88,9 @@ public class LargeScreenController extends BaseController { list.forEach(item -> { double ratio = total == 0 ? 0 : (double) item.getDeviceCount() / total; double ratioPercent = ratio * 100; - item.setRatio(ratioPercent); + + BigDecimal bd = new BigDecimal(ratioPercent).setScale(2, RoundingMode.HALF_UP); + item.setRatio(bd); }); return AjaxResult.success(list); } @@ -139,13 +140,24 @@ public class LargeScreenController extends BaseController { orderData.setDevLeasingNum(devLeasingNum); Integer repairingDevNum = devInfoMapper.getRepairingDevNum(); orderData.setDevRepairingNum(repairingDevNum); + Integer rentToalNum = devInfoMapper.getRentToalNum(); + orderData.setRentToalNum(rentToalNum); DevInfo devInfo = devInfoMapper.getDevUsageRatio(); - if(devInfo != null){ + if (devInfo != null) { orderData.setDevUsageRatio(MathUtil.calculatePercentage(devInfo.getTotalLeaseDay(), devInfo.getTotalUpDay() + devInfo.getTotalLeaseDay())); } return AjaxResult.success(orderData); } + + @ApiOperation("公司出租/租赁数") + @GetMapping("/devLeaseAndRentCount") + public AjaxResult devLeaseAndRentCount() { + List leaseInfo = devInfoMapper.getDevLeaseCount(); + List rentInfo = devInfoMapper.getDevRentCount(); + return AjaxResult.success(new LeaseAndRentInfo(leaseInfo, rentInfo)); + } + @ApiOperation("装备需求统计") @GetMapping("/demandCount") public AjaxResult demandCount() { @@ -154,10 +166,12 @@ public class LargeScreenController extends BaseController { Integer leaseOrderNum = leaseInfoMapper.getLeaseOrderCount(); Integer maTypeCountFromLease = leaseInfoMapper.getMaTypeCountFromLease(); String topPopularTypeName = leaseInfoMapper.getTopPopularTypeName(); + Integer demandUnitNum = leaseInfoMapper.getDemandUnit(); orderData.setLeaseNum(leaseNum); orderData.setMaTypeCountFromLease(maTypeCountFromLease); orderData.setLeaseOrderRatio(MathUtil.calculatePercentage(leaseOrderNum, leaseNum)); orderData.setTopPopularTypeName(topPopularTypeName); + orderData.setDemandUnitNum(demandUnitNum); return AjaxResult.success(orderData); } @@ -266,6 +280,20 @@ public class LargeScreenController extends BaseController { List list = devInfoMapper.getMaTypeLeasingNumList(devInfoVo); return AjaxResult.success(getDataTable(list)); } + @ApiOperation("装备租赁-累计数二级页面") + @GetMapping("/getMaTypeLeasingDetail") + public AjaxResult getMaTypeLeasingDetail(DevInfoVo devInfoVo) { + startPage(); + List list = devInfoMapper.getMaTypeLeasingDetail(devInfoVo); + return AjaxResult.success(getDataTable(list)); + } + @ApiOperation("装备需求-需求单位二级页面") + @GetMapping("/getDemandUnit") + public AjaxResult getDemandUnit(DevInfoVo devInfoVo) { + startPage(); + List list = devInfoMapper.getDemandUnit(devInfoVo); + return AjaxResult.success(getDataTable(list)); + } @ApiOperation("在租赁装备数二级页面") @GetMapping("/getDevLeasingNum") @@ -309,6 +337,7 @@ public class LargeScreenController extends BaseController { /** * 应答率二级页面 + * * @param dto * @return */ @@ -339,6 +368,7 @@ public class LargeScreenController extends BaseController { /** * 总应答率二级页面 + * * @param dto * @return */ @@ -382,6 +412,7 @@ public class LargeScreenController extends BaseController { /** * 判断关键字 + * * @param item * @param keyWord * @return @@ -393,6 +424,7 @@ public class LargeScreenController extends BaseController { /** * 最需装备二级页面 + * * @param dto * @return */ @@ -411,6 +443,7 @@ public class LargeScreenController extends BaseController { /** * 需求装备种类 + * * @param dto * @return */ @@ -457,6 +490,7 @@ public class LargeScreenController extends BaseController { /** * 判断关键字 + * * @param item * @param keyWord * @return @@ -468,6 +502,7 @@ public class LargeScreenController extends BaseController { /** * 计算租赁天数差 + * * @param startTime * @param rentEndTime * @return @@ -488,6 +523,7 @@ public class LargeScreenController extends BaseController { /** * 将 java.util.Date 转换为 java.time.LocalDate + * * @param date * @return */ @@ -499,6 +535,7 @@ public class LargeScreenController extends BaseController { /** * 装备利用率 + * * @param dto * @return */ @@ -533,6 +570,7 @@ public class LargeScreenController extends BaseController { /** * 退租装备 + * * @param dto * @return */ @@ -543,4 +581,43 @@ public class LargeScreenController extends BaseController { List list = leaseInfoMapper.getReturnDev(dto); return AjaxResult.success(getDataTable(list)); } + + /** + * 按公司纬度获取设备入驻数 + * @param dto + * @return + */ + @ApiOperation("按公司纬度获取设备入驻数") + @GetMapping("/getDevNumList") + public AjaxResult getDevNumList(DevInfo dto) { + startPage(); + List list = leaseInfoMapper.getDevNumList(dto); + return AjaxResult.success(getDataTable(list)); + } + + /** + * 入驻设备明细 + * @param dto + * @return + */ + @ApiOperation("入驻设备明细") + @GetMapping("/getDevNumDetailsList") + public AjaxResult getDevNumDetailsList(DevInfo dto) { + startPage(); + List list = leaseInfoMapper.getDevNumDetailsList(dto); + return AjaxResult.success(getDataTable(list)); + } + + /** + * 导出入驻设备明细 + * @param dto + * @return + */ + @ApiOperation("导出入驻设备明细") + @PostMapping("/exportDevNumDetailsList") + public void exportDevNumDetailsList(HttpServletResponse response, @RequestBody DevInfo dto) { + List list = leaseInfoMapper.getDevNumDetailsList(dto); + ExcelUtil util = new ExcelUtil<>(DevInfoDt.class); + util.exportExcel(response, list, "入驻设备明细数据"); + } } diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/largeScreen/entity/LeaseAndRentInfo.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/largeScreen/entity/LeaseAndRentInfo.java new file mode 100644 index 0000000..d0a7b00 --- /dev/null +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/largeScreen/entity/LeaseAndRentInfo.java @@ -0,0 +1,17 @@ +package com.bonus.material.largeScreen.entity; + +import lombok.AllArgsConstructor; +import lombok.Data; + +import java.util.List; + +/** + * @Author:liang.chao + * @Date:2025/7/3 - 14:10 + */ +@Data +@AllArgsConstructor +public class LeaseAndRentInfo { + private List LeaseInfos; + private List RentInfos; +} diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/largeScreen/entity/LeaseInfo.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/largeScreen/entity/LeaseInfo.java new file mode 100644 index 0000000..baffe60 --- /dev/null +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/largeScreen/entity/LeaseInfo.java @@ -0,0 +1,14 @@ +package com.bonus.material.largeScreen.entity; + +import lombok.Data; + +/** + * @Author:liang.chao + * @Date:2025/7/3 - 14:10 + * 租赁信息 + */ +@Data +public class LeaseInfo { + private Integer leaseNum; + private String leaseCompanyName; +} diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/largeScreen/entity/OrderData.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/largeScreen/entity/OrderData.java index d2ca3da..dbd2290 100644 --- a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/largeScreen/entity/OrderData.java +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/largeScreen/entity/OrderData.java @@ -67,6 +67,12 @@ public class OrderData { @ApiModelProperty(value = "订单总数") private Integer orderNum; + @ApiModelProperty(value = "租赁总数") + private Integer rentToalNum; + + @ApiModelProperty(value = "需求单位数") + private Integer demandUnitNum; + @ApiModelProperty(value = "装备利用率") private BigDecimal devUsageRatio; diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/largeScreen/entity/RentInfo.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/largeScreen/entity/RentInfo.java new file mode 100644 index 0000000..7052431 --- /dev/null +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/largeScreen/entity/RentInfo.java @@ -0,0 +1,14 @@ +package com.bonus.material.largeScreen.entity; + +import lombok.Data; + +/** + * @Author:liang.chao + * @Date:2025/7/3 - 14:10 + * 出租信息 + */ +@Data +public class RentInfo { + private Integer rentNum; + private String rentCompanyName; +} diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/lease/mapper/MaLeaseInfoMapper.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/lease/mapper/MaLeaseInfoMapper.java index d8739f9..a00a0e6 100644 --- a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/lease/mapper/MaLeaseInfoMapper.java +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/lease/mapper/MaLeaseInfoMapper.java @@ -1,5 +1,7 @@ package com.bonus.material.lease.mapper; +import com.bonus.material.device.domain.DevInfo; +import com.bonus.material.device.domain.DevInfoDt; import com.bonus.material.largeScreen.entity.MaDevRateInfo; import com.bonus.material.largeScreen.entity.MaLeaseAnswerInfo; import com.bonus.material.largeScreen.entity.MaLeaseOnlyInfo; @@ -183,4 +185,20 @@ public interface MaLeaseInfoMapper { * @return */ List getReturnDev(MaDevRateInfo dto); + + Integer getDemandUnit(); + + /** + * 获取设备入驻数 + * @param dto + * @return + */ + List getDevNumList(DevInfo dto); + + /** + * 入驻设备明细 + * @param dto + * @return + */ + List getDevNumDetailsList( DevInfo dto); } diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/owner/controller/OwnerController.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/owner/controller/OwnerController.java new file mode 100644 index 0000000..43fa92e --- /dev/null +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/owner/controller/OwnerController.java @@ -0,0 +1,109 @@ +package com.bonus.material.owner.controller; + + +import com.bonus.common.core.utils.poi.ExcelUtil; +import com.bonus.common.core.web.controller.BaseController; +import com.bonus.common.core.web.domain.AjaxResult; +import com.bonus.common.security.utils.SecurityUtils; +import com.bonus.material.contract.domain.BmContract; +import com.bonus.material.device.domain.dto.DevInfoImpDto; +import com.bonus.material.owner.domain.Ownerdomin; +import com.bonus.material.owner.service.OwnerService; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiOperation; +import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; + +import javax.annotation.Resource; +import java.io.UnsupportedEncodingException; +import java.util.List; + +/** + * @Author:lizhenhua + * @Date:2025/6/26- 9:14 + */ +@RestController +@RequestMapping("/owner") +@Api(value = "自有装备管理", tags = "自有装备管理") +public class OwnerController extends BaseController { + @Resource + private OwnerService ownerService; + + @ApiOperation(value = "自有装备管理列表") + @GetMapping("/list") + public AjaxResult list(Ownerdomin ownerdomin) { + startPage(); + List list = ownerService.list(ownerdomin); + return AjaxResult.success(getDataTable(list)); + } + + @ApiOperation(value = "自有装备管理新增") + @PostMapping("/add") + public AjaxResult add(@RequestBody Ownerdomin ownerdomin) throws UnsupportedEncodingException { + if(ownerdomin.getMaNameId() != null){ + ownerdomin.setMaName(ownerdomin.getMaNameId()); + } + Integer i = ownerService.add(ownerdomin); + if (i > 0){ + return AjaxResult.success("新增成功"); + }else { + return AjaxResult.error("新增失败"); + } + } + + @ApiOperation(value = "自有装备管理修改") + @PostMapping("/edit") + public AjaxResult edit(@RequestBody Ownerdomin ownerdomin) throws UnsupportedEncodingException { + Integer i = ownerService.edit(ownerdomin); + if (i > 0){ + return AjaxResult.success("修改成功"); + }else { + return AjaxResult.error("修改失败"); + } + } + @ApiOperation(value = "自有装备管理删除") + @PostMapping("/del") + public AjaxResult del(@RequestBody Ownerdomin ownerdomin) { + Integer i = ownerService.del(ownerdomin); + if (i > 0){ + return AjaxResult.success("删除成功"); + }else { + return AjaxResult.error("删除失败"); + } + } + @ApiOperation(value = "装备批量录入") + @PostMapping("/importData") + public AjaxResult importData(@RequestParam("file") MultipartFile file, + String type) throws Exception { + // 1. 空文件判断 + if (file == null || file.isEmpty()) { + return AjaxResult.error("上传的文件不能为空!"); + } + + // 2. 文件名及格式校验 + String fileName = file.getOriginalFilename(); + if (fileName != null) { + String fileExtension = fileName.substring(fileName.lastIndexOf(".") + 1); + long fileSize = file.getSize(); + if (!fileExtension.equalsIgnoreCase("xls") && !fileExtension.equalsIgnoreCase("xlsx")) { + return AjaxResult.error("文件后缀名必须为 xls 或 xlsx"); + } else if (fileSize > 10 * 1024 * 1024) { + return AjaxResult.error("文件大小不能超过 10MB"); + } + } + + // 3. 读取文件内容并处理 + ExcelUtil util = new ExcelUtil<>(Ownerdomin.class); + List maPropInfoList = util.importExcel(file.getInputStream()); + + if (maPropInfoList == null || maPropInfoList.isEmpty()) { + return AjaxResult.error("导入的数据不能为空!"); + } + + Long userId = SecurityUtils.getLoginUser().getUserid(); + String message = ownerService.importMaProp(maPropInfoList, type, userId); + + return AjaxResult.success(message); + } + +} diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/owner/domain/FileInfo.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/owner/domain/FileInfo.java new file mode 100644 index 0000000..634cde5 --- /dev/null +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/owner/domain/FileInfo.java @@ -0,0 +1,13 @@ +package com.bonus.material.owner.domain; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +@Data +public class FileInfo { + @ApiModelProperty(value = "文件名称") + private String fileName; + + @ApiModelProperty(value = "文件 URL") + private String fileUrl; +} diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/owner/domain/Ownerdomin.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/owner/domain/Ownerdomin.java new file mode 100644 index 0000000..efd5f77 --- /dev/null +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/owner/domain/Ownerdomin.java @@ -0,0 +1,68 @@ +package com.bonus.material.owner.domain; + +import com.bonus.common.biz.domain.BmFileInfo; +import com.bonus.common.core.annotation.Excel; +import com.bonus.material.device.domain.vo.DevInfoPropertyVo; +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +/** + * @Author:liang.chao + * @Date:2024/12/13 - 9:17 + */ +@Data +public class Ownerdomin { + @ApiModelProperty(value = "主键ID") + private Integer id; + + @ApiModelProperty(value = "装备分类") + private String maType; + + @ApiModelProperty(value = "装备名称") + @Excel(name = "装备名称") + private String maName; + + @ApiModelProperty(value = "装备规格") + @Excel(name = "装备规格") + private String maModel; + + @ApiModelProperty(value = "规格id") + private Integer modelId; + + @ApiModelProperty(value = "类型(1租赁 2自有)") + private String type; + + @ApiModelProperty(value = "所属公司") + private Long companyId; + + @ApiModelProperty(value = "创建时间") + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + private Date createTime; + + @ApiModelProperty(value = "装备数量") + @Excel(name = "装备数量") + private Integer maNum; + + @ApiModelProperty(value = "创建人") + private String creator; + + @ApiModelProperty(value = "备注") + @Excel(name = "备注") + private String remark; + @ApiModelProperty(value = "装备名称id") + private String maNameId; + + private BigDecimal orderCount; + + @ApiModelProperty(value = "文件列表") + private List mainFileList = new ArrayList<>(); + + +} + diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/owner/mapper/OwnerMapper.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/owner/mapper/OwnerMapper.java new file mode 100644 index 0000000..2f72fd9 --- /dev/null +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/owner/mapper/OwnerMapper.java @@ -0,0 +1,23 @@ +package com.bonus.material.owner.mapper; + + +import com.bonus.material.equipment.domain.NewOwnerdomin; +import com.bonus.material.owner.domain.Ownerdomin; + +import java.util.List; + +public interface OwnerMapper { + + + List list(Ownerdomin ownerdomin); + + Integer add(Ownerdomin ownerdomin); + + Integer edit(Ownerdomin ownerdomin); + + Integer del(Ownerdomin ownerdomin); + + List listGrouped(); + + void deleteFileInfo(Integer id); +} diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/owner/service/OwnerService.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/owner/service/OwnerService.java new file mode 100644 index 0000000..841ee43 --- /dev/null +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/owner/service/OwnerService.java @@ -0,0 +1,18 @@ +package com.bonus.material.owner.service; + +import com.bonus.material.owner.domain.Ownerdomin; + +import java.util.List; + +public interface OwnerService { + + List list(Ownerdomin ownerdomin); + + Integer add(Ownerdomin ownerdomin); + + Integer edit(Ownerdomin ownerdomin); + + Integer del(Ownerdomin ownerdomin); + + String importMaProp(List maPropInfoList, String type, Long userId); +} diff --git a/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/owner/service/impl/OwnerServiceImpl.java b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/owner/service/impl/OwnerServiceImpl.java new file mode 100644 index 0000000..f87dbe7 --- /dev/null +++ b/bonus-modules/bonus-material-mall/src/main/java/com/bonus/material/owner/service/impl/OwnerServiceImpl.java @@ -0,0 +1,114 @@ +package com.bonus.material.owner.service.impl; + +import com.bonus.common.biz.domain.BmFileInfo; +import com.bonus.common.core.exception.ServiceException; +import com.bonus.common.core.utils.StringUtils; +import com.bonus.common.core.utils.bean.BeanUtils; +import com.bonus.common.core.utils.bean.BeanValidators; +import com.bonus.common.security.utils.SecurityUtils; +import com.bonus.material.device.domain.DevInfo; +import com.bonus.material.device.domain.dto.DevInfoImpDto; +import com.bonus.material.device.mapper.BmFileInfoMapper; +import com.bonus.material.owner.domain.FileInfo; +import com.bonus.material.owner.domain.Ownerdomin; +import com.bonus.material.owner.mapper.OwnerMapper; +import com.bonus.material.owner.service.OwnerService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import javax.validation.Validator; +import java.util.List; +import java.util.Objects; +import java.util.stream.Collectors; + +@Service +@Slf4j +public class OwnerServiceImpl implements OwnerService { + + @Resource + private OwnerMapper ownerMapper; + + @Resource + private BmFileInfoMapper bmFileInfoMapper; + + @Resource + protected Validator validator; + + @Override + public List list(Ownerdomin ownerdomin) { + ownerdomin.setCreator(SecurityUtils.getLoginUser().getSysUser().getUserId()+""); + ownerdomin.setCompanyId(SecurityUtils.getLoginUser().getSysUser().getCompanyId()); + List list = ownerMapper.list(ownerdomin); + return list; + } + + @Override + public Integer add(Ownerdomin ownerdomin) { + ownerdomin.setCreator(SecurityUtils.getLoginUser().getSysUser().getUserId()+""); + ownerdomin.setCompanyId(SecurityUtils.getLoginUser().getSysUser().getCompanyId()); + Integer add = ownerMapper.add(ownerdomin); + //判断是否存在图片等 + if (ownerdomin.getMainFileList() != null && ownerdomin.getMainFileList().size() > 0) { + bmFileInfoMapper.insertRentInfo(ownerdomin); + } + return add; + } + + @Override + public Integer edit(Ownerdomin ownerdomin) { + Integer edit = ownerMapper.edit(ownerdomin); + //删除对应保存到表里面的信息 + ownerMapper.deleteFileInfo(ownerdomin.getId()); + if (ownerdomin.getMainFileList() != null && ownerdomin.getMainFileList().size() > 0) { + BmFileInfo bmFileInfo = new BmFileInfo(); + bmFileInfo.setTaskId(Long.valueOf(ownerdomin.getId())); + bmFileInfo.setFileName(bmFileInfo.getFileName()); + bmFileInfo.setFileUrl(bmFileInfo.getFileUrl()); + bmFileInfoMapper.insertRentInfo(ownerdomin); + } + return edit; + } + + @Override + public Integer del(Ownerdomin ownerdomin) { + return ownerMapper.del(ownerdomin); + } + + @Override + public String importMaProp(List maPropInfoList, String type, Long userId) { + if (StringUtils.isNull(maPropInfoList) || maPropInfoList.isEmpty()) { + throw new ServiceException("导入的数据不能为空!"); + } + +// 过滤掉空对象或空行 + maPropInfoList = maPropInfoList.stream() + .filter(Objects::nonNull) + .filter(item -> StringUtils.isNotEmpty(item.getMaName())) // 替换为你必须字段 + .collect(Collectors.toList()); + + int failureNum = 0; + StringBuilder failureMsg = new StringBuilder(); + StringBuilder successMsg = new StringBuilder(); + + for (Ownerdomin devInfo : maPropInfoList) { + try { + BeanValidators.validateWithException(validator, devInfo); + devInfo.setCreator(userId + ""); + Ownerdomin ownerdomin = new Ownerdomin(); + BeanUtils.copyProperties(devInfo, ownerdomin); + ownerdomin.setType(type); + ownerdomin.setCompanyId(SecurityUtils.getLoginUser().getSysUser().getCompanyId()); + ownerMapper.add(ownerdomin); + successMsg.append(" 导入成功"); + } catch (Exception e) { + failureNum++; + String msg = " 导入失败:"; + failureMsg.append(msg).append(e.getMessage()); + log.error(msg, e); + } + } + + return successMsg.toString(); + } +} diff --git a/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/device/BmFileInfoMapper.xml b/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/device/BmFileInfoMapper.xml index ab466c5..20d12b5 100644 --- a/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/device/BmFileInfoMapper.xml +++ b/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/device/BmFileInfoMapper.xml @@ -1,7 +1,7 @@ + PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> @@ -32,7 +32,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and file_type = #{fileType} - + @@ -67,11 +67,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" select id, task_type, task_id, model_id, name fileName, url fileUrl, file_type, create_by, create_time from bm_file_info - WHERE + WHERE model_id = #{maId} - and task_id = #{id} - and task_type = 17 - and file_type = 4 + and task_id = #{id} + and task_type = 17 + and file_type = 4 @@ -85,7 +85,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" file_type, create_by, create_time - + #{taskType}, #{taskId}, @@ -95,7 +95,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{fileType}, #{createBy}, now() - + @@ -114,6 +114,18 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ) + + INSERT INTO bm_rent_info(task_id,name,url,create_time) + VALUES + + ( + #{id}, + #{item.fileName}, + #{item.fileUrl}, + now() + ) + + update bm_file_info @@ -135,7 +147,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - delete from bm_file_info where id in + delete from bm_file_info where id in #{id} @@ -165,4 +177,4 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" delete from bm_file_info where id = #{fileId} and task_type = 17 and file_type = #{fileType} - \ No newline at end of file + diff --git a/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/device/DevInfoMapper.xml b/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/device/DevInfoMapper.xml index b78e4e1..31c4b2f 100644 --- a/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/device/DevInfoMapper.xml +++ b/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/device/DevInfoMapper.xml @@ -1008,6 +1008,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" update ma_dev_info set total_lease_day = IFNULL(total_lease_day, 0) + 1 where is_active = '1' and ma_status = '3' + + update ma_type set lease_price = #{dayLeasePrice} + where type_id = #{typeId} + + + + + + diff --git a/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/equipment/DeptEquipmentConfigMapper.xml b/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/equipment/DeptEquipmentConfigMapper.xml new file mode 100644 index 0000000..8f1776f --- /dev/null +++ b/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/equipment/DeptEquipmentConfigMapper.xml @@ -0,0 +1,93 @@ + + + + + DELETE FROM ma_dept_config WHERE dept_id = #{deptId} AND type_id = #{typeId} + + + + + + + + INSERT INTO ma_dept_config ( + dept_id, + type_id, + config_type, + config_value, + config_rate, + config_description, + remark + ) + VALUES + + ( + #{deptId}, + #{typeId}, + #{item.configurationType}, + #{item.basicConfig}, + #{item.configurationRate}, + #{item.configurationDescription}, + #{remark} + ) + + ON DUPLICATE KEY UPDATE + config_value = VALUES(config_value), + config_rate = VALUES(config_rate), + config_description = VALUES(config_description), + remark = VALUES(remark), + update_time = CURRENT_TIMESTAMP + + + diff --git a/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/equipment/SysDeptMapper.xml b/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/equipment/SysDeptMapper.xml new file mode 100644 index 0000000..afed426 --- /dev/null +++ b/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/equipment/SysDeptMapper.xml @@ -0,0 +1,241 @@ + + + + + select d.dept_id, + d.parent_id, + d.ancestors, + d.dept_name, + d.order_num, + d.leader, + d.phone, + d.email, + d.status, + d.del_flag, + d.create_by, + d.create_time + from sys_dept d + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/lease/MaLeaseInfoMapper.xml b/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/lease/MaLeaseInfoMapper.xml index 6a49ff5..87b445a 100644 --- a/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/lease/MaLeaseInfoMapper.xml +++ b/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/lease/MaLeaseInfoMapper.xml @@ -683,4 +683,55 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" ORDER BY md.rent_over_time DESC + + + + + diff --git a/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/owner/OwnerMapper.xml b/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/owner/OwnerMapper.xml new file mode 100644 index 0000000..68f5bcb --- /dev/null +++ b/bonus-modules/bonus-material-mall/src/main/resources/mapper/material/owner/OwnerMapper.xml @@ -0,0 +1,110 @@ + + + + + + + + + + + + + + + + + + + + insert into ma_own_manage( + ma_type, ma_name, model_id, ma_model, ma_num, + creator, remark,company_id,type) + values(#{maType}, #{maName}, #{modelId}, #{maModel}, #{maNum}, #{creator}, #{remark}, #{companyId},#{type}) + + + update ma_own_manage set + ma_type = #{maType}, + ma_name = #{maNameId}, + model_id = #{modelId}, + ma_model = #{maModel}, + ma_num = #{maNum}, + creator = #{creator}, + remark = #{remark} + where id = #{id} + + + update ma_own_manage set + is_active =1 + where id = #{id} + + + delete FROM + bm_rent_info + WHERE + task_id = #{id} + + + + +