package com.zbooksoft.gdmis.controller;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.ruili.wcp.common.CustomConfigUtil;
|
import com.ruili.wcp.data.entity.config.Module;
|
import com.ruili.wcp.data.entity.management.*;
|
import com.ruili.wcp.engine.flow.HistoryService;
|
import com.ruili.wcp.engine.flow.RuntimeService;
|
import com.ruili.wcp.engine.flow.TaskService;
|
import com.ruili.wcp.service.config.ModuleService;
|
import com.ruili.wcp.web.common.UserFriendlyException;
|
import com.ruili.wcp.web.model.AjaxResponse;
|
import com.ruili.wcp.web.model.ErrorInfo;
|
import com.ruili.wcp.web.model.easyui.DataTableVO;
|
import com.ruili.wcp.web.model.easyui.PagedSortedAndFilteredInputDto;
|
import com.zbooksoft.gdmis.config.ArchivesCustomConfig;
|
import com.zbooksoft.gdmis.data.entity.BorrowDetail;
|
import com.zbooksoft.gdmis.data.entity.BorrowForm;
|
import com.zbooksoft.gdmis.data.entity.CatAjjxx;
|
import com.zbooksoft.gdmis.data.vo.BorrowInfo;
|
import com.zbooksoft.gdmis.data.vo.ParentBorrowInfo;
|
import com.zbooksoft.gdmis.service.*;
|
import org.apache.shiro.SecurityUtils;
|
import org.apache.shiro.authz.annotation.RequiresUser;
|
import org.apache.shiro.session.InvalidSessionException;
|
import org.apache.shiro.session.Session;
|
import org.apache.shiro.subject.Subject;
|
import org.joda.time.DateTime;
|
import org.slf4j.Logger;
|
import org.slf4j.LoggerFactory;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.jdbc.core.JdbcTemplate;
|
import org.springframework.stereotype.Controller;
|
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMethod;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
import org.springframework.web.servlet.ModelAndView;
|
|
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletResponse;
|
import java.text.SimpleDateFormat;
|
import java.util.*;
|
|
|
/**
|
* @Description: 借阅
|
* @Author: zhai
|
* @Date: 2024/8/28
|
**/
|
|
@Controller
|
@RequestMapping("/borrow")
|
public class BorrowController {
|
@Autowired
|
CatAjjxxService catAjjxxService;
|
@Autowired
|
CatCgwjxxService catCgwjxxService;
|
@Autowired
|
CatYswjxxService catYswjxxService;
|
@Autowired
|
BorrowDetailService borrowDetailService;
|
@Autowired
|
BorrowFormService borrowFormService;
|
@Autowired
|
RuntimeService runtimeService;
|
@Autowired
|
TaskService taskService;
|
@Autowired
|
CustomConfigUtil customConfigUtil;
|
@Autowired
|
ModuleService moduleService;
|
@Autowired
|
HistoryService historyService;
|
@Autowired
|
UserCheckService userCheckService;
|
@Autowired
|
UtilizationUserService utilizationUserService;
|
@Autowired
|
JdbcTemplate jdbcTemplate;
|
private static final Logger logger = LoggerFactory.getLogger(BorrowController.class);
|
|
|
@RequestMapping({"/addBorrowDetail"})
|
@ResponseBody
|
@RequiresUser
|
public AjaxResponse addBorrowDetail(String keyId) {
|
try {
|
String strSql = "select * from view_all_utlization where id = " + keyId;
|
Map<String, Object> map = jdbcTemplate.queryForMap(strSql);
|
Long moduleId = Long.parseLong(map.get("module_id").toString());
|
Module module = moduleService.getByIdModule(moduleId);
|
QueryWrapper<Module> moduleQueryWrapper = new QueryWrapper<>();
|
moduleQueryWrapper.eq("module_id", module.getParentId());
|
moduleQueryWrapper.ne("parent_id", 0);
|
List<Module> moduleList = moduleService.list(moduleQueryWrapper);
|
AjaxResponse ajaxResponse = new AjaxResponse(true);
|
Map<String, Object> resultMap = new HashMap<String, Object>();
|
if (moduleList.size() == 0) {
|
// 案卷级利用
|
resultMap = addUtilizationForFile(Long.parseLong(keyId));
|
} else if (moduleList.size() > 0) {
|
// 文件级利用,需要反查案卷级信息
|
resultMap = addUtilizationForItem(module, Long.parseLong(keyId));
|
}
|
|
// String unit = resultMap.get("unit").toString().equals("卷") ? "0" : "1";
|
String unit = "0";
|
if (resultMap != null) {
|
StringBuilder sb = new StringBuilder();
|
sb.append("top.layer.open({");
|
sb.append(" title : '提示',");
|
sb.append(" type : 2,");
|
sb.append(" area : [ '700px', '220px' ],");
|
sb.append(" fixed : true, ");
|
sb.append(" content : 'common/commonTips?addNum=" + resultMap.get("addNum") + "&type=借阅&repeatNum=" + resultMap.get("repeatNum") + "&existFileNum=" + resultMap.get("existFileNum") + "&existItemNum=" + resultMap.get("existItemNum") + "&urlPath=borrow'");
|
sb.append("});");
|
Map<String, String> result = new HashMap<String, String>();
|
result.put("jsExpression", sb.toString());
|
result.put("totalNum", resultMap.get("existFileNum").toString());
|
ajaxResponse.setResult(result);
|
}
|
return ajaxResponse;
|
} catch (InvalidSessionException e) {
|
logger.error(e.getMessage(), e);
|
return new AjaxResponse(new ErrorInfo(e.getMessage()), false);
|
}
|
}
|
|
/**
|
* 资料借阅申请首页
|
*
|
* @return
|
*/
|
@RequestMapping(value = {"", "index"})
|
@RequiresUser
|
public ModelAndView index() {
|
Subject currentUser = SecurityUtils.getSubject();
|
Session session = currentUser.getSession();
|
User user = (User) session.getAttribute("user");
|
List<BorrowInfo> borrowInfoList = new ArrayList<>();
|
List<BorrowDetail> allBorrowDetailList = new ArrayList<>();
|
if (user != null) {
|
List<ParentBorrowInfo> parentBorrowInfoList = borrowDetailService.selectDistinctParentBorrowInfo(user.getUserId());
|
// 通过distinct获取案卷
|
for (ParentBorrowInfo parentBorrowInfo : parentBorrowInfoList) {
|
QueryWrapper<BorrowDetail> queryWrapper = new QueryWrapper<>();
|
queryWrapper.eq("form_id", 0).eq("create_user_id", user.getUserId()).eq("file_id", parentBorrowInfo.getFileId());
|
queryWrapper.orderByDesc("item_number");
|
List<BorrowDetail> borrowDetailList = borrowDetailService.list(queryWrapper);
|
BorrowInfo borrowInfo = new BorrowInfo();
|
borrowInfo.setParentBorrowInfo(parentBorrowInfo);
|
borrowInfo.setBorrowDetailList(borrowDetailList);
|
borrowInfoList.add(borrowInfo);
|
allBorrowDetailList.addAll(borrowDetailList);
|
}
|
}
|
ModelAndView mav = new ModelAndView("gh/borrow/index");
|
mav.addObject("curUserId", user.getUserId());
|
mav.addObject("curUserName", user.getTrueName());
|
mav.addObject("curUserTel", user.getMobilePhone());
|
mav.addObject("curDeptName", user.getDeptName());
|
mav.addObject("curDeptId", user.getDeptId());
|
mav.addObject("dateNow", DateTime.now());
|
// 默认加一个月
|
Calendar rightNow = Calendar.getInstance();
|
rightNow.setTime(new Date());
|
rightNow.add(Calendar.MONTH, 1);
|
Date utilizationValidDate = rightNow.getTime();
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
String reStr = sdf.format(utilizationValidDate);
|
|
mav.addObject("borrowValidDate", reStr);
|
|
mav.addObject("borrowInfoList", borrowInfoList);
|
mav.addObject("allBorrowDetailList", allBorrowDetailList);
|
return mav;
|
}
|
|
/**
|
* 保存明细信息
|
*
|
* @param
|
* @return
|
*/
|
@RequestMapping(value = "/saveBorrowDetail", produces = "application/json; charset=utf-8", method = RequestMethod.POST)
|
@ResponseBody
|
@RequiresUser
|
public Object saveBorrowDetail(Long formId, @RequestBody ArrayList<BorrowDetail> borrowDetailList) {
|
try {
|
//添加判断,判断一年是否已经
|
borrowDetailService.saveOrUpdateBatch(borrowDetailList);
|
return new AjaxResponse(true);
|
} catch (Exception e) {
|
logger.error(e.getMessage(), e);
|
return new AjaxResponse(new ErrorInfo(e.getMessage()), false);
|
}
|
}
|
|
/**
|
* 保存申请单信息
|
*
|
* @param
|
* @return
|
*/
|
@RequestMapping(value = "/saveBorrowForm", produces = "application/json; charset=utf-8", method = RequestMethod.POST)
|
@ResponseBody
|
@RequiresUser
|
public Object saveBorrowForm(@RequestBody BorrowForm borrowForm) {
|
try {
|
Subject currentUser = SecurityUtils.getSubject();
|
Session session = currentUser.getSession();
|
User user = (User) session.getAttribute("user");
|
borrowForm.setCreateUserId(user.getUserId());
|
borrowForm.setCreateUserName(user.getTrueName());
|
borrowForm.setCreateTime(new Date());
|
|
// 生成利用单编号
|
Date date = new Date();
|
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMM");
|
String preNum = dateFormat.format(date);
|
String maxApplyCode = borrowFormService.selectMaxApplyCode(preNum);
|
String applyCode = preNum + "0001";
|
if (StringUtils.isNotEmpty(maxApplyCode)) {
|
Integer newApplyCode = Integer.parseInt(maxApplyCode) + 1;
|
applyCode = newApplyCode.toString();
|
}
|
borrowForm.setApplyCode(applyCode);
|
borrowForm.setFlowState(0);
|
borrowForm.setState(0);
|
borrowForm.setDeleteState(0);
|
borrowForm.setBorrowDate(new Date());
|
borrowFormService.saveOrUpdate(borrowForm);
|
QueryWrapper<BorrowDetail> query = new QueryWrapper<>();
|
query.eq("form_id", 0).eq("electronic", 0).eq("paper", 0).eq("original", 0).eq("create_user_id", user.getUserId());
|
borrowDetailService.remove(query);
|
// 修改明细表formid
|
QueryWrapper<BorrowDetail> updateWrapper = new QueryWrapper<>();
|
updateWrapper.eq("form_id", 0).eq("create_user_id", user.getUserId());
|
|
BorrowDetail borrowDetail = new BorrowDetail();
|
borrowDetail.setFormId(borrowForm.getFormId());
|
borrowDetailService.update(borrowDetail, updateWrapper);
|
|
|
List<ParentBorrowInfo> parentBorrowInfos = borrowDetailService.selectDistinctParentBorrowInfoByFormId(borrowForm.getFormId());
|
borrowForm.setFileCount(parentBorrowInfos.size());
|
QueryWrapper<BorrowDetail> wrapper = new QueryWrapper<>();
|
wrapper.eq("form_id", borrowForm.getFormId());
|
int count = borrowDetailService.count(wrapper);
|
borrowForm.setItemCount(count);
|
borrowFormService.saveOrUpdate(borrowForm);
|
// 生成流程信息
|
Long moduleId = 1828968610175959041L;
|
Long tableId = 1828970885262917633L;
|
Long keyId = borrowForm.getFormId();
|
|
Long processDefinitionId = 1829455272978984961L;
|
String businessViewUrl = "borrow/borrowForm?formId=" + keyId;
|
|
Map<String, Object> dataMap = new HashMap<String, Object>();
|
dataMap.put("applyCode", borrowForm.getApplyCode());
|
dataMap.put("createTime", borrowForm.getCreateTime());
|
dataMap.put("createUserId", borrowForm.getCreateUserId());
|
dataMap.put("formId", borrowForm.getFormId());
|
dataMap.put("remark", borrowForm.getRemark());
|
dataMap.put("utilizationMethod", borrowForm.getUtilizationMethod());
|
FlowRuntimeExecution processInstance = runtimeService.startProcessInstanceById(processDefinitionId, moduleId, tableId, keyId, user.getUserId(), user.getTrueName(), businessViewUrl, dataMap);
|
// 完成第一步
|
List<FlowRuntimeTask> taskList = taskService.getTaskByProcessInstanceId(processInstance.getProcessInstanceId());
|
if (taskList != null && taskList.size() > 0) {
|
for (FlowRuntimeTask task : taskList) {
|
taskService.complete(task.getTaskId(), "", null, dataMap, null);
|
}
|
}
|
return new AjaxResponse(true);
|
} catch (Exception e) {
|
logger.error(e.getMessage(), e);
|
return new AjaxResponse(new ErrorInfo(e.getMessage()), false);
|
}
|
}
|
|
|
/**
|
* 档案利用申请单审核
|
*
|
* @param request
|
* @param response
|
* @return
|
* @throws Exception
|
*/
|
@RequestMapping(value = "/borrowForm")
|
@RequiresUser
|
public ModelAndView borrowForm(Long formId, Long processInstanceId, Long taskId, HttpServletRequest request, HttpServletResponse response) throws Exception {
|
ArchivesCustomConfig archivesCustomConfig = customConfigUtil.getConfigObj(ArchivesCustomConfig.class);
|
ModelAndView mav = new ModelAndView("gh/borrow/borrowForm");
|
BorrowForm borrowForm = borrowFormService.getById(formId);
|
List<BorrowInfo> borrowInfoList = new ArrayList<>();
|
List<ParentBorrowInfo> parentBorrowInfoList = borrowDetailService.selectDistinctParentBorrowInfoByFormId(formId);
|
List<BorrowDetail> allBorrowDetailList = new ArrayList<>();
|
if (borrowForm == null) {
|
throw new UserFriendlyException("申请单不存在", "申请单已被删除,无法打开!");
|
}
|
// 通过distinct获取案卷
|
for (ParentBorrowInfo parentBorrowInfo : parentBorrowInfoList) {
|
QueryWrapper<BorrowDetail> queryWrapper = new QueryWrapper<>();
|
queryWrapper.eq("form_id", formId).eq("file_id", parentBorrowInfo.getFileId());
|
queryWrapper.orderByAsc("item_number");
|
List<BorrowDetail> borrowDetailList = borrowDetailService.list(queryWrapper);
|
BorrowInfo archivalInfo = new BorrowInfo();
|
archivalInfo.setParentBorrowInfo(parentBorrowInfo);
|
archivalInfo.setBorrowDetailList(borrowDetailList);
|
borrowInfoList.add(archivalInfo);
|
allBorrowDetailList.addAll(borrowDetailList);
|
}
|
|
// 获取利用单模块
|
QueryWrapper<Module> borrowFormWrapper = new QueryWrapper<Module>();
|
borrowFormWrapper.eq("module_identify", "borrowForm");
|
Module borrowFormModule = moduleService.getOne(borrowFormWrapper);
|
|
mav.addObject("borrowFormModule", borrowFormModule);
|
mav.addObject("borrowInfoList", borrowInfoList);
|
mav.addObject("allBorrowDetailList", allBorrowDetailList);
|
|
mav.addObject("borrowForm", borrowForm);
|
mav.addObject("archivesCustomConfig", archivesCustomConfig);
|
// 处理流程信息
|
Subject currentUser = SecurityUtils.getSubject();
|
Session session = currentUser.getSession();
|
User user = (User) session.getAttribute("user");
|
|
Long moduleId = 1828968610175959041L;
|
Long tableId = 1828970885262917633L;
|
|
FlowRuntimeTask task = null;
|
FlowHistoryProcess historyProcess = null;
|
|
if (taskId != null) {
|
task = taskService.getTaskById(taskId);
|
|
if (task != null) {
|
processInstanceId = task.getProcessInstanceId();
|
mav.addObject("task", task);
|
mav.addObject("processInstanceId", processInstanceId);
|
mav.addObject("isEnd", false);
|
|
} else {
|
// 查找是否有历史任务记录
|
FlowHistoryTask historyTask = historyService.getHistoryTaskById(taskId);
|
if (historyTask != null) {
|
processInstanceId = historyTask.getProcessInstanceId();
|
} else {
|
|
}
|
}
|
}
|
|
// 查找流程是否已经结束
|
if (processInstanceId != null) {
|
historyProcess = historyService.getHistoryProcessByProcessInstanceId(processInstanceId);
|
} else if (moduleId != null && tableId != null && formId != null) {
|
historyProcess = historyService.getHistoryProcessByBusinessInfo(moduleId, tableId, formId);
|
}
|
|
if (historyProcess != null) {
|
processInstanceId = historyProcess.getProcessInstanceId();
|
mav.addObject("processInstanceId", processInstanceId);
|
|
// 如果流程已经结束
|
if (historyProcess.getEndTime() != null) {
|
|
mav.addObject("isEnd", true);
|
} else {
|
mav.addObject("isEnd", false);
|
// 查找是否为自己待办
|
List<FlowRuntimeTask> taskList = taskService.findTasksByProcessInstanceIdAndUserId(user.getUserId(), historyProcess.getProcessInstanceId());
|
if (taskList != null && taskList.size() > 0) {
|
mav.addObject("task", taskList.get(0));
|
mav.addObject("isEnd", false);
|
}
|
}
|
} else {
|
// throw new UserFriendlyException("找不到流程实例", "流程实例不存在或已完成!");
|
}
|
|
// 读取流程历史信息
|
if (task != null || historyProcess != null) {
|
List<FlowHistoryTask> historyTaskList = historyService.getFlowHistoryTaskByProcessInstanceId(processInstanceId);
|
mav.addObject("historyTaskList", historyTaskList);
|
}
|
//
|
// String utilizeApprovePermission = "BusinessManage.borrowForm.UtilizeApprove";
|
// boolean permitted = currentUser.isPermitted(utilizeApprovePermission);
|
|
// mav.addObject("approvePermission", currentUser.isPermitted(utilizeApprovePermission));
|
mav.addObject("approvePermission", true);
|
|
return mav;
|
}
|
|
|
/**
|
* 我的借阅单首页
|
*
|
* @param request
|
* @param response
|
* @return
|
* @throws Exception
|
*/
|
@RequestMapping(value = "/myBorrowFormIndex")
|
@RequiresUser
|
public ModelAndView myBorrowFormIndex(HttpServletRequest request, HttpServletResponse response) throws Exception {
|
ModelAndView mav = new ModelAndView("gh/borrow/myBorrowFormIndex");
|
return mav;
|
}
|
|
|
/**
|
* 分页获取我的利用申请列表
|
*
|
* @param
|
* @param pageInput
|
* @return
|
*/
|
@RequestMapping("/getMyBorrowFormList")
|
@ResponseBody
|
@RequiresUser
|
public Object getMyBorrowFormList(Integer flowState, PagedSortedAndFilteredInputDto pageInput) {
|
Subject currentUser = SecurityUtils.getSubject();
|
Session session = currentUser.getSession();
|
User user = (User) session.getAttribute("user");
|
QueryWrapper<BorrowForm> query = new QueryWrapper<>();
|
if (flowState != null && flowState != -2) {
|
query.eq("flow_state", flowState);
|
}
|
|
query.nested(qy -> qy.eq("create_user_id", user.getUserId()).or().eq("borrow_user_id", user.getUserId()));
|
|
IPage<BorrowForm> utilizationFormIPage;
|
String searchText = pageInput.getSearchText();
|
if (searchText != null && searchText != "") {
|
query.nested(i -> i.like("apply_code", searchText).or().like("borrow_user_name", searchText));
|
}
|
String sort = pageInput.getSort();
|
String order = pageInput.getOrder();
|
if (sort != null && sort != "") {
|
query.orderBy(true, !order.equals("desc"), "apply_code");
|
}
|
DataTableVO<BorrowForm> dto = new DataTableVO<>();
|
if (pageInput.getPage() != 0 && pageInput.getRows() != 0) {
|
Page<BorrowForm> page = new Page<>(pageInput.getPage(), pageInput.getRows());
|
utilizationFormIPage = borrowFormService.page(page, query);
|
dto.setTotal(utilizationFormIPage.getTotal());
|
dto.setRows(utilizationFormIPage.getRecords());
|
} else {
|
List<BorrowForm> utilizationFormList = borrowFormService.list(query);
|
dto.setTotal(utilizationFormList.size());
|
dto.setRows(utilizationFormList);
|
}
|
return dto;
|
}
|
|
/**
|
* 删除借阅单
|
*
|
* @param formIdList
|
* @return
|
*/
|
@RequestMapping(value = "/deleteBorrowForm", produces = "application/json; charset=utf-8", method = RequestMethod.POST)
|
@ResponseBody
|
@RequiresUser
|
public Object deleteBorrowForm(@RequestBody ArrayList<Long> formIdList) {
|
try {
|
borrowFormService.removeByIds(formIdList);
|
for (Long formId : formIdList) {
|
QueryWrapper<BorrowDetail> query = new QueryWrapper<>();
|
query.eq("form_id", formId);
|
borrowDetailService.remove(query);
|
// 删除流程实例
|
runtimeService.deleteProcessInstanceByBusinessInfo(1828968610175959041L, 1828970885262917633L, formId);
|
}
|
return new AjaxResponse(true);
|
} catch (Exception e) {
|
logger.error(e.getMessage(), e);
|
return new AjaxResponse(new ErrorInfo(e.getMessage()), false);
|
}
|
}
|
|
|
/**
|
* 删除明细信息
|
*
|
* @param fileId
|
* @return
|
*/
|
@RequestMapping(value = "/deleteBorrowDetail", produces = "application/json; charset=utf-8", method = RequestMethod.POST)
|
@ResponseBody
|
@RequiresUser
|
public Object deleteBorrowDetail(Long fileId) {
|
try {
|
QueryWrapper<BorrowDetail> query = new QueryWrapper<>();
|
query.eq("file_id", fileId);
|
query.eq("form_id", 0L);
|
borrowDetailService.remove(query);
|
return new AjaxResponse(true);
|
} catch (Exception e) {
|
logger.error(e.getMessage(), e);
|
return new AjaxResponse(new ErrorInfo(e.getMessage()), false);
|
}
|
}
|
|
/**
|
* 删除明细信息通过明细id
|
*
|
* @param detailId
|
* @return
|
*/
|
@RequestMapping(value = "/deleteBorrowDetailById", produces = "application/json; charset=utf-8", method = RequestMethod.POST)
|
@ResponseBody
|
@RequiresUser
|
public Object deleteBorrowDetailById(Long detailId) {
|
try {
|
borrowDetailService.removeById(detailId);
|
return new AjaxResponse(true);
|
} catch (Exception e) {
|
logger.error(e.getMessage(), e);
|
return new AjaxResponse(new ErrorInfo(e.getMessage()), false);
|
}
|
}
|
|
/**
|
* 人工添加申请单
|
*
|
* @param
|
* @return
|
*/
|
@RequestMapping(value = "/addBorrowForm")
|
@RequiresUser
|
public ModelAndView addBorrowForm() {
|
ModelAndView mav = new ModelAndView("gh/borrow/addBorrowForm");
|
Subject currentUser = SecurityUtils.getSubject();
|
Session session = currentUser.getSession();
|
User user = (User) session.getAttribute("user");
|
mav.addObject("curUserId", user.getUserId());
|
mav.addObject("curUserName", user.getTrueName());
|
mav.addObject("curUserTel", user.getMobilePhone());
|
mav.addObject("curDeptName", user.getDeptName());
|
mav.addObject("curDeptId", user.getDeptId());
|
return mav;
|
}
|
|
/**
|
* 分页获取人工添加明细列表
|
*
|
* @param
|
* @param pageInput
|
* @return
|
*/
|
@RequestMapping("/getBorrowDetailListByPeople")
|
@ResponseBody
|
@RequiresUser
|
public Object getBorrowDetailListByPeople(PagedSortedAndFilteredInputDto pageInput, Long formId) {
|
Subject currentUser = SecurityUtils.getSubject();
|
Session session = currentUser.getSession();
|
User user = (User) session.getAttribute("user");
|
QueryWrapper<BorrowDetail> query = new QueryWrapper<>();
|
if (formId != null && formId > 0) {
|
query.eq("form_id", formId);
|
} else if (formId != null && formId < 0) {
|
query.gt("form_id", 0);
|
} else {
|
query.eq("form_id", 0).eq("create_user_id", user.getUserId());
|
}
|
query.eq("file_title", "人工添加");
|
List<BorrowDetail> list = borrowDetailService.list(query);
|
return list;
|
}
|
|
public Map<String, Object> addUtilizationForFile(Long keyId) {
|
Subject currentUser = SecurityUtils.getSubject();
|
Session session = currentUser.getSession();
|
User user = (User) session.getAttribute("user");
|
|
Map<String, Object> resultMap = new HashMap<>();
|
int addNum = 0;
|
int repeatNum = 0;
|
int existItemNum = 0;
|
|
QueryWrapper<BorrowDetail> queryWrapper = new QueryWrapper<>();
|
queryWrapper.eq("form_id", 0);
|
queryWrapper.eq("create_user_id", user.getUserId());
|
int itemCount = borrowDetailService.count(queryWrapper);
|
existItemNum += itemCount;
|
queryWrapper.eq("file_id", keyId);
|
List<BorrowDetail> borrowDetailList = borrowDetailService.list(queryWrapper);
|
if (borrowDetailList.size() == 0) {
|
CatAjjxx catAjjxx = catAjjxxService.getById(keyId);
|
Integer cgwjxxCount = borrowDetailService.setCgwjxx(catAjjxx);
|
Integer yswjxxCount = borrowDetailService.setYswjxx(catAjjxx);
|
addNum++;
|
existItemNum += cgwjxxCount + yswjxxCount;
|
} else {
|
repeatNum++;
|
}
|
|
String strSql = "select distinct file_id from UTL_BORROW_DETAIL where form_id=0 and create_user_id=" + user.getUserId();
|
List<Map<String, Object>> parentMapList = jdbcTemplate.queryForList(strSql);
|
resultMap.put("existFileNum", parentMapList.size());
|
resultMap.put("existItemNum", existItemNum);
|
resultMap.put("addNum", addNum);
|
resultMap.put("repeatNum", repeatNum);
|
return resultMap;
|
}
|
|
public Map<String, Object> addUtilizationForItem(Module module, Long keyId) {
|
Subject currentUser = SecurityUtils.getSubject();
|
Session session = currentUser.getSession();
|
User user = (User) session.getAttribute("user");
|
|
int addNum = 0;
|
int repeatNum = 0;
|
int existItemNum = 0;
|
|
ArrayList<Long> longs = new ArrayList<>();
|
longs.add(keyId);
|
Map<String, Object> resultMap = new HashMap<>();
|
QueryWrapper<BorrowDetail> queryWrapper = new QueryWrapper<>();
|
queryWrapper.eq("form_id", 0);
|
queryWrapper.eq("create_user_id", user.getUserId());
|
int itemCount = borrowDetailService.count(queryWrapper);
|
existItemNum += itemCount;
|
queryWrapper.eq("item_id", keyId);
|
List<BorrowDetail> borrowDetailList = borrowDetailService.list(queryWrapper);
|
if (borrowDetailList.size() == 0) {
|
String mainTableName = module.getMainTableName();
|
if (mainTableName.equals("CAT_ITEM_CGWJXX")) {
|
Integer cgwjxxCount = borrowDetailService.setCgwjxxByIds(longs);
|
existItemNum += cgwjxxCount;
|
} else if (mainTableName.equals("CAT_ITEM_YSWJXX")) {
|
Integer cgwjxxCount = borrowDetailService.setYswjxxByIds(longs);
|
existItemNum += cgwjxxCount;
|
}
|
}
|
|
|
resultMap.put("addNum", 1);
|
resultMap.put("repeatNum", 0);
|
resultMap.put("existItemNum", existItemNum);
|
String strSql = "select distinct file_id from UTL_BORROW_DETAIL where form_id=0 and create_user_id=" + user.getUserId();
|
List<Map<String, Object>> parentMapList = jdbcTemplate.queryForList(strSql);
|
resultMap.put("existFileNum", parentMapList.size());
|
return resultMap;
|
}
|
}
|