diff --git a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/controller/InspectionEquInfoController.java b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/controller/InspectionEquInfoController.java index 3c428f50..23f2fbfd 100644 --- a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/controller/InspectionEquInfoController.java +++ b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/controller/InspectionEquInfoController.java @@ -1,26 +1,32 @@ package cn.iocoder.yudao.module.inspection.controller; +import java.io.IOException; +import java.util.Arrays; +import java.util.HashMap; import java.util.List; +import java.util.Map; import javax.servlet.http.HttpServletResponse; 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.inspection.service.AppInspectionPartnerService; +import cn.iocoder.yudao.module.inspection.vo.InspectionEqInfoImportVo; +import cn.iocoder.yudao.module.inspection.vo.StaffImportExcelVO; import cn.iocoder.yudao.module.shop.entity.ShopMallPartners; +import cn.iocoder.yudao.module.system.api.dict.DictDataApi; +import cn.iocoder.yudao.module.system.api.dict.dto.DictDataRespDTO; import cn.iocoder.yudao.util.ExcelUtil; 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.GetMapping; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.DeleteMapping; -import org.springframework.web.bind.annotation.PathVariable; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import cn.iocoder.yudao.module.core.controller.BaseController; import cn.iocoder.yudao.module.inspection.entity.InspectionEquInfo; import cn.iocoder.yudao.module.inspection.service.IInspectionEquInfoService; +import org.springframework.web.multipart.MultipartFile; + +import static cn.iocoder.yudao.framework.excel.core.util.ExcelUtils.exportBlankTemplate; /** * equInfoController @@ -30,25 +36,26 @@ import cn.iocoder.yudao.module.inspection.service.IInspectionEquInfoService; */ @RestController @RequestMapping("/admin-api/system/equInfo") -public class InspectionEquInfoController extends BaseController -{ +public class InspectionEquInfoController extends BaseController { @Autowired private IInspectionEquInfoService inspectionEquInfoService; - @Autowired - private AppInspectionPartnerService partnerService; + @Autowired + private AppInspectionPartnerService partnerService; + @Autowired + private DictDataApi dictDataApi; /** * 查询equInfo列表 */ @GetMapping("/list") - public CommonResult list(Integer pageNum,Integer pageSize,InspectionEquInfo inspectionEquInfo) throws Exception { + public CommonResult list(Integer pageNum, Integer pageSize, InspectionEquInfo inspectionEquInfo) throws Exception { - Page page =new Page(pageNum,pageSize); + Page page = new Page(pageNum, pageSize); if (ObjectUtil.isNull(inspectionEquInfo.getPartnerId())) { ShopMallPartners partners = partnerService.shopInfoByUserId(); inspectionEquInfo.setPartnerId(partners.getPartnerId()); } - IPage<InspectionEquInfo> list = inspectionEquInfoService.selectInspectionEquInfoList(page,inspectionEquInfo); + IPage<InspectionEquInfo> list = inspectionEquInfoService.selectInspectionEquInfoList(page, inspectionEquInfo); return success(list); } @@ -56,10 +63,9 @@ public class InspectionEquInfoController extends BaseController * 导出equInfo列表 */ @PostMapping("/export") - public void export(HttpServletResponse response, InspectionEquInfo inspectionEquInfo) - { - Page page =new Page(1,100000); - IPage<InspectionEquInfo> list = inspectionEquInfoService.selectInspectionEquInfoList(page,inspectionEquInfo); + public void export(HttpServletResponse response, InspectionEquInfo inspectionEquInfo) { + Page page = new Page(1, 100000); + IPage<InspectionEquInfo> list = inspectionEquInfoService.selectInspectionEquInfoList(page, inspectionEquInfo); ExcelUtil<InspectionEquInfo> util = new ExcelUtil<InspectionEquInfo>(InspectionEquInfo.class); util.exportExcel(response, list.getRecords(), "equInfo数据"); } @@ -68,8 +74,7 @@ public class InspectionEquInfoController extends BaseController * 获取equInfo详细信息 */ @GetMapping(value = "/{id}") - public CommonResult getInfo(@PathVariable("id") Long id) - { + public CommonResult getInfo(@PathVariable("id") Long id) { return success(inspectionEquInfoService.selectInspectionEquInfoById(id)); } @@ -90,7 +95,7 @@ public class InspectionEquInfoController extends BaseController public CommonResult edit(@RequestBody InspectionEquInfo inspectionEquInfo) throws Exception { ShopMallPartners partners = partnerService.shopInfo(); InspectionEquInfo inspectionEquInfo1 = inspectionEquInfoService.selectInspectionEquInfoById(inspectionEquInfo.getId()); - if (!partners.getPartnerId().equals(inspectionEquInfo1.getPartnerId())){ + if (!partners.getPartnerId().equals(inspectionEquInfo1.getPartnerId())) { return null; } return toAjax(inspectionEquInfoService.updateInspectionEquInfo(inspectionEquInfo)); @@ -99,13 +104,63 @@ public class InspectionEquInfoController extends BaseController /** * 删除equInfo */ - @DeleteMapping("/{id}") + @DeleteMapping("/{id}") public CommonResult remove(@PathVariable Long id) throws Exception { ShopMallPartners partners = partnerService.shopInfo(); InspectionEquInfo inspectionEquInfo1 = inspectionEquInfoService.selectInspectionEquInfoById(id); - if (!partners.getPartnerId().equals(inspectionEquInfo1.getPartnerId())){ + if (!partners.getPartnerId().equals(inspectionEquInfo1.getPartnerId())) { return null; } return toAjax(inspectionEquInfoService.deleteInspectionEquInfoById(id)); } + + /** + * 导入模板 + * + * @param response 响应 + * @throws IOException IOException + */ + @PostMapping("/importTemplate") + public void importTemplate(HttpServletResponse response) throws IOException { + // 表头 + String[] head = {"设备名称", "设备类型", "型号", "出厂编号", "校准日期", "复校日期", "证书编号", "制造商", "校准单位", "电话", "地址", "邮编", "电子邮箱"}; + + // 下拉框列及选项:列索引 -> 下拉框选项 + Map<Integer, String[]> dropdownColumns = new HashMap<>(); + + // 查询设备类型 + List<DictDataRespDTO> eqType = dictDataApi.getDictDataList("ins_equ_type"); + if (eqType != null && !eqType.isEmpty()) { + String[] array1 = eqType.stream() + .map(DictDataRespDTO::getLabel) + .toArray(String[]::new); + dropdownColumns.put(1, array1); // 设备类型列 + } + + // 示例数据(此处为自定义示例行,可根据实际需求修改) + List<List<String>> exampleDataList = Arrays.asList( + Arrays.asList("示例设备", "请在下拉框中选择", "示例型号", "示例出厂编号", "2023/1/1", "2023/12/31", "123456", "示例制造商", "示例校准单位", "1234567890", "示例地址", "12345", "example@email.com") + ); + + // 调用方法导出空白模板 + exportBlankTemplate(response, "eq_template.xlsx", "设备信息", head, dropdownColumns, true, null, null); + } + + + /** + * 导入设备信息 + * + * @param file 文件 + * @return 导入结果 + */ + @PostMapping("/importEquipment") + public CommonResult<Map<String, Object>> importEquipment(@RequestParam("file") MultipartFile file) { + try { + List<InspectionEqInfoImportVo> list = ExcelUtils.read(file, InspectionEqInfoImportVo.class); + return success(inspectionEquInfoService.importStaff(list)); + } catch (Exception e) { + throw new RuntimeException(e.getMessage()); + } + } + } diff --git a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/controller/InspectionStaffController.java b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/controller/InspectionStaffController.java index 5fad688e..0d0c3cb5 100644 --- a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/controller/InspectionStaffController.java +++ b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/controller/InspectionStaffController.java @@ -58,9 +58,9 @@ public class InspectionStaffController extends BaseController { * @return */ @GetMapping("/list") - public CommonResult list(InspectionStaffQuery query, - @RequestParam(value = "pageNo", required = false, defaultValue = "1") Integer pageNum, - @RequestParam(value = "pageSize", required = false, defaultValue = "10") Integer pageSize) { + public CommonResult<?> list(InspectionStaffQuery query, + @RequestParam(value = "pageNo", required = false, defaultValue = "1") Integer pageNum, + @RequestParam(value = "pageSize", required = false, defaultValue = "10") Integer pageSize) { Page<InspectionStaffSaveVo> page = new Page<>(pageNum, pageSize); IPage<InspectionStaffSaveVo> list = inspectionStaffService.getList(page, query); return success(list); @@ -73,7 +73,7 @@ public class InspectionStaffController extends BaseController { * @return */ @GetMapping("/get") - public CommonResult get(Long id) { + public CommonResult<?> get(Long id) { return success(inspectionStaffService.get(id)); } @@ -84,7 +84,7 @@ public class InspectionStaffController extends BaseController { * @return */ @PostMapping("/save") - public CommonResult save(@RequestBody InspectionStaffSaveVo inspectionStaff) { + public CommonResult<?> save(@RequestBody InspectionStaffSaveVo inspectionStaff) { //校验 verify(inspectionStaff); return success(inspectionStaffService.saveInspectionStaff(inspectionStaff)); @@ -97,7 +97,7 @@ public class InspectionStaffController extends BaseController { * @return */ @PutMapping("/update") - public CommonResult update(@RequestBody InspectionStaffSaveVo inspectionStaff) { + public CommonResult<?> update(@RequestBody InspectionStaffSaveVo inspectionStaff) { Assert.notNull(inspectionStaff.getUserId(), "员工id不能为空"); //校验 verify(inspectionStaff); @@ -112,23 +112,7 @@ public class InspectionStaffController extends BaseController { */ @GetMapping("/get-import-template") public void importTemplate(HttpServletResponse response) throws IOException { - Map<Integer, String> headerMap = new HashMap<>(); - headerMap.put(0, "部门名称"); - headerMap.put(1, "员工姓名"); - headerMap.put(2, "岗位"); - headerMap.put(3, "身份证号码"); - headerMap.put(4, "居住地址"); - headerMap.put(5, "学历"); - headerMap.put(6, "毕业院校"); - headerMap.put(7, "电话号码"); - headerMap.put(8, "短号"); - headerMap.put(9, "入职时间"); - headerMap.put(10, "试用期"); - headerMap.put(11, "社保购买日期"); - headerMap.put(12, "紧急联系人"); - headerMap.put(13, "紧急联系人电话"); - headerMap.put(14, "驾驶证类型"); - headerMap.put(15, "备注"); + String[] head = {"部门名称", "员工姓名", "岗位", "身份证号码", "居住地址", "学历", "毕业院校", "电话号码", "短号", "入职时间", "试用期", "社保购买日期", "紧急联系人", "紧急联系人电话", "驾驶证类型", "备注"}; // 下拉框列及选项:列索引 -> 下拉框选项 Map<Integer, String[]> dropdownColumns = new HashMap<>(); @@ -151,16 +135,14 @@ public class InspectionStaffController extends BaseController { dropdownColumns.put(2, roles); - int[] dateColumns = {9, 10, 11}; - List<List<String>> exampleDataList = Arrays.asList( - Arrays.asList("测试部门", "测试员工","岗位时下拉框选择","xxxxxxxxxxxxxxxxx","居住地","学历是下拉框","xxx学校","手机号","短号","2023/5/2(日期格式)","2023/5/2(日期格式)","2023/5/2(日期格式","紧急联系人","xxxxxxxx","A1,C1(有多个驾驶证类型使用逗号分割)","备注") + Arrays.asList("测试部门", "测试员工", "岗位时下拉框选择", "xxxxxxxxxxxxxxxxx", "居住地", "学历是下拉框", "xxx学校", "手机号", "短号", "2023/5/2(日期格式)", "2023/5/2(日期格式)", "2023/5/2(日期格式", "紧急联系人", "xxxxxxxx", "A1,C1(有多个驾驶证类型使用逗号分割)", "备注") ); List<Integer> textColumns = Collections.singletonList(3); // 导出空白模板到Excel - exportBlankTemplate(response, "staff_template.xlsx", "员工信息", headerMap, dropdownColumns, dateColumns, true, exampleDataList,textColumns); + exportBlankTemplate(response, "staff_template.xlsx", "员工信息", head, dropdownColumns, true, exampleDataList, textColumns); } @GetMapping("/export") @@ -177,7 +159,7 @@ public class InspectionStaffController extends BaseController { * 导入 */ @PostMapping("/import") - public CommonResult importUser(@RequestParam("file") MultipartFile file) { + public CommonResult<?> importUser(@RequestParam("file") MultipartFile file) { try { List<StaffImportExcelVO> list = ExcelUtils.read(file, StaffImportExcelVO.class); Map<String, Object> map = inspectionStaffService.importStaff(list); diff --git a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/controller/InspectionUtilController.java b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/controller/InspectionUtilController.java index 542094fa..ceb4a74e 100644 --- a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/controller/InspectionUtilController.java +++ b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/controller/InspectionUtilController.java @@ -9,6 +9,8 @@ import cn.iocoder.yudao.module.inspection.entity.InspectionEquInfo; import cn.iocoder.yudao.module.inspection.entity.InspectionFile; import cn.iocoder.yudao.module.inspection.service.IInspectionEquInfoService; import cn.iocoder.yudao.module.inspection.service.IInspectionFileService; +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.PermissionApi; import cn.iocoder.yudao.module.system.api.permission.RoleApi; import cn.iocoder.yudao.module.system.api.permission.dto.RoleReqDTO; @@ -53,6 +55,9 @@ public class InspectionUtilController { @Resource private WorkReportService workReportService; + @Resource + private DictDataApi dictDataApi; + /** * 根据用户取出当前用户的角色,只针对检测 * @@ -99,10 +104,24 @@ public class InspectionUtilController { map.put("equ", equs.getTotal()); long fileCount = fileService.count(new LambdaQueryWrapper<InspectionFile>().eq(InspectionFile::getType, "2")); map.put("file", fileCount); + //查询汇报数量 WorkReportPageReqVO workReportPageReqVO = new WorkReportPageReqVO(); workReportPageReqVO.setUserId(SecurityFrameworkUtils.getLoginUserId()); workReportPageReqVO.setServicePackageId("jiance"); + //根据dictType查询角色 + List<DictDataRespDTO> roleList = dictDataApi.getDictDataList("ins_high_rise"); + //公司高层角色code集合 + List<String> codes = roleList.stream().map(DictDataRespDTO::getValue).collect(Collectors.toList()); + + Map<Long, List<String>> longListMap = permissionApi.roleCodesByUserIds(Collections.singletonList(SecurityFrameworkUtils.getLoginUserId())); + List<String> roleKey = longListMap.get(SecurityFrameworkUtils.getLoginUserId()); + + //判断当前登陆人的角色是否是公司高层 + boolean isCompanyLeader = roleKey != null && roleKey.stream().anyMatch(codes::contains); + if (isCompanyLeader) { + workReportPageReqVO.setUserId(null); + } Long reportCount = workReportService.queryReportCount(workReportPageReqVO); map.put("report", reportCount); return success(map); diff --git a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/controller/PartnerOwnController.java b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/controller/PartnerOwnController.java index 19da2a91..d070e643 100644 --- a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/controller/PartnerOwnController.java +++ b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/controller/PartnerOwnController.java @@ -762,6 +762,18 @@ public class PartnerOwnController extends BaseController { return success(partnerList.staticsTable5(partners.getPartnerId(), startTime, endTime)); } + /** + * 查询检测类型统计 + * + * @param startTime 开始时间 + * @param endTime 结束时间 + * @return 结果 + */ + @GetMapping("/queryInspectionSkuList") + public CommonResult<?> queryInspectionSkuList(String startTime, String endTime) { + return success(partnerList.queryInspectionSkuList(startTime, endTime)); + } + /** * 根据inspection_info的id查有的项目名称 * @@ -797,16 +809,27 @@ public class PartnerOwnController extends BaseController { /** * 分类计数 * + * @param startTime 开始时间 + * @param endTime 结束时间 + * @param chooseStatus 状态 * @author 小李 * @date 17:14 2024/12/16 - * @param startTime 开始时间 - * @param endTime 结束时间 - * @param chooseStatus 状态 - **/ + **/ @GetMapping("/getTypeCount") public CommonResult<?> getTypeCount(@RequestParam(value = "startTime", required = false) String startTime, @RequestParam(value = "endTime", required = false) String endTime, - @RequestParam(value = "chooseStatus", required = false) String chooseStatus){ + @RequestParam(value = "chooseStatus", required = false) String chooseStatus) { return success(partnerList.getTypeCount(startTime, endTime, chooseStatus)); } + + /** + * 获取员工统计 + * + * @param dlInspectionProject 项目 + * @return 结果 + */ + @PostMapping("/getStaffCount") + public CommonResult<?> getStaffCount(@RequestBody DlInspectionProject dlInspectionProject) { + return success(partnerList.getStaffCount(dlInspectionProject)); + } } diff --git a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/controller/ShopInspectionGoodsController.java b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/controller/ShopInspectionGoodsController.java index 1513affb..f42da64f 100644 --- a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/controller/ShopInspectionGoodsController.java +++ b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/controller/ShopInspectionGoodsController.java @@ -4,15 +4,20 @@ import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.Set; +import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; + +import cn.hutool.core.bean.BeanUtil; 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.framework.security.core.LoginUser; import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils; import cn.iocoder.yudao.module.core.text.Convert; import cn.iocoder.yudao.module.core.text.ServletUtils; import cn.iocoder.yudao.module.partner.service.IPartnerWorkerService; import cn.iocoder.yudao.module.payment.service.OrderInfoService; +import cn.iocoder.yudao.module.payment.vo.OrderInfoExportVo; import cn.iocoder.yudao.module.system.dal.dataobject.permission.RoleDO; import cn.iocoder.yudao.module.system.service.permission.PermissionService; import cn.iocoder.yudao.module.system.service.permission.RoleService; @@ -32,6 +37,8 @@ import cn.iocoder.yudao.module.core.controller.BaseController; import cn.iocoder.yudao.module.inspection.entity.ShopInspectionGoods; import cn.iocoder.yudao.module.inspection.service.IShopInspectionGoodsService; +import javax.servlet.http.HttpServletResponse; + /** * 检测商品Controller @@ -41,8 +48,7 @@ import cn.iocoder.yudao.module.inspection.service.IShopInspectionGoodsService; */ @RestController @RequestMapping("/admin-api/system/inspectionGoods") -public class ShopInspectionGoodsController extends BaseController -{ +public class ShopInspectionGoodsController extends BaseController { @Autowired private IShopInspectionGoodsService shopInspectionGoodsService; @Autowired @@ -63,11 +69,10 @@ public class ShopInspectionGoodsController extends BaseController // @PreAuthorize("@ss.hasPermi('system:inspectionGoods:list')") @GetMapping("/listSystem") public CommonResult listSystem(ShopInspectionGoods shopInspectionGoods, - @RequestParam(value = "pageNum" ,required = false ,defaultValue = "1") Integer pageNum, - @RequestParam(value ="pageSize" ,required = false ,defaultValue = "10") Integer pageSize) - { + @RequestParam(value = "pageNum", required = false, defaultValue = "1") Integer pageNum, + @RequestParam(value = "pageSize", required = false, defaultValue = "10") Integer pageSize) { Page<ShopInspectionGoods> page = new Page<>(pageNum, pageSize); - IPage<ShopInspectionGoods> list = shopInspectionGoodsService.listSystem(page,shopInspectionGoods); + IPage<ShopInspectionGoods> list = shopInspectionGoodsService.listSystem(page, shopInspectionGoods); return success(list); } @@ -76,12 +81,12 @@ public class ShopInspectionGoodsController extends BaseController */ @GetMapping("/listPartnerGoods") public CommonResult listPartnerGoods(ShopInspectionGoods shopInspectionGoods, - @RequestParam(value = "pageNum" ,required = false ,defaultValue = "1") Integer pageNum, - @RequestParam(value ="pageSize" ,required = false ,defaultValue = "10") Integer pageSize) throws Exception { + @RequestParam(value = "pageNum", required = false, defaultValue = "1") Integer pageNum, + @RequestParam(value = "pageSize", required = false, defaultValue = "10") Integer pageSize) throws Exception { ShopMallPartners one = appInspectionPartnerService.shopInfoByUserId(); shopInspectionGoods.setPartnerId(one.getPartnerId().intValue()); Page<ShopInspectionGoods> page = new Page<>(pageNum, pageSize); - IPage<ShopInspectionGoods> list = shopInspectionGoodsService.listPartnerGoods(page,shopInspectionGoods); + IPage<ShopInspectionGoods> list = shopInspectionGoodsService.listPartnerGoods(page, shopInspectionGoods); return success(list); } @@ -92,7 +97,7 @@ public class ShopInspectionGoodsController extends BaseController */ @GetMapping("/categoryList") public CommonResult categoryList() throws Exception { - return success( shopInspectionGoodsService.categoryList()); + return success(shopInspectionGoodsService.categoryList()); } /** @@ -107,7 +112,6 @@ public class ShopInspectionGoodsController extends BaseController } - /** * 商品详细信息 */ @@ -122,7 +126,7 @@ public class ShopInspectionGoodsController extends BaseController // throw new Exception("您不是商户"); // } - return success(appInspectionPartnerService.goodsDetail(goodsId)); + return success(appInspectionPartnerService.goodsDetail(goodsId)); } /** @@ -131,45 +135,47 @@ public class ShopInspectionGoodsController extends BaseController @PostMapping("/partnerEditGoods") public CommonResult partnerEditGoods(@RequestBody ShopInspectionGoods goods) throws Exception { LoginUser loginUser = SecurityFrameworkUtils.getLoginUser(); - LambdaQueryWrapper<ShopMallPartners> queryWrapper =new LambdaQueryWrapper<>(); - queryWrapper.eq(ShopMallPartners::getUserId,loginUser.getId()).eq(ShopMallPartners::getType,"jc").last("limit 1"); + LambdaQueryWrapper<ShopMallPartners> queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(ShopMallPartners::getUserId, loginUser.getId()).eq(ShopMallPartners::getType, "jc").last("limit 1"); ShopMallPartners one = appInspectionPartnerService.getOne(queryWrapper); - if (ObjectUtils.isEmpty(one)){ + if (ObjectUtils.isEmpty(one)) { throw new Exception("您不是商户"); } goods.setPartnerId(one.getPartnerId().intValue()); appInspectionPartnerService.editGoods(goods); - return success(); + return success(); } + /** * 上下架 */ @PostMapping("/partnerChangeListing") public CommonResult partnerChangeListing(Long goodsId) throws Exception { LoginUser loginUser = SecurityFrameworkUtils.getLoginUser(); - LambdaQueryWrapper<ShopMallPartners> queryWrapper =new LambdaQueryWrapper<>(); - queryWrapper.eq(ShopMallPartners::getUserId,loginUser.getId()).eq(ShopMallPartners::getType,"jc").last("limit 1"); + LambdaQueryWrapper<ShopMallPartners> queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(ShopMallPartners::getUserId, loginUser.getId()).eq(ShopMallPartners::getType, "jc").last("limit 1"); ShopMallPartners one = appInspectionPartnerService.getOne(queryWrapper); - if (ObjectUtils.isEmpty(one)){ + if (ObjectUtils.isEmpty(one)) { throw new Exception("您不是商户"); } appInspectionPartnerService.changeListing(goodsId); - return success(); + return success(); } + /** * 删除商品 */ @PostMapping("/partnerDelGoods") public CommonResult partnerDelGoods(Long goodsId) throws Exception { LoginUser loginUser = SecurityFrameworkUtils.getLoginUser(); - LambdaQueryWrapper<ShopMallPartners> queryWrapper =new LambdaQueryWrapper<>(); - queryWrapper.eq(ShopMallPartners::getUserId,loginUser.getId()).eq(ShopMallPartners::getType,"jc").last("limit 1"); + LambdaQueryWrapper<ShopMallPartners> queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(ShopMallPartners::getUserId, loginUser.getId()).eq(ShopMallPartners::getType, "jc").last("limit 1"); ShopMallPartners one = appInspectionPartnerService.getOne(queryWrapper); - if (ObjectUtils.isEmpty(one)){ + if (ObjectUtils.isEmpty(one)) { throw new Exception("您不是商户"); } appInspectionPartnerService.delGoods(goodsId); - return success(); + return success(); } /** @@ -184,19 +190,20 @@ public class ShopInspectionGoodsController extends BaseController List<RoleDO> roleList = roleService.getRoleList(userRoleIdListByUserId); List<String> roles = roleList.stream().map(RoleDO::getCode).collect(Collectors.toList()); - ShopMallPartners partner = new ShopMallPartners(); - if (roles.contains("jcshop")){ - LambdaQueryWrapper<ShopMallPartners> queryWrapper =new LambdaQueryWrapper<>(); - queryWrapper.orderByAsc(ShopMallPartners::getPartnerId).eq(ShopMallPartners::getType,"jc").eq(ShopMallPartners::getIsBanned,"0").last("limit 1"); + ShopMallPartners partner = new ShopMallPartners(); + if (roles.contains("jcshop")) { + LambdaQueryWrapper<ShopMallPartners> queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.orderByAsc(ShopMallPartners::getPartnerId).eq(ShopMallPartners::getType, "jc").eq(ShopMallPartners::getIsBanned, "0").last("limit 1"); partner = appInspectionPartnerService.getOne(queryWrapper); - if (ObjectUtil.isEmpty(partner)){ + if (ObjectUtil.isEmpty(partner)) { return error(); } - }else if (roles.contains("jcworker")){ - LambdaQueryWrapper<PartnerWorker> queryWrapperWork =new LambdaQueryWrapper<>(); - queryWrapperWork.eq(PartnerWorker::getUserId,user.getId()); + } else if (roles.contains("jcworker")) { + LambdaQueryWrapper<PartnerWorker> queryWrapperWork = new LambdaQueryWrapper<>(); + queryWrapperWork.eq(PartnerWorker::getUserId, user.getId()); + queryWrapperWork.last("limit 1"); PartnerWorker worker = partnerWorkerService.getOne(queryWrapperWork); - if (ObjectUtil.isEmpty(worker)){ + if (ObjectUtil.isEmpty(worker)) { return error(); } partner.setPartnerId(worker.getPartnerId()); @@ -204,17 +211,58 @@ public class ShopInspectionGoodsController extends BaseController shopInspectionOrder.setPartnerId(partner.getPartnerId()); shopInspectionOrder.setValidationTime(new Date()); Page<OrderInfo> page = new Page<>(pageNo, pageSize); - return CommonResult.success(orderInfoService.queryListPage(shopInspectionOrder,page)); + return CommonResult.success(orderInfoService.queryListPage(shopInspectionOrder, page)); } + /** + * 导出检测订单列表 + * + * @param response + * @param shopInspectionOrder + * @param pageNo + * @param pageSize + * @throws Exception + */ + @PostMapping("/exportPartnerOrderListSystem") + public void exportPartnerOrderListSystem(HttpServletResponse response, + OrderInfo shopInspectionOrder, + @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo, + @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) throws Exception { + LoginUser user = SecurityFrameworkUtils.getLoginUser(); + Set<Long> userRoleIdListByUserId = permissionService.getUserRoleIdListByUserId(user.getId()); + List<RoleDO> roleList = roleService.getRoleList(userRoleIdListByUserId); + List<String> roles = roleList.stream().map(RoleDO::getCode).collect(Collectors.toList()); + + ShopMallPartners partner = new ShopMallPartners(); + if (roles.contains("jcshop")) { + LambdaQueryWrapper<ShopMallPartners> queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.orderByAsc(ShopMallPartners::getPartnerId).eq(ShopMallPartners::getType, "jc").eq(ShopMallPartners::getIsBanned, "0").last("limit 1"); + partner = appInspectionPartnerService.getOne(queryWrapper); + if (ObjectUtil.isEmpty(partner)) { + return; + } + } else if (roles.contains("jcworker")) { + LambdaQueryWrapper<PartnerWorker> queryWrapperWork = new LambdaQueryWrapper<>(); + queryWrapperWork.eq(PartnerWorker::getUserId, user.getId()); + queryWrapperWork.last("limit 1"); + PartnerWorker worker = partnerWorkerService.getOne(queryWrapperWork); + if (ObjectUtil.isEmpty(worker)) { + return; + } + partner.setPartnerId(worker.getPartnerId()); + } + shopInspectionOrder.setPartnerId(partner.getPartnerId()); + shopInspectionOrder.setValidationTime(new Date()); + Page<OrderInfo> page = new Page<>(pageNo, pageSize); + orderInfoService.exportExcel(response, shopInspectionOrder, page); + } /** * 获取检测商品详细信息 */ @GetMapping(value = "/getByIdSystem") - public CommonResult getByIdSystem(@RequestParam("id") Long id) - { + public CommonResult getByIdSystem(@RequestParam("id") Long id) { return success(shopInspectionGoodsService.selectShopInspectionGoodsById(id)); } @@ -223,8 +271,7 @@ public class ShopInspectionGoodsController extends BaseController */ // @PreAuthorize("@ss.hasPermi('system:inspectionGoods:add')") @PostMapping("/add") - public CommonResult add(@RequestBody ShopInspectionGoods shopInspectionGoods) - { + public CommonResult add(@RequestBody ShopInspectionGoods shopInspectionGoods) { shopInspectionGoods.setIsListing("1"); return toAjax(shopInspectionGoodsService.insertShopInspectionGoods(shopInspectionGoods)); } @@ -234,8 +281,7 @@ public class ShopInspectionGoodsController extends BaseController */ // @PreAuthorize("@ss.hasPermi('system:inspectionGoods:edit')") @PostMapping("/edit") - public CommonResult edit(@RequestBody ShopInspectionGoods shopInspectionGoods) - { + public CommonResult edit(@RequestBody ShopInspectionGoods shopInspectionGoods) { return toAjax(shopInspectionGoodsService.updateShopInspectionGoods(shopInspectionGoods)); } @@ -244,8 +290,7 @@ public class ShopInspectionGoodsController extends BaseController */ // @PreAuthorize("@ss.hasPermi('system:inspectionGoods:edit')") @PostMapping("/examine") - public CommonResult examine(@RequestBody ShopInspectionGoods shopInspectionGoods) - { + public CommonResult examine(@RequestBody ShopInspectionGoods shopInspectionGoods) { return toAjax(shopInspectionGoodsService.examine(shopInspectionGoods)); } @@ -254,26 +299,24 @@ public class ShopInspectionGoodsController extends BaseController */ // @PreAuthorize("@ss.hasPermi('system:inspectionGoods:remove')") @PostMapping("/del") - public CommonResult remove(@RequestParam("idList") Long[] ids) - { + public CommonResult remove(@RequestParam("idList") Long[] ids) { return toAjax(shopInspectionGoodsService.deleteShopInspectionGoodsByIds(ids)); } @GetMapping("/listWx") public CommonResult listWx(ShopInspectionGoods shopInspectionGoods, - @RequestParam(value = "pageNum" ,required = false ,defaultValue = "1") Integer pageNum, - @RequestParam(value ="pageSize" ,required = false ,defaultValue = "10") Integer pageSize) - { + @RequestParam(value = "pageNum", required = false, defaultValue = "1") Integer pageNum, + @RequestParam(value = "pageSize", required = false, defaultValue = "10") Integer pageSize) { Page<ShopInspectionGoods> page = new Page<>(pageNum, pageSize); - IPage<ShopInspectionGoods> list = shopInspectionGoodsService.selectShopInspectionGoodsListWx(page,shopInspectionGoods); + IPage<ShopInspectionGoods> list = shopInspectionGoodsService.selectShopInspectionGoodsListWx(page, shopInspectionGoods); return success(list); } + /** * 获取检测商品详细信息 */ @GetMapping(value = "/{id}") - public CommonResult getInfo(@PathVariable("id") Long id) - { + public CommonResult getInfo(@PathVariable("id") Long id) { return success(shopInspectionGoodsService.selectShopInspectionGoodsById(id)); } diff --git a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/entity/InspectionEquInfo.java b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/entity/InspectionEquInfo.java index 9318f227..3ab64a60 100644 --- a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/entity/InspectionEquInfo.java +++ b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/entity/InspectionEquInfo.java @@ -73,6 +73,24 @@ public class InspectionEquInfo extends TenantBaseDO */ private Long folderId; + /** 检测证书编号 */ + private String certificateNumber; + + /** 制造商 */ + private String manufacturer; + + /** 电话 */ + private String mobile; + + /** 地址 */ + private String address; + + /** 邮编 */ + private String postcode; + + /** 邮箱 */ + private String email; + /** * 文件集合 */ diff --git a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/mapper/AppInspectionPartnerMapper.java b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/mapper/AppInspectionPartnerMapper.java index a92b2c7c..7cafa60c 100644 --- a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/mapper/AppInspectionPartnerMapper.java +++ b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/mapper/AppInspectionPartnerMapper.java @@ -14,76 +14,125 @@ import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; + import java.util.List; import java.util.Map; @Mapper public interface AppInspectionPartnerMapper extends BaseMapper<ShopMallPartners> { ShopMallPartners selectById(@Param("id") Long id); + ShopMallPartners selectByIdNew(); + IPage<PartnerListVo> partnerList(Page<PartnerListVo> page, @Param("vo") PartnerListQuery partnerListQuery); + PartnerListVo shopDetail(PartnerListQuery partnerListQuery); + void addSalesNum(@Param("partnerId") Long partnerId); - StatisticsInfo workNum(@Param("partnerId") Long partnerId,@Param("timeStr") String timeStr); - Integer srlNum(@Param("partnerId") Long partnerId,@Param("timeStr") String timeStr); - Integer hgNum(@Param("partnerId") Long partnerId,@Param("timeStr") String timeStr); + + StatisticsInfo workNum(@Param("partnerId") Long partnerId, @Param("timeStr") String timeStr); + + Integer srlNum(@Param("partnerId") Long partnerId, @Param("timeStr") String timeStr); + + Integer hgNum(@Param("partnerId") Long partnerId, @Param("timeStr") String timeStr); //订单数量接口 - StatisticsInfo orderNum(@Param("partnerId") Long partnerId,@Param("timeStr") String timeStr); - Integer allAmount(@Param("partnerId") Long partnerId); - Integer todayAmount(@Param("partnerId") Long partnerId,@Param("timeStr") String timeStr); - List<HotGoodsVo> hotGoodsList(@Param("partnerId") Long partnerId,@Param("dateStr")String dateStr); - List<HotGoodsVo> newHotGoodsList(@Param("dateStr")String dateStr); - IPage<GoodsVo> manageGoodsList(Page<GoodsVo> page,@Param("partnerId") Long partnerId, @Param("isListing")String isListing,@Param("goodsTitle") String goodsTitle); - IPage<OrderAppDetail> orderList(Page<OrderAppDetail> page,@Param("partnerId") Long partnerId, @Param("phoneNum") String phoneNum,@Param("title") String title); - List<PartnerWorker> getWorkList(@Param("partnerId")Long partnerId, @Param("postId") Long postId, @Param("workName") String workName, @Param("phoneNum")String phoneNum); - IPage<PartnerWorker> pageWorkList(@Param("partnerId")Long partnerId, @Param("postId") Long postId, @Param("workName") String workName, @Param("phoneNum")String phoneNum,Page<LabelRespVO> page); - IPage<InspectionInfo> inspectionList(Page<InspectionInfo> page,@Param("partnerId")Long partnerId, @Param("status") String status, @Param("carNum")String carNum); - List<InspectionInfo> workerInspectionList(@Param("workerId")Long workerId,@Param("status") String status, @Param("searchValue")String searchValue); - IPage<OrderInfo> validationList(Page<OrderInfo> page, @Param("partnerId") Long partnerId, @Param("searchValue") String searchValue); - IPage<InspectionPickCar> getPickCarList(Page page,@Param("partnerId") Long partnerId, @Param("phoneNum") String phoneNum, @Param("pickStatus") String pickStatus); - IPage<InspectionPickCar> getPickCarListOfWorker(Page<InspectionPickCar> page,@Param("workerId") Long workerId, @Param("phoneNum") String phoneNum); + StatisticsInfo orderNum(@Param("partnerId") Long partnerId, @Param("timeStr") String timeStr); + + Integer allAmount(@Param("partnerId") Long partnerId); + + Integer todayAmount(@Param("partnerId") Long partnerId, @Param("timeStr") String timeStr); + + List<HotGoodsVo> hotGoodsList(@Param("partnerId") Long partnerId, @Param("dateStr") String dateStr); + + List<HotGoodsVo> newHotGoodsList(@Param("dateStr") String dateStr); + + IPage<GoodsVo> manageGoodsList(Page<GoodsVo> page, @Param("partnerId") Long partnerId, @Param("isListing") String isListing, @Param("goodsTitle") String goodsTitle); + + IPage<OrderAppDetail> orderList(Page<OrderAppDetail> page, @Param("partnerId") Long partnerId, @Param("phoneNum") String phoneNum, @Param("title") String title); + + List<PartnerWorker> getWorkList(@Param("partnerId") Long partnerId, @Param("postId") Long postId, @Param("workName") String workName, @Param("phoneNum") String phoneNum); + + IPage<PartnerWorker> pageWorkList(@Param("partnerId") Long partnerId, @Param("postId") Long postId, @Param("workName") String workName, @Param("phoneNum") String phoneNum, Page<LabelRespVO> page); + + IPage<InspectionInfo> inspectionList(Page<InspectionInfo> page, @Param("partnerId") Long partnerId, @Param("status") String status, @Param("carNum") String carNum); + + List<InspectionInfo> workerInspectionList(@Param("workerId") Long workerId, @Param("status") String status, @Param("searchValue") String searchValue); + + IPage<OrderInfo> validationList(Page<OrderInfo> page, @Param("partnerId") Long partnerId, @Param("searchValue") String searchValue); + + IPage<InspectionPickCar> getPickCarList(Page page, @Param("partnerId") Long partnerId, @Param("phoneNum") String phoneNum, @Param("pickStatus") String pickStatus); + + IPage<InspectionPickCar> getPickCarListOfWorker(Page<InspectionPickCar> page, @Param("workerId") Long workerId, @Param("phoneNum") String phoneNum); + + List<OrderInfo> chartInfoAmount(@Param("startTime") String startTime, @Param("endTime") String endTime, @Param("partnerId") Long partnerId); + + List<OrderInfo> newChartInfoAmount(@Param("startTime") String startTime, @Param("endTime") String endTime); + + List<OrderInfo> chartInfoNum(@Param("startTime") String startTime, @Param("endTime") String endTime, @Param("partnerId") Long partnerId); + + List<OrderInfo> newChartInfoNum(@Param("startTime") String startTime, @Param("endTime") String endTime); + + List<Map<String, String>> chartInfoRatio(@Param("startTime") String startTime, @Param("endTime") String endTime, @Param("partnerId") Long partnerId); + + List<Map<String, String>> newChartInfoRatio(@Param("startTime") String startTime, @Param("endTime") String endTime); - List<OrderInfo> chartInfoAmount(@Param("startTime") String startTime,@Param("endTime")String endTime,@Param("partnerId")Long partnerId); - List<OrderInfo> newChartInfoAmount(@Param("startTime") String startTime,@Param("endTime")String endTime); - List<OrderInfo> chartInfoNum(@Param("startTime") String startTime,@Param("endTime")String endTime,@Param("partnerId")Long partnerId); - List<OrderInfo> newChartInfoNum(@Param("startTime") String startTime,@Param("endTime")String endTime); - List<Map<String,String>> chartInfoRatio(@Param("startTime") String startTime, @Param("endTime")String endTime, @Param("partnerId")Long partnerId); - List<Map<String,String>> newChartInfoRatio(@Param("startTime") String startTime, @Param("endTime")String endTime); List<ShopInspectionCategory> partnerCategoryList(@Param("partnerId") Long partnerId); - OrderInfo chartLineInspectionAmount(@Param("partnerId") Long partnerId,@Param("dateStr") String dateStr); + + OrderInfo chartLineInspectionAmount(@Param("partnerId") Long partnerId, @Param("dateStr") String dateStr); + OrderInfo newChartLineInspectionAmount(@Param("dateStr") String dateStr); - Map<String,Double> staticsTable1(@Param("partnerId") Long partnerId,@Param("startTime") String startTime,@Param("endTime") String endTime); - Map<String,Double> newStaticsTable1(@Param("startTime") String startTime,@Param("endTime") String endTime); - Map<String,Integer> staticsTable2(@Param("partnerId") Long partnerId,@Param("startTime") String startTime,@Param("endTime") String endTime); - Map<String,Integer> newStaticsTable2(@Param("startTime") String startTime,@Param("endTime") String endTime); - List<Map<String,Object>> staticsTable3(@Param("partnerId") Long partnerId,@Param("startTime") String startTime,@Param("endTime") String endTime); - List<Map<String,Object>> newStaticsTable3(@Param("startTime") String startTime,@Param("endTime") String endTime); - List<Map<String,Object>> staticsTable3Detail(@Param("partnerId") Long partnerId,@Param("startTime") String startTime,@Param("endTime") String endTime,@Param("remark") String remark); - List<Map<String,Object>> staticsTable4(@Param("partnerId") Long partnerId,@Param("startTime") String startTime,@Param("endTime") String endTime); - List<Map<String,Object>> staticsTable5(@Param("partnerId") Long partnerId,@Param("startTime") String startTime,@Param("endTime") String endTime); - Long dhjNum(@Param("partnerId") Long partnerId,@Param("dateStr") String dateStr); - Long getAppointNum(@Param("partnerId") Long partnerId,@Param("formDate") String formDate); - Long getPickNum(@Param("partnerId") Long partnerId,@Param("formDate") String formDate); + + Map<String, Double> staticsTable1(@Param("partnerId") Long partnerId, @Param("startTime") String startTime, @Param("endTime") String endTime); + + Map<String, Double> newStaticsTable1(@Param("startTime") String startTime, @Param("endTime") String endTime); + + Map<String, Integer> staticsTable2(@Param("partnerId") Long partnerId, @Param("startTime") String startTime, @Param("endTime") String endTime); + + Map<String, Integer> newStaticsTable2(@Param("startTime") String startTime, @Param("endTime") String endTime); + + List<Map<String, Object>> staticsTable3(@Param("partnerId") Long partnerId, @Param("startTime") String startTime, @Param("endTime") String endTime); + + List<Map<String, Object>> newStaticsTable3(@Param("startTime") String startTime, @Param("endTime") String endTime); + + List<Map<String, Object>> staticsTable3Detail(@Param("partnerId") Long partnerId, @Param("startTime") String startTime, @Param("endTime") String endTime, @Param("remark") String remark); + + List<Map<String, Object>> staticsTable4(@Param("partnerId") Long partnerId, @Param("startTime") String startTime, @Param("endTime") String endTime); + + List<Map<String, Object>> staticsTable5(@Param("partnerId") Long partnerId, @Param("startTime") String startTime, @Param("endTime") String endTime); + + Long dhjNum(@Param("partnerId") Long partnerId, @Param("dateStr") String dateStr); + + Long getAppointNum(@Param("partnerId") Long partnerId, @Param("formDate") String formDate); + + Long getPickNum(@Param("partnerId") Long partnerId, @Param("formDate") String formDate); /** * 根据时间查订单 * + * @param startTime 开始时间 非必传 + * @param endTime 结束时间 非必传 * @author 小李 * @date 14:39 2024/12/12 - * @param startTime 开始时间 非必传 - * @param endTime 结束时间 非必传 **/ IPage<OrderTable> getOrderByDate(@Param("startTime") String startTime, @Param("endTime") String endTime, @Param("chooseStatus") String chooseStatus, Page<OrderTable> page); /** * 分类计数 * + * @param startTime 开始时间 + * @param endTime 结束时间 + * @param chooseStatus 状态 * @author 小李 * @date 17:14 2024/12/16 - * @param startTime 开始时间 - * @param endTime 结束时间 - * @param chooseStatus 状态 **/ List<Map<String, Long>> getTypeCount(@Param("startTime") String startTime, @Param("endTime") String endTime, @Param("chooseStatus") String chooseStatus); + + /** + * 获取检测类型统计 + * + * @param startTime 开始时间 + * @param endTime 结束时间 + */ + List<Map<String, Object>> queryInspectionSkuList(@Param("startTime") String startTime, @Param("endTime") String endTime); } diff --git a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/mapper/DlInspectionProjectMapper.java b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/mapper/DlInspectionProjectMapper.java index b00d94c0..dbd73789 100644 --- a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/mapper/DlInspectionProjectMapper.java +++ b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/mapper/DlInspectionProjectMapper.java @@ -3,11 +3,14 @@ package cn.iocoder.yudao.module.inspection.mapper; import cn.iocoder.yudao.module.inspection.entity.DlInspectionProject; import cn.iocoder.yudao.module.inspection.vo.DlInspectionProjectPageReqVO; import cn.iocoder.yudao.module.inspection.vo.DlInspectionProjectRespVO; +import cn.iocoder.yudao.module.inspection.vo.InspectionOrderExportVo; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.metadata.IPage; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; +import java.util.List; + /** * 检测项目 Mapper * @@ -16,4 +19,6 @@ import org.apache.ibatis.annotations.Param; @Mapper public interface DlInspectionProjectMapper extends BaseMapper<DlInspectionProject> { IPage<DlInspectionProjectRespVO> selectListPage(@Param("page") IPage page,@Param("entity") DlInspectionProjectPageReqVO pageReqVO); + + List<InspectionOrderExportVo> queryProjectWorkerName(@Param("orderIds") List<Long> orderIds); } \ No newline at end of file diff --git a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/mapper/InspectionWorkNodeMapper.java b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/mapper/InspectionWorkNodeMapper.java index f2287d84..5e04339a 100644 --- a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/mapper/InspectionWorkNodeMapper.java +++ b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/mapper/InspectionWorkNodeMapper.java @@ -1,5 +1,6 @@ package cn.iocoder.yudao.module.inspection.mapper; +import cn.iocoder.yudao.module.inspection.entity.DlInspectionProject; import cn.iocoder.yudao.module.inspection.entity.InspectionWorkNode; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.metadata.IPage; @@ -37,4 +38,6 @@ public interface InspectionWorkNodeMapper extends BaseMapper<InspectionWorkNode> * @param workNodes */ void recheck(@Param("list") List<InspectionWorkNode> workNodes, @Param("status") String status); + + List<Map<String, Object>> getStaffCount(DlInspectionProject dlInspectionProject); } diff --git a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/AppInspectionPartnerService.java b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/AppInspectionPartnerService.java index c003fae6..6a1b4fd6 100644 --- a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/AppInspectionPartnerService.java +++ b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/AppInspectionPartnerService.java @@ -23,121 +23,195 @@ import java.util.Map; public interface AppInspectionPartnerService extends IService<ShopMallPartners> { - IPage<PartnerListVo> partnerList(Page<PartnerListVo> page, PartnerListQuery partnerListQuery); - List<ShopInspectionCategory> categoryList(Long partnerId); - PartnerListVo shopDetail(PartnerListQuery partnerListQuery); - void addSalesNum(Long partnerId); - ShopMallPartners shopInfo() throws Exception; + IPage<PartnerListVo> partnerList(Page<PartnerListVo> page, PartnerListQuery partnerListQuery); - /** - * 重写shopInfo()方法 - * - */ - ShopMallPartners shopInfoByUserId() throws Exception; + List<ShopInspectionCategory> categoryList(Long partnerId); - JSONObject getAppointAndPickNum() throws Exception; + PartnerListVo shopDetail(PartnerListQuery partnerListQuery); - void startOrEnd(Long partnerId); - StatisticsInfo statisticsInfo(Long partnerId); - JSONObject chartInfoAmount(Long partnerId,String unit); - JSONObject newChartInfoAmount(String unit); - JSONObject chartLineInspectionNum(Long partnerId,String unit); - JSONObject newChartLineInspectionNum(String unit); - JSONObject chartLineInspectionAmount(Long partnerId,String unit); + void addSalesNum(Long partnerId); - JSONObject chartInfoNum(Long partnerId,String unit); - JSONObject newChartInfoNum(String unit); - JSONObject chartInfoRatio(Long partnerId, String unit); - JSONObject newChartInfoRatio(String unit); - List<OrderInfo> orderInfo(Long partnerId); - List<HotGoodsVo> hotGoodsList(Long partnerId); - List<HotGoodsVo> newHotGoodsList(); - void addGoods(ShopInspectionGoods goods) throws Exception; - IPage<GoodsVo> goodsList(Page<GoodsVo> page,Long partnerId, String isListing, String goodsTitle); - List<JSONObject> canUseGoods(Long partnerId); - ShopInspectionGoods goodsDetail(Long goodsId); - void editGoods(ShopInspectionGoods goods) throws Exception; - void editSkuPrice(ShopInspectionGoods goods) throws Exception; + ShopMallPartners shopInfo() throws Exception; - void changeListing(Long goodsId) throws Exception; - void delGoods(Long goodsId) throws Exception; - void editPartnerInfo(ShopMallPartners partners); - PartnerVo getPartnerInfo(Long partnerId); - PartnerBalance accountInfo(Long partnerId); - IPage<PartnerBalanceDetail> accountDetail(Page<PartnerBalanceDetail> page,Long partnerId, Integer pageNum, Integer pageSize); - IPage<OrderAppDetail> orderList(Page<OrderAppDetail> page,Long partnerId,String phoneNum, String title); - OrderAppDetail orderDetail(Long partnerId,Long orderId); - Long orderDetailByCode(Long partnerId,String code) throws Exception; - void takeOut(Long partnerId,Long orderId,Long workId,String carNum) throws Exception; - void addWorker(Long partnerId,String realName,String phoneNum,Long postId) throws Exception; - List<PartnerWorker> getWorkList(Long partnerId, Long postId, String workName, String phoneNum); + /** + * 重写shopInfo()方法 + */ + ShopMallPartners shopInfoByUserId() throws Exception; - IPage<PartnerWorker> pageWorkList(Long partnerId, Long postId, String workName, String phoneNum, Page<LabelRespVO> page); + JSONObject getAppointAndPickNum() throws Exception; - void delWorker(Long partnerId,Long workId); + void startOrEnd(Long partnerId); - IPage<InspectionInfo> inspectionList(Page<InspectionInfo> page,Long partnerId, String status, String carNum); - InspectionInfoVo inspectionDetail(Long inspectionInfoId); + StatisticsInfo statisticsInfo(Long partnerId); - List<InspectionInfo> workerInspectionList(Long partnerId,String status,String searchValue); - void addStepInfo(InspectionStepInfo stepInfo); - void stopInspection(InspectionInfo info) throws Exception; - void makeCertOk(Long inspectionId); - IPage<InspectionAppointment> getAppointmentList(Page<InspectionAppointment> page,Long partnerId,String phoneNum); - IPage<OrderInfo> validationList(Page<OrderInfo> page,Long partnerId,String searchValue); - void sendCoupon(ShopCouponTemplate template) throws Exception; - IPage<ShopCouponTemplate> listCoupon(Page<ShopCouponTemplate> page,Long partnerId,String searchValue); - void delCoupon(Long partnerId,Long id); - void designatePickCarWorker(Long pickCarId,Long workerId); - IPage<InspectionPickCar> getPickCarList(Page page,Long partnerId, String phoneNum,String pickStatus); - InspectionPickCar getPickCarDetail(Long dataId); - IPage<InspectionPickCar> getPickCarListOfWorker(Page<InspectionPickCar> page,Long workerId, String phoneNum); - JSONObject vehicleLicenseOCR(String imagePath) throws Exception; - void offlineCharging(InspectionInfoVo infoVo); - String workOrderView(Long inspectionId); - List<PostDO> inspectionPostInfo(); - Map<String,Double> staticsTable1(Long partnerId, String startTime, String endTime); - Map<String,Double> newStaticsTable1(String startTime, String endTime); - Map<String,Integer> staticsTable2(Long partnerId, String startTime, String endTime); - Map<String,Integer> newStaticsTable2(String startTime, String endTime); - List<Map<String,Object>> staticsTable3(Long partnerId, String startTime, String endTime); - List<Map<String,Object>> newStaticsTable3(String startTime, String endTime); - List<Map<String,Object>> staticsTable3Detail(Long partnerId, String startTime, String endTime,String remark); + JSONObject chartInfoAmount(Long partnerId, String unit); - List<Map<String,Object>> staticsTable4(Long partnerId, String startTime, String endTime); - List<Map<String,Object>> staticsTable5(Long partnerId, String startTime, String endTime); + JSONObject newChartInfoAmount(String unit); + + JSONObject chartLineInspectionNum(Long partnerId, String unit); + + JSONObject newChartLineInspectionNum(String unit); + + JSONObject chartLineInspectionAmount(Long partnerId, String unit); + + JSONObject chartInfoNum(Long partnerId, String unit); + + JSONObject newChartInfoNum(String unit); + + JSONObject chartInfoRatio(Long partnerId, String unit); + + JSONObject newChartInfoRatio(String unit); + + List<OrderInfo> orderInfo(Long partnerId); + + List<HotGoodsVo> hotGoodsList(Long partnerId); + + List<HotGoodsVo> newHotGoodsList(); + + void addGoods(ShopInspectionGoods goods) throws Exception; + + IPage<GoodsVo> goodsList(Page<GoodsVo> page, Long partnerId, String isListing, String goodsTitle); + + List<JSONObject> canUseGoods(Long partnerId); + + ShopInspectionGoods goodsDetail(Long goodsId); + + void editGoods(ShopInspectionGoods goods) throws Exception; + + void editSkuPrice(ShopInspectionGoods goods) throws Exception; + + void changeListing(Long goodsId) throws Exception; + + void delGoods(Long goodsId) throws Exception; + + void editPartnerInfo(ShopMallPartners partners); + + PartnerVo getPartnerInfo(Long partnerId); + + PartnerBalance accountInfo(Long partnerId); + + IPage<PartnerBalanceDetail> accountDetail(Page<PartnerBalanceDetail> page, Long partnerId, Integer pageNum, Integer pageSize); + + IPage<OrderAppDetail> orderList(Page<OrderAppDetail> page, Long partnerId, String phoneNum, String title); + + OrderAppDetail orderDetail(Long partnerId, Long orderId); + + Long orderDetailByCode(Long partnerId, String code) throws Exception; + + void takeOut(Long partnerId, Long orderId, Long workId, String carNum) throws Exception; + + void addWorker(Long partnerId, String realName, String phoneNum, Long postId) throws Exception; + + List<PartnerWorker> getWorkList(Long partnerId, Long postId, String workName, String phoneNum); + + IPage<PartnerWorker> pageWorkList(Long partnerId, Long postId, String workName, String phoneNum, Page<LabelRespVO> page); + + void delWorker(Long partnerId, Long workId); + + IPage<InspectionInfo> inspectionList(Page<InspectionInfo> page, Long partnerId, String status, String carNum); + + InspectionInfoVo inspectionDetail(Long inspectionInfoId); + + List<InspectionInfo> workerInspectionList(Long partnerId, String status, String searchValue); + + void addStepInfo(InspectionStepInfo stepInfo); + + void stopInspection(InspectionInfo info) throws Exception; + + void makeCertOk(Long inspectionId); + + IPage<InspectionAppointment> getAppointmentList(Page<InspectionAppointment> page, Long partnerId, String phoneNum); + + IPage<OrderInfo> validationList(Page<OrderInfo> page, Long partnerId, String searchValue); + + void sendCoupon(ShopCouponTemplate template) throws Exception; + + IPage<ShopCouponTemplate> listCoupon(Page<ShopCouponTemplate> page, Long partnerId, String searchValue); + + void delCoupon(Long partnerId, Long id); + + void designatePickCarWorker(Long pickCarId, Long workerId); + + IPage<InspectionPickCar> getPickCarList(Page page, Long partnerId, String phoneNum, String pickStatus); + + InspectionPickCar getPickCarDetail(Long dataId); + + IPage<InspectionPickCar> getPickCarListOfWorker(Page<InspectionPickCar> page, Long workerId, String phoneNum); + + JSONObject vehicleLicenseOCR(String imagePath) throws Exception; + + void offlineCharging(InspectionInfoVo infoVo); + + String workOrderView(Long inspectionId); + + List<PostDO> inspectionPostInfo(); + + Map<String, Double> staticsTable1(Long partnerId, String startTime, String endTime); + + Map<String, Double> newStaticsTable1(String startTime, String endTime); + + Map<String, Integer> staticsTable2(Long partnerId, String startTime, String endTime); + + Map<String, Integer> newStaticsTable2(String startTime, String endTime); + + List<Map<String, Object>> staticsTable3(Long partnerId, String startTime, String endTime); + + List<Map<String, Object>> newStaticsTable3(String startTime, String endTime); + + List<Map<String, Object>> staticsTable3Detail(Long partnerId, String startTime, String endTime, String remark); + + List<Map<String, Object>> staticsTable4(Long partnerId, String startTime, String endTime); + + List<Map<String, Object>> staticsTable5(Long partnerId, String startTime, String endTime); - //新检测金额折线图 - JSONObject newChartLineInspectionAmount(String unit); + //新检测金额折线图 + JSONObject newChartLineInspectionAmount(String unit); - /** - * 根据inspection_info的id查有的项目名称 - * - * @author 小李 - * @date 14:52 2024/12/10 - * @param ids inspection_info的id - **/ - Map<Long, String> getProjectByIds(Long[] ids); + /** + * 根据inspection_info的id查有的项目名称 + * + * @param ids inspection_info的id + * @author 小李 + * @date 14:52 2024/12/10 + **/ + Map<Long, String> getProjectByIds(Long[] ids); - /** - * 根据时间查订单 - * - * @author 小李 - * @date 14:39 2024/12/12 - * @param startTime 开始时间 非必传 - * @param endTime 结束时间 非必传 - **/ - IPage<OrderTable> getOrderByDate(String startTime, String endTime, String chooseStatus, Page<OrderTable> page); + /** + * 根据时间查订单 + * + * @param startTime 开始时间 非必传 + * @param endTime 结束时间 非必传 + * @author 小李 + * @date 14:39 2024/12/12 + **/ + IPage<OrderTable> getOrderByDate(String startTime, String endTime, String chooseStatus, Page<OrderTable> page); - /** - * 分类计数 - * - * @author 小李 - * @date 17:14 2024/12/16 - * @param startTime 开始时间 - * @param endTime 结束时间 - * @param chooseStatus 状态 - **/ - Map<String, Long> getTypeCount(String startTime, String endTime, String chooseStatus); + /** + * 分类计数 + * + * @param startTime 开始时间 + * @param endTime 结束时间 + * @param chooseStatus 状态 + * @author 小李 + * @date 17:14 2024/12/16 + **/ + Map<String, Long> getTypeCount(String startTime, String endTime, String chooseStatus); + + /** + * 查询检测类型统计 + * + * @param startTime 开始时间 + * @param endTime 结束时间 + * @return 结果 + */ + List<Map<String, Object>> queryInspectionSkuList(String startTime, String endTime); + + /** + * 查询员工统计 + * + * @param dlInspectionProject 项目信息 + * @return 结果 + */ + List<Map<String, Object>> getStaffCount(DlInspectionProject dlInspectionProject); } diff --git a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/DlInspectionProjectService.java b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/DlInspectionProjectService.java index 68f0b792..0d6db9c6 100644 --- a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/DlInspectionProjectService.java +++ b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/DlInspectionProjectService.java @@ -4,10 +4,13 @@ import cn.iocoder.yudao.module.inspection.entity.DlInspectionProject; import cn.iocoder.yudao.module.inspection.vo.DlInspectionProjectPageReqVO; import cn.iocoder.yudao.module.inspection.vo.DlInspectionProjectRespVO; import cn.iocoder.yudao.module.inspection.vo.DlInspectionProjectSaveReqVO; +import cn.iocoder.yudao.module.inspection.vo.InspectionOrderExportVo; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.IService; +import org.apache.ibatis.annotations.Param; import javax.validation.Valid; +import java.util.List; /** * 检测项目 Service 接口 @@ -33,6 +36,7 @@ public interface DlInspectionProjectService extends IService<DlInspectionProject /** * 更新排序 + * * @param updateReqVO */ void updateSort(DlInspectionProjectSaveReqVO updateReqVO); @@ -60,4 +64,11 @@ public interface DlInspectionProjectService extends IService<DlInspectionProject */ IPage<DlInspectionProjectRespVO> getDlInspectionProjectPage(IPage page, DlInspectionProjectPageReqVO pageReqVO); + /** + * 查询项目对应的检测员名称 + * + * @param orderIds 订单id集合 + * @return + */ + List<InspectionOrderExportVo> queryProjectWorkerName(List<Long> orderIds); } \ No newline at end of file diff --git a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/IInspectionEquInfoService.java b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/IInspectionEquInfoService.java index e8d157b7..0fec0564 100644 --- a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/IInspectionEquInfoService.java +++ b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/IInspectionEquInfoService.java @@ -1,7 +1,9 @@ package cn.iocoder.yudao.module.inspection.service; import java.util.List; +import java.util.Map; +import cn.iocoder.yudao.module.inspection.vo.InspectionEqInfoImportVo; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.IService; @@ -13,8 +15,7 @@ import cn.iocoder.yudao.module.inspection.entity.InspectionEquInfo; * @author zcy * @date 2023-10-13 */ -public interface IInspectionEquInfoService extends IService<InspectionEquInfo> -{ +public interface IInspectionEquInfoService extends IService<InspectionEquInfo> { /** * 查询equInfo * @@ -29,7 +30,7 @@ public interface IInspectionEquInfoService extends IService<InspectionEquInfo> * @param inspectionEquInfo equInfo * @return equInfo集合 */ - public IPage<InspectionEquInfo> selectInspectionEquInfoList(Page page,InspectionEquInfo inspectionEquInfo); + public IPage<InspectionEquInfo> selectInspectionEquInfoList(Page page, InspectionEquInfo inspectionEquInfo); /** * 新增equInfo @@ -62,4 +63,12 @@ public interface IInspectionEquInfoService extends IService<InspectionEquInfo> * @return 结果 */ public int deleteInspectionEquInfoById(Long id); + + /** + * 导入设备信息 + * + * @param list 设备信息集合 + * @return 结果 + */ + Map<String, Object> importStaff(List<InspectionEqInfoImportVo> list); } diff --git a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/IInspectionWorkNodeService.java b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/IInspectionWorkNodeService.java index 526ee66e..b6e416d6 100644 --- a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/IInspectionWorkNodeService.java +++ b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/IInspectionWorkNodeService.java @@ -1,5 +1,6 @@ package cn.iocoder.yudao.module.inspection.service; +import cn.iocoder.yudao.module.inspection.entity.DlInspectionProject; import cn.iocoder.yudao.module.inspection.entity.InspectionWorkNode; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.IService; @@ -18,6 +19,7 @@ import java.util.Map; public interface IInspectionWorkNodeService extends IService<InspectionWorkNode> { /** * 员工接单 + * * @param inspectionId * @param workNodeId */ @@ -25,6 +27,7 @@ public interface IInspectionWorkNodeService extends IService<InspectionWorkNode> /** * 员工取消接单 + * * @param inspectionId * @param workNodeId */ @@ -32,12 +35,14 @@ public interface IInspectionWorkNodeService extends IService<InspectionWorkNode> /** * 更新流程图片 步骤信息 + * * @param inspectionWorkNode */ void updateImageAndStep(InspectionWorkNode inspectionWorkNode); /** * 根据检测id获取流程信息 + * * @param inspectionId * @return */ @@ -47,6 +52,7 @@ public interface IInspectionWorkNodeService extends IService<InspectionWorkNode> /** * 分页查询提成 + * * @param page * @param inspectionWorkNode * @return @@ -57,7 +63,16 @@ public interface IInspectionWorkNodeService extends IService<InspectionWorkNode> /** * 重新检测 + * * @param workNodes */ void recheck(InspectionWorkNode workNodes); + + /** + * 获取员工统计排序 + * + * @param dlInspectionProject + * @return + */ + List<Map<String, Object>> getStaffCount(DlInspectionProject dlInspectionProject); } diff --git a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/impl/AppInspectionPartnerServiceImpl.java b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/impl/AppInspectionPartnerServiceImpl.java index 301acfc2..d537c990 100644 --- a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/impl/AppInspectionPartnerServiceImpl.java +++ b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/impl/AppInspectionPartnerServiceImpl.java @@ -74,7 +74,7 @@ import java.util.*; import java.util.stream.Collectors; @Service("appInspectionPartnerService") -public class AppInspectionPartnerServiceImpl extends ServiceImpl<AppInspectionPartnerMapper,ShopMallPartners> implements AppInspectionPartnerService { +public class AppInspectionPartnerServiceImpl extends ServiceImpl<AppInspectionPartnerMapper, ShopMallPartners> implements AppInspectionPartnerService { @Autowired private AppInspectionOrderService orderService; @Autowired @@ -102,7 +102,7 @@ public class AppInspectionPartnerServiceImpl extends ServiceImpl<AppInspectionPa @Autowired private IInspectionPickCarService pickCarService; @Autowired - private IInspectionCategoryTemplateService categoryTemplateService; + private IInspectionCategoryTemplateService categoryTemplateService; @Autowired private IPartnerCustomerInfoService customerInfoService; @Autowired @@ -132,10 +132,10 @@ public class AppInspectionPartnerServiceImpl extends ServiceImpl<AppInspectionPa @Override public IPage<PartnerListVo> partnerList(Page<PartnerListVo> page, PartnerListQuery partnerListQuery) { - if (null!=partnerListQuery.getDistance()){ - partnerListQuery.setDistance(partnerListQuery.getDistance()*1000); + if (null != partnerListQuery.getDistance()) { + partnerListQuery.setDistance(partnerListQuery.getDistance() * 1000); } - IPage<PartnerListVo> partnerListVos = baseMapper.partnerList(page,partnerListQuery); + IPage<PartnerListVo> partnerListVos = baseMapper.partnerList(page, partnerListQuery); return partnerListVos; } @@ -149,8 +149,8 @@ public class AppInspectionPartnerServiceImpl extends ServiceImpl<AppInspectionPa // } List<ShopInspectionCategory> shopInspectionCategories = baseMapper.partnerCategoryList(partnerId); for (ShopInspectionCategory shopInspectionCategory : shopInspectionCategories) { - LambdaQueryWrapper<InspectionCategoryTemplate> templateLambdaQueryWrapper =new LambdaQueryWrapper<>(); - templateLambdaQueryWrapper.eq(InspectionCategoryTemplate::getCategoryId,shopInspectionCategory.getId()).orderByAsc(InspectionCategoryTemplate::getSkuPrice); + LambdaQueryWrapper<InspectionCategoryTemplate> templateLambdaQueryWrapper = new LambdaQueryWrapper<>(); + templateLambdaQueryWrapper.eq(InspectionCategoryTemplate::getCategoryId, shopInspectionCategory.getId()).orderByAsc(InspectionCategoryTemplate::getSkuPrice); List<InspectionCategoryTemplate> list = categoryTemplateService.list(templateLambdaQueryWrapper); shopInspectionCategory.setTemplates(list); } @@ -160,10 +160,10 @@ public class AppInspectionPartnerServiceImpl extends ServiceImpl<AppInspectionPa @Override public PartnerListVo shopDetail(PartnerListQuery partnerListQuery) { PartnerListVo partnerListVo = baseMapper.shopDetail(partnerListQuery); - if (!StringUtils.isEmpty(partnerListVo.getShopImages())){ + if (!StringUtils.isEmpty(partnerListVo.getShopImages())) { String[] shopImages = partnerListVo.getShopImages().split(","); partnerListVo.setImageList(Arrays.asList(shopImages)); - }else { + } else { partnerListVo.setImageList(new ArrayList<>()); } return partnerListVo; @@ -182,21 +182,21 @@ public class AppInspectionPartnerServiceImpl extends ServiceImpl<AppInspectionPa List<RoleDO> roleList = roleService.getRoleList(userRoleIdListByUserId); List<String> roles = roleList.stream().map(RoleDO::getCode).collect(Collectors.toList()); - ShopMallPartners partner = new ShopMallPartners(); - if (roles.contains("jcshop")){ - LambdaQueryWrapper<ShopMallPartners> queryWrapper =new LambdaQueryWrapper<>(); - queryWrapper.orderByAsc(ShopMallPartners::getPartnerId).eq(ShopMallPartners::getType,"jc").eq(ShopMallPartners::getIsBanned,"0").last("limit 1"); + ShopMallPartners partner = new ShopMallPartners(); + if (roles.contains("jcshop")) { + LambdaQueryWrapper<ShopMallPartners> queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.orderByAsc(ShopMallPartners::getPartnerId).eq(ShopMallPartners::getType, "jc").eq(ShopMallPartners::getIsBanned, "0").last("limit 1"); partner = this.getOne(queryWrapper); - if (ObjectUtil.isEmpty(partner)){ + if (ObjectUtil.isEmpty(partner)) { throw new Exception("信息有误"); } - }else if (roles.contains("jcworker")){ - LambdaQueryWrapper<PartnerWorker> queryWrapperWork =new LambdaQueryWrapper<>(); - queryWrapperWork.eq(PartnerWorker::getUserId,user.getId()); + } else if (roles.contains("jcworker")) { + LambdaQueryWrapper<PartnerWorker> queryWrapperWork = new LambdaQueryWrapper<>(); + queryWrapperWork.eq(PartnerWorker::getUserId, user.getId()); queryWrapperWork.orderByAsc(PartnerWorker::getPartnerId); queryWrapperWork.last("limit 1"); PartnerWorker worker = partnerWorkerService.getOne(queryWrapperWork); - if (ObjectUtil.isEmpty(worker)){ + if (ObjectUtil.isEmpty(worker)) { throw new Exception("信息有误"); } partner.setPartnerId(worker.getPartnerId()); @@ -206,39 +206,37 @@ public class AppInspectionPartnerServiceImpl extends ServiceImpl<AppInspectionPa /** * 对shopInfo方法的重写,只根据user_id进行查询 - * */ @Override public ShopMallPartners shopInfoByUserId() throws Exception { LambdaQueryWrapper<ShopMallPartners> queryWrapper = new LambdaQueryWrapper<>(); queryWrapper.orderByAsc(ShopMallPartners::getPartnerId).last("limit 1"); ShopMallPartners partner = this.getOne(queryWrapper); - if (ObjectUtil.isEmpty(partner)){ + if (ObjectUtil.isEmpty(partner)) { throw new Exception("未查询到信息"); } return partner; } - @Override public JSONObject getAppointAndPickNum() throws Exception { ShopMallPartners shopMallPartners = this.shopInfo(); - String formDate = DateUtil.format(new Date(),"yyyy-MM-dd"); - Long appointNum = baseMapper.getAppointNum(shopMallPartners.getPartnerId(),formDate); - Long pickNum = baseMapper.getPickNum(shopMallPartners.getPartnerId(),formDate); - JSONObject res =new JSONObject(); - res.put("appointNum",appointNum); - res.put("pickNum",pickNum); + String formDate = DateUtil.format(new Date(), "yyyy-MM-dd"); + Long appointNum = baseMapper.getAppointNum(shopMallPartners.getPartnerId(), formDate); + Long pickNum = baseMapper.getPickNum(shopMallPartners.getPartnerId(), formDate); + JSONObject res = new JSONObject(); + res.put("appointNum", appointNum); + res.put("pickNum", pickNum); return res; } @Override public void startOrEnd(Long partnerId) { ShopMallPartners partners = baseMapper.selectById(partnerId); - if (StringUtils.isEmpty(partners.getIsWorking())||partners.getIsWorking().equals("0")){ + if (StringUtils.isEmpty(partners.getIsWorking()) || partners.getIsWorking().equals("0")) { partners.setIsWorking("1"); - }else { + } else { partners.setIsWorking("0"); } baseMapper.updateById(partners); @@ -247,7 +245,7 @@ public class AppInspectionPartnerServiceImpl extends ServiceImpl<AppInspectionPa @Override public StatisticsInfo statisticsInfo(Long partnerId) { LoginUser user = SecurityFrameworkUtils.getLoginUser(); - StatisticsInfo statisticsInfo2 = baseMapper.orderNum(partnerId, DateUtil.format(new Date(),"yyyy-MM-dd")); + StatisticsInfo statisticsInfo2 = baseMapper.orderNum(partnerId, DateUtil.format(new Date(), "yyyy-MM-dd")); //合规且合格双燃料 Integer i = baseMapper.srlNum(partnerId, DateUtil.format(new Date(), "yyyy-MM-dd")); Integer hgNum = baseMapper.hgNum(partnerId, DateUtil.format(new Date(), "yyyy-MM-dd")); @@ -257,27 +255,27 @@ public class AppInspectionPartnerServiceImpl extends ServiceImpl<AppInspectionPa } @Override - public JSONObject chartInfoAmount(Long partnerId,String unit) { + public JSONObject chartInfoAmount(Long partnerId, String unit) { // LoginUser user = SecurityFrameworkUtils.getLoginUser(); // ShopMallPartners partners = baseMapper.selectById(partnerId); // if (!partners.getUserId().equals(user.getId())){ // return null; // } - JSONObject res =new JSONObject(); - List<String> categories =new ArrayList<>(); - List<JSONObject> series =new ArrayList<>(); - JSONObject seriesObject=new JSONObject(); - seriesObject.put("name","金额"); - List<Double> seriesObjectData =new ArrayList<>(); + JSONObject res = new JSONObject(); + List<String> categories = new ArrayList<>(); + List<JSONObject> series = new ArrayList<>(); + JSONObject seriesObject = new JSONObject(); + seriesObject.put("name", "金额"); + List<Double> seriesObjectData = new ArrayList<>(); //按照单位日期查询数据 //横坐标获取当前商品上架的商品 String startTime = null; String endTime = null; - if (unit.equals("day")){ + if (unit.equals("day")) { String format = DateUtil.format(new Date(), "yyyy-MM-dd"); - startTime = format+" 00:00:00"; - endTime = format+" 23:59:59"; - } else if (unit.equals("week")){ + startTime = format + " 00:00:00"; + endTime = format + " 23:59:59"; + } else if (unit.equals("week")) { // 获取当前日期 LocalDate currentDate = LocalDate.now(); @@ -289,8 +287,8 @@ public class AppInspectionPartnerServiceImpl extends ServiceImpl<AppInspectionPa // 将日期格式化为字符串 startTime = startOfWeek.atStartOfDay().format(formatter); - endTime = DateUtil.format(new Date(),"yyyy-MM-dd HH:mm:ss"); - } else if (unit.equals("month")){ + endTime = DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"); + } else if (unit.equals("month")) { // 获取当前日期 LocalDate currentDate = LocalDate.now(); @@ -299,8 +297,8 @@ public class AppInspectionPartnerServiceImpl extends ServiceImpl<AppInspectionPa // 创建日期时间格式化器 DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); startTime = firstDayOfMonth.atStartOfDay().format(formatter); - endTime = DateUtil.format(new Date(),"yyyy-MM-dd HH:mm:ss"); - } else if (unit.equals("year")){ + endTime = DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"); + } else if (unit.equals("year")) { // 获取当前日期 LocalDate currentDate = LocalDate.now(); @@ -309,8 +307,8 @@ public class AppInspectionPartnerServiceImpl extends ServiceImpl<AppInspectionPa // 创建日期时间格式化器 DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); startTime = firstDayOfYear.atStartOfDay().format(formatter); - endTime = DateUtil.format(new Date(),"yyyy-MM-dd HH:mm:ss"); - }else { + endTime = DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"); + } else { // 获取当前日期 LocalDate currentDate = LocalDate.now(); @@ -322,50 +320,51 @@ public class AppInspectionPartnerServiceImpl extends ServiceImpl<AppInspectionPa // 将日期格式化为字符串 startTime = startOfWeek.atStartOfDay().format(formatter); - endTime = DateUtil.format(new Date(),"yyyy-MM-dd HH:mm:ss"); + endTime = DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"); } //获取商家现有商品 - LambdaQueryWrapper<ShopInspectionGoods> queryWrapper1 =new LambdaQueryWrapper<>(); - queryWrapper1.eq(ShopInspectionGoods::getPartnerId,partnerId); + LambdaQueryWrapper<ShopInspectionGoods> queryWrapper1 = new LambdaQueryWrapper<>(); + queryWrapper1.eq(ShopInspectionGoods::getPartnerId, partnerId); List<ShopInspectionGoods> list1 = goodsService.list(queryWrapper1); - List<OrderInfo> list = baseMapper.chartInfoAmount(startTime,endTime,partnerId); + List<OrderInfo> list = baseMapper.chartInfoAmount(startTime, endTime, partnerId); //统计各个车型的价格 从高到低 for (OrderInfo orderInfo : list) { - categories.add(orderInfo.getGoodsTitle().indexOf("(")>0?orderInfo.getGoodsTitle().substring(0,orderInfo.getGoodsTitle().indexOf("(")):orderInfo.getGoodsTitle()); - list1.removeIf(it->{ - return it.getTitle().equals(orderInfo.getGoodsTitle()); + categories.add(orderInfo.getGoodsTitle().indexOf("(") > 0 ? orderInfo.getGoodsTitle().substring(0, orderInfo.getGoodsTitle().indexOf("(")) : orderInfo.getGoodsTitle()); + list1.removeIf(it -> { + return it.getTitle().equals(orderInfo.getGoodsTitle()); }); - seriesObjectData.add(Double.valueOf(orderInfo.getRealPayMoney())/100); + seriesObjectData.add(Double.valueOf(orderInfo.getRealPayMoney()) / 100); } - categories.addAll(list1.stream().map(it->{ - return it.getTitle().indexOf("(")>0?it.getTitle().substring(0,it.getTitle().indexOf("(")):it.getTitle(); + categories.addAll(list1.stream().map(it -> { + return it.getTitle().indexOf("(") > 0 ? it.getTitle().substring(0, it.getTitle().indexOf("(")) : it.getTitle(); }).collect(Collectors.toList())); - seriesObjectData.addAll(list1.stream().map(it->{ + seriesObjectData.addAll(list1.stream().map(it -> { return 0d; }).collect(Collectors.toList())); - seriesObject.put("data",seriesObjectData); + seriesObject.put("data", seriesObjectData); series.add(seriesObject); - res.put("categories",categories); - res.put("series",series); + res.put("categories", categories); + res.put("series", series); return res; } + @Override public JSONObject newChartInfoAmount(String unit) { - JSONObject res =new JSONObject(); - List<String> categories =new ArrayList<>(); - List<JSONObject> series =new ArrayList<>(); - JSONObject seriesObject=new JSONObject(); - seriesObject.put("name","金额"); - List<Double> seriesObjectData =new ArrayList<>(); + JSONObject res = new JSONObject(); + List<String> categories = new ArrayList<>(); + List<JSONObject> series = new ArrayList<>(); + JSONObject seriesObject = new JSONObject(); + seriesObject.put("name", "金额"); + List<Double> seriesObjectData = new ArrayList<>(); //按照单位日期查询数据 //横坐标获取当前商品上架的商品 String startTime = null; String endTime = null; - if (unit.equals("day")){ + if (unit.equals("day")) { String format = DateUtil.format(new Date(), "yyyy-MM-dd"); - startTime = format+" 00:00:00"; - endTime = format+" 23:59:59"; - } else if (unit.equals("week")){ + startTime = format + " 00:00:00"; + endTime = format + " 23:59:59"; + } else if (unit.equals("week")) { // 获取当前日期 LocalDate currentDate = LocalDate.now(); @@ -377,8 +376,8 @@ public class AppInspectionPartnerServiceImpl extends ServiceImpl<AppInspectionPa // 将日期格式化为字符串 startTime = startOfWeek.atStartOfDay().format(formatter); - endTime = DateUtil.format(new Date(),"yyyy-MM-dd HH:mm:ss"); - } else if (unit.equals("month")){ + endTime = DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"); + } else if (unit.equals("month")) { // 获取当前日期 LocalDate currentDate = LocalDate.now(); @@ -387,8 +386,8 @@ public class AppInspectionPartnerServiceImpl extends ServiceImpl<AppInspectionPa // 创建日期时间格式化器 DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); startTime = firstDayOfMonth.atStartOfDay().format(formatter); - endTime = DateUtil.format(new Date(),"yyyy-MM-dd HH:mm:ss"); - } else if (unit.equals("year")){ + endTime = DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"); + } else if (unit.equals("year")) { // 获取当前日期 LocalDate currentDate = LocalDate.now(); @@ -397,8 +396,8 @@ public class AppInspectionPartnerServiceImpl extends ServiceImpl<AppInspectionPa // 创建日期时间格式化器 DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); startTime = firstDayOfYear.atStartOfDay().format(formatter); - endTime = DateUtil.format(new Date(),"yyyy-MM-dd HH:mm:ss"); - }else { + endTime = DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"); + } else { // 获取当前日期 LocalDate currentDate = LocalDate.now(); @@ -410,31 +409,31 @@ public class AppInspectionPartnerServiceImpl extends ServiceImpl<AppInspectionPa // 将日期格式化为字符串 startTime = startOfWeek.atStartOfDay().format(formatter); - endTime = DateUtil.format(new Date(),"yyyy-MM-dd HH:mm:ss"); + endTime = DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"); } //获取商家现有商品 - LambdaQueryWrapper<ShopInspectionGoods> queryWrapper1 =new LambdaQueryWrapper<>(); + LambdaQueryWrapper<ShopInspectionGoods> queryWrapper1 = new LambdaQueryWrapper<>(); // queryWrapper1.eq(ShopInspectionGoods::getPartnerId,partnerId); List<ShopInspectionGoods> list1 = goodsService.list(queryWrapper1); - List<OrderInfo> list = baseMapper.newChartInfoAmount(startTime,endTime); + List<OrderInfo> list = baseMapper.newChartInfoAmount(startTime, endTime); //统计各个车型的价格 从高到低 for (OrderInfo orderInfo : list) { - categories.add(orderInfo.getGoodsTitle().indexOf("(")>0?orderInfo.getGoodsTitle().substring(0,orderInfo.getGoodsTitle().indexOf("(")):orderInfo.getGoodsTitle()); - list1.removeIf(it->{ - return it.getTitle().equals(orderInfo.getGoodsTitle()); + categories.add(orderInfo.getGoodsTitle().indexOf("(") > 0 ? orderInfo.getGoodsTitle().substring(0, orderInfo.getGoodsTitle().indexOf("(")) : orderInfo.getGoodsTitle()); + list1.removeIf(it -> { + return it.getTitle().equals(orderInfo.getGoodsTitle()); }); - seriesObjectData.add(Double.valueOf(orderInfo.getRealPayMoney())/100); + seriesObjectData.add(Double.valueOf(orderInfo.getRealPayMoney()) / 100); } - categories.addAll(list1.stream().map(it->{ - return it.getTitle().indexOf("(")>0?it.getTitle().substring(0,it.getTitle().indexOf("(")):it.getTitle(); + categories.addAll(list1.stream().map(it -> { + return it.getTitle().indexOf("(") > 0 ? it.getTitle().substring(0, it.getTitle().indexOf("(")) : it.getTitle(); }).collect(Collectors.toList())); - seriesObjectData.addAll(list1.stream().map(it->{ + seriesObjectData.addAll(list1.stream().map(it -> { return 0d; }).collect(Collectors.toList())); - seriesObject.put("data",seriesObjectData); + seriesObject.put("data", seriesObjectData); series.add(seriesObject); - res.put("categories",categories); - res.put("series",series); + res.put("categories", categories); + res.put("series", series); return res; } @@ -446,14 +445,14 @@ public class AppInspectionPartnerServiceImpl extends ServiceImpl<AppInspectionPa // return null; // } JSONObject res = new JSONObject(); - List<String> categories =new ArrayList<>(); - List<JSONObject> series =new ArrayList<>(); - JSONObject seriesData1 =new JSONObject(); - seriesData1.put("name","总数量"); - List<Long> seriesData1List =new ArrayList<>(); - JSONObject seriesData2 =new JSONObject(); - List<Long> seriesData2List =new ArrayList<>(); - seriesData2.put("name","合格数"); + List<String> categories = new ArrayList<>(); + List<JSONObject> series = new ArrayList<>(); + JSONObject seriesData1 = new JSONObject(); + seriesData1.put("name", "总数量"); + List<Long> seriesData1List = new ArrayList<>(); + JSONObject seriesData2 = new JSONObject(); + List<Long> seriesData2List = new ArrayList<>(); + seriesData2.put("name", "合格数"); // JSONObject seriesData3 =new JSONObject(); // List<Long> seriesData3List =new ArrayList<>(); // seriesData3.put("name","环检次数"); @@ -467,39 +466,40 @@ public class AppInspectionPartnerServiceImpl extends ServiceImpl<AppInspectionPa } for (String date : dateList) { categories.add(date); - LambdaQueryWrapper<InspectionInfo> queryWrapper1 =new LambdaQueryWrapper<>(); - queryWrapper1.eq(InspectionInfo::getPartnerId,partnerId).like(InspectionInfo::getStartTime,date); + LambdaQueryWrapper<InspectionInfo> queryWrapper1 = new LambdaQueryWrapper<>(); + queryWrapper1.eq(InspectionInfo::getPartnerId, partnerId).like(InspectionInfo::getStartTime, date); Long sum = inspectionInfoService.count(queryWrapper1); - LambdaQueryWrapper<InspectionInfo> queryWrapper2 =new LambdaQueryWrapper<>(); - queryWrapper2.eq(InspectionInfo::getPartnerId,partnerId).like(InspectionInfo::getStartTime,date).eq(InspectionInfo::getIsPass,"1"); + LambdaQueryWrapper<InspectionInfo> queryWrapper2 = new LambdaQueryWrapper<>(); + queryWrapper2.eq(InspectionInfo::getPartnerId, partnerId).like(InspectionInfo::getStartTime, date).eq(InspectionInfo::getIsPass, "1"); Long passNum = inspectionInfoService.count(queryWrapper2); - // Long noPassNum = baseMapper.dhjNum(partnerId,date); + // Long noPassNum = baseMapper.dhjNum(partnerId,date); seriesData1List.add(sum); seriesData2List.add(passNum); // seriesData3List.add(noPassNum); } - seriesData1.put("data",seriesData1List); - seriesData2.put("data",seriesData2List); - // seriesData3.put("data",seriesData3List); + seriesData1.put("data", seriesData1List); + seriesData2.put("data", seriesData2List); + // seriesData3.put("data",seriesData3List); series.add(seriesData1); series.add(seriesData2); //series.add(seriesData3); - res.put("categories",categories); - res.put("series",series); + res.put("categories", categories); + res.put("series", series); return res; } + @Override public JSONObject newChartLineInspectionNum(String unit) { JSONObject res = new JSONObject(); - List<String> categories =new ArrayList<>(); - List<JSONObject> series =new ArrayList<>(); - JSONObject seriesData1 =new JSONObject(); - seriesData1.put("name","总数量"); - List<Long> seriesData1List =new ArrayList<>(); - JSONObject seriesData2 =new JSONObject(); - List<Long> seriesData2List =new ArrayList<>(); - seriesData2.put("name","合格数"); + List<String> categories = new ArrayList<>(); + List<JSONObject> series = new ArrayList<>(); + JSONObject seriesData1 = new JSONObject(); + seriesData1.put("name", "总数量"); + List<Long> seriesData1List = new ArrayList<>(); + JSONObject seriesData2 = new JSONObject(); + List<Long> seriesData2List = new ArrayList<>(); + seriesData2.put("name", "合格数"); // JSONObject seriesData3 =new JSONObject(); // List<Long> seriesData3List =new ArrayList<>(); // seriesData3.put("name","环检次数"); @@ -513,26 +513,26 @@ public class AppInspectionPartnerServiceImpl extends ServiceImpl<AppInspectionPa } for (String date : dateList) { categories.add(date); - LambdaQueryWrapper<InspectionInfo> queryWrapper1 =new LambdaQueryWrapper<>(); - queryWrapper1.like(InspectionInfo::getStartTime,date); + LambdaQueryWrapper<InspectionInfo> queryWrapper1 = new LambdaQueryWrapper<>(); + queryWrapper1.like(InspectionInfo::getStartTime, date); Long sum = inspectionInfoService.count(queryWrapper1); - LambdaQueryWrapper<InspectionInfo> queryWrapper2 =new LambdaQueryWrapper<>(); - queryWrapper2.like(InspectionInfo::getStartTime,date).eq(InspectionInfo::getIsPass,"1"); + LambdaQueryWrapper<InspectionInfo> queryWrapper2 = new LambdaQueryWrapper<>(); + queryWrapper2.like(InspectionInfo::getStartTime, date).eq(InspectionInfo::getIsPass, "1"); Long passNum = inspectionInfoService.count(queryWrapper2); - // Long noPassNum = baseMapper.dhjNum(partnerId,date); + // Long noPassNum = baseMapper.dhjNum(partnerId,date); seriesData1List.add(sum); seriesData2List.add(passNum); // seriesData3List.add(noPassNum); } - seriesData1.put("data",seriesData1List); - seriesData2.put("data",seriesData2List); - // seriesData3.put("data",seriesData3List); + seriesData1.put("data", seriesData1List); + seriesData2.put("data", seriesData2List); + // seriesData3.put("data",seriesData3List); series.add(seriesData1); series.add(seriesData2); //series.add(seriesData3); - res.put("categories",categories); - res.put("series",series); + res.put("categories", categories); + res.put("series", series); return res; } @@ -544,11 +544,11 @@ public class AppInspectionPartnerServiceImpl extends ServiceImpl<AppInspectionPa // return null; // } JSONObject res = new JSONObject(); - List<String> categories =new ArrayList<>(); - List<JSONObject> series =new ArrayList<>(); - JSONObject seriesData1 =new JSONObject(); - seriesData1.put("name","成交金额"); - List<Long> seriesData1List =new ArrayList<>(); + List<String> categories = new ArrayList<>(); + List<JSONObject> series = new ArrayList<>(); + JSONObject seriesData1 = new JSONObject(); + seriesData1.put("name", "成交金额"); + List<Long> seriesData1List = new ArrayList<>(); List<String> dateList = new ArrayList<>(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); for (int i = 0; i < 7; i++) { @@ -559,14 +559,14 @@ public class AppInspectionPartnerServiceImpl extends ServiceImpl<AppInspectionPa } for (String date : dateList) { categories.add(date); - OrderInfo one = baseMapper.chartLineInspectionAmount(partnerId,date); + OrderInfo one = baseMapper.chartLineInspectionAmount(partnerId, date); Integer amount = Optional.ofNullable(one.getRealPayMoney()).orElse(0); - seriesData1List.add(amount/100L); + seriesData1List.add(amount / 100L); } - seriesData1.put("data",seriesData1List); + seriesData1.put("data", seriesData1List); series.add(seriesData1); - res.put("categories",categories); - res.put("series",series); + res.put("categories", categories); + res.put("series", series); return res; } @@ -574,11 +574,11 @@ public class AppInspectionPartnerServiceImpl extends ServiceImpl<AppInspectionPa public JSONObject newChartLineInspectionAmount(String unit) { // LoginUser user = SecurityFrameworkUtils.getLoginUser(); JSONObject res = new JSONObject(); - List<String> categories =new ArrayList<>(); - List<JSONObject> series =new ArrayList<>(); - JSONObject seriesData1 =new JSONObject(); - seriesData1.put("name","成交金额"); - List<Long> seriesData1List =new ArrayList<>(); + List<String> categories = new ArrayList<>(); + List<JSONObject> series = new ArrayList<>(); + JSONObject seriesData1 = new JSONObject(); + seriesData1.put("name", "成交金额"); + List<Long> seriesData1List = new ArrayList<>(); List<String> dateList = new ArrayList<>(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); for (int i = 0; i < 7; i++) { @@ -591,38 +591,38 @@ public class AppInspectionPartnerServiceImpl extends ServiceImpl<AppInspectionPa categories.add(date); OrderInfo one = baseMapper.newChartLineInspectionAmount(date); Integer amount = Optional.ofNullable(one.getRealPayMoney()).orElse(0); - seriesData1List.add(amount/100L); + seriesData1List.add(amount / 100L); } - seriesData1.put("data",seriesData1List); + seriesData1.put("data", seriesData1List); series.add(seriesData1); - res.put("categories",categories); - res.put("series",series); + res.put("categories", categories); + res.put("series", series); return res; } @Override - public JSONObject chartInfoNum(Long partnerId,String unit) { + public JSONObject chartInfoNum(Long partnerId, String unit) { // LoginUser user = SecurityFrameworkUtils.getLoginUser(); // ShopMallPartners partners = baseMapper.selectById(partnerId); // if (!partners.getUserId().equals(user.getId())){ // return null; // } - JSONObject res =new JSONObject(); - List<String> categories =new ArrayList<>(); - List<JSONObject> series =new ArrayList<>(); - JSONObject seriesObject=new JSONObject(); - seriesObject.put("name","数量"); - List<Integer> seriesObjectData =new ArrayList<>(); + JSONObject res = new JSONObject(); + List<String> categories = new ArrayList<>(); + List<JSONObject> series = new ArrayList<>(); + JSONObject seriesObject = new JSONObject(); + seriesObject.put("name", "数量"); + List<Integer> seriesObjectData = new ArrayList<>(); //按照单位日期查询数据 //横坐标获取当前商品上架的商品 - String startTime ; - String endTime ; - if (unit.equals("day")){ + String startTime; + String endTime; + if (unit.equals("day")) { String format = DateUtil.format(new Date(), "yyyy-MM-dd"); - startTime = format+" 00:00:00"; - endTime = format+" 23:59:59"; - } else if (unit.equals("week")){ + startTime = format + " 00:00:00"; + endTime = format + " 23:59:59"; + } else if (unit.equals("week")) { // 获取当前日期 LocalDate currentDate = LocalDate.now(); @@ -634,8 +634,8 @@ public class AppInspectionPartnerServiceImpl extends ServiceImpl<AppInspectionPa // 将日期格式化为字符串 startTime = startOfWeek.atStartOfDay().format(formatter); - endTime = DateUtil.format(new Date(),"yyyy-MM-dd HH:mm:ss"); - } else if (unit.equals("month")){ + endTime = DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"); + } else if (unit.equals("month")) { // 获取当前日期 LocalDate currentDate = LocalDate.now(); @@ -644,8 +644,8 @@ public class AppInspectionPartnerServiceImpl extends ServiceImpl<AppInspectionPa // 创建日期时间格式化器 DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); startTime = firstDayOfMonth.atStartOfDay().format(formatter); - endTime = DateUtil.format(new Date(),"yyyy-MM-dd HH:mm:ss"); - } else if (unit.equals("year")){ + endTime = DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"); + } else if (unit.equals("year")) { // 获取当前日期 LocalDate currentDate = LocalDate.now(); @@ -654,8 +654,8 @@ public class AppInspectionPartnerServiceImpl extends ServiceImpl<AppInspectionPa // 创建日期时间格式化器 DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); startTime = firstDayOfYear.atStartOfDay().format(formatter); - endTime = DateUtil.format(new Date(),"yyyy-MM-dd HH:mm:ss"); - }else { + endTime = DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"); + } else { // 获取当前日期 LocalDate currentDate = LocalDate.now(); @@ -667,50 +667,51 @@ public class AppInspectionPartnerServiceImpl extends ServiceImpl<AppInspectionPa // 将日期格式化为字符串 startTime = startOfWeek.atStartOfDay().format(formatter); - endTime = DateUtil.format(new Date(),"yyyy-MM-dd HH:mm:ss"); + endTime = DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"); } //获取商家现有商品 - LambdaQueryWrapper<ShopInspectionGoods> queryWrapper1 =new LambdaQueryWrapper<>(); - queryWrapper1.eq(ShopInspectionGoods::getPartnerId,partnerId); + LambdaQueryWrapper<ShopInspectionGoods> queryWrapper1 = new LambdaQueryWrapper<>(); + queryWrapper1.eq(ShopInspectionGoods::getPartnerId, partnerId); List<ShopInspectionGoods> list1 = goodsService.list(queryWrapper1); - List<OrderInfo> list = baseMapper.chartInfoNum(startTime,endTime,partnerId); + List<OrderInfo> list = baseMapper.chartInfoNum(startTime, endTime, partnerId); //统计各个车型的价格 从高到低 for (OrderInfo orderInfo : list) { - categories.add(orderInfo.getGoodsTitle().indexOf("(")>0?orderInfo.getGoodsTitle().substring(0,orderInfo.getGoodsTitle().indexOf("(")):orderInfo.getGoodsTitle()); - list1.removeIf(it->{ + categories.add(orderInfo.getGoodsTitle().indexOf("(") > 0 ? orderInfo.getGoodsTitle().substring(0, orderInfo.getGoodsTitle().indexOf("(")) : orderInfo.getGoodsTitle()); + list1.removeIf(it -> { return it.getTitle().equals(orderInfo.getGoodsTitle()); }); seriesObjectData.add(orderInfo.getRealPayNum()); } - categories.addAll(list1.stream().map(it->{ - return it.getTitle().indexOf("(")>0?it.getTitle().substring(0,it.getTitle().indexOf("(")):it.getTitle(); + categories.addAll(list1.stream().map(it -> { + return it.getTitle().indexOf("(") > 0 ? it.getTitle().substring(0, it.getTitle().indexOf("(")) : it.getTitle(); }).collect(Collectors.toList())); - seriesObjectData.addAll(list1.stream().map(it->{ + seriesObjectData.addAll(list1.stream().map(it -> { return 0; }).collect(Collectors.toList())); - seriesObject.put("data",seriesObjectData); + seriesObject.put("data", seriesObjectData); series.add(seriesObject); - res.put("categories",categories); - res.put("series",series); + res.put("categories", categories); + res.put("series", series); return res; } + @Override public JSONObject newChartInfoNum(String unit) { - JSONObject res =new JSONObject(); - List<String> categories =new ArrayList<>(); - List<JSONObject> series =new ArrayList<>(); - JSONObject seriesObject=new JSONObject(); - seriesObject.put("name","数量"); - List<Integer> seriesObjectData =new ArrayList<>(); + JSONObject res = new JSONObject(); + List<String> categories = new ArrayList<>(); + List<JSONObject> series = new ArrayList<>(); + JSONObject seriesObject = new JSONObject(); + seriesObject.put("name", "数量"); + List<Integer> seriesObjectData = new ArrayList<>(); //按照单位日期查询数据 //横坐标获取当前商品上架的商品 - String startTime ; - String endTime ; - if (unit.equals("day")){ + String startTime; + String endTime; + if (unit.equals("day")) { String format = DateUtil.format(new Date(), "yyyy-MM-dd"); - startTime = format+" 00:00:00"; - endTime = format+" 23:59:59"; - } else if (unit.equals("week")){ + startTime = format + " 00:00:00"; + endTime = format + " 23:59:59"; + } else if (unit.equals("week")) { // 获取当前日期 LocalDate currentDate = LocalDate.now(); @@ -722,8 +723,8 @@ public class AppInspectionPartnerServiceImpl extends ServiceImpl<AppInspectionPa // 将日期格式化为字符串 startTime = startOfWeek.atStartOfDay().format(formatter); - endTime = DateUtil.format(new Date(),"yyyy-MM-dd HH:mm:ss"); - } else if (unit.equals("month")){ + endTime = DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"); + } else if (unit.equals("month")) { // 获取当前日期 LocalDate currentDate = LocalDate.now(); @@ -732,8 +733,8 @@ public class AppInspectionPartnerServiceImpl extends ServiceImpl<AppInspectionPa // 创建日期时间格式化器 DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); startTime = firstDayOfMonth.atStartOfDay().format(formatter); - endTime = DateUtil.format(new Date(),"yyyy-MM-dd HH:mm:ss"); - } else if (unit.equals("year")){ + endTime = DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"); + } else if (unit.equals("year")) { // 获取当前日期 LocalDate currentDate = LocalDate.now(); @@ -742,8 +743,8 @@ public class AppInspectionPartnerServiceImpl extends ServiceImpl<AppInspectionPa // 创建日期时间格式化器 DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); startTime = firstDayOfYear.atStartOfDay().format(formatter); - endTime = DateUtil.format(new Date(),"yyyy-MM-dd HH:mm:ss"); - }else { + endTime = DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"); + } else { // 获取当前日期 LocalDate currentDate = LocalDate.now(); @@ -755,30 +756,30 @@ public class AppInspectionPartnerServiceImpl extends ServiceImpl<AppInspectionPa // 将日期格式化为字符串 startTime = startOfWeek.atStartOfDay().format(formatter); - endTime = DateUtil.format(new Date(),"yyyy-MM-dd HH:mm:ss"); + endTime = DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"); } //获取商家现有商品 - LambdaQueryWrapper<ShopInspectionGoods> queryWrapper1 =new LambdaQueryWrapper<>(); + LambdaQueryWrapper<ShopInspectionGoods> queryWrapper1 = new LambdaQueryWrapper<>(); List<ShopInspectionGoods> list1 = goodsService.list(queryWrapper1); - List<OrderInfo> list = baseMapper.newChartInfoNum(startTime,endTime); + List<OrderInfo> list = baseMapper.newChartInfoNum(startTime, endTime); //统计各个车型的价格 从高到低 for (OrderInfo orderInfo : list) { - categories.add(orderInfo.getGoodsTitle().indexOf("(")>0?orderInfo.getGoodsTitle().substring(0,orderInfo.getGoodsTitle().indexOf("(")):orderInfo.getGoodsTitle()); - list1.removeIf(it->{ + categories.add(orderInfo.getGoodsTitle().indexOf("(") > 0 ? orderInfo.getGoodsTitle().substring(0, orderInfo.getGoodsTitle().indexOf("(")) : orderInfo.getGoodsTitle()); + list1.removeIf(it -> { return it.getTitle().equals(orderInfo.getGoodsTitle()); }); seriesObjectData.add(orderInfo.getRealPayNum()); } - categories.addAll(list1.stream().map(it->{ - return it.getTitle().indexOf("(")>0?it.getTitle().substring(0,it.getTitle().indexOf("(")):it.getTitle(); + categories.addAll(list1.stream().map(it -> { + return it.getTitle().indexOf("(") > 0 ? it.getTitle().substring(0, it.getTitle().indexOf("(")) : it.getTitle(); }).collect(Collectors.toList())); - seriesObjectData.addAll(list1.stream().map(it->{ + seriesObjectData.addAll(list1.stream().map(it -> { return 0; }).collect(Collectors.toList())); - seriesObject.put("data",seriesObjectData); + seriesObject.put("data", seriesObjectData); series.add(seriesObject); - res.put("categories",categories); - res.put("series",series); + res.put("categories", categories); + res.put("series", series); return res; } @@ -789,21 +790,21 @@ public class AppInspectionPartnerServiceImpl extends ServiceImpl<AppInspectionPa // if (!partners.getUserId().equals(user.getId())){ // return null; // } - JSONObject res =new JSONObject(); - List<String> categories =new ArrayList<>(); - List<JSONObject> series =new ArrayList<>(); - JSONObject seriesObject=new JSONObject(); - seriesObject.put("name","合格率"); - List<Double> seriesObjectData =new ArrayList<>(); + JSONObject res = new JSONObject(); + List<String> categories = new ArrayList<>(); + List<JSONObject> series = new ArrayList<>(); + JSONObject seriesObject = new JSONObject(); + seriesObject.put("name", "合格率"); + List<Double> seriesObjectData = new ArrayList<>(); //按照单位日期查询数据 //横坐标获取当前商品上架的商品 - String startTime ; - String endTime ; - if (unit.equals("day")){ + String startTime; + String endTime; + if (unit.equals("day")) { String format = DateUtil.format(new Date(), "yyyy-MM-dd"); - startTime = format+" 00:00:00"; - endTime = format+" 23:59:59"; - } else if (unit.equals("week")){ + startTime = format + " 00:00:00"; + endTime = format + " 23:59:59"; + } else if (unit.equals("week")) { // 获取当前日期 LocalDate currentDate = LocalDate.now(); @@ -815,8 +816,8 @@ public class AppInspectionPartnerServiceImpl extends ServiceImpl<AppInspectionPa // 将日期格式化为字符串 startTime = startOfWeek.atStartOfDay().format(formatter); - endTime = DateUtil.format(new Date(),"yyyy-MM-dd HH:mm:ss"); - } else if (unit.equals("month")){ + endTime = DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"); + } else if (unit.equals("month")) { // 获取当前日期 LocalDate currentDate = LocalDate.now(); @@ -825,8 +826,8 @@ public class AppInspectionPartnerServiceImpl extends ServiceImpl<AppInspectionPa // 创建日期时间格式化器 DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); startTime = firstDayOfMonth.atStartOfDay().format(formatter); - endTime = DateUtil.format(new Date(),"yyyy-MM-dd HH:mm:ss"); - } else if (unit.equals("year")){ + endTime = DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"); + } else if (unit.equals("year")) { // 获取当前日期 LocalDate currentDate = LocalDate.now(); @@ -835,8 +836,8 @@ public class AppInspectionPartnerServiceImpl extends ServiceImpl<AppInspectionPa // 创建日期时间格式化器 DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); startTime = firstDayOfYear.atStartOfDay().format(formatter); - endTime = DateUtil.format(new Date(),"yyyy-MM-dd HH:mm:ss"); - }else { + endTime = DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"); + } else { // 获取当前日期 LocalDate currentDate = LocalDate.now(); @@ -848,55 +849,56 @@ public class AppInspectionPartnerServiceImpl extends ServiceImpl<AppInspectionPa // 将日期格式化为字符串 startTime = startOfWeek.atStartOfDay().format(formatter); - endTime = DateUtil.format(new Date(),"yyyy-MM-dd HH:mm:ss"); + endTime = DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"); } //获取商家现有商品 - LambdaQueryWrapper<ShopInspectionGoods> queryWrapper1 =new LambdaQueryWrapper<>(); - queryWrapper1.eq(ShopInspectionGoods::getPartnerId,partnerId); + LambdaQueryWrapper<ShopInspectionGoods> queryWrapper1 = new LambdaQueryWrapper<>(); + queryWrapper1.eq(ShopInspectionGoods::getPartnerId, partnerId); List<ShopInspectionGoods> list1 = goodsService.list(queryWrapper1); - List<Map<String,String>> list = baseMapper.chartInfoRatio(startTime,endTime,partnerId); + List<Map<String, String>> list = baseMapper.chartInfoRatio(startTime, endTime, partnerId); //统计各个车型的价格 从高到低 - for (Map<String,String> orderInfo : list) { - categories.add(orderInfo.get("goodsTitle").indexOf("(")>0?orderInfo.get("goodsTitle").substring(0,orderInfo.get("goodsTitle").indexOf("(")):orderInfo.get("goodsTitle")); - list1.removeIf(it->{ + for (Map<String, String> orderInfo : list) { + categories.add(orderInfo.get("goodsTitle").indexOf("(") > 0 ? orderInfo.get("goodsTitle").substring(0, orderInfo.get("goodsTitle").indexOf("(")) : orderInfo.get("goodsTitle")); + list1.removeIf(it -> { return it.getTitle().equals(orderInfo.get("goodsTitle")); }); - if (ObjectUtil.isEmpty(orderInfo.get("passRatio"))){ + if (ObjectUtil.isEmpty(orderInfo.get("passRatio"))) { seriesObjectData.add(0d); - }else { + } else { seriesObjectData.add(Double.valueOf(String.valueOf(orderInfo.get("passRatio")))); } } - categories.addAll(list1.stream().map(it->{ - return it.getTitle().indexOf("(")>0?it.getTitle().substring(0,it.getTitle().indexOf("(")):it.getTitle(); + categories.addAll(list1.stream().map(it -> { + return it.getTitle().indexOf("(") > 0 ? it.getTitle().substring(0, it.getTitle().indexOf("(")) : it.getTitle(); }).collect(Collectors.toList())); - seriesObjectData.addAll(list1.stream().map(it->{ + seriesObjectData.addAll(list1.stream().map(it -> { return 0d; }).collect(Collectors.toList())); - seriesObject.put("data",seriesObjectData); + seriesObject.put("data", seriesObjectData); series.add(seriesObject); - res.put("categories",categories); - res.put("series",series); + res.put("categories", categories); + res.put("series", series); return res; } + @Override public JSONObject newChartInfoRatio(String unit) { - JSONObject res =new JSONObject(); - List<String> categories =new ArrayList<>(); - List<JSONObject> series =new ArrayList<>(); - JSONObject seriesObject=new JSONObject(); - seriesObject.put("name","合格率"); - List<Double> seriesObjectData =new ArrayList<>(); + JSONObject res = new JSONObject(); + List<String> categories = new ArrayList<>(); + List<JSONObject> series = new ArrayList<>(); + JSONObject seriesObject = new JSONObject(); + seriesObject.put("name", "合格率"); + List<Double> seriesObjectData = new ArrayList<>(); //按照单位日期查询数据 //横坐标获取当前商品上架的商品 - String startTime ; - String endTime ; - if (unit.equals("day")){ + String startTime; + String endTime; + if (unit.equals("day")) { String format = DateUtil.format(new Date(), "yyyy-MM-dd"); - startTime = format+" 00:00:00"; - endTime = format+" 23:59:59"; - } else if (unit.equals("week")){ + startTime = format + " 00:00:00"; + endTime = format + " 23:59:59"; + } else if (unit.equals("week")) { // 获取当前日期 LocalDate currentDate = LocalDate.now(); @@ -908,8 +910,8 @@ public class AppInspectionPartnerServiceImpl extends ServiceImpl<AppInspectionPa // 将日期格式化为字符串 startTime = startOfWeek.atStartOfDay().format(formatter); - endTime = DateUtil.format(new Date(),"yyyy-MM-dd HH:mm:ss"); - } else if (unit.equals("month")){ + endTime = DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"); + } else if (unit.equals("month")) { // 获取当前日期 LocalDate currentDate = LocalDate.now(); @@ -918,8 +920,8 @@ public class AppInspectionPartnerServiceImpl extends ServiceImpl<AppInspectionPa // 创建日期时间格式化器 DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); startTime = firstDayOfMonth.atStartOfDay().format(formatter); - endTime = DateUtil.format(new Date(),"yyyy-MM-dd HH:mm:ss"); - } else if (unit.equals("year")){ + endTime = DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"); + } else if (unit.equals("year")) { // 获取当前日期 LocalDate currentDate = LocalDate.now(); @@ -928,8 +930,8 @@ public class AppInspectionPartnerServiceImpl extends ServiceImpl<AppInspectionPa // 创建日期时间格式化器 DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); startTime = firstDayOfYear.atStartOfDay().format(formatter); - endTime = DateUtil.format(new Date(),"yyyy-MM-dd HH:mm:ss"); - }else { + endTime = DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"); + } else { // 获取当前日期 LocalDate currentDate = LocalDate.now(); @@ -941,35 +943,35 @@ public class AppInspectionPartnerServiceImpl extends ServiceImpl<AppInspectionPa // 将日期格式化为字符串 startTime = startOfWeek.atStartOfDay().format(formatter); - endTime = DateUtil.format(new Date(),"yyyy-MM-dd HH:mm:ss"); + endTime = DateUtil.format(new Date(), "yyyy-MM-dd HH:mm:ss"); } //获取商家现有商品 - LambdaQueryWrapper<ShopInspectionGoods> queryWrapper1 =new LambdaQueryWrapper<>(); + LambdaQueryWrapper<ShopInspectionGoods> queryWrapper1 = new LambdaQueryWrapper<>(); List<ShopInspectionGoods> list1 = goodsService.list(queryWrapper1); - List<Map<String,String>> list = baseMapper.newChartInfoRatio(startTime,endTime); + List<Map<String, String>> list = baseMapper.newChartInfoRatio(startTime, endTime); //统计各个车型的价格 从高到低 - for (Map<String,String> orderInfo : list) { - categories.add(orderInfo.get("goodsTitle").indexOf("(")>0?orderInfo.get("goodsTitle").substring(0,orderInfo.get("goodsTitle").indexOf("(")):orderInfo.get("goodsTitle")); - list1.removeIf(it->{ + for (Map<String, String> orderInfo : list) { + categories.add(orderInfo.get("goodsTitle").indexOf("(") > 0 ? orderInfo.get("goodsTitle").substring(0, orderInfo.get("goodsTitle").indexOf("(")) : orderInfo.get("goodsTitle")); + list1.removeIf(it -> { return it.getTitle().equals(orderInfo.get("goodsTitle")); }); - if (ObjectUtil.isEmpty(orderInfo.get("passRatio"))){ + if (ObjectUtil.isEmpty(orderInfo.get("passRatio"))) { seriesObjectData.add(0d); - }else { + } else { seriesObjectData.add(Double.valueOf(String.valueOf(orderInfo.get("passRatio")))); } } - categories.addAll(list1.stream().map(it->{ - return it.getTitle().indexOf("(")>0?it.getTitle().substring(0,it.getTitle().indexOf("(")):it.getTitle(); + categories.addAll(list1.stream().map(it -> { + return it.getTitle().indexOf("(") > 0 ? it.getTitle().substring(0, it.getTitle().indexOf("(")) : it.getTitle(); }).collect(Collectors.toList())); - seriesObjectData.addAll(list1.stream().map(it->{ + seriesObjectData.addAll(list1.stream().map(it -> { return 0d; }).collect(Collectors.toList())); - seriesObject.put("data",seriesObjectData); + seriesObject.put("data", seriesObjectData); series.add(seriesObject); - res.put("categories",categories); - res.put("series",series); + res.put("categories", categories); + res.put("series", series); return res; } @@ -980,8 +982,8 @@ public class AppInspectionPartnerServiceImpl extends ServiceImpl<AppInspectionPa // if (!partners.getUserId().equals(user.getId())){ // return null; // } - LambdaQueryWrapper<OrderInfo> queryWrapper =new LambdaQueryWrapper<>(); - queryWrapper.eq(OrderInfo::getPartnerId,partnerId).isNotNull(OrderInfo::getValidationTime).orderByDesc(OrderInfo::getValidationTime).last("limit 8"); + LambdaQueryWrapper<OrderInfo> queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(OrderInfo::getPartnerId, partnerId).isNotNull(OrderInfo::getValidationTime).orderByDesc(OrderInfo::getValidationTime).last("limit 8"); List<OrderInfo> list = orderService.list(queryWrapper); return list; } @@ -994,8 +996,9 @@ public class AppInspectionPartnerServiceImpl extends ServiceImpl<AppInspectionPa // return null; // } String dateStr = DateUtil.format(new Date(), "yyyy-MM-dd"); - return baseMapper.hotGoodsList(partnerId,dateStr); + return baseMapper.hotGoodsList(partnerId, dateStr); } + @Override public List<HotGoodsVo> newHotGoodsList() { String dateStr = DateUtil.format(new Date(), "yyyy-MM-dd"); @@ -1007,35 +1010,35 @@ public class AppInspectionPartnerServiceImpl extends ServiceImpl<AppInspectionPa public void addGoods(ShopInspectionGoods goods) throws Exception { LoginUser user = SecurityFrameworkUtils.getLoginUser(); ShopMallPartners partners = baseMapper.selectById(goods.getPartnerId()); - if (!partners.getUserId().equals(user.getId())){ + if (!partners.getUserId().equals(user.getId())) { return; } //判断当前分类 是否已经存在商品 - LambdaQueryWrapper<ShopInspectionGoods> queryWrapper =new LambdaQueryWrapper<>(); - queryWrapper.eq(ShopInspectionGoods::getGoodsCategoryId,goods.getGoodsCategoryId()).eq(ShopInspectionGoods::getPartnerId,goods.getPartnerId()); + LambdaQueryWrapper<ShopInspectionGoods> queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(ShopInspectionGoods::getGoodsCategoryId, goods.getGoodsCategoryId()).eq(ShopInspectionGoods::getPartnerId, goods.getPartnerId()); List<ShopInspectionGoods> list = goodsService.list(queryWrapper); - if (CollectionUtil.isNotEmpty(list)){ + if (CollectionUtil.isNotEmpty(list)) { throw new Exception("当前分类已存在商品"); } ShopInspectionCategory category = categoryService.getById(goods.getGoodsCategoryId()); goods.setTitle(category.getCategoryName()); - LambdaQueryWrapper<InspectionCategoryTemplate> categoryTemplateLambdaQueryWrapper =new LambdaQueryWrapper<>(); - categoryTemplateLambdaQueryWrapper.eq(InspectionCategoryTemplate::getCategoryId,category.getId()); + LambdaQueryWrapper<InspectionCategoryTemplate> categoryTemplateLambdaQueryWrapper = new LambdaQueryWrapper<>(); + categoryTemplateLambdaQueryWrapper.eq(InspectionCategoryTemplate::getCategoryId, category.getId()); List<InspectionCategoryTemplate> categoryTemplates = categoryTemplateService.list(categoryTemplateLambdaQueryWrapper); - List<InspectionGoodsSku> skuList = categoryTemplates.stream().sorted((o1,o2)->{ - if(o1.getSkuPrice()<o2.getSkuPrice()){ + List<InspectionGoodsSku> skuList = categoryTemplates.stream().sorted((o1, o2) -> { + if (o1.getSkuPrice() < o2.getSkuPrice()) { return 1; - }else if(o1.getSkuPrice().equals(o2.getSkuPrice())){ - if (o1.getSkuName().length()<o2.getSkuName().length()){ - return 1; - }else { - return 0; - } + } else if (o1.getSkuPrice().equals(o2.getSkuPrice())) { + if (o1.getSkuName().length() < o2.getSkuName().length()) { + return 1; + } else { + return 0; + } } else { return 0; } - }).map(it->{ - InspectionGoodsSku sku =new InspectionGoodsSku(); + }).map(it -> { + InspectionGoodsSku sku = new InspectionGoodsSku(); sku.setSkuName(it.getSkuName()); sku.setPrice(it.getSkuPrice()); sku.setDbPrice(it.getSkuPrice()); @@ -1046,30 +1049,31 @@ public class AppInspectionPartnerServiceImpl extends ServiceImpl<AppInspectionPa goods.setIsListing("0"); goods.setListingStatus("0"); goods.setRejectReason(""); - goods.setPrice(skuList.get(skuList.size()-1).getPrice()); + goods.setPrice(skuList.get(skuList.size() - 1).getPrice()); goodsService.save(goods); Integer orderNum = 1; for (InspectionGoodsSku it : skuList) { it.setGoodsId(goods.getId()); it.setOrderNum(orderNum); orderNum++; - }; + } + ; skuService.saveBatch(skuList); } @Override - public IPage<GoodsVo> goodsList(Page<GoodsVo> page,Long partnerId, String isListing, String goodsTitle) { - return baseMapper.manageGoodsList(page,partnerId,isListing,goodsTitle); + public IPage<GoodsVo> goodsList(Page<GoodsVo> page, Long partnerId, String isListing, String goodsTitle) { + return baseMapper.manageGoodsList(page, partnerId, isListing, goodsTitle); } @Override public List<JSONObject> canUseGoods(Long partnerId) { List<JSONObject> listGoods = new ArrayList<>(); - LambdaQueryWrapper<ShopInspectionGoods> queryWrapper =new LambdaQueryWrapper<>(); - queryWrapper.eq(ShopInspectionGoods::getPartnerId,partnerId).eq(ShopInspectionGoods::getIsListing,"1").orderByAsc(ShopInspectionGoods::getOrderNum); + LambdaQueryWrapper<ShopInspectionGoods> queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(ShopInspectionGoods::getPartnerId, partnerId).eq(ShopInspectionGoods::getIsListing, "1").orderByAsc(ShopInspectionGoods::getOrderNum); List<ShopInspectionGoods> list = goodsService.list(queryWrapper); - if (CollectionUtil.isNotEmpty(list)){ + if (CollectionUtil.isNotEmpty(list)) { listGoods = list.stream().map(it -> { JSONObject item = new JSONObject(); item.put("label", it.getTitle()); @@ -1077,7 +1081,7 @@ public class AppInspectionPartnerServiceImpl extends ServiceImpl<AppInspectionPa return item; }).collect(Collectors.toList()); } - return listGoods; + return listGoods; } @Override @@ -1089,16 +1093,16 @@ public class AppInspectionPartnerServiceImpl extends ServiceImpl<AppInspectionPa // if (!partners.getUserId().equals(user.getId())){ // return null; // } - LambdaQueryWrapper<InspectionGoodsSku> queryWrapper =new LambdaQueryWrapper<>(); - queryWrapper.eq(InspectionGoodsSku::getGoodsId,goodsId); + LambdaQueryWrapper<InspectionGoodsSku> queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(InspectionGoodsSku::getGoodsId, goodsId); List<InspectionGoodsSku> list = skuService.list(queryWrapper); goods.setSkuList(list); - if (StringUtils.isNotEmpty(goods.getImages())){ + if (StringUtils.isNotEmpty(goods.getImages())) { goods.setImageList(goods.getImages().split(",")); } ShopInspectionCategory category = categoryService.getById(goods.getGoodsCategoryId()); goods.setCategoryName(category.getCategoryName()); - return goods; + return goods; } @Override @@ -1106,21 +1110,21 @@ public class AppInspectionPartnerServiceImpl extends ServiceImpl<AppInspectionPa public void editGoods(ShopInspectionGoods goods) throws Exception { LoginUser user = SecurityFrameworkUtils.getLoginUser(); ShopMallPartners partners = baseMapper.selectById(goods.getPartnerId()); - if (!partners.getUserId().equals(user.getId())){ + if (!partners.getUserId().equals(user.getId())) { return; } ShopInspectionGoods goods1 = goodsService.getById(goods.getId()); - if (goods1.getIsListing().equals("1")){ + if (goods1.getIsListing().equals("1")) { //如果是上架状态不可编辑 throw new Exception("请先下架"); } //判断当前分类 是否已经存在商品 - LambdaQueryWrapper<ShopInspectionGoods> queryWrapper1 =new LambdaQueryWrapper<>(); - queryWrapper1.eq(ShopInspectionGoods::getGoodsCategoryId,goods.getGoodsCategoryId()) - .eq(ShopInspectionGoods::getPartnerId,goods.getPartnerId()) - .ne(ShopInspectionGoods::getId,goods.getId()); + LambdaQueryWrapper<ShopInspectionGoods> queryWrapper1 = new LambdaQueryWrapper<>(); + queryWrapper1.eq(ShopInspectionGoods::getGoodsCategoryId, goods.getGoodsCategoryId()) + .eq(ShopInspectionGoods::getPartnerId, goods.getPartnerId()) + .ne(ShopInspectionGoods::getId, goods.getId()); List<ShopInspectionGoods> list = goodsService.list(queryWrapper1); - if (CollectionUtil.isNotEmpty(list)){ + if (CollectionUtil.isNotEmpty(list)) { throw new Exception("当前分类已存在商品"); } ShopInspectionCategory category = categoryService.getById(goods.getGoodsCategoryId()); @@ -1130,38 +1134,40 @@ public class AppInspectionPartnerServiceImpl extends ServiceImpl<AppInspectionPa goods.setRejectReason(goods1.getRejectReason()); goodsService.updateById(goods); } + @Override @Transactional(rollbackFor = Exception.class) public void editSkuPrice(ShopInspectionGoods goods) throws Exception { LoginUser user = SecurityFrameworkUtils.getLoginUser(); ShopMallPartners partners = baseMapper.selectById(goods.getPartnerId()); - if (!partners.getUserId().equals(user.getId())){ + if (!partners.getUserId().equals(user.getId())) { return; } skuService.updateBatchById(goods.getSkuList()); } + @Override public void changeListing(Long goodsId) throws Exception { ShopInspectionGoods goods = goodsService.getById(goodsId); - if (goods.getIsListing().equals("0")&&(goods.getListingStatus().equals("1")||goods.getListingStatus().equals("2"))){ + if (goods.getIsListing().equals("0") && (goods.getListingStatus().equals("1") || goods.getListingStatus().equals("2"))) { throw new Exception("不可重复上架!"); } LoginUser user = SecurityFrameworkUtils.getLoginUser(); ShopMallPartners partners = baseMapper.selectById(goods.getPartnerId()); - if (!partners.getUserId().equals(user.getId())){ + if (!partners.getUserId().equals(user.getId())) { return; } - goods.setIsListing(goods.getIsListing().equals("0")?"1":"0"); - if (goods.getIsListing().equals("1")){ + goods.setIsListing(goods.getIsListing().equals("0") ? "1" : "0"); + if (goods.getIsListing().equals("1")) { //代表上架 goods.setIsListing("0"); //上架待审核 goods.setListingStatus("1"); goods.setRejectReason(""); - }else { + } else { //代表下架 goods.setListingStatus("0"); goods.setRejectReason(""); @@ -1174,17 +1180,17 @@ public class AppInspectionPartnerServiceImpl extends ServiceImpl<AppInspectionPa @Transactional(rollbackFor = Exception.class) public void delGoods(Long goodsId) throws Exception { ShopInspectionGoods goods = goodsService.getById(goodsId); - if (goods.getIsListing().equals("1")){ + if (goods.getIsListing().equals("1")) { throw new Exception("删除请先下架!"); } LoginUser user = SecurityFrameworkUtils.getLoginUser(); ShopMallPartners partners = baseMapper.selectById(goods.getPartnerId()); - if (!partners.getUserId().equals(user.getId())){ + if (!partners.getUserId().equals(user.getId())) { return; } goodsService.removeById(goodsId); - LambdaQueryWrapper<InspectionGoodsSku> queryWrapper =new LambdaQueryWrapper<>(); - queryWrapper.eq(InspectionGoodsSku::getGoodsId,goodsId); + LambdaQueryWrapper<InspectionGoodsSku> queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(InspectionGoodsSku::getGoodsId, goodsId); skuService.remove(queryWrapper); } @@ -1192,7 +1198,7 @@ public class AppInspectionPartnerServiceImpl extends ServiceImpl<AppInspectionPa public void editPartnerInfo(ShopMallPartners partners) { LoginUser user = SecurityFrameworkUtils.getLoginUser(); ShopMallPartners partnersTmp = baseMapper.selectById(partners.getPartnerId()); - if (!partnersTmp.getUserId().equals(user.getId())){ + if (!partnersTmp.getUserId().equals(user.getId())) { return; } List<String> addressList = AddressSplitter.splitAddress(partners.getAddress()); @@ -1206,13 +1212,13 @@ public class AppInspectionPartnerServiceImpl extends ServiceImpl<AppInspectionPa public PartnerVo getPartnerInfo(Long partnerId) { LoginUser user = SecurityFrameworkUtils.getLoginUser(); ShopMallPartners partnersTmp = baseMapper.selectById(partnerId); - if (!partnersTmp.getUserId().equals(user.getId())){ + if (!partnersTmp.getUserId().equals(user.getId())) { return null; } ShopMallPartners partners = this.getById(partnerId); - PartnerVo partnerVo =new PartnerVo(); - BeanUtils.copyProperties(partners,partnerVo); - if (StringUtils.isNotEmpty(partnerVo.getShopImages())){ + PartnerVo partnerVo = new PartnerVo(); + BeanUtils.copyProperties(partners, partnerVo); + if (StringUtils.isNotEmpty(partnerVo.getShopImages())) { partnerVo.setShopImageList(partnerVo.getShopImages().split(",")); } return partnerVo; @@ -1223,50 +1229,50 @@ public class AppInspectionPartnerServiceImpl extends ServiceImpl<AppInspectionPa public PartnerBalance accountInfo(Long partnerId) { LoginUser user = SecurityFrameworkUtils.getLoginUser(); ShopMallPartners partnersTmp = baseMapper.selectById(partnerId); - if (!partnersTmp.getUserId().equals(user.getId())){ + if (!partnersTmp.getUserId().equals(user.getId())) { return null; } - LambdaQueryWrapper<PartnerBalance> queryWrapper =new LambdaQueryWrapper<>(); - queryWrapper.eq(PartnerBalance::getPartnerId,partnerId); - return partnerBalanceService.getOne(queryWrapper); + LambdaQueryWrapper<PartnerBalance> queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(PartnerBalance::getPartnerId, partnerId); + return partnerBalanceService.getOne(queryWrapper); } @Override - public IPage<PartnerBalanceDetail> accountDetail(Page<PartnerBalanceDetail> page,Long partnerId, Integer pageNum, Integer pageSize) { + public IPage<PartnerBalanceDetail> accountDetail(Page<PartnerBalanceDetail> page, Long partnerId, Integer pageNum, Integer pageSize) { LoginUser user = SecurityFrameworkUtils.getLoginUser(); ShopMallPartners partnersTmp = baseMapper.selectById(partnerId); - if (!partnersTmp.getUserId().equals(user.getId())){ + if (!partnersTmp.getUserId().equals(user.getId())) { return null; } - LambdaQueryWrapper<PartnerBalance> queryWrapper =new LambdaQueryWrapper<>(); - queryWrapper.eq(PartnerBalance::getPartnerId,partnerId); + LambdaQueryWrapper<PartnerBalance> queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(PartnerBalance::getPartnerId, partnerId); PartnerBalance one = partnerBalanceService.getOne(queryWrapper); - LambdaQueryWrapper<PartnerBalanceDetail> queryWrapper1 =new LambdaQueryWrapper<>(); - queryWrapper1.eq(PartnerBalanceDetail::getPartnerBalanceId,one.getId()).orderByDesc(PartnerBalanceDetail::getChangeTime); - return detailService.page(page,queryWrapper1); + LambdaQueryWrapper<PartnerBalanceDetail> queryWrapper1 = new LambdaQueryWrapper<>(); + queryWrapper1.eq(PartnerBalanceDetail::getPartnerBalanceId, one.getId()).orderByDesc(PartnerBalanceDetail::getChangeTime); + return detailService.page(page, queryWrapper1); } @Override - public IPage<OrderAppDetail> orderList(Page<OrderAppDetail> page,Long partnerId,String phoneNum, String title) { - return baseMapper.orderList(page,partnerId,phoneNum,title); + public IPage<OrderAppDetail> orderList(Page<OrderAppDetail> page, Long partnerId, String phoneNum, String title) { + return baseMapper.orderList(page, partnerId, phoneNum, title); } @Override public OrderAppDetail orderDetail(Long partnerId, Long orderId) { LoginUser user = SecurityFrameworkUtils.getLoginUser(); ShopMallPartners partnersTmp = baseMapper.selectById(partnerId); - if (!partnersTmp.getUserId().equals(user.getId())){ + if (!partnersTmp.getUserId().equals(user.getId())) { return null; } OrderInfo orderInfo = orderService.getById(orderId); - if (!orderInfo.getPartnerId().equals(partnerId)){ + if (!orderInfo.getPartnerId().equals(partnerId)) { return null; } ShopInspectionGoods goods = goodsService.getById(orderInfo.getGoodsId()); - OrderAppDetail orderDetail =new OrderAppDetail(); + OrderAppDetail orderDetail = new OrderAppDetail(); orderDetail.setGoodsId(orderInfo.getGoodsId()); - orderDetail.setGoodsTitle(orderInfo.getGoodsTitle()+ (StringUtils.isNotEmpty(orderInfo.getSkuName())?"-"+orderInfo.getSkuName():"")); + orderDetail.setGoodsTitle(orderInfo.getGoodsTitle() + (StringUtils.isNotEmpty(orderInfo.getSkuName()) ? "-" + orderInfo.getSkuName() : "")); orderDetail.setGoodsImage(goods.getImage()); orderDetail.setGoodsPrice(orderInfo.getGoodsPrice()); orderDetail.setPayMoney(orderInfo.getPayMoney()); @@ -1279,7 +1285,7 @@ public class AppInspectionPartnerServiceImpl extends ServiceImpl<AppInspectionPa AdminUserDO buyUser = userService.getUser(orderInfo.getUserId()); orderDetail.setBuyUserName(buyUser.getNickname()); orderDetail.setBuyUserPhone(buyUser.getMobile()); - if(ObjectUtil.isNotEmpty(orderInfo.getUserCarId())){ + if (ObjectUtil.isNotEmpty(orderInfo.getUserCarId())) { ShopUserCar userCar = userCarService.getById(orderInfo.getUserCarId()); orderDetail.setCarNum(userCar.getCarNo()); } @@ -1287,30 +1293,30 @@ public class AppInspectionPartnerServiceImpl extends ServiceImpl<AppInspectionPa } @Override - public Long orderDetailByCode(Long partnerId, String code) throws Exception { - LambdaQueryWrapper<OrderInfo> queryWrapper =new LambdaQueryWrapper<>(); - queryWrapper.eq(OrderInfo::getAccessCode,code); + public Long orderDetailByCode(Long partnerId, String code) throws Exception { + LambdaQueryWrapper<OrderInfo> queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(OrderInfo::getAccessCode, code); OrderInfo one = orderService.getOne(queryWrapper); - if (ObjectUtil.isEmpty(one)){ + if (ObjectUtil.isEmpty(one)) { throw new Exception("核销码不存在"); } - return one.getId(); + return one.getId(); } @Override @Transactional(rollbackFor = Exception.class) - public void takeOut(Long partnerId, Long orderId,Long workId,String carNum) throws Exception { + public void takeOut(Long partnerId, Long orderId, Long workId, String carNum) throws Exception { LoginUser loginUser = SecurityFrameworkUtils.getLoginUser(); AdminUserDO user = userService.getUser(loginUser.getId()); ShopMallPartners partnersTmp = baseMapper.selectById(partnerId); - if (!partnersTmp.getUserId().equals(user.getId())){ + if (!partnersTmp.getUserId().equals(user.getId())) { return; } OrderInfo orderInfo = orderService.getById(orderId); - if (!orderInfo.getPartnerId().equals(partnerId)){ + if (!orderInfo.getPartnerId().equals(partnerId)) { throw new Exception("您无核销权限"); } - if (!orderInfo.getOrderStatus().equals("1")&&!ObjectUtil.isEmpty(orderInfo.getValidationTime())){ + if (!orderInfo.getOrderStatus().equals("1") && !ObjectUtil.isEmpty(orderInfo.getValidationTime())) { throw new Exception("已核销请不要重复核销"); } //处理订单信息 @@ -1320,20 +1326,20 @@ public class AppInspectionPartnerServiceImpl extends ServiceImpl<AppInspectionPa orderInfo.setValidationRealName(user.getNickname()); orderService.updateById(orderInfo); //追加订单明细记录 - orderInfoDetailService.save(new OrderInfoDetail(orderInfo.getId(),"核销成功",new Date(),orderInfo.getPayMoney(),"1")); + orderInfoDetailService.save(new OrderInfoDetail(orderInfo.getId(), "核销成功", new Date(), orderInfo.getPayMoney(), "1")); //处理商家收益 - partnerBalanceService.addSellBalance(orderInfo.getPartnerId(),orderInfo.getPayMoney()+orderInfo.getBalance(),orderInfo.getGoodsTitle()); + partnerBalanceService.addSellBalance(orderInfo.getPartnerId(), orderInfo.getPayMoney() + orderInfo.getBalance(), orderInfo.getGoodsTitle()); ShopInspectionGoods goods = goodsService.getById(orderInfo.getGoodsId()); //开始检测信息 - InspectionInfo info =new InspectionInfo(); + InspectionInfo info = new InspectionInfo(); info.setUserId(orderInfo.getUserId()); info.setPartnerId(orderInfo.getPartnerId()); info.setInspectionOrderId(orderInfo.getId()); info.setCarNum(carNum); info.setCategoryId(goods.getGoodsCategoryId()); - info.setYear(DateUtil.format(new Date(),"yyyy")); - info.setMonth(DateUtil.format(new Date(),"yyyy-MM")); - info.setDay(DateUtil.format(new Date(),"yyyy-MM-dd")); + info.setYear(DateUtil.format(new Date(), "yyyy")); + info.setMonth(DateUtil.format(new Date(), "yyyy-MM")); + info.setDay(DateUtil.format(new Date(), "yyyy-MM-dd")); info.setStartTime(new Date()); info.setStatus("0"); //获取修理工信息 @@ -1353,12 +1359,12 @@ public class AppInspectionPartnerServiceImpl extends ServiceImpl<AppInspectionPa info.setCarNum(orderInfo.getCarNo()); inspectionInfoService.save(info); //增加客户信息 - LambdaQueryWrapper<PartnerCustomerInfo> queryWrapper =new LambdaQueryWrapper<>(); - queryWrapper.eq(PartnerCustomerInfo::getPartnerId,partnerId).eq(PartnerCustomerInfo::getUserId,orderInfo.getUserId()); + LambdaQueryWrapper<PartnerCustomerInfo> queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(PartnerCustomerInfo::getPartnerId, partnerId).eq(PartnerCustomerInfo::getUserId, orderInfo.getUserId()); PartnerCustomerInfo customerInfo = customerInfoService.getOne(queryWrapper); - if (ObjectUtil.isEmpty(customerInfo)){ + if (ObjectUtil.isEmpty(customerInfo)) { AdminUserDO buyUser = userService.getUser(orderInfo.getUserId()); - customerInfo =new PartnerCustomerInfo(); + customerInfo = new PartnerCustomerInfo(); customerInfo.setPartnerId(partnerId); customerInfo.setUserId(buyUser.getId()); customerInfo.setCustomerPhone(buyUser.getMobile()); @@ -1368,7 +1374,7 @@ public class AppInspectionPartnerServiceImpl extends ServiceImpl<AppInspectionPa customerInfoService.save(customerInfo); } - InspectionStepInfo stepInfo =new InspectionStepInfo(); + InspectionStepInfo stepInfo = new InspectionStepInfo(); stepInfo.setInspectionInfoId(info.getId().intValue()); stepInfo.setContent("检测开始"); stepInfo.setTitle("检测开始"); @@ -1383,31 +1389,31 @@ public class AppInspectionPartnerServiceImpl extends ServiceImpl<AppInspectionPa // 将当前时间转换为指定格式 String formattedTime = currentTime.format(formatter); try { - SendSmsUtil.sendMsgCommon(new String[]{formattedTime},orderInfo.getPhonenumber(),"1400852709","机动车管家小程序","1961713"); - }catch (Exception ignored){ + SendSmsUtil.sendMsgCommon(new String[]{formattedTime}, orderInfo.getPhonenumber(), "1400852709", "机动车管家小程序", "1961713"); + } catch (Exception ignored) { log.error(ignored.getMessage()); } } @Override - public void addWorker(Long partnerId, String realName, String phoneNum,Long postId) throws Exception { + public void addWorker(Long partnerId, String realName, String phoneNum, Long postId) throws Exception { try { LoginUser user = SecurityFrameworkUtils.getLoginUser(); ShopMallPartners partnersTmp = baseMapper.selectById(partnerId); - if (!partnersTmp.getUserId().equals(user.getId())){ + if (!partnersTmp.getUserId().equals(user.getId())) { return; } AdminUserDO workUser = userService.getUserByMobile(phoneNum); - if (workUser.getMobile().equals(phoneNum)){ - LambdaQueryWrapper<PartnerWorker> queryWrapper1 =new LambdaQueryWrapper<>(); - queryWrapper1.eq(PartnerWorker::getUserId,workUser.getId()); + if (workUser.getMobile().equals(phoneNum)) { + LambdaQueryWrapper<PartnerWorker> queryWrapper1 = new LambdaQueryWrapper<>(); + queryWrapper1.eq(PartnerWorker::getUserId, workUser.getId()); PartnerWorker one = partnerWorkerService.getOne(queryWrapper1); if (ObjectUtil.isNotEmpty(one)) { return; } - PartnerWorker partnerWorker =new PartnerWorker(); + PartnerWorker partnerWorker = new PartnerWorker(); partnerWorker.setPartnerId(partnerId); partnerWorker.setUserId(workUser.getId()); partnerWorker.setWorkPhone(workUser.getMobile()); @@ -1426,39 +1432,39 @@ public class AppInspectionPartnerServiceImpl extends ServiceImpl<AppInspectionPa userSaveReqVO.setNickname(realName); userService.updateUser(userSaveReqVO); - }else { + } else { throw new Exception(""); } - }catch (Exception e){ + } catch (Exception e) { throw new Exception("输入信息有误,添加失败"); } } @Override - public List<PartnerWorker> getWorkList(Long partnerId,Long postId,String workName,String phoneNum) { - return baseMapper.getWorkList(partnerId,postId,workName,phoneNum); + public List<PartnerWorker> getWorkList(Long partnerId, Long postId, String workName, String phoneNum) { + return baseMapper.getWorkList(partnerId, postId, workName, phoneNum); } @Override public IPage<PartnerWorker> pageWorkList(Long partnerId, Long postId, String workName, String phoneNum, Page<LabelRespVO> page) { - return baseMapper.pageWorkList(partnerId,postId,workName,phoneNum,page); + return baseMapper.pageWorkList(partnerId, postId, workName, phoneNum, page); } @Override public void delWorker(Long partnerId, Long workId) { LoginUser user = SecurityFrameworkUtils.getLoginUser(); ShopMallPartners partnersTmp = baseMapper.selectById(partnerId); - if (!partnersTmp.getUserId().equals(user.getId())){ + if (!partnersTmp.getUserId().equals(user.getId())) { return; } partnerWorkerService.removeById(workId); } @Override - public IPage<InspectionInfo> inspectionList(Page<InspectionInfo> page,Long partnerId, String status, String carNum) { - return baseMapper.inspectionList(page,partnerId,status,carNum); + public IPage<InspectionInfo> inspectionList(Page<InspectionInfo> page, Long partnerId, String status, String carNum) { + return baseMapper.inspectionList(page, partnerId, status, carNum); } @Override @@ -1468,8 +1474,8 @@ public class AppInspectionPartnerServiceImpl extends ServiceImpl<AppInspectionPa InspectionGoodsSku sku = skuService.getById(order.getSkuId()); AdminUserDO buyUser = userService.getUser(info.getUserId()); AdminUserDO worker = userService.getUser(info.getWorkId()); - InspectionInfoVo res =new InspectionInfoVo(); - BeanUtils.copyProperties(order,res); + InspectionInfoVo res = new InspectionInfoVo(); + BeanUtils.copyProperties(order, res); res.setInspectionId(info.getId()); if (ObjectUtil.isNotNull(worker)) { res.setWorkerAvatar(Optional.ofNullable(worker.getAvatar()).orElse(null)); @@ -1477,11 +1483,11 @@ public class AppInspectionPartnerServiceImpl extends ServiceImpl<AppInspectionPa res.setWorkerPhone(worker.getMobile()); } /*根据工单表中的leadManId查询对应的引车员*/ - if (ObjectUtil.isNotNull(info.getLeadManId())){ + if (ObjectUtil.isNotNull(info.getLeadManId())) { AdminUserDO leadMan = adminUserService.getById(info.getLeadManId()); res.setLeadManName(leadMan.getNickname()); res.setLeadManId(info.getLeadManId()); - }else { + } else { res.setLeadManName(""); } res.setBuyUserName(Optional.ofNullable(buyUser.getNickname()).orElse("")); @@ -1503,10 +1509,10 @@ public class AppInspectionPartnerServiceImpl extends ServiceImpl<AppInspectionPa ShopInspectionGoods goods = goodsService.getById(order.getGoodsId()); res.setGoodsImage(goods.getImage()); LambdaQueryWrapper<InspectionStepInfo> queryWrapper = new LambdaQueryWrapper<>(); - queryWrapper.eq(InspectionStepInfo::getInspectionInfoId,inspectionInfoId).orderByAsc(InspectionStepInfo::getStepNum); + queryWrapper.eq(InspectionStepInfo::getInspectionInfoId, inspectionInfoId).orderByAsc(InspectionStepInfo::getStepNum); queryWrapper.orderBy(true, false, InspectionStepInfo::getId); List<InspectionStepInfo> list = stepInfoService.listByInspectionInfoId(inspectionInfoId); - if (CollectionUtil.isNotEmpty(list)){ + if (CollectionUtil.isNotEmpty(list)) { res.setStepInfos(list); } ShopInspectionCategory category = categoryService.getById(info.getCategoryId()); @@ -1519,18 +1525,18 @@ public class AppInspectionPartnerServiceImpl extends ServiceImpl<AppInspectionPa @Override public List<InspectionInfo> workerInspectionList(Long workerId, String status, String searchValue) { - return baseMapper.workerInspectionList(workerId,status,searchValue); + return baseMapper.workerInspectionList(workerId, status, searchValue); } @Override public void addStepInfo(InspectionStepInfo stepInfo) { LambdaQueryWrapper<InspectionStepInfo> queryWrapper = new LambdaQueryWrapper<>(); - queryWrapper.eq(InspectionStepInfo::getInspectionInfoId,stepInfo.getInspectionInfoId()).orderByDesc(InspectionStepInfo::getStepNum).last("limit 1"); + queryWrapper.eq(InspectionStepInfo::getInspectionInfoId, stepInfo.getInspectionInfoId()).orderByDesc(InspectionStepInfo::getStepNum).last("limit 1"); InspectionStepInfo list = stepInfoService.getOne(queryWrapper); - if (ObjectUtil.isNotEmpty(list)){ - stepInfo.setStepNum(list.getStepNum()+1); - }else { + if (ObjectUtil.isNotEmpty(list)) { + stepInfo.setStepNum(list.getStepNum() + 1); + } else { stepInfo.setStepNum(1); } stepInfoService.save(stepInfo); @@ -1539,33 +1545,33 @@ public class AppInspectionPartnerServiceImpl extends ServiceImpl<AppInspectionPa @Override public void stopInspection(InspectionInfo info) throws Exception { InspectionInfo infoOld = inspectionInfoService.getById(info.getId()); - if (infoOld.getStatus().equals("1")){ + if (infoOld.getStatus().equals("1")) { throw new Exception("已结束"); } - if (info.getIsPass().equals("0")&&StringUtils.isNotEmpty(info.getIsRetrial())&&info.getIsRetrial().equals("1")){ + if (info.getIsPass().equals("0") && StringUtils.isNotEmpty(info.getIsRetrial()) && info.getIsRetrial().equals("1")) { //重审 infoOld.setStatus("0"); infoOld.setIsPass(info.getIsPass()); infoOld.setRemark(info.getRemark()); infoOld.setIsRetrial("1"); inspectionInfoService.updateById(infoOld); - InspectionStepInfo stepInfo =new InspectionStepInfo(); + InspectionStepInfo stepInfo = new InspectionStepInfo(); stepInfo.setInspectionInfoId(info.getId().intValue()); stepInfo.setContent(info.getRemark()); stepInfo.setTitle("检测重审"); this.addStepInfo(stepInfo); - }else { + } else { infoOld.setStatus("1"); infoOld.setIsPass(info.getIsPass()); infoOld.setRemark(info.getRemark()); infoOld.setEndTime(new Date()); inspectionInfoService.updateById(infoOld); - InspectionStepInfo stepInfo =new InspectionStepInfo(); + InspectionStepInfo stepInfo = new InspectionStepInfo(); stepInfo.setContent(info.getRemark()); - if (StringUtils.isNotEmpty(infoOld.getIsPass())&&infoOld.getIsPass().equals("1")){ + if (StringUtils.isNotEmpty(infoOld.getIsPass()) && infoOld.getIsPass().equals("1")) { stepInfo.setTitle("检测结束-检测通过"); - }else { + } else { stepInfo.setTitle("检测结束-检测不合格"); } @@ -1584,17 +1590,17 @@ public class AppInspectionPartnerServiceImpl extends ServiceImpl<AppInspectionPa // 将当前时间转换为指定格式 String formattedTime = currentTime.format(formatter); - if (PhoneValidator.isValid(orderInfo.getPhonenumber())){ - if (StringUtils.isNotEmpty(infoOld.getIsPass())&&infoOld.getIsPass().equals("1")){ - SendSmsUtil.sendMsgCommon(new String[]{Optional.ofNullable(orderInfo.getCarNo()).orElse(" "),infoOld.getWorkerName(),infoOld.getWorkerPhone()},orderInfo.getPhonenumber(),"1400852709","机动车管家小程序","2112788"); + if (PhoneValidator.isValid(orderInfo.getPhonenumber())) { + if (StringUtils.isNotEmpty(infoOld.getIsPass()) && infoOld.getIsPass().equals("1")) { + SendSmsUtil.sendMsgCommon(new String[]{Optional.ofNullable(orderInfo.getCarNo()).orElse(" "), infoOld.getWorkerName(), infoOld.getWorkerPhone()}, orderInfo.getPhonenumber(), "1400852709", "机动车管家小程序", "2112788"); - }else { - SendSmsUtil.sendMsgCommon(new String[]{Optional.ofNullable(orderInfo.getCarNo()).orElse(" "),formattedTime,infoOld.getWorkerName()+""+infoOld.getWorkerPhone()},orderInfo.getPhonenumber(),"1400852709","机动车管家小程序","2112806"); + } else { + SendSmsUtil.sendMsgCommon(new String[]{Optional.ofNullable(orderInfo.getCarNo()).orElse(" "), formattedTime, infoOld.getWorkerName() + "" + infoOld.getWorkerPhone()}, orderInfo.getPhonenumber(), "1400852709", "机动车管家小程序", "2112806"); } } - }catch (Exception ignored){ + } catch (Exception ignored) { log.error(ignored.getMessage()); } } @@ -1606,7 +1612,7 @@ public class AppInspectionPartnerServiceImpl extends ServiceImpl<AppInspectionPa infoOld.setMakeCert("1"); inspectionInfoService.updateById(infoOld); inspectionInfoService.updateById(infoOld); - InspectionStepInfo stepInfo =new InspectionStepInfo(); + InspectionStepInfo stepInfo = new InspectionStepInfo(); stepInfo.setContent("制证完成"); stepInfo.setTitle("制证完成"); stepInfo.setInspectionInfoId(infoOld.getId().intValue()); @@ -1614,42 +1620,42 @@ public class AppInspectionPartnerServiceImpl extends ServiceImpl<AppInspectionPa } @Override - public IPage<InspectionAppointment> getAppointmentList(Page<InspectionAppointment> page,Long partnerId,String phoneNum) { - return appointmentService.getAppointmentList(page,partnerId,phoneNum); + public IPage<InspectionAppointment> getAppointmentList(Page<InspectionAppointment> page, Long partnerId, String phoneNum) { + return appointmentService.getAppointmentList(page, partnerId, phoneNum); } @Override - public IPage<OrderInfo> validationList(Page<OrderInfo> page, Long partnerId,String searchValue) { + public IPage<OrderInfo> validationList(Page<OrderInfo> page, Long partnerId, String searchValue) { - return baseMapper.validationList(page,partnerId,searchValue); + return baseMapper.validationList(page, partnerId, searchValue); } @Override public void sendCoupon(ShopCouponTemplate template) throws Exception { LoginUser user = SecurityFrameworkUtils.getLoginUser(); ShopMallPartners partnersTmp = baseMapper.selectById(template.getPartnerId()); - if (!partnersTmp.getUserId().equals(user.getId())){ + if (!partnersTmp.getUserId().equals(user.getId())) { return; } - if (StringUtils.isEmpty(template.getRoleKey())){ + if (StringUtils.isEmpty(template.getRoleKey())) { throw new Exception("请选择角色信息"); } - if(template.getEventsStartTime().after(template.getExpirationTime())){ + if (template.getEventsStartTime().after(template.getExpirationTime())) { throw new Exception("活动开始时间需要在生效时间之前"); } - if(template.getEventsEndTime().before(template.getStartTime())){ + if (template.getEventsEndTime().before(template.getStartTime())) { throw new Exception("活动结束时间需要在开始时间之前"); } - if(template.getEventsStartTime().after(template.getEventsEndTime())){ + if (template.getEventsStartTime().after(template.getEventsEndTime())) { throw new Exception("结束时间要在开始时间之后"); } - if(template.getStartTime().after(template.getExpirationTime())){ + if (template.getStartTime().after(template.getExpirationTime())) { throw new Exception("结束时间要在开始时间之后"); } template.setBindMoudle("检测项目现金券"); template.setCouponType("cash"); template.setBindPartnerId(template.getPartnerId()); - if (ObjectUtil.isEmpty(template.getEventsEndTime())){ + if (ObjectUtil.isEmpty(template.getEventsEndTime())) { template.setStartTime(new Date()); template.setEventsEndTime(DateUtil.parse("2888-08-08")); } @@ -1657,41 +1663,42 @@ public class AppInspectionPartnerServiceImpl extends ServiceImpl<AppInspectionPa } @Override - public IPage<ShopCouponTemplate> listCoupon(Page<ShopCouponTemplate> page,Long partnerId, String searchValue) { - LambdaQueryWrapper<ShopCouponTemplate> queryWrapper =new LambdaQueryWrapper<>(); - queryWrapper.eq(ShopCouponTemplate::getPartnerId,partnerId).eq(ShopCouponTemplate::getBindMoudle,"检测项目现金券") - .eq(StringUtils.isNotEmpty(searchValue),ShopCouponTemplate::getTitle,searchValue).orderByDesc(TenantBaseDO::getCreateTime); + public IPage<ShopCouponTemplate> listCoupon(Page<ShopCouponTemplate> page, Long partnerId, String searchValue) { + LambdaQueryWrapper<ShopCouponTemplate> queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(ShopCouponTemplate::getPartnerId, partnerId).eq(ShopCouponTemplate::getBindMoudle, "检测项目现金券") + .eq(StringUtils.isNotEmpty(searchValue), ShopCouponTemplate::getTitle, searchValue).orderByDesc(TenantBaseDO::getCreateTime); - return templateService.listCoupon(page,partnerId,searchValue); + return templateService.listCoupon(page, partnerId, searchValue); } @Override - public void delCoupon(Long partnerId,Long id) { + public void delCoupon(Long partnerId, Long id) { LoginUser user = SecurityFrameworkUtils.getLoginUser(); ShopMallPartners partnersTmp = baseMapper.selectById(partnerId); - if (!partnersTmp.getUserId().equals(user.getId())){ + if (!partnersTmp.getUserId().equals(user.getId())) { return; } templateService.deleteShopCouponTemplateById(id); } + @Override - public void designatePickCarWorker(Long pickCarId,Long workerId){ + public void designatePickCarWorker(Long pickCarId, Long workerId) { InspectionPickCar pickCar = pickCarService.getById(pickCarId); pickCar.setWorkerId(workerId); pickCarService.updateById(pickCar); } @Override - public IPage<InspectionPickCar> getPickCarList(Page page,Long partnerId, String phoneNum,String pickStatus) { + public IPage<InspectionPickCar> getPickCarList(Page page, Long partnerId, String phoneNum, String pickStatus) { - return baseMapper.getPickCarList(page,partnerId,phoneNum,pickStatus); + return baseMapper.getPickCarList(page, partnerId, phoneNum, pickStatus); } @Override public InspectionPickCar getPickCarDetail(Long dataId) { InspectionPickCar pickCar = pickCarService.getById(dataId); //获取已经指派了的修理工 - if (null!=pickCar.getWorkerId()){ + if (null != pickCar.getWorkerId()) { // PartnerWorker worker = partnerWorkerService.getById(pickCar.getWorkerId()); AdminUserDO user = userService.getUser(pickCar.getWorkerId()); pickCar.setWorkerName(user.getNickname()); @@ -1702,17 +1709,17 @@ public class AppInspectionPartnerServiceImpl extends ServiceImpl<AppInspectionPa } @Override - public IPage<InspectionPickCar> getPickCarListOfWorker(Page<InspectionPickCar> page,Long workerId, String phoneNum) { - return baseMapper.getPickCarListOfWorker(page,workerId,phoneNum); + public IPage<InspectionPickCar> getPickCarListOfWorker(Page<InspectionPickCar> page, Long workerId, String phoneNum) { + return baseMapper.getPickCarListOfWorker(page, workerId, phoneNum); } @Override public JSONObject vehicleLicenseOCR(String imagePath) throws Exception { try { - imagePath = imagePath.replace("undefined",""); + imagePath = imagePath.replace("undefined", ""); String s = VehicleLicenseOCR.dealFunction(imagePath); return JSONObject.parseObject(s); - }catch (Exception e){ + } catch (Exception e) { throw new Exception("识别失败,请对准拍摄"); } @@ -1726,7 +1733,7 @@ public class AppInspectionPartnerServiceImpl extends ServiceImpl<AppInspectionPa InspectionInfo info = inspectionInfoService.getById(infoVo.getInspectionId()); OrderInfo orderInfo = orderService.getById(info.getInspectionOrderId()); orderInfo.setPayType(infoVo.getPayType()); - if (infoVo.getPayType().equals("sz")){ + if (infoVo.getPayType().equals("sz")) { //赊账 orderInfo.setOrderStatus("0"); orderInfo.setReceivablesAccount(infoVo.getReceivablesAccount()); @@ -1735,8 +1742,8 @@ public class AppInspectionPartnerServiceImpl extends ServiceImpl<AppInspectionPa orderInfo.setPayRemark(infoVo.getPayRemark()); orderService.updateById(orderInfo); //追加订单明细记录 - orderInfoDetailService.save(new OrderInfoDetail(orderInfo.getId(),"线下订单赊账",new Date(),0L,"1")); - }else{ + orderInfoDetailService.save(new OrderInfoDetail(orderInfo.getId(), "线下订单赊账", new Date(), 0L, "1")); + } else { orderInfo.setOrderStatus("2"); orderInfo.setReceivablesAccount(infoVo.getReceivablesAccount()); orderInfo.setPayMoney(infoVo.getPayMoney()); @@ -1748,7 +1755,7 @@ public class AppInspectionPartnerServiceImpl extends ServiceImpl<AppInspectionPa orderInfo.setValidationRealName(user.getNickname()); orderService.updateById(orderInfo); //追加订单明细记录 - orderInfoDetailService.save(new OrderInfoDetail(orderInfo.getId(),"线下订单支付并核销",new Date(),orderInfo.getPayMoney(),"1")); + orderInfoDetailService.save(new OrderInfoDetail(orderInfo.getId(), "线下订单支付并核销", new Date(), orderInfo.getPayMoney(), "1")); } } @@ -1763,35 +1770,35 @@ public class AppInspectionPartnerServiceImpl extends ServiceImpl<AppInspectionPa AdminUserDO workerUser = userService.getUser(inspectionInfo.getWorkId()); String inspection_work_order = configService.selectConfigByKey("inspection_work_order"); String payType = "未知"; - if (StringUtils.isNotEmpty(orderInfo.getPayType())){ + if (StringUtils.isNotEmpty(orderInfo.getPayType())) { DictDataDO payType1 = dictDataService.getDictData("pay_type", orderInfo.getPayType()); payType = payType1.getLabel(); } - inspection_work_order = inspection_work_order.replaceAll("title",Optional.ofNullable(partner.getPartnerName()).orElse("")); - inspection_work_order = inspection_work_order.replaceAll("buyAdress",Optional.ofNullable(inspectionInfo.getUserAddress()).orElse("")); - inspection_work_order= inspection_work_order.replaceAll("buyName",Optional.ofNullable(buyUser.getNickname()).orElse("未知")); - inspection_work_order= inspection_work_order.replaceAll("buyPhone",Optional.ofNullable(buyUser.getMobile()).orElse("未知")); - inspection_work_order=inspection_work_order.replaceAll("timeStr",null!=inspectionInfo.getEndTime()?DateUtil.format(inspectionInfo.getEndTime(),"yyyy-MM-dd"):"未结束"); - inspection_work_order=inspection_work_order.replaceAll("carNum",Optional.ofNullable(inspectionInfo.getCarNum()).orElse("")); - inspection_work_order=inspection_work_order.replaceAll("carIdNo",Optional.ofNullable(inspectionInfo.getCarIdNo()).orElse("")); - inspection_work_order= inspection_work_order.replaceAll("goodsTitle",orderInfo.getGoodsTitle()); - inspection_work_order=inspection_work_order.replaceAll("skuName",orderInfo.getSkuName()); - inspection_work_order=inspection_work_order.replaceAll("goodsPrice",String.valueOf(orderInfo.getGoodsPrice()/100)); - inspection_work_order=inspection_work_order.replaceAll("reduceMoney",String.valueOf(null!=orderInfo.getReduceMoney()?orderInfo.getReduceMoney()/100:0)); - inspection_work_order= inspection_work_order.replaceAll("realPayMoney",String.valueOf(null!=orderInfo.getRealPayMoney()?orderInfo.getRealPayMoney()/100:0)); - inspection_work_order=inspection_work_order.replaceAll("payType",payType); - inspection_work_order=inspection_work_order.replaceAll("workName",StringUtils.isNotEmpty(workerUser.getNickname())?workerUser.getNickname():workerUser.getMobile()); - inspection_work_order=inspection_work_order.replaceAll("payRemark",Optional.ofNullable(orderInfo.getPayRemark()).orElse("")); - inspection_work_order= inspection_work_order.replaceAll("buyName",Optional.ofNullable(buyUser.getNickname()).orElse("未知")); + inspection_work_order = inspection_work_order.replaceAll("title", Optional.ofNullable(partner.getPartnerName()).orElse("")); + inspection_work_order = inspection_work_order.replaceAll("buyAdress", Optional.ofNullable(inspectionInfo.getUserAddress()).orElse("")); + inspection_work_order = inspection_work_order.replaceAll("buyName", Optional.ofNullable(buyUser.getNickname()).orElse("未知")); + inspection_work_order = inspection_work_order.replaceAll("buyPhone", Optional.ofNullable(buyUser.getMobile()).orElse("未知")); + inspection_work_order = inspection_work_order.replaceAll("timeStr", null != inspectionInfo.getEndTime() ? DateUtil.format(inspectionInfo.getEndTime(), "yyyy-MM-dd") : "未结束"); + inspection_work_order = inspection_work_order.replaceAll("carNum", Optional.ofNullable(inspectionInfo.getCarNum()).orElse("")); + inspection_work_order = inspection_work_order.replaceAll("carIdNo", Optional.ofNullable(inspectionInfo.getCarIdNo()).orElse("")); + inspection_work_order = inspection_work_order.replaceAll("goodsTitle", orderInfo.getGoodsTitle()); + inspection_work_order = inspection_work_order.replaceAll("skuName", orderInfo.getSkuName()); + inspection_work_order = inspection_work_order.replaceAll("goodsPrice", String.valueOf(orderInfo.getGoodsPrice() / 100)); + inspection_work_order = inspection_work_order.replaceAll("reduceMoney", String.valueOf(null != orderInfo.getReduceMoney() ? orderInfo.getReduceMoney() / 100 : 0)); + inspection_work_order = inspection_work_order.replaceAll("realPayMoney", String.valueOf(null != orderInfo.getRealPayMoney() ? orderInfo.getRealPayMoney() / 100 : 0)); + inspection_work_order = inspection_work_order.replaceAll("payType", payType); + inspection_work_order = inspection_work_order.replaceAll("workName", StringUtils.isNotEmpty(workerUser.getNickname()) ? workerUser.getNickname() : workerUser.getMobile()); + inspection_work_order = inspection_work_order.replaceAll("payRemark", Optional.ofNullable(orderInfo.getPayRemark()).orElse("")); + inspection_work_order = inspection_work_order.replaceAll("buyName", Optional.ofNullable(buyUser.getNickname()).orElse("未知")); return inspection_work_order; } @Override public List<PostDO> inspectionPostInfo() { - PostPageReqVO post =new PostPageReqVO(); + PostPageReqVO post = new PostPageReqVO(); post.setCode("inspection"); - List<PostDO> postPage = postService.listPostPage(post); + List<PostDO> postPage = postService.listPostPage(post); // List<PostDO> sysPosts = postPage.getList(); // PostDO sysPost = new PostDO(); @@ -1802,8 +1809,8 @@ public class AppInspectionPartnerServiceImpl extends ServiceImpl<AppInspectionPa } @Override - public Map<String,Double> staticsTable1(Long partnerId,String startTime,String endTime) { - if (StringUtils.isEmpty(startTime)){ + public Map<String, Double> staticsTable1(Long partnerId, String startTime, String endTime) { + if (StringUtils.isEmpty(startTime)) { startTime = DateUtil.format(new Date(), "yyyy-MM-dd"); endTime = DateUtil.format(new Date(), "yyyy-MM-dd"); } @@ -1812,9 +1819,10 @@ public class AppInspectionPartnerServiceImpl extends ServiceImpl<AppInspectionPa Map<String, Double> map = baseMapper.staticsTable1(partnerId, startTime, endTime); return map; } + @Override - public Map<String,Double> newStaticsTable1(String startTime,String endTime) { - if (StringUtils.isEmpty(startTime)){ + public Map<String, Double> newStaticsTable1(String startTime, String endTime) { + if (StringUtils.isEmpty(startTime)) { startTime = DateUtil.format(new Date(), "yyyy-MM-dd"); endTime = DateUtil.format(new Date(), "yyyy-MM-dd"); } @@ -1826,7 +1834,7 @@ public class AppInspectionPartnerServiceImpl extends ServiceImpl<AppInspectionPa @Override public Map<String, Integer> staticsTable2(Long partnerId, String startTime, String endTime) { - if (StringUtils.isEmpty(startTime)){ + if (StringUtils.isEmpty(startTime)) { startTime = DateUtil.format(new Date(), "yyyy-MM-dd"); endTime = DateUtil.format(new Date(), "yyyy-MM-dd"); } @@ -1835,21 +1843,22 @@ public class AppInspectionPartnerServiceImpl extends ServiceImpl<AppInspectionPa Map<String, Integer> map = baseMapper.staticsTable2(partnerId, startTime, endTime); return map; } + @Override public Map<String, Integer> newStaticsTable2(String startTime, String endTime) { - if (StringUtils.isEmpty(startTime)){ + if (StringUtils.isEmpty(startTime)) { startTime = DateUtil.format(new Date(), "yyyy-MM-dd"); endTime = DateUtil.format(new Date(), "yyyy-MM-dd"); } startTime = startTime + " 00:00:00"; endTime = endTime + " 23:59:59"; - Map<String, Integer> map = baseMapper.newStaticsTable2( startTime, endTime); + Map<String, Integer> map = baseMapper.newStaticsTable2(startTime, endTime); return map; } @Override public List<Map<String, Object>> staticsTable3(Long partnerId, String startTime, String endTime) { - if (StringUtils.isEmpty(startTime)){ + if (StringUtils.isEmpty(startTime)) { startTime = DateUtil.format(new Date(), "yyyy-MM-dd"); endTime = DateUtil.format(new Date(), "yyyy-MM-dd"); } @@ -1858,9 +1867,10 @@ public class AppInspectionPartnerServiceImpl extends ServiceImpl<AppInspectionPa List<Map<String, Object>> res = baseMapper.staticsTable3(partnerId, startTime, endTime); return res; } + @Override public List<Map<String, Object>> newStaticsTable3(String startTime, String endTime) { - if (StringUtils.isEmpty(startTime)){ + if (StringUtils.isEmpty(startTime)) { startTime = DateUtil.format(new Date(), "yyyy-MM-dd"); endTime = DateUtil.format(new Date(), "yyyy-MM-dd"); } @@ -1872,19 +1882,19 @@ public class AppInspectionPartnerServiceImpl extends ServiceImpl<AppInspectionPa @Override public List<Map<String, Object>> staticsTable3Detail(Long partnerId, String startTime, String endTime, String remark) { - if (StringUtils.isEmpty(startTime)){ + if (StringUtils.isEmpty(startTime)) { startTime = DateUtil.format(new Date(), "yyyy-MM-dd"); endTime = DateUtil.format(new Date(), "yyyy-MM-dd"); } startTime = startTime + " 00:00:00"; endTime = endTime + " 23:59:59"; - List<Map<String, Object>> res = baseMapper.staticsTable3Detail(partnerId, startTime, endTime,remark); + List<Map<String, Object>> res = baseMapper.staticsTable3Detail(partnerId, startTime, endTime, remark); return res; } @Override public List<Map<String, Object>> staticsTable4(Long partnerId, String startTime, String endTime) { - if (StringUtils.isEmpty(startTime)){ + if (StringUtils.isEmpty(startTime)) { startTime = DateUtil.format(new Date(), "yyyy-MM-dd"); endTime = DateUtil.format(new Date(), "yyyy-MM-dd"); } @@ -1896,7 +1906,7 @@ public class AppInspectionPartnerServiceImpl extends ServiceImpl<AppInspectionPa @Override public List<Map<String, Object>> staticsTable5(Long partnerId, String startTime, String endTime) { - if (StringUtils.isEmpty(startTime)){ + if (StringUtils.isEmpty(startTime)) { startTime = DateUtil.format(new Date(), "yyyy-MM-dd"); endTime = DateUtil.format(new Date(), "yyyy-MM-dd"); } @@ -1909,24 +1919,24 @@ public class AppInspectionPartnerServiceImpl extends ServiceImpl<AppInspectionPa /** * 根据inspection_info的id查有的项目名称 * + * @param ids inspection_info的id * @author 小李 * @date 14:52 2024/12/10 - * @param ids inspection_info的id **/ @Override - public Map<Long, String> getProjectByIds(Long[] ids){ + public Map<Long, String> getProjectByIds(Long[] ids) { List<InspectionWorkNode> inspectionWorkNodes = inspectionWorkNodeService. list(new LambdaQueryWrapper<InspectionWorkNode>() .in(InspectionWorkNode::getInspectionInfoId, Arrays.asList(ids))); - if (ObjectUtil.isEmpty(inspectionWorkNodes)){ + if (ObjectUtil.isEmpty(inspectionWorkNodes)) { return null; } List<String> projectIds = inspectionWorkNodes.stream().map(InspectionWorkNode::getProjectId).collect(Collectors.toList()); - if (CollUtil.isEmpty(projectIds)){ + if (CollUtil.isEmpty(projectIds)) { return null; } List<DlInspectionProject> projects = projectService.listByIds(projectIds); - if (CollUtil.isEmpty(projects)){ + if (CollUtil.isEmpty(projects)) { return null; } Map<String, String> projectMap = projects.stream().collect(Collectors.toMap(DlInspectionProject::getId, DlInspectionProject::getProjectName)); @@ -1945,14 +1955,14 @@ public class AppInspectionPartnerServiceImpl extends ServiceImpl<AppInspectionPa /** * 根据时间查订单 * + * @param startTime 开始时间 非必传 + * @param endTime 结束时间 非必传 * @author 小李 * @date 14:39 2024/12/12 - * @param startTime 开始时间 非必传 - * @param endTime 结束时间 非必传 **/ @Override - public IPage<OrderTable> getOrderByDate(String startTime, String endTime, String chooseStatus, Page<OrderTable> page){ - if (StringUtils.isEmpty(startTime)){ + public IPage<OrderTable> getOrderByDate(String startTime, String endTime, String chooseStatus, Page<OrderTable> page) { + if (StringUtils.isEmpty(startTime)) { startTime = DateUtil.format(new Date(), "yyyy-MM-dd"); endTime = DateUtil.format(new Date(), "yyyy-MM-dd"); } @@ -1964,15 +1974,15 @@ public class AppInspectionPartnerServiceImpl extends ServiceImpl<AppInspectionPa /** * 分类计数 * + * @param startTime 开始时间 + * @param endTime 结束时间 + * @param chooseStatus 状态 * @author 小李 * @date 17:14 2024/12/16 - * @param startTime 开始时间 - * @param endTime 结束时间 - * @param chooseStatus 状态 **/ @Override - public Map<String, Long> getTypeCount(String startTime, String endTime, String chooseStatus){ - if (StringUtils.isEmpty(startTime)){ + public Map<String, Long> getTypeCount(String startTime, String endTime, String chooseStatus) { + if (StringUtils.isEmpty(startTime)) { startTime = DateUtil.format(new Date(), "yyyy-MM-dd"); endTime = DateUtil.format(new Date(), "yyyy-MM-dd"); } @@ -1981,4 +1991,27 @@ public class AppInspectionPartnerServiceImpl extends ServiceImpl<AppInspectionPa List<Map<String, Long>> typeCount = baseMapper.getTypeCount(startTime, endTime, chooseStatus); return typeCount.stream().collect(Collectors.toMap(map -> String.valueOf(map.get("type")), map -> map.get("count"))); } + + /** + * 查询检测类型统计 + * + * @param startTime 开始时间 + * @param endTime 结束时间 + * @return 结果 + */ + @Override + public List<Map<String, Object>> queryInspectionSkuList(String startTime, String endTime) { + return baseMapper.queryInspectionSkuList(startTime, endTime); + } + + /** + * 查询员工统计 + * + * @param dlInspectionProject 项目信息 + * @return 结果 + */ + @Override + public List<Map<String, Object>> getStaffCount(DlInspectionProject dlInspectionProject) { + return inspectionWorkNodeService.getStaffCount(dlInspectionProject); + } } diff --git a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/impl/DlInspectionProjectServiceImpl.java b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/impl/DlInspectionProjectServiceImpl.java index 7b66327a..02f2733c 100644 --- a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/impl/DlInspectionProjectServiceImpl.java +++ b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/impl/DlInspectionProjectServiceImpl.java @@ -12,6 +12,7 @@ import cn.iocoder.yudao.module.inspection.service.ProjectRoyaltyService; import cn.iocoder.yudao.module.inspection.vo.DlInspectionProjectPageReqVO; import cn.iocoder.yudao.module.inspection.vo.DlInspectionProjectRespVO; import cn.iocoder.yudao.module.inspection.vo.DlInspectionProjectSaveReqVO; +import cn.iocoder.yudao.module.inspection.vo.InspectionOrderExportVo; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; @@ -116,4 +117,15 @@ public class DlInspectionProjectServiceImpl extends ServiceImpl<DlInspectionProj return baseMapper.selectListPage(page, pageReqVO); } + /** + * 查询项目对应的检测员名称 + * + * @param orderIds 订单id集合 + * @return + */ + @Override + public List<InspectionOrderExportVo> queryProjectWorkerName(List<Long> orderIds) { + return baseMapper.queryProjectWorkerName(orderIds); + } + } \ No newline at end of file diff --git a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/impl/InspectionEquInfoServiceImpl.java b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/impl/InspectionEquInfoServiceImpl.java index ff4dc9da..08d19b99 100644 --- a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/impl/InspectionEquInfoServiceImpl.java +++ b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/impl/InspectionEquInfoServiceImpl.java @@ -3,13 +3,21 @@ package cn.iocoder.yudao.module.inspection.service.impl; import java.util.*; import java.util.stream.Collectors; +import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.lang.Validator; import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; import cn.iocoder.yudao.module.constant.InspectionConstants; import cn.iocoder.yudao.module.infra.dal.dataobject.file.FileDO; import cn.iocoder.yudao.module.inspection.entity.InspectionFile; import cn.iocoder.yudao.module.inspection.entity.InspectionStaff; import cn.iocoder.yudao.module.inspection.service.IInspectionFileService; +import cn.iocoder.yudao.module.inspection.vo.ImportEquipmentVo; +import cn.iocoder.yudao.module.inspection.vo.InspectionEqInfoImportVo; +import cn.iocoder.yudao.module.inspection.vo.StaffImportExcelVO; +import cn.iocoder.yudao.module.system.api.dict.DictDataApi; +import cn.iocoder.yudao.module.system.api.dict.dto.DictDataRespDTO; import com.baomidou.dynamic.datasource.annotation.DSTransactional; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; @@ -41,6 +49,9 @@ public class InspectionEquInfoServiceImpl extends ServiceImpl<InspectionEquInfoM @Autowired private IInspectionFileService inspectionFileService; + @Autowired + private DictDataApi dictDataApi; + /** * 查询equInfo * @@ -183,6 +194,123 @@ public class InspectionEquInfoServiceImpl extends ServiceImpl<InspectionEquInfoM return baseMapper.deleteById(id); } + /** + * 导入设备信息 + * + * @param list 设备信息集合 + * @return 结果 + */ + @Override + public Map<String, Object> importStaff(List<InspectionEqInfoImportVo> list) { + if (CollUtil.isEmpty(list)) { + throw new RuntimeException("导入数据为空"); + } + Map<String, Object> resultMap = new HashMap<>(); + + // 校验导入信息 + ImportEquipmentVo importEquipmentVo = validImportEquipment(list); + // 保存信息 + int saveNum = saveImportStaff(importEquipmentVo.getSuccessList()); + resultMap.put("successList", importEquipmentVo.getSuccessList()); + resultMap.put("failList", importEquipmentVo.getFailList()); + return resultMap; + } + + /** + * 保存导入的设备信息 + * + * @param successList 设备信息集合 + * @return 结果 + */ + private int saveImportStaff(List<InspectionEqInfoImportVo> successList) { + // 批量保存设备信息 + List<InspectionEquInfo> inspectionEquInfos = BeanUtil.copyToList(successList, InspectionEquInfo.class); + this.saveBatch(inspectionEquInfos); + + List<WarnMessage> warnMessages = new ArrayList<>(); + for (InspectionEquInfo inspectionEqInfoImportVo : inspectionEquInfos) { + if (ObjectUtil.isNotEmpty(inspectionEqInfoImportVo.getNextCheckTime())) { + //同时处理提醒信息 + WarnMessage warnMessage = new WarnMessage(); + warnMessage.setTitle("设备检测即将到期"); + warnMessage.setContent("名为:" + inspectionEqInfoImportVo.getEquName() + "的设备即将到设定的检测时间,请及时处理相关事项!"); + warnMessage.setIsRead("0"); + warnMessage.setPartnerId(inspectionEqInfoImportVo.getPartnerId()); + warnMessage.setType("equ"); + warnMessage.setObjectId(inspectionEqInfoImportVo.getId()); + // 创建Calendar对象 + Calendar calendar = Calendar.getInstance(); + calendar.setTime(inspectionEqInfoImportVo.getNextCheckTime()); + calendar.add(Calendar.MONTH, -1); + Date newDate = calendar.getTime(); + warnMessage.setWarnTime(newDate); + + warnMessages.add(warnMessage); + } + //批量保存提醒信息 + if (CollUtil.isNotEmpty(warnMessages)) { + messageService.saveBatch(warnMessages); + } + } + return 0; + } + + /** + * 验证导入的设备信息 + * + * @param list 设备信息集合 + * @return 结果 + */ + private ImportEquipmentVo validImportEquipment(List<InspectionEqInfoImportVo> list) { + List<InspectionEqInfoImportVo> successList = new ArrayList<>(); + List<InspectionEqInfoImportVo> failList = new ArrayList<>(); + + //查询设备类别 + // 查询设备类型 + List<DictDataRespDTO> eqType = dictDataApi.getDictDataList("ins_equ_type"); + Map<String, String> typeMap = eqType.stream().collect(Collectors.toMap(DictDataRespDTO::getLabel, DictDataRespDTO::getValue)); + + //去除示例数据 + if ("示例设备".equals(list.get(0).getEquName())) { + list.remove(0); + } + + for (InspectionEqInfoImportVo inspectionEqInfoImportVo : list) { + //判断设备名称是否为空 + if (ObjectUtil.isEmpty(inspectionEqInfoImportVo.getEquName())) { + inspectionEqInfoImportVo.setReason("设备名称不能为空"); + failList.add(inspectionEqInfoImportVo); + continue; + } + // 判断设备类别是否为空 + if (ObjectUtil.isEmpty(inspectionEqInfoImportVo.getType())) { + inspectionEqInfoImportVo.setReason(inspectionEqInfoImportVo.getEquName() + "设备类别不能为空"); + failList.add(inspectionEqInfoImportVo); + continue; + } + if (ObjectUtil.isEmpty(typeMap.get(inspectionEqInfoImportVo.getType()))) { + inspectionEqInfoImportVo.setReason(inspectionEqInfoImportVo.getEquName() + "请在下拉框中选择设备类型"); + failList.add(inspectionEqInfoImportVo); + continue; + }else { + inspectionEqInfoImportVo.setType(typeMap.get(inspectionEqInfoImportVo.getType())); + } + // 如果邮箱不为空判断是否正确 + if (ObjectUtil.isNotEmpty(inspectionEqInfoImportVo.getEmail())) { + if (!Validator.isEmail(inspectionEqInfoImportVo.getEmail())) { + inspectionEqInfoImportVo.setReason(inspectionEqInfoImportVo.getEquName() + "的邮箱格式不正确"); + failList.add(inspectionEqInfoImportVo); + continue; + } + } + successList.add(inspectionEqInfoImportVo); + } + ImportEquipmentVo importEquipmentVo = new ImportEquipmentVo(); + importEquipmentVo.setSuccessList(successList); + importEquipmentVo.setFailList(failList); + return importEquipmentVo; + } + /** * 添加设备附件 * diff --git a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/impl/InspectionStaffServiceImpl.java b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/impl/InspectionStaffServiceImpl.java index 3bfbd6f1..235386dd 100644 --- a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/impl/InspectionStaffServiceImpl.java +++ b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/impl/InspectionStaffServiceImpl.java @@ -194,7 +194,7 @@ public class InspectionStaffServiceImpl extends ServiceImpl<InspectionStaffMappe */ @Override public Map<String, Object> importStaff(List<StaffImportExcelVO> list) { - if (ObjectUtil.isEmpty(list)) { + if (CollUtil.isEmpty(list)) { throw new RuntimeException("导入数据为空"); } Map<String, Object> resultMap = new HashMap<>(); diff --git a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/impl/InspectionWorkNodeServiceImpl.java b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/impl/InspectionWorkNodeServiceImpl.java index 1322311c..dad4ade2 100644 --- a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/impl/InspectionWorkNodeServiceImpl.java +++ b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/service/impl/InspectionWorkNodeServiceImpl.java @@ -405,6 +405,17 @@ public class InspectionWorkNodeServiceImpl extends ServiceImpl<InspectionWorkNod } } + /** + * 获取员工统计排序 + * + * @param dlInspectionProject + * @return + */ + @Override + public List<Map<String, Object>> getStaffCount(DlInspectionProject dlInspectionProject) { + return baseMapper.getStaffCount(dlInspectionProject); + } + /** * 判断传入的 InspectionWorkNode 对象是否在集合中有后续项目 * diff --git a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/vo/ImportEquipmentVo.java b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/vo/ImportEquipmentVo.java new file mode 100644 index 00000000..53d6d0bb --- /dev/null +++ b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/vo/ImportEquipmentVo.java @@ -0,0 +1,24 @@ +package cn.iocoder.yudao.module.inspection.vo; + +import lombok.Data; + +import java.util.List; + +/** + * @Description: 导入设备返回对象 + * @Author: 86187 + * @Date: 2025/02/13 11:46 + * @Version: 1.0 + */ +@Data +public class ImportEquipmentVo { + /** + * 导入成功的集合 + */ + private List<InspectionEqInfoImportVo> successList; + + /** + * 导入失败的集合 + */ + private List<InspectionEqInfoImportVo> failList; +} diff --git a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/vo/ImportStaffVo.java b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/vo/ImportStaffVo.java index 83721011..35759505 100644 --- a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/vo/ImportStaffVo.java +++ b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/vo/ImportStaffVo.java @@ -1,16 +1,22 @@ package cn.iocoder.yudao.module.inspection.vo; +import lombok.AllArgsConstructor; +import lombok.Builder; import lombok.Data; +import lombok.NoArgsConstructor; import java.util.List; /** - * @Description: 导入实习生返回对象 + * @Description: 导入检测员工返回对象 * @Author: 86187 * @Date: 2025/02/13 11:46 * @Version: 1.0 */ @Data +@Builder +@AllArgsConstructor +@NoArgsConstructor public class ImportStaffVo { /** * 导入成功的集合 diff --git a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/vo/InspectionEqInfoImportVo.java b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/vo/InspectionEqInfoImportVo.java new file mode 100644 index 00000000..a5aa7f48 --- /dev/null +++ b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/vo/InspectionEqInfoImportVo.java @@ -0,0 +1,119 @@ +package cn.iocoder.yudao.module.inspection.vo; + +import cn.iocoder.yudao.module.infra.dal.dataobject.file.FileDO; +import com.alibaba.excel.annotation.ExcelIgnore; +import com.alibaba.excel.annotation.ExcelProperty; +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; +import lombok.experimental.Accessors; + +import java.util.Date; +import java.util.List; +import java.util.Map; + +/** + * @Description: 设备导入类 + * @Author: 86187 + * @Date: 2025/02/14 9:13 + * @Version: 1.0 + */ +@Data +@Accessors(chain = false) // 禁用链式调用 +public class InspectionEqInfoImportVo { + /** + * 设备名称 + */ + @ExcelProperty(value = "设备名称", index = 0) + private String equName; + + /** + * 设备类别(字典:ins_equ_type) + */ + @ExcelProperty(value = "设备类型", index = 1) + private String type; + + /** + * 设备型号 + */ + @ExcelProperty(value = "型号", index = 2) + private String equModel; + + /** + * 设备编号 + */ + @ExcelProperty(value = "出厂编号", index = 3) + private String equNumber; + + /** + * 有效期 + */ + @JsonFormat(pattern = "yyyy-MM-dd") + @ExcelProperty(value = "校准日期", index = 4) + private Date validTime; + + /** + * 下次检定时间 + */ + @JsonFormat(pattern = "yyyy-MM-dd") + @ExcelProperty(value = "复校日期", index = 5) + private Date nextCheckTime; + + /** + * 检测证书编号 + */ + @ExcelProperty(value = "证书编号", index = 6) + private String certificateNumber; + + /** + * 制造商 + */ + @ExcelProperty(value = "制造商", index = 7) + private String manufacturer; + + /** + * 上次检定单位 + */ + @ExcelProperty(value = "校准单位", index = 8) + private String lastUnit; + + /** + * 电话 + */ + @ExcelProperty(value = "电话", index = 9) + private String mobile; + + /** + * 地址 + */ + @ExcelProperty(value = "地址", index = 10) + private String address; + + /** + * 邮编 + */ + @ExcelProperty(value = "邮编", index = 11) + private String postcode; + + /** + * 邮箱 + */ + @ExcelProperty(value = "电子邮箱", index = 12) + private String email; + + /** + * 设备检定周期 + */ +// @ExcelProperty(value = "设备检定周期", index = 13) + @ExcelIgnore + private String equZq; + + @ExcelIgnore + private Long id; + + @ExcelIgnore + private String reason; + +} diff --git a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/vo/InspectionOrderExportVo.java b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/vo/InspectionOrderExportVo.java new file mode 100644 index 00000000..6da4e7f5 --- /dev/null +++ b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/inspection/vo/InspectionOrderExportVo.java @@ -0,0 +1,27 @@ +package cn.iocoder.yudao.module.inspection.vo; + +import lombok.Data; + +/** + * @Description: 查询数据库 + * @Author: 86187 + * @Date: 2025/02/15 17:11 + * @Version: 1.0 + */ +@Data +public class InspectionOrderExportVo { + /** + * 项目名称 + */ + private String projectName; + + /** + * 订单编号 + */ + private Long orderId; + + /** + * 工作人员名称 + */ + private String workName; +} diff --git a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/payment/entity/OrderInfo.java b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/payment/entity/OrderInfo.java index 4392c762..ccba8620 100644 --- a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/payment/entity/OrderInfo.java +++ b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/payment/entity/OrderInfo.java @@ -1,6 +1,8 @@ package cn.iocoder.yudao.module.payment.entity; import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO; +import com.alibaba.excel.annotation.ExcelIgnore; +import com.alibaba.excel.annotation.ExcelProperty; import com.baomidou.mybatisplus.annotation.TableField; import com.fasterxml.jackson.annotation.JsonFormat; import lombok.Data; @@ -17,13 +19,17 @@ import java.util.Date; @Data public class OrderInfo extends TenantBaseDO { //订单id + @ExcelIgnore private Long id; + @ExcelIgnore private String transactionId; //订单号 + @ExcelProperty(index = 0, value = "订单号") private String orderNo; //商品id private Long goodsId; //商品名称 + @ExcelProperty(index = 11, value = "商品名称") private String goodsTitle; private String goodsType; private Long skuId; @@ -31,8 +37,10 @@ public class OrderInfo extends TenantBaseDO { //用户id private Long userId; //用户姓名 + @ExcelProperty(index = 1, value = "客户姓名") private String realName; //用户手机号 + @ExcelProperty(index = 2, value = "联系方式") private String phonenumber; //商品原价 分 private Long goodsPrice; @@ -124,14 +132,44 @@ public class OrderInfo extends TenantBaseDO { private String isPickCar; private String remark; //车牌号 + @ExcelProperty(index = 3, value = "车牌号") private String carNo; //车辆品牌型号 + @ExcelProperty(index = 4, value = "品牌类型") private String carModel; //车辆性质 非营运 营运等 + @ExcelProperty(index = 8, value = "使用性质") private String carNature; //车架号 + @ExcelProperty(index = 5, value = "车架号") private String carIdNo; + @ExcelProperty(index = 6, value = "住址") + @TableField(exist = false) + private String userAddress; + + @ExcelProperty(index = 7, value = "单位") + @TableField(exist = false) + private String unitName; + + @ExcelProperty(index = 9, value = "来源") + @TableField(exist = false) + private String customerName; + + @ExcelProperty(index = 10, value = "代办人电话") + @TableField(exist = false) + private String phone; + + @ExcelProperty(index = 12, value = "新旧车") + @TableField(exist = false) + private String carStatus; + + @TableField(exist = false) + private Long payMoneyStr; + + @TableField(exist = false) + private Double inspectionTime; + } diff --git a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/payment/service/OrderInfoService.java b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/payment/service/OrderInfoService.java index a1eb3ad7..302ddeb6 100644 --- a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/payment/service/OrderInfoService.java +++ b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/payment/service/OrderInfoService.java @@ -12,6 +12,8 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.IService; import org.springframework.data.repository.query.Param; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; import java.util.List; import java.util.Map; @@ -81,5 +83,13 @@ public interface OrderInfoService extends IService<OrderInfo> { IPage<OrderInfo> orderListPc(Page<OrderInfo> page,OrderInfo orderInfo); OrderInfo getOrderByOrderNo(String orderNo); + + /** + * 导出订单 + * @param response 响应 + * @param shopInspectionOrder 订单 + * @param page 分页 + */ + void exportExcel(HttpServletResponse response, OrderInfo shopInspectionOrder, Page<OrderInfo> page) throws IOException; } diff --git a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/payment/service/impl/OrderInfoServiceImpl.java b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/payment/service/impl/OrderInfoServiceImpl.java index 06fcf979..2b23004d 100644 --- a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/payment/service/impl/OrderInfoServiceImpl.java +++ b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/payment/service/impl/OrderInfoServiceImpl.java @@ -1,10 +1,13 @@ package cn.iocoder.yudao.module.payment.service.impl; +import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.util.ObjectUtil; +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; import cn.iocoder.yudao.framework.security.core.LoginUser; import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils; import cn.iocoder.yudao.module.inspection.entity.*; import cn.iocoder.yudao.module.inspection.service.*; +import cn.iocoder.yudao.module.inspection.vo.InspectionOrderExportVo; import cn.iocoder.yudao.module.partner.entity.PartnerWorker; import cn.iocoder.yudao.module.partner.service.IPartnerWorkerService; import cn.iocoder.yudao.module.payment.entity.OrderInfo; @@ -13,6 +16,7 @@ import cn.iocoder.yudao.module.payment.entity.commentVo; import cn.iocoder.yudao.module.payment.mapper.OrderInfoMapper; import cn.iocoder.yudao.module.payment.service.IOrderInfoDetailService; import cn.iocoder.yudao.module.payment.service.OrderInfoService; +import cn.iocoder.yudao.module.payment.vo.OrderInfoExportVo; import cn.iocoder.yudao.module.shop.entity.*; import cn.iocoder.yudao.module.shop.service.*; import cn.iocoder.yudao.module.system.dal.dataobject.permission.RoleDO; @@ -21,10 +25,12 @@ import cn.iocoder.yudao.module.system.service.permission.PermissionService; import cn.iocoder.yudao.module.system.service.permission.RoleService; import cn.iocoder.yudao.module.system.service.user.AdminUserService; import cn.iocoder.yudao.util.StringUtils; +import com.alibaba.excel.EasyExcel; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import org.apache.commons.lang3.ObjectUtils; @@ -32,8 +38,11 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import javax.servlet.http.HttpServletResponse; +import java.io.IOException; import java.math.BigDecimal; import java.util.*; +import java.util.concurrent.TimeUnit; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; import java.util.stream.Collectors; @@ -78,6 +87,8 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo private IShopRepairGoodsService repairGoodsService; @Autowired private IShopMallPartnersService shopMallPartnersService; + @Autowired + private DlInspectionProjectService dlInspectionProjectService; @Override public void reviewOrder(String orderId, Integer starLevel, String reviewStr) throws Exception { @@ -845,5 +856,103 @@ public class OrderInfoServiceImpl extends ServiceImpl<OrderInfoMapper, OrderInfo return this.getOne(queryWrapper); } + /** + * 导出订单 + * + * @param response 响应 + * @param shopInspectionOrder 订单 + * @param page 分页 + */ + @Override + public void exportExcel(HttpServletResponse response, OrderInfo shopInspectionOrder, Page<OrderInfo> page) throws IOException { + // 查询订单数据 + List<OrderInfo> orderInfoIPage = queryListPage(shopInspectionOrder, page).getRecords(); + List<OrderInfoExportVo> objects = BeanUtil.copyToList(orderInfoIPage, OrderInfoExportVo.class); + + // 计算检测时长 + objects.forEach(item -> { + if (ObjectUtil.isNotEmpty(item.getStartTime()) && ObjectUtil.isNotEmpty(item.getEndTime())) { + long diff = item.getEndTime().getTime() - item.getStartTime().getTime(); + long hours = TimeUnit.MILLISECONDS.toHours(diff); + long minutes = TimeUnit.MILLISECONDS.toMinutes(diff) % 60; + String inspectionTime = String.format("%d小时%d分", hours, minutes); + item.setInspectionTime(inspectionTime); + } + }); + + // 查询所有检测项目 + List<DlInspectionProject> projectList = dlInspectionProjectService.list(Wrappers.<DlInspectionProject>lambdaQuery() + .orderBy(true, true,DlInspectionProject::getSort)); + + // 动态构建表头 + List<List<String>> head = new ArrayList<>(); + // 固定列 + head.add(Collections.singletonList("订单号")); + head.add(Collections.singletonList("客户姓名")); + head.add(Collections.singletonList("联系方式")); + head.add(Collections.singletonList("车牌号")); + head.add(Collections.singletonList("品牌类型")); + head.add(Collections.singletonList("车架号")); + head.add(Collections.singletonList("住址")); + head.add(Collections.singletonList("单位")); + head.add(Collections.singletonList("使用性质")); + head.add(Collections.singletonList("来源")); + head.add(Collections.singletonList("代办人电话")); + head.add(Collections.singletonList("商品名称")); + head.add(Collections.singletonList("新旧车")); + head.add(Collections.singletonList("开始时间")); + head.add(Collections.singletonList("结束时间")); + head.add(Collections.singletonList("检测时长")); + head.add(Collections.singletonList("支付方式")); + head.add(Collections.singletonList("金额")); + // 动态列(检测项目) + for (DlInspectionProject project : projectList) { + head.add(Collections.singletonList(project.getProjectName())); + } + + List<Long> orderIds = orderInfoIPage.stream().map(OrderInfo::getId).collect(Collectors.toList()); + + List<InspectionOrderExportVo> projectWorkerNames = dlInspectionProjectService.queryProjectWorkerName(orderIds); + + // 动态构建数据 + List<List<Object>> data = new ArrayList<>(); + for (OrderInfoExportVo item : objects) { + List<Object> row = new ArrayList<>(); + // 固定列数据 + row.add(item.getOrderNo()); + row.add(item.getRealName()); + row.add(item.getPhonenumber()); + row.add(item.getCarNo()); + row.add(item.getCarModel()); + row.add(item.getCarIdNo()); + row.add(item.getUserAddress()); + row.add(item.getUnitName()); + row.add(item.getCarNature()); + row.add(item.getCustomerName()); + row.add(item.getWorkerPhone()); + row.add(item.getGoodsTitle()); + row.add(item.getCarStatus()); + row.add(item.getStartTime()); + row.add(item.getEndTime()); + row.add(item.getInspectionTime()); + row.add(item.getPayType()); + row.add(item.getPayMoneyStr()); + // 动态列数据 + for (InspectionOrderExportVo project : projectWorkerNames) { + row.add(item.getDynamicColumns().get(project.getWorkName())); + } + data.add(row); + + } + + + + // 导出 Excel + EasyExcel.write(response.getOutputStream()) + .head(head) // 设置动态表头 + .sheet("检测商品信息") + .doWrite(data); // 写入数据 + } + } diff --git a/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/payment/vo/OrderInfoExportVo.java b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/payment/vo/OrderInfoExportVo.java new file mode 100644 index 00000000..65a60695 --- /dev/null +++ b/dl-module-inspection/src/main/java/cn/iocoder/yudao/module/payment/vo/OrderInfoExportVo.java @@ -0,0 +1,41 @@ +package cn.iocoder.yudao.module.payment.vo; + +import com.alibaba.excel.annotation.ExcelProperty; +import com.alibaba.excel.annotation.write.style.ColumnWidth; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.Data; + +import java.util.Date; +import java.util.HashMap; +import java.util.Map; + +/** + * @Description: 导出订单 + * @Author: 86187 + * @Date: 2025/02/15 10:49 + * @Version: 1.0 + */ +@Data +public class OrderInfoExportVo { + private String orderNo; + private String realName; + private String phonenumber; + private String carNo; + private String carModel; + private String carIdNo; + private String userAddress; + private String unitName; + private String carNature; + private String customerName; + private String workerPhone; + private String goodsTitle; + private String carStatus; + private Date startTime; + private Date endTime; + private String inspectionTime; + private String payType; + private Long payMoneyStr; + + // 动态列数据 + private Map<String, Object> dynamicColumns = new HashMap<>(); +} diff --git a/dl-module-inspection/src/main/resources/mapper/InspectionWorkNodeMapper.xml b/dl-module-inspection/src/main/resources/mapper/InspectionWorkNodeMapper.xml index b11b9c69..1d6adf68 100644 --- a/dl-module-inspection/src/main/resources/mapper/InspectionWorkNodeMapper.xml +++ b/dl-module-inspection/src/main/resources/mapper/InspectionWorkNodeMapper.xml @@ -95,7 +95,7 @@ inspection_project_royalty AS royalty ON node.project_id = royalty.project_id and orders.goods_id = royalty.goods_id <where> - node.status = '2' AND info.status = '1' + node.status = '2' AND info.status = '1' and node.deleted = 0 <if test="inspectionWorkNode.createTime != null"> AND node.create_time = #{inspectionWorkNode.createTime} </if> @@ -115,7 +115,32 @@ AND node.create_time BETWEEN #{inspectionWorkNode.rescueStart} AND #{inspectionWorkNode.rescueEnd} </if> </where> + group by node.deal_user_id ORDER BY node.create_time DESC; </select> + <select id="getStaffCount" resultType="java.util.Map" + parameterType="cn.iocoder.yudao.module.inspection.entity.DlInspectionProject"> + SELECT iwn.deal_user_id, -- 处理人员ID + su.nickname, -- 处理人员名称 + COUNT(iwn.deal_user_id) AS orderCount, -- 统计每个员工接单的数量 + SUM(IFNULL(royalty.royalty_amount, 0) / 100) AS royaltyAmount -- 计算每个员工的总佣金 + FROM inspection_work_node iwn + LEFT JOIN inspection_project AS proj -- Assuming this is the table for project details + ON iwn.project_id = proj.id + LEFT JOIN system_users su ON su.id = iwn.deal_user_id + LEFT JOIN inspection_info AS info ON iwn.inspection_info_id = info.id + LEFT JOIN order_info orders ON info.inspection_order_id = orders.id + LEFT JOIN inspection_project_royalty AS royalty ON iwn.project_id = royalty.project_id + AND orders.goods_id = royalty.goods_id + + WHERE iwn.deleted = 0 -- 排除已删除的数据 + AND iwn.deal_user_id IS NOT NULL -- 排除 deal_user_id 为 NULL 的记录 + AND iwn.`status` = 2 + AND info.`status` = 1 + + GROUP BY iwn.deal_user_id -- 根据处理人员ID和名称进行分组 + + ORDER BY orderCount DESC; -- 根据接单数量进行降序排序 + </select> </mapper> diff --git a/dl-module-inspection/src/main/resources/mapper/inspection/AppInspectionPartnerMapper.xml b/dl-module-inspection/src/main/resources/mapper/inspection/AppInspectionPartnerMapper.xml index 2e7c05ae..44bebaa9 100644 --- a/dl-module-inspection/src/main/resources/mapper/inspection/AppInspectionPartnerMapper.xml +++ b/dl-module-inspection/src/main/resources/mapper/inspection/AppInspectionPartnerMapper.xml @@ -217,7 +217,7 @@ where sig.partner_id =#{partnerId} info.customer_source as customerSource, info.other_phone as otherPhone,oi.sku_id as skuId, oi.sku_name as skuName,oi.goods_price as goodsPrice from inspection_info info - LEFT JOIN inspection_step_info step ON info.id = st ep.inspection_info_id + LEFT JOIN inspection_step_info step ON info.id = step.inspection_info_id INNER JOIN system_users su on su.id = info.user_id INNER JOIN order_info oi on oi.id = info.inspection_order_id WHERE info.status = #{status} and info.partner_id = #{partnerId} @@ -649,4 +649,19 @@ FROM ) t2 GROUP BY t2.type </select> + <select id="queryInspectionSkuList" resultType="java.util.Map"> + SELECT + sku_name AS skuName, + COUNT(*) AS orderCount + FROM + order_info + <where> + sku_name IN ('年审', '上户', '双燃料', '非定检', '其他检测') + <if test="startTime != null"> + AND create_time BETWEEN #{startTime} AND #{endTime} + </if> + </where> + GROUP BY + sku_name; + </select> </mapper> diff --git a/dl-module-inspection/src/main/resources/mapper/inspection/DlInspectionProjectMapper.xml b/dl-module-inspection/src/main/resources/mapper/inspection/DlInspectionProjectMapper.xml index 140971a6..370d72a5 100644 --- a/dl-module-inspection/src/main/resources/mapper/inspection/DlInspectionProjectMapper.xml +++ b/dl-module-inspection/src/main/resources/mapper/inspection/DlInspectionProjectMapper.xml @@ -25,4 +25,31 @@ </where> ORDER BY sort </select> + <select id="queryProjectWorkerName" resultType="cn.iocoder.yudao.module.inspection.vo.InspectionOrderExportVo"> + SELECT + iw.inspection_info_id orderId, + iw.id AS nodeId, + ip.project_name, + iw.deal_user_name AS workName, + iw.deal_user_id + FROM + inspection_work_node iw + JOIN + inspection_project ip ON iw.project_id = ip.id + WHERE + iw.inspection_info_id IN ( + SELECT + ii.id + FROM + inspection_info ii + WHERE + ii.inspection_order_id IN ( + <foreach collection="orderIds" item="orderId" separator=","> + #{orderId} + </foreach> + ) + ) + ORDER BY + iw.inspection_info_id, iw.order_num; + </select> </mapper> \ No newline at end of file diff --git a/dl-module-inspection/src/main/resources/mapper/payment/OrderInfoMapper.xml b/dl-module-inspection/src/main/resources/mapper/payment/OrderInfoMapper.xml index 479e6447..4ecb7be7 100644 --- a/dl-module-inspection/src/main/resources/mapper/payment/OrderInfoMapper.xml +++ b/dl-module-inspection/src/main/resources/mapper/payment/OrderInfoMapper.xml @@ -54,6 +54,7 @@ oi.comment_desc, oi.comment_star, suc.car_no + -- oi.pay_money FROM `order_info` oi LEFT JOIN system_users su ON su.id = oi.user_id @@ -253,17 +254,32 @@ oi.order_status, oi.comment_desc, oi.comment_star, - suc.car_no +-- suc.car_no, + info.car_num as carNo, + info.car_model, + info.car_id_no, + info.user_address, + info.unit_name, + info.car_nature, + info.customer_source as customerName, + info.worker_phone, + info.car_status, + oi.pay_money / 100 as payMoneyStr, + info.start_time, + info.end_time, + -- end_time 减去 start_time + DATE_FORMAT(info.end_time, '%Y-%m-%d %H:%i:%s') - DATE_FORMAT(info.start_time, '%Y-%m-%d %H:%i:%s') as inspectionTime FROM `order_info` oi LEFT JOIN system_users su ON su.id = oi.user_id left join shop_user_car suc on suc.car_id = oi.user_car_id + LEFT JOIN inspection_info info on info.inspection_order_id = oi.id where 1=1 <if test="entity.orderStatus!=null and entity.orderStatus!='' "> and oi.order_status = #{entity.orderStatus} </if> <if test="entity.validationTime!=null"> - and oi.validation_time is not null + -- and oi.validation_time is not null </if> <if test="entity.realName!=null and entity.realName!='' "> and oi.real_name like concat('%',#{entity.realName},'%') diff --git a/yudao-framework/yudao-spring-boot-starter-excel/src/main/java/cn/iocoder/yudao/framework/excel/core/util/ExcelUtils.java b/yudao-framework/yudao-spring-boot-starter-excel/src/main/java/cn/iocoder/yudao/framework/excel/core/util/ExcelUtils.java index 80e7b426..964506bc 100644 --- a/yudao-framework/yudao-spring-boot-starter-excel/src/main/java/cn/iocoder/yudao/framework/excel/core/util/ExcelUtils.java +++ b/yudao-framework/yudao-spring-boot-starter-excel/src/main/java/cn/iocoder/yudao/framework/excel/core/util/ExcelUtils.java @@ -89,108 +89,90 @@ public class ExcelUtils { } /** - * 导出空白模板Excel,并为指定列添加下拉框和日期时间格式验证 + * 导出空白模板Excel,并为指定列添加下拉框和日期时间格式验证,同时支持自定义示例数据。 * - * @param response HttpServletResponse - * @param fileName 文件名 - * @param sheetName 工作表名称 - * @param headerMap 表头字段映射(列索引 -> 列名称) - * @param dropdownColumns 带下拉框的列及选项(列索引 -> 下拉框选项数组) - * @param dateTimeColumns 需要验证日期时间格式的列(列索引) - * @param isMultiSelect 是否允许多选 - * @throws IOException + * @param response HttpServletResponse,用于将生成的Excel文件写入响应流。 + * @param fileName 导出的Excel文件名。 + * @param sheetName 工作表名称。 + * @param headerArray 表头字段数组(每个元素代表一列的表头名称)。 + * @param dropdownColumns 带下拉框的列及选项(列索引 -> 下拉框选项数组)。 + * @param isMultiSelect 是否允许多选的下拉框选项。 + * @param exampleDataList 自定义的示例数据(每个元素是一个包含多列数据的List)。 + * @param textColumns 需要设置为文本格式的列索引列表。 + * @throws IOException 如果在写入文件或操作Excel时发生错误。 */ public static void exportBlankTemplate(HttpServletResponse response, String fileName, String sheetName, - Map<Integer, String> headerMap, + String[] headerArray, // 接收一个字符串数组作为表头 Map<Integer, String[]> dropdownColumns, - int[] dateTimeColumns, boolean isMultiSelect, List<List<String>> exampleDataList, List<Integer> textColumns) throws IOException { + // 创建工作簿对象,支持xlsx格式 Workbook workbook = new XSSFWorkbook(); + // 创建一个工作表 Sheet sheet = workbook.createSheet(sheetName); // 创建表头 Row headerRow = sheet.createRow(0); - for (Map.Entry<Integer, String> entry : headerMap.entrySet()) { - headerRow.createCell(entry.getKey()).setCellValue(entry.getValue()); + for (int i = 0; i < headerArray.length; i++) { + // 根据传入的表头数组动态创建每一列的表头 + headerRow.createCell(i).setCellValue(headerArray[i]); // 使用数组来填充表头 } - // 创建一个 CellStyle 对象,用于设置文本格式 - CellStyle textCellStyle = workbook.createCellStyle(); - DataFormat dataFormat = workbook.createDataFormat(); - textCellStyle.setDataFormat(dataFormat.getFormat("@")); // "@" 表示文本格式 - // 为每个需要文本格式的列设置整个列的文本格式 - for (Integer columnIndex : textColumns) { - setColumnTextFormat(sheet, columnIndex, textCellStyle); + + if (textColumns != null) { + // 创建一个 CellStyle 对象,用于设置文本格式 + CellStyle textCellStyle = workbook.createCellStyle(); + DataFormat dataFormat = workbook.createDataFormat(); + textCellStyle.setDataFormat(dataFormat.getFormat("@")); // "@" 表示文本格式 + // 为每个需要文本格式的列设置整个列的文本格式 + for (Integer columnIndex : textColumns) { + // 调用辅助方法,设置特定列的单元格为文本格式 + setColumnTextFormat(sheet, columnIndex, textCellStyle); + } } - // 添加多行自定义示例数据 - for (int i = 0; i < exampleDataList.size(); i++) { - List<String> exampleData = exampleDataList.get(i); - Row exampleRow = sheet.createRow(i + 1); // 示例数据从第二行开始 - for (int j = 0; j < exampleData.size(); j++) { - Cell cell = exampleRow.createCell(j); - cell.setCellValue(exampleData.get(j)); - - // 如果当前列索引在 textColumns 列表中,则设置为文本格式 - if (textColumns.contains(j)) { - cell.setCellStyle(textCellStyle); + if (exampleDataList != null) { + // 添加多行自定义示例数据 + for (int i = 0; i < exampleDataList.size(); i++) { + // 获取每一行的示例数据 + List<String> exampleData = exampleDataList.get(i); + // 在表格中创建新的一行 + Row exampleRow = sheet.createRow(i + 1); // 示例数据从第二行开始 + for (int j = 0; j < exampleData.size(); j++) { + // 在每一列添加数据 + Cell cell = exampleRow.createCell(j); + cell.setCellValue(exampleData.get(j)); } } } // 添加下拉框到指定列 if (dropdownColumns != null) { + // 遍历所有需要添加下拉框的列 for (Map.Entry<Integer, String[]> entry : dropdownColumns.entrySet()) { + // 调用辅助方法添加下拉框 addDropdownValidation(sheet, entry.getKey(), entry.getValue(), isMultiSelect); } } - // 添加日期时间格式验证到指定列 - if (dateTimeColumns != null) { - for (int columnIndex : dateTimeColumns) { - addDateTimeValidation(sheet, columnIndex); - } - } - // 设置响应头,指示浏览器下载文件 response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); response.setHeader("Content-Disposition", "attachment; filename=" + URLEncoder.encode(fileName, StandardCharsets.UTF_8.name()) + ".xlsx"); - // 将 Excel 文件写入输出流 + // 将生成的 Excel 文件写入到输出流 try (ServletOutputStream out = response.getOutputStream()) { - workbook.write(out); - out.flush(); + workbook.write(out); // 写入文件 + out.flush(); // 刷新输出流 } finally { + // 关闭工作簿对象,释放资源 workbook.close(); } } - - /** - * 为指定列添加日期时间格式验证 - * - * @param sheet 工作表 - * @param columnIndex 需要验证日期时间格式的列索引 - */ - private static void addDateTimeValidation(Sheet sheet, int columnIndex) { - // 使用 Excel 的数据验证机制为指定列添加日期时间格式验证 - DataValidationHelper validationHelper = sheet.getDataValidationHelper(); - DataValidationConstraint constraint = validationHelper.createCustomConstraint( - "AND(ISNUMBER(" + CellReference.convertNumToColString(columnIndex) + "1), TEXT(" + CellReference.convertNumToColString(columnIndex) + "1, \"yyyy-mm-dd hh:mm:ss\")= " + - "\"yyyy-mm-dd\")"); - - CellRangeAddressList addressList = new CellRangeAddressList(1, sheet.getPhysicalNumberOfRows(), columnIndex, columnIndex); - DataValidation validation = validationHelper.createValidation(constraint, addressList); - - sheet.addValidationData(validation); - } - - // 修改下拉框验证方法,支持多选功能 private static void addDropdownValidation(Sheet sheet, int column, String[] options, boolean isMultiSelect) { DataValidationHelper validationHelper = sheet.getDataValidationHelper();