This commit is contained in:
liuyaxin
2026-06-17 15:26:16 +08:00
parent 48075b431c
commit 2a5312a4d8
10 changed files with 702 additions and 0 deletions
@@ -0,0 +1,77 @@
/**
* BladeX Commercial License Agreement
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
* <p>
* Use of this software is governed by the Commercial License Agreement
* obtained after purchasing a license from BladeX.
* <p>
* 1. This software is for development use only under a valid license
* from BladeX.
* <p>
* 2. Redistribution of this software's source code to any third party
* without a commercial license is strictly prohibited.
* <p>
* 3. Licensees may copyright their own code but cannot use segments
* from this software for such purposes. Copyright of this software
* remains with BladeX.
* <p>
* Using this software signifies agreement to this License, and the software
* must not be used for illegal purposes.
* <p>
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
* not liable for any claims arising from secondary or illegal development.
* <p>
* Author: Chill Zhuang (bladejava@qq.com)
*/
package org.springblade.zhaocai.controller;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.secure.annotation.PreAuth;
import org.springblade.core.tenant.annotation.NonDS;
import org.springblade.core.tool.api.R;
import org.springblade.system.feign.ISysClient;
import org.springblade.system.pojo.entity.Dept;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* 当前登录用户部门公司查询控制器
*
* @author Chill
*/
@NonDS
@RestController
@RequestMapping("current-user")
@AllArgsConstructor
@PreAuth(menu = "procurement-plan")
@Tag(name = "当前用户信息", description = "当前登录用户部门公司查询接口")
public class UserDeptController extends BladeController {
private final ISysClient sysClient;
/**
* 获取当前登录用户所属公司
*/
@GetMapping("/company")
@ApiOperationSupport(order = 1)
@Operation(summary = "获取当前登录用户所属公司", description = "根据当前登录用户部门ID向上查找dept_category=1的公司")
public R<Dept> getCurrentUserCompany() {
return sysClient.getCurrentUserCompany();
}
/**
* 获取当前登录用户所属部门
*/
@GetMapping("/dept")
@ApiOperationSupport(order = 2)
@Operation(summary = "获取当前登录用户所属部门", description = "根据当前登录用户部门ID查找dept_category=2的部门")
public R<Dept> getCurrentUserDept() {
return sysClient.getCurrentUserDept();
}
}
@@ -0,0 +1,38 @@
/**
* BladeX Commercial License Agreement
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
* <p>
* Use of this software is governed by the Commercial License Agreement
* obtained after purchasing a license from BladeX.
* <p>
* 1. This software is for development use only under a valid license
* from BladeX.
* <p>
* 2. Redistribution of this software's source code to any third party
* without a commercial license is strictly prohibited.
* <p>
* 3. Licensees may copyright their own code but cannot use segments
* from this software for such purposes. Copyright of this software
* remains with BladeX.
* <p>
* Using this software signifies agreement to this License, and the software
* must not be used for illegal purposes.
* <p>
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
* not liable for any claims arising from secondary or illegal development.
* <p>
* Author: Chill Zhuang (bladejava@qq.com)
*/
package org.springblade.zhaocai.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.springblade.zhaocai.pojo.entity.BillCode;
/**
* 单据号码 Mapper 接口
*
* @author Chill
*/
public interface BillCodeMapper extends BaseMapper<BillCode> {
}
@@ -0,0 +1,56 @@
/**
* BladeX Commercial License Agreement
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
* <p>
* Use of this software is governed by the Commercial License Agreement
* obtained after purchasing a license from BladeX.
* <p>
* 1. This software is for development use only under a valid license
* from BladeX.
* <p>
* 2. Redistribution of this software's source code to any third party
* without a commercial license is strictly prohibited.
* <p>
* 3. Licensees may copyright their own code but cannot use segments
* from this software for such purposes. Copyright of this software
* remains with BladeX.
* <p>
* Using this software signifies agreement to this License, and the software
* must not be used for illegal purposes.
* <p>
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
* not liable for any claims arising from secondary or illegal development.
* <p>
* Author: Chill Zhuang (bladejava@qq.com)
*/
package org.springblade.zhaocai.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.springblade.zhaocai.pojo.entity.ProcurementPlanMaterial;
import java.util.List;
/**
* 年度招采计划物料明细 Mapper 接口
*
* @author Chill
*/
public interface ProcurementPlanMaterialMapper extends BaseMapper<ProcurementPlanMaterial> {
/**
* 根据项目明细ID查询物料明细列表
*
* @param projectId 项目明细ID
* @return 物料明细列表
*/
List<ProcurementPlanMaterial> selectByProjectId(Long projectId);
/**
* 根据主表ID删除物料明细
*
* @param planId 主表ID
* @return 影响行数
*/
int deleteByPlanId(Long planId);
}
@@ -0,0 +1,58 @@
<?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="org.springblade.zhaocai.mapper.ProcurementPlanMaterialMapper">
<!-- 通用查询映射结果 -->
<resultMap id="procurementPlanMaterialResultMap" type="org.springblade.zhaocai.pojo.entity.ProcurementPlanMaterial">
<result column="id" property="id"/>
<result column="tenant_id" property="tenantId"/>
<result column="create_user" property="createUser"/>
<result column="create_time" property="createTime"/>
<result column="update_user" property="updateUser"/>
<result column="update_time" property="updateTime"/>
<result column="status" property="status"/>
<result column="is_deleted" property="isDeleted"/>
<result column="plan_id" property="planId"/>
<result column="project_id" property="projectId"/>
<result column="sort_no" property="sortNo"/>
<result column="material_name" property="materialName"/>
<result column="material_code" property="materialCode"/>
<result column="specification" property="specification"/>
<result column="brand" property="brand"/>
<result column="unit" property="unit"/>
<result column="reference_price" property="referencePrice"/>
<result column="quantity" property="quantity"/>
<result column="estimated_amount" property="estimatedAmount"/>
<result column="contact_person" property="contactPerson"/>
<result column="contact_person_id" property="contactPersonId"/>
<result column="apply_date" property="applyDate"/>
<result column="expect_date" property="expectDate"/>
<result column="last_year_total" property="lastYearTotal"/>
<result column="last_year_avg_price" property="lastYearAvgPrice"/>
<result column="last_year_total_amount" property="lastYearTotalAmount"/>
<result column="requirement_intro" property="requirementIntro"/>
<result column="remark" property="remark"/>
</resultMap>
<!-- 通用查询结果列 -->
<sql id="baseColumnList">
select
id, tenant_id, create_user, create_time, update_user, update_time, status, is_deleted,
plan_id, project_id, sort_no, material_name, material_code, specification, brand, unit,
reference_price, quantity, estimated_amount, contact_person, contact_person_id, apply_date,
expect_date, last_year_total, last_year_avg_price, last_year_total_amount, requirement_intro, remark
</sql>
<select id="selectByProjectId" resultMap="procurementPlanMaterialResultMap">
<include refid="baseColumnList"/>
from zc_procurement_plan_material
where project_id = #{projectId}
and is_deleted = 0
order by sort_no asc
</select>
<delete id="deleteByPlanId">
delete from zc_procurement_plan_material where plan_id = #{planId}
</delete>
</mapper>
@@ -0,0 +1,46 @@
/**
* BladeX Commercial License Agreement
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
* <p>
* Use of this software is governed by the Commercial License Agreement
* obtained after purchasing a license from BladeX.
* <p>
* 1. This software is for development use only under a valid license
* from BladeX.
* <p>
* 2. Redistribution of this software's source code to any third party
* without a commercial license is strictly prohibited.
* <p>
* 3. Licensees may copyright their own code but cannot use segments
* from this software for such purposes. Copyright of this software
* remains with BladeX.
* <p>
* Using this software signifies agreement to this License, and the software
* must not be used for illegal purposes.
* <p>
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
* not liable for any claims arising from secondary or illegal development.
* <p>
* Author: Chill Zhuang (bladejava@qq.com)
*/
package org.springblade.zhaocai.service;
import com.baomidou.mybatisplus.extension.service.IService;
import org.springblade.zhaocai.pojo.entity.BillCode;
/**
* 单据号码服务类
*
* @author Chill
*/
public interface IBillCodeService extends IService<BillCode> {
/**
* 生成唯一单据号
*
* @param billType 单据类型
* @return 单据号
*/
String generateBillCode(String billType);
}
@@ -0,0 +1,56 @@
/**
* BladeX Commercial License Agreement
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
* <p>
* Use of this software is governed by the Commercial License Agreement
* obtained after purchasing a license from BladeX.
* <p>
* 1. This software is for development use only under a valid license
* from BladeX.
* <p>
* 2. Redistribution of this software's source code to any third party
* without a commercial license is strictly prohibited.
* <p>
* 3. Licensees may copyright their own code but cannot use segments
* from this software for such purposes. Copyright of this software
* remains with BladeX.
* <p>
* Using this software signifies agreement to this License, and the software
* must not be used for illegal purposes.
* <p>
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
* not liable for any claims arising from secondary or illegal development.
* <p>
* Author: Chill Zhuang (bladejava@qq.com)
*/
package org.springblade.zhaocai.service;
import com.baomidou.mybatisplus.extension.service.IService;
import org.springblade.zhaocai.pojo.entity.ProcurementPlanMaterial;
import java.util.List;
/**
* 年度招采计划物料明细服务类
*
* @author Chill
*/
public interface IProcurementPlanMaterialService extends IService<ProcurementPlanMaterial> {
/**
* 根据项目明细ID查询物料明细列表
*
* @param projectId 项目明细ID
* @return 物料明细列表
*/
List<ProcurementPlanMaterial> listByProjectId(Long projectId);
/**
* 根据主表ID删除物料明细
*
* @param planId 主表ID
* @return 是否成功
*/
boolean removeByPlanId(Long planId);
}
@@ -0,0 +1,79 @@
/**
* BladeX Commercial License Agreement
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
* <p>
* Use of this software is governed by the Commercial License Agreement
* obtained after purchasing a license from BladeX.
* <p>
* 1. This software is for development use only under a valid license
* from BladeX.
* <p>
* 2. Redistribution of this software's source code to any third party
* without a commercial license is strictly prohibited.
* <p>
* 3. Licensees may copyright their own code but cannot use segments
* from this software for such purposes. Copyright of this software
* remains with BladeX.
* <p>
* Using this software signifies agreement to this License, and the software
* must not be used for illegal purposes.
* <p>
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
* not liable for any claims arising from secondary or illegal development.
* <p>
* Author: Chill Zhuang (bladejava@qq.com)
*/
package org.springblade.zhaocai.service.impl;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.tool.utils.DateUtil;
import org.springblade.zhaocai.mapper.BillCodeMapper;
import org.springblade.zhaocai.pojo.entity.BillCode;
import org.springblade.zhaocai.service.IBillCodeService;
import org.springframework.stereotype.Service;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.concurrent.ThreadLocalRandom;
/**
* 单据号码服务实现类
*
* @author Chill
*/
@Service
public class BillCodeServiceImpl extends ServiceImpl<BillCodeMapper, BillCode> implements IBillCodeService {
/**
* 最大重试次数
*/
private static final int MAX_RETRY = 10;
/**
* 单据号前缀
*/
private static final String BILL_NO_PREFIX = "NDZC";
@Override
public String generateBillCode(String billType) {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmm");
for (int i = 0; i < MAX_RETRY; i++) {
String dateStr = dateFormat.format(new Date());
String randomStr = String.format("%03d", ThreadLocalRandom.current().nextInt(0, 1000));
String candidate = BILL_NO_PREFIX + dateStr + randomStr;
if (baseMapper.selectCount(Wrappers.<BillCode>lambdaQuery()
.eq(BillCode::getBillCode, candidate)) == 0) {
BillCode billCode = new BillCode();
billCode.setBillCode(candidate);
billCode.setBillType(billType);
billCode.setCreateTime(DateUtil.now());
baseMapper.insert(billCode);
return candidate;
}
}
throw new ServiceException("单据号生成失败,请重试");
}
}
@@ -0,0 +1,55 @@
/**
* BladeX Commercial License Agreement
* Copyright (c) 2018-2099, https://bladex.cn. All rights reserved.
* <p>
* Use of this software is governed by the Commercial License Agreement
* obtained after purchasing a license from BladeX.
* <p>
* 1. This software is for development use only under a valid license
* from BladeX.
* <p>
* 2. Redistribution of this software's source code to any third party
* without a commercial license is strictly prohibited.
* <p>
* 3. Licensees may copyright their own code but cannot use segments
* from this software for such purposes. Copyright of this software
* remains with BladeX.
* <p>
* Using this software signifies agreement to this License, and the software
* must not be used for illegal purposes.
* <p>
* THIS SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY. The author is
* not liable for any claims arising from secondary or illegal development.
* <p>
* Author: Chill Zhuang (bladejava@qq.com)
*/
package org.springblade.zhaocai.service.impl;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springblade.zhaocai.mapper.ProcurementPlanMaterialMapper;
import org.springblade.zhaocai.pojo.entity.ProcurementPlanMaterial;
import org.springblade.zhaocai.service.IProcurementPlanMaterialService;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* 年度招采计划物料明细服务实现类
*
* @author Chill
*/
@Service
public class ProcurementPlanMaterialServiceImpl extends ServiceImpl<ProcurementPlanMaterialMapper, ProcurementPlanMaterial> implements IProcurementPlanMaterialService {
@Override
public List<ProcurementPlanMaterial> listByProjectId(Long projectId) {
return baseMapper.selectByProjectId(projectId);
}
@Override
public boolean removeByPlanId(Long planId) {
return baseMapper.deleteByPlanId(planId) >= 0;
}
}