platformx-device-api/src/main/java/com/by4cloud/platformx/device/entity/DeviceDemandSub.java
@@ -36,6 +36,9 @@ @Schema(description = "建议厂家") @Column(columnDefinition="VARCHAR(64) comment '建议厂家'") private String manu; @Schema(description = "年度") @Column(columnDefinition="int comment '年度'") private Integer year; @Schema(description = "投资必要性") @Column(columnDefinition="VARCHAR(64) comment '投资必要性'") private String necessity; platformx-device-api/src/main/java/com/by4cloud/platformx/device/entity/DeviceDemandTotal.java
@@ -28,9 +28,15 @@ @Schema(description = "拟使用地点") @Column(columnDefinition="VARCHAR(64) comment '拟使用地点'") private String place; @Schema(description = "项目名称") @Column(columnDefinition="VARCHAR(64) comment '项目名称'") private String name; @Schema(description = "申请部门") @Column(columnDefinition="long comment '申请部门'") private Long deptId; @Schema(description = "申请部门") @Column(columnDefinition="VARCHAR(64) comment '申请部门'") private String deptName; @Schema(description = "建议厂家") @Column(columnDefinition="VARCHAR(64) comment '建议厂家'") private String manu; platformx-device-api/src/main/java/com/by4cloud/platformx/device/entity/MaxSize.java
@@ -50,8 +50,13 @@ @Column(columnDefinition="VARCHAR(32) comment'组织内编码'") private String innerCode; @Column(columnDefinition="VARCHAR(32) comment'日期'") private String day; @Column(columnDefinition="int comment'编号长度'") private Integer length; @Column(columnDefinition="int comment'类型'") private Integer type; } platformx-device-biz/src/main/java/com/by4cloud/platformx/device/controller/DeviceDemandTotalController.java
@@ -86,7 +86,15 @@ QueryWrapper<DeviceDemandTotal> wrapper = new QueryWrapper<>(); wrapper.lambda() .eq(DeviceDemandTotal::getPlanId,id); return R.ok(deviceDemandTotalService.list(wrapper)); List<DeviceDemandTotal> list = deviceDemandTotalService.list(wrapper); for (DeviceDemandTotal deviceDemandTotal : list) { QueryWrapper<DeviceDemandSub> wrapper1 = new QueryWrapper<>(); wrapper1.lambda() .eq(DeviceDemandSub::getTotalId,deviceDemandTotal.getId()); List<DeviceDemandSub> list1 = deviceDemandSubService.list(wrapper1); deviceDemandTotal.setSubList(list1); } return R.ok(list); } platformx-device-biz/src/main/java/com/by4cloud/platformx/device/controller/JcMaxSizeController.java
New file @@ -0,0 +1,167 @@ package com.by4cloud.platformx.device.controller; import cn.hutool.core.util.ArrayUtil; import cn.hutool.core.collection.CollUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.toolkit.StringUtils; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.by4cloud.platformx.common.core.util.R; import com.by4cloud.platformx.common.log.annotation.SysLog; import com.by4cloud.platformx.common.security.annotation.Inner; import com.by4cloud.platformx.device.constant.MaxSizeContant; import com.by4cloud.platformx.device.entity.MaxSize; import com.by4cloud.platformx.device.service.JcMaxSizeService; import org.springframework.security.access.prepost.PreAuthorize; import com.by4cloud.platformx.common.excel.annotation.ResponseExcel; import io.swagger.v3.oas.annotations.security.SecurityRequirement; import org.springdoc.api.annotations.ParameterObject; import org.springframework.http.HttpHeaders; import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.Operation; import lombok.RequiredArgsConstructor; import org.springframework.web.bind.annotation.*; import javax.validation.constraints.Max; import java.util.List; import java.util.Objects; /** * 最大号表 * * @author kdq * @date 2025-03-25 16:24:34 */ @RestController @RequiredArgsConstructor @RequestMapping("/jcMaxSize" ) @Tag(description = "jcMaxSize" , name = "最大号表管理" ) @SecurityRequirement(name = HttpHeaders.AUTHORIZATION) public class JcMaxSizeController { private final JcMaxSizeService jcMaxSizeService; /** * 分页查询 * @param page 分页对象 * @param jcMaxSize 最大号表 * @return */ @Operation(summary = "分页查询" , description = "分页查询" ) @GetMapping("/page" ) @PreAuthorize("@pms.hasPermission('device_jcMaxSize_view')" ) public R getJcMaxSizePage(@ParameterObject Page page, @ParameterObject MaxSize jcMaxSize) { LambdaQueryWrapper<MaxSize> wrapper = Wrappers.lambdaQuery(); wrapper.like(StringUtils.isNotBlank(jcMaxSize.getBusinessName()),MaxSize::getBusinessName,jcMaxSize.getBusinessName()); wrapper.eq(MaxSize::getType,0); return R.ok(jcMaxSizeService.page(page, wrapper)); } @GetMapping("/getNum" ) public R getNum() { String s = jcMaxSizeService.nextNo(MaxSizeContant.DEVICE_NUM); String s1 = jcMaxSizeService.nextNo(MaxSizeContant.DEVICE_CLASS_NUM); String s2 = jcMaxSizeService.nextNo(MaxSizeContant.CONTRACT_NUM); System.out.println(s); System.out.println(s1); System.out.println(s2); return null; } /** * 通过id查询最大号表 * @param id id * @return R */ @Operation(summary = "通过id查询" , description = "通过id查询" ) @GetMapping("/{id}" ) @PreAuthorize("@pms.hasPermission('device_jcMaxSize_view')" ) public R getById(@PathVariable("id" ) Long id) { return R.ok(jcMaxSizeService.getById(id)); } /** * 通过id查询最大号表 * @param id id * @return R */ @Operation(summary = "通过id查询" , description = "通过id查询" ) @GetMapping("/getByMasterId/{id}" ) public R getByMasterId(@PathVariable("id" ) Long id) { MaxSize byId = jcMaxSizeService.getById(id); LambdaQueryWrapper<MaxSize> wrapper = Wrappers.lambdaQuery(); wrapper.eq(MaxSize::getSign,byId.getSign()); wrapper.ne(MaxSize::getType,0); wrapper.orderByDesc(MaxSize::getDay); return R.ok(jcMaxSizeService.list(wrapper)); } /** * 新增最大号表 * @param jcMaxSize 最大号表 * @return R */ @Operation(summary = "新增最大号表" , description = "新增最大号表" ) @SysLog("新增最大号表" ) @PostMapping @PreAuthorize("@pms.hasPermission('device_jcMaxSize_add')" ) public R save(@RequestBody MaxSize jcMaxSize) { LambdaQueryWrapper<MaxSize> wrapper = Wrappers.lambdaQuery(); wrapper.eq(MaxSize::getSign,jcMaxSize.getSign()); wrapper.eq(MaxSize::getType,0); List<MaxSize> list = jcMaxSizeService.list(wrapper); if(list !=null && list.size()>0){ return R.failed("主键标识已存在"); } return R.ok(jcMaxSizeService.save(jcMaxSize)); } /** * 修改最大号表 * @param jcMaxSize 最大号表 * @return R */ @Operation(summary = "修改最大号表" , description = "修改最大号表" ) @SysLog("修改最大号表" ) @PutMapping @PreAuthorize("@pms.hasPermission('device_jcMaxSize_edit')" ) public R updateById(@RequestBody MaxSize jcMaxSize) { LambdaQueryWrapper<MaxSize> wrapper = Wrappers.lambdaQuery(); wrapper.eq(MaxSize::getSign,jcMaxSize.getSign()); wrapper.ne(MaxSize::getId,jcMaxSize.getId()); List<MaxSize> list = jcMaxSizeService.list(wrapper); if(list !=null && list.size()>0){ return R.failed("主键标识重复"); } return R.ok(jcMaxSizeService.updateById(jcMaxSize)); } /** * 通过id删除最大号表 * @param ids id列表 * @return R */ @Operation(summary = "通过id删除最大号表" , description = "通过id删除最大号表" ) @SysLog("通过id删除最大号表" ) @DeleteMapping @PreAuthorize("@pms.hasPermission('device_jcMaxSize_del')" ) public R removeById(@RequestBody Long[] ids) { return R.ok(jcMaxSizeService.removeBatchByIds(CollUtil.toList(ids))); } /** * 导出excel 表格 * @param jcMaxSize 查询条件 * @param ids 导出指定ID * @return excel 文件流 */ @ResponseExcel @GetMapping("/export") @PreAuthorize("@pms.hasPermission('device_jcMaxSize_export')" ) public List<MaxSize> export(MaxSize jcMaxSize,Long[] ids) { return jcMaxSizeService.list(Wrappers.lambdaQuery(jcMaxSize).in(ArrayUtil.isNotEmpty(ids), MaxSize::getId, ids)); } } platformx-device-biz/src/main/java/com/by4cloud/platformx/device/mapper/JcMaxSizeMapper.java
File was renamed from platformx-device-biz/src/main/java/com/by4cloud/platformx/device/mapper/MaxSizeMapper.java @@ -5,7 +5,7 @@ import org.apache.ibatis.annotations.Mapper; @Mapper public interface MaxSizeMapper extends PlatformxBaseMapper<MaxSize> { public interface JcMaxSizeMapper extends PlatformxBaseMapper<MaxSize> { } platformx-device-biz/src/main/java/com/by4cloud/platformx/device/service/JcMaxSizeService.java
New file @@ -0,0 +1,15 @@ package com.by4cloud.platformx.device.service; import com.baomidou.mybatisplus.extension.service.IService; import com.by4cloud.platformx.device.entity.MaxSize; public interface JcMaxSizeService extends IService<MaxSize> { /** * * @param type * @return */ String nextNo(String type); } platformx-device-biz/src/main/java/com/by4cloud/platformx/device/service/impl/JcMaxSizeServiceImpl.java
New file @@ -0,0 +1,77 @@ package com.by4cloud.platformx.device.service.impl; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.by4cloud.platformx.common.data.mybatis.BaseModel; import com.by4cloud.platformx.common.security.service.PlatformxUser; import com.by4cloud.platformx.common.security.util.SecurityUtils; import com.by4cloud.platformx.device.entity.MaxSize; import com.by4cloud.platformx.device.mapper.JcMaxSizeMapper; import com.by4cloud.platformx.device.service.JcMaxSizeService; import lombok.AllArgsConstructor; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import javax.validation.constraints.Max; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Random; /** * 最大号表 * * @author kdq * @date 2025-03-25 16:24:34 */ @Service @AllArgsConstructor @Transactional public class JcMaxSizeServiceImpl extends ServiceImpl<JcMaxSizeMapper, MaxSize> implements JcMaxSizeService { private final JcMaxSizeMapper maxSizeMapper; @Override public String nextNo(String type) { synchronized (this) { SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd"); String format = sdf.format(new Date()); MaxSize maxSize = maxSizeMapper.selectOne(new QueryWrapper<MaxSize>().lambda().eq(MaxSize::getSign, type).eq(MaxSize::getType,0)); if (maxSize == null) { return null; }else { MaxSize dayMax = maxSizeMapper.selectOne(new QueryWrapper<MaxSize>().lambda() .eq(MaxSize::getSign, type) .eq(MaxSize::getDay,format)); Random random = new Random(); int randomNumber = random.nextInt(99); if(dayMax == null){ MaxSize maxSize1 = new MaxSize(); maxSize1.setSign(type); maxSize1.setDay(format); maxSize1.setType(1); int current = 1; String n = padStart(current, maxSize.getLength()); String pre = (maxSize.getUsePrefix() == 0 ? "" : maxSize.getPrefixName()); String suf = (maxSize.getUseSuffix() == 0 ? "" : maxSize.getSuffixName()); maxSize1.setCurrentNumber(current); save(maxSize1); String s = pre+format+suf+randomNumber+n; return s; }else { Integer currentNumber = dayMax.getCurrentNumber(); int current = currentNumber+1; String n = padStart(current, maxSize.getLength()); String pre = (maxSize.getUsePrefix() == 0 ? "" : maxSize.getPrefixName()); String suf = (maxSize.getUseSuffix() == 0 ? "" : maxSize.getSuffixName()); dayMax.setCurrentNumber(current); updateById(dayMax); String s = pre+format+suf+randomNumber+n; return s; } } } } private String padStart(int num, int len) { String v = "000000000000000" + num; return v.substring(v.length() - len); } } platformx-device-biz/src/main/resources/mapper/DeviceMapper.xml
@@ -15,7 +15,6 @@ <result property="beforeDate" column="before_date"/> <result property="remindDate" column="remind_date"/> <result property="num" column="num"/> <result property="amount" column="amount"/> <result property="month" column="month"/> <result property="releaseDate" column="release_date"/> <result property="releasePerson" column="release_person"/> platformx-device-biz/src/main/resources/mapper/JcMaxSizeMapper.xml
New file @@ -0,0 +1,26 @@ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <mapper namespace="com.by4cloud.platformx.device.mapper.JcMaxSizeMapper"> <resultMap id="jcMaxSizeMap" type="com.by4cloud.platformx.device.entity.MaxSize"> <id property="id" column="id"/> <result property="compId" column="comp_id"/> <result property="businessName" column="business_name"/> <result property="sign" column="sign"/> <result property="currentNumber" column="current_number"/> <result property="cacheSize" column="cache_size"/> <result property="usePrefix" column="use_prefix"/> <result property="useSuffix" column="use_suffix"/> <result property="prefixName" column="prefix_name"/> <result property="suffixName" column="suffix_name"/> <result property="length" column="length"/> <result property="innerCode" column="inner_code"/> <result property="isAll" column="is_all"/> <result property="createBy" column="create_by"/> <result property="createTime" column="create_time"/> <result property="updateBy" column="update_by"/> <result property="updateTime" column="update_time"/> <result property="delFlag" column="del_flag"/> </resultMap> </mapper>