Merge branch 'develop_master' into develop_3

This commit is contained in:
super_liu
2021-07-05 11:10:43 +08:00
224 changed files with 15825 additions and 798 deletions
+50
View File
@@ -35,5 +35,55 @@
<version>3.1.0</version>
<scope>compile</scope>
</dependency>
<!-- poi -->
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi</artifactId>
<version>4.1.2</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>4.1.2</version>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml-schemas</artifactId>
<version>4.1.2</version>
<exclusions>
<exclusion>
<groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-scratchpad</artifactId>
<version>4.1.2</version>
</dependency>
<dependency>
<groupId>org.apache.pdfbox</groupId>
<artifactId>pdfbox</artifactId>
<version>1.8.8</version>
</dependency>
<dependency>
<groupId>com.itextpdf</groupId>
<artifactId>itextpdf</artifactId>
<version>5.5.13</version>
</dependency>
<dependency>
<groupId>com.zip4j</groupId>
<artifactId>zip4j</artifactId>
<scope>system</scope>
<version>1.3.1</version>
<systemPath>${basedir}/src/main/lib/zip4j-1.3.1.jar</systemPath>
</dependency>
</dependencies>
</project>
@@ -0,0 +1,223 @@
package com.adc.da.common;
import com.adc.da.base.entity.BaseEntity;
import com.fasterxml.jackson.annotation.JsonFormat;
import java.util.Date;
/**
* <b>功能:</b>OT_CONVERT_MQ OtConvertMqEOEntity<br>
* <b>作者:</b>code generator<br>
* <b>日期:</b> 2018-09-25 <br>
* <b>版权所有:<b>版权归北京卡达克数据技术中心所有。<br>
*/
public class ConvertMqEO extends BaseEntity {
@JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
private Date modifyTime;
@org.springframework.format.annotation.DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
private Date creationTime;
private Integer validFlag;
private String attId;
private String filePath;
private String fileOriginPath;
private String userId;
private Integer mqState;
private String mqCode;
private String id;
private String addOrUp;
//向文件表添加信息
private String lawsId;
private String resId;
private String convertType;
private String pdfPath;
private String pdfId;
private String fileSuffix;
private String standFileClassify;
private String oriAttId;
private String lawsFileClassify;
private int againNum;
/** **/
public Integer getValidFlag() {
return this.validFlag;
}
/** **/
public void setValidFlag(Integer validFlag) {
this.validFlag = validFlag;
}
/** **/
public String getAttId() {
return this.attId;
}
/** **/
public void setAttId(String attId) {
this.attId = attId;
}
/** **/
public String getFilePath() {
return this.filePath;
}
/** **/
public void setFilePath(String filePath) {
this.filePath = filePath;
}
/** **/
public String getUserId() {
return this.userId;
}
/** **/
public void setUserId(String userId) {
this.userId = userId;
}
/** **/
public Integer getMqState() {
return this.mqState;
}
/** **/
public void setMqState(Integer mqState) {
this.mqState = mqState;
}
/** **/
public String getMqCode() {
return this.mqCode;
}
/** **/
public void setMqCode(String mqCode) {
this.mqCode = mqCode;
}
/** **/
public String getId() {
return this.id;
}
/** **/
public void setId(String id) {
this.id = id;
}
public String getFileOriginPath() {
return fileOriginPath;
}
public void setFileOriginPath(String fileOriginPath) {
this.fileOriginPath = fileOriginPath;
}
public String getLawsId() {
return lawsId;
}
public void setLawsId(String lawsId) {
this.lawsId = lawsId;
}
public String getResId() {
return resId;
}
public void setResId(String resId) {
this.resId = resId;
}
public String getConvertType() {
return convertType;
}
public void setConvertType(String convertType) {
this.convertType = convertType;
}
public String getPdfPath() {
return pdfPath;
}
public void setPdfPath(String pdfPath) {
this.pdfPath = pdfPath;
}
public String getAddOrUp() {
return addOrUp;
}
public void setAddOrUp(String addOrUp) {
this.addOrUp = addOrUp;
}
public String getPdfId() {
return pdfId;
}
public void setPdfId(String pdfId) {
this.pdfId = pdfId;
}
public Date getModifyTime() {
return modifyTime;
}
public void setModifyTime(Date modifyTime) {
this.modifyTime = modifyTime;
}
public Date getCreationTime() {
return creationTime;
}
public void setCreationTime(Date creationTime) {
this.creationTime = creationTime;
}
public String getFileSuffix() {
return fileSuffix;
}
public void setFileSuffix(String fileSuffix) {
this.fileSuffix = fileSuffix;
}
public String getStandFileClassify() {
return standFileClassify;
}
public void setStandFileClassify(String standFileClassify) {
this.standFileClassify = standFileClassify;
}
public String getOriAttId() {
return oriAttId;
}
public void setOriAttId(String oriAttId) {
this.oriAttId = oriAttId;
}
public int getAgainNum() {
return againNum;
}
public void setAgainNum(int againNum) {
this.againNum = againNum;
}
public String getLawsFileClassify() {
return lawsFileClassify;
}
public void setLawsFileClassify(String lawsFileClassify) {
this.lawsFileClassify = lawsFileClassify;
}
}
@@ -0,0 +1,10 @@
package com.adc.da.mq.dao;
import com.adc.da.common.ConvertMqEO;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
public interface OtConvertEODao extends BaseMapper<ConvertMqEO> {
int deleteByAttId(String value);
}
@@ -0,0 +1,77 @@
package com.adc.da.mq.service;
import com.adc.da.common.ConvertMqEO;
import com.adc.da.mq.dao.OtConvertEODao;
import com.adc.da.util.UUIDUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.Date;
import java.util.HashMap;
import java.util.Map;
@Component
public class CreateMQService {
@Autowired
private AmqpTemplate rabbitTemplate;
@Autowired
private OtConvertEODao otConvertEODao;
/**
* @Author yangxuenan
* @Description 创建消息队列
* Date 2018/8/24 13:59
* @Param [convert, convertType]
* @return int
**/
public void sendMQ(ConvertMqEO convert) throws Exception{
String otId = UUIDUtils.randomUUID20();
//向OT_CONVERT_EO表中添加/修改数据
//判断用户是初次发送还是重新发送,初次将添加到数据库,重新发送将修改原数据信息
convert.setMqState(0);
convert.setModifyTime(new Date());
if("0".equals(convert.getAddOrUp()) && StringUtils.isEmpty(convert.getId())){
convert.setId(otId);
convert.setMqCode(convert.getConvertType());
convert.setCreationTime(new Date());
convert.setValidFlag(0);
otConvertEODao.insert(convert);
} else {
otConvertEODao.updateById(convert);
}
//将数据信息保存并发送给消息队列
Map<String,Object> convertInfo = new HashMap<String,Object>();
//标准/政策ID
convertInfo.put("lawsId", convert.getLawsId());
//标准/政策关联的res表ID
convertInfo.put("resId", convert.getResId());
//文档的ID
convertInfo.put("attId", convert.getAttId());
//判断当前操作是新增还是修改
convertInfo.put("addUpFlag", convert.getAddOrUp());
//资源类型(标准,政策,企标)
convertInfo.put("convertType", convert.getConvertType());
//文档路径
convertInfo.put("path", convert.getFilePath());
convertInfo.put("standFileClassify", convert.getStandFileClassify());
convertInfo.put("lawsFileClassify", convert.getLawsFileClassify());
if("0".equals(convert.getAddOrUp())){
//otId在转换表中数据ID
convertInfo.put("otId", otId);
//在stand_file等资源与文件关联表中转换成功的pdf数据ID
convertInfo.put("standFilePdfId", UUIDUtils.randomUUID20());
convertInfo.put("againNum",0);
} else {
convertInfo.put("otId", convert.getId());
convertInfo.put("standFilePdfId", convert.getPdfId());
convertInfo.put("againNum",convert.getAgainNum());
}
//发送消息队列
this.rabbitTemplate.convertAndSend("convert-exchange_SQ_GSAR", "convert-key_SQ_GSAR", convertInfo);
}
}
@@ -0,0 +1,32 @@
package com.adc.da.mq.service;
import net.sf.json.JSONObject;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.HashMap;
import java.util.Map;
@Component
public class CreateStandMQService {
@Autowired
private AmqpTemplate rabbitTemplate;
/**
*
* @param sarStandardsInfoEO 标准实体
* @param addOrUpdate
* @throws Exception
*/
public void sendStandMQ(Object sarStandardsInfoEO, String addOrUpdate) throws Exception{
JSONObject json = JSONObject.fromObject(sarStandardsInfoEO);
String sarStandardsInfoStr = json.toString();
Map<String,Object> standMap = new HashMap<String,Object>();
standMap.put("sarStandards", sarStandardsInfoStr);
standMap.put("addOrUpdate", addOrUpdate);
//发送消息队列
this.rabbitTemplate.convertAndSend("stand-exchange_SQ_GSAR", "stand-key_SQ_GSAR", standMap);
}
}
@@ -0,0 +1,316 @@
package com.adc.da.mq.service;
import com.adc.da.slrs.otSvpps.entity.OtSvpps;
import com.adc.da.slrs.otSvpps.service.IOtSvppsService;
import com.adc.da.slrs.sarStandardsInfo.entity.SarStandardsInfo;
import com.adc.da.slrs.sarStandardsInfo.service.ISarStandardsInfoService;
import com.adc.da.slrs.sysInfo.service.SysInfoEOService;
import com.rabbitmq.client.Channel;
import net.sf.json.JSONObject;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.amqp.support.AmqpHeaders;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.Message;
import org.springframework.stereotype.Component;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Component
public class SendStandMQService {
@Autowired
private ISarStandardsInfoService sarStandardsInfoService;
@Autowired
private SysInfoEOService sysInfoEOService;
@Autowired
private IOtSvppsService otSvppsEOService;
private static final Logger logger = LoggerFactory.getLogger(SendStandMQService.class);
@RabbitListener(bindings = @QueueBinding(
value = @Queue(value = "createStandMQ_SQ_GSAR", durable = "true"),
exchange = @Exchange(value = "stand-exchange_SQ_GSAR", ignoreDeclarationExceptions = "true"),
key = "stand-key_SQ_GSAR"))
public void createMQ(Map<String,Object> standMap, Message message, Channel channel) throws Exception{
try{
try{
Thread.sleep(5000);
insertOrUpdateStandInfo(standMap);
}catch(InterruptedException e){
logger.error(e.toString());
Thread.currentThread().interrupt();
}
} catch (Exception e) {
logger.error("搜索中心标准消息队列进入添加数据方法前失败!");
logger.error(e.getMessage(),e);
}finally {
Long tag = (Long) message.getHeaders().get(AmqpHeaders.DELIVERY_TAG);
channel.basicAck(tag,false);
logger.debug("消息确认成功!!!!!!!!!");
}
}
public void insertOrUpdateStandInfo(Map<String,Object> standMap){
String addOrUpdate = standMap.get("addOrUpdate").toString();
String sarStandards = standMap.get("sarStandards").toString();
JSONObject jsonobject = JSONObject.fromObject(sarStandards);
SarStandardsInfo infoEO = (SarStandardsInfo) JSONObject.toBean(jsonobject,SarStandardsInfo.class);
String attr = infoEO.getSarStandAttrEOStr();
JSONObject jsonobject1 = JSONObject.fromObject(attr);
Map<String,Object> map = (Map)jsonobject1;
String GZZXX = String.valueOf(map.get("GZZXX"));
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
// 往索引表中插入数据
String getCodeName = "";
Map<String,Object> saveMap = new HashMap<>();
String baseSearchContent = "";
// 开始存放数据
saveMap.put("id",infoEO.getId());
saveMap.put("BYYBJ", map.getOrDefault("BYYBJ", ""));
saveMap.put("BDTBH", map.getOrDefault("BDTBH", ""));
saveMap.put("country",infoEO.getCountry());
if (StringUtils.isNotEmpty(infoEO.getCountry())) {
String codeName = sysInfoEOService.getDicNamesByCodes(infoEO.getCountry());
saveMap.put("countryShow",codeName);
}
saveMap.put("standSort",infoEO.getStandSort());
saveMap.put("stand_sort",infoEO.getStandSort());
if (StringUtils.isNotEmpty(infoEO.getStandSort())) {
String codeName = sysInfoEOService.getDicNamesByCodes(infoEO.getStandSort());
saveMap.put("standSortShow",codeName);
getCodeName = codeName;
}
saveMap.put("standNumber",infoEO.getStandNumber());
saveMap.put("stand_number",infoEO.getStandNumber());
saveMap = dealNumberMsg(saveMap,infoEO,getCodeName);
saveMap.put("standYear",infoEO.getStandYear());
saveMap.put("stand_year",infoEO.getStandYear());
saveMap.put("nameshow",infoEO.getStandName());
saveMap.put("stand_name",infoEO.getStandName());
saveMap.put("standEnName",infoEO.getStandEnName());
saveMap.put("stand_en_name",infoEO.getStandEnName());
if ("1".equals(infoEO.getIsRelateAccess())) {
saveMap.put("isRelateAccess","A" );
}else{
saveMap.put("isRelateAccess","B" );
}
if (StringUtils.isNotEmpty(infoEO.getStandState())) {
String codeName = sysInfoEOService.getDicNamesByCodes(infoEO.getStandState());
saveMap.put("standstateshow",codeName);
}
saveMap.put("issueTime",infoEO.getIssueTime());
String newDate = infoEO.getIssueTime();
if (StringUtils.isNotBlank(infoEO.getIssueTime()) && StringUtils.isNotBlank(infoEO.getIssueTime().trim()) && infoEO.getIssueTime().trim().length()>10) {
newDate = infoEO.getIssueTime().trim().substring(0,10);
}
saveMap.put("issue_time",newDate);
Date issue_time_data = null;
if (StringUtils.isNotBlank(infoEO.getIssueTime())) {
try {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
issue_time_data = format.parse(newDate+" 00:00:00");
} catch (ParseException ignored) {
}
}
if (issue_time_data != null) {
saveMap.put("issue_time_data",issue_time_data.getTime());
}else{
saveMap.put("issue_time_data",0L);
}
saveMap.put("synopsis",infoEO.getSynopsis());
saveMap.put("standType",infoEO.getStandType());
// 自定义属性字段
String sarStandAttrEOStr = infoEO.getSarStandAttrEOStr();
Map<String,Object> attrInfoMap = JSONObject.fromObject(sarStandAttrEOStr);
if (attrInfoMap != null && !attrInfoMap.isEmpty()) {
attrInfoMap = sysInfoEOService.changeSelectInfo(attrInfoMap, "stand",baseSearchContent);
saveMap.putAll(attrInfoMap);
}
saveMap.put("baseSearchContent",baseSearchContent);
saveMap.put("type","stand");
saveMap.put("validFlag","0");
saveMap.put("content",infoEO.getFileIds());
saveMap.put("CHJL",infoEO.getCHJL());
String SVPPSSting = "";
if (attrInfoMap != null) {
if (attrInfoMap.containsKey("SVPPS")){
String svpps = String.valueOf(attrInfoMap.get("SVPPS"));
List<String> ids = new ArrayList<>(Arrays.asList(svpps.split(",")));
for (String id: ids){
String num = "";
try {
OtSvpps otSvppsEO = otSvppsEOService.getById(id);
if (null != otSvppsEO) {
if ("NA".equals(otSvppsEO.getTNum())) {
if ("NA".equals(otSvppsEO.getSNum())) {
num = otSvppsEO.getFNum();
} else {
num = otSvppsEO.getSNum();
}
} else {
num = otSvppsEO.getTNum();
}
}
if ("".equals(SVPPSSting)){
SVPPSSting = num;
}else {
SVPPSSting = SVPPSSting + "," + num;
}
} catch (Exception e) {
e.printStackTrace();
}
}
saveMap.put("SVPPSName",SVPPSSting);
}
}
Date XCXSSRQ_data = null;
if (StringUtils.isNotBlank(String.valueOf(saveMap.get("XCXSSRQ")))) {
try {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
if (String.valueOf(saveMap.get("XCXSSRQ")).trim().length()>10) {
XCXSSRQ_data = format.parse(String.valueOf(saveMap.get("XCXSSRQ")).trim().substring(0,10) + " 00:00:00");
saveMap.put("XCXSSRQ",String.valueOf(saveMap.get("XCXSSRQ")).trim().substring(0,10));
}else{
XCXSSRQ_data = format.parse(String.valueOf(saveMap.get("XCXSSRQ")).trim() + " 00:00:00");
saveMap.put("XCXSSRQ",String.valueOf(saveMap.get("XCXSSRQ")).trim());
}
} catch (ParseException ignored) {
}
}
if (XCXSSRQ_data != null) {
saveMap.put("XCXSSRQ_data",XCXSSRQ_data.getTime());
}else{
saveMap.put("XCXSSRQ_data",0L);
}
saveMap.put("XCXSSRQ",String.valueOf(saveMap.get("XCXSSRQ")+" "));
Date ZCCSSRQ_data = null;
if (StringUtils.isNotBlank(String.valueOf(saveMap.get("ZCCSSRQ")))) {
try {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
if (String.valueOf(saveMap.get("ZCCSSRQ")).trim().length()>10) {
ZCCSSRQ_data = format.parse(String.valueOf(saveMap.get("ZCCSSRQ")).trim().substring(0, 10) + " 00:00:00");
saveMap.put("ZCCSSRQ",String.valueOf(saveMap.get("ZCCSSRQ")).trim().substring(0, 10));
}else {
ZCCSSRQ_data = format.parse(String.valueOf(saveMap.get("ZCCSSRQ")).trim() + " 00:00:00");
saveMap.put("ZCCSSRQ",String.valueOf(saveMap.get("ZCCSSRQ")).trim());
}
} catch (ParseException ignored) {
}
}
if (ZCCSSRQ_data != null) {
saveMap.put("ZCCSSRQ_data",ZCCSSRQ_data.getTime());
}else{
saveMap.put("ZCCSSRQ_data",0L);
}
saveMap.put("ZCCSSRQ",String.valueOf(saveMap.get("ZCCSSRQ")+" "));
Date EOPSSRQ_data = null;
String ESSRQ= null;
if (StringUtils.isNotBlank(String.valueOf(saveMap.get("EOPSSRQ")))) {
try {
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
if (String.valueOf(saveMap.get("EOPSSRQ")).trim().length()>10){
ESSRQ = String.valueOf(saveMap.get("EOPSSRQ")).trim().substring(0,10);
}else {
ESSRQ = String.valueOf(saveMap.get("EOPSSRQ")).trim();
}
EOPSSRQ_data = format.parse(ESSRQ + " 00:00:00");
} catch (ParseException ignored) {
}
map.put("EOPSSRQ",ESSRQ);
}
if (EOPSSRQ_data != null) {
saveMap.put("EOPSSRQ_data",EOPSSRQ_data.getTime());
}else{
saveMap.put("EOPSSRQ_data",0L);
}
saveMap.put("EOPSSRQ",String.valueOf(saveMap.get("EOPSSRQ")+" "));
if (map.containsKey("DXBZ")){
saveMap.put("DXBZ",map.get("DXBZ"));
}else{
saveMap.put("DXBZ","");
}
//当建立代替时,产生的没有文件的问题
if (StringUtils.isBlank(String.valueOf(saveMap.get("content")))) {
String context = String.valueOf(saveMap.get("FBGBJBD")) + ","
+ String.valueOf(saveMap.get("XXZLXX")) + ","
+ String.valueOf(saveMap.get("ZQYJG")) + ","
+ String.valueOf(saveMap.get("BPG")) + ","
+ String.valueOf(saveMap.get("CA")) + ","
+ String.valueOf(saveMap.get("SSG")) + ","
+ String.valueOf(saveMap.get("ZBJBD"));
context = context.replace(",,", ",");
saveMap.put("content", context);
}
if (StringUtils.isNotBlank(String.valueOf(saveMap.get("FO"))) && !"null".equals(String.valueOf(saveMap.get("FO")))){
saveMap.put("FO",String.valueOf(saveMap.get("FO"))+" ");
}
if("add".equals(addOrUpdate)){
sarStandardsInfoService.insertIntoIndexForMap(saveMap);
} else {
sarStandardsInfoService.updateIntoIndexForMap(saveMap);
}
}
public Map<String,Object> dealNumberMsg (Map<String,Object> saveMap,SarStandardsInfo infoEO,String getCodeName) {
if(StringUtils.isNotEmpty(infoEO.getStandYear())){
String number = getCodeName + " " + infoEO.getStandNumber() + "-" + infoEO.getStandYear();
saveMap.put("numbershow",number);
int index = infoEO.getStandNumber().indexOf(".");
int index1 = infoEO.getStandNumber().indexOf(":");
String numberExpNull = "";
if(index > -1){
numberExpNull = (getCodeName + infoEO.getStandNumber() + "-" + number.replaceAll(" ","")
+ "-" + getCodeName + infoEO.getStandNumber().substring(0,index) + "-" + infoEO.getStandNumber().substring(0,index));
} else if (index1 > -1) {
numberExpNull = getCodeName + infoEO.getStandNumber() + "-" + number.replaceAll(" ","")
+ "-" + getCodeName + infoEO.getStandNumber().substring(0,index1) + "-" + infoEO.getStandNumber().substring(0,index1);
} else {
numberExpNull = getCodeName + infoEO.getStandNumber() + "-" + number.replaceAll(" ","");
}
saveMap.put("numberExpNull",numberExpNull);
} else {
String num = getCodeName + " " + infoEO.getStandNumber();
saveMap.put("numbershow",num);
int index = infoEO.getStandNumber().indexOf(".");
String numberExpNull = "";
if(index > -1){
numberExpNull = getCodeName + infoEO.getStandNumber() + "-" + num.replaceAll(" ","")
+ "-" + getCodeName + infoEO.getStandNumber().substring(0,index) + "-" + infoEO.getStandNumber().substring(0,index);
} else {
numberExpNull = getCodeName + infoEO.getStandNumber() + "-" + num.replaceAll(" ","");
}
saveMap.put("numberExpNull",numberExpNull);
}
return saveMap;
}
}
@@ -0,0 +1,79 @@
package com.adc.da.slrs.sarInstitution.controller;
import com.adc.da.http.ResponseMessage;
import com.adc.da.http.Result;
import com.adc.da.slrs.sarInstitution.entity.TsInstitution;
import com.adc.da.slrs.sarInstitution.service.ITsInstitutionService;
import com.adc.da.slrs.sarUser.entity.TsUser;
import com.adc.da.slrs.sarUser.service.ITsUserService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.Api;
import com.adc.da.base.web.BaseController;
import java.util.List;
import java.util.Map;
/**
* <p>
* 前端控制器
* </p>
*
* @author zyl
* @since 2021-06-22
*/
@RestController
@Api(tags = "|机构管理|")
@RequestMapping("/api/SarInstitution/institution")
public class TsInstitutionController extends BaseController<TsInstitution> {
@Autowired
private ITsInstitutionService tsInstitutionService;
@Autowired
private ITsUserService tsUserService;
/**
* 查询所有机构
* @return ResponseMessage<List<TsInstitution>>
*/
@ApiOperation("查询所有机构")
@GetMapping
public ResponseMessage<List<TsInstitution>> getInstitution(){
List<TsInstitution> institutions=tsInstitutionService.getInstitution();
return Result.success(institutions);
}
/**
* 查询所有机构和人员
* @return ResponseMessage<List<TsInstitution>>
*/
@ApiOperation("查询所有机构和人员")
@GetMapping("/institutionAndUser")
public ResponseMessage<List<TsInstitution>> getInstitutionAndUser(){
List<TsInstitution> institutions=tsInstitutionService.getInstitutionAndUser();
return Result.success(institutions);
}
/**
* 查询机构人员
* @param institutionId:机构ID
* @return ResponseMessage<List<TsUser>>
*/
@ApiOperation("查询机构的人员")
@GetMapping("/user")
public ResponseMessage<List<TsUser>> getUserByInstitutionId(@RequestParam String institutionId){
List<TsUser> tsUsers=tsUserService.getUserByInstitutionId(institutionId);
return Result.success(tsUsers);
}
@ApiOperation("导入机构数据")
@PostMapping("/import")
public ResponseMessage<Object> importInstitution(Map<String,Object> param){
String json= (String) param.get("json");
tsInstitutionService.parseInstitution(json);
return Result.success();
}
}
@@ -0,0 +1,37 @@
package com.adc.da.slrs.sarInstitution.dao;
import com.adc.da.slrs.sarInstitution.entity.InstitutionAndUser;
import com.adc.da.slrs.sarInstitution.entity.TsInstitution;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import java.util.List;
/**
* <p>
* Mapper 接口
* </p>
*
* @author zyl
* @since 2021-06-22
*/
public interface TsInstitutionDao extends BaseMapper<TsInstitution> {
/**
* 查询最高级机构及其人员
* @return List<TsInstitution>
*/
List<TsInstitution> selectRootAndUser();
/**
* 根据父节点查询机构及其人员
* @param parentId:父节点Id
* @return List<TsInstitution>
*/
List<TsInstitution> selectAndUserByParent(String parentId);
/**
* 批量插入机构
* @param tsInstitutions:机构列表
*/
void batchInsert(List<TsInstitution> tsInstitutions);
}
@@ -0,0 +1,13 @@
package com.adc.da.slrs.sarInstitution.entity;
import com.adc.da.slrs.sarUser.entity.TsUser;
import lombok.Data;
import java.util.List;
@Data
public class InstitutionAndUser {
private TsInstitution institution;
private List<TsUser> users;
private List<InstitutionAndUser> children;
}
@@ -0,0 +1,27 @@
package com.adc.da.slrs.sarInstitution.entity;
import lombok.Data;
import java.util.ArrayList;
import java.util.List;
@Data
public class SyncInstitution {
private String orgNumber;
private String orgName;
private String departmentName;
private String orgStatus;
private String orgShortName;
private String parentOrgNumber;
private String orgFullPath;
private String order;
private String modifyTimestamp;
public static List<TsInstitution> syncToInstitution(List<SyncInstitution> syncInstitutions){
List<TsInstitution> tsInstitutions=new ArrayList<>();
for(SyncInstitution syncInstitution:syncInstitutions){
tsInstitutions.add(new TsInstitution(syncInstitution.getOrgNumber(),syncInstitution.getParentOrgNumber(),syncInstitution.getOrgName()));
}
return tsInstitutions;
}
}
@@ -0,0 +1,66 @@
package com.adc.da.slrs.sarInstitution.entity;
import com.adc.da.base.entity.BaseEntity;
import com.adc.da.slrs.sarUser.entity.TsUser;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.util.List;
/**
* <p>
*
* </p>
*
* @author zyl
* @since 2021-06-22
*/
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@ApiModel(value="TsInstitution对象", description="")
public class TsInstitution extends BaseEntity {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "主键")
@TableId("id")
private String id;
@ApiModelProperty(value = "上级机构")
private String parentId;
@ApiModelProperty(value = "机构层级")
private Integer level;
@ApiModelProperty(value = "机构名")
private String name;
@TableField(exist = false)
@ApiModelProperty(value = "子机构")
private List<Object> children;
@JsonIgnore
@TableField(exist = false)
@ApiModelProperty(value = "人员")
private List<TsUserVO> users;
@TableField(exist = false)
@ApiModelProperty("是否是机构")
private Boolean disabled;
public TsInstitution() {
}
public TsInstitution(String id, String parentId, String name) {
this.id = id;
this.parentId = parentId;
this.name = name;
}
}
@@ -0,0 +1,121 @@
package com.adc.da.slrs.sarInstitution.entity;
import com.adc.da.slrs.sarPosition.entity.TsPosition;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import javax.validation.constraints.NotNull;
import java.sql.Timestamp;
import java.util.List;
@Data
public class TsUserVO {
public interface disable{
}
@ApiModelProperty(value = "主键Id")
@NotNull(message = "userId不能为空",groups = {disable.class})
@TableId(value = "USID")
private String id;
@ApiModelProperty(value = "帐户")
@TableField("ACCOUNT")
private String account;
@ApiModelProperty(value = "密码")
@TableField("PASSWORD")
private String password;
@ApiModelProperty(value = "用户姓名")
@TableField("UNAME")
private String name;
@ApiModelProperty(value = "用户性别(1为男,2为女)")
@TableField("SEX")
private String sex;
@ApiModelProperty(value = "用户来源")
@TableField("USER_SOURCE")
private String userSource;
@ApiModelProperty(value = "用户手机号")
@TableField("PHONE")
private String phone;
@ApiModelProperty(value = "用户状态")
@TableField("STATE")
private String state;
@ApiModelProperty(value = "用户邮箱")
@TableField("EMAIL")
private String email;
@ApiModelProperty(value = "所属部门名称")
@TableField("INSTITUTION_NAME")
private String institutionName;
@ApiModelProperty(value = "所属部门ID")
@TableField("INSTITUTION_ID")
private String institutionId;
@ApiModelProperty(value = "岗位名")
@TableField("POSITION_NAME")
private String positionName;
@ApiModelProperty(value = "岗位ID")
@TableField("POSITION_ID")
private String positionId;
@ApiModelProperty(value = "工号")
@TableField("WORK_NUM")
private String workNum;
@ApiModelProperty(value = "备注")
@TableField("EXT_INFO")
private String extInfo;
@TableField("OPER_USER")
private String operUser;
@ApiModelProperty(value = "创建时间")
@TableField("CREATION_TIME")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Timestamp creationTime;
@ApiModelProperty(value = "修改时间")
@TableField("MODIFY_TIME")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Timestamp modifyTime;
@ApiModelProperty(value = "是否有效")
@TableField("VALID_FLAG")
private String validFlag;
@ApiModelProperty(value = "是否禁用(0为未禁用,1为已禁用)")
@NotNull(message = "disableFlag不能为空",groups = {disable.class})
@TableField("DISABLE_FLAG")
private String disableFlag;
@ApiModelProperty(value = "是否锁定")
@TableField("UNLOCK_FLAG")
private String unlockFlag;
@ApiModelProperty(value = "用户类型")
@TableField("USER_TYPE")
private String userType;
@ApiModelProperty(value = "对接单点登录用户ID")
@TableField("SSO_ID")
private String ssoId;
@ApiModelProperty(value = "岗位")
@TableField(exist = false)
private List<TsPosition> positions;
}
@@ -0,0 +1,37 @@
package com.adc.da.slrs.sarInstitution.service;
import com.adc.da.slrs.sarInstitution.entity.SyncInstitution;
import com.adc.da.slrs.sarInstitution.entity.TsInstitution;
import com.adc.da.slrs.sarUser.entity.TsUser;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
/**
* <p>
* 服务类
* </p>
*
* @author zxy
* @since 2021-06-22
*/
public interface ITsInstitutionService extends IService<TsInstitution> {
/**
* 查询所有机构
*/
List<TsInstitution> getInstitution();
List<TsInstitution> getInstitutionAndUser();
/**
* 批量插入机构
* @param tsInstitutions:机构列表
*/
void batchInsert(List<TsInstitution> tsInstitutions);
public void parseInstitution(String json);
}
@@ -0,0 +1,127 @@
package com.adc.da.slrs.sarInstitution.service.impl;
import com.adc.da.slrs.sarInstitution.dao.TsInstitutionDao;
import com.adc.da.slrs.sarInstitution.entity.InstitutionAndUser;
import com.adc.da.slrs.sarInstitution.entity.SyncInstitution;
import com.adc.da.slrs.sarInstitution.entity.TsInstitution;
import com.adc.da.slrs.sarInstitution.entity.TsUserVO;
import com.adc.da.slrs.sarInstitution.service.ITsInstitutionService;
import com.adc.da.slrs.sarUser.entity.TsUser;
import com.adc.da.slrs.sarUser.service.ITsUserService;
import com.adc.da.sync.service.SyncUserService;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
/**
* <p>
* 服务实现类
* </p>
*
* @author zyl
* @since 2021-06-22
*/
@Service
public class TsInstitutionServiceImpl extends ServiceImpl<TsInstitutionDao, TsInstitution> implements ITsInstitutionService {
@Autowired
private TsInstitutionDao tsInstitutionDao;
/**
* 查询所有机构
*/
@Override
public List<TsInstitution> getInstitution() {
//查询第一层机构
QueryWrapper<TsInstitution> institutionQueryWrapper=new QueryWrapper<>();
institutionQueryWrapper.eq("level",1);
List<TsInstitution> institutionRoot=tsInstitutionDao.selectList(institutionQueryWrapper);
for(TsInstitution tsInstitution:institutionRoot){
tsInstitution.setChildren(recursionGetInstitution(tsInstitution));
}
return institutionRoot;
}
/**
* 递归获取子机构
* @param tsInstitution:父机构
* @return List<TsInstitution>
*/
private List<Object> recursionGetInstitution(TsInstitution tsInstitution){
List<Object> institutionObject=new ArrayList<>();
QueryWrapper<TsInstitution> institutionQueryWrapper=new QueryWrapper<>();
institutionQueryWrapper.eq("parent_id",tsInstitution.getId());
institutionQueryWrapper.eq("level",tsInstitution.getLevel()+1);
List<TsInstitution> tsInstitutions=tsInstitutionDao.selectList(institutionQueryWrapper);
for(TsInstitution tsInstitutionNode:tsInstitutions){
tsInstitutionNode.setChildren(recursionGetInstitution(tsInstitutionNode));
institutionObject.add(tsInstitutionNode);
}
return institutionObject;
}
/**
* 查询所有机构
*/
@Override
public List<TsInstitution> getInstitutionAndUser() {
//查询第一层机构
List<TsInstitution> institutionRoot=tsInstitutionDao.selectRootAndUser();
for(TsInstitution tsInstitution:institutionRoot){
tsInstitution.setDisabled(true);
tsInstitution.setChildren(recursionGetInstitutionAndUser(tsInstitution));
for(TsUserVO user:tsInstitution.getUsers()){
tsInstitution.getChildren().add(user);
}
}
return institutionRoot;
}
/**
* 批量插入机构
* @param tsInstitutions:机构列表
*/
@Override
public void batchInsert(List<TsInstitution> tsInstitutions) {
if(tsInstitutions!=null&&tsInstitutions.size()>0){
tsInstitutionDao.batchInsert(tsInstitutions);
}
}
/**
* 递归获取子机构
* @param tsInstitution:父机构
* @return List<TsInstitution>
*/
private List<Object> recursionGetInstitutionAndUser(TsInstitution tsInstitution){
List<Object> institutionObject=new ArrayList<>();
List<TsInstitution> tsInstitutions=tsInstitutionDao.selectAndUserByParent(tsInstitution.getId());
for(TsInstitution tsInstitutionNode:tsInstitutions){
tsInstitutionNode.setDisabled(true);
tsInstitutionNode.setChildren(recursionGetInstitutionAndUser(tsInstitutionNode));
institutionObject.add(tsInstitutionNode);
for(TsUserVO user:tsInstitutionNode.getUsers()){
tsInstitutionNode.getChildren().add(user);
}
}
return institutionObject;
}
public void parseInstitution(String json){
JSONObject jsonObject= JSON.parseObject(json);
JSONArray results=jsonObject.getJSONArray("results");
List<SyncInstitution> syncInstitutions=results.toJavaList(SyncInstitution.class);
List<TsInstitution> tsInstitutions=SyncInstitution.syncToInstitution(syncInstitutions);
batchInsert(tsInstitutions);
}
}
@@ -1,41 +0,0 @@
package com.adc.da.slrs.sarInterpretationStandard.entity;
import com.adc.da.base.entity.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* <p>
*
* </p>
*
* @author zyl
* @since 2021-06-16
*/
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@ApiModel(value="SarInterpretationForeignStandard对象", description="")
public class SarInterpretationForeignStandard extends BaseEntity {
private static final long serialVersionUID = 1L;
private String standardNum;
private String standardName;
private String correspondDomesticStandard;
private String specificItem;
private String coreTechnicalRequirement;
private String comparedDomesticStandard;
private String complianceState;
}
@@ -1,41 +0,0 @@
package com.adc.da.slrs.sarInterpretationStandard.entity;
import com.adc.da.base.entity.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* <p>
*
* </p>
*
* @author zyl
* @since 2021-06-16
*/
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@ApiModel(value="SarInterpretationNationalStandard对象", description="")
public class SarInterpretationNationalStandard extends BaseEntity {
private static final long serialVersionUID = 1L;
private String standardNum;
private String standardName;
private Integer lastVersionNum;
private String specificItem;
private String coreTechnicalRequirement;
private String comparedWithPrevious;
private String complianceState;
}
@@ -1,20 +0,0 @@
package com.adc.da.slrs.sarInterpretationStandard.service.impl;
import com.adc.da.slrs.sarInterpretationStandard.entity.SarInterpretationForeignStandard;
import com.adc.da.slrs.sarInterpretationStandard.dao.SarInterpretationForeignStandardDao;
import com.adc.da.slrs.sarInterpretationStandard.service.ISarInterpretationForeignStandardService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
/**
* <p>
* 服务实现类
* </p>
*
* @author zyl
* @since 2021-06-16
*/
@Service
public class SarInterpretationForeignStandardServiceImpl extends ServiceImpl<SarInterpretationForeignStandardDao, SarInterpretationForeignStandard> implements ISarInterpretationForeignStandardService {
}
@@ -1,20 +0,0 @@
package com.adc.da.slrs.sarInterpretationStandard.service.impl;
import com.adc.da.slrs.sarInterpretationStandard.entity.SarInterpretationNationalStandard;
import com.adc.da.slrs.sarInterpretationStandard.dao.SarInterpretationNationalStandardDao;
import com.adc.da.slrs.sarInterpretationStandard.service.ISarInterpretationNationalStandardService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
/**
* <p>
* 服务实现类
* </p>
*
* @author zyl
* @since 2021-06-16
*/
@Service
public class SarInterpretationNationalStandardServiceImpl extends ServiceImpl<SarInterpretationNationalStandardDao, SarInterpretationNationalStandard> implements ISarInterpretationNationalStandardService {
}
@@ -0,0 +1,23 @@
package com.adc.da.slrs.sarLawsAttrDetailedList.controller;
import org.springframework.web.bind.annotation.RequestMapping;
import com.adc.da.slrs.sarLawsAttrDetailedList.entity.SarDetailedIdAttFile;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.RestController;
import com.adc.da.base.web.BaseController;
/**
* <p>
* 前端控制器
* </p>
*
* @author zzy
* @since 2021-06-24
*/
@RestController
@Api(description = "|SarDetailedIdAttFile|")
@RequestMapping("/api/sarLawsAttrDetailedList/sar-detailed-id-att-file")
public class SarDetailedIdAttFileController extends BaseController<SarDetailedIdAttFile> {
}
@@ -0,0 +1,145 @@
package com.adc.da.slrs.sarLawsAttrDetailedList.controller;
import com.adc.da.att.entity.AttFileEO;
import com.adc.da.att.service.IAttFileEOService;
import com.adc.da.http.ResponseMessage;
import com.adc.da.http.Result;
import com.adc.da.slrs.sarLawsAttrDetailedList.dao.SarLawsAttrDetailedListDao;
import com.adc.da.slrs.sarLawsAttrDetailedList.entity.*;
import com.adc.da.slrs.sarLawsAttrDetailedList.service.ISarLawsAttrDetailedListService;
import com.alibaba.excel.EasyExcel;
import com.alibaba.fastjson.JSON;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;
import io.swagger.annotations.Api;
import com.adc.da.base.web.BaseController;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.List;
/**
* <p>
* 前端控制器
* </p>
*
* @author zzy
* @since 2021-06-15
*/
@RestController
//@Api(description = "|SarLawsAttrDetailedList|")
@Api(tags = "标准法规清单详情")
@RequestMapping("/api/sarLawsAttrDetailedList/sar-laws-attr-detailed-list")
public class SarLawsAttrDetailedListController extends BaseController<SarLawsAttrDetailedList> {
@Autowired
private ISarLawsAttrDetailedListService iSarLawsAttrDetailedList;
@Autowired
private IAttFileEOService attFileEOService;
@Autowired
private SarLawsAttrDetailedListDao sarLawsAttrDetailedListDao;
/**
* @param Page 页数
* @param Size 大小
* @param id 清单id
* @return ResponseMessage
* @author zzy
* date 2021-06-17
**/
@ApiOperation(value = "查询标准信息")
@GetMapping("/selectLawsById")
public ResponseMessage selectLawsById(@RequestParam(defaultValue = "1")int Page, @RequestParam(defaultValue = "10") int Size, String id,String standName,String responseUnit){
List<LawsDto> laws = iSarLawsAttrDetailedList.selectLaws(id,Page-1,Size,standName);
return Result.success("200",laws);
}
@ApiOperation(value = "查询附件信息")
@GetMapping("/selectFile")
public ResponseMessage selectFile(String Id){
AttFileEO attFileEO = attFileEOService.getFileInfo(Id);
return Result.success("200",attFileEO);
}
/**
* @param Page 页数
* @param Size 大小
* @param id 清单id
* @return ResponseMessage
* @author zzy
* date 2021-06-17
* 标准主表中的数据不全,先预留接口
**/
@ApiOperation(value = "检索和高级检索")
@PostMapping("/selectByStandId")
public ResponseMessage selectByStandId(@RequestParam(defaultValue = "1")int Page, @RequestParam(defaultValue = "10") int Size, String id){
return null;
}
/**
*
* @param response 返回头
* @param standExcelVo standExcelVo类
* @return void
* @author 作者信息
* date 2021-06-24
**/
@ApiOperation(value = "导出标准信息")
@RequestMapping("/ExportLawsById")
public void ExportLawsById(HttpServletResponse response, StandExcelVo standExcelVo){
try {
response.setContentType("application/vnd.ms-excel");
response.setCharacterEncoding("utf-8");
if(standExcelVo.getExportName()==null){
standExcelVo.setExportName("标准导出信息");
}
String fileName = URLEncoder.encode(standExcelVo.getExportName(), "UTF-8").replaceAll("\\+", "%20");
response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx");
List<LittleLawsDto> data = new ArrayList<>();
if (CollectionUtils.isEmpty(standExcelVo.getIds())){
List<String> list= sarLawsAttrDetailedListDao.selectLawsId2(standExcelVo.getId());
if (CollectionUtils.isEmpty(list)) return;
data=sarLawsAttrDetailedListDao.selectLawsById(list,null);
}else {
data=sarLawsAttrDetailedListDao.selectLawsById(standExcelVo.getIds(),null);
}
List<StandExcelDto> standExcel=new ArrayList<>();
for (LittleLawsDto littleLawsDto:data){
StandExcelDto standExcelDto=StandExcelDto.builder()
.standNumber(littleLawsDto.getStandNumber())
.standName(littleLawsDto.getStandName())
.standEnName(littleLawsDto.getStandEnName())
.responseUnit("责任部门")
.newCarTime("无字段")
.nowCarTime("无字段")
.typeApplicable("无字段")
.issueTime(littleLawsDto.getIssueTime())
.textStatus(littleLawsDto.getTextStatus())
.build();
standExcel.add(standExcelDto);
}
EasyExcel.write(response.getOutputStream(), StandExcelDto.class).autoCloseStream(Boolean.FALSE).sheet("sheet1")
.doWrite(standExcel);
} catch (Exception e) {
response.reset();
response.setContentType("application/json");
response.setCharacterEncoding("utf-8");
try {
response.getWriter().println(JSON.toJSONString(Result.error()));
} catch (IOException ioException) {
ioException.printStackTrace();
}
}
}
}
@@ -0,0 +1,18 @@
package com.adc.da.slrs.sarLawsAttrDetailedList.dao;
import com.adc.da.slrs.sarLawsAttrDetailedList.entity.SarDetailedIdAttFile;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
/**
* <p>
* Mapper 接口
* </p>
*
* @author zzy
* @since 2021-06-24
*/
@Mapper
public interface SarDetailedIdAttFileDao extends BaseMapper<SarDetailedIdAttFile> {
}
@@ -0,0 +1,29 @@
package com.adc.da.slrs.sarLawsAttrDetailedList.dao;
import com.adc.da.slrs.sarLawsAttrDetailedList.entity.SarLawsAttrDetailedList;
import com.adc.da.slrs.sarLawsAttrDetailedList.entity.LittleLawsDto;
import com.adc.da.slrs.sarLawsAttrDetailedList.entity.StandExcelDto;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
/**
* <p>
* Mapper 接口
* </p>
*
* @author zzy
* @since 2021-06-15
*/
@Mapper
public interface SarLawsAttrDetailedListDao extends BaseMapper<SarLawsAttrDetailedList> {
//根据清单id,查出标准的id并排序
List<String> selectLawsId(String standId,Integer page,Integer size);
//根据标准id查出数据
List<LittleLawsDto> selectLawsById(List<String> LawsIds,String standName);
List<String> selectLawsId2(String standId);
Boolean insertList(List<SarLawsAttrDetailedList> sarLawsAttrDetailedLists);
Boolean deleteByStandId(String standId);
}
@@ -0,0 +1,38 @@
package com.adc.da.slrs.sarLawsAttrDetailedList.entity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Builder;
import lombok.Data;
/**
* //Dto,用于从标准主表中查询和检索信息
* 主表还未完善需修改
*
* @author ZhangZhiYuan
* date 2021-06-16
*/
@Builder
@Data
public class LawsDto {
@ApiModelProperty(value = "主键")
private String id;
@ApiModelProperty(value = "标准编号")
private String standNumber;
@ApiModelProperty(value = "中文名称")
private String standName;
@ApiModelProperty(value = "英文名称")
private String standEnName;
@ApiModelProperty(value = "责任部门")
private String responseUnit;
@ApiModelProperty(value = "新车型实施日期")
private String newCarTime;
@ApiModelProperty(value = "在产车实施日期")
private String nowCarTime;
@ApiModelProperty(value = "适用车辆类型")
private String typeApplicable;
@ApiModelProperty(value = "发布日期")
private String issueTime;
@ApiModelProperty(value = "文本状态")
private String textStatus;
}
@@ -0,0 +1,26 @@
package com.adc.da.slrs.sarLawsAttrDetailedList.entity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* //TODO 添加类、接口描述
* 能从主表中查出的LawsDto所需要的数据
* @author ZhangZhiYuan
* date 2021-06-22
*/
@Data
public class LittleLawsDto {
@ApiModelProperty(value = "主键")
private String id;
@ApiModelProperty(value = "标准编号")
private String standNumber;
@ApiModelProperty(value = "中文名称")
private String standName;
@ApiModelProperty(value = "英文名称")
private String standEnName;
@ApiModelProperty(value = "发布日期")
private String issueTime;
@ApiModelProperty(value = "文本状态")
private String textStatus;
}
@@ -0,0 +1,38 @@
package com.adc.da.slrs.sarLawsAttrDetailedList.entity;
import com.adc.da.base.entity.BaseEntity;
import com.baomidou.mybatisplus.annotation.TableId;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* <p>
*
* </p>
* 上传的附件和清单id的关联表
* @author zzy
* @since 2021-06-24
*/
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@ApiModel(value="SarDetailedIdAttFile对象", description="")
public class SarDetailedIdAttFile extends BaseEntity {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "主键")
@TableId
private String id;
@ApiModelProperty(value = "清单id")
private String detailedId;
@ApiModelProperty(value = "文件id")
private String fileId;
}
@@ -0,0 +1,43 @@
package com.adc.da.slrs.sarLawsAttrDetailedList.entity;
import com.adc.da.base.entity.BaseEntity;
import com.baomidou.mybatisplus.annotation.TableId;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Builder;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* <p>
*
* </p>
*
* @author zzy
* @since 2021-06-15
*/
@Data
@Builder
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@ApiModel(value="SarLawsAttrDetailedList对象", description="")
public class SarLawsAttrDetailedList extends BaseEntity {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "主键")
@TableId
private String id;
@ApiModelProperty(value = "标准政策表的id")
private String standId;
@ApiModelProperty(value = "标准清单主键")
private String detailedListId;
@ApiModelProperty(value = "顺序")
private String number;
}
@@ -0,0 +1,45 @@
package com.adc.da.slrs.sarLawsAttrDetailedList.entity;
import com.alibaba.excel.annotation.ExcelProperty;
import io.swagger.annotations.ApiModelProperty;
import lombok.Builder;
import lombok.Data;
/**
* //TODO 添加类、接口描述
*用于导出标准数据信息
* 需要后期修改
* @author ZhangZhiYuan
* @date 2021-06-24
*/
@Data
@Builder
public class StandExcelDto {
@ExcelProperty("标准编号")
@ApiModelProperty(value = "标准编号")
private String standNumber;
@ExcelProperty("中文名称")
@ApiModelProperty(value = "中文名称")
private String standName;
@ExcelProperty("英文名称")
@ApiModelProperty(value = "英文名称")
private String standEnName;
@ExcelProperty("责任部门")
@ApiModelProperty(value = "责任部门")
private String responseUnit;
@ExcelProperty("新车型实施日期")
@ApiModelProperty(value = "新车型实施日期")
private String newCarTime;
@ExcelProperty("在产车实施日期")
@ApiModelProperty(value = "在产车实施日期")
private String nowCarTime;
@ExcelProperty("适用车辆类型")
@ApiModelProperty(value = "适用车辆类型")
private String typeApplicable;
@ExcelProperty("发布日期")
@ApiModelProperty(value = "发布日期")
private String issueTime;
@ExcelProperty("文本状态")
@ApiModelProperty(value = "文本状态")
private String textStatus;
}
@@ -0,0 +1,25 @@
package com.adc.da.slrs.sarLawsAttrDetailedList.entity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* //TODO 添加类、接口描述
*
* @author ZhangZhiYuan
* @date 2021-06-24
*/
@Data
@ApiModel(description = "标准导出类")
public class StandExcelVo {
@ApiModelProperty("文件名")
String exportName;
@ApiModelProperty("标准ID列表")
List<String> ids;
@ApiModelProperty("ID")
String id;
}
@@ -0,0 +1,16 @@
package com.adc.da.slrs.sarLawsAttrDetailedList.service;
import com.adc.da.slrs.sarLawsAttrDetailedList.entity.SarDetailedIdAttFile;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* <p>
* 服务类
* </p>
*
* @author zzy
* @since 2021-06-24
*/
public interface ISarDetailedIdAttFileService extends IService<SarDetailedIdAttFile> {
}
@@ -0,0 +1,25 @@
package com.adc.da.slrs.sarLawsAttrDetailedList.service;
import com.adc.da.slrs.sarLawsAttrDetailedList.entity.SarLawsAttrDetailedList;
import com.adc.da.slrs.sarLawsAttrDetailedList.entity.LawsDto;
import com.adc.da.slrs.sarLawsAttrDetailedList.entity.StandExcelVo;
import com.baomidou.mybatisplus.extension.service.IService;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
/**
* <p>
* 服务类
* </p>
*
* @author zzy
* @since 2021-06-15
*/
public interface ISarLawsAttrDetailedListService extends IService<SarLawsAttrDetailedList> {
List<LawsDto> selectLaws(String standId, Integer Page, Integer Size,String standName);
Boolean insertDetailedList(String id,String[] lawsIds);
Boolean updateDetailedLaws(String id,String[] lawsIds);
void exportExcel(HttpServletResponse response, StandExcelVo standExcelVo);
}
@@ -0,0 +1,20 @@
package com.adc.da.slrs.sarLawsAttrDetailedList.service.impl;
import com.adc.da.slrs.sarLawsAttrDetailedList.entity.SarDetailedIdAttFile;
import com.adc.da.slrs.sarLawsAttrDetailedList.dao.SarDetailedIdAttFileDao;
import com.adc.da.slrs.sarLawsAttrDetailedList.service.ISarDetailedIdAttFileService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
/**
* <p>
* 服务实现类
* </p>
*
* @author zzy
* @since 2021-06-24
*/
@Service
public class SarDetailedIdAttFileServiceImpl extends ServiceImpl<SarDetailedIdAttFileDao, SarDetailedIdAttFile> implements ISarDetailedIdAttFileService {
}
@@ -0,0 +1,104 @@
package com.adc.da.slrs.sarLawsAttrDetailedList.service.impl;
import com.adc.da.slrs.sarLawsAttrDetailedList.dao.SarLawsAttrDetailedListDao;
import com.adc.da.slrs.sarLawsAttrDetailedList.entity.LawsDto;
import com.adc.da.slrs.sarLawsAttrDetailedList.entity.LittleLawsDto;
import com.adc.da.slrs.sarLawsAttrDetailedList.entity.SarLawsAttrDetailedList;
import com.adc.da.slrs.sarLawsAttrDetailedList.entity.StandExcelVo;
import com.adc.da.slrs.sarLawsAttrDetailedList.service.ISarLawsAttrDetailedListService;
import com.adc.da.util.UUIDUtils;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;
/**
* <p>
* 服务实现类
* </p>
*
* @author zzy
* @since 2021-06-15
*/
@Service
public class SarLawsAttrDetailedListServiceImpl extends ServiceImpl<SarLawsAttrDetailedListDao, SarLawsAttrDetailedList> implements ISarLawsAttrDetailedListService {
@Autowired
SarLawsAttrDetailedListDao sarLawsAttrDetailedListDao;
//从主表中查询信息
@Override
public List<LawsDto> selectLaws(String standId, Integer Page, Integer Size,String standName) {
List<String> lawsIds = sarLawsAttrDetailedListDao.selectLawsId(standId,Page,Size);
if (CollectionUtils.isEmpty(lawsIds)){
return null;
}
List<LittleLawsDto> lawsDtoList = sarLawsAttrDetailedListDao.selectLawsById(lawsIds,standName);
List<LawsDto> list = new ArrayList<>();
for (LittleLawsDto laws:lawsDtoList){
LawsDto lawsDto = LawsDto.builder()
.id(laws.getId())
.standNumber(laws.getStandNumber())
.standName(laws.getStandName())
.standEnName(laws.getStandEnName())
.issueTime(laws.getIssueTime())
.textStatus(laws.getTextStatus())
.build();
list.add(lawsDto);
}
return list;
}
//向清单表和主表中的关联表插入信息
@Override
public Boolean insertDetailedList(String standId, String[] lawsIds) {
if (!StringUtils.isEmpty(lawsIds)){
try {
List<SarLawsAttrDetailedList> attrDetailedLists = new ArrayList<>();
int a=0;
for (String lawsId:lawsIds){
SarLawsAttrDetailedList sarLawsAttrDetailedList = SarLawsAttrDetailedList.builder()
.id(UUIDUtils.randomUUID20())
.standId(lawsId)
.detailedListId(standId)
.number(String.valueOf(a))
.build();
attrDetailedLists.add(sarLawsAttrDetailedList);
a++;
}
sarLawsAttrDetailedListDao.insertList(attrDetailedLists);
return true;
} catch (Exception e) {
e.printStackTrace();
}
}
return false;
}
//修改关联表中的信息,先删除后修改
@Override
public Boolean updateDetailedLaws(String id, String[] lawsIds) {
try {
QueryWrapper<SarLawsAttrDetailedList> wrapper = new QueryWrapper<>();
wrapper.eq("detailed_list_id",id);
sarLawsAttrDetailedListDao.delete(wrapper);
insertDetailedList(id,lawsIds);
return true;
} catch (Exception e) {
return false;
}
}
@Override
public void exportExcel(HttpServletResponse response, StandExcelVo standExcelVo){
}
}
@@ -0,0 +1,119 @@
package com.adc.da.slrs.sarLawsDetailedList.controller;
import com.adc.da.base.web.BaseController;
import com.adc.da.http.ResponseMessage;
import com.adc.da.http.Result;
import com.adc.da.slrs.sarLawsDetailedList.entity.AddDetailedDto;
import com.adc.da.slrs.sarLawsDetailedList.entity.SarLawsDetailedList;
import com.adc.da.slrs.sarLawsDetailedList.entity.DetailedUpDto;
import com.adc.da.slrs.sarLawsDetailedList.service.impl.SarLawsDetailedListServiceImpl;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
/**
* <p>
* 前端控制器
* </p>
*
* @author szc
* @since 2021-06-15
*/
@RestController
//@Api(description = "|SarLawsDetailedList|")
@Api(tags = "标准法规清单")
@RequestMapping("/api/sarLawsDetailedList/sar-laws-detailed-list")
public class SarLawsDetailedListController extends BaseController<SarLawsDetailedList> {
@Autowired
private SarLawsDetailedListServiceImpl sarLawsDetailedListService;
/**
* @param idList 要进行删除的清单id
* @return ResponseMessage
* @author zzy
* date 2021-06-22
**/
@ApiOperation(value = "批量删除清单")
@PostMapping("/deleteListAll")
public ResponseMessage deleteListAll(String[] idList) {
if (idList == null || idList.length == 0) {
return Result.success("200", "要删除的数据为空");
} else {
List<String> list = new ArrayList<>(Arrays.asList(idList));
String src = sarLawsDetailedListService.del(list);
return Result.success("200", src);
}
}
/**
* @param addDetailedDto AddDetailed类
* @return ResponseMessage
* @author zzy
* date 2021-06-22
**/
@ApiOperation(value = "增加清单")
@PostMapping("/insertList")
public ResponseMessage insertList(AddDetailedDto addDetailedDto) {
String src = sarLawsDetailedListService.add(addDetailedDto);
return Result.success(src);
}
/**
* 动态查询
* @param page 页数
* @param pageSize 大小
* @param sortKey 进行三个页面的分类1,2,3
* @param countryArea 动态查询输入 国家清单
* @param detailedList 列表
* @param projectName 其他
* @param detailedListName 动态查询输入
* @return ResponseMessage
*/
@ApiOperation(value = "动态查询")
@GetMapping("/getAllStand")
public ResponseMessage getAllStand(Integer page,Integer pageSize, String sortKey,
String countryArea, String projectName,
String detailedList,
String detailedListName) {
if ("null".equals(countryArea))countryArea=null;
if ("null".equals(projectName))projectName=null;
if ("null".equals(detailedList))detailedList=null;
if ("null".equals(detailedListName))detailedListName=null;
if (StringUtils.isNotEmpty(sortKey)) {
IPage<SarLawsDetailedList> publicList = sarLawsDetailedListService.AllSelectD(page, pageSize, sortKey,
countryArea, projectName, detailedList, detailedListName);
return Result.success("200", publicList);
} else {
return Result.success("200", null);
}
}
/**
* @param detailedUpDto 修改的信息,通过类进行接收
* @return ResponseMessage
* @author 张志远
* date 2021-06-22
**/
@ApiOperation(value = "修改清单")
@PutMapping("/updateList")
public ResponseMessage updateList(@RequestBody DetailedUpDto detailedUpDto) {
String src = sarLawsDetailedListService.updateList(detailedUpDto);
return Result.success("200",src,true);
}
}
@@ -0,0 +1,18 @@
package com.adc.da.slrs.sarLawsDetailedList.dao;
import com.adc.da.slrs.sarLawsDetailedList.entity.SarLawsDetailedList;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
/**
* <p>
* Mapper 接口
* </p>
*
* @author szc
* @since 2021-06-15
*/
@Mapper
public interface SarLawsDetailedListDao extends BaseMapper<SarLawsDetailedList> {
}
@@ -0,0 +1,48 @@
package com.adc.da.slrs.sarLawsDetailedList.entity;
import com.baomidou.mybatisplus.annotation.TableId;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.web.multipart.MultipartFile;
import java.util.Collection;
/**
* //TODO 添加类、接口描述
*
* @author ZhangZhiYuan
* @date 2021-06-24
*/
@Data
public class AddDetailedDto {
@ApiModelProperty(value = "国家或地区")
private String countryArea;
@ApiModelProperty(value = "项目名称")
private String projectName;
@ApiModelProperty(value = "清单类别")
private String detailedList;
@ApiModelProperty(value = "区分,国家地区为1,项目名称为2,清单类别为3")
private String sortKey;
@ApiModelProperty(value = "清单名称")
private String detailedListName;
@ApiModelProperty(value = "清单详情")
private String remark;
@ApiModelProperty(value = "清单状态,1为未发布,2为发布")
private String detailedListState;
@ApiModelProperty(value = "适用领域")
private String applicationScope;
@ApiModelProperty(value = "更新人")
private String updatePeople;
@ApiModelProperty(value = "上传的附件")
private MultipartFile[] files;
@ApiModelProperty(value = "要添加的清单id")
private String[] lawsIds;
public MultipartFile getFiles(int i) {
return files[i];
}
}
@@ -0,0 +1,62 @@
package com.adc.da.slrs.sarLawsDetailedList.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* //TODO 添加类、接口描述
*
* @author ZhangZhiYuan
* @date 2021-06-25
*/
@Data
public class DetailedUpDto {
@ApiModelProperty(value = "主键")
private String id;
@ApiModelProperty(value = "国家或地区")
private String countryArea;
@ApiModelProperty(value = "项目名称")
private String projectName;
@ApiModelProperty(value = "清单类别")
private String detailedList;
@ApiModelProperty(value = "区分,国家地区为1,项目名称为2,清单类别为3")
private String sortKey;
@ApiModelProperty(value = "清单名称")
private String detailedListName;
@ApiModelProperty(value = "清单状态,1为未发布,2为发布")
private String detailedListState;
@ApiModelProperty(value = "清单版本,默认V0")
private String detailedListVision;
@ApiModelProperty(value = "适用领域")
private String applicationScope;
// @ApiModelProperty(value = "附件id")
// private String fileId;
@ApiModelProperty(value = "更新时间")
private Date reNewTime;
@ApiModelProperty(value = "更新人")
private String reNewPeople;
@ApiModelProperty(value = "要添加的清单id")
private String[] lawsIds;
@ApiModelProperty(value = "清单详情")
private String remark;
}
@@ -0,0 +1,18 @@
package com.adc.da.slrs.sarLawsDetailedList.entity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* //TODO 添加类、接口描述
*
* @author ZhangZhiYuan
* @date 2021-06-22
*/
@Data
public class IdListDto {
@ApiModelProperty("未符合项ID列表")
private List<String> Ids;
}
@@ -0,0 +1,81 @@
package com.adc.da.slrs.sarLawsDetailedList.entity;
import com.adc.da.base.entity.BaseEntity;
import java.util.Date;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;
import lombok.experimental.Accessors;
/**
* <p>
*
* </p>
*
* @author szc
* @since 2021-06-15
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@ApiModel(value="SarLawsDetailedList对象", description="")
public class SarLawsDetailedList extends BaseEntity {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "主键")
@TableId("id")
private String id;
@ApiModelProperty(value = "国家或地区")
@TableField("country_area")
private String countryArea;
@ApiModelProperty(value = "项目名称")
@TableField("project_name")
private String projectName;
@ApiModelProperty(value = "清单类别")
@TableField("detailed_list")
private String detailedList;
@ApiModelProperty(value = "区分,国家地区为1,项目名称为2,清单类别为3")
@TableField("sort_key")
private String sortKey;
@ApiModelProperty(value = "清单名称")
@TableField("detailed_list_name")
private String detailedListName;
@ApiModelProperty(value = "清单状态,1为未发布,2为发布")
@TableField("detailed_list_state")
private String detailedListState;
@ApiModelProperty(value = "清单版本,默认V0")
@TableField("detailed_list_vesion")
private String detailedListVision;
@ApiModelProperty(value = "适用领域")
@TableField("application_scope")
private String applicationScope;
@ApiModelProperty(value = "清单列表")
@TableField("remark")
private String remark;
@ApiModelProperty(value = "更新时间")
@TableField("update_time")
private Date updateTime;
@ApiModelProperty(value = "更新人")
@TableField("update_people")
private String updatePeople;
}
@@ -0,0 +1,29 @@
package com.adc.da.slrs.sarLawsDetailedList.service;
import com.adc.da.slrs.sarLawsDetailedList.entity.AddDetailedDto;
import com.adc.da.slrs.sarLawsDetailedList.entity.SarLawsDetailedList;
import com.adc.da.slrs.sarLawsDetailedList.entity.DetailedUpDto;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
/**
* <p>
* 服务类
* </p>
*
* @author szc
* @since 2021-06-15
*/
public interface ISarLawsDetailedListService extends IService<SarLawsDetailedList> {
String del(List<String> idList);
String add(AddDetailedDto addDetailedDto);
IPage<SarLawsDetailedList> AllSelectD(Integer pages, Integer size, String sortKey,
String countryArea,String projectName,
String detailedList, String detailedListName);
// IPage<SarLawsDetailedList> selectAllP(Integer pages,Integer size,String sortKey);
String updateList(DetailedUpDto detailedUpDto);
}
@@ -0,0 +1,157 @@
package com.adc.da.slrs.sarLawsDetailedList.service.impl;
import com.adc.da.att.service.IAttFileEOService;
import com.adc.da.slrs.sarLawsAttrDetailedList.dao.SarDetailedIdAttFileDao;
import com.adc.da.slrs.sarLawsAttrDetailedList.dao.SarLawsAttrDetailedListDao;
import com.adc.da.slrs.sarLawsAttrDetailedList.entity.SarLawsAttrDetailedList;
import com.adc.da.slrs.sarLawsAttrDetailedList.service.impl.SarLawsAttrDetailedListServiceImpl;
import com.adc.da.slrs.sarLawsDetailedList.dao.SarLawsDetailedListDao;
import com.adc.da.slrs.sarLawsDetailedList.entity.AddDetailedDto;
import com.adc.da.slrs.sarLawsDetailedList.entity.SarLawsDetailedList;
import com.adc.da.slrs.sarLawsDetailedList.entity.DetailedUpDto;
import com.adc.da.slrs.sarLawsDetailedList.service.ISarLawsDetailedListService;
import com.adc.da.util.UUIDUtils;
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.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.swagger.annotations.ApiModelProperty;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
/**
* <p>
* 服务实现类
* </p>
*
* @author szc
* @since 2021-06-15
*/
@Service
public class SarLawsDetailedListServiceImpl extends ServiceImpl<SarLawsDetailedListDao, SarLawsDetailedList> implements ISarLawsDetailedListService {
@Autowired
public SarLawsDetailedListDao sarLawsDetailedListDao;
@Autowired
public IAttFileEOService iAttFileEOService;
@Autowired
private SarLawsAttrDetailedListDao sarLawsAttrDetailedListDao;
@Autowired
private SarLawsAttrDetailedListServiceImpl service;
@Override
public String del(List<String> idList) {
QueryWrapper<SarLawsAttrDetailedList> wrapper = new QueryWrapper<>();
for (String id:idList){
wrapper.eq("detailed_list_id",id);
sarLawsAttrDetailedListDao.delete(wrapper);
}
sarLawsDetailedListDao.deleteBatchIds(idList);
return "删除成功";
}
@Override
public String add(AddDetailedDto addDetailedDto) {
try {
SarLawsDetailedList sarLawsDetailedList = SarLawsDetailedList.builder()
.id(UUIDUtils.randomUUID20())
.sortKey(addDetailedDto.getSortKey())
.detailedListName(addDetailedDto.getDetailedListName())
.detailedListState("1")
.detailedListVision("v0")
.applicationScope(addDetailedDto.getApplicationScope())
.updateTime(new Date())
.updatePeople(addDetailedDto.getUpdatePeople())
.remark(addDetailedDto.getRemark())
.build();
switch (addDetailedDto.getSortKey()) {
case "1":
sarLawsDetailedList.setCountryArea(addDetailedDto.getCountryArea());
break;
case "2":
sarLawsDetailedList.setProjectName(addDetailedDto.getProjectName());
break;
case "3":
sarLawsDetailedList.setDetailedList(addDetailedDto.getDetailedList());
break;
default:
break;
}
sarLawsDetailedListDao.insert(sarLawsDetailedList);
service.insertDetailedList(sarLawsDetailedList.getId(),addDetailedDto.getLawsIds());
} catch (Exception e) {
e.printStackTrace();
}
return "添加成功";
}
@Override
public IPage<SarLawsDetailedList> AllSelectD(Integer pages, Integer size, String sortKey,
String countryArea,String projectName,
String detailedList,String detailedListName) {
QueryWrapper<SarLawsDetailedList> wrapper = new QueryWrapper<>();
if ("1".equals(sortKey) ) {
wrapper.like(StringUtils.isNotEmpty(countryArea),"country_area",countryArea).
like(StringUtils.isNotEmpty(detailedListName),"detailed_list_name",detailedListName);
}else if ("2".equals(sortKey)) {
wrapper.like(StringUtils.isNotEmpty(projectName),"project_name",projectName).
like(StringUtils.isNotEmpty(detailedListName),"detailed_list_name",detailedListName);
}else if ("3".equals(sortKey)){
wrapper.like(StringUtils.isNotEmpty(detailedList),"detailed_list_state",detailedList).
like(StringUtils.isNotEmpty(detailedListName),"detailed_list_name",detailedListName);
}
wrapper.eq("sort_key",sortKey);
Page<SarLawsDetailedList> page = new Page<>(pages, size);
IPage<SarLawsDetailedList> userIPage = sarLawsDetailedListDao.selectPage(page, wrapper);
System.out.println("总条数" + userIPage.getTotal());
System.out.println("总页数" + userIPage.getPages());
return userIPage;
}
@Override
public String updateList(DetailedUpDto detailedUpDto) {
SarLawsDetailedList list = sarLawsDetailedListDao.selectById(detailedUpDto.getId());
//国家或地区
if (StringUtils.isBlank(detailedUpDto.getCountryArea())) list.setCountryArea(null);
else if ("null".equals(detailedUpDto.getCountryArea()));
else list.setCountryArea(detailedUpDto.getCountryArea());
//项目名称
if (StringUtils.isBlank(detailedUpDto.getProjectName())) list.setProjectName(null);
else if ("null".equals(detailedUpDto.getProjectName()));
else list.setProjectName(detailedUpDto.getProjectName());
//清单类别
if (StringUtils.isBlank(detailedUpDto.getDetailedList())) list.setDetailedList(null);
else if ("null".equals(detailedUpDto.getDetailedList()));
else list.setDetailedList(detailedUpDto.getDetailedList());
//清单名称
if (StringUtils.isBlank(detailedUpDto.getDetailedListName())) list.setDetailedListName(null);
else if ("null".equals(detailedUpDto.getDetailedListName()));
else list.setDetailedListName(detailedUpDto.getDetailedListName());
//适用领域
if (StringUtils.isBlank(detailedUpDto.getApplicationScope())) list.setApplicationScope(null);
else if ("null".equals(detailedUpDto.getApplicationScope()));
else list.setApplicationScope(detailedUpDto.getApplicationScope());
//清单详情
if (StringUtils.isBlank(detailedUpDto.getRemark())) list.setRemark(null);
else if ("null".equals(detailedUpDto.getRemark()));
list.setRemark(detailedUpDto.getRemark());
//更新时间
list.setUpdateTime(new Date());
//更新人
if (StringUtils.isBlank(detailedUpDto.getReNewPeople())) list.setUpdatePeople(null);
else if ("null".equals(detailedUpDto.getReNewPeople()));
else list.setUpdatePeople(detailedUpDto.getReNewPeople());
sarLawsDetailedListDao.updateById(list);
service.updateDetailedLaws(detailedUpDto.getId(), detailedUpDto.getLawsIds());
return "修改成功";
}
}
@@ -9,11 +9,10 @@ import com.adc.da.sys.common.SelectionResult;
import com.adc.da.sys.service.IDicTypeEOService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import com.adc.da.slrs.sarMenu.entity.SarMenu;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.RestController;
import com.adc.da.base.web.BaseController;
import java.util.ArrayList;
@@ -59,7 +58,9 @@ public class SarMenuController extends BaseController<SarMenu> {
for (SarMenu resultMenu : resultList) {
if ("gxhbq".equals(resultMenu.getId())) {
// 查出配置管理项
System.out.println(resultMenu);
List<SelectionResult> getDicList = dicTypeEOService.getDicTypeByDicId("ZHFKGAACTNUCN9AR5YBM");
System.out.println(getDicList);
if (getDicList != null && !getDicList.isEmpty()) {
for (SelectionResult selectionResult : getDicList) {
int i=0;
@@ -76,6 +77,33 @@ public class SarMenuController extends BaseController<SarMenu> {
}
}
resultList.addAll(listDic);
System.out.println("listDic");
System.out.println(listDic);
return Result.success(resultList);
}
@ApiOperation("查询所有菜单")
@GetMapping
public ResponseMessage<List<SarMenu>> getAll(){
List<SarMenu> sarMenus=sarMenuEOService.getAll();
return Result.success(sarMenus);
}
@ApiOperation("添加菜单")
@PostMapping("/add")
public ResponseMessage<Object> addMenu(@RequestBody SarMenu sarMenu){
return sarMenuEOService.addMenu(sarMenu);
}
@ApiOperation("编辑菜单")
@PutMapping
public ResponseMessage<Object> updateMenu(@Validated(SarMenu.update.class) @RequestBody SarMenu sarMenu){
return sarMenuEOService.updateMenu(sarMenu);
}
@ApiOperation("删除菜单")
@DeleteMapping
public ResponseMessage<Object> delMenu(@RequestParam String menuId){
return sarMenuEOService.delMenu(menuId);
}
}
@@ -4,6 +4,7 @@ import com.adc.da.base.entity.BaseEntity;
import com.adc.da.utils.treetool.annotation.TreeNodeId;
import com.adc.da.utils.treetool.annotation.TreeNodeName;
import com.adc.da.utils.treetool.annotation.TreeNodeParentId;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import java.time.LocalDateTime;
import java.util.Date;
@@ -17,6 +18,8 @@ import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.springframework.data.annotation.Transient;
import javax.validation.constraints.NotNull;
/**
* <p>
*
@@ -30,13 +33,15 @@ import org.springframework.data.annotation.Transient;
@Accessors(chain = true)
@ApiModel(value="SarMenu对象", description="")
public class SarMenu extends BaseEntity {
public interface update{
}
private static final long serialVersionUID = 1L;
@TreeNodeId
@NotNull(message = "id不能为空",groups = {update.class})
@ApiModelProperty(value = "主键")
@TableId("ID")
@TableId(value = "ID",type = IdType.UUID)
private String id;
@ApiModelProperty(value = "标准法规划分")
@@ -61,6 +66,10 @@ public class SarMenu extends BaseEntity {
@TableField("DISPLAY_SEQ")
private Integer displaySeq;
@ApiModelProperty(value = "路径")
@TableField("HREF")
private String href;
@ApiModelProperty(value = "是否有效")
@TableField("VALID_FLAG")
private Integer validFlag;
@@ -77,6 +86,10 @@ public class SarMenu extends BaseEntity {
@TableField("REMARKS")
private String remarks;
@ApiModelProperty(value = "子菜单")
@TableField(exist = false)
private List<SarMenu> children;
@TableField(exist=false)
private List<String> roleIds;
@@ -1,5 +1,6 @@
package com.adc.da.slrs.sarMenu.service;
import com.adc.da.http.ResponseMessage;
import com.adc.da.slrs.sarMenu.entity.SarMenu;
import com.baomidou.mybatisplus.extension.service.IService;
@@ -24,4 +25,44 @@ public interface ISarMenuService extends IService<SarMenu> {
List<String> queryRoleMenuIdList(String sordDivide, String menuId) throws Exception;
List<String> getChildMenuList(String menuId);
/**
* 通过ids查询menus
* @param menuIds:菜单ID
* @return List<SarMenu>
*/
List<SarMenu> getMenusByIds(List<String> menuIds);
/**
* 查询所有菜单
*/
List<SarMenu> getAll();
/**
* 添加菜单
* @param sarMenu:菜单信息
* @return ResponseMessage<Object>
*/
ResponseMessage<Object> addMenu(SarMenu sarMenu);
/**
* 编辑菜单
* @param sarMenu:菜单信息
* @return ResponseMessage<Object>
*/
ResponseMessage<Object> updateMenu(SarMenu sarMenu);
/**
* 删除菜单
* @param menuId :菜单ID
* @return ResponseMessage<Object>
*/
ResponseMessage<Object> delMenu(String menuId);
/**
* 通过Ids查询menu
* @param menuIds :菜单Ids
* @return List<Menu>
*/
List<SarMenu> getMenuByIds(List<String> menuIds);
}
@@ -1,5 +1,7 @@
package com.adc.da.slrs.sarMenu.service.impl;
import com.adc.da.http.ResponseMessage;
import com.adc.da.http.Result;
import com.adc.da.login.util.UserUtils;
import com.adc.da.slrs.sarMenu.entity.SarMenu;
import com.adc.da.slrs.sarMenu.dao.SarMenuDao;
@@ -152,4 +154,117 @@ public class SarMenuServiceImpl extends ServiceImpl<SarMenuDao, SarMenu> impleme
}
return menuIds;
}
/**
* 通过ids查询menus
* @param menuIds:菜单ID
* @return List<SarMenu>
*/
@Override
public List<SarMenu> getMenusByIds(List<String> menuIds) {
QueryWrapper<SarMenu> menuQueryWrapper=new QueryWrapper<>();
menuQueryWrapper.in("id",menuIds);
return dao.selectList(menuQueryWrapper);
}
/**
* 查询所有菜单
*/
@Override
public List<SarMenu> getAll() {
QueryWrapper<SarMenu> sarMenuQueryWrapper=new QueryWrapper<>();
sarMenuQueryWrapper.orderByAsc("DISPLAY_SEQ");
sarMenuQueryWrapper.isNull("PARENT_ID");
List<SarMenu> sarMenus=dao.selectList(sarMenuQueryWrapper);
for(SarMenu sarMenu:sarMenus){
sarMenu.setChildren(recursionGetChildren((sarMenu)));
}
return sarMenus;
}
/**
* 添加菜单
* @param sarMenu:菜单信息
* @return ResponseMessage<Object>
*/
@Override
public ResponseMessage<Object> addMenu(SarMenu sarMenu) {
if(sarMenu.getParentId()!=null){
SarMenu parent=dao.selectById(sarMenu.getParentId());
if(parent==null){
return Result.error("该父菜单不存在");
}
}
dao.insert(sarMenu);
return Result.success();
}
/**
* 编辑菜单
* @param sarMenu:菜单信息
* @return ResponseMessage<Object>
*/
@Override
public ResponseMessage<Object> updateMenu(SarMenu sarMenu) {
SarMenu oldMenu=dao.selectById(sarMenu.getId());
if(oldMenu==null){
return Result.error("该菜单不存在");
}
if(sarMenu.getParentId()!=null){
SarMenu parent=dao.selectById(sarMenu.getParentId());
if(parent==null){
return Result.error("父节点不存在");
}
}
dao.updateById(sarMenu);
return Result.success();
}
/**
* 删除菜单
* @param menuId :菜单ID
* @return ResponseMessage<Object>
*/
@Override
public ResponseMessage<Object> delMenu(String menuId) {
QueryWrapper<SarMenu> sarMenuQueryWrapper=new QueryWrapper<>();
sarMenuQueryWrapper.eq("parent_id",menuId);
List<SarMenu> children=dao.selectList(sarMenuQueryWrapper);
if(children!=null&&children.size()>0){
return Result.error("该菜单有子节点,无法删除");
}
dao.deleteById(menuId);
return Result.success();
}
/**
* 通过Ids查询menu
* @param menuIds :菜单Ids
* @return List<Menu>
*/
@Override
public List<SarMenu> getMenuByIds(List<String> menuIds) {
if(menuIds!=null&&menuIds.size()>0){
QueryWrapper<SarMenu> sarMenuQueryWrapper=new QueryWrapper<>();
sarMenuQueryWrapper.in("id",menuIds);
return dao.selectList(sarMenuQueryWrapper);
}
return new ArrayList<>();
}
/**
* 递归调用获取子节点
* @param parent:父节点
* @return List<SarMenu>
*/
private List<SarMenu> recursionGetChildren(SarMenu parent){
QueryWrapper<SarMenu> sarMenuQueryWrapper=new QueryWrapper<>();
sarMenuQueryWrapper.orderByAsc("DISPLAY_SEQ");
sarMenuQueryWrapper.eq("PARENT_ID",parent.getId());
List<SarMenu> children=dao.selectList(sarMenuQueryWrapper);
for(SarMenu sarMenu:children){
sarMenu.setChildren(recursionGetChildren((sarMenu)));
}
return children;
}
}
@@ -0,0 +1,43 @@
package com.adc.da.slrs.sarPersonalCenter.controller;
import com.adc.da.http.ResponseMessage;
import com.adc.da.slrs.sarPersonalCenter.entity.SarUserPersonalMenuEO;
import com.adc.da.slrs.sarPersonalCenter.service.ISarUserPersonalMenuService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.adc.da.slrs.sarPersonalCenter.entity.SarUserPersonalMenu;
import io.swagger.annotations.Api;
import com.adc.da.base.web.BaseController;
/**
* <p>
* 前端控制器
* </p>
*
* @author zyl
* @since 2021-06-22
*/
@RestController
@Api(tags = "福田标准法规--个人中心--我的板块")
@RequestMapping("/${restPath}/sarPersonalCenter/sar-user-personal-menu")
public class SarUserPersonalMenuController extends BaseController<SarUserPersonalMenu> {
@Autowired
private ISarUserPersonalMenuService iSarUserPersonalMenuService;
@ApiOperation("获取用户的板块列表")
@GetMapping("/getList")
public ResponseMessage<IPage<SarUserPersonalMenu>> getList(SarUserPersonalMenuEO eo){
return iSarUserPersonalMenuService.getUserPersonalMenu(eo);
}
@ApiOperation("更新用户的板块列表")
@PostMapping("/update")
public ResponseMessage<IPage<SarUserPersonalMenu>> update(@RequestBody SarUserPersonalMenuEO eo){
return iSarUserPersonalMenuService.updateUserPersonalMenu(eo);
}
}
@@ -0,0 +1,67 @@
package com.adc.da.slrs.sarPersonalCenter.controller;
import com.adc.da.http.ResponseMessage;
import com.adc.da.http.Result;
import com.adc.da.slrs.sarPersonalCenter.entity.SarUserStarEO;
import com.adc.da.slrs.sarPersonalCenter.service.ISarUserStarService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.adc.da.slrs.sarPersonalCenter.entity.SarUserStar;
import io.swagger.annotations.Api;
import com.adc.da.base.web.BaseController;
import java.util.Date;
/**
* <p>
* 前端控制器
* </p>
*
* @author zyl
* @since 2021-06-21
*/
@RestController
@Api(tags = "福田标准法规--个人中心--我的收藏")
@RequestMapping("/${restPath}/sarPersonalCenter/sar-user-star")
public class SarUserStarController extends BaseController<SarUserStar> {
@Autowired
private ISarUserStarService iSarUserStarService;
@ApiOperation("获取用户收藏列表")
@GetMapping("/getList")
public ResponseMessage<IPage<SarUserStar>> getUserStarList(SarUserStarEO sarUserStarEO) {
return iSarUserStarService.getUserStarList(sarUserStarEO);
}
@ApiOperation("批量删除用户收藏")
@PostMapping("/deleteList")
public ResponseMessage<IPage<SarUserStar>> deleteList(@RequestBody SarUserStarEO sarUserStars) {
return iSarUserStarService.deleteList(sarUserStars);
}
@ApiOperation("删除用户收藏")
@PostMapping("/delete")
public ResponseMessage<Boolean> deleteById(@RequestBody SarUserStarEO sarUserStars) {
return iSarUserStarService.deleteById(sarUserStars);
}
@ApiOperation("添加用户收藏")
@PostMapping("/addStar")
public ResponseMessage<Boolean> addStar(@RequestBody SarUserStar sarUserStar) {
return iSarUserStarService.addStar(sarUserStar);
}
@ApiOperation("获取当前用户是否收藏该页面")
@GetMapping("/isStar")
public ResponseMessage<Boolean> isStar(String userId, String url) {
return iSarUserStarService.isStar(userId,url);
}
}
@@ -0,0 +1,16 @@
package com.adc.da.slrs.sarPersonalCenter.dao;
import com.adc.da.slrs.sarPersonalCenter.entity.SarUserPersonalMenu;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* <p>
* Mapper 接口
* </p>
*
* @author zyl
* @since 2021-06-22
*/
public interface SarUserPersonalMenuDao extends BaseMapper<SarUserPersonalMenu> {
}
@@ -0,0 +1,16 @@
package com.adc.da.slrs.sarPersonalCenter.dao;
import com.adc.da.slrs.sarPersonalCenter.entity.SarUserStar;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* <p>
* Mapper 接口
* </p>
*
* @author zyl
* @since 2021-06-21
*/
public interface SarUserStarDao extends BaseMapper<SarUserStar> {
}
@@ -0,0 +1,49 @@
package com.adc.da.slrs.sarPersonalCenter.entity;
import com.adc.da.base.entity.BaseEntity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
/**
* <p>
*
* </p>
*
* @author zyl
* @since 2021-06-22
*/
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@ApiModel(value="SarUserPersonalMenu对象", description="")
public class SarUserPersonalMenu extends BaseEntity {
@TableId(type = IdType.UUID)
@ApiModelProperty("id")
private String id;
private String menuName;
private String menuId;
private Integer state;
private String userId;
private String menuUrl;
public SarUserPersonalMenu(String menuName, String menuId, String menuUrl) {
this.menuName = menuName;
this.menuId = menuId;
this.menuUrl = menuUrl;
}
public SarUserPersonalMenu() {
}
}
@@ -0,0 +1,34 @@
package com.adc.da.slrs.sarPersonalCenter.entity;
import com.adc.da.base.entity.BaseEntity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.util.List;
/**
* <p>
*
* </p>
*
* @author zyl
* @since 2021-06-22
*/
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@ApiModel(value="SarUserPersonalMenu批量操作对象", description="")
public class SarUserPersonalMenuEO extends SarUserPersonalMenu {
@ApiModelProperty("当页数量")
private Integer size=20;
@ApiModelProperty("当前页数")
private Integer current=1;
@ApiModelProperty("操作信息")
private List<SarUserPersonalMenu> sarUserPersonalMenus;
}
@@ -0,0 +1,55 @@
package com.adc.da.slrs.sarPersonalCenter.entity;
import com.adc.da.base.entity.BaseEntity;
import java.time.LocalDateTime;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.springframework.format.annotation.DateTimeFormat;
/**
* <p>
*
* </p>
*
* @author zyl
* @since 2021-06-21
*/
@EqualsAndHashCode(callSuper = true)
@Data
@ApiModel(value="SarUserStar对象", description="")
public class SarUserStar extends BaseEntity {
@ApiModelProperty("id")
private String id;
@ApiModelProperty(value = "收藏名")
private String name;
@ApiModelProperty(value = "收藏类型")
private String type;
@ApiModelProperty(value = "收藏具体信息")
private String info;
@ApiModelProperty(value = "用户id")
private String userId;
@ApiModelProperty(value = "所属模块")
private String modular;
@ApiModelProperty(value = "创建时间")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@JsonFormat(locale = "zh", timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
private Date createTime;
@ApiModelProperty(value = "该收藏对应的路由")
private String url;
}
@@ -0,0 +1,25 @@
package com.adc.da.slrs.sarPersonalCenter.entity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import java.util.List;
@Data
@Accessors(chain = true)
@ApiModel(value="SarUserStar批量操作对象", description="")
public class SarUserStarEO extends SarUserStar{
@ApiModelProperty("当页数量")
private Integer size=20;
@ApiModelProperty("当前页数")
private Integer current=1;
@ApiModelProperty("操作信息")
private List<SarUserStar> sarUserStars;
}
@@ -0,0 +1,33 @@
package com.adc.da.slrs.sarPersonalCenter.service;
import com.adc.da.http.ResponseMessage;
import com.adc.da.slrs.sarMenu.entity.SarMenu;
import com.adc.da.slrs.sarPersonalCenter.entity.SarUserPersonalMenu;
import com.adc.da.slrs.sarPersonalCenter.entity.SarUserPersonalMenuEO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
/**
* <p>
* 服务类
* </p>
*
* @author zyl
* @since 2021-06-22
*/
public interface ISarUserPersonalMenuService extends IService<SarUserPersonalMenu> {
public ResponseMessage<IPage<SarUserPersonalMenu>> getUserPersonalMenu(SarUserPersonalMenuEO eo);
public ResponseMessage<IPage<SarUserPersonalMenu>> updateUserPersonalMenu(SarUserPersonalMenuEO eo);
public void updateUserPersonalMenuForRole(List<SarMenu> menus, String userId);
/**
* 更新用户权限
* @param roleId:角色ID
*/
void setPersonalMenu(String roleId);
}
@@ -0,0 +1,25 @@
package com.adc.da.slrs.sarPersonalCenter.service;
import com.adc.da.http.ResponseMessage;
import com.adc.da.http.Result;
import com.adc.da.slrs.sarPersonalCenter.entity.SarUserStar;
import com.adc.da.slrs.sarPersonalCenter.entity.SarUserStarEO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import org.springframework.web.bind.annotation.RequestBody;
/**
* <p>
* 服务类
* </p>
*
* @author zyl
* @since 2021-06-21
*/
public interface ISarUserStarService extends IService<SarUserStar> {
public ResponseMessage<IPage<SarUserStar>> getUserStarList(SarUserStarEO sarUserStarEO);
public ResponseMessage<IPage<SarUserStar>> deleteList(@RequestBody SarUserStarEO sarUserStars);
public ResponseMessage<Boolean> deleteById(@RequestBody SarUserStarEO sarUserStars);
public ResponseMessage<Boolean> addStar(@RequestBody SarUserStar sarUserStar);
public ResponseMessage<Boolean> isStar(String userId, String url);
}
@@ -0,0 +1,124 @@
package com.adc.da.slrs.sarPersonalCenter.service.impl;
import com.adc.da.http.ResponseMessage;
import com.adc.da.http.Result;
import com.adc.da.slrs.sarMenu.entity.SarMenu;
import com.adc.da.slrs.sarPersonalCenter.entity.SarUserPersonalMenu;
import com.adc.da.slrs.sarPersonalCenter.dao.SarUserPersonalMenuDao;
import com.adc.da.slrs.sarPersonalCenter.entity.SarUserPersonalMenuEO;
import com.adc.da.slrs.sarPersonalCenter.service.ISarUserPersonalMenuService;
import com.adc.da.slrs.sarUser.service.impl.TsUserServiceImpl;
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.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import java.util.*;
/**
* <p>
* 服务实现类
* </p>
*
* @author zyl
* @since 2021-06-22
*/
@Service
public class SarUserPersonalMenuServiceImpl extends ServiceImpl<SarUserPersonalMenuDao, SarUserPersonalMenu> implements ISarUserPersonalMenuService {
@Autowired
@Lazy
private TsUserServiceImpl tsUserService;
@Override
public ResponseMessage<IPage<SarUserPersonalMenu>> getUserPersonalMenu(SarUserPersonalMenuEO eo) {
if(eo.getUserId()==null||eo.getUserId().trim().length()==0){
return Result.error("userId不能为空");
}
QueryWrapper<SarUserPersonalMenu> queryWrapper=new QueryWrapper<>();
queryWrapper.eq("user_id",eo.getUserId());
if(eo.getMenuUrl()!=null)queryWrapper.eq("menu_url",eo.getMenuUrl());
if(eo.getMenuName()!=null&&eo.getMenuName().trim().length()>0)queryWrapper.like("menu_name",eo.getMenuName().trim());
if(eo.getState()!=null)queryWrapper.eq("state",eo.getState());
IPage<SarUserPersonalMenu> iPage=new Page<>(eo.getCurrent(),eo.getSize());
IPage<SarUserPersonalMenu> page = page(iPage, queryWrapper);
while (page.getRecords().remove(null));
return Result.success(page);
}
@Override
public ResponseMessage<IPage<SarUserPersonalMenu>> updateUserPersonalMenu(SarUserPersonalMenuEO eo) {
if(eo.getUserId()==null||eo.getUserId().trim().length()==0){
return Result.error("userId不能为空");
}
List<SarUserPersonalMenu> menus=new ArrayList<>();
if(eo.getSarUserPersonalMenus()!=null){
for (SarUserPersonalMenu menu : eo.getSarUserPersonalMenus()) {
if(menu.getId()!=null&&menu.getId().trim().length()>0&&menu.getState()!=null){
SarUserPersonalMenu sarUserPersonalMenu=new SarUserPersonalMenu();
sarUserPersonalMenu.setState(menu.getState()==0?0:1);
QueryWrapper<SarUserPersonalMenu> queryWrapper=new QueryWrapper<>();
queryWrapper.eq("user_id",eo.getUserId());
queryWrapper.eq("id",menu.getId());
update(sarUserPersonalMenu,queryWrapper);
}
}
}
return getUserPersonalMenu(eo);
}
@Override
public void updateUserPersonalMenuForRole(List<SarMenu> menuList,String userId) {
Set<String> ids=new HashSet<>();
for (SarMenu menu : menuList) {
if(menu.getId()!=null&&menu.getId().trim().length()>0){
QueryWrapper<SarUserPersonalMenu> queryWrapper=new QueryWrapper<>();
queryWrapper.eq("user_id",userId);
queryWrapper.eq("menu_id",menu.getId());
List<SarUserPersonalMenu> menus = getBaseMapper().selectList(queryWrapper);
if (menus.size()>0) {
ids.add(menus.get(0).getId());
continue;
}
SarUserPersonalMenu sarUserPersonalMenu=new SarUserPersonalMenu();
sarUserPersonalMenu.setMenuName(menu.getMenuName());
sarUserPersonalMenu.setMenuUrl(menu.getHref());
sarUserPersonalMenu.setUserId(userId);
sarUserPersonalMenu.setMenuId(menu.getId());
sarUserPersonalMenu.setState(0);
getBaseMapper().insert(sarUserPersonalMenu);
ids.add(sarUserPersonalMenu.getId());
}
}
QueryWrapper<SarUserPersonalMenu> queryWrapper=new QueryWrapper<>();
queryWrapper.notIn("id",ids);
queryWrapper.eq("user_id",userId);
getBaseMapper().delete(queryWrapper);
}
/**
* 更新用户权限
* @param roleId:角色ID
*/
@Async
@Override
public void setPersonalMenu(String roleId) {
List<String> userIds=tsUserService.getUserIdsByRoleId(roleId);
for(String userId:userIds){
List<SarMenu> menus=tsUserService.getMenusByUserId(userId);
updateUserPersonalMenuForRole(menus,userId);
}
}
}
@@ -0,0 +1,125 @@
package com.adc.da.slrs.sarPersonalCenter.service.impl;
import com.adc.da.http.ResponseMessage;
import com.adc.da.http.Result;
import com.adc.da.slrs.sarPersonalCenter.entity.SarUserStar;
import com.adc.da.slrs.sarPersonalCenter.dao.SarUserStarDao;
import com.adc.da.slrs.sarPersonalCenter.entity.SarUserStarEO;
import com.adc.da.slrs.sarPersonalCenter.service.ISarUserStarService;
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.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestBody;
import java.util.Date;
/**
* <p>
* 服务实现类
* </p>
*
* @author zyl
* @since 2021-06-21
*/
@Service
public class SarUserStarServiceImpl extends ServiceImpl<SarUserStarDao, SarUserStar> implements ISarUserStarService {
@Autowired
private ISarUserStarService iSarUserStarService;
@Override
public ResponseMessage<IPage<SarUserStar>> getUserStarList(SarUserStarEO sarUserStarEO) {
if (sarUserStarEO.getUserId() == null) {
return Result.error("userId不能为空");
} else {
if (sarUserStarEO.getSize() == null || sarUserStarEO.getSize() <= 0) sarUserStarEO.setSize(20);
if (sarUserStarEO.getCurrent() == null || sarUserStarEO.getCurrent() <= 0) sarUserStarEO.setCurrent(1);
QueryWrapper<SarUserStar> wrapper = new QueryWrapper<>();
wrapper.eq("user_id", sarUserStarEO.getUserId());
if(sarUserStarEO.getType()!=null)wrapper.like("type",sarUserStarEO.getType());
if(sarUserStarEO.getName()!=null)wrapper.like("name",sarUserStarEO.getName());
if(sarUserStarEO.getModular()!=null)wrapper.like("modular",sarUserStarEO.getModular());
if(sarUserStarEO.getInfo()!=null)wrapper.like("info",sarUserStarEO.getInfo());
if(sarUserStarEO.getUrl()!=null)wrapper.like("url",sarUserStarEO.getUrl());
IPage<SarUserStar> page = iSarUserStarService.page(new Page<>(sarUserStarEO.getCurrent(), sarUserStarEO.getSize()), wrapper);
while (page.getRecords().remove(null)) ;
return Result.success(page);
}
}
@Override
public ResponseMessage<IPage<SarUserStar>> deleteList(@RequestBody SarUserStarEO sarUserStars) {
if (sarUserStars.getUserId() == null) {
return Result.error("userId不能为空");
}
if (!(sarUserStars.getSarUserStars() == null || sarUserStars.getSarUserStars().size() <= 0)) {
for (SarUserStar sarUserStar : sarUserStars.getSarUserStars()) {
if (sarUserStar.getId() != null) {
QueryWrapper<SarUserStar> sarUserStarQueryWrapper = new QueryWrapper<>();
sarUserStarQueryWrapper.eq("id", sarUserStar.getId());
sarUserStarQueryWrapper.eq("user_id", sarUserStars.getUserId());
iSarUserStarService.remove(sarUserStarQueryWrapper);
}
}
}
return getUserStarList(sarUserStars);
}
@Override
public ResponseMessage<Boolean> deleteById(@RequestBody SarUserStarEO sarUserStars) {
if (sarUserStars.getUserId() == null) {
return Result.error("userId不能为空");
}
if ((sarUserStars.getId() == null && sarUserStars.getUrl() == null)) {
return Result.error("url或id不能为空");
}
QueryWrapper<SarUserStar> sarUserStarQueryWrapper = new QueryWrapper<>();
if(sarUserStars.getId()!=null)sarUserStarQueryWrapper.eq("id", sarUserStars.getId());
else sarUserStarQueryWrapper.eq("url", sarUserStars.getUrl());
sarUserStarQueryWrapper.eq("user_id", sarUserStars.getUserId());
return Result.success(iSarUserStarService.remove(sarUserStarQueryWrapper));
}
@Override
public ResponseMessage<Boolean> addStar(@RequestBody SarUserStar sarUserStar) {
if (sarUserStar.getUserId() == null) {
return Result.error("userId不能为空");
}
if (sarUserStar.getUrl() == null
&& sarUserStar.getModular() == null
&& sarUserStar.getName() == null
&& sarUserStar.getType() == null) {
return Result.error("数据有误");
}
sarUserStar.setId(null);
sarUserStar.setCreateTime(new Date());
return Result.success(iSarUserStarService.save(sarUserStar));
}
@Override
public ResponseMessage<Boolean> isStar(String userId, String url) {
if (userId == null) {
return Result.error("userId不能为空");
}
if (url == null) {
return Result.error("url不能为空");
}
QueryWrapper<SarUserStar> sarUserStarQueryWrapper = new QueryWrapper<>();
sarUserStarQueryWrapper.eq("user_id", userId);
sarUserStarQueryWrapper.eq("url", url);
int count = iSarUserStarService.count(sarUserStarQueryWrapper);
return Result.success(count > 0);
}
}
@@ -0,0 +1,76 @@
package com.adc.da.slrs.sarPosition.controller;
import com.adc.da.http.ResponseMessage;
import com.adc.da.http.Result;
import com.adc.da.slrs.sarPosition.entity.TsPositionRoleVO;
import com.adc.da.slrs.sarPosition.service.ITsPositionService;
import com.adc.da.slrs.sarRole.entity.TsRole;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import com.adc.da.slrs.sarPosition.entity.TsPosition;
import io.swagger.annotations.Api;
import com.adc.da.base.web.BaseController;
import javax.validation.Valid;
import java.util.List;
/**
* <p>
* 前端控制器
* </p>
*
* @author zyl
* @since 2021-06-23
*/
@RestController
@Api(tags = "|岗位管理|")
@RequestMapping("/api/sarPosition/position")
public class TsPositionController extends BaseController<TsPosition> {
@Autowired
private ITsPositionService tsPositionService;
/**
* 查询岗位(可通过name筛选)
* @param tsPosition:筛选信息
*/
@ApiOperation("查询岗位")
@GetMapping
public ResponseMessage<List<TsPosition>> getPosition(TsPosition tsPosition){
List<TsPosition> positions=tsPositionService.getPosition(tsPosition);
return Result.success(positions);
}
@ApiOperation("新增岗位")
@PostMapping
public ResponseMessage<Object> addPosition(@Validated(TsPosition.insert.class) TsPosition tsPosition){
return tsPositionService.addPosition(tsPosition);
}
@ApiOperation("配置角色")
@PostMapping("/role")
public ResponseMessage<List<TsRole>> setRole(@Valid @RequestBody TsPositionRoleVO tsPositionRoleVO){
return tsPositionService.setRole(tsPositionRoleVO);
}
@ApiOperation("查询角色")
@GetMapping("/role")
public ResponseMessage<List<TsRole>> getRole(@RequestParam String positionId){
List<TsRole> roles=tsPositionService.getRole(positionId);
return Result.success(roles);
}
@ApiOperation("编辑岗位")
@PutMapping
public ResponseMessage<Object> updatePosition(@Validated(TsPosition.update.class) TsPosition tsPosition){
return tsPositionService.updatePosition(tsPosition);
}
@ApiOperation("删除岗位")
@DeleteMapping
public ResponseMessage<Object> deletePosition(@RequestParam String positionId){
return tsPositionService.deletePosition(positionId);
}
}
@@ -0,0 +1,74 @@
package com.adc.da.slrs.sarPosition.dao;
import com.adc.da.slrs.sarPosition.entity.TsPosition;
import com.adc.da.slrs.sarRole.entity.TsRole;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import java.util.List;
/**
* <p>
* Mapper 接口
* </p>
*
* @author zyl
* @since 2021-06-23
*/
public interface TsPositionDao extends BaseMapper<TsPosition> {
/**
* 查询岗位绑定的角色ID
* @param positionId:岗位ID
* @return List<String>:角色ID
*/
@Select("select role_id from ts_position_role where position_id=#{positionId}")
List<String> getRoleId(String positionId);
/**
* 绑定角色
* @param positionId:岗位ID
* @param roleId:角色ID
*/
@Insert("insert into ts_position_role (position_id,role_id) values (#{positionId},#{roleId})")
void insertRole(String positionId, String roleId);
/**
* 解绑角色
* @param positionId:岗位ID
* @param roleId:角色ID
*/
@Delete("delete from ts_position_role where position_id=#{positionId} and role_id=#{roleId}")
void deleteRole(String positionId, String roleId);
/**
* 查询岗位绑定的角色信息
* @param positionId:岗位ID
* @return List<TsRole>
*/
List<TsRole> getRole(String positionId);
/**
* 查询岗位以及绑定的角色信息
* @param tsPosition:岗位信息
* @return List<TsPosition>
*/
List<TsPosition> selectPositionAndRole(TsPosition tsPosition);
/**
* 通过岗位列表查询绑定的角色列表
* @param positionIds:岗位列表
* @return List<String>
*/
List<String> getRoleIdsByPositionIds(List<String> positionIds);
/**
* 通过roleId查询岗位ID列表
* @param roleId:角色ID
* @return List<String>
*/
@Select("select position_id from ts_position_role where role_id=#{roleId}")
List<String> getPositionIdsByRoleId(String roleId);
}
@@ -0,0 +1,80 @@
package com.adc.da.slrs.sarPosition.entity;
import com.adc.da.base.entity.BaseEntity;
import java.sql.Timestamp;
import java.time.LocalDateTime;
import java.util.List;
import com.adc.da.slrs.sarRole.entity.TsRole;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.springframework.format.annotation.DateTimeFormat;
import javax.validation.constraints.NotNull;
/**
* <p>
*
* </p>
*
* @author zyl
* @since 2021-06-23
*/
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@ApiModel(value="TsPosition对象", description="")
public class TsPosition extends BaseEntity {
public interface insert{
}
public interface update{
}
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "操作时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Timestamp operateTime;
@ApiModelProperty(value = "操作人")
private String operator;
@NotNull(message = "name不能为空",groups = {insert.class})
@ApiModelProperty(value = "岗位名称")
private String name;
@ApiModelProperty(value = "创建部门ID")
private String createDeptId;
@ApiModelProperty(value = "创建人ID")
private String createById;
@ApiModelProperty(value = "类型(1为导入,2为新建)")
private String type;
@NotNull(message = "id不能为空",groups = {update.class})
@ApiModelProperty(value = "ID")
@TableId(value = "id",type = IdType.UUID)
private String id;
@ApiModelProperty(value = "绑定角色")
@TableField(exist = false)
private List<TsRole> roles;
@ApiModelProperty(value = "创建时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Timestamp createTime;
}
@@ -0,0 +1,15 @@
package com.adc.da.slrs.sarPosition.entity;
import com.adc.da.slrs.sarRole.entity.TsRole;
import lombok.Data;
import javax.validation.constraints.NotNull;
import java.util.List;
@Data
public class TsPositionRoleVO {
@NotNull(message = "positionId不能为空")
private String positionId;
@NotNull(message = "roleIds不能为空")
private List<String> roleIds;
}
@@ -0,0 +1,76 @@
package com.adc.da.slrs.sarPosition.service;
import com.adc.da.http.ResponseMessage;
import com.adc.da.slrs.sarPosition.entity.TsPosition;
import com.adc.da.slrs.sarPosition.entity.TsPositionRoleVO;
import com.adc.da.slrs.sarRole.entity.TsRole;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
/**
* <p>
* 服务类
* </p>
*
* @author zyl
* @since 2021-06-23
*/
public interface ITsPositionService extends IService<TsPosition> {
/**
* 查询岗位
* @param tsPosition:查询信息
* @return List<TsPosition>
*/
List<TsPosition> getPosition(TsPosition tsPosition);
/**
* 配置角色
* @param tsPositionRoleVO :角色ID
* @return ResponseMessage<Object>
*/
ResponseMessage<List<TsRole>> setRole(TsPositionRoleVO tsPositionRoleVO);
/**
* 查询角色
* @param positionId :岗位ID
* @return List<TsRole>
*/
List<TsRole> getRole(String positionId);
/**
* 添加岗位
* @param tsPosition:岗位信息
* @return ResponseMessage<Object>
*/
ResponseMessage<Object> addPosition(TsPosition tsPosition);
/**
* 修改岗位
* @param tsPosition:岗位信息
* @return ResponseMessage<Object>
*/
ResponseMessage<Object> updatePosition(TsPosition tsPosition);
/**
* 删除岗位
* @param positionId:岗位ID
* @return ResponseMessage<Object>
*/
ResponseMessage<Object> deletePosition(String positionId);
/**
* 通过岗位列表查询绑定的角色列表
* @param positionIds:岗位列表
* @return List<String>
*/
List<String> getRoleIdsByPositionIds(List<String> positionIds);
/**
* 通过roleId查询岗位ID列表
* @param roleId:角色ID
* @return List<String>
*/
List<String> getPositionIdsByRoleId(String roleId);
}
@@ -0,0 +1,160 @@
package com.adc.da.slrs.sarPosition.service.impl;
import com.adc.da.http.ResponseMessage;
import com.adc.da.http.Result;
import com.adc.da.slrs.sarPosition.entity.TsPosition;
import com.adc.da.slrs.sarPosition.dao.TsPositionDao;
import com.adc.da.slrs.sarPosition.entity.TsPositionRoleVO;
import com.adc.da.slrs.sarPosition.service.ITsPositionService;
import com.adc.da.slrs.sarRole.entity.TsRole;
import com.adc.da.utils.util.ListUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.management.relation.Role;
import java.util.List;
import java.util.Map;
/**
* <p>
* 服务实现类
* </p>
*
* @author zyl
* @since 2021-06-23
*/
@Service
public class TsPositionServiceImpl extends ServiceImpl<TsPositionDao, TsPosition> implements ITsPositionService {
@Autowired
private TsPositionDao tsPositionDao;
/**
* 查询岗位
* @param tsPosition:查询信息
* @return List<TsPosition>
*/
@Override
public List<TsPosition> getPosition(TsPosition tsPosition) {
return tsPositionDao.selectPositionAndRole(tsPosition);
}
/**
* 配置角色
* @param tsPositionRoleVO :角色ID
* @return ResponseMessage<Object>
*/
@Override
@Transactional
public ResponseMessage<List<TsRole>> setRole(TsPositionRoleVO tsPositionRoleVO) {
TsPosition position=tsPositionDao.selectById(tsPositionRoleVO.getPositionId());
if(position==null){
return Result.error("该岗位不存在");
}
List<String> oldRoleIds=tsPositionDao.getRoleId(tsPositionRoleVO.getPositionId());
Map<String,List<String>> updateRoleIds= ListUtil.difList(tsPositionRoleVO.getRoleIds(),oldRoleIds);
List<String> insertIds=updateRoleIds.get("insert");
List<String> deleteIds=updateRoleIds.get("delete");
for(String id:insertIds){
tsPositionDao.insertRole(tsPositionRoleVO.getPositionId(),id);
}
for(String id:deleteIds){
tsPositionDao.deleteRole(tsPositionRoleVO.getPositionId(),id);
}
List<TsRole> roles=getRole(tsPositionRoleVO.getPositionId());
return Result.success(roles);
}
/**
* 查询角色
* @param positionId :岗位ID
* @return List<TsRole>
*/
@Override
public List<TsRole> getRole(String positionId) {
return tsPositionDao.getRole(positionId);
}
/**
* 添加岗位
* @param tsPosition:岗位信息
* @return ResponseMessage<Object>
*/
@Override
public ResponseMessage<Object> addPosition(TsPosition tsPosition) {
QueryWrapper<TsPosition> positionQueryWrapper=new QueryWrapper<>();
positionQueryWrapper.eq("name",tsPosition.getName());
List<TsPosition> tsPositions=tsPositionDao.selectList(positionQueryWrapper);
if(tsPositions!=null&&tsPositions.size()>0){
return Result.error("该岗位已存在");
}
tsPosition.setType("2");
tsPositionDao.insert(tsPosition);
return Result.success();
}
/**
* 修改岗位
* @param tsPosition:岗位信息
* @return ResponseMessage<Object>
*/
@Override
public ResponseMessage<Object> updatePosition(TsPosition tsPosition) {
TsPosition oldPosition=tsPositionDao.selectById(tsPosition.getId());
if(oldPosition==null){
return Result.error("该岗位不存在");
}
if(!oldPosition.getType().equals("2")){
return Result.error("该岗位不可修改");
}
tsPositionDao.updateById(tsPosition);
return Result.success();
}
/**
* 删除岗位
* @param positionId:岗位ID
* @return ResponseMessage<Object>
*/
@Override
public ResponseMessage<Object> deletePosition(String positionId) {
TsPosition oldPosition=tsPositionDao.selectById(positionId);
if(oldPosition==null){
return Result.error("该岗位不存在");
}
if(!oldPosition.getType().equals("2")){
return Result.error("该岗位不可删除");
}
List<String> roleIds=tsPositionDao.getRoleId(positionId);
if(roleIds!=null&&roleIds.size()>0){
return Result.error("该岗位已绑定角色,无法删除");
}
tsPositionDao.deleteById(positionId);
return Result.success();
}
/**
* 通过岗位列表查询绑定的角色列表
* @param positionIds:岗位列表
* @return List<String>
*/
@Override
public List<String> getRoleIdsByPositionIds(List<String> positionIds) {
if(positionIds!=null&&positionIds.size()>0){
return tsPositionDao.getRoleIdsByPositionIds(positionIds);
}
return null;
}
/**
* 通过roleId查询岗位ID列表
* @param roleId:角色ID
* @return List<String>
*/
@Override
public List<String> getPositionIdsByRoleId(String roleId) {
return tsPositionDao.getPositionIdsByRoleId(roleId);
}
}
@@ -0,0 +1,57 @@
package com.adc.da.slrs.sarResource.controller;
import com.adc.da.base.web.BaseController;
import com.adc.da.http.ResponseMessage;
import com.adc.da.http.Result;
import com.adc.da.slrs.sarResource.entity.TsResource;
import com.adc.da.slrs.sarResource.service.ITsResourceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* <p>
* 前端控制器
* </p>
*
* @author zyl
* @since 2021-06-30
*/
@RestController
@Api(tags = "资源管理")
@RequestMapping("/api/sarResource/ts-resource")
public class TsResourceController extends BaseController<TsResource> {
@Autowired
private ITsResourceService tsResourceService;
@ApiOperation("查询所有资源")
@GetMapping
public ResponseMessage<List<TsResource>> getAll(TsResource tsResource){
List<TsResource> tsResources=tsResourceService.getAll(tsResource);
return Result.success(tsResources);
}
@ApiOperation("添加资源")
@PostMapping("/add")
public ResponseMessage<Object> addResource(@RequestBody TsResource tsResource){
return tsResourceService.addResource(tsResource);
}
@ApiOperation("编辑资源")
@PutMapping
public ResponseMessage<Object> updateResource(@Validated(TsResource.update.class) @RequestBody TsResource tsResource){
return tsResourceService.updateResource(tsResource);
}
@ApiOperation("删除资源")
@DeleteMapping
public ResponseMessage<Object> delResource(@RequestParam String resourceId){
return tsResourceService.delResource(resourceId);
}
}
@@ -0,0 +1,16 @@
package com.adc.da.slrs.sarResource.dao;
import com.adc.da.slrs.sarResource.entity.TsResource;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* <p>
* Mapper 接口
* </p>
*
* @author zyl
* @since 2021-06-30
*/
public interface TsResourceDao extends BaseMapper<TsResource> {
}
@@ -0,0 +1,88 @@
package com.adc.da.slrs.sarResource.entity;
import com.adc.da.base.entity.BaseEntity;
import com.adc.da.slrs.sarMenu.entity.SarMenu;
import com.adc.da.utils.treetool.annotation.TreeNodeName;
import com.adc.da.utils.treetool.annotation.TreeNodeParentId;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import javax.validation.constraints.NotNull;
import java.util.Date;
import java.util.List;
/**
* <p>
*
* </p>
*
* @author zyl
* @since 2021-06-30
*/
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@ApiModel(value="TsResource对象", description="")
public class TsResource extends BaseEntity {
public interface update{
}
private static final long serialVersionUID = 1L;
@NotNull(message = "id不能为空",groups = {SarMenu.update.class})
@ApiModelProperty(value = "主键")
@TableId(value = "ID",type = IdType.UUID)
private String id;
@ApiModelProperty(value = "标准法规划分")
@TableField("SOR_DIVIDE")
private String sorDivide;
@TreeNodeName
@ApiModelProperty(value = "目录名称")
@TableField("MENU_NAME")
private String menuName;
@TreeNodeParentId
@ApiModelProperty(value = "父级ID")
@TableField("PARENT_ID")
private String parentId;
@ApiModelProperty(value = "父级ID集合")
@TableField("PARENT_IDS")
private String parentIds;
@ApiModelProperty(value = "排序序号")
@TableField("DISPLAY_SEQ")
private Integer displaySeq;
@ApiModelProperty(value = "是否有效")
@TableField("VALID_FLAG")
private Integer validFlag;
@ApiModelProperty(value = "创建时间")
@TableField("CREATION_TIME")
private Date creationTime;
@ApiModelProperty(value = "修改时间")
@TableField("MODIFY_TIME")
private Date modifyTime;
@ApiModelProperty(value = "备注")
@TableField("REMARKS")
private String remarks;
@ApiModelProperty(value = "子菜单")
@TableField(exist = false)
private List<TsResource> children;
}
@@ -0,0 +1,34 @@
package com.adc.da.slrs.sarResource.service;
import com.adc.da.http.ResponseMessage;
import com.adc.da.slrs.sarResource.entity.TsResource;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
/**
* <p>
* 服务类
* </p>
*
* @author zyl
* @since 2021-06-30
*/
public interface ITsResourceService extends IService<TsResource> {
List<TsResource> getAll(TsResource tsResource);
ResponseMessage<Object> addResource(TsResource tsResource);
ResponseMessage<Object> updateResource(TsResource tsResource);
ResponseMessage<Object> delResource(String resourceId);
/**
* 通过Ids查询menu
* @param resourceIds :菜单Ids
* @param sorDivide
* @return List<Menu>
*/
List<TsResource> getResourceByIds(List<String> resourceIds, String sorDivide);
}
@@ -0,0 +1,135 @@
package com.adc.da.slrs.sarResource.service.impl;
import com.adc.da.http.ResponseMessage;
import com.adc.da.http.Result;
import com.adc.da.slrs.sarResource.dao.TsResourceDao;
import com.adc.da.slrs.sarResource.entity.TsResource;
import com.adc.da.slrs.sarResource.service.ITsResourceService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
/**
* <p>
* 服务实现类
* </p>
*
* @author zyl
* @since 2021-06-30
*/
@Service
public class TsResourceServiceImpl extends ServiceImpl<TsResourceDao, TsResource> implements ITsResourceService {
@Autowired
private TsResourceDao dao;
/**
* 查询所有菜单
* @param tsResource
*/
@Override
public List<TsResource> getAll(TsResource tsResource) {
QueryWrapper<TsResource> tsResourceQueryWrapper=new QueryWrapper<>();
if(tsResource.getSorDivide()!=null){
tsResourceQueryWrapper.eq("sor_divide",tsResource.getSorDivide());
}
tsResourceQueryWrapper.isNull("PARENT_ID");
List<TsResource> TsResources=dao.selectList(tsResourceQueryWrapper);
for(TsResource TsResource:TsResources){
TsResource.setChildren(recursionGetChildren((TsResource)));
}
return TsResources;
}
/**
* 添加菜单
* @param TsResource:菜单信息
* @return ResponseMessage<Object>
*/
@Override
public ResponseMessage<Object> addResource(TsResource TsResource) {
if(TsResource.getParentId()!=null){
TsResource parent=dao.selectById(TsResource.getParentId());
if(parent==null){
return Result.error("该父菜单不存在");
}
}
dao.insert(TsResource);
return Result.success();
}
/**
* 编辑菜单
* @param TsResource:菜单信息
* @return ResponseMessage<Object>
*/
@Override
public ResponseMessage<Object> updateResource(TsResource TsResource) {
TsResource oldResource=dao.selectById(TsResource.getId());
if(oldResource==null){
return Result.error("该菜单不存在");
}
if(TsResource.getParentId()!=null){
TsResource parent=dao.selectById(TsResource.getParentId());
if(parent==null){
return Result.error("父节点不存在");
}
}
dao.updateById(TsResource);
return Result.success();
}
/**
* 删除菜单
* @param ResourceId:菜单ID
* @return ResponseMessage<Object>
*/
@Override
public ResponseMessage<Object> delResource(String ResourceId) {
QueryWrapper<TsResource> TsResourceQueryWrapper=new QueryWrapper<>();
TsResourceQueryWrapper.eq("parent_id",ResourceId);
List<TsResource> children=dao.selectList(TsResourceQueryWrapper);
if(children!=null&&children.size()>0){
return Result.error("该菜单有子节点,无法删除");
}
dao.deleteById(ResourceId);
return Result.success();
}
/**
* 通过Ids查询Resource
* @param resourceIds :菜单Ids
* @param sorDivide
* @return List<Resource>
*/
@Override
public List<TsResource> getResourceByIds(List<String> resourceIds, String sorDivide) {
if(resourceIds!=null&&resourceIds.size()>0){
QueryWrapper<TsResource> TsResourceQueryWrapper=new QueryWrapper<>();
if(sorDivide!=null){
TsResourceQueryWrapper.eq("sor_divide",sorDivide);
}
TsResourceQueryWrapper.in("id",resourceIds);
return dao.selectList(TsResourceQueryWrapper);
}
return new ArrayList<>();
}
/**
* 递归调用获取子节点
* @param parent:父节点
* @return List<TsResource>
*/
private List<TsResource> recursionGetChildren(TsResource parent){
QueryWrapper<TsResource> TsResourceQueryWrapper=new QueryWrapper<>();
TsResourceQueryWrapper.eq("PARENT_ID",parent.getId());
List<TsResource> children=dao.selectList(TsResourceQueryWrapper);
for(TsResource TsResource:children){
TsResource.setChildren(recursionGetChildren((TsResource)));
}
return children;
}
}
@@ -0,0 +1,115 @@
package com.adc.da.slrs.sarRole.controller;
import com.adc.da.http.ResponseMessage;
import com.adc.da.http.Result;
import com.adc.da.login.util.UserUtils;
import com.adc.da.slrs.sarMenu.entity.SarMenu;
import com.adc.da.slrs.sarRole.entity.TsRoleMenuVO;
import com.adc.da.slrs.sarRole.entity.TsRoleResourceVO;
import com.adc.da.slrs.sarRole.service.ITsRoleService;
import com.adc.da.sys.entity.UserEO;
import io.swagger.annotations.ApiOperation;
import org.apache.ibatis.annotations.Delete;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import com.adc.da.slrs.sarRole.entity.TsRole;
import io.swagger.annotations.Api;
import com.adc.da.base.web.BaseController;
import javax.validation.Valid;
import java.util.List;
/**
* <p>
* 前端控制器
* </p>
*
* @author zxy
* @since 2021-06-22
*/
@RestController
@Api(tags = "|角色管理|")
@RequestMapping("/api/sarRole/role")
public class TsRoleController extends BaseController<TsRole> {
@Autowired
private ITsRoleService tsRoleService;
@ApiOperation("查询所有角色")
@GetMapping
public ResponseMessage<List<TsRole>> getAll(){
List<TsRole> tsRoles=tsRoleService.getAll();
return Result.success(tsRoles);
}
@ApiOperation("根据角色名筛选角色")
@GetMapping("/name")
public ResponseMessage<List<TsRole>> getByName(String name){
List<TsRole> tsRoles=tsRoleService.getByName(name);
return Result.success(tsRoles);
}
@ApiOperation("新增角色")
@PostMapping
public ResponseMessage<Object> addRole(@Validated(TsRole.insert.class) @RequestBody TsRole tsRole){
//设置操作人
UserEO userEO=UserUtils.getUser();
tsRole.setOperator(userEO.getUname());
return tsRoleService.addRole(tsRole);
}
@ApiOperation("编辑角色")
@PutMapping
public ResponseMessage<Object> updateRole(@Validated(TsRole.update.class)@RequestBody TsRole tsRole){
//设置操作人
UserEO userEO=UserUtils.getUser();
tsRole.setOperator(userEO.getUname());
System.out.println(tsRole);
return tsRoleService.updateRole(tsRole);
}
@ApiOperation("删除角色")
@DeleteMapping
public ResponseMessage<Object> deleteRole(@RequestParam String roleId){
return tsRoleService.deleteRole(roleId);
}
@ApiOperation("配置权限")
@PostMapping("/menu")
public ResponseMessage<Object> setMenu(@Valid @RequestBody TsRoleMenuVO tsRoleMenuVO){
return tsRoleService.setMenu(tsRoleMenuVO);
}
@ApiOperation("查询角色详情")
@GetMapping("/id")
public ResponseMessage<TsRole> getRoleById(@RequestParam String roleId){
TsRole tsRole=tsRoleService.getById(roleId);
if(tsRole.getParentId()!=null){
TsRole parent=tsRoleService.getById(tsRole.getParentId());
tsRole.setParent(parent.getName());
}
return Result.success(tsRole);
}
@ApiOperation("查询角色权限")
@GetMapping("/menu")
public ResponseMessage<List<String>> getMenu(@RequestParam String roleId){
List<String> menuIds=tsRoleService.getMenu(roleId);
return Result.success(menuIds);
}
@ApiOperation("配置资源")
@PostMapping("/resource")
public ResponseMessage<Object> setResource(@Valid @RequestBody TsRoleResourceVO tsRoleResourceVO){
return tsRoleService.setResource(tsRoleResourceVO);
}
@ApiOperation("查询角色资源")
@GetMapping("/resource")
public ResponseMessage<List<String>> getResource(@RequestParam String roleId){
List<String> resourceIds=tsRoleService.getResource(roleId);
return Result.success(resourceIds);
}
}
@@ -0,0 +1,94 @@
package com.adc.da.slrs.sarRole.dao;
import com.adc.da.slrs.sarRole.entity.TsRole;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import java.util.List;
/**
* <p>
* Mapper 接口
* </p>
*
* @author zyl
* @since 2021-06-22
*/
public interface TsRoleDao extends BaseMapper<TsRole> {
/**
* 查询该角色绑定的岗位ID
* @param roleId:角色ID
* @return List<String>:岗位ID
*/
@Select("select position_id from ts_position_role where role_id=#{roleId}")
List<String> getPositionIds(String roleId);
/**
* 查询角色的权限ID
* @param roleId:角色ID
* @return List<String>
*/
@Select("select menu_id from ts_role_menu where role_id=#{roleId}")
List<String> getMenuIds(String roleId);
/**
* 添加权限
* @param roleId:角色ID
* @param menuId:权限ID
*/
@Insert("insert into ts_role_menu (role_id,menu_id) values (#{roleId},#{menuId})")
void addMenu(String roleId, String menuId);
/**
* 删除权限
* @param roleId:角色ID
* @param menuId:权限ID
*/
@Delete("delete from ts_role_menu where role_id=#{roleId} and menu_id=#{menuId}")
void delMenu(String roleId, String menuId);
@Select("select menu_id from ts_role_menu where role_id=#{roleId}")
List<String> getMenuIdByRoleId(String roleId);
/**
* 通过角色Id列表查询菜单Id列表
* @param roleIds:角色ID列表
* @return List<String>
*/
List<String> getMenuIdsByRoleIds(List<String> roleIds);
/**
* 通过角色ID查询绑定的资源ID
* @param roleId:角色ID
* @return List<String>
*/
@Select("select resource_id from ts_role_resource where role_id=#{roleId}")
List<String> getResourceIds(String roleId);
/**
* 添加资源
* @param roleId:角色ID
* @param resourceId:权限ID
*/
@Insert("insert into ts_role_resource (role_id,resource_id) values (#{roleId},#{resourceId})")
void addResource(String roleId, String resourceId);
/**
* 删除权限
* @param roleId:角色ID
* @param resourceId:权限ID
*/
@Delete("delete from ts_role_resource where role_id=#{roleId} and resource_id=#{resourceId}")
void delResource(String roleId, String resourceId);
/**
* 通过角色Id列表查询资源Id列表
* @param roleIds:角色ID列表
* @return List<String>
*/
List<String> getResourceIdsByRoleIds(List<String> roleIds);
}
@@ -0,0 +1,127 @@
package com.adc.da.slrs.sarRole.entity;
import com.adc.da.base.entity.BaseEntity;
import java.math.BigDecimal;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import java.sql.Timestamp;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.List;
import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.springframework.format.annotation.DateTimeFormat;
import javax.validation.constraints.NotNull;
/**
* <p>
*
* </p>
*
* @author zyl
* @since 2021-06-22
*/
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@ApiModel(value="TsRole对象", description="")
public class TsRole extends BaseEntity {
public interface insert{
}
public interface update{
}
private static final long serialVersionUID = 1L;
@NotNull(message = "id不能为空",groups = {update.class})
@ApiModelProperty(value = "主键")
@TableId(value = "ID",type = IdType.UUID)
private String id;
@NotNull(message = "name不能为空",groups = {insert.class})
@ApiModelProperty(value = "角色名称")
@TableField("NAME")
private String name;
@ApiModelProperty(value = "角色类型")
@TableField("ROLE_TYPE")
private String roleType;
@ApiModelProperty(value = "角色状态")
@TableField("USE_FLAG")
private BigDecimal useFlag;
@ApiModelProperty(value = "是否默认")
@TableField("IS_DEFAULT")
private BigDecimal isDefault;
@ApiModelProperty(value = "角色描述")
@TableField("REMARKS")
private String remarks;
@ApiModelProperty(value = "操作时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Timestamp operateTime;
@ApiModelProperty(value = "操作人")
private String operator;
@ApiModelProperty(value = "备注")
@TableField("EXT_INFO")
private String extInfo;
@TableField("OPER_USER")
private String operUser;
@ApiModelProperty(value = "是否有效")
@TableField("VALID_FLAG")
private BigDecimal validFlag;
@ApiModelProperty(value = "创建时间")
@TableField("CREATION_TIME")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Timestamp creationTime;
@ApiModelProperty(value = "修改时间")
@TableField("MODIFY_TIME")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Timestamp modifyTime;
@ApiModelProperty(value = "上级节点id")
@TableField("PARENT_ID")
private String parentId;
@ApiModelProperty(value = "角色层级")
@TableField("ROLE_HIERARCHY")
private Integer roleHierarchy;
@ApiModelProperty(value = "对应部门id")
@TableField("DY_ORG_ID")
private String dyOrgId;
@ApiModelProperty(value = "对应部门名称")
@TableField("DY_ORG_NAME")
private String dyOrgName;
@ApiModelProperty(value = "子角色")
@TableField(exist = false)
private List<TsRole> children;
@ApiModelProperty("父节点名称")
@TableField(exist = false)
private String parent;
}
@@ -0,0 +1,14 @@
package com.adc.da.slrs.sarRole.entity;
import lombok.Data;
import javax.validation.constraints.NotNull;
import java.util.List;
@Data
public class TsRoleMenuVO {
@NotNull(message = "roleId不能为空")
private String roleId;
@NotNull(message = "menuIds不能为空")
private List<String> menuIds;
}
@@ -0,0 +1,14 @@
package com.adc.da.slrs.sarRole.entity;
import lombok.Data;
import javax.validation.constraints.NotNull;
import java.util.List;
@Data
public class TsRoleResourceVO {
@NotNull(message = "roleId不能为空")
private String roleId;
@NotNull(message = "resourceIds不能为空")
private List<String> resourceIds;
}
@@ -0,0 +1,81 @@
package com.adc.da.slrs.sarRole.service;
import com.adc.da.http.ResponseMessage;
import com.adc.da.slrs.sarRole.entity.TsRole;
import com.adc.da.slrs.sarRole.entity.TsRoleMenuVO;
import com.adc.da.slrs.sarRole.entity.TsRoleResourceVO;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
/**
* <p>
* 服务类
* </p>
*
* @author zyl
* @since 2021-06-22
*/
public interface ITsRoleService extends IService<TsRole> {
/**
* 查询所有角色
* @return List<TsRole>
*/
List<TsRole> getAll();
/**
* 通过名字查询角色
* @param name:角色名
* @return List<TsRole>
*/
List<TsRole> getByName(String name);
/**
* 添加角色
* @param tsRole :角色信息
* @return ResponseMessage<Object>
*/
ResponseMessage<Object> addRole(TsRole tsRole);
/**
* 编辑角色
* @param tsRole:角色信息
* @return ResponseMessage<Object>
*/
ResponseMessage<Object> updateRole(TsRole tsRole);
/**
* 删除角色
* @param roleId:角色Id
* @return ResponseMessage<Object>
*/
ResponseMessage<Object> deleteRole(String roleId);
/**
* 配置菜单
* @param tsRoleMenuVO:菜单ID
* @return ResponseMessage<Object>
*/
ResponseMessage<Object> setMenu(TsRoleMenuVO tsRoleMenuVO);
/**
* 查询角色权限
* @param roleId:角色ID
* @return List<String>
*/
List<String> getMenu(String roleId);
/**
* 通过角色Id列表查询菜单Id列表
* @param roleIds:角色ID列表
* @return List<String>
*/
List<String> getMenuIdsByRoleIds(List<String> roleIds);
ResponseMessage<Object> setResource(TsRoleResourceVO tsRoleResourceVO);
List<String> getResource(String roleId);
List<String> getResourceIdsByRoleIds(List<String> roleIds);
}
@@ -0,0 +1,262 @@
package com.adc.da.slrs.sarRole.service.impl;
import com.adc.da.http.ResponseMessage;
import com.adc.da.http.Result;
import com.adc.da.slrs.sarMenu.dao.SarMenuDao;
import com.adc.da.slrs.sarMenu.entity.SarMenu;
import com.adc.da.slrs.sarMenu.service.ISarMenuService;
import com.adc.da.slrs.sarPersonalCenter.service.ISarUserPersonalMenuService;
import com.adc.da.slrs.sarRole.entity.TsRole;
import com.adc.da.slrs.sarRole.dao.TsRoleDao;
import com.adc.da.slrs.sarRole.entity.TsRoleMenuVO;
import com.adc.da.slrs.sarRole.entity.TsRoleResourceVO;
import com.adc.da.slrs.sarRole.service.ITsRoleService;
import com.adc.da.slrs.sarUser.service.ITsUserService;
import com.adc.da.utils.util.ListUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.Map;
/**
* <p>
* 服务实现类
* </p>
*
* @author zyl
* @since 2021-06-22
*/
@EnableAsync
@Service
public class TsRoleServiceImpl extends ServiceImpl<TsRoleDao, TsRole> implements ITsRoleService {
@Autowired
private TsRoleDao tsRoleDao;
@Autowired
private ISarMenuService sarMenuService;
@Autowired
@Lazy
private ISarUserPersonalMenuService sarUserPersonalMenuService;
/**
* 查询所有角色
* @return List<TsRole>
*/
@Override
public List<TsRole> getAll() {
QueryWrapper<TsRole> tsRoleQueryWrapper=new QueryWrapper<>();
tsRoleQueryWrapper.eq("ROLE_HIERARCHY",1);
List<TsRole> rootRole=tsRoleDao.selectList(tsRoleQueryWrapper);
for(TsRole tsRole:rootRole){
tsRole.setChildren(recursionGetRole(tsRole));
}
return rootRole;
}
/**
* 递归查询子角色
* @param tsRole:父角色
* @return List<TsRole>
*/
private List<TsRole> recursionGetRole(TsRole tsRole){
QueryWrapper<TsRole> tsRoleQueryWrapper=new QueryWrapper<>();
tsRoleQueryWrapper.eq("parent_id",tsRole.getId());
tsRoleQueryWrapper.eq("ROLE_HIERARCHY",tsRole.getRoleHierarchy()+1);
List<TsRole> tsRoles=tsRoleDao.selectList(tsRoleQueryWrapper);
for(TsRole tsRoleNode:tsRoles){
tsRoleNode.setChildren(recursionGetRole(tsRoleNode));
}
return tsRoles;
}
/**
* 通过名字查询角色
* @param name:角色名
* @return List<TsRole>
*/
@Override
public List<TsRole> getByName(String name) {
QueryWrapper<TsRole> tsRoleQueryWrapper=new QueryWrapper<>();
tsRoleQueryWrapper.like("name","%"+name+"%");
return tsRoleDao.selectList(tsRoleQueryWrapper);
}
/**
* 添加角色
* @param tsRole :角色信息
* @return TsRole
*/
@Override
public ResponseMessage<Object> addRole(TsRole tsRole) {
//判断是否是顶级角色
if(tsRole.getParentId()==null){
tsRole.setRoleHierarchy(1);
}else {
QueryWrapper<TsRole> parentQueryWrapper=new QueryWrapper<>();
parentQueryWrapper.eq("id",tsRole.getParentId());
TsRole parentRole=tsRoleDao.selectOne(parentQueryWrapper);
if(parentRole==null){
return Result.error("父角色不存在");
}
tsRole.setRoleHierarchy(parentRole.getRoleHierarchy()+1);
}
tsRoleDao.insert(tsRole);
return Result.success();
}
/**
* 编辑角色
* @param tsRole:角色信息
* @return ResponseMessage<Object>
*/
@Override
public ResponseMessage<Object> updateRole(TsRole tsRole) {
TsRole oldRole=tsRoleDao.selectById(tsRole.getId());
if(oldRole==null){
return Result.error("该角色不存在");
}
//不允许修改父节点
tsRole.setRoleHierarchy(null);
tsRole.setParentId(null);
tsRoleDao.updateById(tsRole);
return Result.success();
}
/**
* 删除角色
* @param roleId:角色Id
* @return ResponseMessage<Object>
*/
@Override
public ResponseMessage<Object> deleteRole(String roleId) {
TsRole tsRole=tsRoleDao.selectById(roleId);
if(tsRole==null){
return Result.error("该角色不存在");
}
QueryWrapper<TsRole> childrenRoleQueryWrapper=new QueryWrapper<>();
childrenRoleQueryWrapper.eq("parent_id",roleId);
List<TsRole> childrenRole=tsRoleDao.selectList(childrenRoleQueryWrapper);
if(childrenRole!=null&&childrenRole.size()>0){
return Result.error("该角色有下属角色,无法删除");
}
List<String> positionIds=tsRoleDao.getPositionIds(roleId);
if(positionIds!=null&&positionIds.size()>0){
return Result.error("该角色已绑定岗位,无法删除");
}
tsRoleDao.deleteById(roleId);
return Result.success();
}
/**
* 配置菜单
* @param tsRoleMenuVO:菜单ID
* @return ResponseMessage<Object>
*/
@Override
@Transactional
public ResponseMessage<Object> setMenu(TsRoleMenuVO tsRoleMenuVO) {
TsRole role=tsRoleDao.selectById(tsRoleMenuVO.getRoleId());
if(role==null){
return Result.error("该角色不存在");
}
List<String> oldMenuIds=tsRoleDao.getMenuIds(tsRoleMenuVO.getRoleId());
Map<String,List<String>> updateMenuIds= ListUtil.difList(tsRoleMenuVO.getMenuIds(),oldMenuIds);
List<String> insertIds=updateMenuIds.get("insert");
List<String> deleteIds=updateMenuIds.get("delete");
if(insertIds!=null&&insertIds.size()>0){
for(String menuId:insertIds){
tsRoleDao.addMenu(tsRoleMenuVO.getRoleId(),menuId);
}
}
if(deleteIds!=null&&deleteIds.size()>0){
for(String menuId:deleteIds){
tsRoleDao.delMenu(tsRoleMenuVO.getRoleId(),menuId);
}
}
sarUserPersonalMenuService.setPersonalMenu(tsRoleMenuVO.getRoleId());
return Result.success();
}
/**
* 查询角色权限
* @param roleId:角色ID
* @return List<String>
*/
@Override
public List<String> getMenu(String roleId) {
return tsRoleDao.getMenuIdByRoleId(roleId);
}
/**
* 通过角色Id列表查询菜单Id列表
* @param roleIds:角色ID列表
* @return List<String>
*/
@Override
public List<String> getMenuIdsByRoleIds(List<String> roleIds) {
if(roleIds!=null&&roleIds.size()>0){
return tsRoleDao.getMenuIdsByRoleIds(roleIds);
}
return null;
}
/**
* 配置资源
* @param tsRoleResourceVO:资源ID
* @return ResponseMessage<Object>
*/
@Override
public ResponseMessage<Object> setResource(TsRoleResourceVO tsRoleResourceVO) {
TsRole role=tsRoleDao.selectById(tsRoleResourceVO.getRoleId());
if(role==null){
return Result.error("该角色不存在");
}
List<String> oldResourceIds=tsRoleDao.getResourceIds(tsRoleResourceVO.getRoleId());
Map<String,List<String>> updateMenuIds= ListUtil.difList(tsRoleResourceVO.getResourceIds(),oldResourceIds);
List<String> insertIds=updateMenuIds.get("insert");
List<String> deleteIds=updateMenuIds.get("delete");
if(insertIds!=null&&insertIds.size()>0){
for(String menuId:insertIds){
tsRoleDao.addResource(tsRoleResourceVO.getRoleId(),menuId);
}
}
if(deleteIds!=null&&deleteIds.size()>0){
for(String menuId:deleteIds){
tsRoleDao.delResource(tsRoleResourceVO.getRoleId(),menuId);
}
}
return Result.success();
}
/**
* 查询角色资源
* @param roleId:角色ID
* @return List<String>
*/
@Override
public List<String> getResource(String roleId) {
return tsRoleDao.getResourceIds(roleId);
}
/**
* 通过角色Id列表查询菜单Id列表
* @param roleIds:角色ID列表
* @return List<String>
*/
@Override
public List<String> getResourceIdsByRoleIds(List<String> roleIds) {
if(roleIds!=null&&roleIds.size()>0){
return tsRoleDao.getResourceIdsByRoleIds(roleIds);
}
return null;
}
}
@@ -22,7 +22,7 @@ public interface ISarPublicIdeaAllService extends IService<SarPublicIdeaAll> {
IPage<SarPublicIdeaAll> selectAll(DetAllStandDto detAllStandDto);
String add(SarPublicIdeaAll sarPublicIdeaAll);
String updateById(SarPublicIdeaAll sarPublicIdeaAll, String autUseerid);
String updateById(SarPublicIdeaAll sarPublicIdeaAll, String autUserid);
String delete(DelStandDto delStandDto);
String del(String id);
String stuListExcel(HttpServletResponse response,String cid);
@@ -63,8 +63,8 @@ public class SarPublicIdeaAllServiceImpl extends ServiceImpl<SarPublicIdeaAllDao
@Override
public String updateById(SarPublicIdeaAll sar, String autUseerid) {
if(sar.getUserId().equals(autUseerid)){
public String updateById(SarPublicIdeaAll sar, String autUserid) {
if(sar.getUserId().equals(autUserid)){
sarPublicIdeaAllDao.updateById(sar);
return "修改成功";
}else {
@@ -98,7 +98,7 @@ public class SarPublicIdeaAllServiceImpl extends ServiceImpl<SarPublicIdeaAllDao
SimpleDateFormat sdf1 = new SimpleDateFormat("yyyyMMdd hhmmss");
Workbook wb = new XSSFWorkbook();
//标题行抽出字段
String[] title = {"", "标准或政策编号","章节编号", "内容","提出人"};
String[] title = {"", "标准或政策编号","章节编号", "内容","提出人","所在部门"};
//设置sheet名称,并创建新的sheet对象
String sheetName = "意见信息";
Sheet stuSheet = wb.createSheet(sheetName);
@@ -124,9 +124,8 @@ public class SarPublicIdeaAllServiceImpl extends ServiceImpl<SarPublicIdeaAllDao
row.createCell(1).setCellValue(data.get(i).getCid());
row.createCell(2).setCellValue(data.get(i).getPartCode());
row.createCell(3).setCellValue(data.get(i).getContent());
row.createCell(4).setCellValue(data.get(i).getUserId());
row.createCell(4).setCellValue(data.get(i).getUserName());
row.createCell(5).setCellValue(data.get(i).getDeptName());
}
//设置单元格宽度自适应,在此基础上把宽度调至1.5倍
for (int i = 0; i < title.length; i++) {
@@ -45,11 +45,11 @@ public class SarPublicIdeaServiceImpl extends ServiceImpl<SarPublicIdeaDao, SarP
}
@Override
public IPage<SarPublicIdea> selectAllP(Integer p, Integer size, String categorg, String cname, Date start, Date end) {
public IPage<SarPublicIdea> selectAllP(Integer p, Integer size, String category, String cname, Date start, Date end) {
QueryWrapper<SarPublicIdea> list = new QueryWrapper<>();
list.eq(StringUtils.isNotEmpty(categorg),"category",categorg)
list.like(StringUtils.isNotEmpty(category),"category",category)
.like(StringUtils.isNotEmpty(cname),"cname",cname)
.gt(start!=null,"start_time",start).
.ge(start!=null,"start_time",start).
le(end!=null,"end_time",end);
Page<SarPublicIdea> page = new Page<>(p,size);
@@ -0,0 +1,121 @@
package com.adc.da.slrs.sarStandIssueControlCause.controller;
import com.adc.da.http.ResponseMessage;
import com.adc.da.http.ResponseMessageCodeEnum;
import com.adc.da.http.Result;
import com.adc.da.slrs.sarStandIssueControlCause.entity.SarStandIssueControlCausePage;
import com.adc.da.slrs.sarStandIssueControlCause.entity.StandIssueControlCauseExcelVO;
import com.adc.da.slrs.sarStandIssueControlCause.entity.StandIssueControlCauseListVO;
import com.adc.da.slrs.sarStandIssueControlCause.service.ISarStandIssueControlCauseService;
import com.adc.da.slrs.sarStandUnqualified.entity.SarStandUnqualified;
import com.adc.da.slrs.sarStandUnqualified.entity.SarStandUnqualifiedPage;
import com.adc.da.slrs.sarStandUnqualified.entity.StandUnqualifiedExcelVO;
import com.adc.da.slrs.sarStandUnqualified.entity.StandUnqualifiedListVO;
import com.adc.da.slrs.sarStandUnqualified.service.ISarStandUnqualifiedService;
import com.adc.da.slrs.sarStandardsInfo.controller.SarStandardsInfoController;
import com.alibaba.excel.EasyExcel;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.adc.da.slrs.sarStandIssueControlCause.entity.SarStandIssueControlCause;
import io.swagger.annotations.Api;
import com.adc.da.base.web.BaseController;
import javax.servlet.http.HttpServletResponse;
import java.net.URLEncoder;
import java.util.List;
/**
* <p>
* 前端控制器
* </p>
*
* @author super_liu
* @since 2021-06-16
*/
@RestController
@Api(tags = "|重点问题项管控模块-事业部|")
@RequestMapping("/api/sarStandIssueControlCause/sar-stand-issue-control-cause")
public class SarStandIssueControlCauseController extends BaseController<SarStandIssueControlCause> {
private static final Logger logger = LoggerFactory.getLogger(SarStandardsInfoController.class);
@Autowired
private ISarStandIssueControlCauseService sarStandIssueControlCauseService;
/**
* 分页查询
* @param sarStandIssueControlCausePage:筛选、分页信息
* @return ResponseMessage<IPage<SarStandIssueControlCause>>
*/
@ApiOperation("分页查询")
@GetMapping
public ResponseMessage<IPage<SarStandIssueControlCause>> getSarStandIssueControlCausePage(SarStandIssueControlCausePage sarStandIssueControlCausePage){
IPage<SarStandIssueControlCause> sarStandIssueControlCauseIPage=sarStandIssueControlCauseService.getSarStandIssueControlCausePage(sarStandIssueControlCausePage);
return Result.success(sarStandIssueControlCauseIPage);
}
/**
* 分页查询历史数据
* @param sarStandIssueControlCausePage:筛选、分页信息
* @return ResponseMessage<IPage<SarStandUnqualified>>
*/
@ApiOperation("分页查询历史数据")
@GetMapping("/history")
public ResponseMessage<IPage<SarStandIssueControlCause>> getSarStandIssueControlCauseHistoryPage(SarStandIssueControlCausePage sarStandIssueControlCausePage){
IPage<SarStandIssueControlCause> sarStandIssueControlCauseIPage=sarStandIssueControlCauseService.getSarStandIssueControlCauseHistoryPage(sarStandIssueControlCausePage);
return Result.success(sarStandIssueControlCauseIPage);
}
/**
* 批量关闭
* @param standIssueControlCauseListVO:事业部重大问题ID列表
* @return ResponseMessage<List<String>>:关闭失败的事业部重大问题ID列表
*/
@ApiOperation("批量关闭")
@PostMapping("/close")
public ResponseMessage<List<String>> closeSarStandIssueControlCause(@RequestBody StandIssueControlCauseListVO standIssueControlCauseListVO){
if(standIssueControlCauseListVO==null||standIssueControlCauseListVO.getIds().size()==0){
return Result.error(ResponseMessageCodeEnum.ERROR.getCode(),"未传入ID",null);
}
List<String> failIds=sarStandIssueControlCauseService.closeSarStandIssueControlCauseList(standIssueControlCauseListVO);
if(failIds==null||failIds.size()==0){
return Result.success(null);
}else {
return Result.error(ResponseMessageCodeEnum.ERROR.getCode(),"部分关闭失败",null);
}
}
@ApiOperation("导出Excel表")
@GetMapping(value = "/exportStandUnqulifiedExcel")
public void exportStandardsInfoExcel(StandIssueControlCauseExcelVO standIssueControlCauseExcelVO, HttpServletResponse response) throws Exception {
// 这里注意 有同学反应使用swagger 会导致各种问题,请直接用浏览器或者用postman
try {
response.setContentType("application/vnd.ms-excel");
response.setCharacterEncoding("utf-8");
// 这里URLEncoder.encode可以防止中文乱码 当然和easyexcel没有关系
if(standIssueControlCauseExcelVO.getExportName()==null){
standIssueControlCauseExcelVO.setExportName("事业部重点问题项管控");
}
String fileName = URLEncoder.encode(standIssueControlCauseExcelVO.getExportName(), "UTF-8").replaceAll("\\+", "%20");
response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx");
List<SarStandIssueControlCause> data=sarStandIssueControlCauseService.getStandIssueControlCauseExcelData(standIssueControlCauseExcelVO);
// 这里需要设置不关闭流
EasyExcel.write(response.getOutputStream(), SarStandIssueControlCause.class).autoCloseStream(Boolean.FALSE).sheet("sheet1")
.doWrite(data);
} catch (Exception e) {
System.out.println(e);
// 重置response
response.reset();
response.setContentType("application/json");
response.setCharacterEncoding("utf-8");
response.getWriter().println(JSON.toJSONString(Result.error()));
}
}
}
@@ -0,0 +1,16 @@
package com.adc.da.slrs.sarStandIssueControlCause.dao;
import com.adc.da.slrs.sarStandIssueControlCause.entity.SarStandIssueControlCause;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* <p>
* Mapper 接口
* </p>
*
* @author super_liu
* @since 2021-06-16
*/
public interface SarStandIssueControlCauseDao extends BaseMapper<SarStandIssueControlCause> {
}
@@ -0,0 +1,124 @@
package com.adc.da.slrs.sarStandIssueControlCause.entity;
import com.adc.da.base.entity.BaseEntity;
import java.sql.Timestamp;
import java.time.LocalDateTime;
import com.adc.da.slrs.sarStandUnqualified.utils.TimestampConverter;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.springframework.format.annotation.DateTimeFormat;
/**
* <p>
*
* </p>
*
* @author super_liu
* @since 2021-06-16
*/
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@ApiModel(value="SarStandIssueControlCause对象", description="")
public class SarStandIssueControlCause extends BaseEntity {
private static final long serialVersionUID = 1L;
@ExcelProperty("创建部门")
@ApiModelProperty(value = "创建部门")
@TableField("CREATE_DEPT_ID")
private String createDeptId;
@ExcelProperty("创建人")
@ApiModelProperty(value = "创建人")
@TableField("CREATE_BY_ID")
private String createById;
@ExcelProperty(value = "创建时间",converter = TimestampConverter.class)
@ApiModelProperty(value = "创建时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@TableField("CREATE_TIME")
private Timestamp createTime;
@ExcelIgnore
@ApiModelProperty(value = "关闭状态(1为开启,2为关闭)")
@TableField("CLOSE_STATE")
private Integer closeState;
@ExcelIgnore
@ApiModelProperty(value = "实际关闭时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@TableField("ACTUAL_CLOSE_TIME")
private Timestamp actualCloseTime;
@ExcelProperty(value = "要求关闭时间",converter = TimestampConverter.class)
@ApiModelProperty(value = "要求关闭时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@TableField("REQUIRE_CLOSE_TIME")
private Timestamp requireCloseTime;
@ExcelProperty("质量工程师")
@ApiModelProperty(value = "质量工程师")
@TableField("QA_ENGINEER")
private String qaEngineer;
@ExcelProperty("认证工程师")
@ApiModelProperty(value = "认证工程师")
@TableField("AUTH_ENGINEER")
private String authEngineer;
@ExcelProperty("责任工程师")
@ApiModelProperty(value = "责任工程师")
@TableField("DUTY_ENGINEER")
private String dutyEngineer;
@ExcelProperty("责任部门")
@ApiModelProperty(value = "责任部门")
@TableField("RESPONSIBLE_UNIT")
private String responsibleUnit;
@ExcelProperty("项目名称")
@ApiModelProperty(value = "项目名称")
@TableField("PRODUCT_NAME")
private String productName;
@ExcelProperty("产品线")
@ApiModelProperty(value = "产品线")
@TableField("PRODUCT_LINE")
private String productLine;
@ExcelProperty("当前节点")
@ApiModelProperty(value = "当前节点")
@TableField("CURRENT_NODE")
private String currentNode;
@ExcelProperty("标准名称")
@ApiModelProperty(value = "标准名称")
@TableField("STAND_NAME")
private String standName;
@ExcelProperty("标准编号")
@ApiModelProperty(value = "标准编号")
@TableField("STAND_ID")
private String standId;
@ExcelIgnore
@ApiModelProperty(value = "主键")
@TableId("ID")
private String id;
}
@@ -0,0 +1,69 @@
package com.adc.da.slrs.sarStandIssueControlCause.entity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.sql.Timestamp;
@Data
@ApiModel(value="SarStandIssueControlCausePage对象", description="")
public class SarStandIssueControlCausePage{
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "创建部门")
private String createDeptId;
@ApiModelProperty(value = "创建人")
private String createById;
@ApiModelProperty(value = "创建时间")
private Timestamp createTime;
@ApiModelProperty(value = "关闭状态(1为开启,2为关闭)")
private Integer closeState;
@ApiModelProperty(value = "实际关闭时间")
private Timestamp actualCloseTime;
@ApiModelProperty(value = "要求关闭时间")
private Timestamp requireCloseTime;
@ApiModelProperty(value = "质量工程师")
private String qaEngineer;
@ApiModelProperty(value = "认证工程师")
private String authEngineer;
@ApiModelProperty(value = "责任工程师")
private String dutyEngineer;
@ApiModelProperty(value = "责任部门")
private String responsibleUnit;
@ApiModelProperty(value = "项目名称")
private String productName;
@ApiModelProperty(value = "产品线")
private String productLine;
@ApiModelProperty(value = "当前节点")
private String currentNode;
@ApiModelProperty(value = "标准名称")
private String standName;
@ApiModelProperty(value = "标准编号")
private String standId;
@ApiModelProperty(value = "主键")
private String id;
@ApiModelProperty("当前页")
private Integer current;
@ApiModelProperty("每页条数")
private Integer size;
}
@@ -0,0 +1,16 @@
package com.adc.da.slrs.sarStandIssueControlCause.entity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
@Data
@ApiModel(description = "ExcelVO类")
public class StandIssueControlCauseExcelVO {
@ApiModelProperty("文件名")
String exportName;
@ApiModelProperty("导出的ID列表")
List<String> ids;
}
@@ -0,0 +1,12 @@
package com.adc.da.slrs.sarStandIssueControlCause.entity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
@Data
public class StandIssueControlCauseListVO {
@ApiModelProperty("ID列表")
private List<String> Ids;
}
@@ -0,0 +1,49 @@
package com.adc.da.slrs.sarStandIssueControlCause.service;
import com.adc.da.slrs.sarStandIssueControlCause.entity.SarStandIssueControlCause;
import com.adc.da.slrs.sarStandIssueControlCause.entity.SarStandIssueControlCausePage;
import com.adc.da.slrs.sarStandIssueControlCause.entity.StandIssueControlCauseExcelVO;
import com.adc.da.slrs.sarStandIssueControlCause.entity.StandIssueControlCauseListVO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
/**
* <p>
* 服务类
* </p>
*
* @author super_liu
* @since 2021-06-16
*/
public interface ISarStandIssueControlCauseService extends IService<SarStandIssueControlCause> {
/**
* 分页查询
* @param sarStandIssueControlCausePage:筛选信息、分页信息
* @return IPage<SarStandIssueControlCause>
*/
IPage<SarStandIssueControlCause> getSarStandIssueControlCausePage(SarStandIssueControlCausePage sarStandIssueControlCausePage);
/**
* 分页查询历史数据
* @param sarStandIssueControlCausePage:筛选信息、分页信息
* @return IPage<SarStandIssueControlCause>
*/
IPage<SarStandIssueControlCause> getSarStandIssueControlCauseHistoryPage(SarStandIssueControlCausePage sarStandIssueControlCausePage);
/**
* 批量关闭
* @param standIssueControlCauseListVO:问题ID列表
* @return List<String>:关闭失败的ID列表
*/
List<String> closeSarStandIssueControlCauseList(StandIssueControlCauseListVO standIssueControlCauseListVO);
/**
* 获得excel导出的数据
* @param standIssueControlCauseExcelVO :筛选ID
* @return List<SarStandIssueControlCause>
*/
List<SarStandIssueControlCause> getStandIssueControlCauseExcelData(StandIssueControlCauseExcelVO standIssueControlCauseExcelVO);
}
@@ -0,0 +1,145 @@
package com.adc.da.slrs.sarStandIssueControlCause.service.impl;
import com.adc.da.slrs.sarStandIssueControlCause.entity.SarStandIssueControlCause;
import com.adc.da.slrs.sarStandIssueControlCause.dao.SarStandIssueControlCauseDao;
import com.adc.da.slrs.sarStandIssueControlCause.entity.SarStandIssueControlCausePage;
import com.adc.da.slrs.sarStandIssueControlCause.entity.StandIssueControlCauseExcelVO;
import com.adc.da.slrs.sarStandIssueControlCause.entity.StandIssueControlCauseListVO;
import com.adc.da.slrs.sarStandIssueControlCause.service.ISarStandIssueControlCauseService;
import com.adc.da.slrs.sarStandUnqualified.entity.SarStandUnqualified;
import com.adc.da.slrs.sarStandUnqualified.entity.StandUnqualifiedExcelVO;
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.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
* <p>
* 服务实现类
* </p>
*
* @author super_liu
* @since 2021-06-16
*/
@Service
public class SarStandIssueControlCauseServiceImpl extends ServiceImpl<SarStandIssueControlCauseDao, SarStandIssueControlCause> implements ISarStandIssueControlCauseService {
@Autowired
private SarStandIssueControlCauseDao sarStandIssueControlCauseDao;
/**
* 分页查询
* @param sarStandIssueControlCausePage:筛选信息、分页信息
* @return SarStandIssueControlCause
*/
@Override
public IPage<SarStandIssueControlCause> getSarStandIssueControlCausePage(SarStandIssueControlCausePage sarStandIssueControlCausePage) {
QueryWrapper<SarStandIssueControlCause> sarStandIssueControlCauseQueryWrapper=new QueryWrapper<>();
//仅查询未关闭的
sarStandIssueControlCauseQueryWrapper.eq("close_state",1);
if(sarStandIssueControlCausePage.getStandId()!=null){
sarStandIssueControlCauseQueryWrapper.eq("stand_id",sarStandIssueControlCausePage.getStandId()).or().like("stand_name","%"+sarStandIssueControlCausePage.getStandId()+"%");
}
if(sarStandIssueControlCausePage.getProductName()!=null){
sarStandIssueControlCauseQueryWrapper.like("product_name","%"+sarStandIssueControlCausePage.getProductName()+"%");
}
if(sarStandIssueControlCausePage.getResponsibleUnit()!=null){
sarStandIssueControlCauseQueryWrapper.eq("responsible_unit",sarStandIssueControlCausePage.getResponsibleUnit());
}
Page<SarStandIssueControlCause> standIssueControlCausePage=new Page<>();
//判断前端是否提供页码和每页条数
if(sarStandIssueControlCausePage.getCurrent()!=null&&sarStandIssueControlCausePage.getSize()!=null){
standIssueControlCausePage=new Page<>(sarStandIssueControlCausePage.getCurrent(),sarStandIssueControlCausePage.getSize());
}
return sarStandIssueControlCauseDao.selectPage(standIssueControlCausePage,sarStandIssueControlCauseQueryWrapper);
}
/**
* 分页查询历史数据
* @param sarStandIssueControlCausePage:筛选信息、分页信息
* @return IPage<SarStandIssueControlCause>
*/
@Override
public IPage<SarStandIssueControlCause> getSarStandIssueControlCauseHistoryPage(SarStandIssueControlCausePage sarStandIssueControlCausePage) {
QueryWrapper<SarStandIssueControlCause> sarStandIssueControlCauseQueryWrapper=new QueryWrapper<>();
//仅查询关闭的
sarStandIssueControlCauseQueryWrapper.eq("close_state",2);
if(sarStandIssueControlCausePage.getStandId()!=null){
sarStandIssueControlCauseQueryWrapper.eq("stand_id",sarStandIssueControlCausePage.getStandId()).or().like("stand_name","%"+sarStandIssueControlCausePage.getStandId()+"%");
}
if(sarStandIssueControlCausePage.getProductName()!=null){
sarStandIssueControlCauseQueryWrapper.like("product_name","%"+sarStandIssueControlCausePage.getProductName()+"%");
}
if(sarStandIssueControlCausePage.getResponsibleUnit()!=null){
sarStandIssueControlCauseQueryWrapper.eq("responsible_unit",sarStandIssueControlCausePage.getResponsibleUnit());
}
Page<SarStandIssueControlCause> standIssueControlCausePage=new Page<>();
//判断前端是否提供页码和每页条数
if(sarStandIssueControlCausePage.getCurrent()!=null&&sarStandIssueControlCausePage.getSize()!=null){
standIssueControlCausePage=new Page<>(sarStandIssueControlCausePage.getCurrent(),sarStandIssueControlCausePage.getSize());
}
return sarStandIssueControlCauseDao.selectPage(standIssueControlCausePage,sarStandIssueControlCauseQueryWrapper);
}
/**
* 批量关闭
* @param standIssueControlCauseListVO:问题ID列表
* @return List<String>:关闭失败的ID列表
*/
@Override
public List<String> closeSarStandIssueControlCauseList(StandIssueControlCauseListVO standIssueControlCauseListVO) {
List<String> failIds=new ArrayList<>();
for(String id:standIssueControlCauseListVO.getIds()){
boolean success=closeSarStandIssueControlCause(id);
if(!success){
failIds.add(id);
}
}
return failIds;
}
/**
* 获得excel导出的数据
* @param standIssueControlCauseExcelVO :筛选ID
* @return List<SarStandIssueControlCause>
*/
@Override
public List<SarStandIssueControlCause> getStandIssueControlCauseExcelData(StandIssueControlCauseExcelVO standIssueControlCauseExcelVO) {
QueryWrapper<SarStandIssueControlCause> sarStandIssueControlCauseQueryWrapper=new QueryWrapper<>();
sarStandIssueControlCauseQueryWrapper.eq("close_state",1);
if(standIssueControlCauseExcelVO.getIds()!=null&&standIssueControlCauseExcelVO.getIds().size()>0){
sarStandIssueControlCauseQueryWrapper.in("id",standIssueControlCauseExcelVO.getIds());
}
return sarStandIssueControlCauseDao.selectList(sarStandIssueControlCauseQueryWrapper);
}
/**
* 问题关闭
* @param standIssueControlCauseIdID
* @return boolean
*/
private boolean closeSarStandIssueControlCause(String standIssueControlCauseId){
SarStandIssueControlCause sarStandIssueControlCause=sarStandIssueControlCauseDao.selectById(standIssueControlCauseId);
//判断是否存在
if(sarStandIssueControlCause==null){
return false;
}
//判断是否已关闭
if(sarStandIssueControlCause.getCloseState()==2){
return false;
}
sarStandIssueControlCause.setCloseState(2);
sarStandIssueControlCause.setActualCloseTime(new Timestamp(new Date().getTime()));
sarStandIssueControlCauseDao.updateById(sarStandIssueControlCause);
return true;
}
}
@@ -0,0 +1,122 @@
package com.adc.da.slrs.sarStandIssueControlProduct.controller;
import com.adc.da.http.ResponseMessage;
import com.adc.da.http.ResponseMessageCodeEnum;
import com.adc.da.http.Result;
import com.adc.da.slrs.sarStandIssueControlCause.entity.SarStandIssueControlCause;
import com.adc.da.slrs.sarStandIssueControlCause.entity.SarStandIssueControlCausePage;
import com.adc.da.slrs.sarStandIssueControlCause.entity.StandIssueControlCauseExcelVO;
import com.adc.da.slrs.sarStandIssueControlCause.entity.StandIssueControlCauseListVO;
import com.adc.da.slrs.sarStandIssueControlCause.service.ISarStandIssueControlCauseService;
import com.adc.da.slrs.sarStandIssueControlProduct.entity.SarStandIssueControlProductPage;
import com.adc.da.slrs.sarStandIssueControlProduct.entity.StandIssueControlProductExcelVO;
import com.adc.da.slrs.sarStandIssueControlProduct.entity.StandIssueControlProductListVO;
import com.adc.da.slrs.sarStandIssueControlProduct.service.ISarStandIssueControlProductService;
import com.adc.da.slrs.sarStandUnqualified.entity.SarStandUnqualified;
import com.adc.da.slrs.sarStandardsInfo.controller.SarStandardsInfoController;
import com.alibaba.excel.EasyExcel;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.adc.da.slrs.sarStandIssueControlProduct.entity.SarStandIssueControlProduct;
import io.swagger.annotations.Api;
import com.adc.da.base.web.BaseController;
import javax.servlet.http.HttpServletResponse;
import java.net.URLEncoder;
import java.util.List;
/**
* <p>
* 前端控制器
* </p>
*
* @author zxy
* @since 2021-06-17
*/
@RestController
@Api(tags = "|重点问题项管控-产品规划部|")
@RequestMapping("/api/sarStandIssueControlProduct/sar-stand-issue-control-product")
public class SarStandIssueControlProductController extends BaseController<SarStandIssueControlProduct> {
private static final Logger logger = LoggerFactory.getLogger(SarStandardsInfoController.class);
@Autowired
private ISarStandIssueControlProductService sarStandIssueControlProductService;
/**
* 分页查询
* @param sarStandIssueControlProductPage:筛选、分页信息
* @return ResponseMessage<IPage<SarStandIssueControlCause>>
*/
@ApiOperation("分页查询")
@GetMapping
public ResponseMessage<IPage<SarStandIssueControlProduct>> getSarStandIssueControlProductPage(SarStandIssueControlProductPage sarStandIssueControlProductPage){
IPage<SarStandIssueControlProduct> sarStandIssueControlCauseIPage=sarStandIssueControlProductService.getSarStandIssueControlProductPage(sarStandIssueControlProductPage);
return Result.success(sarStandIssueControlCauseIPage);
}
/**
* 分页查询历史数据
* @param sarStandIssueControlProductPage:筛选、分页信息
* @return ResponseMessage<IPage<SarStandUnqualified>>
*/
@ApiOperation("分页查询历史数据")
@GetMapping("/history")
public ResponseMessage<IPage<SarStandIssueControlProduct>> getSarStandIssueControlProductHistoryPage(SarStandIssueControlProductPage sarStandIssueControlProductPage){
IPage<SarStandIssueControlProduct> sarStandIssueControlProductIPage=sarStandIssueControlProductService.getSarStandIssueControlProductHistoryPage(sarStandIssueControlProductPage);
return Result.success(sarStandIssueControlProductIPage);
}
/**
* 批量关闭
* @param standIssueControlProductListVO:重大问题ID列表
* @return ResponseMessage<List<String>>:关闭失败的重大问题ID列表
*/
@ApiOperation("批量关闭")
@PostMapping("/close")
public ResponseMessage<List<String>> closeSarStandIssueControlCause(@RequestBody StandIssueControlProductListVO standIssueControlProductListVO){
if(standIssueControlProductListVO==null||standIssueControlProductListVO.getIds().size()==0){
return Result.error(ResponseMessageCodeEnum.ERROR.getCode(),"未传入ID",null);
}
List<String> failIds=sarStandIssueControlProductService.closeSarStandIssueControlProductList(standIssueControlProductListVO);
if(failIds==null||failIds.size()==0){
return Result.success(null);
}else {
return Result.error(ResponseMessageCodeEnum.ERROR.getCode(),"部分关闭失败",null);
}
}
@ApiOperation("导出Excel表")
@GetMapping(value = "/exportStandUnqulifiedExcel")
public void exportStandardsInfoExcel(StandIssueControlProductExcelVO standIssueControlProductExcelVO, HttpServletResponse response) throws Exception {
// 这里注意 有同学反应使用swagger 会导致各种问题,请直接用浏览器或者用postman
try {
response.setContentType("application/vnd.ms-excel");
response.setCharacterEncoding("utf-8");
// 这里URLEncoder.encode可以防止中文乱码 当然和easyexcel没有关系
if(standIssueControlProductExcelVO.getExportName()==null){
standIssueControlProductExcelVO.setExportName("产品规划部重点问题项管控");
}
String fileName = URLEncoder.encode(standIssueControlProductExcelVO.getExportName(), "UTF-8").replaceAll("\\+", "%20");
response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx");
List<SarStandIssueControlProduct> data=sarStandIssueControlProductService.getStandIssueControlProductExcelData(standIssueControlProductExcelVO);
// 这里需要设置不关闭流
EasyExcel.write(response.getOutputStream(), SarStandIssueControlProduct.class).autoCloseStream(Boolean.FALSE).sheet("sheet1")
.doWrite(data);
} catch (Exception e) {
System.out.println(e);
// 重置response
response.reset();
response.setContentType("application/json");
response.setCharacterEncoding("utf-8");
response.getWriter().println(JSON.toJSONString(Result.error()));
}
}
}
@@ -0,0 +1,16 @@
package com.adc.da.slrs.sarStandIssueControlProduct.dao;
import com.adc.da.slrs.sarStandIssueControlProduct.entity.SarStandIssueControlProduct;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* <p>
* Mapper 接口
* </p>
*
* @author super_liu
* @since 2021-06-17
*/
public interface SarStandIssueControlProductDao extends BaseMapper<SarStandIssueControlProduct> {
}
@@ -0,0 +1,131 @@
package com.adc.da.slrs.sarStandIssueControlProduct.entity;
import com.adc.da.base.entity.BaseEntity;
import java.sql.Timestamp;
import java.time.LocalDateTime;
import com.adc.da.slrs.sarStandUnqualified.utils.TimestampConverter;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.springframework.format.annotation.DateTimeFormat;
/**
* <p>
*
* </p>
*
* @author super_liu
* @since 2021-06-17
*/
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@ApiModel(value="SarStandIssueControlProduct对象", description="产品规划部重大问题管控")
public class SarStandIssueControlProduct extends BaseEntity {
private static final long serialVersionUID = 1L;
@ExcelProperty("创建部门")
@ApiModelProperty(value = "创建部门")
@TableField("CREATE_DEPT_ID")
private String createDeptId;
@ExcelProperty("创建人")
@ApiModelProperty(value = "创建人")
@TableField("CREATE_BY_ID")
private String createById;
@ExcelProperty(value = "创建时间",converter = TimestampConverter.class)
@ApiModelProperty(value = "创建时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@TableField("CREATE_TIME")
private Timestamp createTime;
@ExcelIgnore
@ApiModelProperty(value = "关闭状态(1为开启,2为关闭)")
@TableField("CLOSE_STATE")
private Integer closeState;
@ExcelIgnore
@ApiModelProperty(value = "实际关闭时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@TableField("ACTUAL_CLOSE_TIME")
private Timestamp actualCloseTime;
@ExcelProperty(value = "要求关闭时间",converter = TimestampConverter.class)
@ApiModelProperty(value = "要求关闭时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@TableField("REQUIRE_CLOSE_TIME")
private Timestamp requireCloseTime;
@ExcelProperty("平台")
@ApiModelProperty(value = "平台")
@TableField("PLATFORM")
private String platform;
@ExcelProperty("业务")
@ApiModelProperty(value = "业务")
@TableField("BUSINESS")
private String business;
@ExcelProperty("符合性状态")
@ApiModelProperty(value = "符合性状态")
@TableField("CONFORMANCE_STATE")
private String conformanceState;
@ExcelProperty("责任工程师")
@ApiModelProperty(value = "责任工程师")
@TableField("DUTY_ENGINEER")
private String dutyEngineer;
@ExcelProperty("责任部门")
@ApiModelProperty(value = "责任部门")
@TableField("RESPONSIBLE_UNIT")
private String responsibleUnit;
@ExcelProperty("实施要求")
@ApiModelProperty(value = "实施要求")
@TableField("IMPLEMENT_DEMAND")
private String implementDemand;
@ExcelProperty(value = "实施时间",converter = TimestampConverter.class)
@ApiModelProperty(value = "实施时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@TableField("IMPLEMENT_TIME")
private Timestamp implementTime;
@ExcelProperty("当前节点")
@ApiModelProperty(value = "当前节点")
@TableField("CURRENT_NODE")
private String currentNode;
@ExcelProperty(value = "标准名称/政策名称")
@ApiModelProperty(value = "标准名称/政策名称")
@TableField("STAND_NAME")
private String standName;
@ExcelProperty("标准编号/政策编号")
@ApiModelProperty(value = "标准编号/政策编号")
@TableField("STAND_ID")
private String standId;
@ExcelIgnore
@ApiModelProperty(value = "主键")
@TableId("ID")
private String id;
}
@@ -0,0 +1,91 @@
package com.adc.da.slrs.sarStandIssueControlProduct.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.sql.Timestamp;
import java.time.LocalDateTime;
@Data
@ApiModel(description = "产品规划部重大问题管控分页")
public class SarStandIssueControlProductPage {
@ApiModelProperty(value = "创建部门")
@TableField("CREATE_DEPT_ID")
private String createDeptId;
@ApiModelProperty(value = "创建人")
@TableField("CREATE_BY_ID")
private String createById;
@ApiModelProperty(value = "创建时间")
@TableField("CREATE_TIME")
private Timestamp createTime;
@ApiModelProperty(value = "关闭状态(1为开启,2为关闭)")
@TableField("CLOSE_STATE")
private Integer closeState;
@ApiModelProperty(value = "实际关闭时间")
@TableField("ACTUAL_CLOSE_TIME")
private Timestamp actualCloseTime;
@ApiModelProperty(value = "要求关闭时间")
@TableField("REQUIRE_CLOSE_TIME")
private Timestamp requireCloseTime;
@ApiModelProperty(value = "平台")
@TableField("PLANTFORM")
private String plantform;
@ApiModelProperty(value = "业务")
@TableField("BUSINESS")
private String business;
@ApiModelProperty(value = "符合性状态")
@TableField("CONFORMANCE_STATE")
private String conformanceState;
@ApiModelProperty(value = "责任工程师")
@TableField("DUTY_ENGINEER")
private String dutyEngineer;
@ApiModelProperty(value = "责任部门")
@TableField("RESPONSIBLE_UNIT")
private String responsibleUnit;
@ApiModelProperty(value = "实施要求")
@TableField("IMPLEMEN_DEMAND")
private String implemenDemand;
@ApiModelProperty(value = "实施时间")
@TableField("IMPLEMENT_TIME")
private Timestamp implementTime;
@ApiModelProperty(value = "当前节点")
@TableField("CURRENT_NODE")
private String currentNode;
@ApiModelProperty(value = "标准名称/政策名称")
@TableField("STAND_NAME")
private String standName;
@ApiModelProperty(value = "标准编号/政策编号")
@TableField("STAND_ID")
private String standId;
@ApiModelProperty(value = "主键")
@TableId("ID")
private String id;
@ApiModelProperty("当前页")
private Integer current;
@ApiModelProperty("每页条数")
private Integer size;
}
@@ -0,0 +1,16 @@
package com.adc.da.slrs.sarStandIssueControlProduct.entity;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
@Data
@ApiModel(description = "ExcelVO类")
public class StandIssueControlProductExcelVO {
@ApiModelProperty("文件名")
String exportName;
@ApiModelProperty("导出的ID列表")
List<String> ids;
}
@@ -0,0 +1,12 @@
package com.adc.da.slrs.sarStandIssueControlProduct.entity;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
@Data
public class StandIssueControlProductListVO {
@ApiModelProperty("ID列表")
private List<String> Ids;
}
@@ -0,0 +1,51 @@
package com.adc.da.slrs.sarStandIssueControlProduct.service;
import com.adc.da.slrs.sarStandIssueControlCause.entity.SarStandIssueControlCause;
import com.adc.da.slrs.sarStandIssueControlCause.entity.StandIssueControlCauseExcelVO;
import com.adc.da.slrs.sarStandIssueControlProduct.entity.SarStandIssueControlProduct;
import com.adc.da.slrs.sarStandIssueControlProduct.entity.SarStandIssueControlProductPage;
import com.adc.da.slrs.sarStandIssueControlProduct.entity.StandIssueControlProductExcelVO;
import com.adc.da.slrs.sarStandIssueControlProduct.entity.StandIssueControlProductListVO;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
/**
* <p>
* 服务类
* </p>
*
* @author zxy
* @since 2021-06-17
*/
public interface ISarStandIssueControlProductService extends IService<SarStandIssueControlProduct> {
/**
* 分页查询
* @param sarStandIssueControlProductPage:筛选、分页信息
* @return IPage<SarStandIssueControlProduct>
*/
IPage<SarStandIssueControlProduct> getSarStandIssueControlProductPage(SarStandIssueControlProductPage sarStandIssueControlProductPage);
/**
* 分页查询
* @param sarStandIssueControlProductPage:筛选、分页信息
* @return IPage<SarStandIssueControlProduct>
*/
IPage<SarStandIssueControlProduct> getSarStandIssueControlProductHistoryPage(SarStandIssueControlProductPage sarStandIssueControlProductPage);
/**
* 批量关闭
* @param standIssueControlProductListVO:关闭ID列表
* @return List<String>:关闭失败的ID
*/
List<String> closeSarStandIssueControlProductList(StandIssueControlProductListVO standIssueControlProductListVO);
/**
* 获得导出excel的数据
* @param standIssueControlProductExcelVO:导出的数据ID
* @return List<SarStandIssueControlProduct>
*/
List<SarStandIssueControlProduct> getStandIssueControlProductExcelData(StandIssueControlProductExcelVO standIssueControlProductExcelVO);
}
@@ -0,0 +1,135 @@
package com.adc.da.slrs.sarStandIssueControlProduct.service.impl;
import com.adc.da.slrs.sarStandIssueControlCause.entity.SarStandIssueControlCause;
import com.adc.da.slrs.sarStandIssueControlProduct.entity.SarStandIssueControlProduct;
import com.adc.da.slrs.sarStandIssueControlProduct.dao.SarStandIssueControlProductDao;
import com.adc.da.slrs.sarStandIssueControlProduct.entity.SarStandIssueControlProductPage;
import com.adc.da.slrs.sarStandIssueControlProduct.entity.StandIssueControlProductExcelVO;
import com.adc.da.slrs.sarStandIssueControlProduct.entity.StandIssueControlProductListVO;
import com.adc.da.slrs.sarStandIssueControlProduct.service.ISarStandIssueControlProductService;
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.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
* <p>
* 服务实现类
* </p>
*
* @author super_liu
* @since 2021-06-17
*/
@Service
public class SarStandIssueControlProductServiceImpl extends ServiceImpl<SarStandIssueControlProductDao, SarStandIssueControlProduct> implements ISarStandIssueControlProductService {
@Autowired
private SarStandIssueControlProductDao sarStandIssueControlProductDao;
/**
* 分页查询
* @param sarStandIssueControlProductPage:筛选、分页信息
* @return IPage<SarStandIssueControlProduct>
*/
@Override
public IPage<SarStandIssueControlProduct> getSarStandIssueControlProductPage(SarStandIssueControlProductPage sarStandIssueControlProductPage) {
QueryWrapper<SarStandIssueControlProduct> sarStandIssueControlProductQueryWrapper=new QueryWrapper<>();
//仅查询未关闭的
sarStandIssueControlProductQueryWrapper.eq("close_state",1);
if(sarStandIssueControlProductPage.getStandId()!=null){
sarStandIssueControlProductQueryWrapper.eq("stand_id",sarStandIssueControlProductPage.getStandId()).or().like("stand_name","%"+sarStandIssueControlProductPage.getStandId()+"%");
}
if(sarStandIssueControlProductPage.getResponsibleUnit()!=null){
sarStandIssueControlProductQueryWrapper.eq("responsible_unit",sarStandIssueControlProductPage.getResponsibleUnit());
}
Page<SarStandIssueControlProduct> standIssueControlCausePage=new Page<>();
//判断前端是否提供页码和每页条数
if(sarStandIssueControlProductPage.getCurrent()!=null&&sarStandIssueControlProductPage.getSize()!=null){
standIssueControlCausePage=new Page<>(sarStandIssueControlProductPage.getCurrent(),sarStandIssueControlProductPage.getSize());
}
return sarStandIssueControlProductDao.selectPage(standIssueControlCausePage,sarStandIssueControlProductQueryWrapper);
}
/**
* 分页查询
* @param sarStandIssueControlProductPage:筛选、分页信息
* @return IPage<SarStandIssueControlProduct>
*/
@Override
public IPage<SarStandIssueControlProduct> getSarStandIssueControlProductHistoryPage(SarStandIssueControlProductPage sarStandIssueControlProductPage) {
QueryWrapper<SarStandIssueControlProduct> sarStandIssueControlProductQueryWrapper=new QueryWrapper<>();
//仅查询关闭的
sarStandIssueControlProductQueryWrapper.eq("close_state",2);
if(sarStandIssueControlProductPage.getStandId()!=null){
sarStandIssueControlProductQueryWrapper.eq("stand_id",sarStandIssueControlProductPage.getStandId()).or().like("stand_name","%"+sarStandIssueControlProductPage.getStandId()+"%");
}
if(sarStandIssueControlProductPage.getResponsibleUnit()!=null){
sarStandIssueControlProductQueryWrapper.eq("responsible_unit",sarStandIssueControlProductPage.getResponsibleUnit());
}
Page<SarStandIssueControlProduct> standIssueControlCausePage=new Page<>();
//判断前端是否提供页码和每页条数
if(sarStandIssueControlProductPage.getCurrent()!=null&&sarStandIssueControlProductPage.getSize()!=null){
standIssueControlCausePage=new Page<>(sarStandIssueControlProductPage.getCurrent(),sarStandIssueControlProductPage.getSize());
}
return sarStandIssueControlProductDao.selectPage(standIssueControlCausePage,sarStandIssueControlProductQueryWrapper);
}
/**
* 批量关闭
* @param standIssueControlProductListVO:关闭ID列表
* @return List<String>:关闭失败的ID
*/
@Override
public List<String> closeSarStandIssueControlProductList(StandIssueControlProductListVO standIssueControlProductListVO) {
List<String> failIds=new ArrayList<>();
for(String id:standIssueControlProductListVO.getIds()){
boolean success=closeSarStandIssueControlProduct(id);
if(!success){
failIds.add(id);
}
}
return failIds;
}
/**
* 获得导出excel的数据
* @param standIssueControlProductExcelVO:导出的数据ID
* @return List<SarStandIssueControlProduct>
*/
@Override
public List<SarStandIssueControlProduct> getStandIssueControlProductExcelData(StandIssueControlProductExcelVO standIssueControlProductExcelVO) {
QueryWrapper<SarStandIssueControlProduct> sarStandIssueControlProductQueryWrapper=new QueryWrapper<>();
sarStandIssueControlProductQueryWrapper.eq("close_state",1);
if(standIssueControlProductExcelVO.getIds()!=null&&standIssueControlProductExcelVO.getIds().size()>0){
sarStandIssueControlProductQueryWrapper.in("id",standIssueControlProductExcelVO.getIds());
}
return sarStandIssueControlProductDao.selectList(sarStandIssueControlProductQueryWrapper);
}
/**
* 问题关闭
* @param standIssueControlCauseIdID
* @return boolean
*/
private boolean closeSarStandIssueControlProduct(String standIssueControlCauseId){
SarStandIssueControlProduct sarStandIssueControlProduct=sarStandIssueControlProductDao.selectById(standIssueControlCauseId);
//判断是否存在
if(sarStandIssueControlProduct==null){
return false;
}
//判断是否已关闭
if(sarStandIssueControlProduct.getCloseState()==2){
return false;
}
sarStandIssueControlProduct.setCloseState(2);
sarStandIssueControlProduct.setActualCloseTime(new Timestamp(new Date().getTime()));
sarStandIssueControlProductDao.updateById(sarStandIssueControlProduct);
return true;
}
}
@@ -3,6 +3,7 @@ package com.adc.da.slrs.sarStandProjectLibrary.controller;
import com.adc.da.http.ResponseMessage;
import com.adc.da.http.Result;
import com.adc.da.slrs.sarStandProjectLibrary.entity.SarStandProjectLibraryDto;
import com.adc.da.slrs.sarStandProjectLibrary.service.impl.SarStandProjectLibraryServiceImpl;
import com.adc.da.slrs.sarStandWarning.entity.EarlyWarningEO;
import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -16,26 +17,58 @@ import org.springframework.web.bind.annotation.RestController;
import com.adc.da.base.web.BaseController;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* <p>
* 前端控制器
* </p>
*
* @author ZhangJin
* @since 2021-06-15
*/
* <p>
* 前端控制器
* </p>
*
* @author ZhangJin
* @since 2021-06-15
*/
@RestController
@Api(description = "|SarStandProjectLibrary|")
@RequestMapping("/sarStandProjectLibrary/sar-stand-project-library")
@RequestMapping("/api/sarStandProjectLibrary")
public class SarStandProjectLibraryController extends BaseController<SarStandProjectLibrary> {
@Resource
private SarStandProjectLibraryServiceImpl sarStandProjectLibraryService;
@GetMapping("/queryMaintenanceProject")
@ApiOperation("项目查询")
public ResponseMessage queryMaintenanceProject(@RequestParam(defaultValue = "1", value = "newStandPage")int Page, @RequestParam(defaultValue = "10", value = "newStandPageSize") int PageSize) {
IPage<SarStandProjectLibrary> list = sarStandProjectLibraryService.queryMaintenanceProject(Page,PageSize);
/**
*
* @param Page
* @param PageSize
* @param sarDto
* @return
* @author zj
* date 2021-06-22
**/
@GetMapping("/queryProject")
@ApiOperation("车型/项目库")
public ResponseMessage queryMaintenanceProject(@RequestParam(defaultValue = "1", value = "Page")int Page, @RequestParam(defaultValue = "10", value = "PageSize") int PageSize,
SarStandProjectLibraryDto sarDto) {
IPage<SarStandProjectLibrary> MaintenanceList = sarStandProjectLibraryService.queryMaintenanceProject(Page,PageSize,sarDto);
IPage<SarStandProjectLibrary> notMaintenanceList = sarStandProjectLibraryService.queryNotMaintenanceProject(Page,PageSize,sarDto);
Map<String, Object> map = new HashMap<String, Object>();
map.put("Maintenance",MaintenanceList);
map.put("notMaintenance",notMaintenanceList);
return Result.success("200",map);
}
/**
*
* @param id
* @return
* @author zj
* date 2021-06-22
**/
@GetMapping("/queryById")
@ApiOperation("点击项目id查询")
public ResponseMessage queryByName(String id){
List<SarStandProjectLibrary> list = sarStandProjectLibraryService.queryById(id);
return Result.success("200",list);
}
}
@@ -0,0 +1,38 @@
package com.adc.da.slrs.sarStandProjectLibrary.entity;
import lombok.Data;
import java.util.Date;
/**
* //TODO
*
* @author 作者信息
* @date 2021-06-16
*/
@Data
public class SarStandProjectLibraryDto {
private String projectPlatfor;
private String projectNumber;
private String projectName;
private String projectClassification;
private String projectStatus;
private String projectGroup;
private String projectStartDate;
private String projectEndDate;
private String currentNode;
private String projectLevel;
private String projectManager;
}
@@ -1,18 +0,0 @@
package com.adc.da.slrs.sarStandProjectLibrary.service;
import com.adc.da.slrs.sarStandProjectLibrary.entity.SarStandProjectLibrary;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
/**
* <p>
* 服务类
* </p>
*
* @author super_liu
* @since 2021-06-02
*/
public interface ISarStandProjectLibraryService extends IService<SarStandProjectLibrary> {
IPage<SarStandProjectLibrary> queryMaintenanceProject(int current, int pageSize);
}
@@ -0,0 +1,13 @@
package com.adc.da.slrs.sarStandProjectLibrary.service;
import com.adc.da.slrs.sarStandProjectLibrary.entity.SarStandProjectLibrary;
import com.adc.da.slrs.sarStandProjectLibrary.entity.SarStandProjectLibraryDto;
import com.baomidou.mybatisplus.core.metadata.IPage;
import java.util.List;
public interface SarStandProjectLibraryService {
IPage<SarStandProjectLibrary> queryMaintenanceProject(int current, int pageSize, SarStandProjectLibraryDto sarDto);
IPage<SarStandProjectLibrary> queryNotMaintenanceProject(int current, int pageSize, SarStandProjectLibraryDto sarDto);
List<SarStandProjectLibrary> queryById(String id);
}
@@ -2,14 +2,20 @@ package com.adc.da.slrs.sarStandProjectLibrary.service.impl;
import com.adc.da.slrs.sarStandProjectLibrary.entity.SarStandProjectLibrary;
import com.adc.da.slrs.sarStandProjectLibrary.dao.SarStandProjectLibraryDao;
import com.adc.da.slrs.sarStandProjectLibrary.service.ISarStandProjectLibraryService;
import com.adc.da.slrs.sarStandProjectLibrary.entity.SarStandProjectLibraryDto;
import com.adc.da.slrs.sarStandProjectLibrary.service.SarStandProjectLibraryService;
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.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.List;
/**
* <p>
* 服务实现类
@@ -19,15 +25,101 @@ import org.springframework.stereotype.Service;
* @since 2021-06-15
*/
@Service
public class SarStandProjectLibraryServiceImpl extends ServiceImpl<SarStandProjectLibraryDao, SarStandProjectLibrary> implements ISarStandProjectLibraryService {
public class SarStandProjectLibraryServiceImpl extends ServiceImpl<SarStandProjectLibraryDao, SarStandProjectLibrary> implements SarStandProjectLibraryService {
@Autowired
@Resource
private SarStandProjectLibraryDao sarStandProjectLibraryDao;
@Override
public IPage<SarStandProjectLibrary> queryMaintenanceProject(int current,int pageSize) {
QueryWrapper<SarStandProjectLibrary> wrapper= new QueryWrapper<>();
wrapper.inSql("id", "select project_id from sar_stand_project_relation");
public IPage<SarStandProjectLibrary> queryMaintenanceProject(int current, int pageSize, SarStandProjectLibraryDto sarDto) {
SarStandProjectLibrary sar = new SarStandProjectLibrary();
sar.setProjectPlatfor(sarDto.getProjectPlatfor());
sar.setProjectNumber(sarDto.getProjectNumber());
sar.setProjectName(sarDto.getProjectName());
sar.setProjectClassification(sarDto.getProjectClassification());
sar.setProjectStatus(sarDto.getProjectStatus());
sar.setProjectGroup(sarDto.getProjectGroup());
sar.setCurrentNode(sarDto.getCurrentNode());
sar.setProjectLevel(sar.getProjectLevel());
sar.setProjectManager(sarDto.getProjectManager());
SimpleDateFormat formater = new SimpleDateFormat();
formater.applyPattern("yyyy-MM-dd");
try {
if (sarDto.getProjectStartDate()!=null){
sar.setProjectStartDate(formater.parse(sarDto.getProjectStartDate()));
}
if (sarDto.getProjectEndDate()!=null){
sar.setProjectEndDate(formater.parse(sarDto.getProjectEndDate()));
}
} catch (ParseException e) {
e.printStackTrace();
}
QueryWrapper<SarStandProjectLibrary> wrapper = new QueryWrapper<>();
wrapper.inSql("id", "select project_id from sar_stand_project_relation")
.like(StringUtils.isNotEmpty(sar.getProjectPlatfor()),"project_platfor",sar.getProjectPlatfor())
.like(StringUtils.isNotEmpty(sar.getProjectNumber()),"project_number",sar.getProjectNumber())
.like(StringUtils.isNotEmpty(sar.getProjectName()),"project_name",sar.getProjectName())
.like(StringUtils.isNotEmpty(sar.getProjectGroup()),"project_group",sar.getProjectGroup())
.like(StringUtils.isNotEmpty(sar.getProjectClassification()),"project_classification",sar.getProjectClassification())
.like(StringUtils.isNotEmpty(sar.getProjectStatus()),"project_status",sar.getProjectStatus())
.like(StringUtils.isNotEmpty(sar.getCurrentNode()),"current_node",sar.getCurrentNode())
.like(StringUtils.isNotEmpty(sar.getProjectLevel()),"project_level",sar.getProjectLevel())
.like(StringUtils.isNotEmpty(sar.getProjectManager()),"project_manager",sar.getProjectManager())
.ge(sar.getProjectStartDate()!=null,"project_start_date",sar.getProjectStartDate())
.le(sar.getProjectEndDate()!=null,"project_end_date",sar.getProjectEndDate());
return getSarStandProjectLibraryIPage(current, pageSize, wrapper);
}
@Override
public IPage<SarStandProjectLibrary> queryNotMaintenanceProject(int current, int pageSize, SarStandProjectLibraryDto sarDto) {
SarStandProjectLibrary sar = new SarStandProjectLibrary();
sar.setProjectPlatfor(sarDto.getProjectPlatfor());
sar.setProjectNumber(sarDto.getProjectNumber());
sar.setProjectName(sarDto.getProjectName());
sar.setProjectClassification(sarDto.getProjectClassification());
sar.setProjectStatus(sarDto.getProjectStatus());
sar.setProjectGroup(sarDto.getProjectGroup());
sar.setCurrentNode(sarDto.getCurrentNode());
sar.setProjectLevel(sar.getProjectLevel());
sar.setProjectManager(sarDto.getProjectManager());
SimpleDateFormat formater = new SimpleDateFormat();
formater.applyPattern("yyyy-MM-dd");
try {
if (sarDto.getProjectStartDate()!=null){
sar.setProjectStartDate(formater.parse(sarDto.getProjectStartDate()));
}
if (sarDto.getProjectEndDate()!=null){
sar.setProjectEndDate(formater.parse(sarDto.getProjectEndDate()));
}
} catch (ParseException e) {
e.printStackTrace();
}
QueryWrapper<SarStandProjectLibrary> wrapper = new QueryWrapper<>();
wrapper.notInSql("id", "select project_id from sar_stand_project_relation")
.like(StringUtils.isNotEmpty(sar.getProjectPlatfor()),"project_platfor",sar.getProjectPlatfor())
.like(StringUtils.isNotEmpty(sar.getProjectNumber()),"project_number",sar.getProjectNumber())
.like(StringUtils.isNotEmpty(sar.getProjectName()),"project_name",sar.getProjectName())
.like(StringUtils.isNotEmpty(sar.getProjectGroup()),"project_group",sar.getProjectGroup())
.like(StringUtils.isNotEmpty(sar.getProjectClassification()),"project_classification",sar.getProjectClassification())
.like(StringUtils.isNotEmpty(sar.getProjectStatus()),"project_status",sar.getProjectStatus())
.like(StringUtils.isNotEmpty(sar.getCurrentNode()),"current_node",sar.getCurrentNode())
.like(StringUtils.isNotEmpty(sar.getProjectLevel()),"project_level",sar.getProjectLevel())
.like(StringUtils.isNotEmpty(sar.getProjectManager()),"project_manager",sar.getProjectManager())
.ge(sar.getProjectStartDate()!=null,"project_start_date",sar.getProjectStartDate())
.le(sar.getProjectEndDate()!=null,"project_end_date",sar.getProjectEndDate());
return getSarStandProjectLibraryIPage(current, pageSize, wrapper);
}
@Override
public List<SarStandProjectLibrary> queryById(String id) {
QueryWrapper<SarStandProjectLibrary> wrapper = new QueryWrapper<>();
wrapper.eq("id",id);
List<SarStandProjectLibrary> list = sarStandProjectLibraryDao.selectList(wrapper);
return list;
}
private IPage<SarStandProjectLibrary> getSarStandProjectLibraryIPage(int current, int pageSize, QueryWrapper<SarStandProjectLibrary> wrapper) {
Page<SarStandProjectLibrary> page = new Page<>(current, pageSize);
IPage<SarStandProjectLibrary> userIPage = sarStandProjectLibraryDao.selectPage(page, wrapper);
System.out.println("总条数"+userIPage.getTotal());
@@ -1,15 +1,42 @@
package com.adc.da.slrs.sarStandUnqualified.controller;
import com.adc.da.common.ReadExcel;
import com.adc.da.exception.AdcDaBaseException;
import com.adc.da.http.ResponseMessage;
import com.adc.da.http.ResponseMessageCodeEnum;
import com.adc.da.http.Result;
import com.adc.da.slrs.sarStandUnqualified.entity.SarStandUnqualifiedPage;
import com.adc.da.slrs.sarStandUnqualified.entity.StandUnqualifiedExcelVO;
import com.adc.da.slrs.sarStandUnqualified.entity.StandUnqualifiedListVO;
import com.adc.da.slrs.sarStandUnqualified.service.ISarStandUnqualifiedService;
import com.adc.da.slrs.sarStandardsInfo.controller.SarStandardsInfoController;
import com.adc.da.slrs.sarStandardsInfo.entity.SarStandardsInfo;
import com.adc.da.slrs.sarStandardsInfo.entity.StandardsInfoExcelVO;
import com.adc.da.utils.util.StandExportUtil;
import com.alibaba.excel.EasyExcel;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.metadata.IPage;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.util.IOUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.*;
import com.adc.da.slrs.sarStandUnqualified.entity.SarStandUnqualified;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.RestController;
import com.adc.da.base.web.BaseController;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.OutputStream;
import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.List;
/**
* <p>
* 前端控制器
@@ -20,10 +47,81 @@ import com.adc.da.base.web.BaseController;
*/
@RestController
@Api(tags = "未符合项整改")
@RequestMapping("/sarStandUnqualified/sar-stand-unqualified")
@RequestMapping("/api/sarStandUnqualified/sar-stand-unqualified")
public class SarStandUnqualifiedController extends BaseController<SarStandUnqualified> {
private static final Logger logger = LoggerFactory.getLogger(SarStandardsInfoController.class);
@Autowired
private ISarStandUnqualifiedService sarStandUnqualifiedService;
/**
* 分页查询未符合项
* @param sarStandUnqualifiedPage:筛选、分页信息
* @return ResponseMessage<IPage<SarStandUnqualified>>
*/
@ApiOperation("分页查询未符合项")
@GetMapping
public ResponseMessage<IPage<SarStandUnqualified>> getSarStandUnqualifiedPage(SarStandUnqualifiedPage sarStandUnqualifiedPage){
IPage<SarStandUnqualified> sarStandUnqualifiedIPage=sarStandUnqualifiedService.getSarStandUnqualifiedPage(sarStandUnqualifiedPage);
return Result.success(sarStandUnqualifiedIPage);
}
/**
* 分页查询未符合项历史数据
* @param sarStandUnqualifiedPage:筛选、分页信息
* @return ResponseMessage<IPage<SarStandUnqualified>>
*/
@ApiOperation("分页查询未符合项历史数据")
@GetMapping("/history")
public ResponseMessage<IPage<SarStandUnqualified>> getSarStandUnqualifiedHistoryPage(SarStandUnqualifiedPage sarStandUnqualifiedPage){
IPage<SarStandUnqualified> sarStandUnqualifiedIPage=sarStandUnqualifiedService.getSarStandUnqualifiedHistoryPage(sarStandUnqualifiedPage);
return Result.success(sarStandUnqualifiedIPage);
}
/**
* 批量关闭未符合项
* @param standUnqualifiedListVO:未符合项ID列表
* @return ResponseMessage<List<String>>:关闭失败的未符合项ID
*/
@ApiOperation("批量关闭未符合项")
@PostMapping("/close")
public ResponseMessage<List<String>> closeSarStandUnqualified(StandUnqualifiedListVO standUnqualifiedListVO){
if(standUnqualifiedListVO==null||standUnqualifiedListVO.getIds().size()==0){
return Result.error(ResponseMessageCodeEnum.ERROR.getCode(),"未传入未符合项ID",null);
}
List<String> failIds=sarStandUnqualifiedService.closeSarStandUnqualifiedList(standUnqualifiedListVO);
if(failIds==null||failIds.size()==0){
return Result.success(null);
}else {
return Result.error(ResponseMessageCodeEnum.ERROR.getCode(),"部分未符合项关闭失败",null);
}
}
@ApiOperation("导出Excel表")
@GetMapping(value = "/exportStandUnqulifiedExcel")
public void exportStandardsInfoExcel(StandUnqualifiedExcelVO standUnqualifiedExcelVO, HttpServletResponse response) throws Exception {
// 这里注意 有同学反应使用swagger 会导致各种问题,请直接用浏览器或者用postman
try {
response.setContentType("application/vnd.ms-excel");
response.setCharacterEncoding("utf-8");
// 这里URLEncoder.encode可以防止中文乱码 当然和easyexcel没有关系
if(standUnqualifiedExcelVO.getExportName()==null){
standUnqualifiedExcelVO.setExportName("未符合项信息");
}
String fileName = URLEncoder.encode(standUnqualifiedExcelVO.getExportName(), "UTF-8").replaceAll("\\+", "%20");
response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx");
List<SarStandUnqualified> data=sarStandUnqualifiedService.getStandUnqualifiedExcelData(standUnqualifiedExcelVO);
// 这里需要设置不关闭流
EasyExcel.write(response.getOutputStream(), SarStandUnqualified.class).autoCloseStream(Boolean.FALSE).sheet("sheet1")
.doWrite(data);
} catch (Exception e) {
System.out.println(e);
// 重置response
response.reset();
response.setContentType("application/json");
response.setCharacterEncoding("utf-8");
response.getWriter().println(JSON.toJSONString(Result.error()));
}
}
}
@@ -1,14 +1,22 @@
package com.adc.da.slrs.sarStandUnqualified.entity;
import com.adc.da.base.entity.BaseEntity;
import java.time.LocalDateTime;
import java.sql.Timestamp;
import com.adc.da.slrs.sarStandUnqualified.utils.ProductTypeConverter;
import com.adc.da.slrs.sarStandUnqualified.utils.TimestampConverter;
import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;
import org.springframework.format.annotation.DateTimeFormat;
/**
* <p>
@@ -26,74 +34,104 @@ public class SarStandUnqualified extends BaseEntity {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "创建部门")
@TableField("CREATE_DEPT_ID")
private String createDeptId;
@ApiModelProperty(value = "创建人")
@TableField("CREATE_BY_ID")
private String createById;
@ApiModelProperty(value = "创建时间")
@TableField("CREATE_TIME")
private LocalDateTime createTime;
@ApiModelProperty(value = "关闭状态(1为开启,2为关闭)")
@TableField("CLOSE_STATE")
private Integer closeState;
@ApiModelProperty(value = "实际关闭时间")
@TableField("ACTUAL_CLOSE_TIME")
private LocalDateTime actualCloseTime;
@ApiModelProperty(value = "计划关闭时间")
@TableField("PLAN_CLOSE_TIME")
private LocalDateTime planCloseTime;
@ApiModelProperty(value = "质量工程师")
@TableField("QA_ENGINEER")
private String qaEngineer;
@ApiModelProperty(value = "认证工程师")
@TableField("AUTH_ENGINEER")
private String authEngineer;
@ApiModelProperty(value = "责任工程师")
@TableField("DUTY_ENGINEER")
private String dutyEngineer;
@ApiModelProperty(value = "责任部门")
@TableField("RESPONSIBLE_UNIT")
private String responsibleUnit;
@ApiModelProperty(value = "项目名称")
@TableField("PRODUCT_NAME")
private String productName;
@ApiModelProperty(value = "产品线")
@TableField("PRODUCT_LINE")
private String productLine;
@ApiModelProperty(value = "产品类型(research为在研产品,product为在产产品)")
@TableField("PRODUCT_TYPE")
private String productType;
@ApiModelProperty(value = "条款名称")
@TableField("ITEMS_NAME")
private String itemsName;
@ApiModelProperty(value = "条款号")
@TableField("ITEMS_NUM")
private String itemsNum;
@ApiModelProperty(value = "标准名称")
@TableField("STAND_NAME")
private String standName;
@ExcelProperty("标准编号")
@ApiModelProperty(value = "标准ID")
@TableField("STAND_ID")
private String standId;
@ExcelProperty("标准名称")
@ApiModelProperty(value = "标准名称")
@TableField("STAND_NAME")
private String standName;
@ExcelProperty("条款号")
@ApiModelProperty(value = "条款号")
@TableField("ITEMS_NUM")
private String itemsNum;
@ExcelProperty("条款名称")
@ApiModelProperty(value = "条款名称")
@TableField("ITEMS_NAME")
private String itemsName;
@ExcelProperty("产品线")
@ApiModelProperty(value = "产品线")
@TableField("PRODUCT_LINE")
private String productLine;
@ExcelProperty("责任部门")
@ApiModelProperty(value = "责任部门")
@TableField("RESPONSIBLE_UNIT")
private String responsibleUnit;
@ExcelProperty("项目名称")
@ApiModelProperty(value = "项目名称")
@TableField("PRODUCT_NAME")
private String productName;
@ExcelProperty("创建部门")
@ApiModelProperty(value = "创建部门")
@TableField("CREATE_DEPT_ID")
private String createDeptId;
@ExcelProperty("创建人")
@ApiModelProperty(value = "创建人")
@TableField("CREATE_BY_ID")
private String createById;
@ExcelProperty(value = "创建时间",converter = TimestampConverter.class)
@ApiModelProperty(value = "创建时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@TableField("CREATE_TIME")
private Timestamp createTime;
@ExcelIgnore
@ApiModelProperty(value = "关闭状态(1为开启,2为关闭)")
@TableField("CLOSE_STATE")
private Integer closeState;
@ExcelIgnore
@ApiModelProperty(value = "实际关闭时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@TableField("ACTUAL_CLOSE_TIME")
private Timestamp actualCloseTime;
@ExcelProperty(value = "计划关闭时间",converter = TimestampConverter.class)
@ApiModelProperty(value = "计划关闭时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
@TableField("PLAN_CLOSE_TIME")
private Timestamp planCloseTime;
@ApiModelProperty(value = "未符合原因")
@TableField("REASON")
private String reason;
@ExcelProperty("质量工程师")
@ApiModelProperty(value = "质量工程师")
@TableField("QA_ENGINEER")
private String qaEngineer;
@ExcelProperty("认证工程师")
@ApiModelProperty(value = "认证工程师")
@TableField("AUTH_ENGINEER")
private String authEngineer;
@ExcelProperty("责任工程师")
@ApiModelProperty(value = "责任工程师")
@TableField("DUTY_ENGINEER")
private String dutyEngineer;
@ExcelProperty(value = "产品类型",converter = ProductTypeConverter.class)
@ApiModelProperty(value = "产品类型(research为在研产品,product为在产产品)")
@TableField("PRODUCT_TYPE")
private String productType;
@ExcelIgnore
@ApiModelProperty(value = "主键")
@TableId("ID")
private String id;

Some files were not shown because too many files have changed in this diff Show More