计划借调管理初版

This commit is contained in:
mashuai 2024-04-12 14:27:08 +08:00
parent 3fea17aa5e
commit 86bfcdae12
9 changed files with 406 additions and 55 deletions

View File

@ -33,23 +33,28 @@ public class PlanManagementController extends BaseController {
/**
* 获取计划管理列表
* @param name
* @param dto
* @return
*/
@ApiOperation(value = "获取计划管理列表")
@GetMapping("/getList")
public TableDataInfo getList(@RequestParam(value = "name", required = false) String name) {
public TableDataInfo getList(PlanManagementDto dto) {
startPage();
List<PlanManagementVO> list = planManagementService.getList(name);
List<PlanVO> list = planManagementService.getList(dto);
return getDataTable(list);
}
/**
* 计划管理导出
* @param response
* @param dto
*/
@ApiOperation("计划管理导出")
@PostMapping("/export")
public void export(HttpServletResponse response, @RequestParam(value = "name", required = false) String name)
public void export(HttpServletResponse response, PlanManagementDto dto)
{
List<PlanManagementVO> list = planManagementService.getList(name);
ExcelUtil<PlanManagementVO> util = new ExcelUtil<>(PlanManagementVO.class);
List<PlanVO> list = planManagementService.getList(dto);
ExcelUtil<PlanVO> util = new ExcelUtil<>(PlanVO.class);
util.exportExcel(response, list, "计划管理数据");
}
@ -72,6 +77,52 @@ public class PlanManagementController extends BaseController {
return planManagementService.insert(dto);
}
/**
* 新增或者修改计划借调管理
* @param dto
* @return
*/
@ApiOperation("新增或者修改计划借调管理")
@PostMapping("/addOrUpdateMange")
public AjaxResult addOrUpdateMange(@ApiParam(value = "添加信息", required = true)
@RequestBody PlanManagementDto dto){
if (dto.getBorrowId() != null) {
log.info("更新计划借调管理:{}", dto);
dto.setUpdateBy(SecurityUtils.getLoginUser().getSysUser().getNickName());
return AjaxResult.success(planManagementService.update(dto));
}
log.info("新增计划借调管理:{}", dto);
dto.setCreateBy(SecurityUtils.getLoginUser().getSysUser().getNickName());
return planManagementService.insertManage(dto);
}
/**
* 获取计划借调管理列表
* @param dto
* @return
*/
@ApiOperation(value = "获取计划借调管理列表")
@GetMapping("/getManageList")
public TableDataInfo getManageList(PlanManagementDto dto) {
startPage();
List<PlanManagementVO> list = planManagementService.getManageList(dto);
return getDataTable(list);
}
/**
* 计划借调管理导出
* @param response
* @param dto
*/
@ApiOperation("计划借调管理导出")
@PostMapping("/exportManage")
public void exportManage(HttpServletResponse response, PlanManagementDto dto)
{
List<PlanManagementVO> list = planManagementService.getManageList(dto);
ExcelUtil<PlanManagementVO> util = new ExcelUtil<>(PlanManagementVO.class);
util.exportExcel(response, list, "计划借调管理数据");
}
/**
* 删除计划管理
* @param planId

View File

@ -1,9 +1,13 @@
package com.bonus.sgzb.material.domain;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
/**
* 计划管理表单集合dto
@ -39,6 +43,10 @@ public class CheckDetailsInfo {
@ApiModelProperty(value = "计划数量")
private Double purchaseNum;
/** 借出数量 */
@ApiModelProperty(value = "借出数量")
private Double borrowNum;
/** 计划总价 */
@ApiModelProperty(value = "计划总价")
private Double totalPrice;
@ -51,6 +59,12 @@ public class CheckDetailsInfo {
@ApiModelProperty(value = "创建者")
private String createBy;
/** 创建时间 */
@ApiModelProperty(value = "创建时间")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date createTime;
/** 更新者 */
@ApiModelProperty(value = "更新者")
private String updateBy;

View File

@ -27,10 +27,10 @@ public class PlanManagementDto {
/** 借调计划ID */
@ApiModelProperty(value = "借调计划ID")
private Long borrowId;
private Integer borrowId;
/** 需求单位ID */
@ApiModelProperty(value = "需求单位ID")
/** 借入单位ID */
@ApiModelProperty(value = "借入单位ID")
private Integer needUnitId;
/** 借出单位ID */
@ -41,6 +41,10 @@ public class PlanManagementDto {
@ApiModelProperty(value = "备注")
private String remark;
/** 查询名称 */
@ApiModelProperty(value = "查询名称")
private String name;
/** 创建者 */
@ApiModelProperty(value = "创建者")
private String createBy;

View File

@ -9,7 +9,7 @@ import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
/**
* 计划管理返回VO
* 计划借调管理返回VO
* @Author ma_sh
* @create 2024/4/9 9:53
*/
@ -24,21 +24,14 @@ public class PlanManagementVO {
@ApiModelProperty(value = "计划ID")
private Integer planId;
/** 借调计划ID */
@ApiModelProperty(value = "借调计划ID")
private Integer borrowId;
/** 借出方单位id */
@Excel(name = "借出方单位id")
@ApiModelProperty(value = "借出方单位id")
private String unitId;
/** 借出方单位 */
@Excel(name = "借出方单位")
@ApiModelProperty(value = "借出方单位")
private String lenderCompany;
/** 借入方单位 */
@Excel(name = "借入方单位")
@ApiModelProperty(value = "借入方单位")
private String borrowerCompany;
/** 物资名称 */
@Excel(name = "物资名称")
@ApiModelProperty(value = "物资名称")
@ -54,42 +47,58 @@ public class PlanManagementVO {
@ApiModelProperty(value = "单位")
private String unitName;
/** 借出方单位 */
@Excel(name = "借出方单位")
@ApiModelProperty(value = "借出方单位")
private String borrowerCompany;
/** 借出方原计划数 */
@Excel(name = "借出方原计划数")
@Excel(name = "原计划数")
@ApiModelProperty(value = "借出方原计划数")
private String lenderOrigPlanNum;
/** 借出方现计划数 */
@Excel(name = "借出方现计划数")
@ApiModelProperty(value = "借出方现计划数")
private String lenderNowPlanNum;
/** 借入方原计划数 */
@Excel(name = "借入方原计划数")
@ApiModelProperty(value = "借入方原计划数")
private String borrowerOrigPlanNum;
/** 借方现计划数 */
@Excel(name = "借入方现计划数")
@ApiModelProperty(value = "方现计划数")
/** 借出方现计划数 */
@Excel(name = "现计划数")
@ApiModelProperty(value = "借出方现计划数")
private String borrowerNowPlanNum;
/** 借入方单位 */
@Excel(name = "借入方单位")
@ApiModelProperty(value = "借入方单位")
private String lenderCompany;
/** 借入方原计划数 */
@ApiModelProperty(value = "借入方原计划数")
private String lenderOrigPlanNum;
/** 借入方现计划数 */
@Excel(name = "现有计划数")
@ApiModelProperty(value = "借入方现计划数")
private String lenderNowPlanNum;
/** 借出数 */
@Excel(name = "借出数")
@Excel(name = "调数量")
@ApiModelProperty(value = "借出数")
private String borrowNum;
/** 计划单价 */
@Excel(name = "计划单价")
@ApiModelProperty(value = "计划单价")
private String planPrice;
/** 计划总价 */
@Excel(name = "计划总价")
@ApiModelProperty(value = "计划总价")
private String planCost;
/** 类型id */
@ApiModelProperty(value = "类型id")
private String typeId;
/** 数据所属组织 */
@ApiModelProperty(value = "数据所属组织")
private Integer companyId;
/** 创建者 */
@Excel(name = "操作人")
@ApiModelProperty(value = "创建者")
private String createBy;
@ -97,10 +106,10 @@ public class PlanManagementVO {
@ApiModelProperty(value = "创建时间")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "操作时间")
private Date createTime;
/** 更新者 */
@Excel(name = "操作人")
@ApiModelProperty(value = "更新者")
private String updateBy;
@ -108,7 +117,6 @@ public class PlanManagementVO {
@ApiModelProperty(value = "更新时间 ")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@Excel(name = "操作时间")
private Date updateTime;
/** 备注 */

View File

@ -0,0 +1,84 @@
package com.bonus.sgzb.material.domain;
import com.bonus.sgzb.common.core.annotation.Excel;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.util.Date;
/**
* 计划管理返回VO
* @Author ma_sh
* @create 2024/4/12 14:07
*/
@Data
public class PlanVO {
/** 计划ID */
@ApiModelProperty(value = "计划ID")
private Integer planId;
/** 借出方单位id */
@ApiModelProperty(value = "借出方单位id")
private String unitId;
/** 基层单位 */
@Excel(name = "基层单位")
@ApiModelProperty(value = "基层单位")
private String lenderCompany;
/** 物资名称 */
@Excel(name = "物资名称")
@ApiModelProperty(value = "物资名称")
private String typeName;
/** 规格型号 */
@Excel(name = "规格型号")
@ApiModelProperty(value = "规格型号")
private String typeModelName;
/** 单位 */
@Excel(name = "单位")
@ApiModelProperty(value = "单位")
private String unitName;
/** 计划数 */
@Excel(name = "计划数")
@ApiModelProperty(value = "计划数")
private String lenderOrigPlanNum;
/** 计划单价 */
@Excel(name = "计划单价")
@ApiModelProperty(value = "计划单价")
private String planPrice;
/** 计划总价 */
@Excel(name = "计划总价")
@ApiModelProperty(value = "计划总价")
private String planCost;
/** 类型id */
@ApiModelProperty(value = "类型id")
private String typeId;
/** 数据所属组织 */
@ApiModelProperty(value = "数据所属组织")
private Integer companyId;
/** 创建者 */
@ApiModelProperty(value = "创建者")
private String createBy;
/** 创建时间 */
@ApiModelProperty(value = "创建时间")
@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date createTime;
/** 备注 */
@Excel(name = "备注")
@ApiModelProperty(value = "备注")
private String remark;
}

View File

@ -3,6 +3,7 @@ package com.bonus.sgzb.material.mapper;
import com.bonus.sgzb.material.domain.CheckDetailsInfo;
import com.bonus.sgzb.material.domain.PlanManagementDto;
import com.bonus.sgzb.material.domain.PlanManagementVO;
import com.bonus.sgzb.material.domain.PlanVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
@ -32,9 +33,29 @@ public interface PlanManagementMapper {
/**
* 查询计划管理列表
* @param name
* @param dto
* @return
*/
List<PlanManagementVO> selectPlanInfo(@Param("name") String name);
List<PlanVO> selectPlanInfo(PlanManagementDto dto);
/**
* 新增plan_borrow_info
* @param dto
* @return
*/
int insertPlanBorrow(PlanManagementDto dto);
/**
* 新增plan_borrow_details
* @param checkDetailsList
* @return
*/
int insertPlanBorrowDetail(@Param("checkDetailsList") List<CheckDetailsInfo> checkDetailsList);
/**
* 获取计划借调管理列表
* @param dto
* @return
*/
List<PlanManagementVO> selectBorrow(PlanManagementDto dto);
}

View File

@ -4,6 +4,7 @@ import com.bonus.sgzb.common.core.web.domain.AjaxResult;
import com.bonus.sgzb.material.domain.CheckDetailsInfo;
import com.bonus.sgzb.material.domain.PlanManagementDto;
import com.bonus.sgzb.material.domain.PlanManagementVO;
import com.bonus.sgzb.material.domain.PlanVO;
import java.util.List;
@ -16,10 +17,10 @@ public interface PlanManagementService {
/**
* 获取计划管理列表
* @param name
* @param dto
* @return
*/
List<PlanManagementVO> getList(String name);
List<PlanVO> getList(PlanManagementDto dto);
/**
* 修改计划管理
@ -41,4 +42,18 @@ public interface PlanManagementService {
* @return
*/
Integer deleteById(Long planId);
/**
* 新增计划借调管理
* @param dto
* @return
*/
AjaxResult insertManage(PlanManagementDto dto);
/**
* 获取计划借调管理列表
* @param dto
* @return
*/
List<PlanManagementVO> getManageList(PlanManagementDto dto);
}

View File

@ -5,6 +5,7 @@ import com.bonus.sgzb.material.config.ExceptionEnum;
import com.bonus.sgzb.material.domain.CheckDetailsInfo;
import com.bonus.sgzb.material.domain.PlanManagementDto;
import com.bonus.sgzb.material.domain.PlanManagementVO;
import com.bonus.sgzb.material.domain.PlanVO;
import com.bonus.sgzb.material.mapper.PlanManagementMapper;
import com.bonus.sgzb.material.service.PlanManagementService;
import lombok.extern.slf4j.Slf4j;
@ -13,6 +14,8 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
/**
@ -29,21 +32,21 @@ public class PlanManagementServiceImpl implements PlanManagementService {
/**
* 获取计划管理列表
* @param name
* @param dto
* @return
*/
@Override
public List<PlanManagementVO> getList(String name) {
return selectPlanInfo(name);
public List<PlanVO> getList(PlanManagementDto dto) {
return selectPlanInfo(dto);
}
/**
* 查询计划管理列表
* @param name
* @param dto
* @return
*/
private List<PlanManagementVO> selectPlanInfo(String name) {
return planManagementMapper.selectPlanInfo(name);
private List<PlanVO> selectPlanInfo(PlanManagementDto dto) {
return planManagementMapper.selectPlanInfo(dto);
}
/**
@ -114,4 +117,60 @@ public class PlanManagementServiceImpl implements PlanManagementService {
return null;
}
/**
* 新增计划借调管理
* @param dto
* @return
*/
@Override
@Transactional(rollbackFor = Exception.class)
public AjaxResult insertManage(PlanManagementDto dto) {
int res = 0;
try {
res = insertManagePlan(dto);
if (res == 0) {
throw new RuntimeException("新增计划借调管理异常");
}
} catch (Exception e) {
log.error("新增计划借调管理异常:{}",e.getMessage());
// 添加事务回滚逻辑保证入库全部成功或者全部失败
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
return AjaxResult.error(ExceptionEnum.SAVE_TO_DATABASE.getCode(), ExceptionEnum.SAVE_TO_DATABASE.getMsg());
}
return AjaxResult.success(res);
}
/**
* 获取计划借调管理列表
* @param dto
* @return
*/
@Override
public List<PlanManagementVO> getManageList(PlanManagementDto dto) {
return planManagementMapper.selectBorrow(dto);
}
/**
* 新增计划借调管理方法抽取
* @param dto
* @return
*/
private int insertManagePlan(PlanManagementDto dto) {
int res = 0;
//新增plan_borrow_info
res += planManagementMapper.insertPlanBorrow(dto);
//新增plan_borrow_details
for (CheckDetailsInfo checkDetailsInfo : dto.getCheckDetailsList()) {
checkDetailsInfo.setPlanId(dto.getBorrowId());
//checkDetailsInfo.setCreateTime(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
}
res += planManagementMapper.insertPlanBorrowDetail(dto.getCheckDetailsList());
return res;
}
public static void main(String[] args) {
SimpleDateFormat simpleDateFormat=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
System.out.println(simpleDateFormat.format(new Date()));
}
}

View File

@ -43,20 +43,64 @@
now()
</trim>
</insert>
<select id="selectPlanInfo" resultType="com.bonus.sgzb.material.domain.PlanManagementVO">
SELECT pn.plan_id AS planId,
<insert id="insertPlanBorrow" useGeneratedKeys="true" keyProperty="borrowId">
insert into plan_borrow_info
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="needUnitId != null">need_unit_id,</if>
<if test="borrowUnitId != null">borrow_unit_id,</if>
<if test="createBy != null">create_by,</if>
<if test="remark != null">remark,</if>
create_time
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="needUnitId != null">#{needUnitId},</if>
<if test="borrowUnitId != null">#{borrowUnitId},</if>
<if test="createBy != null">#{createBy},</if>
<if test="remark != null">#{remark},</if>
now()
</trim>
</insert>
<insert id="insertPlanBorrowDetail">
<foreach item="item" index="index" collection="checkDetailsList" separator=";">
insert into plan_borrow_details
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="item.planId != null">plan_id,</if>
<if test="item.typeId != null">type_id,</if>
<if test="item.purchaseNum != null">plan_num,</if>
<if test="item.borrowNum != null">borrow_num,</if>
create_time,
<if test="item.remark != null">remark,</if>
<if test="item.companyId != null">company_id,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="item.planId != null">#{item.planId},</if>
<if test="item.typeId != null">#{item.typeId},</if>
<if test="item.purchaseNum != null">#{item.purchaseNum},</if>
<if test="item.borrowNum != null">#{item.borrowNum},</if>
now(),
<if test="item.remark != null">#{item.remark},</if>
<if test="item.companyId != null">#{item.companyId},</if>
</trim>
</foreach>
</insert>
<select id="selectPlanInfo" resultType="com.bonus.sgzb.material.domain.PlanVO">
SELECT
pn.plan_id AS planId,
bu.unit_name AS lenderCompany,
bu.unit_id AS unitId,
pnd.plan_num AS lenderOrigPlanNum,
pnd.plan_price AS planPrice,
pnd.plan_cost AS planCost,
pnd.type_id AS typeId,
pnd.company_id AS companyId,
pn.create_by AS createBy,
pn.create_time AS createTime,
pn.remark AS remark,
mt2.type_name AS typeName,
mt.type_name AS typeModelName,
mt.unit_name AS unitName
FROM plan_need_info pn
FROM
plan_need_info pn
LEFT JOIN plan_need_details pnd ON pn.plan_id = pnd.plan_id
LEFT JOIN bm_unit_info bu ON pn.unit_id = bu.unit_id
LEFT JOIN ma_type mt ON pnd.type_id = mt.type_id
@ -66,11 +110,62 @@
WHERE
1=1
<if test="name != null and name != ''">
and (bu.unit_id = #{name} or
and (bu.unit_name like concat('%', #{name}, '%') or
mt2.type_name like concat('%',#{name},'%') or
mt.type_name like concat('%',#{name},'%'))
</if>
<if test="borrowUnitId != null and borrowUnitId != ''">
and bu.unit_id = #{borrowUnitId}
</if>
</select>
<select id="selectBorrow" resultType="com.bonus.sgzb.material.domain.PlanManagementVO">
SELECT
pnd.id AS id,
pb.borrow_id AS borrowId,
bu.unit_name AS borrowerCompany,
pnd.plan_num AS borrowerOrigPlanNum,
pnd.borrow_num AS borrowNum,
(pnd.plan_num - pnd.borrow_num) AS borrowerNowPlanNum,
aa.lenderCompany AS lenderCompany,
aa.lenderOrigPlanNum AS lenderOrigPlanNum,
(aa.lenderOrigPlanNum + pnd.borrow_num) AS lenderNowPlanNum,
CASE
WHEN COALESCE(pb.update_by, '') = '' THEN pb.create_by
ELSE pb.update_by
END AS createBy,
COALESCE(pb.update_time, pb.create_time) AS createTime,
pb.remark AS remark,
mt2.type_name AS typeName,
mt.type_name AS typeModelName,
mt.unit_name AS unitName
FROM
( SELECT
bu.unit_name AS lenderCompany,
pnd.plan_num AS lenderOrigPlanNum,
pbd.plan_id AS planId
FROM
plan_borrow_details pbd
LEFT JOIN plan_borrow_info pb ON pb.borrow_id = pbd.plan_id
LEFT JOIN bm_unit_info bu ON pb.borrow_unit_id = bu.unit_id
LEFT JOIN plan_need_info pn ON pb.need_unit_id = pn.unit_id
LEFT JOIN plan_need_details pnd ON pn.plan_id = pnd.plan_id ) AS aa
LEFT JOIN plan_borrow_details pnd ON pnd.plan_id = aa.planId
LEFT JOIN plan_borrow_info pb ON pb.borrow_id = pnd.plan_id
LEFT JOIN bm_unit_info bu ON pb.need_unit_id = bu.unit_id
LEFT JOIN ma_type mt ON pnd.type_id = mt.type_id
LEFT JOIN ma_type mt2 ON mt2.type_id = mt.parent_id
LEFT JOIN ma_type mt3 ON mt3.type_id = mt2.parent_id
LEFT JOIN ma_type mt4 ON mt4.type_id = mt3.parent_id
WHERE
1=1
<if test="name != null and name != ''">
and (
aa.lenderCompany like concat('%', #{name}, '%') or
bu.unit_name like concat('%', #{name}, '%') or
mt2.type_name like concat('%',#{name},'%') or
mt.type_name like concat('%',#{name},'%'))
</if>
GROUP BY pnd.id,aa.lenderCompany,aa.lenderOrigPlanNum
</select>
</mapper>