30 files added
1 files modified
| New file |
| | |
| | | /* |
| | | * Copyright 2019-2020 Zheng Jie |
| | | * |
| | | * Licensed under the Apache License, Version 2.0 (the "License"); |
| | | * you may not use this file except in compliance with the License. |
| | | * You may obtain a copy of the License at |
| | | * |
| | | * http://www.apache.org/licenses/LICENSE-2.0 |
| | | * |
| | | * Unless required by applicable law or agreed to in writing, software |
| | | * distributed under the License is distributed on an "AS IS" BASIS, |
| | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| | | * See the License for the specific language governing permissions and |
| | | * limitations under the License. |
| | | */ |
| | | package me.zhengjie.modules.assetManagement.domain; |
| | | |
| | | import lombok.Data; |
| | | import cn.hutool.core.bean.BeanUtil; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import cn.hutool.core.bean.copier.CopyOptions; |
| | | import me.zhengjie.base.BaseEntity; |
| | | |
| | | import javax.persistence.*; |
| | | import javax.validation.constraints.*; |
| | | import java.math.BigDecimal; |
| | | import java.sql.Timestamp; |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * @website https://eladmin.vip |
| | | * @description / |
| | | * @author wcd |
| | | * @date 2023-02-06 |
| | | **/ |
| | | @Entity |
| | | @Data |
| | | @Table(name="asset_management") |
| | | public class AssetManagement extends BaseEntity implements Serializable { |
| | | |
| | | @Id |
| | | @GeneratedValue(strategy = GenerationType.IDENTITY) |
| | | @Column(name = "`id`") |
| | | @ApiModelProperty(value = "id") |
| | | private Long id; |
| | | |
| | | @Column(name = "`number`",nullable = false) |
| | | @NotNull |
| | | @ApiModelProperty(value = "编号") |
| | | private String number; |
| | | |
| | | @Column(name = "`name`",nullable = false) |
| | | @NotBlank |
| | | @ApiModelProperty(value = "名称") |
| | | private String name; |
| | | |
| | | @Column(name = "`type_number`") |
| | | @ApiModelProperty(value = "型号") |
| | | private String typeNumber; |
| | | |
| | | @Column(name = "`assets_type`",nullable = false) |
| | | @NotBlank |
| | | @ApiModelProperty(value = "资产类型") |
| | | private String assetsType; |
| | | |
| | | @Column(name = "`buy_date`") |
| | | @ApiModelProperty(value = "购买日期") |
| | | private Timestamp buyDate; |
| | | |
| | | @Column(name = "`buy_money`") |
| | | @ApiModelProperty(value = "购买金额") |
| | | private BigDecimal buyMoney; |
| | | |
| | | @Column(name = "`affiliated_company`",nullable = false) |
| | | @NotBlank |
| | | @ApiModelProperty(value = "所属公司") |
| | | private String affiliatedCompany; |
| | | |
| | | @Column(name = "`state`") |
| | | @ApiModelProperty(value = "使用状态") |
| | | private String state; |
| | | |
| | | @Column(name = "`remarks`") |
| | | @ApiModelProperty(value = "备注") |
| | | private String remarks; |
| | | |
| | | public void copy(AssetManagement source){ |
| | | BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); |
| | | } |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright 2019-2020 Zheng Jie |
| | | * |
| | | * Licensed under the Apache License, Version 2.0 (the "License"); |
| | | * you may not use this file except in compliance with the License. |
| | | * You may obtain a copy of the License at |
| | | * |
| | | * http://www.apache.org/licenses/LICENSE-2.0 |
| | | * |
| | | * Unless required by applicable law or agreed to in writing, software |
| | | * distributed under the License is distributed on an "AS IS" BASIS, |
| | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| | | * See the License for the specific language governing permissions and |
| | | * limitations under the License. |
| | | */ |
| | | package me.zhengjie.modules.assetManagement.domain; |
| | | |
| | | import lombok.Data; |
| | | import cn.hutool.core.bean.BeanUtil; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import cn.hutool.core.bean.copier.CopyOptions; |
| | | import me.zhengjie.base.BaseEntity; |
| | | |
| | | import javax.persistence.*; |
| | | import javax.validation.constraints.*; |
| | | import java.sql.Timestamp; |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * @website https://eladmin.vip |
| | | * @description / |
| | | * @author wcd |
| | | * @date 2023-02-07 |
| | | **/ |
| | | @Entity |
| | | @Data |
| | | @Table(name="asset_use_management") |
| | | public class AssetUseManagement extends BaseEntity implements Serializable { |
| | | |
| | | @Id |
| | | @GeneratedValue(strategy = GenerationType.IDENTITY) |
| | | @Column(name = "`id`") |
| | | @ApiModelProperty(value = "id") |
| | | private Long id; |
| | | |
| | | @Column(name = "`asset_id`") |
| | | @ApiModelProperty(value = "资产id") |
| | | private Long assetId; |
| | | |
| | | @Column(name = "`user_id`") |
| | | @ApiModelProperty(value = "员工id") |
| | | private Long userId; |
| | | |
| | | @Column(name = "`meeting_id`") |
| | | @ApiModelProperty(value = "会议室id") |
| | | private Long meetingId; |
| | | |
| | | @Column(name = "`use_start_time`") |
| | | @ApiModelProperty(value = "使用开始日期") |
| | | private Timestamp useStartTime; |
| | | |
| | | @Column(name = "`use_end_time`") |
| | | @ApiModelProperty(value = "使用结束时间") |
| | | private Timestamp useEndTime; |
| | | |
| | | @Column(name = "`remarks`") |
| | | @ApiModelProperty(value = "备注") |
| | | private String remarks; |
| | | |
| | | public void copy(AssetUseManagement source){ |
| | | BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); |
| | | } |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright 2019-2020 Zheng Jie |
| | | * |
| | | * Licensed under the Apache License, Version 2.0 (the "License"); |
| | | * you may not use this file except in compliance with the License. |
| | | * You may obtain a copy of the License at |
| | | * |
| | | * http://www.apache.org/licenses/LICENSE-2.0 |
| | | * |
| | | * Unless required by applicable law or agreed to in writing, software |
| | | * distributed under the License is distributed on an "AS IS" BASIS, |
| | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| | | * See the License for the specific language governing permissions and |
| | | * limitations under the License. |
| | | */ |
| | | package me.zhengjie.modules.assetManagement.repository; |
| | | |
| | | import me.zhengjie.modules.assetManagement.domain.AssetManagement; |
| | | import org.springframework.data.jpa.repository.JpaRepository; |
| | | import org.springframework.data.jpa.repository.JpaSpecificationExecutor; |
| | | |
| | | /** |
| | | * @website https://eladmin.vip |
| | | * @author wcd |
| | | * @date 2023-02-06 |
| | | **/ |
| | | public interface AssetManagementRepository extends JpaRepository<AssetManagement, Long>, JpaSpecificationExecutor<AssetManagement> { |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright 2019-2020 Zheng Jie |
| | | * |
| | | * Licensed under the Apache License, Version 2.0 (the "License"); |
| | | * you may not use this file except in compliance with the License. |
| | | * You may obtain a copy of the License at |
| | | * |
| | | * http://www.apache.org/licenses/LICENSE-2.0 |
| | | * |
| | | * Unless required by applicable law or agreed to in writing, software |
| | | * distributed under the License is distributed on an "AS IS" BASIS, |
| | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| | | * See the License for the specific language governing permissions and |
| | | * limitations under the License. |
| | | */ |
| | | package me.zhengjie.modules.assetManagement.repository; |
| | | |
| | | import me.zhengjie.modules.assetManagement.domain.AssetUseManagement; |
| | | import me.zhengjie.modules.attendance.domain.AttendanceBusinessTravel; |
| | | import org.springframework.data.jpa.repository.JpaRepository; |
| | | import org.springframework.data.jpa.repository.JpaSpecificationExecutor; |
| | | import org.springframework.data.jpa.repository.Query; |
| | | |
| | | import java.time.LocalDateTime; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @website https://eladmin.vip |
| | | * @author wcd |
| | | * @date 2023-02-07 |
| | | **/ |
| | | public interface AssetUseManagementRepository extends JpaRepository<AssetUseManagement, Long>, JpaSpecificationExecutor<AssetUseManagement> { |
| | | |
| | | // 查询同一资产id最大的数据 |
| | | @Query(value = "SELECT max(id) FROM `asset_use_management` WHERE asset_id = ?", nativeQuery = true) |
| | | Integer findByMaxId(Long assId); |
| | | |
| | | // 查询同一资产id最大的数据 |
| | | @Query(value = "SELECT * FROM `asset_use_management` WHERE asset_id = ?", nativeQuery = true) |
| | | List<AssetUseManagement> findAllByAssId(Long assId); |
| | | |
| | | @Query |
| | | List<AssetUseManagement> findByMeetingId(Long meeting); |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright 2019-2020 Zheng Jie |
| | | * |
| | | * Licensed under the Apache License, Version 2.0 (the "License"); |
| | | * you may not use this file except in compliance with the License. |
| | | * You may obtain a copy of the License at |
| | | * |
| | | * http://www.apache.org/licenses/LICENSE-2.0 |
| | | * |
| | | * Unless required by applicable law or agreed to in writing, software |
| | | * distributed under the License is distributed on an "AS IS" BASIS, |
| | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| | | * See the License for the specific language governing permissions and |
| | | * limitations under the License. |
| | | */ |
| | | package me.zhengjie.modules.assetManagement.rest; |
| | | |
| | | import me.zhengjie.annotation.Log; |
| | | import me.zhengjie.modules.assetManagement.domain.AssetManagement; |
| | | import me.zhengjie.modules.assetManagement.domain.AssetUseManagement; |
| | | import me.zhengjie.modules.assetManagement.service.AssetManagementService; |
| | | import me.zhengjie.modules.assetManagement.service.AssetUseManagementService; |
| | | import me.zhengjie.modules.assetManagement.service.dto.AssetManagementQueryCriteria; |
| | | import me.zhengjie.modules.task.service.dto.TaskUserDto; |
| | | import org.springframework.data.domain.Pageable; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.http.HttpStatus; |
| | | import org.springframework.http.ResponseEntity; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import io.swagger.annotations.*; |
| | | import java.io.IOException; |
| | | import java.text.ParseException; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | |
| | | /** |
| | | * @website https://eladmin.vip |
| | | * @author wcd |
| | | * @date 2023-02-06 |
| | | **/ |
| | | @RestController |
| | | @RequiredArgsConstructor |
| | | @Api(tags = "资产记录管理") |
| | | @RequestMapping("/api/assetManagement") |
| | | public class AssetManagementController { |
| | | |
| | | private final AssetManagementService assetManagementService; |
| | | private final AssetUseManagementService assetUseManagementService; |
| | | |
| | | @Log("导出数据") |
| | | @ApiOperation("导出数据") |
| | | @GetMapping(value = "/download") |
| | | @PreAuthorize("@el.check('assetManagement:download')") |
| | | public void exportAssetManagement(HttpServletResponse response, AssetManagementQueryCriteria criteria) throws IOException { |
| | | assetManagementService.download(assetManagementService.queryAll(criteria), response); |
| | | } |
| | | |
| | | @GetMapping |
| | | @Log("查询资产记录") |
| | | @ApiOperation("查询资产记录") |
| | | @PreAuthorize("@el.check('assetManagement:list')") |
| | | public ResponseEntity<Object> queryAssetManagement(AssetManagementQueryCriteria criteria, Pageable pageable){ |
| | | return new ResponseEntity<>(assetManagementService.queryAll(criteria,pageable),HttpStatus.OK); |
| | | } |
| | | |
| | | @GetMapping(value = "/all") |
| | | @Log("查询资产记录") |
| | | @ApiOperation("查询资产记录") |
| | | @PreAuthorize("@el.check('assetManagement:list')") |
| | | public ResponseEntity<Object> queryAssetManagement(AssetManagementQueryCriteria criteria){ |
| | | return new ResponseEntity<>(assetManagementService.queryAll(criteria),HttpStatus.OK); |
| | | } |
| | | |
| | | @PostMapping |
| | | @Log("新增资产记录") |
| | | @ApiOperation("新增资产记录") |
| | | @PreAuthorize("@el.check('assetManagement:add')") |
| | | public ResponseEntity<Object> createAssetManagement(@Validated @RequestBody AssetManagement resources){ |
| | | return new ResponseEntity<>(assetManagementService.create(resources),HttpStatus.CREATED); |
| | | } |
| | | |
| | | @PutMapping |
| | | @Log("修改资产记录") |
| | | @ApiOperation("修改资产记录") |
| | | @PreAuthorize("@el.check('assetManagement:edit')") |
| | | public ResponseEntity<Object> updateAssetManagement(@Validated @RequestBody AssetManagement resources){ |
| | | assetManagementService.update(resources); |
| | | return new ResponseEntity<>(HttpStatus.NO_CONTENT); |
| | | } |
| | | |
| | | @DeleteMapping |
| | | @Log("删除资产记录") |
| | | @ApiOperation("删除资产记录") |
| | | @PreAuthorize("@el.check('assetManagement:del')") |
| | | public ResponseEntity<Object> deleteAssetManagement(@RequestBody Long[] ids) { |
| | | assetManagementService.deleteAll(ids); |
| | | return new ResponseEntity<>(HttpStatus.OK); |
| | | } |
| | | |
| | | @PostMapping(value = "/divide") |
| | | @Log("分配任务") |
| | | @ApiOperation("分配任务") |
| | | public ResponseEntity<Object> divideTask(@Validated @RequestBody AssetUseManagement resources) throws ParseException { |
| | | assetUseManagementService.divide(resources); |
| | | return new ResponseEntity<>(HttpStatus.NO_CONTENT); |
| | | } |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright 2019-2020 Zheng Jie |
| | | * |
| | | * Licensed under the Apache License, Version 2.0 (the "License"); |
| | | * you may not use this file except in compliance with the License. |
| | | * You may obtain a copy of the License at |
| | | * |
| | | * http://www.apache.org/licenses/LICENSE-2.0 |
| | | * |
| | | * Unless required by applicable law or agreed to in writing, software |
| | | * distributed under the License is distributed on an "AS IS" BASIS, |
| | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| | | * See the License for the specific language governing permissions and |
| | | * limitations under the License. |
| | | */ |
| | | package me.zhengjie.modules.assetManagement.rest; |
| | | |
| | | import me.zhengjie.annotation.Log; |
| | | import me.zhengjie.modules.assetManagement.domain.AssetUseManagement; |
| | | import me.zhengjie.modules.assetManagement.service.AssetUseManagementService; |
| | | import me.zhengjie.modules.assetManagement.service.dto.AssetManagementQueryCriteria; |
| | | import me.zhengjie.modules.assetManagement.service.dto.AssetUseManagementQueryCriteria; |
| | | import org.springframework.data.domain.Pageable; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.http.HttpStatus; |
| | | import org.springframework.http.ResponseEntity; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import io.swagger.annotations.*; |
| | | import java.io.IOException; |
| | | import java.text.ParseException; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | |
| | | /** |
| | | * @website https://eladmin.vip |
| | | * @author wcd |
| | | * @date 2023-02-07 |
| | | **/ |
| | | @RestController |
| | | @RequiredArgsConstructor |
| | | @Api(tags = "资产使用管理") |
| | | @RequestMapping("/api/assetUseManagement") |
| | | public class AssetUseManagementController { |
| | | |
| | | private final AssetUseManagementService assetUseManagementService; |
| | | |
| | | @Log("导出数据") |
| | | @ApiOperation("导出数据") |
| | | @GetMapping(value = "/download") |
| | | @PreAuthorize("@el.check('assetUseManagement:download')") |
| | | public void exportAssetUseManagement(HttpServletResponse response, AssetUseManagementQueryCriteria criteria) throws IOException { |
| | | assetUseManagementService.download(assetUseManagementService.queryAll(criteria), response); |
| | | } |
| | | |
| | | @GetMapping |
| | | @Log("查询资产使用") |
| | | @ApiOperation("查询资产使用") |
| | | @PreAuthorize("@el.check('assetUseManagement:list')") |
| | | public ResponseEntity<Object> queryAssetUseManagement(AssetUseManagementQueryCriteria criteria, Pageable pageable){ |
| | | return new ResponseEntity<>(assetUseManagementService.queryAll(criteria,pageable),HttpStatus.OK); |
| | | } |
| | | |
| | | @GetMapping(value = "/all") |
| | | @Log("查询资产使用") |
| | | @ApiOperation("查询资产使用") |
| | | @PreAuthorize("@el.check('assetUseManagement:list')") |
| | | public ResponseEntity<Object> queryAssetUseManagement(AssetUseManagementQueryCriteria criteria){ |
| | | return new ResponseEntity<>(assetUseManagementService.queryAll(criteria),HttpStatus.OK); |
| | | } |
| | | |
| | | @PostMapping |
| | | @Log("新增资产使用") |
| | | @ApiOperation("新增资产使用") |
| | | @PreAuthorize("@el.check('assetUseManagement:add')") |
| | | public ResponseEntity<Object> createAssetUseManagement(@Validated @RequestBody AssetUseManagement resources) throws ParseException { |
| | | assetUseManagementService.create(resources); |
| | | return new ResponseEntity<>(HttpStatus.CREATED); |
| | | } |
| | | |
| | | @PutMapping |
| | | @Log("修改资产使用") |
| | | @ApiOperation("修改资产使用") |
| | | @PreAuthorize("@el.check('assetUseManagement:edit')") |
| | | public ResponseEntity<Object> updateAssetUseManagement(@Validated @RequestBody AssetUseManagement resources){ |
| | | assetUseManagementService.update(resources); |
| | | return new ResponseEntity<>(HttpStatus.NO_CONTENT); |
| | | } |
| | | |
| | | @DeleteMapping |
| | | @Log("删除资产使用") |
| | | @ApiOperation("删除资产使用") |
| | | @PreAuthorize("@el.check('assetUseManagement:del')") |
| | | public ResponseEntity<Object> deleteAssetUseManagement(@RequestBody Long[] ids) { |
| | | assetUseManagementService.deleteAll(ids); |
| | | return new ResponseEntity<>(HttpStatus.OK); |
| | | } |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright 2019-2020 Zheng Jie |
| | | * |
| | | * Licensed under the Apache License, Version 2.0 (the "License"); |
| | | * you may not use this file except in compliance with the License. |
| | | * You may obtain a copy of the License at |
| | | * |
| | | * http://www.apache.org/licenses/LICENSE-2.0 |
| | | * |
| | | * Unless required by applicable law or agreed to in writing, software |
| | | * distributed under the License is distributed on an "AS IS" BASIS, |
| | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| | | * See the License for the specific language governing permissions and |
| | | * limitations under the License. |
| | | */ |
| | | package me.zhengjie.modules.assetManagement.service; |
| | | |
| | | import me.zhengjie.modules.assetManagement.domain.AssetManagement; |
| | | import me.zhengjie.modules.assetManagement.service.dto.AssetManagementDto; |
| | | import me.zhengjie.modules.assetManagement.service.dto.AssetManagementQueryCriteria; |
| | | import org.springframework.data.domain.Pageable; |
| | | import java.util.Map; |
| | | import java.util.List; |
| | | import java.io.IOException; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | |
| | | /** |
| | | * @website https://eladmin.vip |
| | | * @description 服务接口 |
| | | * @author wcd |
| | | * @date 2023-02-06 |
| | | **/ |
| | | public interface AssetManagementService { |
| | | |
| | | /** |
| | | * 查询数据分页 |
| | | * @param criteria 条件 |
| | | * @param pageable 分页参数 |
| | | * @return Map<String,Object> |
| | | */ |
| | | Map<String,Object> queryAll(AssetManagementQueryCriteria criteria, Pageable pageable); |
| | | |
| | | /** |
| | | * 查询所有数据不分页 |
| | | * @param criteria 条件参数 |
| | | * @return List<AssetManagementDto> |
| | | */ |
| | | List<AssetManagementDto> queryAll(AssetManagementQueryCriteria criteria); |
| | | |
| | | /** |
| | | * 根据ID查询 |
| | | * @param id ID |
| | | * @return AssetManagementDto |
| | | */ |
| | | AssetManagementDto findById(Long id); |
| | | |
| | | /** |
| | | * 创建 |
| | | * @param resources / |
| | | * @return AssetManagementDto |
| | | */ |
| | | AssetManagementDto create(AssetManagement resources); |
| | | |
| | | /** |
| | | * 编辑 |
| | | * @param resources / |
| | | */ |
| | | void update(AssetManagement resources); |
| | | |
| | | /** |
| | | * 多选删除 |
| | | * @param ids / |
| | | */ |
| | | void deleteAll(Long[] ids); |
| | | |
| | | /** |
| | | * 导出数据 |
| | | * @param all 待导出的数据 |
| | | * @param response / |
| | | * @throws IOException / |
| | | */ |
| | | void download(List<AssetManagementDto> all, HttpServletResponse response) throws IOException; |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright 2019-2020 Zheng Jie |
| | | * |
| | | * Licensed under the Apache License, Version 2.0 (the "License"); |
| | | * you may not use this file except in compliance with the License. |
| | | * You may obtain a copy of the License at |
| | | * |
| | | * http://www.apache.org/licenses/LICENSE-2.0 |
| | | * |
| | | * Unless required by applicable law or agreed to in writing, software |
| | | * distributed under the License is distributed on an "AS IS" BASIS, |
| | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| | | * See the License for the specific language governing permissions and |
| | | * limitations under the License. |
| | | */ |
| | | package me.zhengjie.modules.assetManagement.service; |
| | | |
| | | import me.zhengjie.modules.assetManagement.domain.AssetUseManagement; |
| | | import me.zhengjie.modules.assetManagement.service.dto.AssetUseManagementDto; |
| | | import me.zhengjie.modules.assetManagement.service.dto.AssetUseManagementQueryCriteria; |
| | | import me.zhengjie.modules.task.service.dto.TaskUserDto; |
| | | import org.springframework.data.domain.Pageable; |
| | | |
| | | import java.text.ParseException; |
| | | import java.util.Map; |
| | | import java.util.List; |
| | | import java.io.IOException; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | |
| | | /** |
| | | * @website https://eladmin.vip |
| | | * @description 服务接口 |
| | | * @author wcd |
| | | * @date 2023-02-07 |
| | | **/ |
| | | public interface AssetUseManagementService { |
| | | |
| | | /** |
| | | * 查询数据分页 |
| | | * @param criteria 条件 |
| | | * @param pageable 分页参数 |
| | | * @return Map<String,Object> |
| | | */ |
| | | Map<String,Object> queryAll(AssetUseManagementQueryCriteria criteria, Pageable pageable); |
| | | |
| | | /** |
| | | * 查询所有数据不分页 |
| | | * @param criteria 条件参数 |
| | | * @return List<AssetUseManagementDto> |
| | | */ |
| | | List<AssetUseManagementDto> queryAll(AssetUseManagementQueryCriteria criteria); |
| | | |
| | | /** |
| | | * 根据ID查询 |
| | | * @param id ID |
| | | * @return AssetUseManagementDto |
| | | */ |
| | | AssetUseManagementDto findById(Long id); |
| | | |
| | | /** |
| | | * 创建 |
| | | * @param resources / |
| | | * @return AssetUseManagementDto |
| | | */ |
| | | void create(AssetUseManagement resources) throws ParseException; |
| | | |
| | | /** |
| | | * 编辑 |
| | | * @param resources / |
| | | */ |
| | | void update(AssetUseManagement resources); |
| | | |
| | | /** |
| | | * 多选删除 |
| | | * @param ids / |
| | | */ |
| | | void deleteAll(Long[] ids); |
| | | |
| | | /** |
| | | * 导出数据 |
| | | * @param all 待导出的数据 |
| | | * @param response / |
| | | * @throws IOException / |
| | | */ |
| | | void download(List<AssetUseManagementDto> all, HttpServletResponse response) throws IOException; |
| | | |
| | | /** |
| | | * 分配 |
| | | * @param resources / |
| | | * @return AssetUseManagement |
| | | */ |
| | | void divide(AssetUseManagement resources) throws ParseException; |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright 2019-2020 Zheng Jie |
| | | * |
| | | * Licensed under the Apache License, Version 2.0 (the "License"); |
| | | * you may not use this file except in compliance with the License. |
| | | * You may obtain a copy of the License at |
| | | * |
| | | * http://www.apache.org/licenses/LICENSE-2.0 |
| | | * |
| | | * Unless required by applicable law or agreed to in writing, software |
| | | * distributed under the License is distributed on an "AS IS" BASIS, |
| | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| | | * See the License for the specific language governing permissions and |
| | | * limitations under the License. |
| | | */ |
| | | package me.zhengjie.modules.assetManagement.service.dto; |
| | | |
| | | import lombok.Data; |
| | | import me.zhengjie.base.BaseDTO; |
| | | |
| | | import java.math.BigDecimal; |
| | | import java.sql.Timestamp; |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * @website https://eladmin.vip |
| | | * @description / |
| | | * @author wcd |
| | | * @date 2023-02-06 |
| | | **/ |
| | | @Data |
| | | public class AssetManagementDto extends BaseDTO implements Serializable { |
| | | |
| | | private Long id; |
| | | |
| | | /** 编号 */ |
| | | private String number; |
| | | |
| | | /** 名称 */ |
| | | private String name; |
| | | |
| | | /** 型号 */ |
| | | private String typeNumber; |
| | | |
| | | /** 资产类型 */ |
| | | private String assetsType; |
| | | |
| | | /** 购买日期 */ |
| | | private Timestamp buyDate; |
| | | |
| | | /** 购买金额 */ |
| | | private BigDecimal buyMoney; |
| | | |
| | | /** 所属公司 */ |
| | | private String affiliatedCompany; |
| | | |
| | | /** 使用状态 */ |
| | | private String state; |
| | | |
| | | /** 备注 */ |
| | | private String remarks; |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright 2019-2020 Zheng Jie |
| | | * |
| | | * Licensed under the Apache License, Version 2.0 (the "License"); |
| | | * you may not use this file except in compliance with the License. |
| | | * You may obtain a copy of the License at |
| | | * |
| | | * http://www.apache.org/licenses/LICENSE-2.0 |
| | | * |
| | | * Unless required by applicable law or agreed to in writing, software |
| | | * distributed under the License is distributed on an "AS IS" BASIS, |
| | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| | | * See the License for the specific language governing permissions and |
| | | * limitations under the License. |
| | | */ |
| | | package me.zhengjie.modules.assetManagement.service.dto; |
| | | |
| | | import lombok.Data; |
| | | import java.util.List; |
| | | import me.zhengjie.annotation.Query; |
| | | |
| | | /** |
| | | * @website https://eladmin.vip |
| | | * @author wcd |
| | | * @date 2023-02-06 |
| | | **/ |
| | | @Data |
| | | public class AssetManagementQueryCriteria{ |
| | | |
| | | @Query(propName = "number", type = Query.Type.INNER_LIKE) |
| | | private String number; |
| | | |
| | | @Query(propName = "name", type = Query.Type.INNER_LIKE) |
| | | private String name; |
| | | |
| | | @Query |
| | | private String affiliatedCompany; |
| | | |
| | | @Query |
| | | private String state; |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright 2019-2020 Zheng Jie |
| | | * |
| | | * Licensed under the Apache License, Version 2.0 (the "License"); |
| | | * you may not use this file except in compliance with the License. |
| | | * You may obtain a copy of the License at |
| | | * |
| | | * http://www.apache.org/licenses/LICENSE-2.0 |
| | | * |
| | | * Unless required by applicable law or agreed to in writing, software |
| | | * distributed under the License is distributed on an "AS IS" BASIS, |
| | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| | | * See the License for the specific language governing permissions and |
| | | * limitations under the License. |
| | | */ |
| | | package me.zhengjie.modules.assetManagement.service.dto; |
| | | |
| | | import lombok.Data; |
| | | import me.zhengjie.base.BaseDTO; |
| | | |
| | | import java.sql.Timestamp; |
| | | import java.io.Serializable; |
| | | |
| | | /** |
| | | * @website https://eladmin.vip |
| | | * @description / |
| | | * @author wcd |
| | | * @date 2023-02-07 |
| | | **/ |
| | | @Data |
| | | public class AssetUseManagementDto extends BaseDTO implements Serializable { |
| | | |
| | | private Long id; |
| | | |
| | | /** 资产id */ |
| | | private Long assetId; |
| | | |
| | | /** 员工id */ |
| | | private Long userId; |
| | | |
| | | /** 会议室id */ |
| | | private Long meetingId; |
| | | |
| | | /** 使用开始日期 */ |
| | | private Timestamp useStartTime; |
| | | |
| | | /** 使用结束时间 */ |
| | | private Timestamp useEndTime; |
| | | |
| | | /** 备注 */ |
| | | private String remarks; |
| | | |
| | | /** 资产 */ |
| | | private String assName; |
| | | |
| | | /** 用户 */ |
| | | private String nickName; |
| | | |
| | | /** 会议室 */ |
| | | private String meetName; |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright 2019-2020 Zheng Jie |
| | | * |
| | | * Licensed under the Apache License, Version 2.0 (the "License"); |
| | | * you may not use this file except in compliance with the License. |
| | | * You may obtain a copy of the License at |
| | | * |
| | | * http://www.apache.org/licenses/LICENSE-2.0 |
| | | * |
| | | * Unless required by applicable law or agreed to in writing, software |
| | | * distributed under the License is distributed on an "AS IS" BASIS, |
| | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| | | * See the License for the specific language governing permissions and |
| | | * limitations under the License. |
| | | */ |
| | | package me.zhengjie.modules.assetManagement.service.dto; |
| | | |
| | | import lombok.Data; |
| | | |
| | | import java.sql.Timestamp; |
| | | import java.util.List; |
| | | import me.zhengjie.annotation.Query; |
| | | |
| | | /** |
| | | * @website https://eladmin.vip |
| | | * @author wcd |
| | | * @date 2023-02-07 |
| | | **/ |
| | | @Data |
| | | public class AssetUseManagementQueryCriteria{ |
| | | |
| | | @Query |
| | | private Long assetId; |
| | | |
| | | @Query |
| | | private Long userId; |
| | | |
| | | @Query(type = Query.Type.BETWEEN, propName = "useStartTime") |
| | | private List<Timestamp> useStartTime; |
| | | |
| | | @Query(type = Query.Type.BETWEEN, propName = "useEndTime") |
| | | private List<Timestamp> useEndTime; |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright 2019-2020 Zheng Jie |
| | | * |
| | | * Licensed under the Apache License, Version 2.0 (the "License"); |
| | | * you may not use this file except in compliance with the License. |
| | | * You may obtain a copy of the License at |
| | | * |
| | | * http://www.apache.org/licenses/LICENSE-2.0 |
| | | * |
| | | * Unless required by applicable law or agreed to in writing, software |
| | | * distributed under the License is distributed on an "AS IS" BASIS, |
| | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| | | * See the License for the specific language governing permissions and |
| | | * limitations under the License. |
| | | */ |
| | | package me.zhengjie.modules.assetManagement.service.impl; |
| | | |
| | | import me.zhengjie.modules.assetManagement.domain.AssetManagement; |
| | | import me.zhengjie.modules.constant.Constant; |
| | | import me.zhengjie.modules.system.repository.DictDetailRepository; |
| | | import me.zhengjie.modules.system.repository.SysUserCompanyRepository; |
| | | import me.zhengjie.utils.ValidationUtil; |
| | | import me.zhengjie.utils.FileUtil; |
| | | import lombok.RequiredArgsConstructor; |
| | | import me.zhengjie.modules.assetManagement.repository.AssetManagementRepository; |
| | | import me.zhengjie.modules.assetManagement.service.AssetManagementService; |
| | | import me.zhengjie.modules.assetManagement.service.dto.AssetManagementDto; |
| | | import me.zhengjie.modules.assetManagement.service.dto.AssetManagementQueryCriteria; |
| | | import me.zhengjie.modules.assetManagement.service.mapstruct.AssetManagementMapper; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.data.domain.Page; |
| | | import org.springframework.data.domain.Pageable; |
| | | import me.zhengjie.utils.PageUtil; |
| | | import me.zhengjie.utils.QueryHelp; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.io.IOException; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.ArrayList; |
| | | import java.util.LinkedHashMap; |
| | | |
| | | /** |
| | | * @website https://eladmin.vip |
| | | * @description 服务实现 |
| | | * @author wcd |
| | | * @date 2023-02-06 |
| | | **/ |
| | | @Service |
| | | @RequiredArgsConstructor |
| | | public class AssetManagementServiceImpl implements AssetManagementService { |
| | | |
| | | private final AssetManagementRepository assetManagementRepository; |
| | | private final AssetManagementMapper assetManagementMapper; |
| | | private final SysUserCompanyRepository sysUserCompanyRepository; |
| | | private final DictDetailRepository dictDetailRepository; |
| | | |
| | | @Override |
| | | public Map<String,Object> queryAll(AssetManagementQueryCriteria criteria, Pageable pageable){ |
| | | Page<AssetManagement> page = assetManagementRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable); |
| | | return PageUtil.toPage(page.map(assetManagementMapper::toDto)); |
| | | } |
| | | |
| | | @Override |
| | | public List<AssetManagementDto> queryAll(AssetManagementQueryCriteria criteria){ |
| | | return assetManagementMapper.toDto(assetManagementRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder))); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | public AssetManagementDto findById(Long id) { |
| | | AssetManagement assetManagement = assetManagementRepository.findById(id).orElseGet(AssetManagement::new); |
| | | ValidationUtil.isNull(assetManagement.getId(),"AssetManagement","id",id); |
| | | return assetManagementMapper.toDto(assetManagement); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public AssetManagementDto create(AssetManagement resources) { |
| | | return assetManagementMapper.toDto(assetManagementRepository.save(resources)); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void update(AssetManagement resources) { |
| | | AssetManagement assetManagement = assetManagementRepository.findById(resources.getId()).orElseGet(AssetManagement::new); |
| | | ValidationUtil.isNull( assetManagement.getId(),"AssetManagement","id",resources.getId()); |
| | | assetManagement.copy(resources); |
| | | assetManagementRepository.save(assetManagement); |
| | | } |
| | | |
| | | @Override |
| | | public void deleteAll(Long[] ids) { |
| | | for (Long id : ids) { |
| | | assetManagementRepository.deleteById(id); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void download(List<AssetManagementDto> all, HttpServletResponse response) throws IOException { |
| | | List<Map<String, Object>> list = new ArrayList<>(); |
| | | for (AssetManagementDto assetManagement : all) { |
| | | String results = assetManagement.getState() != null ? dictDetailRepository.findByDictNameAndValue("assets_use", assetManagement.getState()).getLabel() : ""; |
| | | Map<String,Object> map = new LinkedHashMap<>(); |
| | | map.put("编号", assetManagement.getNumber()); |
| | | map.put("名称", assetManagement.getName()); |
| | | map.put("型号", assetManagement.getTypeNumber()); |
| | | map.put("资产类型", assetManagement.getAssetsType()); |
| | | map.put("购买日期", assetManagement.getBuyDate()); |
| | | map.put("购买金额", assetManagement.getBuyMoney()); |
| | | map.put("所属公司", sysUserCompanyRepository.findByValue(assetManagement.getAffiliatedCompany()).getLabel()); |
| | | map.put("使用状态", results); |
| | | map.put("备注", assetManagement.getRemarks()); |
| | | map.put("创建者", assetManagement.getCreateBy()); |
| | | map.put("创建时间", assetManagement.getCreateTime()); |
| | | map.put("更新者", assetManagement.getUpdateBy()); |
| | | map.put("更新时间", assetManagement.getUpdateTime()); |
| | | list.add(map); |
| | | } |
| | | FileUtil.downloadExcel(list, response); |
| | | } |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright 2019-2020 Zheng Jie |
| | | * |
| | | * Licensed under the Apache License, Version 2.0 (the "License"); |
| | | * you may not use this file except in compliance with the License. |
| | | * You may obtain a copy of the License at |
| | | * |
| | | * http://www.apache.org/licenses/LICENSE-2.0 |
| | | * |
| | | * Unless required by applicable law or agreed to in writing, software |
| | | * distributed under the License is distributed on an "AS IS" BASIS, |
| | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| | | * See the License for the specific language governing permissions and |
| | | * limitations under the License. |
| | | */ |
| | | package me.zhengjie.modules.assetManagement.service.impl; |
| | | |
| | | import me.zhengjie.exception.BadRequestException; |
| | | import me.zhengjie.modules.assetManagement.domain.AssetManagement; |
| | | import me.zhengjie.modules.assetManagement.domain.AssetUseManagement; |
| | | import me.zhengjie.modules.assetManagement.repository.AssetManagementRepository; |
| | | import me.zhengjie.modules.conferenceRoom.domain.MeetingRoom; |
| | | import me.zhengjie.modules.conferenceRoom.repository.MeetingRoomRepository; |
| | | import me.zhengjie.modules.system.domain.SysUserCompany; |
| | | import me.zhengjie.modules.system.domain.SysUserContract; |
| | | import me.zhengjie.modules.system.domain.User; |
| | | import me.zhengjie.modules.system.repository.UserRepository; |
| | | import me.zhengjie.modules.system.service.dto.SysUserContractDto; |
| | | import me.zhengjie.utils.ValidationUtil; |
| | | import me.zhengjie.utils.FileUtil; |
| | | import lombok.RequiredArgsConstructor; |
| | | import me.zhengjie.modules.assetManagement.repository.AssetUseManagementRepository; |
| | | import me.zhengjie.modules.assetManagement.service.AssetUseManagementService; |
| | | import me.zhengjie.modules.assetManagement.service.dto.AssetUseManagementDto; |
| | | import me.zhengjie.modules.assetManagement.service.dto.AssetUseManagementQueryCriteria; |
| | | import me.zhengjie.modules.assetManagement.service.mapstruct.AssetUseManagementMapper; |
| | | import org.apache.commons.lang3.ObjectUtils; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import org.springframework.data.domain.Page; |
| | | import org.springframework.data.domain.Pageable; |
| | | import me.zhengjie.utils.PageUtil; |
| | | import me.zhengjie.utils.QueryHelp; |
| | | |
| | | import java.sql.Timestamp; |
| | | import java.text.DateFormat; |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.*; |
| | | import java.io.IOException; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.function.Function; |
| | | |
| | | /** |
| | | * @website https://eladmin.vip |
| | | * @description 服务实现 |
| | | * @author wcd |
| | | * @date 2023-02-07 |
| | | **/ |
| | | @Service |
| | | @RequiredArgsConstructor |
| | | public class AssetUseManagementServiceImpl implements AssetUseManagementService { |
| | | |
| | | private final AssetUseManagementRepository assetUseManagementRepository; |
| | | private final AssetUseManagementMapper assetUseManagementMapper; |
| | | private final AssetManagementRepository assetManagementRepository; |
| | | private final UserRepository userRepository; |
| | | private final MeetingRoomRepository meetingRoomRepository; |
| | | |
| | | @Override |
| | | public Map<String,Object> queryAll(AssetUseManagementQueryCriteria criteria, Pageable pageable){ |
| | | Page<AssetUseManagement> page = assetUseManagementRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable); |
| | | //将实体转换为Dto(重写) |
| | | Function<AssetUseManagement, AssetUseManagementDto> func = new Function<AssetUseManagement, AssetUseManagementDto>(){ |
| | | |
| | | @Override |
| | | public AssetUseManagementDto apply(AssetUseManagement assetUseManagement) { |
| | | // 将实体类转换成DTO |
| | | AssetUseManagementDto assetUseManagementDto = assetUseManagementMapper.toDto(assetUseManagement); |
| | | // 查询资产信息 |
| | | AssetManagement assetManagement = assetManagementRepository.findById(assetUseManagementDto.getAssetId()).orElseGet(AssetManagement::new); |
| | | assetUseManagementDto.setAssName(assetManagement.getNumber()); |
| | | // 用户不等于null |
| | | if(ObjectUtils.isNotEmpty(assetUseManagementDto.getUserId())){ |
| | | //查询用户信息 |
| | | User user = userRepository.findById(assetUseManagementDto.getUserId()).orElseGet(User::new); |
| | | assetUseManagementDto.setNickName(user.getNickName()); |
| | | }else{ |
| | | assetUseManagementDto.setNickName(""); |
| | | } |
| | | // 会议室不等于null |
| | | if(ObjectUtils.isNotEmpty(assetUseManagementDto.getMeetingId())){ |
| | | MeetingRoom meetingRoom = meetingRoomRepository.findById(assetUseManagementDto.getMeetingId()).orElseGet(MeetingRoom::new); |
| | | assetUseManagementDto.setMeetName(meetingRoom.getConferenceRoomName()); |
| | | }else{ |
| | | assetUseManagementDto.setMeetName(""); |
| | | } |
| | | return assetUseManagementDto; |
| | | } |
| | | }; |
| | | return PageUtil.toPage(page.map(func)); |
| | | } |
| | | |
| | | @Override |
| | | public List<AssetUseManagementDto> queryAll(AssetUseManagementQueryCriteria criteria){ |
| | | return assetUseManagementMapper.toDto(assetUseManagementRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder))); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | public AssetUseManagementDto findById(Long id) { |
| | | AssetUseManagement assetUseManagement = assetUseManagementRepository.findById(id).orElseGet(AssetUseManagement::new); |
| | | ValidationUtil.isNull(assetUseManagement.getId(),"AssetUseManagement","id",id); |
| | | return assetUseManagementMapper.toDto(assetUseManagement); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void create(AssetUseManagement resources) throws ParseException { |
| | | divide(resources); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void update(AssetUseManagement resources) { |
| | | AssetUseManagement assetUseManagement = assetUseManagementRepository.findById(resources.getId()).orElseGet(AssetUseManagement::new); |
| | | ValidationUtil.isNull( assetUseManagement.getId(),"AssetUseManagement","id",resources.getId()); |
| | | assetUseManagement.copy(resources); |
| | | assetUseManagementRepository.save(assetUseManagement); |
| | | } |
| | | |
| | | @Override |
| | | public void deleteAll(Long[] ids) { |
| | | for (Long id : ids) { |
| | | assetUseManagementRepository.deleteById(id); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void download(List<AssetUseManagementDto> all, HttpServletResponse response) throws IOException { |
| | | List<Map<String, Object>> list = new ArrayList<>(); |
| | | for (AssetUseManagementDto assetUseManagement : all) { |
| | | Map<String,Object> map = new LinkedHashMap<>(); |
| | | AssetManagement assetManagement = assetManagementRepository.findById(assetUseManagement.getAssetId()).orElseGet(AssetManagement::new); |
| | | map.put("资产", assetManagement.getNumber()); |
| | | map.put("员工", ObjectUtils.isEmpty(assetUseManagement.getUserId()) ? "" : userRepository.getById(assetUseManagement.getUserId()).getNickName()); |
| | | map.put("会议室", ObjectUtils.isEmpty(assetUseManagement.getMeetingId()) ? "" : meetingRoomRepository.getById(assetUseManagement.getMeetingId()).getConferenceRoomName()); |
| | | map.put("使用开始日期", assetUseManagement.getUseStartTime()); |
| | | map.put("使用结束时间", assetUseManagement.getUseEndTime()); |
| | | map.put("备注", assetUseManagement.getRemarks()); |
| | | map.put("创建者", assetUseManagement.getCreateBy()); |
| | | map.put("创建时间", assetUseManagement.getCreateTime()); |
| | | map.put("更新者", assetUseManagement.getUpdateBy()); |
| | | map.put("更新时间", assetUseManagement.getUpdateTime()); |
| | | list.add(map); |
| | | } |
| | | FileUtil.downloadExcel(list, response); |
| | | } |
| | | |
| | | /** |
| | | * 分配 |
| | | * @param resources / |
| | | */ |
| | | @Override |
| | | public void divide(AssetUseManagement resources) throws ParseException { |
| | | // 验证日期 |
| | | List<AssetUseManagement> assetUseManagements = assetUseManagementRepository.findAllByAssId(resources.getAssetId()); |
| | | for(int i = 0; i< assetUseManagements.size(); i++){ |
| | | // 结束时间不为null |
| | | if(ObjectUtils.isNotEmpty(assetUseManagements.get(i).getUseEndTime())){ |
| | | if(resources.getUseStartTime().compareTo(assetUseManagements.get(i).getUseEndTime()) <= 0){ |
| | | throw new BadRequestException("使用开始日期不得小于等于已存在的结束日期"); |
| | | } |
| | | } |
| | | if(ObjectUtils.isEmpty(assetUseManagements.get(i).getUseEndTime())){ |
| | | if(resources.getUseStartTime().compareTo(assetUseManagements.get(i).getUseStartTime()) <= 0){ |
| | | throw new BadRequestException("使用开始日期不得小于等于已存在的开始日期"); |
| | | } |
| | | } |
| | | } |
| | | // 查询同一资产id最大的一条数据就是上一条记录 |
| | | Integer count = assetUseManagementRepository.findByMaxId(resources.getAssetId()); |
| | | AssetUseManagement assetUseManagement = null; |
| | | if(ObjectUtils.isNotEmpty(count)){ |
| | | assetUseManagement = assetUseManagementRepository.findById(Long.valueOf(count)).orElseGet(AssetUseManagement::new); |
| | | } |
| | | if(ObjectUtils.isNotEmpty(assetUseManagement)){ |
| | | // 结束时间为null,赋值 |
| | | if(ObjectUtils.isEmpty(assetUseManagement.getUseEndTime())){ |
| | | DateFormat df = new SimpleDateFormat("yyyy-MM-dd"); |
| | | String str = df.format(resources.getUseStartTime()); |
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); |
| | | Date date = sdf.parse(str); |
| | | // 取当前开始日期的前一天日期 |
| | | Calendar calendar = Calendar.getInstance(); |
| | | calendar.setTime(date); |
| | | calendar.add(Calendar.DAY_OF_MONTH, -1); |
| | | date = (Date) calendar.getTime(); |
| | | String format = df.format(date) + " 00:00:00"; |
| | | assetUseManagement.setUseEndTime(Timestamp.valueOf(format)); |
| | | assetUseManagementRepository.save(assetUseManagement); |
| | | } |
| | | } |
| | | AssetUseManagement assetUseManagement1 = new AssetUseManagement(); |
| | | assetUseManagement1.setAssetId(resources.getAssetId()); |
| | | assetUseManagement1.setUserId(ObjectUtils.isEmpty(resources.getUserId()) ? null : resources.getUserId()); |
| | | assetUseManagement1.setMeetingId(ObjectUtils.isEmpty(resources.getMeetingId()) ? null : resources.getMeetingId()); |
| | | assetUseManagement1.setUseStartTime(resources.getUseStartTime()); |
| | | assetUseManagement1.setUseEndTime(ObjectUtils.isEmpty(resources.getUseEndTime()) ? null : resources.getUseEndTime()); |
| | | assetUseManagementRepository.save(assetUseManagement1); |
| | | } |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright 2019-2020 Zheng Jie |
| | | * |
| | | * Licensed under the Apache License, Version 2.0 (the "License"); |
| | | * you may not use this file except in compliance with the License. |
| | | * You may obtain a copy of the License at |
| | | * |
| | | * http://www.apache.org/licenses/LICENSE-2.0 |
| | | * |
| | | * Unless required by applicable law or agreed to in writing, software |
| | | * distributed under the License is distributed on an "AS IS" BASIS, |
| | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| | | * See the License for the specific language governing permissions and |
| | | * limitations under the License. |
| | | */ |
| | | package me.zhengjie.modules.assetManagement.service.mapstruct; |
| | | |
| | | import me.zhengjie.base.BaseMapper; |
| | | import me.zhengjie.modules.assetManagement.domain.AssetManagement; |
| | | import me.zhengjie.modules.assetManagement.service.dto.AssetManagementDto; |
| | | import org.mapstruct.Mapper; |
| | | import org.mapstruct.ReportingPolicy; |
| | | |
| | | /** |
| | | * @website https://eladmin.vip |
| | | * @author wcd |
| | | * @date 2023-02-06 |
| | | **/ |
| | | @Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE) |
| | | public interface AssetManagementMapper extends BaseMapper<AssetManagementDto, AssetManagement> { |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright 2019-2020 Zheng Jie |
| | | * |
| | | * Licensed under the Apache License, Version 2.0 (the "License"); |
| | | * you may not use this file except in compliance with the License. |
| | | * You may obtain a copy of the License at |
| | | * |
| | | * http://www.apache.org/licenses/LICENSE-2.0 |
| | | * |
| | | * Unless required by applicable law or agreed to in writing, software |
| | | * distributed under the License is distributed on an "AS IS" BASIS, |
| | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| | | * See the License for the specific language governing permissions and |
| | | * limitations under the License. |
| | | */ |
| | | package me.zhengjie.modules.assetManagement.service.mapstruct; |
| | | |
| | | import me.zhengjie.base.BaseMapper; |
| | | import me.zhengjie.modules.assetManagement.domain.AssetUseManagement; |
| | | import me.zhengjie.modules.assetManagement.service.dto.AssetUseManagementDto; |
| | | import org.mapstruct.Mapper; |
| | | import org.mapstruct.ReportingPolicy; |
| | | |
| | | /** |
| | | * @website https://eladmin.vip |
| | | * @author wcd |
| | | * @date 2023-02-07 |
| | | **/ |
| | | @Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE) |
| | | public interface AssetUseManagementMapper extends BaseMapper<AssetUseManagementDto, AssetUseManagement> { |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright 2019-2020 Zheng Jie |
| | | * |
| | | * Licensed under the Apache License, Version 2.0 (the "License"); |
| | | * you may not use this file except in compliance with the License. |
| | | * You may obtain a copy of the License at |
| | | * |
| | | * http://www.apache.org/licenses/LICENSE-2.0 |
| | | * |
| | | * Unless required by applicable law or agreed to in writing, software |
| | | * distributed under the License is distributed on an "AS IS" BASIS, |
| | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| | | * See the License for the specific language governing permissions and |
| | | * limitations under the License. |
| | | */ |
| | | package me.zhengjie.modules.conferenceRoom.domain; |
| | | |
| | | import lombok.Data; |
| | | import cn.hutool.core.bean.BeanUtil; |
| | | import io.swagger.annotations.ApiModelProperty; |
| | | import cn.hutool.core.bean.copier.CopyOptions; |
| | | import me.zhengjie.base.BaseEntity; |
| | | |
| | | import javax.persistence.*; |
| | | import javax.validation.constraints.*; |
| | | import java.sql.Timestamp; |
| | | import java.io.Serializable; |
| | | import java.util.List; |
| | | |
| | | /** |
| | | * @website https://eladmin.vip |
| | | * @description / |
| | | * @author wcd |
| | | * @date 2023-02-07 |
| | | **/ |
| | | @Entity |
| | | @Data |
| | | @Table(name="meeting_room") |
| | | public class MeetingRoom extends BaseEntity implements Serializable { |
| | | |
| | | @Id |
| | | @GeneratedValue(strategy = GenerationType.IDENTITY) |
| | | @Column(name = "`id`") |
| | | @ApiModelProperty(value = "id") |
| | | private Long id; |
| | | |
| | | @Column(name = "`conference_room_name`",nullable = false) |
| | | @NotBlank |
| | | @ApiModelProperty(value = "会议室名称") |
| | | private String conferenceRoomName; |
| | | |
| | | @Column(name = "`conference_room_address`") |
| | | @ApiModelProperty(value = "会议室地址") |
| | | private String conferenceRoomAddress; |
| | | |
| | | @Column(name = "`capacity`") |
| | | @ApiModelProperty(value = "容纳人数") |
| | | private Long capacity; |
| | | |
| | | @Column(name = "`remarks`") |
| | | @ApiModelProperty(value = "备注") |
| | | private String remarks; |
| | | |
| | | @Transient |
| | | @ApiModelProperty(value = "数组") |
| | | private List<Long> assList; |
| | | |
| | | public void copy(MeetingRoom source){ |
| | | BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); |
| | | } |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright 2019-2020 Zheng Jie |
| | | * |
| | | * Licensed under the Apache License, Version 2.0 (the "License"); |
| | | * you may not use this file except in compliance with the License. |
| | | * You may obtain a copy of the License at |
| | | * |
| | | * http://www.apache.org/licenses/LICENSE-2.0 |
| | | * |
| | | * Unless required by applicable law or agreed to in writing, software |
| | | * distributed under the License is distributed on an "AS IS" BASIS, |
| | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| | | * See the License for the specific language governing permissions and |
| | | * limitations under the License. |
| | | */ |
| | | package me.zhengjie.modules.conferenceRoom.repository; |
| | | |
| | | import me.zhengjie.modules.conferenceRoom.domain.MeetingRoom; |
| | | import org.springframework.data.jpa.repository.JpaRepository; |
| | | import org.springframework.data.jpa.repository.JpaSpecificationExecutor; |
| | | |
| | | /** |
| | | * @website https://eladmin.vip |
| | | * @author wcd |
| | | * @date 2023-02-07 |
| | | **/ |
| | | public interface MeetingRoomRepository extends JpaRepository<MeetingRoom, Long>, JpaSpecificationExecutor<MeetingRoom> { |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright 2019-2020 Zheng Jie |
| | | * |
| | | * Licensed under the Apache License, Version 2.0 (the "License"); |
| | | * you may not use this file except in compliance with the License. |
| | | * You may obtain a copy of the License at |
| | | * |
| | | * http://www.apache.org/licenses/LICENSE-2.0 |
| | | * |
| | | * Unless required by applicable law or agreed to in writing, software |
| | | * distributed under the License is distributed on an "AS IS" BASIS, |
| | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| | | * See the License for the specific language governing permissions and |
| | | * limitations under the License. |
| | | */ |
| | | package me.zhengjie.modules.conferenceRoom.rest; |
| | | |
| | | import me.zhengjie.annotation.Log; |
| | | import me.zhengjie.modules.conferenceRoom.domain.MeetingRoom; |
| | | import me.zhengjie.modules.conferenceRoom.service.MeetingRoomService; |
| | | import me.zhengjie.modules.conferenceRoom.service.dto.MeetingRoomQueryCriteria; |
| | | import me.zhengjie.modules.system.domain.CustomerResources; |
| | | import org.springframework.data.domain.Pageable; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.http.HttpStatus; |
| | | import org.springframework.http.ResponseEntity; |
| | | import org.springframework.security.access.prepost.PreAuthorize; |
| | | import org.springframework.validation.annotation.Validated; |
| | | import org.springframework.web.bind.annotation.*; |
| | | import io.swagger.annotations.*; |
| | | import java.io.IOException; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | |
| | | /** |
| | | * @website https://eladmin.vip |
| | | * @author wcd |
| | | * @date 2023-02-07 |
| | | **/ |
| | | @RestController |
| | | @RequiredArgsConstructor |
| | | @Api(tags = "会议室信息管理") |
| | | @RequestMapping("/api/meetingRoom") |
| | | public class MeetingRoomController { |
| | | |
| | | private final MeetingRoomService meetingRoomService; |
| | | |
| | | @Log("导出数据") |
| | | @ApiOperation("导出数据") |
| | | @GetMapping(value = "/download") |
| | | @PreAuthorize("@el.check('meetingRoom:download')") |
| | | public void exportMeetingRoom(HttpServletResponse response, MeetingRoomQueryCriteria criteria) throws IOException { |
| | | meetingRoomService.download(meetingRoomService.queryAll(criteria), response); |
| | | } |
| | | |
| | | @GetMapping |
| | | @Log("查询会议室信息") |
| | | @ApiOperation("查询会议室信息") |
| | | @PreAuthorize("@el.check('meetingRoom:list')") |
| | | public ResponseEntity<Object> queryMeetingRoom(MeetingRoomQueryCriteria criteria, Pageable pageable){ |
| | | return new ResponseEntity<>(meetingRoomService.queryAll(criteria,pageable),HttpStatus.OK); |
| | | } |
| | | |
| | | @GetMapping(value = "/all") |
| | | @Log("查询会议室信息") |
| | | @ApiOperation("查询会议室信息") |
| | | @PreAuthorize("@el.check('meetingRoom:list')") |
| | | public ResponseEntity<Object> queryMeetingRoom(MeetingRoomQueryCriteria criteria){ |
| | | return new ResponseEntity<>(meetingRoomService.queryAll(criteria),HttpStatus.OK); |
| | | } |
| | | |
| | | @PostMapping |
| | | @Log("新增会议室信息") |
| | | @ApiOperation("新增会议室信息") |
| | | @PreAuthorize("@el.check('meetingRoom:add')") |
| | | public ResponseEntity<Object> createMeetingRoom(@Validated @RequestBody MeetingRoom resources){ |
| | | return new ResponseEntity<>(meetingRoomService.create(resources),HttpStatus.CREATED); |
| | | } |
| | | |
| | | @PutMapping |
| | | @Log("修改会议室信息") |
| | | @ApiOperation("修改会议室信息") |
| | | @PreAuthorize("@el.check('meetingRoom:edit')") |
| | | public ResponseEntity<Object> updateMeetingRoom(@Validated @RequestBody MeetingRoom resources){ |
| | | meetingRoomService.update(resources); |
| | | return new ResponseEntity<>(HttpStatus.NO_CONTENT); |
| | | } |
| | | |
| | | @DeleteMapping |
| | | @Log("删除会议室信息") |
| | | @ApiOperation("删除会议室信息") |
| | | @PreAuthorize("@el.check('meetingRoom:del')") |
| | | public ResponseEntity<Object> deleteMeetingRoom(@RequestBody Long[] ids) { |
| | | meetingRoomService.deleteAll(ids); |
| | | return new ResponseEntity<>(HttpStatus.OK); |
| | | } |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright 2019-2020 Zheng Jie |
| | | * |
| | | * Licensed under the Apache License, Version 2.0 (the "License"); |
| | | * you may not use this file except in compliance with the License. |
| | | * You may obtain a copy of the License at |
| | | * |
| | | * http://www.apache.org/licenses/LICENSE-2.0 |
| | | * |
| | | * Unless required by applicable law or agreed to in writing, software |
| | | * distributed under the License is distributed on an "AS IS" BASIS, |
| | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| | | * See the License for the specific language governing permissions and |
| | | * limitations under the License. |
| | | */ |
| | | package me.zhengjie.modules.conferenceRoom.service; |
| | | |
| | | import me.zhengjie.modules.conferenceRoom.domain.MeetingRoom; |
| | | import me.zhengjie.modules.conferenceRoom.service.dto.MeetingRoomDto; |
| | | import me.zhengjie.modules.conferenceRoom.service.dto.MeetingRoomQueryCriteria; |
| | | import org.springframework.data.domain.Pageable; |
| | | import java.util.Map; |
| | | import java.util.List; |
| | | import java.io.IOException; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | |
| | | /** |
| | | * @website https://eladmin.vip |
| | | * @description 服务接口 |
| | | * @author wcd |
| | | * @date 2023-02-07 |
| | | **/ |
| | | public interface MeetingRoomService { |
| | | |
| | | /** |
| | | * 查询数据分页 |
| | | * @param criteria 条件 |
| | | * @param pageable 分页参数 |
| | | * @return Map<String,Object> |
| | | */ |
| | | Map<String,Object> queryAll(MeetingRoomQueryCriteria criteria, Pageable pageable); |
| | | |
| | | /** |
| | | * 查询所有数据不分页 |
| | | * @param criteria 条件参数 |
| | | * @return List<MeetingRoomDto> |
| | | */ |
| | | List<MeetingRoomDto> queryAll(MeetingRoomQueryCriteria criteria); |
| | | |
| | | /** |
| | | * 根据ID查询 |
| | | * @param id ID |
| | | * @return MeetingRoomDto |
| | | */ |
| | | MeetingRoomDto findById(Long id); |
| | | |
| | | /** |
| | | * 创建 |
| | | * @param resources / |
| | | * @return MeetingRoomDto |
| | | */ |
| | | MeetingRoomDto create(MeetingRoom resources); |
| | | |
| | | /** |
| | | * 编辑 |
| | | * @param resources / |
| | | */ |
| | | void update(MeetingRoom resources); |
| | | |
| | | /** |
| | | * 多选删除 |
| | | * @param ids / |
| | | */ |
| | | void deleteAll(Long[] ids); |
| | | |
| | | /** |
| | | * 导出数据 |
| | | * @param all 待导出的数据 |
| | | * @param response / |
| | | * @throws IOException / |
| | | */ |
| | | void download(List<MeetingRoomDto> all, HttpServletResponse response) throws IOException; |
| | | |
| | | |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright 2019-2020 Zheng Jie |
| | | * |
| | | * Licensed under the Apache License, Version 2.0 (the "License"); |
| | | * you may not use this file except in compliance with the License. |
| | | * You may obtain a copy of the License at |
| | | * |
| | | * http://www.apache.org/licenses/LICENSE-2.0 |
| | | * |
| | | * Unless required by applicable law or agreed to in writing, software |
| | | * distributed under the License is distributed on an "AS IS" BASIS, |
| | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| | | * See the License for the specific language governing permissions and |
| | | * limitations under the License. |
| | | */ |
| | | package me.zhengjie.modules.conferenceRoom.service.dto; |
| | | |
| | | import lombok.Data; |
| | | import java.sql.Timestamp; |
| | | import java.io.Serializable; |
| | | import java.util.List; |
| | | |
| | | import com.alibaba.fastjson.annotation.JSONField; |
| | | import com.alibaba.fastjson.serializer.ToStringSerializer; |
| | | import me.zhengjie.base.BaseDTO; |
| | | |
| | | /** |
| | | * @website https://eladmin.vip |
| | | * @description / |
| | | * @author wcd |
| | | * @date 2023-02-07 |
| | | **/ |
| | | @Data |
| | | public class MeetingRoomDto extends BaseDTO implements Serializable { |
| | | |
| | | private Long id; |
| | | |
| | | /** 会议室名称 */ |
| | | private String conferenceRoomName; |
| | | |
| | | /** 会议室地址 */ |
| | | private String conferenceRoomAddress; |
| | | |
| | | /** 容纳人数 */ |
| | | private Long capacity; |
| | | |
| | | /** 备注 */ |
| | | private String remarks; |
| | | |
| | | private List<Long> num; |
| | | |
| | | private List<String> snum; |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright 2019-2020 Zheng Jie |
| | | * |
| | | * Licensed under the Apache License, Version 2.0 (the "License"); |
| | | * you may not use this file except in compliance with the License. |
| | | * You may obtain a copy of the License at |
| | | * |
| | | * http://www.apache.org/licenses/LICENSE-2.0 |
| | | * |
| | | * Unless required by applicable law or agreed to in writing, software |
| | | * distributed under the License is distributed on an "AS IS" BASIS, |
| | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| | | * See the License for the specific language governing permissions and |
| | | * limitations under the License. |
| | | */ |
| | | package me.zhengjie.modules.conferenceRoom.service.dto; |
| | | |
| | | import lombok.Data; |
| | | import java.util.List; |
| | | import me.zhengjie.annotation.Query; |
| | | |
| | | /** |
| | | * @website https://eladmin.vip |
| | | * @author wcd |
| | | * @date 2023-02-07 |
| | | **/ |
| | | @Data |
| | | public class MeetingRoomQueryCriteria{ |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright 2019-2020 Zheng Jie |
| | | * |
| | | * Licensed under the Apache License, Version 2.0 (the "License"); |
| | | * you may not use this file except in compliance with the License. |
| | | * You may obtain a copy of the License at |
| | | * |
| | | * http://www.apache.org/licenses/LICENSE-2.0 |
| | | * |
| | | * Unless required by applicable law or agreed to in writing, software |
| | | * distributed under the License is distributed on an "AS IS" BASIS, |
| | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| | | * See the License for the specific language governing permissions and |
| | | * limitations under the License. |
| | | */ |
| | | package me.zhengjie.modules.conferenceRoom.service.impl; |
| | | |
| | | import me.zhengjie.modules.assetManagement.domain.AssetManagement; |
| | | import me.zhengjie.modules.assetManagement.domain.AssetUseManagement; |
| | | import me.zhengjie.modules.assetManagement.repository.AssetManagementRepository; |
| | | import me.zhengjie.modules.assetManagement.repository.AssetUseManagementRepository; |
| | | import me.zhengjie.modules.assetManagement.service.dto.AssetUseManagementDto; |
| | | import me.zhengjie.modules.attendance.domain.Attendance; |
| | | import me.zhengjie.modules.attendance.service.dto.AttendanceDto; |
| | | import me.zhengjie.modules.conferenceRoom.domain.MeetingRoom; |
| | | import me.zhengjie.modules.system.domain.User; |
| | | import me.zhengjie.utils.ValidationUtil; |
| | | import me.zhengjie.utils.FileUtil; |
| | | import lombok.RequiredArgsConstructor; |
| | | import me.zhengjie.modules.conferenceRoom.repository.MeetingRoomRepository; |
| | | import me.zhengjie.modules.conferenceRoom.service.MeetingRoomService; |
| | | import me.zhengjie.modules.conferenceRoom.service.dto.MeetingRoomDto; |
| | | import me.zhengjie.modules.conferenceRoom.service.dto.MeetingRoomQueryCriteria; |
| | | import me.zhengjie.modules.conferenceRoom.service.mapstruct.MeetingRoomMapper; |
| | | import org.apache.commons.lang3.ObjectUtils; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | import cn.hutool.core.lang.Snowflake; |
| | | import cn.hutool.core.util.IdUtil; |
| | | import org.springframework.data.domain.Page; |
| | | import org.springframework.data.domain.Pageable; |
| | | import me.zhengjie.utils.PageUtil; |
| | | import me.zhengjie.utils.QueryHelp; |
| | | |
| | | import java.util.*; |
| | | import java.io.IOException; |
| | | import javax.servlet.http.HttpServletResponse; |
| | | import java.util.function.Function; |
| | | |
| | | /** |
| | | * @website https://eladmin.vip |
| | | * @description 服务实现 |
| | | * @author wcd |
| | | * @date 2023-02-07 |
| | | **/ |
| | | @Service |
| | | @RequiredArgsConstructor |
| | | public class MeetingRoomServiceImpl implements MeetingRoomService { |
| | | |
| | | private final MeetingRoomRepository meetingRoomRepository; |
| | | private final MeetingRoomMapper meetingRoomMapper; |
| | | private final AssetUseManagementRepository assetUseManagementRepository; |
| | | private final AssetManagementRepository assetManagementRepository; |
| | | |
| | | @Override |
| | | public Map<String,Object> queryAll(MeetingRoomQueryCriteria criteria, Pageable pageable){ |
| | | Page<MeetingRoom> page = meetingRoomRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable); |
| | | //将实体转换为Dto(重写) |
| | | Function<MeetingRoom, MeetingRoomDto> func = new Function<MeetingRoom, MeetingRoomDto>(){ |
| | | |
| | | @Override |
| | | public MeetingRoomDto apply(MeetingRoom meetingRoom) { |
| | | // 将实体类转换成DTO |
| | | MeetingRoomDto meetingRoomDto = meetingRoomMapper.toDto(meetingRoom); |
| | | List<Long> sum = new ArrayList<>(); |
| | | // 查询资产管理 |
| | | List<AssetUseManagement> assetUseManagements = assetUseManagementRepository.findByMeetingId(meetingRoomDto.getId()); |
| | | for(int i = 0; i< assetUseManagements.size(); i++){ |
| | | sum.add(assetUseManagements.get(i).getAssetId()); |
| | | } |
| | | HashSet h = new HashSet(sum); |
| | | sum.clear(); |
| | | sum.addAll(h); |
| | | List<String> snum = new ArrayList<>(); |
| | | for(int i = 0; i < sum.size(); i++){ |
| | | // 查询资产记录 |
| | | AssetManagement assetManagement = assetManagementRepository.findById(sum.get(i)).orElseGet(AssetManagement::new); |
| | | if(ObjectUtils.isNotEmpty(assetManagement)){ |
| | | snum.add(assetManagement.getName()); |
| | | } |
| | | } |
| | | meetingRoomDto.setSnum(snum); |
| | | return meetingRoomDto; |
| | | } |
| | | }; |
| | | return PageUtil.toPage(page.map(func)); |
| | | } |
| | | |
| | | @Override |
| | | public List<MeetingRoomDto> queryAll(MeetingRoomQueryCriteria criteria){ |
| | | return meetingRoomMapper.toDto(meetingRoomRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder))); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional |
| | | public MeetingRoomDto findById(Long id) { |
| | | MeetingRoom meetingRoom = meetingRoomRepository.findById(id).orElseGet(MeetingRoom::new); |
| | | ValidationUtil.isNull(meetingRoom.getId(),"MeetingRoom","id",id); |
| | | return meetingRoomMapper.toDto(meetingRoom); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public MeetingRoomDto create(MeetingRoom resources) { |
| | | Snowflake snowflake = IdUtil.createSnowflake(1, 1); |
| | | resources.setId(snowflake.nextId()); |
| | | return meetingRoomMapper.toDto(meetingRoomRepository.save(resources)); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public void update(MeetingRoom resources) { |
| | | MeetingRoom meetingRoom = meetingRoomRepository.findById(resources.getId()).orElseGet(MeetingRoom::new); |
| | | ValidationUtil.isNull( meetingRoom.getId(),"MeetingRoom","id",resources.getId()); |
| | | meetingRoom.copy(resources); |
| | | meetingRoomRepository.save(meetingRoom); |
| | | } |
| | | |
| | | @Override |
| | | public void deleteAll(Long[] ids) { |
| | | for (Long id : ids) { |
| | | meetingRoomRepository.deleteById(id); |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public void download(List<MeetingRoomDto> all, HttpServletResponse response) throws IOException { |
| | | List<Map<String, Object>> list = new ArrayList<>(); |
| | | for (MeetingRoomDto meetingRoom : all) { |
| | | Map<String,Object> map = new LinkedHashMap<>(); |
| | | map.put("会议室名称", meetingRoom.getConferenceRoomName()); |
| | | map.put("会议室地址", meetingRoom.getConferenceRoomAddress()); |
| | | map.put("容纳人数", meetingRoom.getCapacity()); |
| | | List<Long> sum = new ArrayList<>(); |
| | | // 查询资产管理 |
| | | List<AssetUseManagement> assetUseManagements = assetUseManagementRepository.findByMeetingId(meetingRoom.getId()); |
| | | for(int i = 0; i< assetUseManagements.size(); i++){ |
| | | sum.add(assetUseManagements.get(i).getAssetId()); |
| | | } |
| | | HashSet h = new HashSet(sum); |
| | | sum.clear(); |
| | | sum.addAll(h); |
| | | List<String> snum = new ArrayList<>(); |
| | | for(int i = 0; i < sum.size(); i++){ |
| | | // 查询资产记录 |
| | | AssetManagement assetManagement = assetManagementRepository.findById(sum.get(i)).orElseGet(AssetManagement::new); |
| | | if(ObjectUtils.isNotEmpty(assetManagement)){ |
| | | snum.add(assetManagement.getName()); |
| | | } |
| | | } |
| | | map.put("设备", snum); |
| | | map.put("备注", meetingRoom.getRemarks()); |
| | | map.put("创建者", meetingRoom.getCreateBy()); |
| | | map.put("创建时间", meetingRoom.getCreateTime()); |
| | | map.put("更新者", meetingRoom.getUpdateBy()); |
| | | map.put("更新时间", meetingRoom.getUpdateTime()); |
| | | list.add(map); |
| | | } |
| | | FileUtil.downloadExcel(list, response); |
| | | } |
| | | } |
| New file |
| | |
| | | /* |
| | | * Copyright 2019-2020 Zheng Jie |
| | | * |
| | | * Licensed under the Apache License, Version 2.0 (the "License"); |
| | | * you may not use this file except in compliance with the License. |
| | | * You may obtain a copy of the License at |
| | | * |
| | | * http://www.apache.org/licenses/LICENSE-2.0 |
| | | * |
| | | * Unless required by applicable law or agreed to in writing, software |
| | | * distributed under the License is distributed on an "AS IS" BASIS, |
| | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| | | * See the License for the specific language governing permissions and |
| | | * limitations under the License. |
| | | */ |
| | | package me.zhengjie.modules.conferenceRoom.service.mapstruct; |
| | | |
| | | import me.zhengjie.base.BaseMapper; |
| | | import me.zhengjie.modules.conferenceRoom.domain.MeetingRoom; |
| | | import me.zhengjie.modules.conferenceRoom.service.dto.MeetingRoomDto; |
| | | import org.mapstruct.Mapper; |
| | | import org.mapstruct.ReportingPolicy; |
| | | |
| | | /** |
| | | * @website https://eladmin.vip |
| | | * @author wcd |
| | | * @date 2023-02-07 |
| | | **/ |
| | | @Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE) |
| | | public interface MeetingRoomMapper extends BaseMapper<MeetingRoomDto, MeetingRoom> { |
| | | |
| | | } |
| New file |
| | |
| | | import request from '@/utils/request' |
| | | |
| | | export function getAll(params) { |
| | | return request({ |
| | | url: 'api/assetManagement/all', |
| | | method: 'get', |
| | | params |
| | | }) |
| | | } |
| | | |
| | | export function add(data) { |
| | | return request({ |
| | | url: 'api/assetManagement', |
| | | method: 'post', |
| | | data |
| | | }) |
| | | } |
| | | |
| | | export function del(ids) { |
| | | return request({ |
| | | url: 'api/assetManagement/', |
| | | method: 'delete', |
| | | data: ids |
| | | }) |
| | | } |
| | | |
| | | export function edit(data) { |
| | | return request({ |
| | | url: 'api/assetManagement', |
| | | method: 'put', |
| | | data |
| | | }) |
| | | } |
| | | |
| | | export function divide(data) { |
| | | return request({ |
| | | url: 'api/assetManagement/divide', |
| | | method: 'post', |
| | | data |
| | | }) |
| | | } |
| | | |
| | | export default { add, edit, del, getAll, divide } |
| New file |
| | |
| | | import request from '@/utils/request' |
| | | |
| | | export function getAll(params) { |
| | | return request({ |
| | | url: 'api/assetUseManagement/all', |
| | | method: 'get', |
| | | params |
| | | }) |
| | | } |
| | | |
| | | export function add(data) { |
| | | return request({ |
| | | url: 'api/assetUseManagement', |
| | | method: 'post', |
| | | data |
| | | }) |
| | | } |
| | | |
| | | export function del(ids) { |
| | | return request({ |
| | | url: 'api/assetUseManagement/', |
| | | method: 'delete', |
| | | data: ids |
| | | }) |
| | | } |
| | | |
| | | export function edit(data) { |
| | | return request({ |
| | | url: 'api/assetUseManagement', |
| | | method: 'put', |
| | | data |
| | | }) |
| | | } |
| | | |
| | | export default { add, edit, del, getAll } |
| New file |
| | |
| | | import request from '@/utils/request' |
| | | |
| | | export function getAll(params) { |
| | | return request({ |
| | | url: 'api/meetingRoom/all', |
| | | method: 'get', |
| | | params |
| | | }) |
| | | } |
| | | |
| | | export function add(data) { |
| | | return request({ |
| | | url: 'api/meetingRoom', |
| | | method: 'post', |
| | | data |
| | | }) |
| | | } |
| | | |
| | | export function del(ids) { |
| | | return request({ |
| | | url: 'api/meetingRoom/', |
| | | method: 'delete', |
| | | data: ids |
| | | }) |
| | | } |
| | | |
| | | export function edit(data) { |
| | | return request({ |
| | | url: 'api/meetingRoom', |
| | | method: 'put', |
| | | data |
| | | }) |
| | | } |
| | | |
| | | export function getInfo(data) { |
| | | return request({ |
| | | url: 'api/meetingRoom/getInfo', |
| | | method: 'post', |
| | | data |
| | | }) |
| | | } |
| | | |
| | | export default { add, edit, del, getAll, getInfo } |
| | |
| | | // 提醒状态:不提醒 |
| | | export const RESOURCES_TYPE_NOREMIND = 'resources_type_noRemind' |
| | | |
| | | // 资产类型 |
| | | export const ACCET_TYPE = 'asset_type' |
| | | // 资产类型:固定 |
| | | export const ACCET_TYPE_FIXED = 'asset_type_fixed' |
| | | // 资产类型:流动 |
| | | export const ACCET_TYPE_FLOW = 'asset_type_flow' |
| | | |
| | | // 资产使用状态 |
| | | export const ACCETS_USE = 'assets_use' |
| | | // 资产使用状态:使用中 |
| | | export const ACCETS_USE_IN = 'assets_use_in' |
| | | // 资产使用状态:已停止 |
| | | export const ACCETS_USE_STOP = 'assets_use_stop' |
| | | |
| | | export default { |
| | | ROLE_LEVEL_SUPER, |
| | | ROLE_LEVEL_GENERAL, |
| | |
| | | PUBLICITY_STATUS_YES, |
| | | RESOURCES_TYPE, |
| | | RESOURCES_TYPE_REMIND, |
| | | RESOURCES_TYPE_NOREMIND |
| | | RESOURCES_TYPE_NOREMIND, |
| | | ACCET_TYPE, |
| | | ACCET_TYPE_FIXED, |
| | | ACCET_TYPE_FLOW, |
| | | ACCETS_USE, |
| | | ACCETS_USE_IN, |
| | | ACCETS_USE_STOP |
| | | } |
| New file |
| | |
| | | <template> |
| | | <div class="app-container"> |
| | | <!--工具栏--> |
| | | <div class="head-container"> |
| | | <div> |
| | | <el-select v-model="query.assetId" filterable clearable placeholder="资产名称" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery"> |
| | | <el-option |
| | | v-for="item in assetManagements" |
| | | :key="item.id" |
| | | :label="item.number" |
| | | :value="item.id" |
| | | /> |
| | | </el-select> |
| | | <el-select v-model="query.userId" filterable clearable placeholder="审批者" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery"> |
| | | <el-option |
| | | v-for="item in users" |
| | | :key="item.id" |
| | | :label="item.nickName" |
| | | :value="item.id" |
| | | /> |
| | | </el-select> |
| | | <el-date-picker |
| | | v-model="query.useStartTime" |
| | | type="daterange" |
| | | clearable |
| | | class="filter-item" |
| | | value-format="yyyy-MM-dd HH:mm:ss" |
| | | placeholder="请选择日期时间" |
| | | range-separator="至" |
| | | start-placeholder="使用开始日期" |
| | | end-placeholder="使用开始日期" |
| | | /> |
| | | <el-date-picker |
| | | v-model="query.useEndTime" |
| | | type="daterange" |
| | | clearable |
| | | class="filter-item" |
| | | value-format="yyyy-MM-dd HH:mm:ss" |
| | | placeholder="请选择日期时间" |
| | | range-separator="至" |
| | | start-placeholder="使用结束日期" |
| | | end-placeholder="使用结束日期" |
| | | /> |
| | | <rrOperation /> |
| | | </div> |
| | | <!--如果想在工具栏加入更多按钮,可以使用插槽方式, slot = 'left' or 'right'--> |
| | | <crudOperation :permission="permission" /> |
| | | <!--表单组件--> |
| | | <el-dialog :close-on-click-modal="false" :before-close="crud.cancelCU" :visible.sync="crud.status.cu > 0" :title="crud.status.title" width="500px"> |
| | | <el-form ref="form" :model="form" :rules="rules" size="small" label-width="80px"> |
| | | <el-form-item label="资产" prop="assetId"> |
| | | <el-select v-model="form.assetId" filterable clearable placeholder="请选择" style="width: 370px;"> |
| | | <el-option |
| | | v-for="item in assetManagements" |
| | | :key="item.id" |
| | | :label="item.number" |
| | | :value="item.id" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="员工" prop="userId"> |
| | | <el-select v-model="form.userId" filterable clearable placeholder="请选择" style="width: 370px;"> |
| | | <el-option |
| | | v-for="item in users" |
| | | :key="item.id" |
| | | :label="item.nickName" |
| | | :value="item.id" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="会议室"> |
| | | <el-select v-model="form.meetingId" filterable clearable placeholder="请选择" style="width: 370px;"> |
| | | <el-option |
| | | v-for="item in meetingRooms" |
| | | :key="item.id" |
| | | :label="item.conferenceRoomName" |
| | | :value="item.id" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="使用开始日期" prop="useStartTime"> |
| | | <el-date-picker |
| | | v-model="form.useStartTime" |
| | | type="date" |
| | | placeholder="选择日期时间" |
| | | style="width: 370px;" |
| | | value-format="yyyy-MM-dd" |
| | | align="right" |
| | | :picker-options="{ |
| | | disabledDate(time) { |
| | | return form.useEndTime ? time.getTime() > new Date(form.useEndTime).getTime() - 8.64e7 : false; |
| | | } |
| | | }" |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item label="使用结束时间" prop="useEndTime"> |
| | | <el-date-picker |
| | | v-model="form.useEndTime" |
| | | type="date" |
| | | placeholder="选择日期时间" |
| | | style="width: 370px;" |
| | | value-format="yyyy-MM-dd" |
| | | align="right" |
| | | :picker-options="{ |
| | | disabledDate(time) { |
| | | return form.useStartTime ? time.getTime() < new Date(form.useStartTime).getTime() - 8.64e7 : false; |
| | | } |
| | | }" |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item label="备注"> |
| | | <el-input v-model="form.remarks" type="textarea" rows="3" style="width: 370px;" /> |
| | | </el-form-item> |
| | | </el-form> |
| | | <div slot="footer" class="dialog-footer"> |
| | | <el-button type="text" @click="crud.cancelCU">取消</el-button> |
| | | <el-button :loading="crud.status.cu === 2" type="primary" @click="crud.submitCU">确认</el-button> |
| | | </div> |
| | | </el-dialog> |
| | | <!--表格渲染--> |
| | | <el-table ref="table" v-loading="crud.loading" :data="crud.data" size="small" style="width: 100%;" @selection-change="crud.selectionChangeHandler"> |
| | | <el-table-column type="selection" width="55" /> |
| | | <el-table-column prop="assetId" label="资产" show-overflow-tooltip> |
| | | <template slot-scope="scope"> |
| | | <el-tag>{{ scope.row.assName }}</el-tag> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="userId" label="员工" show-overflow-tooltip> |
| | | <template slot-scope="scope"> |
| | | <el-tag v-if="scope.row.nickName !== ''">{{ scope.row.nickName }}</el-tag> |
| | | <el-tag v-if="scope.row.nickName == ''" type="warning">{{ '未分配' }}</el-tag> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="meetingId" label="会议室" show-overflow-tooltip> |
| | | <template slot-scope="scope"> |
| | | <el-tag v-if="scope.row.meetName !== ''">{{ scope.row.meetName }}</el-tag> |
| | | <el-tag v-if="scope.row.meetName == ''" type="warning">{{ '未分配' }}</el-tag> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="useStartTime" label="使用开始日期" show-overflow-tooltip> |
| | | <template slot-scope="scope"> |
| | | {{ crud.toDate(scope.row.useStartTime) }} |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="useEndTime" label="使用结束时间" show-overflow-tooltip> |
| | | <template slot-scope="scope"> |
| | | {{ crud.toDate(scope.row.useEndTime) }} |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="remarks" label="备注" show-overflow-tooltip /> |
| | | <el-table-column prop="createTime" label="创建时间" show-overflow-tooltip /> |
| | | <el-table-column v-if="checkPer(['admin','assetUseManagement:edit','assetUseManagement:del'])" label="操作" width="150px" align="center"> |
| | | <template slot-scope="scope"> |
| | | <udOperation |
| | | :data="scope.row" |
| | | :permission="permission" |
| | | /> |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | <!--分页组件--> |
| | | <pagination /> |
| | | </div> |
| | | </div> |
| | | </template> |
| | | |
| | | <script> |
| | | import crudAssetUseManagement from '@/api/assetManagement/assetUseManagement' |
| | | import crudAssetManagement from '@/api/assetManagement/assetManagement' |
| | | import crudMeetingRoom from '@/api/conferenceRoom/meetingRoom' |
| | | import crudUser from '@/api/system/user' |
| | | import CRUD, { presenter, header, form, crud } from '@crud/crud' |
| | | import rrOperation from '@crud/RR.operation' |
| | | import crudOperation from '@crud/CRUD.operation' |
| | | import udOperation from '@crud/UD.operation' |
| | | import pagination from '@crud/Pagination' |
| | | |
| | | const defaultForm = { id: null, assetId: null, userId: null, meetingId: null, useStartTime: null, useEndTime: null, remarks: null, createBy: null, createTime: null, updateBy: null, updateTime: null } |
| | | export default { |
| | | name: 'AssetUseManagement', |
| | | components: { pagination, crudOperation, rrOperation, udOperation }, |
| | | mixins: [presenter(), header(), form(defaultForm), crud()], |
| | | cruds() { |
| | | return CRUD({ title: '资产使用', url: 'api/assetUseManagement', idField: 'id', sort: 'id,desc', crudMethod: { ...crudAssetUseManagement }}) |
| | | }, |
| | | data() { |
| | | return { |
| | | permission: { |
| | | add: ['admin', 'assetUseManagement:add'], |
| | | edit: ['admin', 'assetUseManagement:edit'], |
| | | del: ['admin', 'assetUseManagement:del'], |
| | | download: ['admin', 'assetUseManagement:download'] |
| | | }, |
| | | rules: { |
| | | assetId: [ |
| | | { required: true, message: '资产不能为空', trigger: 'blur' } |
| | | ], |
| | | useStartTime: [ |
| | | { required: true, message: '使用开始时间不能为空', trigger: 'blur' } |
| | | ] |
| | | }, |
| | | users: [], |
| | | assetManagements: [], |
| | | meetingRooms: [] } |
| | | }, |
| | | methods: { |
| | | // 钩子:在获取表格数据之前执行,false 则代表不获取数据 |
| | | [CRUD.HOOK.beforeRefresh]() { |
| | | // 用户 |
| | | crudUser.getAll().then(res => { |
| | | this.users = res |
| | | }) |
| | | // 资产 |
| | | crudAssetManagement.getAll().then(res => { |
| | | this.assetManagements = res |
| | | }) |
| | | // 会议室 |
| | | crudMeetingRoom.getAll().then(res => { |
| | | this.meetingRooms = res |
| | | }) |
| | | console.log(this.$route.params.assetId) |
| | | // 判断传参是否为空 |
| | | if (this.$route.params.assetId != null && this.$route.params.assetId !== '' && this.crud.query.assetId === undefined) { |
| | | // 检索条件赋值 |
| | | this.$set(this.crud.query, 'assetId', Number(this.$route.params.assetId)) |
| | | } |
| | | return true |
| | | }, |
| | | // 钩子:提交之前 |
| | | [CRUD.HOOK.beforeSubmit]() { |
| | | if (this.form.userId === '' || this.form.userId === undefined) { |
| | | this.form.userId = null |
| | | } |
| | | if (this.form.meetingId === '' || this.form.meetingId === undefined) { |
| | | this.form.meetingId = null |
| | | } |
| | | if (this.form.userId !== null && this.form.meetingId !== null) { |
| | | // 消息提示 |
| | | this.crud.notify('用户和会议室只能选择一个', CRUD.NOTIFICATION_TYPE.ERROR) |
| | | return false |
| | | } |
| | | if (this.form.userId == null && this.form.meetingId == null) { |
| | | // 消息提示 |
| | | this.crud.notify('用户和会议室必须选择一个', CRUD.NOTIFICATION_TYPE.ERROR) |
| | | return false |
| | | } |
| | | } |
| | | } |
| | | } |
| | | </script> |
| | | |
| | | <style scoped> |
| | | |
| | | </style> |
| New file |
| | |
| | | <template> |
| | | <div class="app-container"> |
| | | <!--工具栏--> |
| | | <div class="head-container"> |
| | | <div> |
| | | <el-input |
| | | v-model="query.number" |
| | | clearable |
| | | size="small" |
| | | placeholder="请输入编号" |
| | | style="width: 200px;" |
| | | class="filter-item" |
| | | @keyup.enter.native="crud.toQuery" |
| | | /> |
| | | <el-input |
| | | v-model="query.name" |
| | | clearable |
| | | size="small" |
| | | placeholder="请输入名称" |
| | | style="width: 200px;" |
| | | class="filter-item" |
| | | @keyup.enter.native="crud.toQuery" |
| | | /> |
| | | <el-select v-model="query.affiliatedCompany" filterable clearable placeholder="请选择公司" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery"> |
| | | <el-option |
| | | v-for="item in companyList" |
| | | :key="item.id" |
| | | :label="item.label" |
| | | :value="item.value" |
| | | /> |
| | | </el-select> |
| | | <el-select v-model="query.state" filterable clearable placeholder="请选择使用状态" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery"> |
| | | <el-option |
| | | v-for="item in dict[dictAccteUse]" |
| | | :key="item.value" |
| | | :label="item.label" |
| | | :value="item.value" |
| | | /> |
| | | </el-select> |
| | | <rrOperation /> |
| | | </div> |
| | | <!--如果想在工具栏加入更多按钮,可以使用插槽方式, slot = 'left' or 'right'--> |
| | | <crudOperation :permission="permission"> |
| | | <el-button |
| | | slot="right" |
| | | class="filter-item" |
| | | size="mini" |
| | | type="primary" |
| | | icon="el-icon-view" |
| | | :disabled="crud.selections.length !== 1" |
| | | style="margin-left: 4px !important;" |
| | | @click="toAssetUseManagement(crud.selections[0])" |
| | | > |
| | | 查看资产使用管理 |
| | | </el-button> |
| | | <el-button |
| | | slot="right" |
| | | class="filter-item" |
| | | size="mini" |
| | | type="primary" |
| | | icon="el-icon-share" |
| | | :disabled="crud.selections.length !== 1" |
| | | @click="toDivide(crud.selections[0])" |
| | | > |
| | | 分配资产使用 |
| | | </el-button> |
| | | </crudOperation> |
| | | <!--表单组件--> |
| | | <el-dialog :close-on-click-modal="false" :before-close="crud.cancelCU" :visible.sync="crud.status.cu > 0" :title="crud.status.title" width="500px"> |
| | | <el-form ref="form" :model="form" :rules="rules" size="small" label-width="80px"> |
| | | <el-form-item label="编号" prop="number"> |
| | | <el-input v-model="form.number" style="width: 370px;" /> |
| | | </el-form-item> |
| | | <el-form-item label="名称" prop="name"> |
| | | <el-input v-model="form.name" style="width: 370px;" /> |
| | | </el-form-item> |
| | | <el-form-item label="型号"> |
| | | <el-input v-model="form.typeNumber" style="width: 370px;" /> |
| | | </el-form-item> |
| | | <el-form-item label="资产类型" prop="assetsType"> |
| | | <el-select v-model="form.assetsType" clearable style="width: 370px;"> |
| | | <el-option |
| | | v-for="item in dict[dictAccetType]" |
| | | :key="item.value" |
| | | :label="item.label" |
| | | :value="item.value" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="购买日期"> |
| | | <el-date-picker |
| | | v-model="form.buyDate" |
| | | type="datetime" |
| | | placeholder="选择日期时间" |
| | | style="width: 370px;" |
| | | value-format="yyyy-MM-dd HH:mm:ss" |
| | | align="right" |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item label="购买金额" prop="buyMoney"> |
| | | <money-input :key="random" v-model="form.buyMoney" :width="370" /> |
| | | </el-form-item> |
| | | <el-form-item label="所属公司" prop="affiliatedCompany"> |
| | | <el-select v-model="form.affiliatedCompany" style="width: 370px" clearable> |
| | | <el-option v-for="item in companyList" :key="item.id" :label="item.label" :value="item.value" /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="使用状态" prop="state"> |
| | | <el-select v-model="form.state" clearable style="width: 370px;"> |
| | | <el-option |
| | | v-for="item in dict[dictAccteUse]" |
| | | :key="item.value" |
| | | :label="item.label" |
| | | :value="item.value" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="备注"> |
| | | <el-input v-model="form.remarks" type="textarea" rows="3" style="width: 370px;" /> |
| | | </el-form-item> |
| | | </el-form> |
| | | <div slot="footer" class="dialog-footer"> |
| | | <el-button type="text" @click="crud.cancelCU">取消</el-button> |
| | | <el-button :loading="crud.status.cu === 2" type="primary" @click="crud.submitCU">确认</el-button> |
| | | </div> |
| | | </el-dialog> |
| | | <!-- 资产使用 --> |
| | | <el-dialog :close-on-click-modal="false" :before-close="divideClose" :visible.sync="divideStatus" :title="crudStatusTitle" width="500px"> |
| | | <el-form ref="assUserManagementForm" :model="assUserManagementForm" :rules="rules" size="small" label-width="110px"> |
| | | <el-form-item label="编号:"> |
| | | <el-tag>{{ assUserManagementForm.number }}</el-tag> |
| | | </el-form-item> |
| | | <el-form-item label="名称:"> |
| | | <el-tag>{{ assUserManagementForm.name }}</el-tag> |
| | | </el-form-item> |
| | | <el-form-item label="员工"> |
| | | <el-select v-model="assUserManagementForm.userId" filterable clearable placeholder="请选择" style="width: 330px;"> |
| | | <el-option |
| | | v-for="item in users" |
| | | :key="item.id" |
| | | :label="item.nickName" |
| | | :value="item.id" |
| | | :disabled="!item.enabled" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="会议室"> |
| | | <el-select v-model="assUserManagementForm.meetingId" filterable clearable placeholder="请选择" style="width: 330px;"> |
| | | <el-option |
| | | v-for="item in meetingRooms" |
| | | :key="item.id" |
| | | :label="item.conferenceRoomName" |
| | | :value="item.id" |
| | | /> |
| | | </el-select> |
| | | </el-form-item> |
| | | <el-form-item label="使用开始日期" prop="useStartTime"> |
| | | <el-date-picker |
| | | v-model="assUserManagementForm.useStartTime" |
| | | type="date" |
| | | placeholder="选择日期时间" |
| | | style="width: 330px;" |
| | | value-format="yyyy-MM-dd" |
| | | align="right" |
| | | :picker-options="{ |
| | | disabledDate(time) { |
| | | return assUserManagementForm.useEndTime ? time.getTime() > new Date(assUserManagementForm.useEndTime).getTime() - 8.64e7 : false; |
| | | } |
| | | }" |
| | | /> |
| | | </el-form-item> |
| | | <el-form-item label="使用结束时间"> |
| | | <el-date-picker |
| | | v-model="assUserManagementForm.useEndTime" |
| | | type="date" |
| | | placeholder="选择日期时间" |
| | | style="width: 330px;" |
| | | value-format="yyyy-MM-dd" |
| | | align="right" |
| | | :picker-options="{ |
| | | disabledDate(time) { |
| | | return assUserManagementForm.useStartTime ? time.getTime() < new Date(assUserManagementForm.useStartTime).getTime() - 8.64e7 : false; |
| | | } |
| | | }" |
| | | /> |
| | | </el-form-item> |
| | | </el-form> |
| | | <div slot="footer" class="dialog-footer"> |
| | | <el-button type="text" @click="divideClose">取消</el-button> |
| | | <el-button :loading="divideLoading" type="primary" @click="divideSubmit">确认</el-button> |
| | | </div> |
| | | </el-dialog> |
| | | <!--表格渲染--> |
| | | <el-table ref="table" v-loading="crud.loading" :data="crud.data" size="small" style="width: 100%;" @selection-change="crud.selectionChangeHandler"> |
| | | <el-table-column type="selection" width="55" /> |
| | | <el-table-column prop="number" label="编号" show-overflow-tooltip> |
| | | <template slot-scope="scope"> |
| | | <el-tag> |
| | | {{ scope.row.number }} |
| | | </el-tag> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="name" label="名称" show-overflow-tooltip> |
| | | <template slot-scope="scope"> |
| | | <el-tag> |
| | | {{ scope.row.name }} |
| | | </el-tag> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="typeNumber" label="型号" show-overflow-tooltip /> |
| | | <el-table-column prop="assetsType" label="资产类型" show-overflow-tooltip> |
| | | <template slot-scope="scope"> |
| | | {{ dict.label[dictAccetType][scope.row.assetsType] }} |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="buyDate" label="购买日期" show-overflow-tooltip /> |
| | | <el-table-column prop="buyMoney" label="购买金额" show-overflow-tooltip> |
| | | <template slot-scope="scope"> |
| | | {{ crud.toMoney(scope.row.buyMoney) }} |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="affiliatedCompany" label="所属公司" show-overflow-tooltip> |
| | | <template slot-scope="scope"> |
| | | <template v-for="item in companyList"> |
| | | <span v-if="scope.row.affiliatedCompany == item.value" :key="item.id">{{ item.label }}</span> |
| | | </template> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="state" label="使用状态" show-overflow-tooltip> |
| | | <template slot-scope="scope"> |
| | | <el-tag v-if="scope.row.state === dictOnStart">{{ dict.label[dictAccteUse][scope.row.state] }}</el-tag> |
| | | <el-tag v-if="scope.row.state === dictOffStart" type="danger">{{ dict.label[dictAccteUse][scope.row.state] }}</el-tag> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="remarks" label="备注" /> |
| | | <el-table-column prop="createTime" label="创建时间" /> |
| | | <el-table-column v-if="checkPer(['admin','assetManagement:edit','assetManagement:del'])" label="操作" width="150px" align="center"> |
| | | <template slot-scope="scope"> |
| | | <udOperation |
| | | :data="scope.row" |
| | | :permission="permission" |
| | | /> |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | <!--分页组件--> |
| | | <pagination /> |
| | | </div> |
| | | </div> |
| | | </template> |
| | | |
| | | <script> |
| | | import crudAssetManagement from '@/api/assetManagement/assetManagement' |
| | | import crudSysUserCompany from '@/api/system/sysUserCompany' |
| | | import crudUser from '@/api/system/user' |
| | | import crudMeetingRoom from '@/api/conferenceRoom/meetingRoom' |
| | | import CRUD, { presenter, header, form, crud } from '@crud/crud' |
| | | import rrOperation from '@crud/RR.operation' |
| | | import crudOperation from '@crud/CRUD.operation' |
| | | import udOperation from '@crud/UD.operation' |
| | | import pagination from '@crud/Pagination' |
| | | import constant from '@/utils/constant' |
| | | import moneyInput from '../../assembly/moneyInput/index.vue' |
| | | |
| | | const defaultForm = { id: null, number: null, name: null, typeNumber: null, assetsType: null, buyDate: null, buyMoney: null, affiliatedCompany: null, state: null, remarks: null, createBy: null, createTime: null, updateBy: null, updateTime: null } |
| | | export default { |
| | | name: 'AssetManagement', |
| | | components: { pagination, crudOperation, rrOperation, udOperation, moneyInput }, |
| | | mixins: [presenter(), header(), form(defaultForm), crud()], |
| | | // 数据字典 |
| | | dicts: [constant.ACCET_TYPE, constant.ACCETS_USE], |
| | | cruds() { |
| | | return CRUD({ title: '资产记录', url: 'api/assetManagement', idField: 'id', sort: 'id,desc', crudMethod: { ...crudAssetManagement }}) |
| | | }, |
| | | data() { |
| | | // (千万内)验证 |
| | | var wageValidate = (rule, value, callback) => { |
| | | if (value != null && value !== '' && (isNaN(value) || Number(value) < 0 || Number(value) > 10000000)) { |
| | | callback(new Error('请输入 一千万 以内的正整数或两位小数')) |
| | | } else { |
| | | callback() |
| | | } |
| | | } |
| | | return { |
| | | permission: { |
| | | add: ['admin', 'assetManagement:add'], |
| | | edit: ['admin', 'assetManagement:edit'], |
| | | del: ['admin', 'assetManagement:del'], |
| | | download: ['admin', 'assetManagement:download'] |
| | | }, |
| | | rules: { |
| | | number: [ |
| | | { required: true, message: '编号不能为空', trigger: 'blur' } |
| | | ], |
| | | name: [ |
| | | { required: true, message: '名称不能为空', trigger: 'blur' } |
| | | ], |
| | | assetsType: [ |
| | | { required: true, message: '资产类型不能为空', trigger: 'change' } |
| | | ], |
| | | affiliatedCompany: [ |
| | | { required: true, message: '所属公司不能为空', trigger: 'change' } |
| | | ], |
| | | state: [ |
| | | { required: true, message: '使用状态不能为空', trigger: 'change' } |
| | | ], |
| | | useStartTime: [ |
| | | { required: true, message: '使用开始时间不能为空', trigger: 'change' } |
| | | ], |
| | | buyMoney: [ |
| | | { validator: wageValidate, trigger: 'blur' } |
| | | ] |
| | | }, |
| | | dictAccetType: constant.ACCET_TYPE, |
| | | companyList: [], |
| | | dictAccteUse: constant.ACCETS_USE, |
| | | dictOnStart: constant.ACCETS_USE_IN, |
| | | dictOffStart: constant.ACCETS_USE_STOP, |
| | | random: 0, |
| | | assUserManagementForm: { assetId: null, userId: null, meetingId: null, useStartTime: null, useEndTime: null, number: null, name: null, divideUserIds: [] }, |
| | | divideStatus: false, |
| | | divideLoading: false, |
| | | users: [], |
| | | meetingRooms: [], |
| | | crudStatusTitle: '分配资产', |
| | | assetUseManagements: [] |
| | | } |
| | | }, |
| | | methods: { |
| | | // 钩子:在获取表格数据之前执行,false 则代表不获取数据 |
| | | [CRUD.HOOK.beforeRefresh]() { |
| | | // 查询配置参数 |
| | | crudSysUserCompany.getAll().then(res => { |
| | | // 公司列表 |
| | | this.companyList = res |
| | | }) |
| | | // 用户 |
| | | crudUser.getAll().then(res => { |
| | | this.users = res |
| | | }) |
| | | // 会议室 |
| | | crudMeetingRoom.getAll().then(res => { |
| | | this.meetingRooms = res |
| | | }) |
| | | return true |
| | | }, |
| | | // 钩子: 在新增前执行 |
| | | [CRUD.HOOK.beforeToCU]() { |
| | | // 随机数 |
| | | this.random = Math.random() |
| | | }, |
| | | // 查看资产使用管理 |
| | | toAssetUseManagement(data) { |
| | | console.log(data) |
| | | // 跳转页面 |
| | | this.$router.push({ |
| | | name: 'assetUseManagement', |
| | | params: { |
| | | assetId: data.id |
| | | } |
| | | }) |
| | | }, |
| | | // 分配资产使用 |
| | | toDivide(data) { |
| | | if (data.state === this.dictOffStart) { |
| | | this.crud.notify('使用状态已停止,无法分配', CRUD.NOTIFICATION_TYPE.ERROR) |
| | | } else { |
| | | this.assUserManagementForm.assetId = data.id |
| | | this.assUserManagementForm.userId = data.userId |
| | | this.assUserManagementForm.number = data.number |
| | | this.assUserManagementForm.name = data.name |
| | | this.divideStatus = true |
| | | } |
| | | }, |
| | | // 分配表单提交 |
| | | divideSubmit() { |
| | | if (this.assUserManagementForm.userId === '' || this.assUserManagementForm.userId === undefined) { |
| | | this.assUserManagementForm.userId = null |
| | | } |
| | | if (this.assUserManagementForm.meetingId === '' || this.assUserManagementForm.meetingId === undefined) { |
| | | this.assUserManagementForm.meetingId = null |
| | | } |
| | | if (this.assUserManagementForm.userId !== null && this.assUserManagementForm.meetingId != null) { |
| | | // 消息提示 |
| | | this.crud.notify('用户和会议室只能选择一个', CRUD.NOTIFICATION_TYPE.ERROR) |
| | | return |
| | | } |
| | | if (this.assUserManagementForm.userId == null && this.assUserManagementForm.meetingId == null) { |
| | | // 消息提示 |
| | | this.crud.notify('用户和会议室必须选择一个', CRUD.NOTIFICATION_TYPE.ERROR) |
| | | return |
| | | } |
| | | // 分配表单加载 |
| | | this.divideLoading = true |
| | | // 表单验证 |
| | | this.$refs['assUserManagementForm'].validate((valid) => { |
| | | if (valid) { |
| | | // 分配任务 |
| | | crudAssetManagement.divide(this.assUserManagementForm).then(res => { |
| | | // 分配表单关闭 |
| | | this.divideClose() |
| | | // 消息提示 |
| | | this.crud.notify('资产分配成功', CRUD.NOTIFICATION_TYPE.SUCCESS) |
| | | // 刷新页面 |
| | | this.crud.refresh() |
| | | }) |
| | | this.divideLoading = false |
| | | } else { |
| | | // 分配表单加载 |
| | | this.divideLoading = false |
| | | return false |
| | | } |
| | | }) |
| | | }, |
| | | // 分配表单关闭 |
| | | divideClose() { |
| | | // 分配表单状态 |
| | | this.divideStatus = false |
| | | // 分配表单加载 |
| | | this.divideLoading = false |
| | | // 清除表单验证 |
| | | this.$nextTick(() => { |
| | | this.$refs['assUserManagementForm'].clearValidate() |
| | | }) |
| | | } |
| | | } |
| | | } |
| | | </script> |
| | | |
| | | <style scoped> |
| | | |
| | | </style> |
| New file |
| | |
| | | <template> |
| | | <div class="app-container"> |
| | | <!--工具栏--> |
| | | <div class="head-container"> |
| | | <div> |
| | | <el-input |
| | | v-model="query.conferenceRoomName" |
| | | clearable |
| | | size="small" |
| | | placeholder="请输入会议室名称" |
| | | style="width: 200px;" |
| | | class="filter-item" |
| | | @keyup.enter.native="crud.toQuery" |
| | | /> |
| | | <rrOperation /> |
| | | </div> |
| | | <!--如果想在工具栏加入更多按钮,可以使用插槽方式, slot = 'left' or 'right'--> |
| | | <crudOperation :permission="permission" /> |
| | | <!--表单组件--> |
| | | <el-dialog :close-on-click-modal="false" :before-close="crud.cancelCU" :visible.sync="crud.status.cu > 0" :title="crud.status.title" width="500px"> |
| | | <el-form ref="form" :model="form" :rules="rules" size="small" label-width="95px"> |
| | | <el-form-item label="会议室名称" prop="conferenceRoomName"> |
| | | <el-input v-model="form.conferenceRoomName" style="width: 365px;" /> |
| | | </el-form-item> |
| | | <el-form-item label="会议室地址"> |
| | | <el-input v-model="form.conferenceRoomAddress" style="width: 365px;" /> |
| | | </el-form-item> |
| | | <el-form-item label="容纳人数"> |
| | | <el-input v-model="form.capacity" style="width: 365px;" /> |
| | | </el-form-item> |
| | | <el-form-item label="备注"> |
| | | <el-input v-model="form.remarks" style="width: 365px;" /> |
| | | </el-form-item> |
| | | </el-form> |
| | | <div slot="footer" class="dialog-footer"> |
| | | <el-button type="text" @click="crud.cancelCU">取消</el-button> |
| | | <el-button :loading="crud.status.cu === 2" type="primary" @click="crud.submitCU">确认</el-button> |
| | | </div> |
| | | </el-dialog> |
| | | <!--表格渲染--> |
| | | <el-table ref="table" v-loading="crud.loading" :data="crud.data" size="small" style="width: 100%;" @selection-change="crud.selectionChangeHandler"> |
| | | <el-table-column type="selection" width="55" /> |
| | | <el-table-column prop="conferenceRoomName" label="会议室名称" show-overflow-tooltip> |
| | | <template slot-scope="scope"> |
| | | <el-tag>{{ scope.row.conferenceRoomName }}</el-tag> |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="conferenceRoomAddress" label="会议室地址" show-overflow-tooltip /> |
| | | <el-table-column prop="snum" label="设备" show-overflow-tooltip> |
| | | <template slot-scope="scope"> |
| | | {{ getEquipment(scope.row.snum) }} |
| | | </template> |
| | | </el-table-column> |
| | | <el-table-column prop="capacity" label="容纳人数" show-overflow-tooltip /> |
| | | <el-table-column prop="remarks" label="备注" show-overflow-tooltip /> |
| | | <el-table-column prop="createTime" label="创建时间" show-overflow-tooltip /> |
| | | <el-table-column v-if="checkPer(['admin','meetingRoom:edit','meetingRoom:del'])" label="操作" width="150px" align="center"> |
| | | <template slot-scope="scope"> |
| | | <udOperation |
| | | :data="scope.row" |
| | | :permission="permission" |
| | | /> |
| | | </template> |
| | | </el-table-column> |
| | | </el-table> |
| | | <!--分页组件--> |
| | | <pagination /> |
| | | </div> |
| | | </div> |
| | | </template> |
| | | |
| | | <script> |
| | | import crudMeetingRoom from '@/api/conferenceRoom/meetingRoom' |
| | | import CRUD, { presenter, header, form, crud } from '@crud/crud' |
| | | import rrOperation from '@crud/RR.operation' |
| | | import crudOperation from '@crud/CRUD.operation' |
| | | import udOperation from '@crud/UD.operation' |
| | | import pagination from '@crud/Pagination' |
| | | |
| | | const defaultForm = { id: null, conferenceRoomName: null, conferenceRoomAddress: null, capacity: null, remarks: null, createBy: null, createTime: null, updateBy: null, updateTime: null } |
| | | export default { |
| | | name: 'MeetingRoom', |
| | | components: { pagination, crudOperation, rrOperation, udOperation }, |
| | | mixins: [presenter(), header(), form(defaultForm), crud()], |
| | | cruds() { |
| | | return CRUD({ title: '会议室信息', url: 'api/meetingRoom', idField: 'id', sort: 'id,desc', crudMethod: { ...crudMeetingRoom }}) |
| | | }, |
| | | data() { |
| | | return { |
| | | permission: { |
| | | add: ['admin', 'meetingRoom:add'], |
| | | edit: ['admin', 'meetingRoom:edit'], |
| | | del: ['admin', 'meetingRoom:del'], |
| | | download: ['admin', 'meetingRoom:download'] |
| | | }, |
| | | rules: { |
| | | id: [ |
| | | { required: true, message: '不能为空', trigger: 'blur' } |
| | | ], |
| | | conferenceRoomName: [ |
| | | { required: true, message: '会议室名称不能为空', trigger: 'blur' } |
| | | ], |
| | | createBy: [ |
| | | { required: true, message: '创建者不能为空', trigger: 'blur' } |
| | | ], |
| | | createTime: [ |
| | | { required: true, message: '创建时间不能为空', trigger: 'blur' } |
| | | ] |
| | | }} |
| | | }, |
| | | methods: { |
| | | // 钩子:在获取表格数据之前执行,false 则代表不获取数据 |
| | | [CRUD.HOOK.beforeRefresh]() { |
| | | return true |
| | | }, |
| | | // 获取设备 |
| | | getEquipment(data) { |
| | | const assList = [] |
| | | data.forEach(element => { |
| | | assList.push(element) |
| | | }) |
| | | const name = '"' + assList + '"' |
| | | const name1 = name.substring(1, name.length - 1) |
| | | return name1 |
| | | } |
| | | } |
| | | } |
| | | </script> |
| | | |
| | | <style scoped> |
| | | |
| | | </style> |