diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/common/DictBaseConstants.java b/dl-module-base/src/main/java/cn/iocoder/yudao/common/DictBaseConstants.java index 11da91c6..10a20281 100644 --- a/dl-module-base/src/main/java/cn/iocoder/yudao/common/DictBaseConstants.java +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/common/DictBaseConstants.java @@ -21,4 +21,11 @@ public class DictBaseConstants { public static final String COMPANY_STAFF_EDU = "company_staff_edu"; /**企业资质临期判定时间*/ public static final String COMPANY_QUALS_EXPIRED = "company_quals_expired"; + /** 价值类型 */ + public static final String COMPANY_COST_TYPE = "company_cost_type"; + /** 资产状态 */ + public static final String COMPANY_PROP_STATUS = "company_prop_status"; + /** 时间周期字典 */ + public static final String CYCLE_DICT = "cycle_dict"; + } diff --git a/dl-module-company/src/main/java/cn/iocoder/yudao/module/property/controller/admin/PropertyController.java b/dl-module-company/src/main/java/cn/iocoder/yudao/module/property/controller/admin/PropertyController.java index 0d44356d..3c472057 100644 --- a/dl-module-company/src/main/java/cn/iocoder/yudao/module/property/controller/admin/PropertyController.java +++ b/dl-module-company/src/main/java/cn/iocoder/yudao/module/property/controller/admin/PropertyController.java @@ -1,15 +1,17 @@ package cn.iocoder.yudao.module.property.controller.admin; +import cn.hutool.core.util.ObjectUtil; import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; import cn.iocoder.yudao.framework.common.util.object.BeanUtils; import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; import cn.iocoder.yudao.module.property.entity.Property; import cn.iocoder.yudao.module.property.service.PropertyService; import cn.iocoder.yudao.module.property.vo.PropertyReqVO; import cn.iocoder.yudao.module.property.vo.PropertyRespVO; +import cn.iocoder.yudao.module.staff.entity.CompanyStaff; import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; @@ -19,14 +21,24 @@ import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; + import java.io.IOException; +import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; -@Tag(name = "管理后台 - 企业管理-资产") +/** + * 企业管理-资产管理 控制层 + * + * @author 小李 + * @date 16:41 2024/8/15 + **/ @RestController +@Tag(name = "企业管理 - 资产管理") @RequestMapping("/company/property") @Validated public class PropertyController { @@ -34,30 +46,49 @@ public class PropertyController { @Resource private PropertyService propertyService; + /** + * 企业管理-资产分页 + * + * @param pageReqVO 查询对象 + * @param pageNo 页码 + * @param pageSize 条数 + * @author 小李 + * @date 16:15 2024/8/15 + **/ + @GetMapping("/page") + @Operation(summary = "获得企业管理-资产分页") + @PreAuthorize("@ss.hasPermission('company:property:query')") + public CommonResult> getPropertyPage(PropertyReqVO pageReqVO, + @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, + @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) { + Page page = new Page<>(pageNo, pageSize); + IPage pageResult = propertyService.getPropertyPage(pageReqVO, page); + return success(pageResult); + } + + + /** + * 创建资产 + * + * @param createReqVO + * @author 小李 + * @date 18:26 2024/8/15 + **/ @PostMapping("/create") @Operation(summary = "创建企业管理-资产") @PreAuthorize("@ss.hasPermission('company:property:create')") - public CommonResult createProperty(@RequestBody PropertyReqVO createReqVO) { - return success(propertyService.createProperty(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新企业管理-资产") - @PreAuthorize("@ss.hasPermission('company:property:update')") - public CommonResult updateProperty(@RequestBody PropertyReqVO updateReqVO) { - propertyService.updateProperty(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除企业管理-资产") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('company:property:delete')") - public CommonResult deleteProperty(@RequestParam("id") String id) { - propertyService.deleteProperty(id); - return success(true); + public CommonResult createProperty(@RequestBody PropertyReqVO createReqVO) { + propertyService.createProperty(createReqVO); + return CommonResult.ok(); } + /** + * 获得资产记录 + * + * @param id 资产ID + * @author 小李 + * @date 18:45 2024/8/15 + **/ @GetMapping("/get") @Operation(summary = "获得企业管理-资产") @Parameter(name = "id", description = "编号", required = true, example = "1024") @@ -67,24 +98,66 @@ public class PropertyController { return success(BeanUtils.toBean(property, PropertyRespVO.class)); } - @GetMapping("/page") - @Operation(summary = "获得企业管理-资产分页") - @PreAuthorize("@ss.hasPermission('company:property:query')") - public CommonResult> getPropertyPage(PropertyReqVO pageReqVO) { - IPage pageResult = propertyService.getPropertyPage(pageReqVO); - return success(pageResult); + /** + * 更新资产 + * @author 小李 + * @date 18:57 2024/8/15 + * @param updateReqVO 资产对象 + **/ + @PutMapping("/update") + @Operation(summary = "更新企业管理-资产") + @PreAuthorize("@ss.hasPermission('company:property:update')") + public CommonResult updateProperty(@RequestBody PropertyReqVO updateReqVO) { + propertyService.updateProperty(updateReqVO); + return success(true); } + /** + * 删除资产 + * @author 小李 + * @date 19:20 2024/8/15 + * @param id 资产ID + **/ + @DeleteMapping("/delete") + @Operation(summary = "删除企业管理-资产") + @Parameter(name = "id", description = "编号", required = true) + @PreAuthorize("@ss.hasPermission('company:property:delete')") + public CommonResult deleteProperty(@RequestParam("id") String id) { + propertyService.deleteProperty(id); + return success(true); + } + + /** + * 导出资产数据 + * @author 小李 + * @date 20:02 2024/8/15 + * @param pageReqVO + * @param response + **/ @GetMapping("/export-excel") @Operation(summary = "导出企业管理-资产 Excel") @PreAuthorize("@ss.hasPermission('company:property:export')") @ApiAccessLog(operateType = EXPORT) public void exportPropertyExcel(PropertyReqVO pageReqVO, HttpServletResponse response) throws IOException { - pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); - List list = propertyService.getPropertyPage(pageReqVO).getRecords(); + int pageNo = 1, pageSize = 100; + List list = new ArrayList<>(); + while (true){ + Page page = new Page<>(pageNo, pageSize); + IPage propertyPage = propertyService.getPropertyPage(pageReqVO, page); + if (ObjectUtil.isNotEmpty(propertyPage) && !propertyPage.getRecords().isEmpty()){ + list.addAll(propertyPage.getRecords()); + pageNo++; + }else { + break; + } + } // 导出 Excel - ExcelUtils.write(response, "企业管理-资产.xls", "数据", PropertyRespVO.class, list); + Map columnWidthMap = new HashMap<>(); + // 第一列的索引是0,宽度设置为20个字符宽 + columnWidthMap.put(9, 20); + columnWidthMap.put(10, 20); + ExcelUtils.write(response, "企业管理-资产.xls", "数据", Property.class, list, columnWidthMap); } } \ No newline at end of file diff --git a/dl-module-company/src/main/java/cn/iocoder/yudao/module/property/controller/admin/PropertyPosController.java b/dl-module-company/src/main/java/cn/iocoder/yudao/module/property/controller/admin/PropertyPosController.java index 9e2c77b2..ca600ab0 100644 --- a/dl-module-company/src/main/java/cn/iocoder/yudao/module/property/controller/admin/PropertyPosController.java +++ b/dl-module-company/src/main/java/cn/iocoder/yudao/module/property/controller/admin/PropertyPosController.java @@ -1,16 +1,11 @@ package cn.iocoder.yudao.module.property.controller.admin; -import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; import cn.iocoder.yudao.framework.common.pojo.CommonResult; -import cn.iocoder.yudao.framework.common.pojo.PageParam; import cn.iocoder.yudao.framework.common.util.object.BeanUtils; -import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; import cn.iocoder.yudao.module.property.entity.PropertyPos; import cn.iocoder.yudao.module.property.service.PropertyPosService; import cn.iocoder.yudao.module.property.vo.PropertyPosReqVO; import cn.iocoder.yudao.module.property.vo.PropertyPosRespVO; -import cn.iocoder.yudao.module.staff.entity.CompanyStaff; -import cn.iocoder.yudao.module.staff.vo.CompanyStaffReqVO; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import io.swagger.v3.oas.annotations.Operation; @@ -21,11 +16,8 @@ import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; import java.util.List; -import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; @Tag(name = "管理后台 - 企业管理-资产存放位置") diff --git a/dl-module-company/src/main/java/cn/iocoder/yudao/module/property/entity/Property.java b/dl-module-company/src/main/java/cn/iocoder/yudao/module/property/entity/Property.java index 915e3b64..f4b0b9d0 100644 --- a/dl-module-company/src/main/java/cn/iocoder/yudao/module/property/entity/Property.java +++ b/dl-module-company/src/main/java/cn/iocoder/yudao/module/property/entity/Property.java @@ -1,151 +1,165 @@ package cn.iocoder.yudao.module.property.entity; +import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; +import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO; +import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; +import com.alibaba.excel.annotation.ExcelProperty; import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.KeySequence; +import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; -import lombok.*; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; +import lombok.EqualsAndHashCode; +import org.springframework.format.annotation.DateTimeFormat; import java.math.BigDecimal; -import java.time.LocalDate; -import java.time.LocalDateTime; +import java.util.Date; + +import static cn.iocoder.yudao.common.DictBaseConstants.*; /** - * 企业管理-资产 DO - * - * @author 后台管理员 - */ + * 企业管理-资产管理 + * @author 小李 + * @date 16:37 2024/8/15 +**/ @TableName("company_property") -@KeySequence("company_property_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 @Data @EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor +@ExcelIgnoreUnannotated public class Property extends TenantBaseDO { - /** - * 主键标识 - */ - @TableId(type = IdType.ASSIGN_UUID) + /** 主键标识 */ + @TableId(type = IdType.ASSIGN_ID) private String id; - /** - * 企业id - */ + + /** 企业id(base_company表中的id) */ private String corpId; - /** - * 部门id - */ + + /** 部门id(system_dept表中的id,用来做数据权限控制) */ private Long deptId; - /** - * 存放位置 - */ + + /** 存放位置id(company_property_pos) */ private String posId; - /** - * 使用人id - */ + + /** 使用人id(sys_users) */ private String userId; - /** - * 资产编号 - */ + + /** 资产编号 */ + @ExcelProperty("资产编号") private String propNo; - /** - * 资产名称 - */ + + /** 资产名称 */ + @ExcelProperty("资产名称") private String propName; - /** - * 资产分类 - */ + + /** 资产分类(分类字典) */ + @ExcelProperty("资产分类") private String propCatg; - /** - * 预计使用年限 - */ + + /** 预计使用年限 */ + @ExcelProperty("预计使用年限") private Integer useYear; - /** - * 价值类型 - * - * 枚举 {@link TODO company_cost_type 对应的类} - */ + + /** 价值类型 */ + @ExcelProperty(value = "价值类型", converter = DictConvert.class) + @DictFormat(COMPANY_COST_TYPE) private String costType; - /** - * 资产数量 - */ + + /** 资产数量 */ + @ExcelProperty("资产数量") private Integer propNum; - /** - * 资产原值(元) - */ + + /** 资产原值(元) */ + @ExcelProperty("资产原值") private BigDecimal costTotal; - /** - * 资产状态 - * - * 枚举 {@link TODO company_prop_status 对应的类} - */ + + /** 资产状态 */ + @ExcelProperty(value = "资产状态", converter = DictConvert.class) + @DictFormat(COMPANY_PROP_STATUS) private String propStatus; - /** - * 品牌 - */ + + /** 品牌 */ + @ExcelProperty("品牌") private String brand; - /** - * 规格型号 - */ + + /** 规格型号 */ + @ExcelProperty("规格型号") private String spec; - /** - * 生产厂家 - */ + + /** 生产厂家 */ + @ExcelProperty("生产厂家") private String factory; - /** - * 出场序列号/编号 - */ + + /** 出场序列号/编号 */ + @ExcelProperty("出场序列号/编号") private String serialNo; - /** - * 数量计量单位 - */ + + /** 数量计量单位 */ + @ExcelProperty("数量计量单位") private String unit; - /** - * 取得日期 - */ - private LocalDateTime getDate; - /** - * 出厂日期 - */ - private LocalDate prodDate; - /** - * 供应商 - */ + + /** 取得日期 */ + @JsonFormat(pattern="yyyy-MM-dd",timezone="GMT+8") + @DateTimeFormat(pattern="yyyy-MM-dd") + @ExcelProperty("取得日期") + private Date getDate; + + /** 出厂日期 */ + @JsonFormat(pattern="yyyy-MM-dd",timezone="GMT+8") + @DateTimeFormat(pattern="yyyy-MM-dd") + @ExcelProperty("出厂日期") + private Date prodDate; + + /** 供应商 */ + @ExcelProperty("供应商") private String supplier; - /** - * 启用日期 - */ - private LocalDate openDate; - /** - * 净值(元) - */ + + /** 启用日期 */ + @JsonFormat(pattern="yyyy-MM-dd",timezone="GMT+8") + @DateTimeFormat(pattern="yyyy-MM-dd") + @ExcelProperty("启用日期") + private Date openDate; + + /** 净值(元) */ + @ExcelProperty("净值") private BigDecimal netValue; - /** - * 凭证号 - */ + + /** 凭证号 */ + @ExcelProperty("凭证号") private String voucherNo; - /** - * 维修/保养周期单位 - */ + + /** 维修/保养周期单位(年/月/天) */ + @ExcelProperty(value = "维修/保养周期单位", converter = DictConvert.class) + @DictFormat(CYCLE_DICT) private String keepCycleType; - /** - * 维修/保养周期 - */ + + /** 维修/保养周期(具体数字) */ + @ExcelProperty("维修/保养周期") private Integer keepCycle; - /** - * 上次维修/保养日期 - */ - private LocalDate lastKeepDate; - /** - * 下次维修/保养日期 - */ - private LocalDate nextKeepDate; - /** - * 附件urls - */ + + /** 上次维修/保养日期 */ + @JsonFormat(pattern="yyyy-MM-dd",timezone="GMT+8") + @DateTimeFormat(pattern="yyyy-MM-dd") + @ExcelProperty("上次维修/保养日期") + private Date lastKeepDate; + + /** 下次维修/保养日期 */ + @JsonFormat(pattern="yyyy-MM-dd",timezone="GMT+8") + @DateTimeFormat(pattern="yyyy-MM-dd") + @ExcelProperty("下次维修/保养日期") + private Date nextKeepDate; + + /** 附件urls(infra_file表中的url,多个英文逗号拼接) */ + @ExcelProperty("附件") private String fileUrls; + @TableField(exist = false) + @ExcelProperty("使用人") + private String staffName; + + @TableField(exist = false) + @ExcelProperty("存放位置") + private String posName; } \ No newline at end of file diff --git a/dl-module-company/src/main/java/cn/iocoder/yudao/module/property/mapper/PropertyMapper.java b/dl-module-company/src/main/java/cn/iocoder/yudao/module/property/mapper/PropertyMapper.java index 67dbc93a..2c2d14dc 100644 --- a/dl-module-company/src/main/java/cn/iocoder/yudao/module/property/mapper/PropertyMapper.java +++ b/dl-module-company/src/main/java/cn/iocoder/yudao/module/property/mapper/PropertyMapper.java @@ -5,18 +5,23 @@ import cn.iocoder.yudao.module.property.vo.PropertyReqVO; import cn.iocoder.yudao.module.property.vo.PropertyRespVO; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import org.apache.ibatis.annotations.Mapper; +import org.apache.ibatis.annotations.Param; /** - * 企业管理-资产 Mapper - * - * @author 后台管理员 - */ + * 企业管理-资产管理 mapper + * @author 小李 + * @date 16:40 2024/8/15 +**/ @Mapper public interface PropertyMapper extends BaseMapper { - default IPage selectPage(PropertyReqVO reqVO) { - return null; - } - + /** + * 企业管理-资产分页 + * @author 小李 + * @date 16:15 2024/8/15 + * @param pageReqVO 查询对象 + **/ + IPage getPropertyPage(@Param("map") PropertyReqVO pageReqVO, Page page); } \ No newline at end of file diff --git a/dl-module-company/src/main/java/cn/iocoder/yudao/module/property/service/PropertyService.java b/dl-module-company/src/main/java/cn/iocoder/yudao/module/property/service/PropertyService.java index 7475e086..ab19b581 100644 --- a/dl-module-company/src/main/java/cn/iocoder/yudao/module/property/service/PropertyService.java +++ b/dl-module-company/src/main/java/cn/iocoder/yudao/module/property/service/PropertyService.java @@ -2,53 +2,55 @@ package cn.iocoder.yudao.module.property.service; import cn.iocoder.yudao.module.property.entity.Property; import cn.iocoder.yudao.module.property.vo.PropertyReqVO; -import cn.iocoder.yudao.module.property.vo.PropertyRespVO; import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.IService; /** - * 企业管理-资产 Service 接口 - * - * @author 后台管理员 - */ + * 企业管理-资产管理 接口 + * @author 小李 + * @date 16:40 2024/8/15 +**/ public interface PropertyService extends IService { /** - * 创建企业管理-资产 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - String createProperty(PropertyReqVO createReqVO); + * 企业管理-资产分页 + * @author 小李 + * @date 16:15 2024/8/15 + * @param pageReqVO 查询对象 + **/ + IPage getPropertyPage(PropertyReqVO pageReqVO, Page page); /** - * 更新企业管理-资产 - * - * @param updateReqVO 更新信息 - */ - void updateProperty(PropertyReqVO updateReqVO); + * 创建资产 + * @author 小李 + * @date 18:26 2024/8/15 + * @param createReqVO + **/ + void createProperty(PropertyReqVO createReqVO); /** - * 删除企业管理-资产 - * - * @param id 编号 - */ - void deleteProperty(String id); - - /** - * 获得企业管理-资产 - * - * @param id 编号 - * @return 企业管理-资产 - */ + * 获得资产记录 + * @author 小李 + * @date 18:45 2024/8/15 + * @param id 资产ID + **/ Property getProperty(String id); /** - * 获得企业管理-资产分页 - * - * @param pageReqVO 分页查询 - * @return 企业管理-资产分页 - */ - IPage getPropertyPage(PropertyReqVO pageReqVO); + * 更新资产 + * @author 小李 + * @date 18:57 2024/8/15 + * @param updateReqVO 资产对象 + **/ + void updateProperty(PropertyReqVO updateReqVO); + + /** + * 删除资产 + * @author 小李 + * @date 19:20 2024/8/15 + * @param id 资产ID + **/ + void deleteProperty(String id); } \ No newline at end of file diff --git a/dl-module-company/src/main/java/cn/iocoder/yudao/module/property/service/impl/PropertyServiceImpl.java b/dl-module-company/src/main/java/cn/iocoder/yudao/module/property/service/impl/PropertyServiceImpl.java index bbe0b702..79a7d407 100644 --- a/dl-module-company/src/main/java/cn/iocoder/yudao/module/property/service/impl/PropertyServiceImpl.java +++ b/dl-module-company/src/main/java/cn/iocoder/yudao/module/property/service/impl/PropertyServiceImpl.java @@ -1,58 +1,98 @@ package cn.iocoder.yudao.module.property.service.impl; -import cn.iocoder.yudao.framework.common.util.object.BeanUtils; +import cn.iocoder.yudao.framework.security.core.LoginUser; +import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils; import cn.iocoder.yudao.module.property.entity.Property; import cn.iocoder.yudao.module.property.mapper.PropertyMapper; import cn.iocoder.yudao.module.property.service.PropertyService; import cn.iocoder.yudao.module.property.vo.PropertyReqVO; -import cn.iocoder.yudao.module.property.vo.PropertyRespVO; +import cn.iocoder.yudao.module.system.api.dept.DeptApi; +import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; +import cn.iocoder.yudao.module.system.api.user.AdminUserApi; +import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; +import com.baomidou.dynamic.datasource.annotation.DSTransactional; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.springframework.stereotype.Service; import org.springframework.validation.annotation.Validated; +import javax.annotation.Resource; + /** - * 企业管理-资产 Service 实现类 - * - * @author 后台管理员 - */ + * 企业管理-资产管理 接口实现类 + * @author 小李 + * @date 16:41 2024/8/15 +**/ @Service -@Validated public class PropertyServiceImpl extends ServiceImpl implements PropertyService { + @Resource + private AdminUserApi userApi; + + @Resource + private DeptApi deptApi; + + /** + * 企业管理-资产分页 + * @author 小李 + * @date 16:15 2024/8/15 + * @param pageReqVO 查询对象 + **/ @Override - public String createProperty(PropertyReqVO createReqVO) { - // 插入 - Property property = BeanUtils.toBean(createReqVO, Property.class); - baseMapper.insert(property); - // 返回 - return property.getId(); + public IPage getPropertyPage(PropertyReqVO pageReqVO, Page page){ + return baseMapper.getPropertyPage(pageReqVO, page); } + /** + * 创建资产 + * @author 小李 + * @date 18:26 2024/8/15 + * @param createReqVO + **/ @Override - public void updateProperty(PropertyReqVO updateReqVO) { - // 更新 - Property updateObj = BeanUtils.toBean(updateReqVO, Property.class); - baseMapper.updateById(updateObj); + @DSTransactional + public void createProperty(PropertyReqVO createReqVO){ + // 获取当前登录用户部门ID和企业ID + Long userId = SecurityFrameworkUtils.getLoginUserId(); + AdminUserRespDTO user = userApi.getUser(userId); + createReqVO.setDeptId(user.getDeptId()); + DeptRespDTO dept = deptApi.getDept(user.getDeptId()); + createReqVO.setCorpId(dept.getCorpId()); + + // 创建资产 + baseMapper.insert(createReqVO); } + /** + * 获得资产记录 + * @author 小李 + * @date 18:45 2024/8/15 + * @param id 资产ID + **/ @Override - public void deleteProperty(String id) { - // 删除 - baseMapper.deleteById(id); - } - - @Override - public Property getProperty(String id) { + public Property getProperty(String id){ return baseMapper.selectById(id); } + /** + * 更新资产 + * @author 小李 + * @date 18:57 2024/8/15 + * @param updateReqVO 资产对象 + **/ @Override - public IPage getPropertyPage(PropertyReqVO pageReqVO) { - Page page = new Page<>(pageReqVO.getPageNo(), pageReqVO.getPageSize()); - - return null; + public void updateProperty(PropertyReqVO updateReqVO){ + baseMapper.updateById(updateReqVO); } + /** + * 删除资产 + * @author 小李 + * @date 19:20 2024/8/15 + * @param id 资产ID + **/ + public void deleteProperty(String id){ + baseMapper.deleteById(id); + } } \ No newline at end of file diff --git a/dl-module-company/src/main/java/cn/iocoder/yudao/module/property/vo/PropertyReqVO.java b/dl-module-company/src/main/java/cn/iocoder/yudao/module/property/vo/PropertyReqVO.java index 4de079a0..866d32d3 100644 --- a/dl-module-company/src/main/java/cn/iocoder/yudao/module/property/vo/PropertyReqVO.java +++ b/dl-module-company/src/main/java/cn/iocoder/yudao/module/property/vo/PropertyReqVO.java @@ -1,114 +1,27 @@ package cn.iocoder.yudao.module.property.vo; -import cn.iocoder.yudao.framework.common.pojo.PageParam; +import cn.iocoder.yudao.module.property.entity.Property; import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; -import lombok.EqualsAndHashCode; -import lombok.ToString; import org.springframework.format.annotation.DateTimeFormat; -import java.math.BigDecimal; -import java.time.LocalDateTime; +import java.util.Date; -import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY; +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; -@Schema(description = "管理后台 - 企业管理-资产分页 Request VO") +/** + * 企业管理-资产管理 查询VO + * @author 小李 + * @date 16:37 2024/8/15 +**/ @Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class PropertyReqVO extends PageParam { +public class PropertyReqVO extends Property { - @Schema(description = "主键标识", requiredMode = Schema.RequiredMode.REQUIRED, example = "22729") - private String id; - - @Schema(description = "企业id", example = "9124") - private String corpId; - - @Schema(description = "部门id", example = "2480") - private Long deptId; - - @Schema(description = "存放位置", example = "7241") - private String posId; - - @Schema(description = "使用人id", example = "6217") - private String userId; - - @Schema(description = "资产编号") - private String propNo; - - @Schema(description = "资产名称", example = "芋艿") - private String propName; - - @Schema(description = "资产分类") - private String propCatg; - - @Schema(description = "预计使用年限") - private Integer useYear; - - @Schema(description = "价值类型", example = "01") - private String costType; - - @Schema(description = "资产数量") - private Integer propNum; - - @Schema(description = "资产原值(元)") - private BigDecimal costTotal; - - @Schema(description = "资产状态", example = "02") - private String propStatus; - - @Schema(description = "品牌") - private String brand; - - @Schema(description = "规格型号") - private String spec; - - @Schema(description = "生产厂家") - private String factory; - - @Schema(description = "出场序列号/编号") - private String serialNo; - - @Schema(description = "数量计量单位") - private String unit; - - @Schema(description = "取得日期") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY) - private LocalDateTime getDate; - - @Schema(description = "出厂日期") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY) - private LocalDateTime prodDate; - - @Schema(description = "供应商") - private String supplier; - - @Schema(description = "启用日期") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY) - private LocalDateTime openDate; - - @Schema(description = "净值(元)") - private BigDecimal netValue; - - @Schema(description = "凭证号") - private String voucherNo; - - @Schema(description = "维修/保养周期单位", example = "2") - private String keepCycleType; - - @Schema(description = "维修/保养周期") - private Integer keepCycle; - - @Schema(description = "上次维修/保养日期") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY) - private LocalDateTime lastKeepDate; - - @Schema(description = "下次维修/保养日期") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY) - private LocalDateTime nextKeepDate; - - @Schema(description = "创建时间") - @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY) - private LocalDateTime createTime; + @Schema(description = "取得日期查询范围") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private Date[] getDateArray; + @Schema(description = "启用日期查询范围") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private Date[] openDateArray; } \ No newline at end of file diff --git a/dl-module-company/src/main/java/cn/iocoder/yudao/module/property/vo/PropertyRespVO.java b/dl-module-company/src/main/java/cn/iocoder/yudao/module/property/vo/PropertyRespVO.java index c605c6b2..a651611b 100644 --- a/dl-module-company/src/main/java/cn/iocoder/yudao/module/property/vo/PropertyRespVO.java +++ b/dl-module-company/src/main/java/cn/iocoder/yudao/module/property/vo/PropertyRespVO.java @@ -1,20 +1,13 @@ package cn.iocoder.yudao.module.property.vo; import cn.iocoder.yudao.module.property.entity.Property; -import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; -import com.alibaba.excel.annotation.ExcelProperty; -import io.swagger.v3.oas.annotations.media.Schema; import lombok.Data; -import java.time.LocalDateTime; - -@Schema(description = "管理后台 - 企业管理-资产 Response VO") +/** + * 企业管理-资产管理 响应或提交VO + * @author 小李 + * @date 16:38 2024/8/15 +**/ @Data -@ExcelIgnoreUnannotated public class PropertyRespVO extends Property { - - @Schema(description = "创建时间") - @ExcelProperty("创建时间") - private LocalDateTime createTime; - } \ No newline at end of file diff --git a/dl-module-company/src/main/java/cn/iocoder/yudao/module/staff/controller/admin/CompanyStaffController.java b/dl-module-company/src/main/java/cn/iocoder/yudao/module/staff/controller/admin/CompanyStaffController.java index 8b93f7cf..8059ac1c 100644 --- a/dl-module-company/src/main/java/cn/iocoder/yudao/module/staff/controller/admin/CompanyStaffController.java +++ b/dl-module-company/src/main/java/cn/iocoder/yudao/module/staff/controller/admin/CompanyStaffController.java @@ -1,5 +1,6 @@ package cn.iocoder.yudao.module.staff.controller.admin; +import cn.hutool.core.util.ObjectUtil; import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; @@ -21,6 +22,7 @@ import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; import java.io.IOException; +import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -137,12 +139,19 @@ public class CompanyStaffController { @PreAuthorize("@ss.hasPermission('company:staff:export')") @ApiAccessLog(operateType = EXPORT) public void exportCompanyStaffExcel(CompanyStaffReqVO pageReqVO, - @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, - @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, HttpServletResponse response) throws IOException { - Page page = new Page<>(pageNo, pageSize); - IPage staffIPage = staffService.queryListPage(pageReqVO, page); - List list = staffIPage.getRecords(); + int pageNo = 1, pageSize = 100; + List list = new ArrayList<>(); + while (true){ + Page page = new Page<>(pageNo, pageSize); + IPage staffIPage = staffService.queryListPage(pageReqVO, page); + if (ObjectUtil.isNotEmpty(staffIPage) && !staffIPage.getRecords().isEmpty()){ + list.addAll(staffIPage.getRecords()); + pageNo++; + }else { + break; + } + } // 导出 Excel Map columnWidthMap = new HashMap<>(); // 第一列的索引是0,宽度设置为20个字符宽 diff --git a/dl-module-company/src/main/java/cn/iocoder/yudao/module/staff/entity/CompanyStaff.java b/dl-module-company/src/main/java/cn/iocoder/yudao/module/staff/entity/CompanyStaff.java index 03f8f1c7..5ec20c26 100644 --- a/dl-module-company/src/main/java/cn/iocoder/yudao/module/staff/entity/CompanyStaff.java +++ b/dl-module-company/src/main/java/cn/iocoder/yudao/module/staff/entity/CompanyStaff.java @@ -1,7 +1,6 @@ package cn.iocoder.yudao.module.staff.entity; -import cn.hutool.core.util.ObjectUtil; import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO; @@ -17,11 +16,11 @@ import lombok.EqualsAndHashCode; import org.springframework.format.annotation.DateTimeFormat; import java.math.BigDecimal; -import java.util.ArrayList; import java.util.Date; import java.util.List; -import static cn.iocoder.yudao.common.DictBaseConstants.*; +import static cn.iocoder.yudao.common.DictBaseConstants.COMPANY_STAFF_EDU; +import static cn.iocoder.yudao.common.DictBaseConstants.DICT_SYS_USER_SEX; /** * 企业管理-员工信息实体 diff --git a/dl-module-company/src/main/resources/mapper/property/PropertyMapper.xml b/dl-module-company/src/main/resources/mapper/property/PropertyMapper.xml index a9432c36..a6b1a0a8 100644 --- a/dl-module-company/src/main/resources/mapper/property/PropertyMapper.xml +++ b/dl-module-company/src/main/resources/mapper/property/PropertyMapper.xml @@ -1,12 +1,119 @@ - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + SELECT cp.id AS cp_id, + cp.corp_id AS cp_corp_id, + cp.dept_id AS cp_dept_id, + cp.pos_id AS cp_pos_id, + cp.user_id AS cp_user_id, + cp.prop_no AS cp_prop_no, + cp.prop_name AS cp_prop_name, + cp.prop_catg AS cp_prop_catg, + cp.use_year AS cp_use_year, + cp.cost_type AS cp_cost_type, + cp.prop_num AS cp_prop_num, + cp.cost_total AS cp_cost_total, + cp.prop_status AS cp_prop_status, + cp.brand AS cp_brand, + cp.spec AS cp_spec, + cp.factory AS cp_factory, + cp.serial_no AS cp_serial_no, + cp.unit AS cp_unit, + cp.get_date AS cp_get_date, + cp.prod_date AS cp_prod_date, + cp.supplier AS cp_supplier, + cp.open_date AS cp_open_date, + cp.net_value AS cp_net_value, + cp.voucher_no AS cp_voucher_no, + cp.keep_cycle_type AS cp_keep_cycle_type, + cp.keep_cycle AS cp_keep_cycle, + cp.last_keep_date AS cp_last_keep_date, + cp.next_keep_date AS cp_next_keep_date, + cp.file_urls AS cp_file_urls, + cs.name AS staff_name, + cpp.pos_name AS pos_name + FROM company_property cp + LEFT JOIN company_staff cs ON cp.user_id = cs.user_id + LEFT JOIN company_property_pos cpp ON cp.pos_id = cpp.id + WHERE cp.deleted = '0' + + + \ No newline at end of file