From b5c1bffef34b16bf8a7bcdecc0cfc89b6edf8423 Mon Sep 17 00:00:00 2001 From: xiao-fajia <1665375861@qq.com> Date: Sat, 17 Aug 2024 20:30:02 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B5=84=E4=BA=A7=E7=AE=A1=E7=90=8690%?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/admin/CompanyController.java | 13 +++ .../admin/PropertyDealController.java | 74 +++---------- .../admin/PropertyDealItemController.java | 102 ++++++++---------- .../admin/PropertyPosController.java | 13 +++ .../module/property/entity/Property.java | 4 + .../mapper/PropertyDealItemMapper.java | 8 ++ .../service/PropertyDealItemService.java | 52 ++++----- .../property/service/PropertyDealService.java | 37 ++----- .../impl/PropertyDealItemServiceImpl.java | 78 ++++++++++---- .../service/impl/PropertyDealServiceImpl.java | 86 +++++++++++---- .../admin/CompanyStaffController.java | 30 ++++++ .../property/PropertyDealItemMapper.xml | 12 ++- 12 files changed, 286 insertions(+), 223 deletions(-) diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/module/company/controller/admin/CompanyController.java b/dl-module-base/src/main/java/cn/iocoder/yudao/module/company/controller/admin/CompanyController.java index f8f29c07..f27c6dbd 100644 --- a/dl-module-base/src/main/java/cn/iocoder/yudao/module/company/controller/admin/CompanyController.java +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/module/company/controller/admin/CompanyController.java @@ -147,4 +147,17 @@ public class CompanyController { columnWidthMap.put(10, 20); ExcelUtils.write(response, "企业信息表.xls", "数据", Company.class, list,columnWidthMap); } + + /** + * 获得企业信息表(每个租户的下属企业信息) + * @author 小李 + * @date 16:50 2024/8/17 + **/ + @GetMapping("/list") + @Operation(summary = "获得企业信息表(每个租户的下属企业信息)") + @Parameter(name = "id", description = "编号", required = true, example = "1024") + @PreAuthorize("@ss.hasPermission('company:property-deal:query')") + public CommonResult> getCompanyList(){ + return success(companyService.list()); + } } \ No newline at end of file diff --git a/dl-module-company/src/main/java/cn/iocoder/yudao/module/property/controller/admin/PropertyDealController.java b/dl-module-company/src/main/java/cn/iocoder/yudao/module/property/controller/admin/PropertyDealController.java index 19d3d569..5eaee881 100644 --- a/dl-module-company/src/main/java/cn/iocoder/yudao/module/property/controller/admin/PropertyDealController.java +++ b/dl-module-company/src/main/java/cn/iocoder/yudao/module/property/controller/admin/PropertyDealController.java @@ -30,74 +30,30 @@ public class PropertyDealController { private PropertyDealService propertyDealService; /** - * 创建企业管理-资产处置单/变动单 + * 创建企业管理-资产处置单 * @author 小李 * @date 21:24 2024/8/16 * @param createReqVO 提交对象 **/ @PostMapping("/create") - @Operation(summary = "创建企业管理-资产处置单/变动单") + @Operation(summary = "创建企业管理-资产处置单") @PreAuthorize("@ss.hasPermission('company:property-deal:create')") public CommonResult createPropertyDeal(@RequestBody PropertyDealRespVO createReqVO) { propertyDealService.createPropertyDeal(createReqVO); return CommonResult.ok(); } -// @GetMapping("/page") -// @Operation(summary = "获得企业管理-资产处置单/变动单分页") -// @PreAuthorize("@ss.hasPermission('company:property-deal:query')") -// public CommonResult> getPropertyDealPage(PropertyDealReqVO pageReqVO, -// @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, -// @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) { -// return null; -// IPage propertyDealPage = propertyDealService.getPropertyDealPage(pageReqVO); -// return success(propertyDealPage); -// } - -// @PutMapping("/update") -// @Operation(summary = "更新企业管理-资产处置单/变动单") -// @PreAuthorize("@ss.hasPermission('company:property-deal:update')") -// public CommonResult updatePropertyDeal(@RequestBody PropertyDealReqVO updateReqVO) { -// propertyDealService.updatePropertyDeal(updateReqVO); -// return success(true); -// } -// -// @DeleteMapping("/delete") -// @Operation(summary = "删除企业管理-资产处置单/变动单") -// @Parameter(name = "id", description = "编号", required = true) -// @PreAuthorize("@ss.hasPermission('company:property-deal:delete')") -// public CommonResult deletePropertyDeal(@RequestParam("id") String id) { -// propertyDealService.deletePropertyDeal(id); -// return success(true); -// } -// -// @GetMapping("/get") -// @Operation(summary = "获得企业管理-资产处置单/变动单") -// @Parameter(name = "id", description = "编号", required = true, example = "1024") -// @PreAuthorize("@ss.hasPermission('company:property-deal:query')") -// public CommonResult getPropertyDeal(@RequestParam("id") String id) { -// PropertyDeal propertyDeal = propertyDealService.getPropertyDeal(id); -// return success(BeanUtils.toBean(propertyDeal, PropertyDealRespVO.class)); -// } -// -// @GetMapping("/page") -// @Operation(summary = "获得企业管理-资产处置单/变动单分页") -// @PreAuthorize("@ss.hasPermission('company:property-deal:query')") -// public CommonResult> getPropertyDealPage(PropertyDealReqVO pageReqVO) { -// IPage propertyDealPage = propertyDealService.getPropertyDealPage(pageReqVO); -// return success(propertyDealPage); -// } -// -// @GetMapping("/export-excel") -// @Operation(summary = "导出企业管理-资产处置单/变动单 Excel") -// @PreAuthorize("@ss.hasPermission('company:property-deal:export')") -// @ApiAccessLog(operateType = EXPORT) -// public void exportPropertyDealExcel(PropertyDealReqVO pageReqVO, -// HttpServletResponse response) throws IOException { -// pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); -// List list = propertyDealService.getPropertyDealPage(pageReqVO).getRecords(); -// // 导出 Excel -// ExcelUtils.write(response, "企业管理-资产处置单/变动单.xls", "数据", PropertyDealRespVO.class,list); -// } - + /** + * 创建企业管理-资产变动单 + * @author 小李 + * @date 21:24 2024/8/16 + * @param createReqVO 提交对象 + **/ + @PostMapping("/createChange") + @Operation(summary = "创建企业管理-资产变动单") + @PreAuthorize("@ss.hasPermission('company:property-deal:create')") + public CommonResult createPropertyDealChange(@RequestBody PropertyDealRespVO createReqVO) { + propertyDealService.createPropertyDealChange(createReqVO); + return CommonResult.ok(); + } } \ No newline at end of file diff --git a/dl-module-company/src/main/java/cn/iocoder/yudao/module/property/controller/admin/PropertyDealItemController.java b/dl-module-company/src/main/java/cn/iocoder/yudao/module/property/controller/admin/PropertyDealItemController.java index 8346842b..65f82247 100644 --- a/dl-module-company/src/main/java/cn/iocoder/yudao/module/property/controller/admin/PropertyDealItemController.java +++ b/dl-module-company/src/main/java/cn/iocoder/yudao/module/property/controller/admin/PropertyDealItemController.java @@ -3,18 +3,17 @@ package cn.iocoder.yudao.module.property.controller.admin; import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.module.property.entity.PropertyDeal; import cn.iocoder.yudao.module.property.service.PropertyDealItemService; +import cn.iocoder.yudao.module.property.vo.PropertyDealItemReqVO; import cn.iocoder.yudao.module.property.vo.PropertyDealItemRespVO; import cn.iocoder.yudao.module.property.vo.PropertyDealReqVO; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; import io.swagger.v3.oas.annotations.tags.Tag; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestParam; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; @@ -52,57 +51,48 @@ public class PropertyDealItemController { return success(propertyDealItemService.getPropertyDealItemPage(pageReqVO, page)); } -// @PostMapping("/create") -// @Operation(summary = "创建企业管理-资产处置子") -// @PreAuthorize("@ss.hasPermission('company:property-deal-item:create')") -// public CommonResult createPropertyDealItem(@RequestBody PropertyDealItemReqVO createReqVO) { -// return success(propertyDealItemService.createPropertyDealItem(createReqVO)); -// } -// -// @PutMapping("/update") -// @Operation(summary = "更新企业管理-资产处置子") -// @PreAuthorize("@ss.hasPermission('company:property-deal-item:update')") -// public CommonResult updatePropertyDealItem(@RequestBody PropertyDealItemReqVO updateReqVO) { -// propertyDealItemService.updatePropertyDealItem(updateReqVO); -// return success(true); -// } -// -// @DeleteMapping("/delete") -// @Operation(summary = "删除企业管理-资产处置子") -// @Parameter(name = "id", description = "编号", required = true) -// @PreAuthorize("@ss.hasPermission('company:property-deal-item:delete')") -// public CommonResult deletePropertyDealItem(@RequestParam("id") String id) { -// propertyDealItemService.deletePropertyDealItem(id); -// return success(true); -// } -// -// @GetMapping("/get") -// @Operation(summary = "获得企业管理-资产处置子") -// @Parameter(name = "id", description = "编号", required = true, example = "1024") -// @PreAuthorize("@ss.hasPermission('company:property-deal-item:query')") -// public CommonResult getPropertyDealItem(@RequestParam("id") String id) { -// PropertyDealItem propertyDealItem = propertyDealItemService.getPropertyDealItem(id); -// return success(BeanUtils.toBean(propertyDealItem, PropertyDealItemRespVO.class)); -// } -// -// @GetMapping("/page") -// @Operation(summary = "获得企业管理-资产处置子分页") -// @PreAuthorize("@ss.hasPermission('company:property-deal-item:query')") -// public CommonResult> getPropertyDealItemPage(PropertyDealItemReqVO pageReqVO) { -// IPage propertyDealItemPage = propertyDealItemService.getPropertyDealItemPage(pageReqVO); -// return success(propertyDealItemPage); -// } -// -// @GetMapping("/export-excel") -// @Operation(summary = "导出企业管理-资产处置子 Excel") -// @PreAuthorize("@ss.hasPermission('company:property-deal-item:export')") -// @ApiAccessLog(operateType = EXPORT) -// public void exportPropertyDealItemExcel(PropertyDealItemReqVO pageReqVO, -// HttpServletResponse response) throws IOException { -// pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); -// List list = propertyDealItemService.getPropertyDealItemPage(pageReqVO).getRecords(); -// // 导出 Excel -// ExcelUtils.write(response, "企业管理-资产处置子.xls", "数据", PropertyDealItemRespVO.class,list); -// } + /** + * 获得企业管理-资产处置子表 + * + * @param id 记录ID + * @author 小李 + * @date 10:20 2024/8/17 + **/ + @GetMapping("/get") + @Operation(summary = "获得企业管理-资产处置子表") + @Parameter(name = "id", description = "编号", required = true, example = "1024") + @PreAuthorize("@ss.hasPermission('company:property-deal:query')") + public CommonResult getPropertyDealItem(@RequestParam("id") String id) { + return success(propertyDealItemService.getPropertyDealItem(id)); + } + /** + * 更新企业管理-资产处置子表 + * + * @param updateReqVO 更新对象 + * @author 小李 + * @date 14:05 2024/8/17 + **/ + @PutMapping("/update") + @Operation(summary = "更新企业管理-资产处置子表") + @PreAuthorize("@ss.hasPermission('company:property-deal:update')") + public CommonResult updatePropertyDealItem(@RequestBody PropertyDealItemReqVO updateReqVO) { + propertyDealItemService.updatePropertyDealItem(updateReqVO); + return CommonResult.ok(); + } + + /** + * 删除企业管理-资产处置子表 + * @author 小李 + * @date 14:55 2024/8/17 + * @param id 记录 + **/ + @DeleteMapping("/delete") + @Operation(summary = "删除企业管理-资产处置子表") + @Parameter(name = "id", description = "编号", required = true) + @PreAuthorize("@ss.hasPermission('company:property-deal:delete')") + public CommonResult deletePropertyDealItem(@RequestParam("id") String id) { + propertyDealItemService.deletePropertyDealItem(id); + return CommonResult.ok(); + } } \ No newline at end of file diff --git a/dl-module-company/src/main/java/cn/iocoder/yudao/module/property/controller/admin/PropertyPosController.java b/dl-module-company/src/main/java/cn/iocoder/yudao/module/property/controller/admin/PropertyPosController.java index ca600ab0..6b3131d2 100644 --- a/dl-module-company/src/main/java/cn/iocoder/yudao/module/property/controller/admin/PropertyPosController.java +++ b/dl-module-company/src/main/java/cn/iocoder/yudao/module/property/controller/admin/PropertyPosController.java @@ -6,6 +6,7 @@ import cn.iocoder.yudao.module.property.entity.PropertyPos; import cn.iocoder.yudao.module.property.service.PropertyPosService; import cn.iocoder.yudao.module.property.vo.PropertyPosReqVO; import cn.iocoder.yudao.module.property.vo.PropertyPosRespVO; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import io.swagger.v3.oas.annotations.Operation; @@ -85,4 +86,16 @@ public class PropertyPosController { return success(propertyPosService.list()); } + /** + * 资产存放位置列表 分不同企业 + * @author 小李 + * @date 17:01 2024/8/17 + * @param id 企业ID + **/ + @GetMapping("/listByCorpId") + @Operation(summary = "获得企业管理-资产存放位置列表") + @PreAuthorize("@ss.hasPermission('company:property-deal:query')") + public CommonResult> getPositionByCorpId(String id){ + return success(propertyPosService.list(new LambdaQueryWrapper().eq(PropertyPos::getCorpId, id))); + } } \ No newline at end of file diff --git a/dl-module-company/src/main/java/cn/iocoder/yudao/module/property/entity/Property.java b/dl-module-company/src/main/java/cn/iocoder/yudao/module/property/entity/Property.java index ddd4f4ef..5ae576a9 100644 --- a/dl-module-company/src/main/java/cn/iocoder/yudao/module/property/entity/Property.java +++ b/dl-module-company/src/main/java/cn/iocoder/yudao/module/property/entity/Property.java @@ -168,4 +168,8 @@ public class Property extends TenantBaseDO { /** 处置方式 */ @TableField(exist = false) private String dealWay; + + /** 备注 */ + @TableField(exist = false) + private String remark; } \ No newline at end of file diff --git a/dl-module-company/src/main/java/cn/iocoder/yudao/module/property/mapper/PropertyDealItemMapper.java b/dl-module-company/src/main/java/cn/iocoder/yudao/module/property/mapper/PropertyDealItemMapper.java index ca1dd0e7..815f3b7e 100644 --- a/dl-module-company/src/main/java/cn/iocoder/yudao/module/property/mapper/PropertyDealItemMapper.java +++ b/dl-module-company/src/main/java/cn/iocoder/yudao/module/property/mapper/PropertyDealItemMapper.java @@ -20,4 +20,12 @@ import org.apache.ibatis.annotations.Param; public interface PropertyDealItemMapper extends BaseMapper { IPage getPropertyDealItemPage(@Param("map") PropertyDealReqVO pageReqVO, Page page); + + /** + * 获得企业管理-资产处置子表 + * @author 小李 + * @date 10:20 2024/8/17 + * @param id 记录ID + **/ + PropertyDealItemRespVO getPropertyDealItem(@Param("id") String id); } \ No newline at end of file diff --git a/dl-module-company/src/main/java/cn/iocoder/yudao/module/property/service/PropertyDealItemService.java b/dl-module-company/src/main/java/cn/iocoder/yudao/module/property/service/PropertyDealItemService.java index 42307eb2..d5a173c7 100644 --- a/dl-module-company/src/main/java/cn/iocoder/yudao/module/property/service/PropertyDealItemService.java +++ b/dl-module-company/src/main/java/cn/iocoder/yudao/module/property/service/PropertyDealItemService.java @@ -1,6 +1,5 @@ package cn.iocoder.yudao.module.property.service; -import cn.iocoder.yudao.module.property.entity.PropertyDeal; import cn.iocoder.yudao.module.property.entity.PropertyDealItem; import cn.iocoder.yudao.module.property.vo.PropertyDealItemReqVO; import cn.iocoder.yudao.module.property.vo.PropertyDealItemRespVO; @@ -26,34 +25,27 @@ public interface PropertyDealItemService extends IService { **/ IPage getPropertyDealItemPage(PropertyDealReqVO pageReqVO, Page page); -// /** -// * 更新企业管理-资产处置子 -// * -// * @param updateReqVO 更新信息 -// */ -// void updatePropertyDealItem(PropertyDealItemReqVO updateReqVO); -// -// /** -// * 删除企业管理-资产处置子 -// * -// * @param id 编号 -// */ -// void deletePropertyDealItem(String id); -// -// /** -// * 获得企业管理-资产处置子 -// * -// * @param id 编号 -// * @return 企业管理-资产处置子 -// */ -// PropertyDealItem getPropertyDealItem(String id); -// -// /** -// * 获得企业管理-资产处置子分页 -// * -// * @param pageReqVO 分页查询 -// * @return 企业管理-资产处置子分页 -// */ -// IPage getPropertyDealItemPage(PropertyDealItemReqVO pageReqVO); + /** + * 获得企业管理-资产处置子表 + * @author 小李 + * @date 10:20 2024/8/17 + * @param id 记录ID + **/ + PropertyDealItemRespVO getPropertyDealItem(String id); + /** + * 更新企业管理-资产处置子表 + * @author 小李 + * @date 14:05 2024/8/17 + * @param updateReqVO 更新对象 + **/ + void updatePropertyDealItem(PropertyDealItemReqVO updateReqVO); + + /** + * 删除企业管理-资产处置子表 + * @author 小李 + * @date 14:55 2024/8/17 + * @param id 记录 + **/ + void deletePropertyDealItem(String id); } \ No newline at end of file diff --git a/dl-module-company/src/main/java/cn/iocoder/yudao/module/property/service/PropertyDealService.java b/dl-module-company/src/main/java/cn/iocoder/yudao/module/property/service/PropertyDealService.java index 7511c169..fee19071 100644 --- a/dl-module-company/src/main/java/cn/iocoder/yudao/module/property/service/PropertyDealService.java +++ b/dl-module-company/src/main/java/cn/iocoder/yudao/module/property/service/PropertyDealService.java @@ -21,34 +21,11 @@ public interface PropertyDealService extends IService { **/ void createPropertyDeal(PropertyDealRespVO createReqVO); -// /** -// * 更新企业管理-资产处置单/变动单 -// * -// * @param updateReqVO 更新信息 -// */ -// void updatePropertyDeal(PropertyDealReqVO updateReqVO); -// -// /** -// * 删除企业管理-资产处置单/变动单 -// * -// * @param id 编号 -// */ -// void deletePropertyDeal(String id); -// -// /** -// * 获得企业管理-资产处置单/变动单 -// * -// * @param id 编号 -// * @return 企业管理-资产处置单/变动单 -// */ -// PropertyDeal getPropertyDeal(String id); -// -// /** -// * 获得企业管理-资产处置单/变动单分页 -// * -// * @param pageReqVO 分页查询 -// * @return 企业管理-资产处置单/变动单分页 -// */ -// IPage getPropertyDealPage(PropertyDealReqVO pageReqVO); - + /** + * 创建企业管理-资产变动单 + * @author 小李 + * @date 21:24 2024/8/16 + * @param createReqVO 提交对象 + **/ + void createPropertyDealChange(PropertyDealRespVO createReqVO); } \ No newline at end of file diff --git a/dl-module-company/src/main/java/cn/iocoder/yudao/module/property/service/impl/PropertyDealItemServiceImpl.java b/dl-module-company/src/main/java/cn/iocoder/yudao/module/property/service/impl/PropertyDealItemServiceImpl.java index a4279cc6..c3186caa 100644 --- a/dl-module-company/src/main/java/cn/iocoder/yudao/module/property/service/impl/PropertyDealItemServiceImpl.java +++ b/dl-module-company/src/main/java/cn/iocoder/yudao/module/property/service/impl/PropertyDealItemServiceImpl.java @@ -4,14 +4,22 @@ import cn.iocoder.yudao.module.property.entity.PropertyDeal; import cn.iocoder.yudao.module.property.entity.PropertyDealItem; import cn.iocoder.yudao.module.property.mapper.PropertyDealItemMapper; import cn.iocoder.yudao.module.property.service.PropertyDealItemService; +import cn.iocoder.yudao.module.property.service.PropertyDealService; +import cn.iocoder.yudao.module.property.vo.PropertyDealItemReqVO; import cn.iocoder.yudao.module.property.vo.PropertyDealItemRespVO; import cn.iocoder.yudao.module.property.vo.PropertyDealReqVO; +import com.baomidou.dynamic.datasource.annotation.DSTransactional; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.wechat.pay.java.service.certificate.model.Data; +import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; import org.springframework.validation.annotation.Validated; +import javax.annotation.Resource; + /** * 企业管理-资产处置子 Service 实现类 * @@ -22,6 +30,10 @@ import org.springframework.validation.annotation.Validated; @Validated public class PropertyDealItemServiceImpl extends ServiceImpl implements PropertyDealItemService { + @Resource + @Lazy // 解决循环依赖问题 + private PropertyDealService dealService; + /** * 获得企业管理-资产处置子表分页 * @@ -34,28 +46,48 @@ public class PropertyDealItemServiceImpl extends ServiceImpl getPropertyDealItemPage(PropertyDealItemReqVO pageReqVO) { -// return baseMapper.selectPage(pageReqVO); -// } + /** + * 获得企业管理-资产处置子表 + * @author 小李 + * @date 10:20 2024/8/17 + * @param id 记录ID + **/ + public PropertyDealItemRespVO getPropertyDealItem(String id){ + return baseMapper.getPropertyDealItem(id); + } + /** + * 更新企业管理-资产处置子表 + * @author 小李 + * @date 14:05 2024/8/17 + * @param updateReqVO 更新对象 + **/ + @Override + public void updatePropertyDealItem(PropertyDealItemReqVO updateReqVO){ + baseMapper.updateById(updateReqVO); + } + + /** + * 删除企业管理-资产处置子表 + * @author 小李 + * @date 14:55 2024/8/17 + * @param id 记录 + **/ + @Override + @DSTransactional + public void deletePropertyDealItem(String id){ + // 这里删除是删除子表的一条记录,所以要先去拿主表的记录,看看自己是不是最后一条,是的话主表也要删 + // 获取子表的详细信息 + PropertyDealItem dealItem = baseMapper.selectById(id); + // 获取主表的详细信息 + PropertyDeal deal = dealService.getById(dealItem.getDealId()); + // 反查统计子表相关联的数据的数量 + Long count = baseMapper.selectCount(new LambdaQueryWrapper().eq(PropertyDealItem::getDealId, deal.getId())); + // 如果减掉一条记录就没有记录了,就要删除主表 + if (count - 1L == 0){ + dealService.removeById(deal.getId()); + } + // 删除子表 + baseMapper.deleteById(id); + } } \ No newline at end of file diff --git a/dl-module-company/src/main/java/cn/iocoder/yudao/module/property/service/impl/PropertyDealServiceImpl.java b/dl-module-company/src/main/java/cn/iocoder/yudao/module/property/service/impl/PropertyDealServiceImpl.java index bdace3e7..d349d961 100644 --- a/dl-module-company/src/main/java/cn/iocoder/yudao/module/property/service/impl/PropertyDealServiceImpl.java +++ b/dl-module-company/src/main/java/cn/iocoder/yudao/module/property/service/impl/PropertyDealServiceImpl.java @@ -1,21 +1,26 @@ package cn.iocoder.yudao.module.property.service.impl; import cn.hutool.core.bean.BeanUtil; +import cn.hutool.core.util.ObjectUtil; import cn.iocoder.yudao.framework.common.util.object.BeanUtils; +import cn.iocoder.yudao.module.property.entity.Property; import cn.iocoder.yudao.module.property.entity.PropertyDeal; import cn.iocoder.yudao.module.property.entity.PropertyDealItem; import cn.iocoder.yudao.module.property.mapper.PropertyDealMapper; import cn.iocoder.yudao.module.property.service.PropertyDealItemService; import cn.iocoder.yudao.module.property.service.PropertyDealService; +import cn.iocoder.yudao.module.property.service.PropertyService; import cn.iocoder.yudao.module.property.vo.PropertyDealReqVO; import cn.iocoder.yudao.module.property.vo.PropertyDealRespVO; import com.baomidou.dynamic.datasource.annotation.DSTransactional; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; import org.springframework.validation.annotation.Validated; import javax.annotation.Resource; +import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; @@ -30,8 +35,13 @@ import java.util.stream.Collectors; public class PropertyDealServiceImpl extends ServiceImpl implements PropertyDealService { @Resource + @Lazy // 解决循环依赖问题 private PropertyDealItemService propertyDealItemService; + @Resource + @Lazy + private PropertyService propertyService; + /** * 创建企业管理-资产处置单/变动单 * @author 小李 @@ -53,33 +63,63 @@ public class PropertyDealServiceImpl extends ServiceImpl getPropertyDealPage(PropertyDealReqVO pageReqVO) { -// return baseMapper.selectPage(pageReqVO); -// } + /** + * 创建企业管理-资产变动单 + * @author 小李 + * @date 21:24 2024/8/16 + * @param createReqVO 提交对象 + **/ + @Override + @DSTransactional + public void createPropertyDealChange(PropertyDealRespVO createReqVO){ + /* 创建主表 */ + PropertyDeal propertyDeal = BeanUtil.toBean(createReqVO, PropertyDeal.class); + propertyDeal.setCorpId(createReqVO.getPropList().get(0).getCorpId()); + propertyDeal.setDeptId(createReqVO.getPropList().get(0).getDeptId()); + baseMapper.insert(propertyDeal); + String dealId = propertyDeal.getId(); + // 资产旧对象集合 + List properties = new ArrayList<>(); + /* 创建子表 */ + List propertyDealItems = createReqVO.getPropList().stream().map(item -> { + // 查询资产旧对象 + Property property = propertyService.getProperty(item.getId()); + + // 构建新对象 + PropertyDealItem propertyDealItem = new PropertyDealItem(); + // 设置正常属性 + propertyDealItem.setDealId(dealId); + propertyDealItem.setPropertyId(item.getId()); + propertyDealItem.setDealWay(item.getDealWay()); + propertyDealItem.setRemark(ObjectUtil.isNotEmpty(item.getRemark()) ? item.getRemark() : ""); + // 设置老属性 + propertyDealItem.setOldCorpId(property.getCorpId()); + propertyDealItem.setOldDeptId(property.getDeptId()); + propertyDealItem.setOldPosId(property.getPosId()); + propertyDealItem.setOldUserId(Long.valueOf(property.getUserId())); + // 设置新属性 + propertyDealItem.setCorpId(item.getCorpId()); + propertyDealItem.setDeptId(item.getDeptId()); + propertyDealItem.setPosId(item.getPosId()); + propertyDealItem.setUserId(Long.valueOf(item.getUserId())); + + // 更新资产数据 + property.setCorpId(item.getCorpId()); + property.setUserId(item.getUserId()); + property.setPosId(item.getPosId()); + properties.add(property); + return propertyDealItem; + }).collect(Collectors.toList()); + // 新增子表 + propertyDealItemService.saveBatch(propertyDealItems); + // 更新资产 + propertyService.updateBatchById(properties); + } } \ No newline at end of file diff --git a/dl-module-company/src/main/java/cn/iocoder/yudao/module/staff/controller/admin/CompanyStaffController.java b/dl-module-company/src/main/java/cn/iocoder/yudao/module/staff/controller/admin/CompanyStaffController.java index 8059ac1c..ccde4856 100644 --- a/dl-module-company/src/main/java/cn/iocoder/yudao/module/staff/controller/admin/CompanyStaffController.java +++ b/dl-module-company/src/main/java/cn/iocoder/yudao/module/staff/controller/admin/CompanyStaffController.java @@ -10,6 +10,7 @@ import cn.iocoder.yudao.module.staff.service.CompanyStaffService; import cn.iocoder.yudao.module.staff.vo.CompanyStaffReqVO; import cn.iocoder.yudao.module.staff.vo.CompanyStaffRespVO; import cn.iocoder.yudao.module.system.api.permission.dto.RoleReqDTO; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import io.swagger.v3.oas.annotations.Operation; @@ -126,6 +127,21 @@ public class CompanyStaffController { return success(staffRespVO); } + /** + * 查询员工单个 没有附加属性 + * + * @param id 这里是userId + * @author 小李 + * @date 17:59 2024/8/6 + **/ + @GetMapping("/getById") + @Operation(summary = "获得企业管理-员工信息表信息") + @Parameter(name = "id", description = "编号", required = true, example = "1024") + @PreAuthorize("@ss.hasPermission('company:staff:query')") + public CommonResult getCompanyStaffById(@RequestParam("id") String id) { + return success(staffService.getOne(new LambdaQueryWrapper().eq(CompanyStaff::getUserId, id))); + } + /** * 导出员工信息表 * @@ -226,4 +242,18 @@ public class CompanyStaffController { public CommonResult> getRoleList(){ return success(staffService.getRoleList()); } + + /** + * 获取当前某个企业下所有员工信息 + * + * @author 小李 + * @date 15:54 2024/8/8 + * @param id 企业ID + **/ + @GetMapping("/listByCorpId") + @Operation(summary = "获取当前登录用户部门下所有员工信息") + @PreAuthorize("@ss.hasPermission('company:property-deal:query')") + public CommonResult> getStaffListByCorpId(String id){ + return success(staffService.list(new LambdaQueryWrapper().eq(CompanyStaff::getCorpId, id))); + } } diff --git a/dl-module-company/src/main/resources/mapper/property/PropertyDealItemMapper.xml b/dl-module-company/src/main/resources/mapper/property/PropertyDealItemMapper.xml index fee9c12f..83bcdbaf 100644 --- a/dl-module-company/src/main/resources/mapper/property/PropertyDealItemMapper.xml +++ b/dl-module-company/src/main/resources/mapper/property/PropertyDealItemMapper.xml @@ -49,6 +49,7 @@ + @@ -111,7 +112,8 @@ cpd.dept_id AS cpd_dept_id, cpd.data_type AS cpd_data_type, cpd.deal_no AS cpd_deal_no, - cpd.deal_date AS cpd_deal_date + cpd.deal_date AS cpd_deal_date, + cpdi.remark AS cp_remark FROM company_property_deal_item cpdi INNER JOIN company_property cp ON cpdi.property_id = cp.id INNER JOIN company_property_deal cpd ON cpdi.deal_id = cpd.id @@ -121,7 +123,7 @@ + + \ No newline at end of file