diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/common/DictBaseConstants.java b/dl-module-base/src/main/java/cn/iocoder/yudao/common/DictBaseConstants.java index 7716c472..2ff34521 100644 --- a/dl-module-base/src/main/java/cn/iocoder/yudao/common/DictBaseConstants.java +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/common/DictBaseConstants.java @@ -29,4 +29,22 @@ public class DictBaseConstants { public static final String CYCLE_DICT = "cycle_dict"; /** 企业资产临期判定时间 */ public static final String COMPANY_PROPERTY_EXPIRED = "company_property_expired"; + /** 客户状态 */ + public static final String DICT_CUS_INFO_STATUS = "cus_info_status"; + /** 卡券类型 */ + public static final String MEMBER_COUPON_TYPE = "member_coupon_type"; + /** 核销规则 */ + public static final String MEMBER_COUPON_OUT_RULE = "member_coupon_out_rule"; + /** 适用车型 */ + public static final String MEMBER_CAR = "member_car"; + /** 活动类型 */ + public static final String MEMBER_ACTIVE = "member_active"; + /** 品牌类型 */ + public static final String DICT_BRAND_TYPE = "brand_type"; + /** 车辆类别 */ + public static final String DICT_CAR_CATEGORY = "car_category"; + /** 车辆性质 */ + public static final String DICT_CAR_NATURE = "car_nature"; + /** 支付方式 */ + public static final String REPAIR_PAY_TYPE = "repair_pay_type"; } diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/controller/admin/CarMainController.java b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/controller/admin/CarMainController.java index 4d5fa91c..25bf2624 100644 --- a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/controller/admin/CarMainController.java +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/controller/admin/CarMainController.java @@ -1,15 +1,15 @@ package cn.iocoder.yudao.module.custom.controller.admin; +import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollectionUtil; import cn.iocoder.yudao.module.custom.entity.CarMain; import cn.iocoder.yudao.module.custom.service.CarMainService; import cn.iocoder.yudao.module.custom.service.UserCarService; -import cn.iocoder.yudao.module.custom.vo.CarMainReqVO; -import cn.iocoder.yudao.module.custom.vo.CarMainRespVO; -import cn.iocoder.yudao.module.custom.vo.CustomerMainSaveReqVO; +import cn.iocoder.yudao.module.custom.vo.*; import cn.iocoder.yudao.module.label.service.BusiLabelService; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; @@ -25,6 +25,7 @@ import javax.servlet.http.*; import javax.validation.Valid; import java.util.*; import java.io.IOException; +import java.util.stream.Collectors; import cn.iocoder.yudao.framework.common.pojo.PageParam; import cn.iocoder.yudao.framework.common.pojo.CommonResult; @@ -32,6 +33,7 @@ import cn.iocoder.yudao.framework.common.util.object.BeanUtils; import static cn.iocoder.yudao.common.BaseConstants.TABLE_BASE_CAR_MAIN; import static cn.iocoder.yudao.common.BaseConstants.TABLE_BASE_CUSTOMER_MAIN; +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception0; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; @@ -167,7 +169,7 @@ public class CarMainController { */ @GetMapping("/export-excel") @Operation(summary = "导出车辆信息 Excel") - @PreAuthorize("@ss.hasPermission('base:car-main:customer')") + @PreAuthorize("@ss.hasPermission('base:car-main:export')") @ApiAccessLog(operateType = EXPORT) public void exportCarMainExcel(CarMainReqVO pageReqVO, HttpServletResponse response) throws IOException { pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); @@ -233,4 +235,94 @@ public class CarMainController { public CommonResult vehicleLicenseOCR(@RequestBody String imagePath) throws Exception { return CommonResult.success(userCarService.vehicleLicenseOCR(imagePath)); } + + /** + * 导出数据 年检临期 + * + * @author 小李 + * @date 11:38 2024/12/3 + * @param pageReqVO 请求对象 + **/ + @GetMapping("/export-inspection") + @Operation(summary = "导出数据") + public void exportInspection(CarMainReqVO pageReqVO, HttpServletResponse response)throws IOException{ + int pageNo = 1, pageSize = 1000; + List list = new ArrayList<>(); + Page page = new Page<>(pageNo, pageSize); + do { + IPage carMainRespVOIPage = carMainService.remindCarMainPage2(page, pageReqVO); + List records = carMainRespVOIPage.getRecords(); + if (CollUtil.isEmpty(records)){ + break; + } + List convertedRecords = records.stream().map(item -> BeanUtils.toBean(item, InspectionExportVO.class)).collect(Collectors.toList()); + list.addAll(convertedRecords); + pageNo++; + page.setCurrent(pageNo); + }while (true); + if (CollUtil.isEmpty(list)){ + throw exception0(500, "没有数据可以导出"); + } + ExcelUtils.write(response, "年检临期提醒数据.xls", "数据", InspectionExportVO.class, list); + } + + /** + * 导出数据 保养临期 + * + * @author 小李 + * @date 12:19 2024/12/3 + * @param pageReqVO 请求对象 + **/ + @GetMapping("/export-maintenance") + @Operation(summary = "导出数据") + public void exportMaintenance(CarMainReqVO pageReqVO, HttpServletResponse response)throws IOException{ + int pageNo = 1, pageSize = 1000; + List list = new ArrayList<>(); + Page page = new Page<>(pageNo, pageSize); + do { + IPage carMainRespVOIPage = carMainService.remindCarMainPage2(page, pageReqVO); + List records = carMainRespVOIPage.getRecords(); + if (CollUtil.isEmpty(records)){ + break; + } + List convertedRecords = records.stream().map(item -> BeanUtils.toBean(item, MaintenanceExportVO.class)).collect(Collectors.toList()); + list.addAll(convertedRecords); + pageNo++; + page.setCurrent(pageNo); + }while (true); + if (CollUtil.isEmpty(list)){ + throw exception0(500, "没有数据可以导出"); + } + ExcelUtils.write(response, "保养临期提醒数据.xls", "数据", MaintenanceExportVO.class, list); + } + + /** + * 导出数据 保险临期 + * + * @author 小李 + * @date 12:19 2024/12/3 + * @param pageReqVO 请求对象 + **/ + @GetMapping("/export-insurance") + @Operation(summary = "导出数据") + public void exportInsurance(CarMainReqVO pageReqVO, HttpServletResponse response)throws IOException{ + int pageNo = 1, pageSize = 1000; + List list = new ArrayList<>(); + Page page = new Page<>(pageNo, pageSize); + do { + IPage carMainRespVOIPage = carMainService.remindCarMainPage2(page, pageReqVO); + List records = carMainRespVOIPage.getRecords(); + if (CollUtil.isEmpty(records)){ + break; + } + List convertedRecords = records.stream().map(item -> BeanUtils.toBean(item, InsuranceExportVO.class)).collect(Collectors.toList()); + list.addAll(convertedRecords); + pageNo++; + page.setCurrent(pageNo); + }while (true); + if (CollUtil.isEmpty(list)){ + throw exception0(500, "没有数据可以导出"); + } + ExcelUtils.write(response, "保险临期提醒数据.xls", "数据", InsuranceExportVO.class, list); + } } \ No newline at end of file diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/controller/admin/CustomerMainController.java b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/controller/admin/CustomerMainController.java index d2b7454f..e3e95054 100644 --- a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/controller/admin/CustomerMainController.java +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/controller/admin/CustomerMainController.java @@ -1,10 +1,15 @@ package cn.iocoder.yudao.module.custom.controller.admin; +import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.util.ObjectUtil; import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; import cn.iocoder.yudao.module.custom.entity.CustomerMain; import cn.iocoder.yudao.module.custom.service.CustomerCarService; import cn.iocoder.yudao.module.custom.service.CustomerMainService; +import cn.iocoder.yudao.module.custom.vo.CustomerExportVO; import cn.iocoder.yudao.module.custom.vo.CustomerMainPageReqVO; import cn.iocoder.yudao.module.custom.vo.CustomerMainRespVO; import cn.iocoder.yudao.module.custom.vo.CustomerMainSaveReqVO; @@ -20,8 +25,12 @@ import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; +import javax.servlet.http.HttpServletResponse; import javax.validation.Valid; +import java.io.IOException; +import java.util.ArrayList; import java.util.List; +import java.util.stream.Collectors; import static cn.iocoder.yudao.common.BaseConstants.*; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception0; @@ -44,6 +53,7 @@ public class CustomerMainController { private BusiLabelService busiLabelService; @Resource private CustomerCarService customerCarService; + /** * 客户管理分页列表查询 * @@ -76,7 +86,7 @@ public class CustomerMainController { @Operation(summary = "创建客户管理") @PreAuthorize("@ss.hasPermission('base:customer-main:create')") public CommonResult createCustomerMain(@Valid @RequestBody CustomerMainSaveReqVO saveReqVO) { - customerMainService.saveCustomer(saveReqVO,SIGN_CREATE); + customerMainService.saveCustomer(saveReqVO, SIGN_CREATE); return success(true); } @@ -99,7 +109,7 @@ public class CustomerMainController { @Operation(summary = "更新客户管理") @PreAuthorize("@ss.hasPermission('base:customer-main:update')") public CommonResult updateCustomerMain(@Valid @RequestBody CustomerMainSaveReqVO saveReqVO) { - customerMainService.saveCustomer(saveReqVO,SIGN_UPDATE); + customerMainService.saveCustomer(saveReqVO, SIGN_UPDATE); return success(true); } @@ -185,10 +195,10 @@ public class CustomerMainController { /** * 根据姓名和电话查询单条记录 * + * @param customerMain 查询对象 * @author 小李 * @date 11:19 2024/10/8 - * @param customerMain 查询对象 - **/ + **/ @PostMapping("/getByNameAndMobile") @Operation(summary = "根据姓名和电话查询单条记录") public CommonResult getByNameAndMobile(@Valid @RequestBody CustomerMain customerMain) { @@ -201,4 +211,39 @@ public class CustomerMainController { } throw exception0(500, "系统异常"); } + + /** + * 导出数据 + * + * @author 小李 + * @date 19:33 2024/12/2 + * @param pageReqVO 请求对象 + **/ + @GetMapping("/export") + @Operation(summary = "导出数据") + public void exportData(CustomerMainPageReqVO pageReqVO, HttpServletResponse response) throws IOException { + int pageNo = 1, pageSize = 1000; + List list = new ArrayList<>(); + Page page = new Page<>(pageNo, pageSize); + do { + IPage customerMainRespVOIPage = customerMainService.queryListPage(pageReqVO, page); + List records = customerMainRespVOIPage.getRecords(); + if (CollUtil.isEmpty(records)){ + break; + } + List convertedRecords = records.stream().map(item -> BeanUtils.toBean(item, CustomerExportVO.class)).collect(Collectors.toList()); + list.addAll(convertedRecords); + pageNo++; + page.setCurrent(pageNo); + }while (true); + if (CollUtil.isEmpty(list)){ + throw exception0(500, "没有数据可以导出"); + } + list.forEach(item -> { + if (ObjectUtil.isNotEmpty(item.getIsHangAccount())){ + item.setIsHangAccount(item.getIsHangAccount().equals("0") ? "否" : "是"); + } + }); + ExcelUtils.write(response, "客户数据.xls", "数据", CustomerExportVO.class, list); + } } \ No newline at end of file diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/entity/CarBrand.java b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/entity/CarBrand.java index 7a9921f6..9c71ba05 100644 --- a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/entity/CarBrand.java +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/entity/CarBrand.java @@ -1,5 +1,6 @@ package cn.iocoder.yudao.module.custom.entity; +import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; import com.alibaba.excel.annotation.ExcelProperty; import io.swagger.v3.oas.annotations.media.Schema; @@ -12,6 +13,8 @@ import java.time.LocalDateTime; import com.baomidou.mybatisplus.annotation.*; import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; +import static cn.iocoder.yudao.common.DictBaseConstants.DICT_BRAND_TYPE; + /** * 车辆品牌维护 DO * @@ -76,6 +79,7 @@ public class CarBrand extends BaseDO { */ @Schema(description = "品牌类型 (01国产车 02韩系车 03日系车 04美系车 05欧系车 06德系车)", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") @ExcelProperty(value = "品牌类型 (01国产车 02韩系车 03日系车 04美系车 05欧系车 06德系车)", converter = DictConvert.class) + @DictFormat(DICT_BRAND_TYPE) private String brandType; /** * 品牌键值 diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/entity/CarMain.java b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/entity/CarMain.java index 12a52acb..94511e1f 100644 --- a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/entity/CarMain.java +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/entity/CarMain.java @@ -1,6 +1,9 @@ package cn.iocoder.yudao.module.custom.entity; +import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; +import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO; +import com.alibaba.excel.annotation.ExcelProperty; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; @@ -12,6 +15,7 @@ import org.springframework.format.annotation.DateTimeFormat; import java.math.BigDecimal; import java.time.LocalDateTime; +import static cn.iocoder.yudao.common.DictBaseConstants.*; import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY; /** @@ -36,14 +40,17 @@ public class CarMain extends TenantBaseDO { /** * 发动机号码 */ + @ExcelProperty("发动机号码") private String engineNumber; /** * 车架号 */ + @ExcelProperty("车架号") private String vin; /** * 车牌号 */ + @ExcelProperty("车牌号") private String licenseNumber; /** * 车辆型号 @@ -106,16 +113,21 @@ public class CarMain extends TenantBaseDO { /** * 车辆性质:营运 非营运等 */ + @ExcelProperty(value = "车辆性质", converter = DictConvert.class) + @DictFormat(DICT_CAR_NATURE) private String carNature; /** * 车辆类别:私家车 货车 教练车 公务车 出租车 */ + @ExcelProperty(value = "车辆类别", converter = DictConvert.class) + @DictFormat(DICT_CAR_CATEGORY) private String carCategory; /** * 车辆注册日期 */ @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY) @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd") + @ExcelProperty("车辆注册日期") private LocalDateTime carRegisterDate; /** * 行驶证图片 @@ -124,11 +136,15 @@ public class CarMain extends TenantBaseDO { /** * 最近办理业务 */ + @ExcelProperty(value = "最近办理业务", converter = DictConvert.class) + @DictFormat(DICT_CUS_BUSI_TYPE) private String recentlyHandledBusiness; /** * 最近办理业务的时间 */ @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY) + @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd") + @ExcelProperty("最近业务时间") private LocalDateTime recentlyHandleBusinessTime; diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/CarMainService.java b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/CarMainService.java index 673fb00d..091b2b33 100644 --- a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/CarMainService.java +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/CarMainService.java @@ -6,6 +6,7 @@ import cn.iocoder.yudao.module.custom.entity.CarMain; import cn.iocoder.yudao.module.custom.vo.CarMainReqVO; import cn.iocoder.yudao.module.custom.vo.CarMainRespVO; import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.IService; import java.util.List; @@ -82,6 +83,15 @@ public interface CarMainService extends IService { **/ IPage remindCarMainPage(CarMainReqVO pageReqVO); + /** + * 对外提供一个导出用 + * + * @author 小李 + * @date 12:03 2024/12/3 + * @param pageReqVO 查询条件 + **/ + IPage remindCarMainPage2(Page page, CarMainReqVO pageReqVO); + /** * 绑定车辆信息 diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/impl/CarMainServiceImpl.java b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/impl/CarMainServiceImpl.java index 74cc104c..bcf05a0d 100644 --- a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/impl/CarMainServiceImpl.java +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/service/impl/CarMainServiceImpl.java @@ -242,6 +242,18 @@ public class CarMainServiceImpl extends ServiceImpl impl return baseMapper.remindCarMainPage(page,pageReqVO); } + /** + * 对外提供一个导出用 + * + * @author 小李 + * @date 12:03 2024/12/3 + * @param pageReqVO 查询条件 + **/ + @Override + public IPage remindCarMainPage2(Page page, CarMainReqVO pageReqVO){ + return baseMapper.remindCarMainPage(page, pageReqVO); + } + /** * 绑定客户信息 * diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/vo/CarMainRespVO.java b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/vo/CarMainRespVO.java index 52b4c6dc..dabd30ae 100644 --- a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/vo/CarMainRespVO.java +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/vo/CarMainRespVO.java @@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.custom.vo; import cn.iocoder.yudao.module.custom.entity.CarMain; import cn.iocoder.yudao.module.custom.entity.CustomerMain; import cn.iocoder.yudao.module.label.entity.BusiLabel; +import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.v3.oas.annotations.media.Schema; import lombok.*; import java.util.*; @@ -10,6 +11,7 @@ import org.springframework.format.annotation.DateTimeFormat; import java.time.LocalDateTime; import com.alibaba.excel.annotation.*; +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY; import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; @Schema(description = "管理后台 - 车辆信息 Response VO") @@ -27,8 +29,10 @@ public class CarMainRespVO extends CarMain { @Schema(description = "标签信息") List labelList; /**品牌字符*/ + @ExcelProperty("车辆品牌") String brandStr; /**型号字符*/ + @ExcelProperty("车辆型号") String modelStr; /**客户名称*/ String cusName; @@ -46,4 +50,9 @@ public class CarMainRespVO extends CarMain { private String brandType; /** 车辆logo */ private String logoImg; + /** 登记时间 */ + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY) + @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd") + @ExcelProperty("登记时间") + private LocalDateTime createTime; } \ No newline at end of file diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/vo/CustomerExportVO.java b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/vo/CustomerExportVO.java new file mode 100644 index 00000000..75b6f0eb --- /dev/null +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/vo/CustomerExportVO.java @@ -0,0 +1,66 @@ +package cn.iocoder.yudao.module.custom.vo; + +import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; +import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; +import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; +import com.alibaba.excel.annotation.ExcelProperty; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; + +import java.time.LocalDateTime; +import java.util.Date; + +import static cn.iocoder.yudao.common.DictBaseConstants.*; + +/** + * 用于导出客户数据VO + * + * @author 小李 + * @date 19:20 2024/12/2 +**/ +@Data +@ExcelIgnoreUnannotated +public class CustomerExportVO { + + @ExcelProperty("客户名称") + private String cusName; + + @ExcelProperty(value = "性别", converter = DictConvert.class) + @DictFormat(DICT_SYS_USER_SEX) + private String sex; + + @ExcelProperty("会员等级") + private String levelName; + + @ExcelProperty("联系方式") + private String phoneNumber; + + @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd") + @DateTimeFormat(pattern="yyyy-MM-dd") + @ExcelProperty("生日") + private LocalDateTime birthday; + + @ExcelProperty("住址") + private String address; + + @ExcelProperty("是否挂账") + private String isHangAccount; + + @ExcelProperty(value = "客户来源", converter = DictConvert.class) + @DictFormat(DICT_CUS_DATA_FROM) + private String dataFrom; + + @ExcelProperty(value = "最近办理业务", converter = DictConvert.class) + @DictFormat(DICT_CUS_BUSI_TYPE) + private String nearDoContent; + + @ExcelProperty("最近业务办理时间") + @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd") + @DateTimeFormat(pattern="yyyy-MM-dd") + private LocalDateTime nearDoTime; + + @ExcelProperty(value = "客户状态", converter = DictConvert.class) + @DictFormat(DICT_CUS_INFO_STATUS) + private String status; +} diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/vo/InspectionExportVO.java b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/vo/InspectionExportVO.java new file mode 100644 index 00000000..42c912cd --- /dev/null +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/vo/InspectionExportVO.java @@ -0,0 +1,35 @@ +package cn.iocoder.yudao.module.custom.vo; + +import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; +import com.alibaba.excel.annotation.ExcelProperty; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; + +import java.time.LocalDateTime; + +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY; + +/** + * 用于车检临期数据导出VO + * + * @author 小李 + * @date 11:49 2024/12/3 +**/ +@Data +@ExcelIgnoreUnannotated +public class InspectionExportVO extends SyntheticExportVO{ + + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY) + @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd") + @ExcelProperty("上次年检时间") + private LocalDateTime inspectionDate; + + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY) + @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd") + @ExcelProperty("下次年检时间") + private LocalDateTime nextInspectionDate; + + @ExcelProperty("临近年检天数") + private String njCont; +} diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/vo/InsuranceExportVO.java b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/vo/InsuranceExportVO.java new file mode 100644 index 00000000..09281023 --- /dev/null +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/vo/InsuranceExportVO.java @@ -0,0 +1,35 @@ +package cn.iocoder.yudao.module.custom.vo; + +import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; +import com.alibaba.excel.annotation.ExcelProperty; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; + +import java.time.LocalDateTime; + +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY; + +/** + * 用户导出保险临期提醒数据VO + * + * @author 小李 + * @date 12:23 2024/12/3 +**/ +@Data +@ExcelIgnoreUnannotated +public class InsuranceExportVO extends SyntheticExportVO{ + + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY) + @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd") + @ExcelProperty("保险日期") + private LocalDateTime insuranceDate; + + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY) + @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd") + @ExcelProperty("保险到期日期") + private LocalDateTime insuranceExpiryDate; + + @ExcelProperty("保险到期天数") + private String bxCont; +} diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/vo/MaintenanceExportVO.java b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/vo/MaintenanceExportVO.java new file mode 100644 index 00000000..80f85cf2 --- /dev/null +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/vo/MaintenanceExportVO.java @@ -0,0 +1,42 @@ +package cn.iocoder.yudao.module.custom.vo; + +import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; +import com.alibaba.excel.annotation.ExcelProperty; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; + +import java.math.BigDecimal; +import java.time.LocalDateTime; + +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY; + +/** + * 用于保养临期提醒VO + * + * @author 小李 + * @date 12:14 2024/12/3 +**/ +@Data +@ExcelIgnoreUnannotated +public class MaintenanceExportVO extends SyntheticExportVO{ + + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY) + @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd") + @ExcelProperty("保养日期") + private LocalDateTime maintenanceDate; + + @ExcelProperty("保养里程") + private BigDecimal maintenanceMileage; + + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY) + @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd") + @ExcelProperty("下次保养日期") + private LocalDateTime nextMaintenanceDate; + + @ExcelProperty("下次保养里程") + private BigDecimal nextMaintenanceMileage; + + @ExcelProperty("临近保养天数") + private String byCont; +} diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/vo/SyntheticExportVO.java b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/vo/SyntheticExportVO.java new file mode 100644 index 00000000..25b936ce --- /dev/null +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/module/custom/vo/SyntheticExportVO.java @@ -0,0 +1,44 @@ +package cn.iocoder.yudao.module.custom.vo; + +import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; +import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; +import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; +import com.alibaba.excel.annotation.ExcelProperty; +import lombok.Data; + +import static cn.iocoder.yudao.common.DictBaseConstants.DICT_CAR_CATEGORY; +import static cn.iocoder.yudao.common.DictBaseConstants.DICT_CAR_NATURE; + +/** + * 用于车检临期、保养临期、保险临期数据导出公共数据VO + * + * @author 小李 + * @date 11:49 2024/12/3 + **/ +@Data +@ExcelIgnoreUnannotated +public class SyntheticExportVO { + + @ExcelProperty("车牌号") + private String licenseNumber; + + @ExcelProperty("车辆品牌") + String brandStr; + + @ExcelProperty("车辆型号") + String modelStr; + + @ExcelProperty(value = "车辆类别", converter = DictConvert.class) + @DictFormat(DICT_CAR_CATEGORY) + private String carCategory; + + @ExcelProperty(value = "车辆性质", converter = DictConvert.class) + @DictFormat(DICT_CAR_NATURE) + private String carNature; + + @ExcelProperty("联系人") + private String cusName; + + @ExcelProperty("联系方式") + private String phoneNumber; +} diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/module/member/controller/admin/ActiveMainController.java b/dl-module-base/src/main/java/cn/iocoder/yudao/module/member/controller/admin/ActiveMainController.java index cc0086cc..43926f92 100644 --- a/dl-module-base/src/main/java/cn/iocoder/yudao/module/member/controller/admin/ActiveMainController.java +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/module/member/controller/admin/ActiveMainController.java @@ -1,9 +1,13 @@ package cn.iocoder.yudao.module.member.controller.admin; +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.ObjectUtil; import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.util.object.BeanUtils; +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; import cn.iocoder.yudao.module.member.entity.ActiveMain; import cn.iocoder.yudao.module.member.service.ActiveMainService; +import cn.iocoder.yudao.module.member.vo.ActiveMainExportVO; import cn.iocoder.yudao.module.member.vo.ActiveMainPageReqVO; import cn.iocoder.yudao.module.member.vo.ActiveMainRespVO; import cn.iocoder.yudao.module.member.vo.ActiveMainSaveReqVO; @@ -17,10 +21,15 @@ import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; +import javax.servlet.http.HttpServletResponse; import javax.validation.Valid; +import java.io.IOException; +import java.util.ArrayList; import java.util.List; +import java.util.stream.Collectors; +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception0; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; @Tag(name = "管理后台 - 营销活动") @@ -111,4 +120,38 @@ public class ActiveMainController { return success(activeMainService.queryListPage(pageReqVO, page)); } + /** + * 导出数据 + * + * @author 小李 + * @date 20:25 2024/12/2 + * @param pageReqVO 请求对象 + **/ + @GetMapping("/export") + @Operation(summary = "导出数据") + public void exportData(ActiveMainPageReqVO pageReqVO, HttpServletResponse response)throws IOException { + int pageNo = 1, pageSize = 1000; + List list = new ArrayList<>(); + Page page = new Page<>(pageNo, pageSize); + do { + IPage activeMainRespVOIPage = activeMainService.queryListPage(pageReqVO, page); + List records = activeMainRespVOIPage.getRecords(); + if (CollUtil.isEmpty(records)){ + break; + } + List convertedRecords = records.stream().map(item -> BeanUtils.toBean(item, ActiveMainExportVO.class)).collect(Collectors.toList()); + list.addAll(convertedRecords); + pageNo++; + page.setCurrent(pageNo); + }while (true); + if (CollUtil.isEmpty(list)){ + throw exception0(500, "没有数据可以导出"); + } + list.forEach(item -> { + if (ObjectUtil.isNotEmpty(item.getStatus())){ + item.setStatus(item.getStatus().equals("01") ? "启用" : "停用"); + } + }); + ExcelUtils.write(response, "营销活动数据.xls", "数据", ActiveMainExportVO.class, list); + } } \ No newline at end of file diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/module/member/controller/admin/MemberCouponController.java b/dl-module-base/src/main/java/cn/iocoder/yudao/module/member/controller/admin/MemberCouponController.java index eab4db6f..e4d37225 100644 --- a/dl-module-base/src/main/java/cn/iocoder/yudao/module/member/controller/admin/MemberCouponController.java +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/module/member/controller/admin/MemberCouponController.java @@ -1,5 +1,7 @@ package cn.iocoder.yudao.module.member.controller.admin; +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.ObjectUtil; import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.PageParam; @@ -8,10 +10,7 @@ import cn.iocoder.yudao.framework.common.util.object.BeanUtils; import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; import cn.iocoder.yudao.module.member.entity.MemberCoupon; import cn.iocoder.yudao.module.member.service.MemberCouponService; -import cn.iocoder.yudao.module.member.vo.MemberCouponPageReqVO; -import cn.iocoder.yudao.module.member.vo.MemberCouponRespVO; -import cn.iocoder.yudao.module.member.vo.MemberCouponSaveReqVO; -import cn.iocoder.yudao.module.member.vo.MemberLevelRespVO; +import cn.iocoder.yudao.module.member.vo.*; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import io.swagger.v3.oas.annotations.Operation; @@ -25,9 +24,12 @@ import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; import javax.validation.Valid; import java.io.IOException; +import java.util.ArrayList; import java.util.List; +import java.util.stream.Collectors; import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception0; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; @Tag(name = "管理后台 - 基础卡券") @@ -138,5 +140,34 @@ public class MemberCouponController { return success(couponService.queryListPage(pageReqVO, page)); } + /** + * 导出数据 + * + * @author 小李 + * @date 19:53 2024/12/2 + * @param pageReqVO 请求数据 + **/ + @GetMapping("/export") + @Operation(summary = "导出数据") + public void exportData(MemberCouponPageReqVO pageReqVO, HttpServletResponse response)throws IOException{ + int pageNo = 1, pageSize = 1000; + List list = new ArrayList<>(); + Page page = new Page<>(pageNo, pageSize); + do { + IPage memberCouponRespVOIPage = couponService.queryListPage(pageReqVO, page); + List records = memberCouponRespVOIPage.getRecords(); + if (CollUtil.isEmpty(records)){ + break; + } + List convertedRecords = records.stream().map(item -> BeanUtils.toBean(item, MemberCouponExportVO.class)).collect(Collectors.toList()); + list.addAll(convertedRecords); + pageNo++; + page.setCurrent(pageNo); + }while (true); + if (CollUtil.isEmpty(list)){ + throw exception0(500, "没有数据可以导出"); + } + ExcelUtils.write(response, "基础卡券数据.xls", "数据", MemberCouponExportVO.class, list); + } } \ No newline at end of file diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/module/member/controller/admin/MemberLevelController.java b/dl-module-base/src/main/java/cn/iocoder/yudao/module/member/controller/admin/MemberLevelController.java index 471bdc71..1e49d979 100644 --- a/dl-module-base/src/main/java/cn/iocoder/yudao/module/member/controller/admin/MemberLevelController.java +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/module/member/controller/admin/MemberLevelController.java @@ -1,9 +1,13 @@ package cn.iocoder.yudao.module.member.controller.admin; +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.ObjectUtil; import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.util.object.BeanUtils; +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; import cn.iocoder.yudao.module.member.entity.MemberLevel; import cn.iocoder.yudao.module.member.service.MemberLevelService; +import cn.iocoder.yudao.module.member.vo.MemberLevelExportVO; import cn.iocoder.yudao.module.member.vo.MemberLevelPageReqVO; import cn.iocoder.yudao.module.member.vo.MemberLevelRespVO; import cn.iocoder.yudao.module.member.vo.MemberLevelSaveReqVO; @@ -17,10 +21,15 @@ import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; +import javax.servlet.http.HttpServletResponse; import javax.validation.Valid; +import java.io.IOException; +import java.util.ArrayList; import java.util.List; +import java.util.stream.Collectors; +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception0; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; @@ -127,4 +136,39 @@ public class MemberLevelController { return success(levelService.queryListAll(pageReqVO)); } + + /** + * 导出数据 + * + * @author 小李 + * @date 19:41 2024/12/2 + * @param pageReqVO 请求对象 + **/ + @GetMapping("/export") + @Operation(summary = "导出数据") + public void exportData(MemberLevelPageReqVO pageReqVO, HttpServletResponse response)throws IOException { + int pageNo = 1, pageSize = 1000; + List list = new ArrayList<>(); + Page page = new Page<>(pageNo, pageSize); + do { + IPage memberLevelRespVOIPage = levelService.queryListPage(pageReqVO, page); + List records = memberLevelRespVOIPage.getRecords(); + if (CollUtil.isEmpty(records)){ + break; + } + List convertedRecords = records.stream().map(item -> BeanUtils.toBean(item, MemberLevelExportVO.class)).collect(Collectors.toList()); + list.addAll(convertedRecords); + pageNo++; + page.setCurrent(pageNo); + }while (true); + if (CollUtil.isEmpty(list)){ + throw exception0(500, "没有数据可以导出"); + } + list.forEach(item -> { + if (ObjectUtil.isNotEmpty(item.getStatus())){ + item.setStatus(item.getStatus().equals("01") ? "启用" : "停用"); + } + }); + ExcelUtils.write(response, "会员等级数据.xls", "数据", MemberLevelExportVO.class, list); + } } \ No newline at end of file diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/module/member/vo/ActiveMainExportVO.java b/dl-module-base/src/main/java/cn/iocoder/yudao/module/member/vo/ActiveMainExportVO.java new file mode 100644 index 00000000..1892c4c3 --- /dev/null +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/module/member/vo/ActiveMainExportVO.java @@ -0,0 +1,47 @@ +package cn.iocoder.yudao.module.member.vo; + +import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; +import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; +import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; +import com.alibaba.excel.annotation.ExcelProperty; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; + +import java.time.LocalDateTime; + +import static cn.iocoder.yudao.common.DictBaseConstants.MEMBER_ACTIVE; + +/** + * 用于导出营销活动VO + * + * @author 小李 + * @date 20:26 2024/12/2 +**/ +@Data +@ExcelIgnoreUnannotated +public class ActiveMainExportVO { + + @ExcelProperty("活动名称") + private String name; + + @ExcelProperty(value = "活动类型", converter = DictConvert.class) + @DictFormat(MEMBER_ACTIVE) + private String type; + + @ExcelProperty("活动开始时间") + @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss") + @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") + private LocalDateTime beginTime; + + @ExcelProperty("活动结束时间") + @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss") + @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") + private LocalDateTime endTime; + + @ExcelProperty("活动状态") + private String status; + + @ExcelProperty("活动描述") + private String remark; +} diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/module/member/vo/MemberCouponExportVO.java b/dl-module-base/src/main/java/cn/iocoder/yudao/module/member/vo/MemberCouponExportVO.java new file mode 100644 index 00000000..0ecbfa86 --- /dev/null +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/module/member/vo/MemberCouponExportVO.java @@ -0,0 +1,56 @@ +package cn.iocoder.yudao.module.member.vo; + +import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; +import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; +import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; +import com.alibaba.excel.annotation.ExcelProperty; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; + +import java.math.BigDecimal; +import java.time.LocalDateTime; + +import static cn.iocoder.yudao.common.DictBaseConstants.*; + +/** + * 用于基础卡券导出VO + * + * @author 小李 + * @date 19:55 2024/12/2 +**/ +@Data +@ExcelIgnoreUnannotated +public class MemberCouponExportVO { + + @ExcelProperty("卡券名称") + private String name; + + @ExcelProperty(value = "卡券类型", converter = DictConvert.class) + @DictFormat(MEMBER_COUPON_TYPE) + private String type; + + @ExcelProperty(value = "适用车型", converter = DictConvert.class) + @DictFormat(MEMBER_CAR) + private String carModel; + + @ExcelProperty(value = "核销规则", converter = DictConvert.class) + @DictFormat(MEMBER_COUPON_OUT_RULE) + private String outRule; + + @ExcelProperty("开始有效期") + @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss") + @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") + private LocalDateTime beginTime; + + @ExcelProperty("结束有效期") + @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss") + @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") + private LocalDateTime endTime; + + @ExcelProperty("面额") + private BigDecimal amount; + + @ExcelProperty("备注") + private String remark; +} diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/module/member/vo/MemberLevelExportVO.java b/dl-module-base/src/main/java/cn/iocoder/yudao/module/member/vo/MemberLevelExportVO.java new file mode 100644 index 00000000..3e9d3ff9 --- /dev/null +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/module/member/vo/MemberLevelExportVO.java @@ -0,0 +1,36 @@ +package cn.iocoder.yudao.module.member.vo; + +import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; +import com.alibaba.excel.annotation.ExcelProperty; +import lombok.Data; + +import java.math.BigDecimal; + +/** + * 用于会员等级导出VO + * + * @author 小李 + * @date 19:42 2024/12/2 +**/ +@Data +@ExcelIgnoreUnannotated +public class MemberLevelExportVO { + + @ExcelProperty("等级名称") + private String name; + + @ExcelProperty("状态") + private String status; + + @ExcelProperty("升级所需积分") + private String growthValue; + + @ExcelProperty("会员折扣") + private BigDecimal discount; + + @ExcelProperty("等级说明") + private String remark; + + @ExcelProperty("等级权益") + private String userEquity; +} diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/module/order/controller/admin/RepairOrderInfoController.java b/dl-module-base/src/main/java/cn/iocoder/yudao/module/order/controller/admin/RepairOrderInfoController.java index dde61feb..fe611f25 100644 --- a/dl-module-base/src/main/java/cn/iocoder/yudao/module/order/controller/admin/RepairOrderInfoController.java +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/module/order/controller/admin/RepairOrderInfoController.java @@ -1,9 +1,12 @@ package cn.iocoder.yudao.module.order.controller.admin; +import cn.hutool.core.collection.CollUtil; import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.util.object.BeanUtils; +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; import cn.iocoder.yudao.module.order.entity.RepairOrderInfo; import cn.iocoder.yudao.module.order.service.RepairOrderInfoService; +import cn.iocoder.yudao.module.order.vo.RepairOrderExportVO; import cn.iocoder.yudao.module.order.vo.RepairOrderInfoPageReqVO; import cn.iocoder.yudao.module.order.vo.RepairOrderInfoRespVO; import cn.iocoder.yudao.module.order.vo.RepairOrderInfoSaveReqVO; @@ -17,13 +20,18 @@ import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; +import javax.servlet.http.HttpServletResponse; import javax.validation.Valid; import java.io.IOException; import java.security.InvalidKeyException; import java.security.NoSuchAlgorithmException; import java.security.SignatureException; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception0; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; @Tag(name = "管理后台 - 维修模块 订单") @@ -113,4 +121,48 @@ public class RepairOrderInfoController { public CommonResult toPay(@RequestParam("id")String id) throws IOException, NoSuchAlgorithmException, SignatureException, InvalidKeyException { return success(repairOrderInfoService.payTransactionsCode(id)); } + + /** + * 导出数据 + * + * @author 小李 + * @date 17:03 2024/12/3 + * @param pageReqVO 请求对象 + **/ + @GetMapping("/export") + @Operation(summary = "导出数据") + public void exportData(RepairOrderInfoPageReqVO pageReqVO, HttpServletResponse response)throws IOException{ + int pageNo = 1, pageSize = 1000; + List list = new ArrayList<>(); + Page page = new Page<>(pageNo, pageSize); + do { + IPage repairOrderInfoRespVOIPage = repairOrderInfoService.queryListPage(pageReqVO, page); + List records = repairOrderInfoRespVOIPage.getRecords(); + if (CollUtil.isEmpty(records)){ + break; + } + List convertedRecords = records.stream().map(item -> BeanUtils.toBean(item, RepairOrderExportVO.class)).collect(Collectors.toList()); + list.addAll(convertedRecords); + pageNo++; + page.setCurrent(pageNo); + }while (true); + if (CollUtil.isEmpty(list)){ + throw exception0(500, "没有数据可以导出"); + } + list.forEach(item -> { + switch (item.getGoodsType()){ + case "1": + item.setGoodsType("会员充值"); + break; + case "2": + item.setGoodsType("维修服务"); + break; + case "3": + item.setGoodsType("保养卡"); + break; + } + item.setOrderStatus(item.getOrderStatus().equals("0") ? "待支付" : "已支付"); + }); + ExcelUtils.write(response, "订单数据.xls", "数据", RepairOrderExportVO.class, list); + } } \ No newline at end of file diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/module/order/vo/RepairOrderExportVO.java b/dl-module-base/src/main/java/cn/iocoder/yudao/module/order/vo/RepairOrderExportVO.java new file mode 100644 index 00000000..52005d3b --- /dev/null +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/module/order/vo/RepairOrderExportVO.java @@ -0,0 +1,63 @@ +package cn.iocoder.yudao.module.order.vo; + +import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; +import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; +import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; +import com.alibaba.excel.annotation.ExcelProperty; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; + +import java.math.BigDecimal; +import java.time.LocalDateTime; + +import static cn.iocoder.yudao.common.DictBaseConstants.REPAIR_PAY_TYPE; + +/** + * 用于维修订单导出VO + * + * @author 小李 + * @date 17:05 2024/12/3 +**/ +@Data +@ExcelIgnoreUnannotated +public class RepairOrderExportVO { + + @ExcelProperty("订单号") + private String orderNo; + + @ExcelProperty("服务名称") + private String goodsTitle; + + @ExcelProperty("消费类型") + private String goodsType; + + @ExcelProperty("客户姓名") + private String cusName; + + @ExcelProperty("客户手机号") + private String cusPhone; + + @ExcelProperty("商品原价(元)") + private BigDecimal goodsPrice; + + @ExcelProperty("实付金额(元)") + private BigDecimal payMoney; + + @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss") + @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") + @ExcelProperty("下单时间") + private LocalDateTime orderTime; + + @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss") + @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") + @ExcelProperty("支付时间") + private LocalDateTime payTime; + + @ExcelProperty(value = "支付方式", converter = DictConvert.class) + @DictFormat(REPAIR_PAY_TYPE) + private String payType; + + @ExcelProperty("订单状态") + private String orderStatus; +} diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/module/supplier/controller/admin/BaseSupplierController.java b/dl-module-base/src/main/java/cn/iocoder/yudao/module/supplier/controller/admin/BaseSupplierController.java index 106a4fb7..1eac0d2f 100644 --- a/dl-module-base/src/main/java/cn/iocoder/yudao/module/supplier/controller/admin/BaseSupplierController.java +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/module/supplier/controller/admin/BaseSupplierController.java @@ -1,12 +1,16 @@ package cn.iocoder.yudao.module.supplier.controller.admin; +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.ObjectUtil; import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.util.object.BeanUtils; +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; import cn.iocoder.yudao.module.supplier.entity.BaseSupplier; import cn.iocoder.yudao.module.supplier.service.BaseSupplierService; import cn.iocoder.yudao.module.supplier.vo.BaseSupplierPageReqVO; import cn.iocoder.yudao.module.supplier.vo.BaseSupplierRespVO; import cn.iocoder.yudao.module.supplier.vo.BaseSupplierSaveReqVO; +import cn.iocoder.yudao.module.supplier.vo.SupplierExportVO; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; @@ -18,8 +22,15 @@ import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; +import javax.servlet.http.HttpServletResponse; import javax.validation.Valid; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception0; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; @Tag(name = "管理后台 - 供应商") @@ -137,4 +148,40 @@ public class BaseSupplierController { .like(BaseSupplier::getName,name); return success(baseSupplierService.list(queryWrapper)); } + + /** + * 导出数据 + * + * @author 小李 + * @date 17:30 2024/12/2 + * @param pageReqVO 请求对象 + **/ + @GetMapping("/export") + @Operation(summary = "导出数据") + public void exportData(BaseSupplierPageReqVO pageReqVO, HttpServletResponse response)throws IOException { + int pageNo = 1, pageSize = 1000; + List list = new ArrayList<>(); + Page page = new Page<>(pageNo, pageSize); + do { + IPage baseSupplierRespVOIPage = baseSupplierService.queryListPage(pageReqVO, page); + List records = baseSupplierRespVOIPage.getRecords(); + if (CollUtil.isEmpty(records)){ + break; + } + List convertedRecords = records.stream().map(item -> BeanUtils.toBean(item, SupplierExportVO.class)).collect(Collectors.toList()); + list.addAll(convertedRecords); + pageNo++; + page.setCurrent(pageNo); + }while (true); + if (CollUtil.isEmpty(list)){ + throw exception0(500, "没有数据可以导出"); + } + list.forEach(item -> { + if (ObjectUtil.isNotEmpty(item.getStatus())){ + item.setStatus(item.getStatus().equals("01") ? "启用" : "禁用"); + } + item.setCorpId(ObjectUtil.isEmpty(item.getCorpId()) ? "未绑定": "已绑定"); + }); + ExcelUtils.write(response, "供应商数据.xls", "数据", SupplierExportVO.class, list); + } } \ No newline at end of file diff --git a/dl-module-base/src/main/java/cn/iocoder/yudao/module/supplier/vo/SupplierExportVO.java b/dl-module-base/src/main/java/cn/iocoder/yudao/module/supplier/vo/SupplierExportVO.java new file mode 100644 index 00000000..33c0334c --- /dev/null +++ b/dl-module-base/src/main/java/cn/iocoder/yudao/module/supplier/vo/SupplierExportVO.java @@ -0,0 +1,43 @@ +package cn.iocoder.yudao.module.supplier.vo; + +import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; +import com.alibaba.excel.annotation.ExcelProperty; +import lombok.Data; + +/** + * 用于导出供应商VO + * + * @author 小李 + * @date 17:30 2024/12/2 +**/ +@Data +@ExcelIgnoreUnannotated +public class SupplierExportVO { + + @ExcelProperty("供应商名称") + private String name; + + @ExcelProperty("联系人") + private String linkName; + + @ExcelProperty("联系电话") + private String linkPhone; + + @ExcelProperty("手机号码") + private String phone; + + @ExcelProperty("传真") + private String fax; + + @ExcelProperty("地址") + private String address; + + @ExcelProperty("状态") + private String status; + + @ExcelProperty("备注") + private String remark; + + @ExcelProperty("绑定状态") + private String corpId; +} diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/common/RepairDictConstants.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/common/RepairDictConstants.java new file mode 100644 index 00000000..c541d183 --- /dev/null +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/common/RepairDictConstants.java @@ -0,0 +1,37 @@ +package cn.iocoder.yudao.common; + +/** + * 维修相关字典枚举 + * + * @author 小李 + * @date 15:48 2024/11/29 +**/ +public interface RepairDictConstants { + + /** 单位 */ + String REPAIR_UNIT = "repair_unit"; + + /** 配件来源 */ + String WARES_DATA_FORM = "repair_data_form"; + + /** 配件属性 */ + String WARES_ATTRIBUTE = "repair_attribute"; + + /** 配件相关提醒配置 */ + String REPAIR_WARES_NOTICE = "repair_wares_notice"; + + /** 维修工人工种 */ + String REPAIR_WORK_TYPE = "repair_work_type"; + + /** 维修类别 */ + String REPAIR_TYPE = "repair_type"; + + /** 配件申请单审核状态 */ + String TICKET_WARES_STATUS = "ticket_wares_status"; + + /** 库存操作单据状态 */ + String REPAIR_SO_STATUS = "repair_so_status"; + + /** 调拨状态 */ + String REPAIR_ST_STATUS = "repair_st_status"; +} diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/job/WaresStockBelowJob.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/job/WaresStockBelowJob.java new file mode 100644 index 00000000..bb4a8aa6 --- /dev/null +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/job/WaresStockBelowJob.java @@ -0,0 +1,30 @@ +package cn.iocoder.yudao.job; + +import cn.iocoder.yudao.framework.quartz.core.handler.JobHandler; +import cn.iocoder.yudao.framework.tenant.core.job.TenantJob; +import cn.iocoder.yudao.module.project.service.RepairWaresService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; + +/** + * 配件库存低于几个(可以自己设置)需要做库存预警 + * + * @author 小李 + * @date 14:40 2024/11/30 + **/ +@Component +@TenantJob +@Slf4j +public class WaresStockBelowJob implements JobHandler { + + @Resource + private RepairWaresService waresService; + + @Override + public String execute(String param) throws Exception { + waresService.stockBelow(); + return null; + } +} diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/job/WaresTimeOverJob.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/job/WaresTimeOverJob.java new file mode 100644 index 00000000..8e6a37c7 --- /dev/null +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/job/WaresTimeOverJob.java @@ -0,0 +1,32 @@ +package cn.iocoder.yudao.job; + +import cn.iocoder.yudao.framework.quartz.core.handler.JobHandler; +import cn.iocoder.yudao.framework.tenant.core.job.TenantJob; +import cn.iocoder.yudao.module.project.service.RepairWaresService; +import lombok.extern.slf4j.Slf4j; +import org.springframework.context.annotation.Lazy; +import org.springframework.stereotype.Component; + +import javax.annotation.Resource; + +/** + * 配件入库超多少天(可以自己设置)没用的话需要做一个临期提醒 + * + * @author 小李 + * @date 14:40 2024/11/30 +**/ +@Component +@TenantJob +@Slf4j +public class WaresTimeOverJob implements JobHandler { + + @Resource + @Lazy + private RepairWaresService waresService; + + @Override + public String execute(String param) throws Exception { + waresService.timeOver(); + return null; + } +} diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/base/controller/admin/RepairWorkerController.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/base/controller/admin/RepairWorkerController.java index 6c61363e..b298da64 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/base/controller/admin/RepairWorkerController.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/base/controller/admin/RepairWorkerController.java @@ -1,15 +1,19 @@ package cn.iocoder.yudao.module.base.controller.admin; +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.ObjectUtil; import cn.iocoder.yudao.common.MessageSend; import cn.iocoder.yudao.common.dto.MessageDTO; import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.util.object.BeanUtils; +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; import cn.iocoder.yudao.module.app.controller.admin.NotifyMessageSocket; import cn.iocoder.yudao.module.base.entity.RepairWorker; import cn.iocoder.yudao.module.base.service.RepairWorkerService; import cn.iocoder.yudao.module.base.vo.RepairWorkerPageReqVO; import cn.iocoder.yudao.module.base.vo.RepairWorkerRespVO; import cn.iocoder.yudao.module.base.vo.RepairWorkerSaveReqVO; +import cn.iocoder.yudao.module.base.vo.WorkerExportVO; import cn.iocoder.yudao.module.system.api.user.dto.UserDTO; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; @@ -21,11 +25,14 @@ import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; +import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.util.ArrayList; import java.util.List; +import java.util.stream.Collectors; import static cn.iocoder.yudao.common.BaseConstants.QUALS_INTERIM_PERIOD; +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception0; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.ok; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; @@ -168,4 +175,41 @@ public class RepairWorkerController { } return ok(); } + + /** + * 导出数据 + * + * @author 小李 + * @date 17:50 2024/12/2 + * @param pageReqVO 请求对象 + **/ + @GetMapping("/export") + @Operation(summary = "导出数据") + public void exportData(RepairWorkerPageReqVO pageReqVO, HttpServletResponse response)throws IOException{ + int pageNo = 1, pageSize = 1000; + List list = new ArrayList<>(); + Page page = new Page<>(pageNo,pageSize); + do { + IPage repairWorkerRespVOIPage = workerService.queryListPage(pageReqVO, page); + List records = repairWorkerRespVOIPage.getRecords(); + if (CollUtil.isEmpty(records)){ + break; + } + List convertedRecords = records.stream().map(item -> BeanUtils.toBean(item, WorkerExportVO.class)).collect(Collectors.toList()); + list.addAll(convertedRecords); + pageNo++; + page.setCurrent(pageNo); + }while (true); + + if (CollUtil.isEmpty(list)){ + throw exception0(500, "没有数据可以导出"); + } + + list.forEach(item -> { + if (ObjectUtil.isNotEmpty(item.getIsLeads())){ + item.setIsLeads(item.getIsLeads().equals("1") ? "班组长" : "维修工"); + } + }); + ExcelUtils.write(response, "维修工人数据.xls", "数据", WorkerExportVO.class, list); + } } \ No newline at end of file diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/base/vo/WorkerExportVO.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/base/vo/WorkerExportVO.java new file mode 100644 index 00000000..cd56d743 --- /dev/null +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/base/vo/WorkerExportVO.java @@ -0,0 +1,32 @@ +package cn.iocoder.yudao.module.base.vo; + +import cn.iocoder.yudao.common.RepairDictConstants; +import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; +import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; +import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; +import com.alibaba.excel.annotation.ExcelProperty; +import lombok.Data; + +/** + * 用于导出维修工人VO + * + * @author 小李 + * @date 17:45 2024/12/2 +**/ +@Data +@ExcelIgnoreUnannotated +public class WorkerExportVO { + + @ExcelProperty("姓名") + private String userName; + + @ExcelProperty(value = "工种", converter = DictConvert.class) + @DictFormat(RepairDictConstants.REPAIR_WORK_TYPE) + private String workType; + + @ExcelProperty("角色") + private String isLeads; + + @ExcelProperty("备注") + private String remark; +} diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/other/controller/admin/DlRepairOtherController.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/other/controller/admin/DlRepairOtherController.java index bd059a11..41451de2 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/other/controller/admin/DlRepairOtherController.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/other/controller/admin/DlRepairOtherController.java @@ -1,20 +1,30 @@ package cn.iocoder.yudao.module.other.controller.admin; +import cn.hutool.core.collection.CollUtil; import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; import cn.iocoder.yudao.module.other.entity.DlRepairOther; import cn.iocoder.yudao.module.other.service.DlRepairOtherService; import cn.iocoder.yudao.module.other.vo.DlRepairOtherReqVO; import cn.iocoder.yudao.module.other.vo.DlRepairOtherRespVO; +import cn.iocoder.yudao.module.other.vo.OtherExportVO; 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; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.ArrayList; import java.util.Comparator; import java.util.List; +import java.util.stream.Collectors; +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception0; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; /** @@ -84,5 +94,42 @@ public class DlRepairOtherController { List list = dlRepairOtherService.list(new LambdaQueryWrapper().eq(DlRepairOther::getName, name)); return success(list.stream().max(Comparator.comparing(DlRepairOther::getCreateTime)).orElse(null)); } + + /** + * 导出数据 + * + * @author 小李 + * @date 16:39 2024/12/2 + * @param repairOtherReqVO 请求对象 + **/ + @GetMapping("/export") + @Operation(summary = "导出数据") + public void exportData(DlRepairOtherReqVO repairOtherReqVO, HttpServletResponse response) throws IOException { + int pageNo = 1, pageSize = 1000; + List list = new ArrayList<>(); + Page page = new Page<>(pageNo, pageSize); + do { + IPage otherPage = dlRepairOtherService.getOtherPage(repairOtherReqVO, page); + List records = otherPage.getRecords(); + + if (CollUtil.isEmpty(records)){ + break; + } + + List convertedRecords = records.stream() + .map(item -> BeanUtils.toBean(item, OtherExportVO.class)) + .collect(Collectors.toList()); + list.addAll(convertedRecords); + + pageNo++; + page.setCurrent(pageNo); + } while (true); + + if (CollUtil.isEmpty(list)){ + throw exception0(500, "没有数据可以导出"); + } + + ExcelUtils.write(response, "附加数据.xls", "数据", OtherExportVO.class, list); + } } diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/other/vo/OtherExportVO.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/other/vo/OtherExportVO.java new file mode 100644 index 00000000..80f352e6 --- /dev/null +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/other/vo/OtherExportVO.java @@ -0,0 +1,24 @@ +package cn.iocoder.yudao.module.other.vo; + +import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; +import com.alibaba.excel.annotation.ExcelProperty; +import lombok.Data; + +import java.math.BigDecimal; + +/** + * 用于导出维修附加内容的VO + * + * @author 小李 + * @date 16:20 2024/12/2 +**/ +@Data +@ExcelIgnoreUnannotated +public class OtherExportVO { + + @ExcelProperty("名称") + private String name; + + @ExcelProperty("价格") + private BigDecimal price; +} diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/project/controller/admin/RepairProjectController.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/project/controller/admin/RepairProjectController.java index db435e3d..b324a1f2 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/project/controller/admin/RepairProjectController.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/project/controller/admin/RepairProjectController.java @@ -1,28 +1,38 @@ package cn.iocoder.yudao.module.project.controller.admin; +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.ObjectUtil; import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.util.object.BeanUtils; +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; +import cn.iocoder.yudao.module.conf.entity.BaseType; +import cn.iocoder.yudao.module.conf.entity.BaseWarehouse; +import cn.iocoder.yudao.module.conf.service.BaseTypeService; +import cn.iocoder.yudao.module.conf.service.BaseWarehouseService; import cn.iocoder.yudao.module.project.entity.RepairProject; import cn.iocoder.yudao.module.project.service.RepairProjectService; -import cn.iocoder.yudao.module.project.vo.RepairProjectPageReqVO; -import cn.iocoder.yudao.module.project.vo.RepairProjectRespVO; -import cn.iocoder.yudao.module.project.vo.RepairProjectSaveReqVO; +import cn.iocoder.yudao.module.project.vo.*; 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; 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.context.annotation.Lazy; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; +import javax.servlet.http.HttpServletResponse; import javax.validation.Valid; - +import java.io.IOException; +import java.util.ArrayList; import java.util.Comparator; import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception0; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; @Tag(name = "管理后台 - 维修项目") @@ -34,6 +44,14 @@ public class RepairProjectController { @Resource private RepairProjectService repairProjectService; + @Resource + @Lazy + private BaseWarehouseService warehouseService; + + @Resource + @Lazy + private BaseTypeService typeService; + /** * 创建维修项目 * @@ -137,4 +155,46 @@ public class RepairProjectController { public CommonResult getRepairProjectAndCateGory(){ return success(repairProjectService.getRepairProjectAndCateGory()); } + + /** + * 导出数据 + * + * @author 小李 + * @date 17:09 2024/12/2 + * @param pageReqVO 请求对象 + **/ + @GetMapping("/export") + @Operation(summary = "导出数据") + public void exportData(RepairProjectPageReqVO pageReqVO, HttpServletResponse response)throws IOException { + int pageNo = 1, pageSize = 1000; + List list = new ArrayList<>(); + Page page = new Page<>(pageNo, pageSize); + do { + IPage repairProjectRespVOIPage = repairProjectService.queryListPage(pageReqVO, page); + List records = repairProjectRespVOIPage.getRecords(); + + if (CollUtil.isEmpty(records)){ + break; + } + + records.forEach(item -> { + if (ObjectUtil.isNotEmpty(item.getTypeName())){ + item.setType(item.getTypeName()); + } + }); + + List convertedRecords = records.stream().map(item -> BeanUtils.toBean(item, ProjectExportVO.class)).collect(Collectors.toList()); + list.addAll(convertedRecords); + + pageNo++; + page.setCurrent(pageNo); + }while (true); + + if (CollUtil.isEmpty(list)){ + throw exception0(500, "没有数据可以导出"); + } + + ExcelUtils.write(response, "维修项目数据.xls", "数据", ProjectExportVO.class, list); + } + } \ No newline at end of file diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/project/controller/admin/RepairWaresController.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/project/controller/admin/RepairWaresController.java index be4b75ce..163e09bf 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/project/controller/admin/RepairWaresController.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/project/controller/admin/RepairWaresController.java @@ -1,22 +1,42 @@ package cn.iocoder.yudao.module.project.controller.admin; +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.ObjectUtil; import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; +import cn.iocoder.yudao.module.conf.entity.BaseType; +import cn.iocoder.yudao.module.conf.entity.BaseWarehouse; +import cn.iocoder.yudao.module.conf.service.BaseTypeService; +import cn.iocoder.yudao.module.conf.service.BaseWarehouseService; import cn.iocoder.yudao.module.project.entity.RepairWares; import cn.iocoder.yudao.module.project.service.RepairWaresService; -import cn.iocoder.yudao.module.project.vo.RepairWaresPageReqVO; -import cn.iocoder.yudao.module.project.vo.RepairWaresRespVO; -import cn.iocoder.yudao.module.project.vo.RepairWaresSaveReqVO; +import cn.iocoder.yudao.module.project.vo.*; +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; import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.Parameters; import io.swagger.v3.oas.annotations.tags.Tag; +import org.springframework.context.annotation.Lazy; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; import javax.annotation.Resource; +import javax.servlet.http.HttpServletResponse; import javax.validation.Valid; +import java.io.IOException; +import java.math.BigDecimal; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception0; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; @Tag(name = "管理后台 - 配件库") @@ -28,6 +48,14 @@ public class RepairWaresController { @Resource private RepairWaresService waresService; + @Resource + @Lazy + private BaseWarehouseService warehouseService; + + @Resource + @Lazy + private BaseTypeService typeService; + /** * 创建配件库 * @@ -135,4 +163,106 @@ public class RepairWaresController { return success(waresService.getAllTypeList()); } + /** + * 下载配件导入模板 + * + * @author 小李 + * @date 15:35 2024/11/29 + **/ + @GetMapping("/get-import-template") + @Operation(summary = "下载配件导入模板") + public void getImportTemplate(HttpServletResponse response) throws Exception { + List list = Collections.singletonList( + RepairWaresExcelVO + .builder() + .barCode("123") + .code("123") + .name("模板数据") + .model("123") + .price(new BigDecimal("100")) + .purPrice(new BigDecimal("100")) + .type("模板分类") + .unit("01") + .warehouse("模板仓库") + .miniStock(new BigDecimal("0")) + .maxStock(new BigDecimal("10")) + .stock(new BigDecimal("5")) +// .attribute("yc") + .carModel("模板车型") +// .dataForm("bd") + .remark("模板") + .build() + ); + ExcelUtils.write(response, "配件导入模板.xls", "配件信息", RepairWaresExcelVO.class, list); + } + + /** + * 导入配件数据 + * + * @author 小李 + * @date 16:20 2024/11/29 + * @param file Excel 文件 + * @param updateSupport 是否支持更新 + **/ + @PostMapping("/import-data") + @Operation(summary = "导入配件数据") + @Parameters({ + @Parameter(name = "file", description = "Excel 文件", required = true), + @Parameter(name = "updateSupport", description = "是否支持更新,默认为 false", example = "true") + }) + public CommonResult importData(@RequestParam("file") MultipartFile file, + @RequestParam(value = "updateSupport", required = false, defaultValue = "false") Boolean updateSupport) throws Exception{ + List list = ExcelUtils.read(file, RepairWaresExcelVO.class); + return success(waresService.importData(list, updateSupport)); + } + + /** + * 导出数据 + * + * @author 小李 + * @date 17:20 2024/12/2 + * @param pageReqVO 请求对象 + **/ + @GetMapping("/export") + @Operation(summary = "导出数据") + public void exportData(RepairWaresPageReqVO pageReqVO, HttpServletResponse response)throws IOException { + int pageNo = 1, pageSize = 1000; + List list = new ArrayList<>(); + Page page = new Page<>(pageNo, pageSize); + do { + IPage waresPage = waresService.getWaresPage(pageReqVO, page); + List records = waresPage.getRecords(); + + if (CollUtil.isEmpty(records)){ + break; + } + + List convertedRecords = records.stream().map(item -> BeanUtils.toBean(item, RepairWaresExcelVO.class)).collect(Collectors.toList()); + list.addAll(convertedRecords); + + pageNo++; + page.setCurrent(pageNo); + }while (true); + + if (CollUtil.isEmpty(list)){ + throw exception0(500, "没有数据可以导出"); + } + + List warehouses = warehouseService.list(); + Map warehousesMap = warehouses.stream().collect(Collectors.toMap(BaseWarehouse::getId, BaseWarehouse::getName)); + + List types = typeService.list(new LambdaQueryWrapper().eq(BaseType::getType, "02")); + Map typesMap = types.stream().collect(Collectors.toMap(BaseType::getId, BaseType::getName)); + + list.forEach(item -> { + if (ObjectUtil.isNotEmpty(item.getWarehouse()) && ObjectUtil.isNotEmpty(warehousesMap.get(item.getWarehouse()))){ + item.setWarehouse(warehousesMap.get(item.getWarehouse())); + } + if (ObjectUtil.isNotEmpty(item.getType()) && ObjectUtil.isNotEmpty(typesMap.get(item.getType()))){ + item.setType(typesMap.get(item.getType())); + } + }); + + ExcelUtils.write(response, "维修配件数据.xls", "数据", RepairWaresExcelVO.class, list); + } } \ No newline at end of file diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/project/service/RepairWaresService.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/project/service/RepairWaresService.java index cc123d5c..ea7c7f06 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/project/service/RepairWaresService.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/project/service/RepairWaresService.java @@ -1,9 +1,7 @@ package cn.iocoder.yudao.module.project.service; import cn.iocoder.yudao.module.project.entity.RepairWares; -import cn.iocoder.yudao.module.project.vo.RepairWaresPageReqVO; -import cn.iocoder.yudao.module.project.vo.RepairWaresRespVO; -import cn.iocoder.yudao.module.project.vo.RepairWaresSaveReqVO; +import cn.iocoder.yudao.module.project.vo.*; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.IService; @@ -80,4 +78,28 @@ public interface RepairWaresService extends IService { * @return java.util.List **/ List listByIds(List idList); + + /** + * 导入配件数据 + * + * @author 小李 + * @date 16:20 2024/11/29 + **/ + ImportExcelRespVO importData(List list, Boolean updateSupport); + + /** + * 配件入库超多少天(可以自己设置)没用的话需要做一个临期提醒 + * + * @author 小李 + * @date 14:42 2024/11/30 + **/ + void timeOver(); + + /** + * 配件库存低于几个(可以自己设置)需要做库存预警 + * + * @author 小李 + * @date 15:54 2024/11/30 + **/ + void stockBelow(); } \ No newline at end of file diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/project/service/impl/RepairWaresServiceImpl.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/project/service/impl/RepairWaresServiceImpl.java index 62aa262a..4aa8e503 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/project/service/impl/RepairWaresServiceImpl.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/project/service/impl/RepairWaresServiceImpl.java @@ -1,23 +1,40 @@ package cn.iocoder.yudao.module.project.service.impl; +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.ObjectUtil; +import cn.iocoder.yudao.common.RepairDictConstants; +import cn.iocoder.yudao.common.RepairRoleEnum; import cn.iocoder.yudao.framework.common.util.object.BeanUtils; +import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder; +import cn.iocoder.yudao.module.base.service.RepairWorkerService; +import cn.iocoder.yudao.module.conf.entity.BaseType; +import cn.iocoder.yudao.module.conf.entity.BaseWarehouse; +import cn.iocoder.yudao.module.conf.service.BaseTypeService; +import cn.iocoder.yudao.module.conf.service.BaseWarehouseService; import cn.iocoder.yudao.module.project.entity.RepairWares; import cn.iocoder.yudao.module.project.mapper.RepairWaresMapper; import cn.iocoder.yudao.module.project.service.RepairWaresService; -import cn.iocoder.yudao.module.project.vo.RepairWaresPageReqVO; -import cn.iocoder.yudao.module.project.vo.RepairWaresRespVO; -import cn.iocoder.yudao.module.project.vo.RepairWaresSaveReqVO; +import cn.iocoder.yudao.module.project.vo.*; +import cn.iocoder.yudao.module.system.api.dict.DictDataApi; +import cn.iocoder.yudao.module.system.api.dict.dto.DictDataRespDTO; +import cn.iocoder.yudao.module.system.api.permission.RoleApi; +import cn.iocoder.yudao.module.system.api.user.dto.UserDTO; +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 org.apache.commons.lang3.StringUtils; +import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import org.springframework.validation.annotation.Validated; import javax.annotation.Resource; -import java.util.Arrays; -import java.util.List; -import java.util.Map; +import java.time.LocalDateTime; +import java.util.*; +import java.util.stream.Collectors; + +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception0; /** * 配件库 Service 实现类 @@ -31,6 +48,25 @@ public class RepairWaresServiceImpl extends ServiceImpl list, Boolean updateSupport) { + // 参数校验 + if (CollUtil.isEmpty(list)) { + throw exception0(500, "导入配件数据不能为空!"); + } + + // 取所有的仓库变成map,key是名称,value是id + List warehouses = warehouseService.list(); + Map warehousesMap = warehouses.stream().collect(Collectors.toMap(BaseWarehouse::getName, BaseWarehouse::getId)); + + // 取所有的配件类型变成map,key是名称,value是id + List types = typeService.list(new LambdaQueryWrapper().eq(BaseType::getType, "02")); + Map typesMap = types.stream().collect(Collectors.toMap(BaseType::getName, BaseType::getId)); + + // 遍历,逐个创建 or 更新 + ImportExcelRespVO result = ImportExcelRespVO.builder().createNames(new ArrayList<>()) + .updateNames(new ArrayList<>()).failureNames(new LinkedHashMap<>()).build(); + list.forEach(item -> { + // 验证是否存在,用selectList防止本来就有多个导致的报错 + List repairWares = baseMapper.selectList(new LambdaQueryWrapper().eq(RepairWares::getName, item.getName())); + if (CollUtil.isEmpty(repairWares)) { + RepairWares wares = BeanUtils.toBean(item, RepairWares.class); + if (ObjectUtil.isNotEmpty(item.getType()) && ObjectUtil.isNotEmpty(typesMap.get(item.getType()))) { + wares.setType(typesMap.get(item.getType())); + } + if (ObjectUtil.isNotEmpty(item.getWarehouse()) && ObjectUtil.isNotEmpty(warehousesMap.get(item.getWarehouse()))) { + wares.setWarehouse(warehousesMap.get(item.getWarehouse())); + } + wares.setStatus("01"); + baseMapper.insert(wares); + result.getCreateNames().add(item.getName()); + return; + } + // 存在看是否可以修改 + if (!updateSupport) { + result.getFailureNames().put(item.getName(), "不允许修改!"); + return; + } + // 可以修改,看是否有多个相同名称的配件 + if (repairWares.size() > 1) { + result.getFailureNames().put(item.getName(), "存在多个相同名称的配件!"); + return; + } + // 更新 + RepairWares wares = repairWares.get(0); + RepairWares updateWares = BeanUtils.toBean(item, RepairWares.class); + updateWares.setId(wares.getId()); + if (ObjectUtil.isNotEmpty(item.getType()) && ObjectUtil.isNotEmpty(typesMap.get(item.getType()))) { + updateWares.setType(typesMap.get(item.getType())); + } + if (ObjectUtil.isNotEmpty(item.getWarehouse()) && ObjectUtil.isNotEmpty(warehousesMap.get(item.getWarehouse()))) { + updateWares.setWarehouse(warehousesMap.get(item.getWarehouse())); + } + updateWares.setStatus(wares.getStatus()); + baseMapper.updateById(updateWares); + result.getUpdateNames().add(item.getName()); + }); + return result; + } + + /** + * 配件入库超多少天(可以自己设置)没用的话需要做一个临期提醒 + * + * @author 小李 + * @date 14:42 2024/11/30 + **/ + @Override + public void timeOver() { + // 取仓管、维修管理员 + List warehouse = roleApi.selectUserListByRoleCode(TenantContextHolder.getRequiredTenantId(), RepairRoleEnum.WAREHOUSE.getCode()); + List admin = roleApi.selectUserListByRoleCode(TenantContextHolder.getRequiredTenantId(), RepairRoleEnum.ADMIN.getCode()); + // 取配置 + List dataList = dictDataApi.getDictDataList(RepairDictConstants.REPAIR_WARES_NOTICE); + + // 取出第一个 + if (CollUtil.isEmpty(dataList)) { + noticeByFlag(true, admin, warehouse); + return; + } + DictDataRespDTO dictDataRespDTO = dataList.get(0); + String day = dictDataRespDTO.getValue(); + // 转时间,如果updateTime小于这个时间,那就是需要提醒的 + LocalDateTime dateAgo = LocalDateTime.now().minusDays(Integer.parseInt(day)); + + List repairWares = baseMapper.selectList(new LambdaQueryWrapper().le(RepairWares::getUpdateTime, dateAgo)); + if (CollUtil.isNotEmpty(repairWares)) { + List names = repairWares.stream().map(RepairWares::getName).collect(Collectors.toList()); + String result = String.join(",", names); + String message = "以下配件未使用天数超过设定的未使用天数提醒,请及时处理相关事项!" + result; + warehouse.forEach(item -> workerService.sentMessage(item.getId(), message)); + admin.forEach(item -> workerService.sentMessage(item.getId(), message)); + } + } + + /** + * 配件库存低于几个(可以自己设置)需要做库存预警 + * + * @author 小李 + * @date 15:54 2024/11/30 + **/ + @Override + public void stockBelow(){ + // 取仓管、维修管理员 + List warehouse = roleApi.selectUserListByRoleCode(TenantContextHolder.getRequiredTenantId(), RepairRoleEnum.WAREHOUSE.getCode()); + List admin = roleApi.selectUserListByRoleCode(TenantContextHolder.getRequiredTenantId(), RepairRoleEnum.ADMIN.getCode()); + // 取配置 + List dataList = dictDataApi.getDictDataList(RepairDictConstants.REPAIR_WARES_NOTICE); + + // 取出第二个 + if (CollUtil.isEmpty(dataList)) { + noticeByFlag(false, admin, warehouse); + return; + } + DictDataRespDTO dictDataRespDTO = dataList.get(1); + String count = dictDataRespDTO.getValue(); + List repairWares = baseMapper.selectList(new LambdaQueryWrapper().le(RepairWares::getStock, count)); + + if (CollUtil.isNotEmpty(repairWares)) { + List names = repairWares.stream().map(RepairWares::getName).collect(Collectors.toList()); + String result = String.join(",", names); + String message = "以下配件库存低于设定的库存不足提醒,请及时处理相关事项!\n" + result; + warehouse.forEach(item -> workerService.sentMessage(item.getId(), message)); + admin.forEach(item -> workerService.sentMessage(item.getId(), message)); + } + } + + /** + * 上面两个方法公共的通知方法 + * + * @author 小李 + * @date 15:57 2024/11/30 + * @param flag 什么通知 + * @param admin 维修管理员们 + * @param warehouse 仓库管理员们 + **/ + private void noticeByFlag(Boolean flag, List admin, List warehouse){ + String message = flag ? "检查配件入库是否超时出现故障,请联系开发人员解决" : "检查配件库存是否充足出现故障,请联系开发人员解决"; + // 如果为空就通知相关人员出现了问题 + if (CollUtil.isNotEmpty(warehouse)) { + warehouse.forEach(item -> workerService.sentMessage(item.getId(), message)); + } + if (CollUtil.isNotEmpty(admin)) { + admin.forEach(item -> workerService.sentMessage(item.getId(), message)); + } + } } \ No newline at end of file diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/project/vo/ImportExcelRespVO.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/project/vo/ImportExcelRespVO.java new file mode 100644 index 00000000..dcc47210 --- /dev/null +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/project/vo/ImportExcelRespVO.java @@ -0,0 +1,29 @@ +package cn.iocoder.yudao.module.project.vo; + +import lombok.Builder; +import lombok.Data; + +import java.util.List; +import java.util.Map; + +/** + * 导入数据的时候用的通用的响应 + * + * @author 小李 + * @date 16:22 2024/11/29 +**/ +@Data +@Builder +public class ImportExcelRespVO { + + /** 导入成功的配件名称集合 */ + private List createNames; + + /** 更新成功的配件名称集合 */ + private List updateNames; + + /** 导入失败的配件信息,key是配件名称,value是失败原因 */ + private Map failureNames; + + +} diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/project/vo/ProjectExportVO.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/project/vo/ProjectExportVO.java new file mode 100644 index 00000000..67d10018 --- /dev/null +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/project/vo/ProjectExportVO.java @@ -0,0 +1,57 @@ +package cn.iocoder.yudao.module.project.vo; + +import cn.iocoder.yudao.common.RepairDictConstants; +import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; +import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; +import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; +import com.alibaba.excel.annotation.ExcelProperty; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; + +import java.math.BigDecimal; +import java.time.LocalDateTime; + +/** + * 用于导出维修项目的VO + * + * @author 小李 + * @date 17:03 2024/12/2 +**/ +@Data +@ExcelIgnoreUnannotated +public class ProjectExportVO { + + @ExcelProperty("名称") + private String name; + + @ExcelProperty("成本") + private Long cost; + + @ExcelProperty("规格") + private String spec; + + @ExcelProperty("售价") + private BigDecimal price; + + @ExcelProperty("编码") + private String code; + + @ExcelProperty(value = "单位", converter = DictConvert.class) + @DictFormat(RepairDictConstants.REPAIR_UNIT) + private String unit; + + @ExcelProperty("分类") + private String type; + + @ExcelProperty("工时") + private String manHour; + + @ExcelProperty("备注") + private String remark; + + @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss") + @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") + @ExcelProperty("创建时间") + private LocalDateTime createTime; +} diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/project/vo/RepairWaresExcelVO.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/project/vo/RepairWaresExcelVO.java new file mode 100644 index 00000000..6df5ba3b --- /dev/null +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/project/vo/RepairWaresExcelVO.java @@ -0,0 +1,80 @@ +package cn.iocoder.yudao.module.project.vo; + +import cn.iocoder.yudao.common.RepairDictConstants; +import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; +import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; +import com.alibaba.excel.annotation.ExcelProperty; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import lombok.experimental.Accessors; + +import java.math.BigDecimal; + +/** + * 导入、导出excel用的配件VO + * + * @author 小李 + * @date 15:38 2024/11/29 +**/ +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +@Accessors(chain = false) +public class RepairWaresExcelVO { + + @ExcelProperty("条形码") + private String barCode; + + @ExcelProperty("商品编码") + private String code; + + @ExcelProperty("商品名称") + private String name; + + @ExcelProperty("规格型号") + private String model; + + @ExcelProperty("售价") + private BigDecimal price; + + @ExcelProperty("进价") + private BigDecimal purPrice; + + @ExcelProperty("所属分类") + private String type; + + @ExcelProperty(value = "计量单位", converter = DictConvert.class) + @DictFormat(RepairDictConstants.REPAIR_UNIT) + private String unit; + + @ExcelProperty("默认仓库") + private String warehouse; + + @ExcelProperty("最低库存") + private BigDecimal miniStock; + + @ExcelProperty("最高库存") + private BigDecimal maxStock; + + @ExcelProperty("当前库存") + private BigDecimal stock; + + /** 好像找不到这个字典 */ +// @ExcelProperty(value = "配件属性", converter = DictConvert.class) +// @DictFormat(RepairDictConstants.WARES_ATTRIBUTE) +// private String attribute; + + @ExcelProperty("适用车型") + private String carModel; + + /** 好像找不到这个字典 */ +// @ExcelProperty(value = "配件来源", converter = DictConvert.class) +// @DictFormat(RepairDictConstants.WARES_DATA_FORM) +// private String dataForm; + + @ExcelProperty("备注") + private String remark; +} diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockOperate/controller/admin/DlRepairSoController.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockOperate/controller/admin/DlRepairSoController.java index 0185b5be..985ccd56 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockOperate/controller/admin/DlRepairSoController.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockOperate/controller/admin/DlRepairSoController.java @@ -1,17 +1,29 @@ package cn.iocoder.yudao.module.stockOperate.controller.admin; +import cn.hutool.core.collection.CollUtil; import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; import cn.iocoder.yudao.module.stockOperate.entity.DlRepairSo; import cn.iocoder.yudao.module.stockOperate.service.DlRepairSoService; import cn.iocoder.yudao.module.stockOperate.vo.DlRepairSoReqVO; import cn.iocoder.yudao.module.stockOperate.vo.DlRepairSoRespVO; +import cn.iocoder.yudao.module.stockOperate.vo.RepairSoExportVO; +import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import io.swagger.v3.oas.annotations.Operation; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.Collectors; + +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception0; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; /** @@ -144,5 +156,28 @@ public class DlRepairSoController { dlRepairSoService.inWare(repairSoRespVO); return CommonResult.ok(); } + + @GetMapping("/export") + @Operation(summary = "导出数据") + public void exportData(DlRepairSoReqVO repairSoReqVO, HttpServletResponse response)throws IOException { + int pageNo = 1, pageSize = 1000; + List list = new ArrayList<>(); + Page page = new Page<>(pageNo, pageSize); + do { + IPage repairSoPage = dlRepairSoService.getRepairSoPage(repairSoReqVO, page); + List records = repairSoPage.getRecords(); + if (CollUtil.isEmpty(records)){ + break; + } + List convertedRecords = records.stream().map(item -> BeanUtils.toBean(item, RepairSoExportVO.class)).collect(Collectors.toList()); + list.addAll(convertedRecords); + pageNo++; + page.setCurrent(pageNo); + }while (true); + if (CollUtil.isEmpty(list)){ + throw exception0(500, "没有数据可以导出"); + } + ExcelUtils.write(response, "单据数据.xls", "数据", RepairSoExportVO.class, list); + } } diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockOperate/controller/admin/DlRepairSoiController.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockOperate/controller/admin/DlRepairSoiController.java index 5377cc1a..2b1651c8 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockOperate/controller/admin/DlRepairSoiController.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockOperate/controller/admin/DlRepairSoiController.java @@ -1,21 +1,37 @@ package cn.iocoder.yudao.module.stockOperate.controller.admin; +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.ObjectUtil; import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; +import cn.iocoder.yudao.module.conf.entity.BaseWarehouse; +import cn.iocoder.yudao.module.conf.service.BaseWarehouseService; +import cn.iocoder.yudao.module.project.entity.RepairWares; +import cn.iocoder.yudao.module.stockOperate.entity.DlRepairSo; import cn.iocoder.yudao.module.stockOperate.entity.DlRepairSoi; import cn.iocoder.yudao.module.stockOperate.service.DlRepairSoiService; -import cn.iocoder.yudao.module.stockOperate.vo.DlRepairSoiReqVO; +import cn.iocoder.yudao.module.stockOperate.vo.*; +import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import io.swagger.v3.oas.annotations.Operation; +import org.springframework.context.annotation.Lazy; 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 javax.annotation.Resource; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.math.BigDecimal; +import java.util.ArrayList; import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception0; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; /** @@ -32,6 +48,10 @@ public class DlRepairSoiController{ @Resource private DlRepairSoiService dlRepairSoiService; + @Resource + @Lazy + private BaseWarehouseService warehouseService; + /** * 采购单领料单子表 分页 * @@ -88,5 +108,79 @@ public class DlRepairSoiController{ public CommonResult getMapBySoIdAndQuery(@RequestParam("id") String id, @RequestParam("query") String query) { return success(dlRepairSoiService.getMapBySoIdAndQuery(id, query)); } + + /** + * 根据供应商查询该供应商采购过的配件 分页 + * + * @author 小李 + * @date 11:49 2024/11/28 + * @param reqVO 查询对象 + * @param pageNo 页码 + * @param pageSize 条数 + **/ + @GetMapping("/getSoBySupplier") + @Operation(summary = "根据供应商查询该供应商采购过的配件 分页") + public CommonResult getSoBySupplier(DlRepairSoiReqVO reqVO, + @RequestParam(value = "pageNo", defaultValue = "1")Integer pageNo, + @RequestParam(value = "pageSize", defaultValue = "10")Integer pageSize){ + Page page = new Page<>(pageNo, pageSize); + return success(dlRepairSoiService.getSoBySupplier(reqVO, page)); + } + + /** + * 导出数据 + * + * @author 小李 + * @date 16:30 2024/12/3 + **/ + @GetMapping("/export") + @Operation(summary = "导出数据") + public void exportData(DlRepairSoiReqVO repairSoiReqVO, HttpServletResponse response)throws IOException { + int pageNo = 1, pageSize = 1000; + Page page = new Page<>(pageNo, pageSize); + List allList = new ArrayList<>(); + do { + IPage repairSoiPage = dlRepairSoiService.getRepairSoiPage(repairSoiReqVO, page); + List records = repairSoiPage.getRecords(); + if (CollUtil.isEmpty(records)){ + break; + } + allList.addAll(records); + pageNo++; + page.setCurrent(pageNo); + }while (true); + if (CollUtil.isEmpty(allList)){ + throw exception0(500, "没有数据可以导出"); + } + List ids = allList.stream().map(DlRepairSoi::getId).collect(Collectors.toList()); + List repairSoiByIds = dlRepairSoiService.getRepairSoiByIds(ids); + List warehouses = warehouseService.list(); + Map warehousesMap = warehouses.stream().collect(Collectors.toMap(BaseWarehouse::getId, BaseWarehouse::getName)); + List list = repairSoiByIds.stream().map(item -> { + DlRepairSo so = item.getSo(); + RepairWares repairWares = item.getRepairWares(); + RepairSoiExportVO repairSoiExportVO = new RepairSoiExportVO(); + repairSoiExportVO.setSoNo(so.getSoNo()); + repairSoiExportVO.setName(repairWares.getName()); + repairSoiExportVO.setUserName(so.getUserName()); + repairSoiExportVO.setCode(repairWares.getCode()); + repairSoiExportVO.setBarCode(repairWares.getBarCode()); + repairSoiExportVO.setModel(repairWares.getModel()); + repairSoiExportVO.setGoodsCount(item.getGoodsCount()); + repairSoiExportVO.setGoodsPrice(item.getGoodsPrice()); + BigDecimal goodsPrice = ObjectUtil.isNotEmpty(item.getGoodsPrice()) ? item.getGoodsPrice() : BigDecimal.ZERO; + int goodsCount = ObjectUtil.isNotEmpty(item.getGoodsCount()) ? item.getGoodsCount() : 0; + repairSoiExportVO.setTotal(goodsPrice.multiply(BigDecimal.valueOf(goodsCount))); + repairSoiExportVO.setSupplierName(so.getSupplierName()); + if (ObjectUtil.isNotEmpty(item.getWareId())) { + repairSoiExportVO.setWarehouseName(warehousesMap.get(item.getWareId())); + } + repairSoiExportVO.setCropId(so.getCorpId()); + repairSoiExportVO.setCreateTime(so.getCreateTime()); + repairSoiExportVO.setRemark(item.getRemark()); + return repairSoiExportVO; + }).collect(Collectors.toList()); + ExcelUtils.write(response, "作废单据数据.xls", "数据", RepairSoiExportVO.class, list); + } } diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockOperate/mapper/DlRepairSoiMapper.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockOperate/mapper/DlRepairSoiMapper.java index 2868f656..7666f785 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockOperate/mapper/DlRepairSoiMapper.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockOperate/mapper/DlRepairSoiMapper.java @@ -36,6 +36,15 @@ public interface DlRepairSoiMapper extends BaseMapper { * @param id id **/ List getMapBySoIdAndQuery(@Param("id") String id, @Param("query") String query); + + /** + * 根据供应商查询该供应商采购过的配件 + * + * @author 小李 + * @date 11:49 2024/11/28 + * @param reqVO 查询对象 + **/ + IPage getSoBySupplier(@Param("map") DlRepairSoiReqVO reqVO, Page page); } diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockOperate/service/DlRepairSoiService.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockOperate/service/DlRepairSoiService.java index 6111b3b9..b80fed2a 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockOperate/service/DlRepairSoiService.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockOperate/service/DlRepairSoiService.java @@ -64,4 +64,13 @@ public interface DlRepairSoiService extends IService { * @param id id **/ Map> getMapBySoIdAndQuery(String id, String query); + + /** + * 根据供应商查询该供应商采购过的配件 + * + * @author 小李 + * @date 11:49 2024/11/28 + * @param reqVO 查询对象 + **/ + IPage getSoBySupplier(DlRepairSoiReqVO reqVO, Page page); } diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockOperate/service/impl/DlRepairSoServiceImpl.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockOperate/service/impl/DlRepairSoServiceImpl.java index 7607bf79..eb1de94e 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockOperate/service/impl/DlRepairSoServiceImpl.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockOperate/service/impl/DlRepairSoServiceImpl.java @@ -3,9 +3,7 @@ package cn.iocoder.yudao.module.stockOperate.service.impl; import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.util.ObjectUtil; -import cn.iocoder.yudao.common.RecordTypeEnum; -import cn.iocoder.yudao.common.RepairErrorCodeConstants; -import cn.iocoder.yudao.common.SoStatusEnum; +import cn.iocoder.yudao.common.*; import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils; import cn.iocoder.yudao.module.base.service.RepairRecordsService; import cn.iocoder.yudao.module.base.service.RepairWorkerService; @@ -26,6 +24,7 @@ import cn.iocoder.yudao.module.system.api.dept.DeptApi; import cn.iocoder.yudao.module.system.api.dept.dto.DeptRespDTO; import cn.iocoder.yudao.module.system.api.user.AdminUserApi; import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; +import cn.iocoder.yudao.module.tickets.entity.DlRepairTitem; import cn.iocoder.yudao.module.tickets.entity.DlTicketWares; import cn.iocoder.yudao.module.tickets.entity.DlTwItem; import cn.iocoder.yudao.module.tickets.service.DlRepairTicketsService; @@ -120,14 +119,6 @@ public class DlRepairSoServiceImpl extends ServiceImpl { -// if (item.getGoodsPrice() == null){ -// throw exception0(500, "有配件未设置进价"); -// } -// }); -// } //保存供应商 if (StringUtils.isEmpty(repairSoRespVO.getSupplierId())) { //采购单中录入供应商或无供应商情况 @@ -151,6 +142,12 @@ public class DlRepairSoServiceImpl extends ServiceImpl { item.setSoId(repairSoRespVO.getId()); -// item.setSoiType(repairSoRespVO.getSoType()); }); repairSoiService.saveBatch(repairSoRespVO.getGoodsList()); @@ -171,30 +167,6 @@ public class DlRepairSoServiceImpl extends ServiceImpl waresList = repairSoRespVO.getWaresList(); waresService.updateBatchById(waresList); - - // 操作配件库存表---应该是弃用了 - // 获取所有需要操作的数据----生成采购单的时候,不直接操作库存,放到下面的inWares方法去操作 -// if (repairSoRespVO.getSoType() != null && !repairSoRespVO.getSoType().equals("01")){ -// List goodsList = repairSoRespVO.getGoodsList(); -// List ids = goodsList.stream().map(DlRepairSoi::getGoodsId).collect(Collectors.toList()); -// List repairWares = waresService.listByIds(ids); -// // 更新库存和进价 -// List newWares = repairWares.stream().map(item -> { -// // 取数据 -// DlRepairSoi repairSoi = goodsList.stream().filter(i -> i.getGoodsId().equals(item.getId())).collect(Collectors.toList()).get(0); -// // 设置新值 -// // 如果是采购入库,数量+,如果是领料出库,数量- -// // 01, 03 是采购 02 是领料 -// BigDecimal count = new BigDecimal(repairSoi.getGoodsCount()); -// RepairWares wares = new RepairWares(); -// wares.setId(item.getId()); -// wares.setStock("02".equals(repairSoRespVO.getSoType()) ? item.getStock().subtract(count) : item.getStock().add(count)); -// // 更新进价 -// wares.setPurPrice(repairSoi.getGoodsPrice()); -// return wares; -// }).collect(Collectors.toList()); -// waresService.updateBatchById(newWares); -// } } /** @@ -219,14 +191,20 @@ public class DlRepairSoServiceImpl extends ServiceImpl() - .set(DlRepairSo::getSoStatus, SoStatusEnum.DEPRECATED.getCode()) - .and(i -> - i.eq(DlRepairSo::getId, repairSoReqVO.getId()) - .ne(DlRepairSo::getSoStatus, SoStatusEnum.DEPRECATED.getCode()) - .ne(DlRepairSo::getSoStatus, SoStatusEnum.PICKED.getCode()) - .ne(DlRepairSo::getSoStatus, SoStatusEnum.RETURNED.getCode()) - )); + LambdaUpdateWrapper wrapper = new LambdaUpdateWrapper<>(); + wrapper.set(DlRepairSo::getSoStatus, SoStatusEnum.DEPRECATED.getCode()); + String userRole = ticketsService.getUserRole(); + if (RepairRoleEnum.WAREHOUSE.getCode().equals(userRole)) { + wrapper.eq(DlRepairSo::getId, repairSoReqVO.getId()); + } else { + wrapper.and(i -> + i.eq(DlRepairSo::getId, repairSoReqVO.getId()) + .ne(DlRepairSo::getSoStatus, SoStatusEnum.DEPRECATED.getCode()) + .ne(DlRepairSo::getSoStatus, SoStatusEnum.PICKED.getCode()) + .ne(DlRepairSo::getSoStatus, SoStatusEnum.RETURNED.getCode()) + ); + } + int update = baseMapper.update(wrapper); if (update == 0) { throw exception0(500, "该单据已有其他人操作"); } @@ -348,21 +326,23 @@ public class DlRepairSoServiceImpl extends ServiceImpl list = twItemService.list(new LambdaQueryWrapper().eq(DlTwItem::getTwId, so.getTwId())); - // 判断是部分完成还是全部完成----不需要判断了 -// DlTicketWares dlTicketWares = new DlTicketWares(); -// dlTicketWares.setId(so.getTwId()); -// List flag = list.stream().filter(item -> !item.getWaresStatus().equals("01")).collect(Collectors.toList()); -// dlTicketWares.setStatus(CollectionUtil.isEmpty(flag) ? "03" : "04"); - // 更新主表的状态 -// ticketWaresService.updateById(dlTicketWares); + List sois = repairSoiService.list(new LambdaQueryWrapper().eq(DlRepairSoi::getSoId, id)); + //本次领料的配件id + Set waresIds = sois.stream().map(DlRepairSoi::getGoodsId).collect(Collectors.toSet()); + //配件库的数据集合 + List repairWares = repairWaresService.listByIds(waresIds); + List list = sois.stream().map(item -> { + DlRepairSoiRespVO bean = BeanUtil.toBean(item, DlRepairSoiRespVO.class); + repairWares.stream().filter(i -> i.getId().equals(item.getGoodsId())).findFirst().ifPresent(bean::setWares); + return bean; + }).collect(Collectors.toList()); + + /* 这里添加新逻辑,员工确认领料时,把领的配件添加进工单子表---start */ + this.dealWareItem(true,so.getTwId(),sois,repairWares); + /* 这里添加新逻辑,员工确认领料时,把领的配件添加进工单子表---end */ // 通知仓库 repairWorkerService.sentMessage(Long.valueOf(so.getCreator()), so.getUserName() + "已确认领料单:" + so.getSoNo()); @@ -371,20 +351,24 @@ public class DlRepairSoServiceImpl extends ServiceImpl nameAndCount = list.stream().map(item -> item.getWaresName() + "x" + item.getWaresCount()).collect(Collectors.toList()); - remark += "确认领料" + String.join(";", nameAndCount); + for (int i = 0; i < list.size(); i++) { + DlRepairSoiRespVO item = list.get(i); + if (ObjectUtil.isNotEmpty(item.getWares())) { + remark.append(i + 1).append(".").append(item.getWares().getName()).append("x").append(item.getGoodsCount()).append("; "); + } + } // 记录日志 - recordsService.saveRepairRecord(byId.getTicketId(), null, RecordTypeEnum.LL.getCode(), remark, image); + recordsService.saveRepairRecord(byId.getTicketId(), null, RecordTypeEnum.LL.getCode(), remark.toString(), image); // 更新工单主表时间 - if (ObjectUtil.isNotEmpty(so) && ObjectUtil.isNotEmpty(so.getTwId())){ + if (ObjectUtil.isNotEmpty(so) && ObjectUtil.isNotEmpty(so.getTwId())) { DlTicketWares ticketWares = ticketWaresService.getById(so.getTwId()); - if (ObjectUtil.isNotEmpty(ticketWares) && ObjectUtil.isNotEmpty(ticketWares.getTicketId())){ + if (ObjectUtil.isNotEmpty(ticketWares) && ObjectUtil.isNotEmpty(ticketWares.getTicketId())) { ticketsService.refreshUpdateTime(ticketWares.getTicketId()); } } @@ -407,7 +391,7 @@ public class DlRepairSoServiceImpl extends ServiceImpl list = twItemService.list(new LambdaQueryWrapper().eq(DlTwItem::getTwId, newSo.getTwId())); + List sois = repairSoiService.list(new LambdaQueryWrapper().eq(DlRepairSoi::getSoId, id)); + Set waresIds = sois.stream().map(DlRepairSoi::getGoodsId).collect(Collectors.toSet()); + List repairWares = repairWaresService.listByIds(waresIds); + List list = sois.stream().map(item -> { + DlRepairSoiRespVO bean = BeanUtil.toBean(item, DlRepairSoiRespVO.class); + repairWares.stream().filter(i -> i.getId().equals(item.getGoodsId())).findFirst().ifPresent(bean::setWares); + return bean; + }).collect(Collectors.toList()); // 查申请表 DlTicketWares byId = ticketWaresService.getById(newSo.getTwId()); // 取当前操作人的名称 - String remark = SecurityFrameworkUtils.getLoginUserNickname(); + StringBuilder remark = new StringBuilder("确认退料: "); + + /* 这里添加新逻辑,员工确认退料时,把退的配件从工单子表中删除---start */ + this.dealWareItem(false,newSo.getTwId(),sois,repairWares); + /* 这里添加新逻辑,员工确认退料时,把退的配件从工单子表中删除---end */ + // 构建备注 /* 谁,退了什么配件,退了多少个 */ - List nameAndCount = list.stream().map(item -> item.getWaresName() + "(" + item.getWaresCount() + ")").collect(Collectors.toList()); - remark += "确认退料" + String.join(",", nameAndCount); + for (int i = 0; i < list.size(); i++) { + DlRepairSoiRespVO item = list.get(i); + if (ObjectUtil.isNotEmpty(item.getWares())) { + remark.append(i + 1).append(".").append(item.getWares().getName()).append("x").append(item.getGoodsCount()).append("; "); + } + } // 记录日志 - recordsService.saveRepairRecord(byId.getTicketId(), null, RecordTypeEnum.TL.getCode(), remark, image); + recordsService.saveRepairRecord(byId.getTicketId(), null, RecordTypeEnum.TL.getCode(), remark.toString(), image); // 更新工单主表时间 - if (ObjectUtil.isNotEmpty(newSo) && ObjectUtil.isNotEmpty(newSo.getTwId())){ + if (ObjectUtil.isNotEmpty(newSo) && ObjectUtil.isNotEmpty(newSo.getTwId())) { DlTicketWares ticketWares = ticketWaresService.getById(newSo.getTwId()); - if (ObjectUtil.isNotEmpty(ticketWares) && ObjectUtil.isNotEmpty(ticketWares.getTicketId())){ + if (ObjectUtil.isNotEmpty(ticketWares) && ObjectUtil.isNotEmpty(ticketWares.getTicketId())) { ticketsService.refreshUpdateTime(ticketWares.getTicketId()); } } } + /** + * 领料、退料计算工单子表的通用方法 + * @author vinjor-M + * @date 14:31 2024/12/4 + * @param ifGet 是否是领料 + * @param applyId 配件申请单id + * @param sois 领料单、退料单配件明细 + * @param repairWares 配件库的明细 + **/ + private void dealWareItem(Boolean ifGet,String applyId,List sois,List repairWares){ + //配件申请单 + DlTicketWares dlTicketWares = ticketWaresService.getById(applyId); + //工单现有的配件 + List titems = titemService.list(new LambdaQueryWrapper().and(i -> { + i.eq(DlRepairTitem::getTicketId,dlTicketWares.getTicketId()) + .eq(DlRepairTitem::getItemType, "02"); + })); + //更新或插入的数据集合 + List saveOrUpdateList = new ArrayList<>(); + //删除的数据id集合 + List delIdList = new ArrayList<>(); + //工单现有配件转MAP + Map itemMap = titems.stream().collect(Collectors.toMap(DlRepairTitem::getPartId,Function.identity())); + //配件库的数据集合转MAP + Map repairWaresMap = repairWares.stream().collect(Collectors.toMap(RepairWares::getId,Function.identity())); + //遍历本次领料/退料的所有配件 + for (DlRepairSoi repairSoi:sois){ + if(itemMap.containsKey(repairSoi.getGoodsId())){ + //工单中有这个配件 + if(ifGet){ + //领料 + //工单现有配件中就有这个领取的配件,需要更新这个配件的数量、价格 + DlRepairTitem item = itemMap.get(repairSoi.getGoodsId()); + item.setItemCount(item.getItemCount() + repairSoi.getGoodsCount()); + item.setItemMoney(item.getItemPrice().multiply(BigDecimal.valueOf(item.getItemCount())).multiply(item.getItemDiscount())); + item.setItemStatus(TicketsItemStatusEnum.RECEIVED.getCode()); + saveOrUpdateList.add(item); + }else{ + //退料 + //工单现有配件中就有这个领取的配件,需要更新这个配件的数量、价格 + DlRepairTitem item = itemMap.get(repairSoi.getGoodsId()); + if(item.getItemCount()>repairSoi.getGoodsCount()){ + //现有数量大于要退的数量,扣掉 + item.setItemCount(item.getItemCount() - repairSoi.getGoodsCount()); + item.setItemMoney(item.getItemPrice().multiply(BigDecimal.valueOf(item.getItemCount())).multiply(item.getItemDiscount())); + item.setItemStatus(TicketsItemStatusEnum.RECEIVED.getCode()); + saveOrUpdateList.add(item); + }else{ + //现有数量小于或等于要退的数量,直接将这个配件删掉 + delIdList.add(item.getId()); + } + } + }else{ + //工单中没有这个配件 + if (ifGet) { + //领料,需要把这个配件添加到工单子表中 + //配件库的对象 + RepairWares waresItem = repairWaresMap.get(repairSoi.getGoodsId()); + //工单子表对象 + DlRepairTitem titem = new DlRepairTitem(); + titem.setTicketId(dlTicketWares.getTicketId()); + titem.setItemType("02"); + titem.setItemName(waresItem.getName()); + titem.setItemCount(repairSoi.getGoodsCount()); + titem.setItemUnit(waresItem.getUnit()); + //优先取领配件的价格,再取配件库的价格, + BigDecimal itemPrice = null != repairSoi.getGoodsPrice() ? repairSoi.getGoodsPrice() : (null != waresItem.getPrice() ? waresItem.getPrice() : BigDecimal.ZERO); + titem.setItemPrice(itemPrice); + titem.setItemDiscount(BigDecimal.ONE); + titem.setItemMoney(titem.getItemPrice().multiply(BigDecimal.valueOf(titem.getItemCount())).multiply(titem.getItemDiscount())); + titem.setRepairIds(String.valueOf(dlTicketWares.getRepairId())); + titem.setRepairNames(dlTicketWares.getRepairName()); + titem.setSaleId(dlTicketWares.getAdviserId()); + titem.setSaleName(dlTicketWares.getAdviserName()); + titem.setPartId(repairSoi.getGoodsId()); + titem.setItemStatus(TicketsItemStatusEnum.RECEIVED.getCode()); + saveOrUpdateList.add(titem); + }else{ + //退料,不可能出现,没领料就退料的情况,不用处理 + } + } + } + if(!saveOrUpdateList.isEmpty()){ + titemService.saveOrUpdateBatch(saveOrUpdateList); + } + if(!delIdList.isEmpty()){ + titemService.removeBatchByIds(delIdList); + } + //重新计算工单的价格和订单的价格 + ticketsService.computeTicket(dlTicketWares.getTicketId()); + } + /** * 采购入库 * diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockOperate/service/impl/DlRepairSoiServiceImpl.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockOperate/service/impl/DlRepairSoiServiceImpl.java index ed0ad7d2..876e823e 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockOperate/service/impl/DlRepairSoiServiceImpl.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockOperate/service/impl/DlRepairSoiServiceImpl.java @@ -18,6 +18,7 @@ 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.sun.xml.bind.v2.TODO; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; @@ -166,6 +167,18 @@ public class DlRepairSoiServiceImpl extends ServiceImpl getSoBySupplier(DlRepairSoiReqVO reqVO, Page page){ + return baseMapper.getSoBySupplier(reqVO, page); + } } diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockOperate/vo/DlRepairSoiReqVO.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockOperate/vo/DlRepairSoiReqVO.java index 1f267e3c..1c4dbbf5 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockOperate/vo/DlRepairSoiReqVO.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockOperate/vo/DlRepairSoiReqVO.java @@ -29,4 +29,7 @@ public class DlRepairSoiReqVO extends DlRepairSoi { @Schema(pattern = "查询关键字") private String query; + + /** 供应商ID */ + private String supplierId; } diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockOperate/vo/RepairSoExportVO.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockOperate/vo/RepairSoExportVO.java new file mode 100644 index 00000000..cc49caff --- /dev/null +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockOperate/vo/RepairSoExportVO.java @@ -0,0 +1,59 @@ +package cn.iocoder.yudao.module.stockOperate.vo; + +import cn.iocoder.yudao.common.RepairDictConstants; +import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; +import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; +import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; +import com.alibaba.excel.annotation.ExcelProperty; +import com.baomidou.mybatisplus.annotation.TableField; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; + +import java.math.BigDecimal; +import java.time.LocalDateTime; +import java.util.Date; + +/** + * 用于采购单导出VO + * + * @author 小李 + * @date 16:03 2024/12/3 +**/ +@Data +@ExcelIgnoreUnannotated +public class RepairSoExportVO { + + /** + * 单据编号;自动生成 + */ + @ExcelProperty("单号") + private String soNo; + + @ExcelProperty("供应商") + private String supplierName; + + @ExcelProperty("操作人") + private String userName; + + @ExcelProperty("数量") + private Integer itemCount; + + @ExcelProperty("金额") + private BigDecimal totalPrice; + + @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") + @DateTimeFormat(pattern="yyyy-MM-dd") + @ExcelProperty("创建时间") + private LocalDateTime createTime; + + @ExcelProperty(value = "状态", converter = DictConvert.class) + @DictFormat(RepairDictConstants.REPAIR_SO_STATUS) + private String soStatus; + + @ExcelProperty("备注") + private String remark; + + @ExcelProperty("门店") + private String corpName; +} diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockOperate/vo/RepairSoiExportVO.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockOperate/vo/RepairSoiExportVO.java new file mode 100644 index 00000000..34a8aac3 --- /dev/null +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockOperate/vo/RepairSoiExportVO.java @@ -0,0 +1,65 @@ +package cn.iocoder.yudao.module.stockOperate.vo; + +import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; +import com.alibaba.excel.annotation.ExcelProperty; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; + +import java.math.BigDecimal; +import java.time.LocalDateTime; + +/** + * 用于导出库存操作子表的VO + * + * @author 小李 + * @date 16:32 2024/12/3 +**/ +@Data +@ExcelIgnoreUnannotated +public class RepairSoiExportVO { + + @ExcelProperty("单号") + private String soNo; + + @ExcelProperty("商品名称") + private String name; + + @ExcelProperty("操作人") + private String userName; + + @ExcelProperty("商品编码") + private String code; + + @ExcelProperty("条形码") + private String barCode; + + @ExcelProperty("规格") + private String model; + + @ExcelProperty("数量") + private Integer goodsCount; + + @ExcelProperty("价格") + private BigDecimal goodsPrice; + + @ExcelProperty("合计") + private BigDecimal total; + + @ExcelProperty("供应商") + private String supplierName; + + @ExcelProperty("仓库") + private String warehouseName; + + @ExcelProperty("门店") + private String cropId; + + @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") + @DateTimeFormat(pattern="yyyy-MM-dd") + @ExcelProperty("时间") + private LocalDateTime createTime; + + @ExcelProperty("备注") + private String remark; +} diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockTransfer/controller/admin/DlRepairStController.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockTransfer/controller/admin/DlRepairStController.java index 9adb14a2..7f8681eb 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockTransfer/controller/admin/DlRepairStController.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockTransfer/controller/admin/DlRepairStController.java @@ -1,17 +1,34 @@ package cn.iocoder.yudao.module.stockTransfer.controller.admin; +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.ObjectUtil; import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; +import cn.iocoder.yudao.module.company.entity.Company; +import cn.iocoder.yudao.module.company.service.CompanyService; import cn.iocoder.yudao.module.stockTransfer.entity.DlRepairSt; import cn.iocoder.yudao.module.stockTransfer.service.DlRepairStService; import cn.iocoder.yudao.module.stockTransfer.vo.DlRepairStReqVO; import cn.iocoder.yudao.module.stockTransfer.vo.DlRepairStRespVO; +import cn.iocoder.yudao.module.stockTransfer.vo.RepairStExportVO; +import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import io.swagger.v3.oas.annotations.Operation; +import org.springframework.context.annotation.Lazy; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; + +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception0; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; /** @@ -28,6 +45,10 @@ public class DlRepairStController{ @Resource private DlRepairStService dlRepairStService; + @Resource + @Lazy + private CompanyService companyService; + /** * 调拨单 新增 * @@ -86,5 +107,45 @@ public class DlRepairStController{ public CommonResult getSt(@RequestParam("id") String id){ return success(dlRepairStService.getSt(id)); } + + /** + * 导出数据 + * + * @author 小李 + * @date 17:26 2024/12/3 + * @param repairStReqVO 请求对象 + **/ + @GetMapping("/export") + @Operation(summary = "导出数据") + public void exportData(DlRepairStReqVO repairStReqVO, HttpServletResponse response)throws IOException { + int pageNo = 1, pageSize = 1000; + List list = new ArrayList<>(); + Page page = new Page<>(pageNo, pageSize); + do { + IPage stPage = dlRepairStService.getStPage(repairStReqVO, page); + List records = stPage.getRecords(); + if (CollUtil.isEmpty(records)){ + break; + } + List convertedRecords = records.stream().map(item -> BeanUtils.toBean(item, RepairStExportVO.class)).collect(Collectors.toList()); + list.addAll(convertedRecords); + pageNo++; + page.setCurrent(pageNo); + }while (true); + if (CollUtil.isEmpty(list)){ + throw exception0(500, "没有数据可以导出"); + } + List companies = companyService.list(); + Map companyMap = companies.stream().collect(Collectors.toMap(Company::getId, Company::getCorpName)); + list.forEach(item -> { + if (ObjectUtil.isNotEmpty(item.getInCorpId()) && ObjectUtil.isNotEmpty(companyMap.get(item.getInCorpId()))){ + item.setInCorpId(companyMap.get(item.getInCorpId())); + } + if (ObjectUtil.isNotEmpty(item.getOutCorpId()) && ObjectUtil.isNotEmpty(companyMap.get(item.getOutCorpId()))){ + item.setOutCorpId(companyMap.get(item.getOutCorpId())); + } + }); + ExcelUtils.write(response, "单据数据.xls", "数据", RepairStExportVO.class, list); + } } diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockTransfer/controller/admin/DlRepairStiController.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockTransfer/controller/admin/DlRepairStiController.java index 0c7a915a..31336e14 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockTransfer/controller/admin/DlRepairStiController.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockTransfer/controller/admin/DlRepairStiController.java @@ -1,21 +1,39 @@ package cn.iocoder.yudao.module.stockTransfer.controller.admin; +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.ObjectUtil; import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; +import cn.iocoder.yudao.module.company.entity.Company; +import cn.iocoder.yudao.module.company.service.CompanyService; +import cn.iocoder.yudao.module.project.entity.RepairWares; +import cn.iocoder.yudao.module.stockTransfer.entity.DlRepairSt; import cn.iocoder.yudao.module.stockTransfer.entity.DlRepairSti; import cn.iocoder.yudao.module.stockTransfer.service.DlRepairStiService; +import cn.iocoder.yudao.module.stockTransfer.vo.DlRepairStiQueryVO; import cn.iocoder.yudao.module.stockTransfer.vo.DlRepairStiReqVO; +import cn.iocoder.yudao.module.stockTransfer.vo.RepairSoiExportVO; +import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import io.swagger.v3.oas.annotations.Operation; +import org.springframework.context.annotation.Lazy; 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 javax.annotation.Resource; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.math.BigDecimal; +import java.util.ArrayList; import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception0; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; /** @@ -32,6 +50,10 @@ public class DlRepairStiController{ @Resource private DlRepairStiService dlRepairStiService; + @Resource + @Lazy + private CompanyService companyService; + /** * 调拨单子表 分页 * @@ -62,5 +84,64 @@ public class DlRepairStiController{ public CommonResult getStIsWares(@RequestParam("ids") List ids){ return success(dlRepairStiService.getStIsWares(ids)); } + + /** + * 导出数据 + * + * @author 小李 + * @date 17:43 2024/12/3 + * @param repairStiReqVO 请求对象 + **/ + @GetMapping("/export") + @Operation(summary = "导出数据") + public void exportData(DlRepairStiReqVO repairStiReqVO, HttpServletResponse response)throws IOException { + int pageNo = 1, pageSize = 1000; + Page page = new Page<>(pageNo, pageSize); + List allList = new ArrayList<>(); + do { + IPage stiPage = dlRepairStiService.getStiPage(repairStiReqVO, page); + List records = stiPage.getRecords(); + if (CollUtil.isEmpty(records)){ + break; + } + allList.addAll(records); + pageNo++; + page.setCurrent(pageNo); + }while (true); + if (CollUtil.isEmpty(allList)){ + throw exception0(500, "没有数据可以导出"); + } + List companies = companyService.list(); + Map companyMap = companies.stream().collect(Collectors.toMap(Company::getId, Company::getCorpName)); + List ids = allList.stream().map(DlRepairSti::getId).collect(Collectors.toList()); + List stIsWares = dlRepairStiService.getStIsWares(ids); + List list = stIsWares.stream().map(item -> { + RepairSoiExportVO repairSoiExportVO = new RepairSoiExportVO(); + DlRepairSt st = item.getSt(); + RepairWares wares = item.getWares(); + repairSoiExportVO.setStNo(st.getStNo()); + repairSoiExportVO.setName(wares.getName()); + repairSoiExportVO.setModel(wares.getModel()); + repairSoiExportVO.setCode(wares.getCode()); + repairSoiExportVO.setBarCode(wares.getBarCode()); + repairSoiExportVO.setGoodsCount(item.getGoodsCount()); + repairSoiExportVO.setPrice(wares.getPrice()); + int goodsCount = ObjectUtil.isNotEmpty(item.getGoodsCount()) ? item.getGoodsCount() : 0; + BigDecimal price = ObjectUtil.isNotEmpty(wares.getPrice()) ? wares.getPrice() : BigDecimal.ZERO; + repairSoiExportVO.setTotalPrice(price.multiply(BigDecimal.valueOf(goodsCount))); + repairSoiExportVO.setGoodsPrice(item.getGoodsPrice()); + repairSoiExportVO.setUserName(st.getUserName()); + if (ObjectUtil.isNotEmpty(st.getInCorpId()) && ObjectUtil.isNotEmpty(companyMap.get(st.getInCorpId()))) { + repairSoiExportVO.setInCorpId(companyMap.get(st.getInCorpId())); + } + if (ObjectUtil.isNotEmpty(st.getOutCorpId()) && ObjectUtil.isNotEmpty(companyMap.get(st.getOutCorpId()))) { + repairSoiExportVO.setOutCorpId(companyMap.get(st.getOutCorpId())); + } + repairSoiExportVO.setStTime(st.getStTime()); + repairSoiExportVO.setRemark(item.getRemark()); + return repairSoiExportVO; + }).collect(Collectors.toList()); + ExcelUtils.write(response, "调拨详细数据.xls", "数据", RepairSoiExportVO.class, list); + } } diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockTransfer/vo/RepairSoiExportVO.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockTransfer/vo/RepairSoiExportVO.java new file mode 100644 index 00000000..893bacc0 --- /dev/null +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockTransfer/vo/RepairSoiExportVO.java @@ -0,0 +1,66 @@ +package cn.iocoder.yudao.module.stockTransfer.vo; + +import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; +import com.alibaba.excel.annotation.ExcelProperty; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; + +import java.math.BigDecimal; +import java.time.LocalDateTime; +import java.util.Date; + +/** + * 用于调拨单子表导出VO + * + * @author 小李 + * @date 17:43 2024/12/3 +**/ +@Data +@ExcelIgnoreUnannotated +public class RepairSoiExportVO { + + @ExcelProperty("单号") + private String stNo; + + @ExcelProperty("商品名称") + private String name; + + @ExcelProperty("规格") + private String model; + + @ExcelProperty("商品编码") + private String code; + + @ExcelProperty("条形码") + private String barCode; + + @ExcelProperty("数量") + private Integer goodsCount; + + @ExcelProperty("成本") + private BigDecimal price; + + @ExcelProperty("金额") + private BigDecimal goodsPrice; + + @ExcelProperty("合计金额") + private BigDecimal totalPrice; + + @ExcelProperty("负责人") + private String userName; + + @ExcelProperty("调出门店") + private String outCorpId; + + @ExcelProperty("调入门店") + private String inCorpId; + + @ExcelProperty("调拨时间") + @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss") + @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss") + private Date stTime; + + @ExcelProperty("备注") + private String remark; +} diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockTransfer/vo/RepairStExportVO.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockTransfer/vo/RepairStExportVO.java new file mode 100644 index 00000000..be8e03a8 --- /dev/null +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/stockTransfer/vo/RepairStExportVO.java @@ -0,0 +1,54 @@ +package cn.iocoder.yudao.module.stockTransfer.vo; + +import cn.iocoder.yudao.common.RepairDictConstants; +import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; +import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; +import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; +import com.alibaba.excel.annotation.ExcelProperty; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; + +import java.math.BigDecimal; +import java.util.Date; + +/** + * 用于调拨相关的导出VO + * + * @author 小李 + * @date 17:27 2024/12/3 +**/ +@Data +@ExcelIgnoreUnannotated +public class RepairStExportVO { + + @ExcelProperty("调出门店") + private String outCorpId; + + @ExcelProperty("调入门店") + private String inCorpId; + + @ExcelProperty("单号") + private String stNo; + + @ExcelProperty("调拨人") + private String userName; + + @ExcelProperty("总数量") + private Integer itemCount; + + @ExcelProperty("总金额") + private BigDecimal totalPrice; + + @ExcelProperty(value = "状态", converter = DictConvert.class) + @DictFormat(RepairDictConstants.REPAIR_ST_STATUS) + private String stStatus; + + @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8") + @DateTimeFormat(pattern = "yyyy-MM-dd") + @ExcelProperty("调拨日期") + private Date stTime; + + @ExcelProperty("备注") + private String remark; +} diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/controller/admin/DlRepairTicketsController.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/controller/admin/DlRepairTicketsController.java index 934e40a1..e01b9d76 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/controller/admin/DlRepairTicketsController.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/controller/admin/DlRepairTicketsController.java @@ -1,15 +1,16 @@ package cn.iocoder.yudao.module.tickets.controller.admin; +import cn.hutool.core.collection.CollUtil; import cn.hutool.core.date.DateUtil; import cn.iocoder.yudao.common.RepairCons; import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; import cn.iocoder.yudao.module.tickets.entity.DlRepairTickets; import cn.iocoder.yudao.module.tickets.service.DlRepairTicketsService; -import cn.iocoder.yudao.module.tickets.vo.CustomerAndCarVO; -import cn.iocoder.yudao.module.tickets.vo.DlRepairTicketsReqVO; -import cn.iocoder.yudao.module.tickets.vo.DlRepairTicketsRespVO; -import cn.iocoder.yudao.module.tickets.vo.NoticeCusVO; +import cn.iocoder.yudao.module.tickets.vo.*; +import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import io.swagger.v3.oas.annotations.Operation; import org.apache.commons.lang3.StringUtils; @@ -17,10 +18,11 @@ import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; import javax.servlet.http.HttpServletResponse; -import java.util.Date; -import java.util.HashMap; -import java.util.Map; +import java.io.IOException; +import java.util.*; +import java.util.stream.Collectors; +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception0; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; /** @@ -438,5 +440,81 @@ public class DlRepairTicketsController { public CommonResult getCusAndCarById(@RequestParam("id") String id) { return success(dlRepairTicketsService.getCusAndCarById(id)); } + + /** + * 导出数据 + * + * @author 小李 + * @date 14:51 2024/12/3 + * @param repairTicketsReqVO 请求对象 + **/ + @GetMapping("/export") + @Operation(summary = "导出数据") + public void exportData(DlRepairTicketsReqVO repairTicketsReqVO, HttpServletResponse response)throws IOException { + int pageNo = 1, pageSize = 1000; + Page page = new Page<>(pageNo, pageSize); + if (StringUtils.isEmpty(repairTicketsReqVO.getSelectType())) { + //查询类型为空,默认查待处理的 + repairTicketsReqVO.setSelectType(RepairCons.TICKETS_WAITING); + } + List list = new ArrayList<>(); + do { + IPage pageType = dlRepairTicketsService.getPageType(repairTicketsReqVO, page); + List records = pageType.getRecords(); + if (CollUtil.isEmpty(records)){ + break; + } + List convertedRecords = records.stream().map(item -> BeanUtils.toBean(item, TicketsExportVO.class)).collect(Collectors.toList()); + list.addAll(convertedRecords); + pageNo++; + page.setCurrent(pageNo); + }while (true); + if (CollUtil.isEmpty(list)){ + throw exception0(500, "没有数据可以导出"); + } + ExcelUtils.write(response, "工单数据.xls", "数据", TicketsExportVO.class, list); + } + + /** + * 导出数据 根据工单状态 + * + * @author 小李 + * @date 15:19 2024/12/3 + * @param repairTicketsReqVO 请求对象 + **/ + @GetMapping("/exportByStatus") + @Operation(summary = "导出数据 根据工单状态") + public void exportByStatus(DlRepairTicketsReqVO repairTicketsReqVO, HttpServletResponse response)throws IOException{ + int pageNo = 1, pageSize = 1000; + List list = new ArrayList<>(); + Page page = new Page<>(pageNo, pageSize); + do { + IPage ticketsPage = dlRepairTicketsService.getTicketsPage(repairTicketsReqVO, page); + List records = ticketsPage.getRecords(); + if (CollUtil.isEmpty(records)){ + break; + } + List convertedRecords = records.stream().map(item -> BeanUtils.toBean(item, TicketExportByStatusVO.class)).collect(Collectors.toList()); + list.addAll(convertedRecords); + pageNo++; + page.setCurrent(pageNo); + }while (true); + if (CollUtil.isEmpty(list)){ + throw exception0(500, "没有数据可以导出"); + } + String name = ""; + switch (repairTicketsReqVO.getTicketsStatus()){ + case "01": + name = "待结算工单数据.xls"; + break; + case "02": + name = "已结算工单数据.xls"; + break; + case "03": + name = "已作废工单数据.xls"; + break; + } + ExcelUtils.write(response, name, "数据", TicketExportByStatusVO.class, list); + } } diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/controller/admin/DlTicketWaresController.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/controller/admin/DlTicketWaresController.java index 1df612e4..90b32486 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/controller/admin/DlTicketWaresController.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/controller/admin/DlTicketWaresController.java @@ -1,18 +1,28 @@ package cn.iocoder.yudao.module.tickets.controller.admin; +import cn.hutool.core.collection.CollUtil; import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; import cn.iocoder.yudao.module.tickets.entity.DlTicketWares; import cn.iocoder.yudao.module.tickets.service.DlTicketWaresService; import cn.iocoder.yudao.module.tickets.vo.DlTicketWaresReqVO; import cn.iocoder.yudao.module.tickets.vo.DlTicketWaresRespVO; +import cn.iocoder.yudao.module.tickets.vo.TicketWaresExportVO; +import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import io.swagger.v3.oas.annotations.Operation; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; +import java.util.ArrayList; import java.util.List; +import java.util.stream.Collectors; +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception0; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; /** @@ -62,7 +72,7 @@ public class DlTicketWaresController { } /** - * 新增、修改 + * 维修工新增配件申请单 * * @author 小李 * @date 12:14 2024/10/15 @@ -210,5 +220,35 @@ public class DlTicketWaresController { public CommonResult getByIds(@RequestParam("ids") List ids){ return success(dlTicketWaresService.getByIds(ids)); } + + /** + * 导出数据 + * + * @author 小李 + * @date 15:02 2024/12/3 + * @param reqVO 请求对象 + **/ + @GetMapping("/export") + @Operation(summary = "导出数据") + public void exportData(DlTicketWaresReqVO reqVO, HttpServletResponse response)throws IOException { + int pageNo = 1, pageSize = 1000; + List list = new ArrayList<>(); + Page page = new Page<>(pageNo, pageSize); + do { + IPage waresServicePage = dlTicketWaresService.getPage(reqVO, page); + List records = waresServicePage.getRecords(); + if (CollUtil.isEmpty(records)){ + break; + } + List convertedRecords = records.stream().map(item -> BeanUtils.toBean(item, TicketWaresExportVO.class)).collect(Collectors.toList()); + list.addAll(convertedRecords); + pageNo++; + page.setCurrent(pageNo); + }while (true); + if (CollUtil.isEmpty(list)){ + throw exception0(500, "没有数据可以导出"); + } + ExcelUtils.write(response, "配件申请单数据.xls", "数据", TicketWaresExportVO.class, list); + } } diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/entity/DlRepairTickets.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/entity/DlRepairTickets.java index 3d87b0f7..c74fee06 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/entity/DlRepairTickets.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/entity/DlRepairTickets.java @@ -45,6 +45,15 @@ public class DlRepairTickets extends TenantBaseDO { */ private String userName; + /** + * 经办人姓名 + */ + private String handleName; + /** + * 经办人电话 + */ + private String handleMobile; + /** * 用户手机号(base_customer_main表的phone_number) */ @@ -79,6 +88,14 @@ public class DlRepairTickets extends TenantBaseDO { * 车辆品牌类型(base_car_brand表的brand_type) */ private String carBrandType; + /** + * 最近保养日期 + */ + private Date maintenanceDate; + /** + * 最近保养里程 + */ + private BigDecimal maintenanceMileage; /** * 服务顾问ID(system_users表的ID) diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/entity/DlTwItem.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/entity/DlTwItem.java index fb1b0351..a739f412 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/entity/DlTwItem.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/entity/DlTwItem.java @@ -2,17 +2,13 @@ package cn.iocoder.yudao.module.tickets.entity; import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO; import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import lombok.Data; import lombok.EqualsAndHashCode; -import java.io.Serializable; -import java.util.Date; - /** - * 工单配件申请/退回子表 + * 工单配件申请单配件明细表 * * @author 小李 * @date 11:49 2024/10/15 @@ -43,6 +39,12 @@ public class DlTwItem extends TenantBaseDO { /** 配件状态:使用字典yes_no,1通过,0没通过 */ private String waresStatus; + /** 配件添加人id */ + private Long addUserId; + /** 配件添加人姓名 */ + private String addUserName; + /** 是否仓管添加的(0否|1是) */ + private Boolean ifHouseAdd; /** 审核人ID(system_users的ID) */ private Long handleId; diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/service/impl/DlRepairTicketsServiceImpl.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/service/impl/DlRepairTicketsServiceImpl.java index 4c047ff9..b0403dc7 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/service/impl/DlRepairTicketsServiceImpl.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/service/impl/DlRepairTicketsServiceImpl.java @@ -7,9 +7,11 @@ import cn.hutool.core.util.ObjectUtil; import cn.iocoder.yudao.common.*; import cn.iocoder.yudao.framework.common.util.number.MoneyUtils; import cn.iocoder.yudao.framework.common.util.object.BeanUtils; +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; import cn.iocoder.yudao.framework.security.core.LoginUser; import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils; import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder; +import cn.iocoder.yudao.module.base.entity.RepairRecords; import cn.iocoder.yudao.module.base.entity.RepairWorker; import cn.iocoder.yudao.module.base.service.RepairRecordsService; import cn.iocoder.yudao.module.base.service.RepairWorkerService; @@ -83,6 +85,7 @@ import java.io.FileOutputStream; import java.io.InputStream; import java.math.BigDecimal; import java.time.LocalDateTime; +import java.time.ZoneId; import java.time.format.DateTimeFormatter; import java.time.temporal.ChronoUnit; import java.util.*; @@ -236,6 +239,20 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl repairTypeList = dictDataApi.getDictDataList(DICT_REPAIR_TYPE); + Map repairTypeMap = repairTypeList.stream().collect(Collectors.toMap(DictDataRespDTO::getValue,DictDataRespDTO::getLabel)); DlRepairTicketsRespVO result = BeanUtil.toBean(dlRepairTickets, DlRepairTicketsRespVO.class); + result.setRepairTypeText(repairTypeMap.getOrDefault(dlRepairTickets.getRepairType(),"")); + + //查是否存在总检完成的记录,取出他的时间 + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper() + .eq(RepairRecords::getTicketId,id) + .eq(RepairRecords::getType,RecordTypeEnum.ZJ.getCode()) + .orderByDesc(BaseDO::getCreateTime); + List repairRecords = repairRecordsService.list(queryWrapper); + if(!repairRecords.isEmpty()){ + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); + String formattedString = repairRecords.get(0).getCreateTime().format(formatter); + result.setRealOverDate(formattedString); + } + AdminUserDO user = userService.getUser(Long.valueOf(dlRepairTickets.getAdviserId())); result.setLinkPhone(user.getMobile()); //查车辆 @@ -365,15 +399,54 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl itemList = titemService.list(new LambdaQueryWrapper().eq(DlRepairTitem::getTicketId, id)); List items = itemList.stream().map(item -> BeanUtil.toBean(item, DlRepairTitemReqVO.class)).collect(Collectors.toList()); - // 取项目 + + + //处理项目 取项目 List projects = items.stream().filter(item -> item.getItemType().equals("01")).collect(Collectors.toList()); + //pc原逻辑 if (CollectionUtil.isNotEmpty(projects)) { Set ids = projects.stream().map(DlRepairTitemReqVO::getProjectId).collect(Collectors.toSet()); List repairProjects = projectService.listByIds(ids); items.forEach(item -> repairProjects.stream().filter(i -> i.getId().equals(item.getProjectId())).findFirst().ifPresent(item::setProject)); } result.setProjects(projects); + if(ifApp){ + //app新增逻辑 + if (CollectionUtil.isNotEmpty(projects)) { + List projectList = new ArrayList<>(); + //查所有服务分类(项目分类) + List baseTypeList = baseTypeService.list(); + Map baseTypeMap = baseTypeList.stream().collect(Collectors.toMap(BaseType::getId,BaseType::getName)); + //先过滤出itenTypeId为null或空为单独一个组 + List nullList = projects.stream().filter(item->StringUtils.isEmpty(item.getItemTypeId())).collect(Collectors.toList()); + if (CollectionUtil.isNotEmpty(nullList)) { + AppWaresGroupVO waresGroupVO = new AppWaresGroupVO(); + waresGroupVO.setWares(nullList); + waresGroupVO.setGroupName("未知分组"); + waresGroupVO.setNums(nullList.size()); + waresGroupVO.setShowAll(false); + waresGroupVO.setServicer(nullList.get(0).getSaleName()); + waresGroupVO.setWorker(nullList.get(0).getRepairNames()); + projectList.add(waresGroupVO); + } + //过滤出有分类的进行分组 + Map> groupListMap = projects.stream().filter(item->StringUtils.isNotEmpty(item.getItemTypeId())).collect(Collectors.groupingBy(DlRepairTitem::getItemTypeId)); + for (String key:groupListMap.keySet()){ + AppWaresGroupVO waresGroupVO = new AppWaresGroupVO(); + waresGroupVO.setWares(groupListMap.get(key)); + waresGroupVO.setGroupName(baseTypeMap.get(key)); + waresGroupVO.setGroupId(key); + waresGroupVO.setNums(groupListMap.get(key).size()); + waresGroupVO.setShowAll(false); + waresGroupVO.setServicer(groupListMap.get(key).get(0).getSaleName()); + waresGroupVO.setWorker(groupListMap.get(key).get(0).getRepairNames()); + projectList.add(waresGroupVO); + } + result.setProjectList(projectList); + } + } + //处理配件 if(ifApp){ //app的逻辑 List waresGroupList = new ArrayList<>(); @@ -443,10 +516,6 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl recordTypeList = dictDataApi.getDictDataList(DICT_REPAIR_RECORDS_TYPE); Map typeMap = recordTypeList.stream().collect(Collectors.toMap(DictDataRespDTO::getValue, DictDataRespDTO::getLabel)); result.setRecords(records.stream().peek(item -> item.setType(typeMap.get(item.getType()))).collect(Collectors.toList())); - - // 更新主表时间 - refreshUpdateTime(id); - return result; } @@ -610,10 +679,6 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl() @@ -1556,6 +1621,7 @@ public class DlRepairTicketsServiceImpl extends ServiceImpl repairType = dictDataApi.getDictDataList(DICT_REPAIR_TYPE); diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/service/impl/DlRepairTitemServiceImpl.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/service/impl/DlRepairTitemServiceImpl.java index 24f0f6b2..26ba0e3d 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/service/impl/DlRepairTitemServiceImpl.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/service/impl/DlRepairTitemServiceImpl.java @@ -161,8 +161,6 @@ public class DlRepairTitemServiceImpl extends ServiceImpl getProjList(String ticketId,String isOpen) { - // 更新工单主表时间 - repairTicketsService.refreshUpdateTime(ticketId); return dlRepairTitemMapper.selectProjList(ticketId,isOpen); } } diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/service/impl/DlTicketWaresServiceImpl.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/service/impl/DlTicketWaresServiceImpl.java index 2418d9ac..28c04272 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/service/impl/DlTicketWaresServiceImpl.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/service/impl/DlTicketWaresServiceImpl.java @@ -223,6 +223,10 @@ public class DlTicketWaresServiceImpl extends ServiceImpl twItems = twItemService.listByIds(twItemIds); // 取所有的配件信息 List wareIds = twItems.stream().map(DlTwItem::getWaresId).collect(Collectors.toList()); - List repairWares = repairWaresService.listByIds(wareIds); // 更新配件申请表子表 List newTwitems = twItemIds.stream().map(item -> { DlTwItem twItem = new DlTwItem(); @@ -307,68 +310,70 @@ public class DlTicketWaresServiceImpl extends ServiceImpl().set(DlTicketWares::getStatus, "02").eq(DlTicketWares::getId, respVO.getId())); } - // 更新维修工单子表 - if (status.equals("01")) { - DlTicketWares ticketWares = baseMapper.selectById(respVO.getId()); - List titems = repairTitemService.list(new LambdaQueryWrapper().and(i -> { - i.in(DlRepairTitem::getTicketId, ticketWares.getTicketId()) - .eq(DlRepairTitem::getItemType, "02"); - })); - // 要修改的 - List updateTitems = titems.stream().filter(item -> wareIds.contains(item.getPartId())).collect(Collectors.toList()); - // 修改 - if (CollectionUtil.isNotEmpty(updateTitems)) { - List newTitems = updateTitems.stream().map(item -> { - DlRepairTitem titem = new DlRepairTitem(); - titem.setId(item.getId()); - DlTwItem twItem = allTwitems.stream().filter(i -> i.getWaresId().equals(item.getPartId())).findFirst().orElse(null); - if (twItem != null) { - titem.setItemCount(item.getItemCount() + twItem.getWaresCount()); - titem.setItemMoney(item.getItemPrice().multiply(BigDecimal.valueOf(titem.getItemCount())).multiply(item.getItemDiscount())); - } - return titem; - }).collect(Collectors.toList()); - repairTitemService.updateBatchById(newTitems); - } - // 要新增的 - if (updateTitems.size() < wareIds.size()) { - List titemIds = updateTitems.stream().map(DlRepairTitem::getPartId).collect(Collectors.toList()); - List newWares = repairWares.stream().filter(item -> !titemIds.contains(item.getId())).collect(Collectors.toList()); - // 新增 - List newTitems = newWares.stream().map(item -> { - DlRepairTitem titem = new DlRepairTitem(); - titem.setTicketId(ticketWares.getTicketId()); - titem.setItemType("02"); - titem.setItemName(item.getName()); - DlTwItem twItem = allTwitems.stream().filter(i -> i.getWaresId().equals(item.getId())).findFirst().orElse(null); - titem.setItemCount(twItem != null ? twItem.getWaresCount() : 0); - titem.setItemUnit(item.getUnit()); - titem.setItemPrice((item.getPrice() != null) ? item.getPrice() : BigDecimal.ZERO); - titem.setItemDiscount(BigDecimal.ONE); - titem.setItemMoney(titem.getItemPrice().multiply(BigDecimal.valueOf(titem.getItemCount())).multiply(titem.getItemDiscount())); - titem.setRepairIds(String.valueOf(ticketWares.getRepairId())); - titem.setRepairNames(ticketWares.getRepairName()); - titem.setSaleId(ticketWares.getAdviserId()); - titem.setSaleName(ticketWares.getAdviserName()); - titem.setPartId(item.getId()); - titem.setItemStatus("04"); - titem.setRemark(twItem != null ? twItem.getRemark() : null); - return titem; - }).collect(Collectors.toList()); - repairTitemService.saveBatch(newTitems); - } - // 更新维修工单主表 - boolean flag = repairTicketsService.computeTicket(ticketWares.getTicketId()); - if (!flag) { - throw exception0(500, "重新计算工单错误"); - } - // 发送通过的消息给仓库 - RoleReqDTO roleInfo = roleApi.getRoleInfo(RepairRoleEnum.WAREHOUSE.getCode()); - List ids = permissionApi.getUserIdByRoleId(roleInfo.getId()); - if (CollectionUtil.isNotEmpty(ids)) { - ids.forEach(id -> repairWorkerService.sentMessage(id, "您有新的配件申请单需要处理")); - } - } + /* 审核配件申请单暂时不操作工单子表 */ +// // 更新维修工单子表 +// List repairWares = repairWaresService.listByIds(wareIds); +// if (status.equals("01")) { +// DlTicketWares ticketWares = baseMapper.selectById(respVO.getId()); +// List titems = repairTitemService.list(new LambdaQueryWrapper().and(i -> { +// i.in(DlRepairTitem::getTicketId, ticketWares.getTicketId()) +// .eq(DlRepairTitem::getItemType, "02"); +// })); +// // 要修改的 +// List updateTitems = titems.stream().filter(item -> wareIds.contains(item.getPartId())).collect(Collectors.toList()); +// // 修改 +// if (CollectionUtil.isNotEmpty(updateTitems)) { +// List newTitems = updateTitems.stream().map(item -> { +// DlRepairTitem titem = new DlRepairTitem(); +// titem.setId(item.getId()); +// DlTwItem twItem = allTwitems.stream().filter(i -> i.getWaresId().equals(item.getPartId())).findFirst().orElse(null); +// if (twItem != null) { +// titem.setItemCount(item.getItemCount() + twItem.getWaresCount()); +// titem.setItemMoney(item.getItemPrice().multiply(BigDecimal.valueOf(titem.getItemCount())).multiply(item.getItemDiscount())); +// } +// return titem; +// }).collect(Collectors.toList()); +// repairTitemService.updateBatchById(newTitems); +// } +// // 要新增的 +// if (updateTitems.size() < wareIds.size()) { +// List titemIds = updateTitems.stream().map(DlRepairTitem::getPartId).collect(Collectors.toList()); +// List newWares = repairWares.stream().filter(item -> !titemIds.contains(item.getId())).collect(Collectors.toList()); +// // 新增 +// List newTitems = newWares.stream().map(item -> { +// DlRepairTitem titem = new DlRepairTitem(); +// titem.setTicketId(ticketWares.getTicketId()); +// titem.setItemType("02"); +// titem.setItemName(item.getName()); +// DlTwItem twItem = allTwitems.stream().filter(i -> i.getWaresId().equals(item.getId())).findFirst().orElse(null); +// titem.setItemCount(twItem != null ? twItem.getWaresCount() : 0); +// titem.setItemUnit(item.getUnit()); +// titem.setItemPrice((item.getPrice() != null) ? item.getPrice() : BigDecimal.ZERO); +// titem.setItemDiscount(BigDecimal.ONE); +// titem.setItemMoney(titem.getItemPrice().multiply(BigDecimal.valueOf(titem.getItemCount())).multiply(titem.getItemDiscount())); +// titem.setRepairIds(String.valueOf(ticketWares.getRepairId())); +// titem.setRepairNames(ticketWares.getRepairName()); +// titem.setSaleId(ticketWares.getAdviserId()); +// titem.setSaleName(ticketWares.getAdviserName()); +// titem.setPartId(item.getId()); +// titem.setItemStatus("04"); +// titem.setRemark(twItem != null ? twItem.getRemark() : null); +// return titem; +// }).collect(Collectors.toList()); +// repairTitemService.saveBatch(newTitems); +// } +// // 更新维修工单主表 +// boolean flag = repairTicketsService.computeTicket(ticketWares.getTicketId()); +// if (!flag) { +// throw exception0(500, "重新计算工单错误"); +// } +// // 发送通过的消息给仓库 +// RoleReqDTO roleInfo = roleApi.getRoleInfo(RepairRoleEnum.WAREHOUSE.getCode()); +// List ids = permissionApi.getUserIdByRoleId(roleInfo.getId()); +// if (CollectionUtil.isNotEmpty(ids)) { +// ids.forEach(id -> repairWorkerService.sentMessage(id, "您有新的配件申请单需要处理")); +// } +// } // 通知维修工 DlTicketWares ticketWares = baseMapper.selectById(respVO.getId()); repairWorkerService.sentMessage(ticketWares.getRepairId(), "您有新的配件申请单" + (status.equals("01") ? "审批通过了" : "被驳回了")); @@ -433,20 +438,18 @@ public class DlTicketWaresServiceImpl extends ServiceImpl oldData = twItemService.list(new LambdaQueryWrapper().and(item -> { - item.eq(DlTwItem::getTwId, respVO.getRepairSo().getTwId()) - .in(DlTwItem::getWaresId, respVO.getRepairSois().stream().map(DlRepairSoi::getGoodsId).collect(Collectors.toList())); - })); + List oldData = twItemService.listByIds(respVO.getIds()); +// List oldData = twItemService.list(new LambdaQueryWrapper().and(item -> { +// item.eq(DlTwItem::getTwId, respVO.getRepairSo().getTwId()) +// .in(DlTwItem::getWaresId, respVO.getRepairSois().stream().map(DlRepairSoi::getGoodsId).collect(Collectors.toList())); +// })); // 要操作的库存数据 List wares = repairWaresService.list(new LambdaQueryWrapper().in(RepairWares::getId, respVO.getRepairSois().stream().map(DlRepairSoi::getGoodsId).collect(Collectors.toList()))); Map waresNameMap = wares.stream().collect(Collectors.toMap(RepairWares::getId, RepairWares::getName)); - String remarkStr = ""; - for (DlRepairSoi item : respVO.getRepairSois()) { - //组装通知领取配件的文字 - if (!"".equals(remarkStr)) { - remarkStr += ";"; - } - remarkStr += waresNameMap.get(item.getGoodsId()) + "x" + item.getGoodsCount(); + StringBuilder remarkStr = new StringBuilder(); + for (int i = 0; i < respVO.getRepairSois().size(); i++) { + DlRepairSoi repairSoi = respVO.getRepairSois().get(i); + remarkStr.append(i + 1).append(".").append(waresNameMap.get(repairSoi.getGoodsId())).append("x").append(repairSoi.getGoodsCount()).append("; "); } if (type.equals("02")) { // 领料 // 构造新数据 @@ -511,7 +514,7 @@ public class DlTicketWaresServiceImpl extends ServiceImpl **/ @Override public void addTwi(AddTwiVO addTwiVO){ + LoginUser loginUser = SecurityFrameworkUtils.getLoginUser(); // 构建子表数据 if (CollectionUtil.isEmpty(addTwiVO.getItems())){ throw exception0(500, "请选择配件"); } - // 查出该配件申请单已有的所有配件,这里只取没有审核过(通过、驳回的不要,同一个配件如果已经审核过了又添加,还是算新的) - List oldData = baseMapper.selectList(new LambdaQueryWrapper().and(i -> { - i.in(DlTwItem::getTwId, addTwiVO.getId()) - .eq(DlTwItem::getWaresStatus, ""); - })); - if (CollectionUtil.isNotEmpty(oldData)){ - // 取配件ID - List ids = oldData.stream().map(DlTwItem::getWaresId).collect(Collectors.toList()); - // 过滤添加的 - List add = addTwiVO.getItems().stream().filter(item -> !ids.contains(item.getId())).collect(Collectors.toList()); - // 过滤存在的 - List update = addTwiVO.getItems().stream().filter(item -> ids.contains(item.getId())).collect(Collectors.toList()); - // 添加 - if (CollectionUtil.isNotEmpty(add)){ - List twItems = add.stream().map(item -> { + if(addTwiVO.getIfHouseAdd()){ + //仓管添加 + List twItems = addTwiVO.getItems().stream().map(item -> { + DlTwItem twItem = new DlTwItem(); + twItem.setTwId(addTwiVO.getId()); + twItem.setWaresId(item.getId()); + twItem.setWaresName(item.getName()); + twItem.setWaresCount(item.getCount()); + twItem.setAddUserId(loginUser.getId()); + twItem.setAddUserName(loginUser.getInfo().get("nickname")); + twItem.setIfHouseAdd(true); + twItem.setWaresAlreadyCount(0); + twItem.setWaresStatus("1"); + twItem.setHandleId(loginUser.getId()); + twItem.setHandleName(loginUser.getInfo().get("nickname")); + twItem.setRemark(item.getRemark()); + return twItem; + }).collect(Collectors.toList()); + // 新增 + baseMapper.insert(twItems); + }else{ + //服务顾问添加 + // 查出该配件申请单已有的所有配件,这里只取没有审核过(通过、驳回的不要,同一个配件如果已经审核过了又添加,还是算新的) + List oldData = baseMapper.selectList(new LambdaQueryWrapper().and(i -> { + i.in(DlTwItem::getTwId, addTwiVO.getId()) + .eq(DlTwItem::getWaresStatus, ""); + })); + if (CollectionUtil.isNotEmpty(oldData)){ + // 取配件ID + List ids = oldData.stream().map(DlTwItem::getWaresId).collect(Collectors.toList()); + // 过滤添加的 + List add = addTwiVO.getItems().stream().filter(item -> !ids.contains(item.getId())).collect(Collectors.toList()); + // 过滤存在的 + List update = addTwiVO.getItems().stream().filter(item -> ids.contains(item.getId())).collect(Collectors.toList()); + // 添加 + if (CollectionUtil.isNotEmpty(add)){ + List twItems = add.stream().map(item -> { + DlTwItem twItem = new DlTwItem(); + twItem.setTwId(addTwiVO.getId()); + twItem.setWaresId(item.getId()); + twItem.setWaresName(item.getName()); + twItem.setWaresCount(item.getCount()); + twItem.setAddUserId(loginUser.getId()); + twItem.setAddUserName(loginUser.getInfo().get("nickname")); + twItem.setIfHouseAdd(false); + twItem.setWaresAlreadyCount(0); + twItem.setWaresStatus(""); + twItem.setRemark(item.getRemark()); + return twItem; + }).collect(Collectors.toList()); + // 新增 + baseMapper.insert(twItems); + } + // 更新 + if (CollectionUtil.isNotEmpty(update)){ + List twItems = update.stream().map(item -> { + DlTwItem twItem = oldData.stream().filter(i -> i.getWaresId().equals(item.getId())).findFirst().orElse(null); + // 只更新数量,其他不变 + if (twItem != null) { + twItem.setWaresCount(twItem.getWaresCount() + item.getCount()); + } + return twItem; + }).collect(Collectors.toList()); + baseMapper.updateById(twItems); + } + }else { + List twItems = addTwiVO.getItems().stream().map(item -> { DlTwItem twItem = new DlTwItem(); twItem.setTwId(addTwiVO.getId()); twItem.setWaresId(item.getId()); twItem.setWaresName(item.getName()); twItem.setWaresCount(item.getCount()); + twItem.setAddUserId(loginUser.getId()); + twItem.setAddUserName(loginUser.getInfo().get("nickname")); + twItem.setIfHouseAdd(false); twItem.setWaresAlreadyCount(0); twItem.setWaresStatus(""); twItem.setRemark(item.getRemark()); @@ -133,32 +191,6 @@ public class DlTwItemServiceImpl extends ServiceImpl // 新增 baseMapper.insert(twItems); } - // 更新 - if (CollectionUtil.isNotEmpty(update)){ - List twItems = update.stream().map(item -> { - DlTwItem twItem = oldData.stream().filter(i -> i.getWaresId().equals(item.getId())).findFirst().orElse(null); - // 只更新数量,其他不变 - if (twItem != null) { - twItem.setWaresCount(twItem.getWaresCount() + item.getCount()); - } - return twItem; - }).collect(Collectors.toList()); - baseMapper.updateById(twItems); - } - }else { - List twItems = addTwiVO.getItems().stream().map(item -> { - DlTwItem twItem = new DlTwItem(); - twItem.setTwId(addTwiVO.getId()); - twItem.setWaresId(item.getId()); - twItem.setWaresName(item.getName()); - twItem.setWaresCount(item.getCount()); - twItem.setWaresAlreadyCount(0); - twItem.setWaresStatus(""); - twItem.setRemark(item.getRemark()); - return twItem; - }).collect(Collectors.toList()); - // 新增 - baseMapper.insert(twItems); } } diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/vo/AddTwiVO.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/vo/AddTwiVO.java index ec012d54..09a09cdd 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/vo/AddTwiVO.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/vo/AddTwiVO.java @@ -14,6 +14,10 @@ import java.util.List; public class AddTwiVO { private String id; + /** + * 是否仓管添加 + */ + private Boolean ifHouseAdd; private List items; diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/vo/AppWaresGroupVO.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/vo/AppWaresGroupVO.java index 82f185ac..bd3e5095 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/vo/AppWaresGroupVO.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/vo/AppWaresGroupVO.java @@ -7,12 +7,14 @@ import java.math.BigDecimal; import java.util.List; /** - * app使用的配件明细,按分类分组后的 + * app使用的配件明细(项目),按分类分组后的 * @author vinjor-M * @date 10:10 2024/11/19 **/ @Data public class AppWaresGroupVO { + /** 是否展开数据 */ + private Boolean showAll; /** 分组ID(分类ID) */ private String groupId; /** 分组名称(分类名称) */ @@ -23,7 +25,7 @@ public class AppWaresGroupVO { private Integer nums; /** 总价 */ private BigDecimal totalAmount; - /** 配件明细 */ + /** 配件/项目明细 */ private List wares; /** 配件申请单配件明细 */ private List twItemList; @@ -36,4 +38,9 @@ public class AppWaresGroupVO { private Integer waitingNum; /** 审核不通过数量-- */ private Integer noNum; + + /** 服务顾问人名 */ + private String servicer; + /** 维修工人名 */ + private String worker; } diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/vo/DlRepairTicketsRespVO.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/vo/DlRepairTicketsRespVO.java index 307d594c..3042b811 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/vo/DlRepairTicketsRespVO.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/vo/DlRepairTicketsRespVO.java @@ -65,4 +65,11 @@ public class DlRepairTicketsRespVO extends DlRepairTickets { /** app分组回显专用--配件明细 */ List waresGroupList; + /** app分组回显专用--项目明细 */ + List projectList; + + /** 维修类型文本 */ + private String repairTypeText; + /** 车辆实际竣工(总检完成)时间 */ + private String realOverDate; } diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/vo/DlTicketWaresRespVO.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/vo/DlTicketWaresRespVO.java index 1e481867..97542169 100644 --- a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/vo/DlTicketWaresRespVO.java +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/vo/DlTicketWaresRespVO.java @@ -36,4 +36,7 @@ public class DlTicketWaresRespVO extends DlTicketWares { /** 通知领料时上传的图片 */ private String images; + + /** 操作的配件申请单子表的ids */ + private List ids; } diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/vo/TicketExportByStatusVO.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/vo/TicketExportByStatusVO.java new file mode 100644 index 00000000..fdc6023c --- /dev/null +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/vo/TicketExportByStatusVO.java @@ -0,0 +1,41 @@ +package cn.iocoder.yudao.module.tickets.vo; + +import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; +import com.alibaba.excel.annotation.ExcelProperty; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; + +import java.math.BigDecimal; +import java.time.LocalDateTime; + +/** + * 用于导出不对状态的工单 + * + * @author 小李 + * @date 15:21 2024/12/3 +**/ +@Data +@ExcelIgnoreUnannotated +public class TicketExportByStatusVO extends TicketsExportVO{ + + @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd") + @DateTimeFormat(pattern="yyyy-MM-dd") + @ExcelProperty("创建时间") + private LocalDateTime createTime; + + @ExcelProperty("合计金额") + private BigDecimal totalPrice; + + @ExcelProperty("参考成本") + private BigDecimal cost; + + @ExcelProperty("参考毛利") + private BigDecimal profit; + + @ExcelProperty("服务顾问") + private String adviserName; + + @ExcelProperty("备注") + private String remark; +} diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/vo/TicketWaresExportVO.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/vo/TicketWaresExportVO.java new file mode 100644 index 00000000..900fa039 --- /dev/null +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/vo/TicketWaresExportVO.java @@ -0,0 +1,48 @@ +package cn.iocoder.yudao.module.tickets.vo; + +import cn.iocoder.yudao.common.RepairDictConstants; +import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; +import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; +import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; +import com.alibaba.excel.annotation.ExcelProperty; +import lombok.Data; + +/** + * 用于配件申请单数据导出VO + * + * @author 小李 + * @date 15:03 2024/12/3 +**/ +@Data +@ExcelIgnoreUnannotated +public class TicketWaresExportVO { + + @ExcelProperty("单据号") + private String no; + + @ExcelProperty("客户名称") + private String userName; + + @ExcelProperty("客户电话") + private String userMobile; + + @ExcelProperty("车牌号") + private String licenseNumber; + + @ExcelProperty("申请人") + private String repairName; + + @ExcelProperty(value = "岗位", converter = DictConvert.class) + @DictFormat(RepairDictConstants.REPAIR_WORK_TYPE) + private String repairWork; + + @ExcelProperty("服务顾问") + private String adviserName; + + @ExcelProperty(value = "状态", converter = DictConvert.class) + @DictFormat(RepairDictConstants.TICKET_WARES_STATUS) + private String status; + + @ExcelProperty("备注") + private String remark; +} diff --git a/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/vo/TicketsExportVO.java b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/vo/TicketsExportVO.java new file mode 100644 index 00000000..6927d8be --- /dev/null +++ b/dl-module-repair/src/main/java/cn/iocoder/yudao/module/tickets/vo/TicketsExportVO.java @@ -0,0 +1,44 @@ +package cn.iocoder.yudao.module.tickets.vo; + +import cn.iocoder.yudao.common.RepairDictConstants; +import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat; +import cn.iocoder.yudao.framework.excel.core.convert.DictConvert; +import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; +import com.alibaba.excel.annotation.ExcelProperty; +import lombok.Data; + +/** + * 用于工单数据导出 + * + * @author 小李 + * @date 14:41 2024/12/3 +**/ +@Data +@ExcelIgnoreUnannotated +public class TicketsExportVO { + + @ExcelProperty("订单编号") + private String ticketNo; + + @ExcelProperty(value = "维修类别", converter = DictConvert.class) + @DictFormat(RepairDictConstants.REPAIR_TYPE) + private String repairType; + + @ExcelProperty("客户名称") + private String userName; + + @ExcelProperty("车牌号") + private String carNo; + + @ExcelProperty("车系") + private String carBrandName; + + @ExcelProperty("手机号") + private String userMobile; + + @ExcelProperty("经办人姓名") + private String handleName; + + @ExcelProperty("经办人电话") + private String handleMobile; +} diff --git a/dl-module-repair/src/main/resources/mapper/stockOperate/DlRepairSoiMapper.xml b/dl-module-repair/src/main/resources/mapper/stockOperate/DlRepairSoiMapper.xml index b67e1c73..b07bb087 100644 --- a/dl-module-repair/src/main/resources/mapper/stockOperate/DlRepairSoiMapper.xml +++ b/dl-module-repair/src/main/resources/mapper/stockOperate/DlRepairSoiMapper.xml @@ -148,4 +148,45 @@ ) + + diff --git a/dl-module-repair/src/main/resources/mapper/tickets/DlRepairTicketsMapper.xml b/dl-module-repair/src/main/resources/mapper/tickets/DlRepairTicketsMapper.xml index f8af711a..02fcf279 100644 --- a/dl-module-repair/src/main/resources/mapper/tickets/DlRepairTicketsMapper.xml +++ b/dl-module-repair/src/main/resources/mapper/tickets/DlRepairTicketsMapper.xml @@ -107,6 +107,8 @@ + + @@ -160,7 +162,9 @@ rescue_money, three_pack_money, confirm_fault_money, - billing_remark + billing_remark, + handle_name, + handle_mobile from dl_repair_tickets drt where drt.deleted = '0' diff --git a/dl-module-repair/src/main/resources/mapper/tickets/DlTwItemMapper.xml b/dl-module-repair/src/main/resources/mapper/tickets/DlTwItemMapper.xml index 1bd01b6f..41e94516 100644 --- a/dl-module-repair/src/main/resources/mapper/tickets/DlTwItemMapper.xml +++ b/dl-module-repair/src/main/resources/mapper/tickets/DlTwItemMapper.xml @@ -26,6 +26,9 @@ wares_count, wares_already_count, wares_status, + add_user_id, + add_user_name, + if_house_add, handle_id, handle_name, remark @@ -56,6 +59,9 @@ dti.wares_count, dti.wares_already_count, dti.wares_status, + dti.add_user_id, + dti.add_user_name, + dti.if_house_add, dti.handle_id, dti.handle_name, dti.update_time, diff --git a/dl-module-repair/src/main/resources/mapper/warnMessage/WarnMessageByRepairMapper.xml b/dl-module-repair/src/main/resources/mapper/warnMessage/WarnMessageByRepairMapper.xml new file mode 100644 index 00000000..3fd1ad59 --- /dev/null +++ b/dl-module-repair/src/main/resources/mapper/warnMessage/WarnMessageByRepairMapper.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/user/AdminUserMapper.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/user/AdminUserMapper.java index 1a78e22c..27d01c14 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/user/AdminUserMapper.java +++ b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/dal/mysql/user/AdminUserMapper.java @@ -47,6 +47,8 @@ public interface AdminUserMapper extends BaseMapperX { return selectPage(reqVO, new LambdaQueryWrapperX() .likeIfPresent(AdminUserDO::getUsername, reqVO.getUsername()) .likeIfPresent(AdminUserDO::getMobile, reqVO.getMobile()) + // 这里加了个模糊查询,用户名称搜索时可以模糊查用户昵称 + .likeIfPresent(AdminUserDO::getNickname, reqVO.getUsername()) .eqIfPresent(AdminUserDO::getStatus, reqVO.getStatus()) .betweenIfPresent(AdminUserDO::getCreateTime, reqVO.getCreateTime()) .inIfPresent(AdminUserDO::getDeptId, deptIds)