|
@@ -1,16 +1,21 @@
|
|
package com.hssx.cloudmodel.service.impl;
|
|
package com.hssx.cloudmodel.service.impl;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
+import com.github.pagehelper.PageHelper;
|
|
|
|
+import com.github.pagehelper.PageInfo;
|
|
import com.hssx.cloudmodel.entity.Project;
|
|
import com.hssx.cloudmodel.entity.Project;
|
|
import com.hssx.cloudmodel.entity.ProjectUser;
|
|
import com.hssx.cloudmodel.entity.ProjectUser;
|
|
|
|
+import com.hssx.cloudmodel.entity.User;
|
|
import com.hssx.cloudmodel.mapper.ProjectMapper;
|
|
import com.hssx.cloudmodel.mapper.ProjectMapper;
|
|
import com.hssx.cloudmodel.service.ProjectService;
|
|
import com.hssx.cloudmodel.service.ProjectService;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.hssx.cloudmodel.util.HttpRespMsg;
|
|
import com.hssx.cloudmodel.util.HttpRespMsg;
|
|
import com.hssx.cloudmodel.util.ListUtil;
|
|
import com.hssx.cloudmodel.util.ListUtil;
|
|
|
|
+import com.hssx.cloudmodel.util.PageUtil;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
+import javax.jws.soap.SOAPBinding;
|
|
import java.text.SimpleDateFormat;
|
|
import java.text.SimpleDateFormat;
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
@@ -32,28 +37,34 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
ProjectUser projectUser;
|
|
ProjectUser projectUser;
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public HttpRespMsg addAndUpdateProject(Project project, Integer flag) {
|
|
|
|
|
|
+ public HttpRespMsg addAndUpdateProject(Project project, Integer flag, User user) {
|
|
HttpRespMsg msg = new HttpRespMsg();
|
|
HttpRespMsg msg = new HttpRespMsg();
|
|
- QueryWrapper<Project> qw = new QueryWrapper<>();
|
|
|
|
- qw.orderByDesc("id").last("limit 1");
|
|
|
|
- Project lastProject = projectMapper.selectOne(qw);
|
|
|
|
- if (flag == 0) {
|
|
|
|
- synchronized (this) {
|
|
|
|
- int count = 1;
|
|
|
|
- if (lastProject != null) {
|
|
|
|
- //YMXM201903220001
|
|
|
|
- String numStr = lastProject.getProjectNo().substring(13);
|
|
|
|
- int num = Integer.valueOf(numStr).intValue();
|
|
|
|
- count += num;
|
|
|
|
|
|
+ if(user != null){
|
|
|
|
+ QueryWrapper<Project> qw = new QueryWrapper<>();
|
|
|
|
+ qw.orderByDesc("id").last("limit 1");
|
|
|
|
+ Project lastProject = projectMapper.selectOne(qw);
|
|
|
|
+ if (flag == 0) {
|
|
|
|
+ synchronized (this) {
|
|
|
|
+ int count = 1;
|
|
|
|
+ if (lastProject != null) {
|
|
|
|
+ //YMXM201903220001
|
|
|
|
+ String numStr = lastProject.getProjectNo().substring(13);
|
|
|
|
+ int num = Integer.valueOf(numStr).intValue();
|
|
|
|
+ count += num;
|
|
|
|
+ }
|
|
|
|
+ long time = System.currentTimeMillis();
|
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
|
|
|
|
+ String seq = sdf.format(time) + String.format("%04d", count);
|
|
|
|
+ project.setProjectNo("YMXM"+seq);
|
|
|
|
+ project.setCreatorId(user.getId());
|
|
|
|
+ project.setCreator(user.getUsername());
|
|
|
|
+ projectMapper.insert(project);
|
|
}
|
|
}
|
|
- long time = System.currentTimeMillis();
|
|
|
|
- SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
|
|
|
|
- String seq = sdf.format(time) + String.format("%04d", count);
|
|
|
|
- project.setProjectNo("YMXM"+seq);
|
|
|
|
- projectMapper.insert(project);
|
|
|
|
|
|
+ }else if(flag == 1){
|
|
|
|
+ projectMapper.updateById(project);
|
|
}
|
|
}
|
|
- }else if(flag == 1){
|
|
|
|
- projectMapper.updateById(project);
|
|
|
|
|
|
+ }else{
|
|
|
|
+ msg.setError("当前角色涉及权限问题,请重新登录");
|
|
}
|
|
}
|
|
return msg;
|
|
return msg;
|
|
}
|
|
}
|
|
@@ -77,4 +88,19 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
|
|
}
|
|
}
|
|
return msg;
|
|
return msg;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public HttpRespMsg getList(String keyName,PageUtil page) {
|
|
|
|
+ HttpRespMsg msg = new HttpRespMsg();
|
|
|
|
+ QueryWrapper<Project> qw = new QueryWrapper<>();
|
|
|
|
+ qw.select("project_name", "creator","charger","indate");
|
|
|
|
+ if(keyName != null){
|
|
|
|
+ qw.like("project_name",keyName);
|
|
|
|
+ }
|
|
|
|
+ PageHelper.startPage(page.getPageNum(),page.getPageSize());
|
|
|
|
+ List<Project> projects = projectMapper.selectList(qw);
|
|
|
|
+ PageInfo<Project> pageInfos = new PageInfo<>(projects);
|
|
|
|
+ msg.data = pageInfos;
|
|
|
|
+ return msg;
|
|
|
|
+ }
|
|
}
|
|
}
|