|
@@ -1,49 +1,132 @@
|
|
|
package com.ruoyi.zzb.zdcx.service;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.ruoyi.common.annotation.DataSource;
|
|
|
import com.ruoyi.common.enums.DataSourceType;
|
|
|
-import com.ruoyi.common.utils.StringUtils;
|
|
|
+import com.ruoyi.zzb.study.domain.BasePersonInfo;
|
|
|
+import com.ruoyi.zzb.study.mapper.BasePersonInfoMapper;
|
|
|
import com.ruoyi.zzb.zdcx.domain.Zdcx;
|
|
|
import com.ruoyi.zzb.zdcx.mapper.ZdcxMapper;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.boot.autoconfigure.web.format.DateTimeFormatters;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
-import java.util.Date;
|
|
|
-import java.util.List;
|
|
|
+import java.util.*;
|
|
|
|
|
|
+@Slf4j
|
|
|
@Service
|
|
|
@DataSource(value = DataSourceType.SLAVE)
|
|
|
public class ZdcxService {
|
|
|
|
|
|
@Autowired
|
|
|
private ZdcxMapper zdcxMapper;
|
|
|
+ @Autowired
|
|
|
+ private BasePersonInfoMapper basePersonInfoMapper;
|
|
|
|
|
|
- public List<Zdcx> getByParams(Zdcx zdcx){
|
|
|
+ /**
|
|
|
+ * 根据条件分页查询制度信息
|
|
|
+ * @param zdcx
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public Map<String, Object> getDataByPage(Zdcx zdcx){
|
|
|
+ Map<String, Object> rspMap = new HashMap<>();
|
|
|
String docId = zdcx.getDocId();
|
|
|
String title = zdcx.getTitle();
|
|
|
- String zhidingDept = zdcx.getZhidingDept();
|
|
|
- Date createTime = zdcx.getCreateTime();
|
|
|
+ String publishDept = zdcx.getPublishDept();
|
|
|
+ String createTime = zdcx.getCreateTime();
|
|
|
String content = zdcx.getContent();
|
|
|
+ // 查询标志位 0:and,1:or
|
|
|
+ Integer queryFlag = zdcx.getQueryFlag();
|
|
|
+ Integer pageNo = zdcx.getPageNo();
|
|
|
+ Integer pageSize = zdcx.getPageSize();
|
|
|
|
|
|
QueryWrapper<Zdcx> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.eq("FLAG", 1);
|
|
|
if(StringUtils.isNotBlank(docId)){
|
|
|
+ if (queryFlag != 0){ // or
|
|
|
+ queryWrapper.or();
|
|
|
+ }
|
|
|
queryWrapper.eq("DOC_ID", docId);
|
|
|
}
|
|
|
if(StringUtils.isNotBlank(title)){
|
|
|
+ if (queryFlag != 0){
|
|
|
+ queryWrapper.or();
|
|
|
+ }
|
|
|
queryWrapper.eq("TITLE", title);
|
|
|
}
|
|
|
- if(StringUtils.isNotBlank(zhidingDept)){
|
|
|
- queryWrapper.eq("ZHIDINGDEPT", zhidingDept);
|
|
|
+ if(StringUtils.isNotBlank(publishDept)){
|
|
|
+ if (queryFlag != 0){
|
|
|
+ queryWrapper.or();
|
|
|
+ }
|
|
|
+ queryWrapper.eq("PUBLISH_DEPT", publishDept);
|
|
|
}
|
|
|
-// if(null != createTime){
|
|
|
-// queryWrapper.eq("CREATETIME", createTime);
|
|
|
-// }
|
|
|
if(StringUtils.isNotBlank(content)){
|
|
|
+ if (queryFlag != 0){
|
|
|
+ queryWrapper.or();
|
|
|
+ }
|
|
|
queryWrapper.like("CONTENT", content);
|
|
|
}
|
|
|
- List<Zdcx> dataList = zdcxMapper.selectList(queryWrapper);
|
|
|
- return dataList;
|
|
|
+ Page<Zdcx> page = new Page<>(pageNo, pageSize);
|
|
|
+ IPage<Zdcx> zdcxPage = zdcxMapper.selectPage(page, queryWrapper);
|
|
|
+ rspMap.put("list", zdcxPage.getRecords());
|
|
|
+ rspMap.put("count", zdcxPage.getTotal());
|
|
|
+
|
|
|
+ /*List<Zdcx> dataList = zdcxMapper.getDataByPage(zdcx);
|
|
|
+ Long count = zdcxMapper.getDataCount(zdcx);
|
|
|
+ rspMap.put("list", dataList);
|
|
|
+ rspMap.put("count", count);*/
|
|
|
+ return rspMap;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据警号查询当前用户信息
|
|
|
+ * @param policeNo
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public BasePersonInfo getDataByParams(String policeNo){
|
|
|
+ QueryWrapper<BasePersonInfo> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.eq("POLICE_NO", policeNo);
|
|
|
+ return basePersonInfoMapper.selectOne(queryWrapper);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据参数保存一条制度规范信息
|
|
|
+ * @param reqBody
|
|
|
+ * @param basePersonInfo
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public boolean insertStandardInfo(JSONObject reqBody, BasePersonInfo basePersonInfo){
|
|
|
+ Zdcx zdcx = new Zdcx();
|
|
|
+ // 制度信息
|
|
|
+ zdcx.setId(UUID.randomUUID().toString().replace("-", ""));
|
|
|
+ zdcx.setDocId(reqBody.getString("docId"));
|
|
|
+ zdcx.setTitle(reqBody.getString("title"));
|
|
|
+ zdcx.setPublishDept(reqBody.getString("publishDept"));
|
|
|
+ zdcx.setContent(reqBody.getString("content"));
|
|
|
+ zdcx.setIsDelete(0);
|
|
|
+ zdcx.setFlag(1);
|
|
|
+ // 录入人信息
|
|
|
+ zdcx.setCreateUserId(basePersonInfo.getUserId());
|
|
|
+ zdcx.setCreateUserName(basePersonInfo.getName());
|
|
|
+ zdcx.setCreateUserPoliceNo(basePersonInfo.getPoliceNo());
|
|
|
+ zdcx.setCreateDeptName(basePersonInfo.getDeptName());
|
|
|
+ zdcx.setCreateDeptCode(basePersonInfo.getDeptCode());
|
|
|
+ zdcx.setCreateParentDeptName(basePersonInfo.getParentDeptName());
|
|
|
+ zdcx.setCreateParentDeptCode(basePersonInfo.getParentDeptCode());
|
|
|
+ try {
|
|
|
+ if (zdcxMapper.insert(zdcx) > 0) {
|
|
|
+ log.info("制度规范信息保存成功");
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ }catch (Exception e){
|
|
|
+ log.error("制度规范信息保存时发生异常", e);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
}
|
|
|
+
|
|
|
}
|