Commit 819ccfcf authored by 竹天卫's avatar 竹天卫

bug修复

parent 2aee0f89
package cn.wise.sc.cement.business.controller;
import cn.wise.sc.cement.business.model.BaseResponse;
import cn.wise.sc.cement.business.model.PageQuery;
import cn.wise.sc.cement.business.service.IDataStatisticsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
......@@ -46,31 +47,57 @@ public class DataStatisticsController {
@ApiOperation(value = "统计概览-检测项数量统计")
@ApiImplicitParams(value = {
@ApiImplicitParam(name = "type", value = "类型1:按时间 2:按地区", paramType = "query", dataType = "Integer"),
@ApiImplicitParam(name = "", value = "类型1:按时间 2:按地区", paramType = "query", dataType = "Integer"),
@ApiImplicitParam(name = "cycle", value = "统计周期1:本周 2:本月 3:本年", paramType = "query", dataType = "Integer"),
@ApiImplicitParam(name = "startDate", value = "开始日期", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "endDate", value = "结束日期", paramType = "query", dataType = "String")
})
@GetMapping("/countTeamByTime")
public BaseResponse countTeamByTime(Integer type, String startDate, String endDate) {
@GetMapping("/countTeam")
public BaseResponse countTeam(Integer type, Integer cycle, String startDate, String endDate) {
try {
if(type == 1){
return dataStatisticsService.countTeamByTime(cycle, startDate,endDate);
}else if(type == 2){
return dataStatisticsService.countTeamByOrigin(cycle, startDate,endDate);
}else{
return BaseResponse.errorMsg("参数错误");
}
} catch (Exception e) {
log.debug("统计概览-检测项数量统计{}", e);
}
return BaseResponse.errorMsg("失败!");
}
return dataStatisticsService.countTeamByTime(startDate,endDate);
@ApiOperation(value = "统计概览-项目进展统计")
@GetMapping("/countEntrustStatus")
public BaseResponse countEntrustStatus() {
try {
return dataStatisticsService.countEntrustStatus();
} catch (Exception e) {
log.debug("统计概览-项目进展统计{}", e);
}
return BaseResponse.errorMsg("失败!");
}
@ApiOperation(value = "统计概览-进行中任务数量统计")
@GetMapping("/countTaskIng")
public BaseResponse countTaskIng(PageQuery pageQuery) {
try {
return dataStatisticsService.countTaskIng(pageQuery);
} catch (Exception e) {
log.debug("统计概览-进行中任务数量统计{}", e);
}
return BaseResponse.errorMsg("失败!");
}
@ApiOperation(value = "统计概览-正在进行的检测项统计")
@GetMapping("/countTeamIng")
public BaseResponse countTeamIng() {
try {
return dataStatisticsService.countTeamIng();
} catch (Exception e) {
log.debug("统计概览-检测项数量统计{}", e);
log.debug("统计概览-正在进行的检测项统计{}", e);
}
return BaseResponse.errorMsg("失败!");
}
......@@ -84,5 +111,7 @@ public class DataStatisticsController {
}
package cn.wise.sc.cement.business.controller;
import cn.wise.sc.cement.business.entity.SysGroup;
import cn.wise.sc.cement.business.entity.SysUser;
import cn.wise.sc.cement.business.entity.Team;
import cn.wise.sc.cement.business.entity.TeamGroup;
import cn.wise.sc.cement.business.model.BaseResponse;
import cn.wise.sc.cement.business.model.PageQuery;
import cn.wise.sc.cement.business.model.query.TeamGroupQuery;
import cn.wise.sc.cement.business.service.ITeamGroupService;
import cn.wise.sc.cement.business.service.ITeamService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
......@@ -34,6 +38,8 @@ public class TeamGroupController {
@Autowired
private ITeamGroupService teamGroupService;
@Autowired
private ITeamService teamService;
@ApiOperation(value = "检测组分页列表")
@ApiImplicitParams(value = {
......@@ -102,6 +108,19 @@ public class TeamGroupController {
@PostMapping("/delete/{id}")
public BaseResponse delete(@PathVariable Integer id) {
try {
if(id == null){
return BaseResponse.errorMsg("参数错误");
}
TeamGroup teamGroup = teamGroupService.getById(id);
if(teamGroup == null){
return BaseResponse.errorMsg("信息错误");
}
QueryWrapper<Team> teamQueryWrapper = new QueryWrapper<>();
teamQueryWrapper.eq("group_id", id);
Integer conunts = teamService.count(teamQueryWrapper);
if (conunts != 0 && conunts > 0) {
return BaseResponse.errorMsg(conunts + "个检测项正在使用!");
}
teamGroupService.removeById(id);
return BaseResponse.okData("删除成功");
} catch (Exception e) {
......
......@@ -26,4 +26,11 @@ public interface DataStatisticsMapper {
List<DataStatisticsVo> countTeamByOrigin(@Param("params") Map<String, Object> params);
List<DataStatisticsVo> countEntrustStatus();
IPage<DataStatisticsVo> countHandlePage(@Param("page") Page page);
IPage<DataStatisticsVo> countDistributionPage(@Param("page") Page page);
List<DataStatisticsVo> countTeamIng();
}
......@@ -71,4 +71,7 @@ public interface SampleMapper extends BaseMapper<Sample> {
}
......@@ -6,6 +6,15 @@
SELECT DATE_FORMAT(sd.create_time,'%Y-%m') as name, count(sd.id) as value
FROM sample_distribution sd
where sd.finish_time is not null
<if test="params.cycle == 1 ">
and YEARWEEK(date_format(sd.create_time,'%Y-%m-%d' ) ) = YEARWEEK(now())
</if>
<if test="params.cycle == 2 ">
and DATE_FORMAT( sd.create_time, '%Y%m' ) = DATE_FORMAT( CURDATE( ) ,'%Y%m')
</if>
<if test="params.cycle = 3 ">
and YEAR(sd.create_time) = YEAR( NOW( ) )
</if>
<if test="params.startDate != null and params.startDate != ''">
and DATE(sd.create_time) &gt;= #{params.startDate}
</if>
......@@ -20,8 +29,17 @@
FROM sample_distribution sd
left join sample s on s.id = sd.sample_id
where sd.finish_time is not null
<if test="params.startDate != null and params.startDate != ''">
and DATE(sd.create_time) &gt;= #{params.startDate}
<if test="params.cycle == 1 ">
and YEARWEEK(date_format(sd.create_time,'%Y-%m-%d' ) ) = YEARWEEK(now())
</if>
<if test="params.cycle == 2 ">
and DATE_FORMAT( sd.create_time, '%Y%m' ) = DATE_FORMAT( CURDATE( ) ,'%Y%m')
</if>
<if test="params.cycle == 3 ">
and YEAR(sd.create_time) = YEAR( NOW( ) )
</if>
<if test="params.endDate != null and params.endDate != ''">
and DATE(sd.create_time) &lt;= #{params.endDate}
</if>
<if test="params.endDate != null and params.endDate != ''">
and DATE(sd.create_time) &lt;= #{params.endDate}
......@@ -30,6 +48,52 @@
</select>
<select id="countEntrustStatus" resultType="cn.wise.sc.cement.business.model.vo.DataStatisticsVo">
SELECT (
CASE e.status
WHEN 0 THEN '未评审'
WHEN 1 THEN '已通过'
WHEN 2 THEN '未通过'
WHEN 3 THEN '样品处理中'
WHEN 4 THEN '样品处理完成'
WHEN 5 THEN '样品检测中'
WHEN 6 THEN '样品检测完成'
WHEN 7 THEN '校核中'
WHEN 8 THEN '校核完成'
ELSE ''
END
) as name,
count(*) as value
FROM entrust e
group by e.status
</select>
<select id="countHandlePage" resultType="cn.wise.sc.cement.business.model.vo.DataStatisticsVo">
SELECT su.name as name, count(*) as value FROM sample_handle sh
left join sys_user su on su.id = sh.user_id
where sh.status != 2
group by sh.user_id
</select>
<select id="countDistributionPage" resultType="cn.wise.sc.cement.business.model.vo.DataStatisticsVo">
SELECT su.name as name, count(*) as value FROM sample_distribution sd
left join sys_user su on su.id = sd.user_id
where sd.status != 2
group by sd.user_id
</select>
<select id="countTeamIng" resultType="cn.wise.sc.cement.business.model.vo.DataStatisticsVo">
SELECT t.name as name, count(*) as value FROM sample_distribution sd
left join team t on t.id = sd.team_id
where sd.status != 2
group by sd.team_id
</select>
</mapper>
......@@ -26,9 +26,14 @@ public interface IDataStatisticsService {
BaseResponse<Map<String, String>> countOverview();
BaseResponse<List<DataStatisticsVo>> countTeamByTime(String startDate, String endDate);
BaseResponse<List<DataStatisticsVo>> countTeamByTime(Integer cycle, String startDate, String endDate);
BaseResponse<List<DataStatisticsVo>> countTeamByOrigin(String startDate, String endDate);
BaseResponse<List<DataStatisticsVo>> countTeamByOrigin(Integer cycle, String startDate, String endDate);
BaseResponse<Map<String, Object>> countEntrustStatus();
BaseResponse<Map<String, Object>> countTaskIng(PageQuery pageQuery);
BaseResponse<List<DataStatisticsVo>> countTeamIng();
}
......@@ -77,6 +77,9 @@ public class ClientServiceImpl extends ServiceImpl<ClientMapper, Client> impleme
if (count > 0) {
return BaseResponse.errorMsg("单位名称已存在!");
}
if(query.getPrincipal().length() > 20 ){
return BaseResponse.errorMsg("联系人姓名过长!");
}
if(query.getPrincipalPhone().length() > 15 ){
return BaseResponse.errorMsg("联系人电话过长!");
}
......@@ -100,6 +103,12 @@ public class ClientServiceImpl extends ServiceImpl<ClientMapper, Client> impleme
if (count > 0) {
return BaseResponse.errorMsg("单位名称已存在!");
}
if(query.getPrincipal().length() > 20 ){
return BaseResponse.errorMsg("联系人姓名过长!");
}
if(query.getPrincipalPhone().length() > 15 ){
return BaseResponse.errorMsg("联系人电话过长!");
}
Client update = new Client();
BeanUtils.copyProperties(query, update);
update.setId(query.getId());
......
......@@ -19,6 +19,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.swagger.models.auth.In;
import lombok.Data;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
......@@ -62,6 +63,10 @@ public class DataStatisticsServiceImpl implements IDataStatisticsService {
private IEntrustService entrustService;
@Autowired
private CommonServiceImpl commonService;
@Autowired
private ISampleHandleService sampleHandleService;
@Autowired
private ISampleDistributionService sampleDistributionService;
/**
......@@ -98,12 +103,13 @@ public class DataStatisticsServiceImpl implements IDataStatisticsService {
/**
* 检测项数量统计-按时间
* @param cycle
* @param startDate
* @param endDate
* @return
*/
@Override
public BaseResponse<List<DataStatisticsVo>> countTeamByTime(String startDate, String endDate){
public BaseResponse<List<DataStatisticsVo>> countTeamByTime(Integer cycle, String startDate, String endDate){
Map<String, String> dateMap = new HashMap<>();
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM");
......@@ -130,6 +136,7 @@ public class DataStatisticsServiceImpl implements IDataStatisticsService {
}
Map<String, Object> params = new HashMap<>();
params.put("cycle", cycle);
params.put("startDate", startDate);
params.put("endDate", endDate);
List<DataStatisticsVo> list = dataStatisticsMapper.countTeamByTime(params);
......@@ -155,14 +162,81 @@ public class DataStatisticsServiceImpl implements IDataStatisticsService {
* @param endDate
* @return
*/
public BaseResponse<List<DataStatisticsVo>> countTeamByOrigin(String startDate, String endDate){
@Override
public BaseResponse<List<DataStatisticsVo>> countTeamByOrigin(Integer cycle, String startDate, String endDate){
Map<String, Object> params = new HashMap<>();
params.put("cycle", cycle);
params.put("startDate", startDate);
params.put("endDate", endDate);
List<DataStatisticsVo> list = dataStatisticsMapper.countTeamByOrigin(params);
return BaseResponse.okData(list);
}
/**
* 项目进展统计
* @return
*/
@Override
public BaseResponse<Map<String, Object>> countEntrustStatus(){
Map<String, Object> map = new HashMap<>();
QueryWrapper<Entrust> entrustQw = new QueryWrapper<>();
Integer sum_counts = entrustService.count(entrustQw);
if(sum_counts == null){
map.put("sumCounts", "0");
map.put("list", null);
}else{
List<DataStatisticsVo> list = dataStatisticsMapper.countEntrustStatus();
map.put("sumCounts", sum_counts);
map.put("list", list);
}
return BaseResponse.okData(map);
}
/**
* 进行中任务数量统计
* @return
*/
@Override
public BaseResponse<Map<String, Object>> countTaskIng(PageQuery pageQuery){
Map<String, Object> map = new HashMap<>();
QueryWrapper<SampleHandle> handleQw = new QueryWrapper<>();
handleQw.eq("status",0).or().eq("status",1);
Integer handle_counts = sampleHandleService.count(handleQw);
map.put("handleCounts", handle_counts);
QueryWrapper<SampleDistribution> distributionQw = new QueryWrapper<>();
distributionQw.eq("status",0).or().eq("status",1);
Integer distribution_counts = sampleDistributionService.count(distributionQw);
map.put("distributionCounts", distribution_counts);
Page<EntrustVo> page = new Page<>(pageQuery.getPageNo(), pageQuery.getPageSize());
IPage<DataStatisticsVo> pagesHandle = dataStatisticsMapper.countHandlePage(page);
map.put("pagesHandle", pagesHandle);
IPage<DataStatisticsVo> pagesDistribution = dataStatisticsMapper.countDistributionPage(page);
map.put("pagesDistribution", pagesDistribution);
return BaseResponse.okData(map);
}
/**
* 正在进行的检测项统计
* @return
*/
public BaseResponse<List<DataStatisticsVo>> countTeamIng(){
List<DataStatisticsVo> list = dataStatisticsMapper.countTeamIng();
return BaseResponse.okData(list);
}
......
......@@ -722,13 +722,27 @@ public class EntrustServiceImpl extends ServiceImpl<EntrustMapper, Entrust> impl
return BaseResponse.errorMsg("参数错误");
}
EntrustVo entrustVo = entrustMapper.getDetail(id);
List<Sample> sampleList = sampleMapper.getSampleList(entrustVo.getId());
QueryWrapper<SampleTmp> sampleTmpQueryWrapper = new QueryWrapper<>();
sampleTmpQueryWrapper.eq("entrust_id", entrustVo.getId());
List<SampleTmp> sampleList = sampleTmpService.list(sampleTmpQueryWrapper);
// List<Sample> sampleList = sampleMapper.getSampleList(entrustVo.getId());
List<SampleTmpVo> sampleVoList = new ArrayList<>();
if (sampleList != null && sampleList.size() > 0) {
for (Sample sample : sampleList) {
for (SampleTmp sample : sampleList) {
SampleTmpVo sampleVo = new SampleTmpVo();
BeanUtils.copyProperties(sample, sampleVo);
sampleVo.setParallelCode(sample.getCementCode());
QueryWrapper<Sample> sampleQueryWrapper = new QueryWrapper<>();
sampleQueryWrapper.eq("entrust_id", entrustVo.getId());
sampleQueryWrapper.eq("sample_id", sample.getId());
List<Sample> sampleList1 = sampleService.list(sampleQueryWrapper);
if(sampleList1 != null && sampleList1.size()>0 ){
Sample sample1 = sampleList1.get(0);
sampleVo.setParallelCode(sample1.getCementCode());
}else{
sampleVo.setParallelCode(null);
}
String teamIds = sample.getTeamIds();
String teamName = "";
if (teamIds != null) {
......
......@@ -12,6 +12,7 @@ import cn.wise.sc.cement.business.util.ExcelUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
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.BeanUtils;
......@@ -64,6 +65,9 @@ public class MethodServiceImpl extends ServiceImpl<MethodMapper, Method> impleme
@Override
public BaseResponse<Method> create(MethodQuery query) {
if(StringUtils.isBlank(query.getName())){
return BaseResponse.errorMsg("检测依据名称不能为空!");
}
if(query.getName().contains("、") || query.getNumber().contains("、") ){
return BaseResponse.errorMsg("检测依据名称和编号不能出现特殊符号");
}
......@@ -73,6 +77,21 @@ public class MethodServiceImpl extends ServiceImpl<MethodMapper, Method> impleme
if (count > 0) {
return BaseResponse.errorMsg("检测依据名称已存在!");
}
QueryWrapper<Method> qw1 = new QueryWrapper<>();
qw1.eq("standard", query.getStandard());
int count1 = methodMapper.selectCount(qw1);
if (count1 > 0) {
return BaseResponse.errorMsg("检测依据标准号已存在!");
}
QueryWrapper<Method> qw2 = new QueryWrapper<>();
qw2.eq("number", query.getNumber());
int count2 = methodMapper.selectCount(qw2);
if (count2 > 0) {
return BaseResponse.errorMsg("检测依据编号已存在!");
}
Method crate = new Method();
BeanUtils.copyProperties(query, crate);
crate.setCreateTime(LocalDateTime.now())
......@@ -83,9 +102,39 @@ public class MethodServiceImpl extends ServiceImpl<MethodMapper, Method> impleme
@Override
public BaseResponse<Method> update(MethodQuery query) {
if(StringUtils.isBlank(query.getName())){
return BaseResponse.errorMsg("检测依据名称不能为空!");
}
if(query.getName().contains("、") || query.getNumber().contains("、") ){
return BaseResponse.errorMsg("检测依据名称和编号不能出现特殊符号");
}
Method oldMethod = methodMapper.selectById(query.getId());
if(oldMethod==null){
return BaseResponse.errorMsg("信息错误");
}
QueryWrapper<Method> qw = new QueryWrapper<>();
qw.eq("name", query.getName());
qw.ne("id", query.getId());
int count = methodMapper.selectCount(qw);
if (count > 0) {
return BaseResponse.errorMsg("检测依据名称已存在!");
}
QueryWrapper<Method> qw1 = new QueryWrapper<>();
qw1.eq("standard", query.getStandard());
qw1.ne("id", query.getId());
int count1 = methodMapper.selectCount(qw1);
if (count1 > 0) {
return BaseResponse.errorMsg("检测依据标准号已存在!");
}
QueryWrapper<Method> qw2 = new QueryWrapper<>();
qw2.eq("number", query.getNumber());
qw.ne("id", query.getId());
int count2 = methodMapper.selectCount(qw2);
if (count2 > 0) {
return BaseResponse.errorMsg("检测依据编号已存在!");
}
Method update = Method.crate(query);
update.setId(query.getId());
this.updateById(update);
......
......@@ -17,6 +17,7 @@ import cn.wise.sc.cement.business.wrapper.page.Query;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
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.slf4j.Logger;
......@@ -75,6 +76,9 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
@Override
@Transactional
public BaseResponse<Project> create(ProjectQuery query) {
if(StringUtils.isBlank(query.getName())){
return BaseResponse.errorMsg("项目名称不可为空!");
}
QueryWrapper<Project> qw = new QueryWrapper<>();
qw.eq("name", query.getName());
int count = projectMapper.selectCount(qw);
......@@ -93,6 +97,9 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
@Override
@Transactional
public BaseResponse<Project> update(ProjectQuery query) {
if(StringUtils.isBlank(query.getName())){
return BaseResponse.errorMsg("项目名称不可为空!");
}
//判断名字是否重复
QueryWrapper<Project> qw = new QueryWrapper<>();
qw.eq("name", query.getName());
......
......@@ -18,6 +18,7 @@ import cn.wise.sc.cement.business.util.ExcelUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.swagger.models.auth.In;
......@@ -84,6 +85,9 @@ public class TeamServiceImpl extends ServiceImpl<TeamMapper, Team> implements IT
@Transactional
public BaseResponse<Team> create(TeamQuery query) {
Team create = new Team();
if (StringUtils.isBlank(query.getName())) {
return BaseResponse.errorMsg("检测项名称不能为空");
}
if (query.getGroupId() == null) {
return BaseResponse.errorMsg("请选择检测组");
}
......@@ -152,6 +156,9 @@ public class TeamServiceImpl extends ServiceImpl<TeamMapper, Team> implements IT
@Override
@Transactional
public BaseResponse<Team> update(TeamQuery query) {
if (StringUtils.isBlank(query.getName())) {
return BaseResponse.errorMsg("检测项名称不能为空");
}
Team update = teamMapper.selectById(query.getId());
if (update == null) {
return BaseResponse.errorMsg("信息错误");
......
......@@ -5,16 +5,10 @@ import cn.wise.sc.cement.business.model.vo.SampleVo;
import freemarker.template.Configuration;
import freemarker.template.Template;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.xwpf.usermodel.XWPFRun;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.io.*;
import java.nio.charset.StandardCharsets;
import java.util.List;
import java.util.Map;
......@@ -95,6 +89,10 @@ public class WordUtil {
template.process(beanParams, out);
FileInputStream in = new FileInputStream(file);
/*HSSFWorkbook xssfWorkbook = new HSSFWorkbook(in);
ByteArrayOutputStream os = new ByteArrayOutputStream();
xssfWorkbook.write(os);
byte[] bytes = os.toByteArray();*/
byte[] buffer = new byte[in.available()];
int i = in.read(buffer);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment