代码提交
This commit is contained in:
parent
4085364894
commit
205b9b5801
|
|
@ -0,0 +1,33 @@
|
|||
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.material.equipment.domain.DeptEquipmentConfig;
|
||||
import com.bonus.material.equipment.service.IDeptEquipmentConfigService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
|
||||
@RestController
|
||||
@RequestMapping("/equipmentConfig")
|
||||
|
||||
public class DeptEquipmentConfigController extends BaseController {
|
||||
|
||||
@Autowired
|
||||
private IDeptEquipmentConfigService service;
|
||||
|
||||
@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("操作失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -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<SysUser> 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<DeptConfigRateSummary> 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<DeptConfigTypeSummary> 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<EquipmentDetail> list = service.detailsInfo(equipmentDetail);
|
||||
return getDataTable(list);
|
||||
} catch (Exception e) {
|
||||
logger.error(e.toString(), e);
|
||||
}
|
||||
return getDataTableError(new ArrayList<>());
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
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;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
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;
|
||||
}
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
@ -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<ConfigEntity> configs;
|
||||
private String configStatus;
|
||||
|
||||
@Excel(name = "配置值")
|
||||
private String configValue;
|
||||
|
||||
private String remark;
|
||||
}
|
||||
|
|
@ -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<DeptTreeSelect> 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<DeptTreeSelect> getChildren() {
|
||||
return children;
|
||||
}
|
||||
|
||||
public void setChildren(List<DeptTreeSelect> children) {
|
||||
this.children = children;
|
||||
}
|
||||
|
||||
public String getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(String status) {
|
||||
this.status = status;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,57 @@
|
|||
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;
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,23 @@
|
|||
package com.bonus.material.equipment.domain;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class NewOwnerdomin {
|
||||
private int companyId; // 公司ID
|
||||
private String maName; // 装备类型ID或名称
|
||||
private String companyName; // 公司名称
|
||||
private Integer maNum; // 数量
|
||||
|
||||
public NewOwnerdomin() {
|
||||
// 必须有无参构造函数
|
||||
}
|
||||
// 构造函数(用于复制)
|
||||
public NewOwnerdomin(NewOwnerdomin o) {
|
||||
this.companyId = o.companyId;
|
||||
this.maName = o.maName;
|
||||
this.maNum = o.maNum;
|
||||
this.companyName = o.companyName;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
|
@ -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;
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
package com.bonus.material.equipment.mapper;
|
||||
|
||||
import com.bonus.material.equipment.domain.DeptEquipmentConfig;
|
||||
import io.lettuce.core.dynamic.annotation.Param;
|
||||
import org.apache.ibatis.annotations.Delete;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface DeptEquipmentConfigMapper {
|
||||
DeptEquipmentConfig selectConfig(Long deptId, Long typeId);
|
||||
List<DeptEquipmentConfig> selectConfigByDept(Long deptId);
|
||||
int insertOrUpdateBatch( DeptEquipmentConfig deptEquipmentConfig);
|
||||
|
||||
int deleteByDeptIdAndTypeId(DeptEquipmentConfig team);
|
||||
|
||||
}
|
||||
|
|
@ -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<SysDept> selectDeptTree();
|
||||
|
||||
List<com.bonus.system.api.domain.SysDept> selectDeptList(com.bonus.system.api.domain.SysDept dept);
|
||||
|
||||
List<SysUser> selectUserList(DeptEquipmentConfig user);
|
||||
|
||||
|
||||
List<ConfigEntity> selectConfigList(DeptEquipmentConfig user);
|
||||
|
||||
List<DeptConfigRateSummary> selectDeptConfigRatePivot(DeptConfigRateSummary entity);
|
||||
|
||||
List<DeptConfigTypeSummary> selectDeptConfigTypeSummary(DeptConfigTypeSummary entity);
|
||||
|
||||
List<DeptTreeSelect> getTree();
|
||||
|
||||
List<EquipmentDetail> detailsInfo(EquipmentDetail equipmentDetail);
|
||||
|
||||
List<NewmydevInfo> listFromDevInfo(String companyId);
|
||||
}
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
package com.bonus.material.equipment.service;
|
||||
|
||||
import com.bonus.material.equipment.domain.DeptEquipmentConfig;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface IDeptEquipmentConfigService {
|
||||
List<DeptEquipmentConfig> selectByDeptId(Long deptId);
|
||||
int saveBatch( DeptEquipmentConfig configList);
|
||||
}
|
||||
|
|
@ -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<DeptTreeSelect> selectDeptTreeList(SysDept dept);
|
||||
|
||||
List<SysUser> selectUserList(DeptEquipmentConfig user);
|
||||
|
||||
|
||||
AjaxResult selectConfigList(DeptEquipmentConfig user);
|
||||
|
||||
AjaxResult getTree();
|
||||
|
||||
List<DeptConfigRateSummary> selectDeptConfigRatePivot(DeptConfigRateSummary entity);
|
||||
|
||||
List<DeptConfigTypeSummary> selectDeptConfigTypeSummary(DeptConfigTypeSummary entity);
|
||||
|
||||
List<EquipmentDetail> detailsInfo(EquipmentDetail equipmentDetail);
|
||||
}
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
package com.bonus.material.equipment.service.impl;
|
||||
|
||||
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.List;
|
||||
|
||||
@Service
|
||||
public class DeptEquipmentConfigServiceImpl implements IDeptEquipmentConfigService {
|
||||
|
||||
@Autowired
|
||||
private DeptEquipmentConfigMapper mapper;
|
||||
|
||||
@Override
|
||||
public List<DeptEquipmentConfig> selectByDeptId(Long deptId) {
|
||||
return mapper.selectConfigByDept(deptId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int saveBatch(DeptEquipmentConfig configList) {
|
||||
configList.setTypeId(configList.getEquipmentId());
|
||||
configList.setConfigValue(configList.getBasicConfig());
|
||||
//直接先删除对应的设备信息 通过公司id 和设备id进行删除
|
||||
DeptEquipmentConfig team = new DeptEquipmentConfig();
|
||||
team.setDeptId(configList.getDeptId());
|
||||
team.setTypeId(configList.getTypeId());
|
||||
mapper.deleteByDeptIdAndTypeId(team);
|
||||
|
||||
return mapper.insertOrUpdateBatch(configList);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,388 @@
|
|||
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<DeptTreeSelect> selectDeptTreeList(SysDept dept) {
|
||||
List<SysDept> depts = SpringUtils.getAopProxy(this).selectDeptList(dept);
|
||||
return buildDeptTreeSelect(depts);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SysUser> selectUserList(DeptEquipmentConfig user) {
|
||||
List<SysUser> sysUsers = mapper.selectUserList(user);
|
||||
return sysUsers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public AjaxResult selectConfigList(DeptEquipmentConfig user) {
|
||||
try {
|
||||
List<ConfigEntity> 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<DeptTreeSelect> 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<DeptConfigRateSummary> selectDeptConfigRatePivot(DeptConfigRateSummary entity) {
|
||||
// 1. 查询配置率项(每条代表一个公司+设备+评分项)
|
||||
List<DeptConfigRateSummary> configList = mapper.selectDeptConfigRatePivot(entity);
|
||||
|
||||
// 2. 查询 ma_own_manage 表中原始设备数据
|
||||
List<Ownerdomin> ownListFromManage = ownerMapper.list(null);
|
||||
|
||||
// 3. 查询 ma_dev_info 表中聚合后的设备数据(包含公司名)
|
||||
List<NewOwnerdomin> ownListFromDevInfo = ownerMapper.listGrouped();
|
||||
|
||||
// 4. 构建设备索引 Map<公司ID_设备名, List<Ownerdomin>>
|
||||
Map<String, List<Ownerdomin>> ownIndex = new HashMap<>();
|
||||
|
||||
for (Ownerdomin device : ownListFromManage) {
|
||||
String key = device.getCompanyId() + "_" + device.getMaName();
|
||||
ownIndex.computeIfAbsent(key, k -> new ArrayList<>()).add(device);
|
||||
}
|
||||
|
||||
for (NewOwnerdomin dev : ownListFromDevInfo) {
|
||||
String key = dev.getCompanyId() + "_" + dev.getMaName();
|
||||
List<Ownerdomin> existList = ownIndex.get(key);
|
||||
|
||||
if (existList != null && !existList.isEmpty()) {
|
||||
for (Ownerdomin device : existList) {
|
||||
device.setMaNum(device.getMaNum() + dev.getMaNum());
|
||||
}
|
||||
} else {
|
||||
Ownerdomin newDevice = new Ownerdomin();
|
||||
newDevice.setCompanyId((long) dev.getCompanyId());
|
||||
newDevice.setMaName(dev.getMaName());
|
||||
newDevice.setMaNum(dev.getMaNum());
|
||||
ownIndex.computeIfAbsent(key, k -> new ArrayList<>()).add(newDevice);
|
||||
}
|
||||
}
|
||||
|
||||
// 5. 构建公司 → 汇总对象 Map<String, DeptConfigRateSummary>
|
||||
Map<String, DeptConfigRateSummary> companyMap = new LinkedHashMap<>();
|
||||
|
||||
for (DeptConfigRateSummary config : configList) {
|
||||
String company = config.getCompanyName();
|
||||
String type = config.getConfigType().toPlainString(); // 0:线路 1:电缆 2:变电
|
||||
String maName = config.getDeptName();
|
||||
BigDecimal orderCount = config.getOrderCount();
|
||||
Long configCompanyId = config.getCompanyId();
|
||||
|
||||
String key = configCompanyId + "_" + maName;
|
||||
List<Ownerdomin> sameCompanyDevices = ownIndex.getOrDefault(key, Collections.emptyList());
|
||||
BigDecimal score = computeScoreByMaName(orderCount, sameCompanyDevices, config);
|
||||
|
||||
DeptConfigRateSummary dto = companyMap.computeIfAbsent(company, k -> {
|
||||
DeptConfigRateSummary d = new DeptConfigRateSummary();
|
||||
d.setDeptName(company);
|
||||
d.setCompanyId(configCompanyId);
|
||||
d.setCompanyName(company);
|
||||
d.setValueA(BigDecimal.ZERO);
|
||||
d.setValueB(BigDecimal.ZERO);
|
||||
d.setValueC(BigDecimal.ZERO);
|
||||
return d;
|
||||
});
|
||||
|
||||
switch (type) {
|
||||
case "0":
|
||||
dto.setValueA(dto.getValueA().add(score));
|
||||
break;
|
||||
case "1":
|
||||
dto.setValueB(dto.getValueB().add(score));
|
||||
break;
|
||||
case "2":
|
||||
dto.setValueC(dto.getValueC().add(score));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// 5.x:补充未出现在 configList 的公司/设备项
|
||||
Set<String> configKeys = configList.stream()
|
||||
.map(c -> c.getCompanyId() + "_" + c.getDeptName())
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
for (Map.Entry<String, List<Ownerdomin>> entry : ownIndex.entrySet()) {
|
||||
String key = entry.getKey();
|
||||
if (configKeys.contains(key)) continue;
|
||||
|
||||
List<Ownerdomin> devices = entry.getValue();
|
||||
if (devices == null || devices.isEmpty()) continue;
|
||||
|
||||
Ownerdomin first = devices.get(0);
|
||||
Long companyId = first.getCompanyId();
|
||||
String maName = first.getMaName();
|
||||
|
||||
// 从 devInfo 中找公司名称
|
||||
Optional<NewOwnerdomin> matchDev = ownListFromDevInfo.stream()
|
||||
.filter(d -> d.getCompanyId()==(new Long(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.setCompanyId(companyId);
|
||||
d.setCompanyName(companyName);
|
||||
d.setValueA(BigDecimal.ZERO);
|
||||
d.setValueB(BigDecimal.ZERO);
|
||||
d.setValueC(BigDecimal.ZERO);
|
||||
return d;
|
||||
});
|
||||
|
||||
// 默认作为线路设备记入 valueA,或根据 maName 判断类型再分类(可拓展)
|
||||
BigDecimal score = computeScoreByMaName(BigDecimal.ZERO, devices, null);
|
||||
dto.setValueA(dto.getValueA().add(score));
|
||||
}
|
||||
|
||||
// 6. 返回汇总结果
|
||||
return new ArrayList<>(companyMap.values());
|
||||
|
||||
}
|
||||
|
||||
// ✅ 可选:添加没有配置项但有设备的公司
|
||||
private void addCompaniesWithoutConfig(List<DeptConfigRateSummary> configList,
|
||||
Map<String, DeptConfigRateSummary> companyMap,
|
||||
Map<String, List<Ownerdomin>> ownIndex) {
|
||||
// 获取所有配置表中出现的公司ID
|
||||
Set<Long> configCompanyIds = configList.stream()
|
||||
.map(DeptConfigRateSummary::getCompanyId)
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
// 获取所有设备公司ID
|
||||
Set<Long> deviceCompanyIds = ownIndex.keySet().stream()
|
||||
.map(key -> Long.parseLong(key.split("_")[0]))
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
// 找出有设备但没配置的公司ID
|
||||
Set<Long> missingCompanyIds = new HashSet<>(deviceCompanyIds);
|
||||
missingCompanyIds.removeAll(configCompanyIds);
|
||||
|
||||
// 为这些公司创建空汇总对象
|
||||
for (Long companyId : missingCompanyIds) {
|
||||
// 获取公司名称(需要查询或从设备中提取)
|
||||
String companyName = "未知公司"; // 实际应从设备数据中获取
|
||||
|
||||
companyMap.computeIfAbsent(companyName, k -> {
|
||||
DeptConfigRateSummary d = new DeptConfigRateSummary();
|
||||
d.setDeptName(companyName);
|
||||
d.setCompanyId(companyId);
|
||||
d.setCompanyName(companyName);
|
||||
d.setValueA(BigDecimal.ZERO);
|
||||
d.setValueB(BigDecimal.ZERO);
|
||||
d.setValueC(BigDecimal.ZERO);
|
||||
return d;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private BigDecimal computeScoreByMaName(BigDecimal ordercount,List<Ownerdomin> owns, DeptConfigRateSummary config) {
|
||||
if (config == null || owns == null || owns.isEmpty()) return BigDecimal.ZERO;
|
||||
|
||||
BigDecimal ownedTotal = BigDecimal.ZERO;
|
||||
BigDecimal leasedTotal = BigDecimal.ZERO;
|
||||
|
||||
for (Ownerdomin own : owns) {
|
||||
BigDecimal num = new BigDecimal(own.getMaNum());
|
||||
if ("2".equals(own.getType())) {
|
||||
ownedTotal = ownedTotal.add(num); // 自有
|
||||
} else {
|
||||
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);
|
||||
|
||||
|
||||
// 判断是否超过满分
|
||||
if (rate.compareTo(BigDecimal.ONE) > 0) {
|
||||
return score.setScale(2, RoundingMode.HALF_UP);
|
||||
} else {
|
||||
return rate.multiply(score).setScale(2, RoundingMode.HALF_UP);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DeptConfigTypeSummary> selectDeptConfigTypeSummary(DeptConfigTypeSummary entity) {
|
||||
return mapper.selectDeptConfigTypeSummary(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<EquipmentDetail> detailsInfo(EquipmentDetail equipmentDetail) {
|
||||
// 1. 原查询,返回 EquipmentDetail 列表
|
||||
List<EquipmentDetail> equipmentDetails = mapper.detailsInfo(equipmentDetail);
|
||||
|
||||
// 2. 新增查询,返回 NewmydevInfo 列表(ma_dev_info 自有设备数据)
|
||||
List<NewmydevInfo> devInfoList = mapper.listFromDevInfo(equipmentDetail.getCompanyId());
|
||||
|
||||
// 3. 建立原有设备索引,key = companyId + "_" + name
|
||||
Map<String, EquipmentDetail> indexMap = new LinkedHashMap<>();
|
||||
for (EquipmentDetail item : equipmentDetails) {
|
||||
String key = item.getCompanyId() + "_" + item.getName();
|
||||
indexMap.put(key, item);
|
||||
}
|
||||
|
||||
// 4. 遍历 devInfoList,合并到 equipmentDetails
|
||||
for (NewmydevInfo devItem : devInfoList) {
|
||||
String key = devItem.getCompanyId() + "_" + devItem.getTypeName();
|
||||
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<SysDept> 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<DeptTreeSelect> buildDeptTreeSelect(List<SysDept> depts) {
|
||||
List<SysDept> deptTrees = buildDeptTree(depts);
|
||||
return deptTrees.stream().map(DeptTreeSelect::new).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public List<SysDept> buildDeptTree(List<SysDept> depts) {
|
||||
List<SysDept> returnList = new ArrayList<SysDept>();
|
||||
List<Long> 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<SysDept> list, SysDept t) {
|
||||
// 得到子节点列表
|
||||
List<SysDept> childList = getChildList(list, t);
|
||||
t.setChildren(childList);
|
||||
for (SysDept tChild : childList) {
|
||||
if (hasChild(list, tChild)) {
|
||||
recursionFn(list, tChild);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private List<SysDept> getChildList(List<SysDept> list, SysDept t) {
|
||||
List<SysDept> tlist = new ArrayList<SysDept>();
|
||||
Iterator<SysDept> 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<SysDept> list, SysDept t) {
|
||||
return getChildList(list, t).size() > 0 ? true : false;
|
||||
}
|
||||
}
|
||||
|
|
@ -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<Ownerdomin> 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<Ownerdomin> util = new ExcelUtil<>(Ownerdomin.class);
|
||||
List<Ownerdomin> 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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,56 @@
|
|||
package com.bonus.material.owner.domain;
|
||||
|
||||
import com.bonus.common.core.annotation.Excel;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @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;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
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<Ownerdomin> list(Ownerdomin ownerdomin);
|
||||
|
||||
Integer add(Ownerdomin ownerdomin);
|
||||
|
||||
Integer edit(Ownerdomin ownerdomin);
|
||||
|
||||
Integer del(Ownerdomin ownerdomin);
|
||||
|
||||
List<NewOwnerdomin> listGrouped();
|
||||
}
|
||||
|
|
@ -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<Ownerdomin> list(Ownerdomin ownerdomin);
|
||||
|
||||
Integer add(Ownerdomin ownerdomin);
|
||||
|
||||
Integer edit(Ownerdomin ownerdomin);
|
||||
|
||||
Integer del(Ownerdomin ownerdomin);
|
||||
|
||||
String importMaProp(List<Ownerdomin> maPropInfoList, String type, Long userId);
|
||||
}
|
||||
|
|
@ -0,0 +1,93 @@
|
|||
package com.bonus.material.owner.service.impl;
|
||||
|
||||
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.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
|
||||
protected Validator validator;
|
||||
|
||||
@Override
|
||||
public List<Ownerdomin> list(Ownerdomin ownerdomin) {
|
||||
ownerdomin.setCreator(SecurityUtils.getLoginUser().getSysUser().getUserId()+"");
|
||||
ownerdomin.setCompanyId(SecurityUtils.getLoginUser().getSysUser().getCompanyId());
|
||||
List<Ownerdomin> list = ownerMapper.list(ownerdomin);
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer add(Ownerdomin ownerdomin) {
|
||||
ownerdomin.setCreator(SecurityUtils.getLoginUser().getSysUser().getUserId()+"");
|
||||
ownerdomin.setCompanyId(SecurityUtils.getLoginUser().getSysUser().getCompanyId());
|
||||
return ownerMapper.add(ownerdomin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer edit(Ownerdomin ownerdomin) {
|
||||
return ownerMapper.edit(ownerdomin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer del(Ownerdomin ownerdomin) {
|
||||
return ownerMapper.del(ownerdomin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String importMaProp(List<Ownerdomin> 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();
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue