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

bug修复

parent 2aee0f89
package cn.wise.sc.cement.business.controller; package cn.wise.sc.cement.business.controller;
import cn.wise.sc.cement.business.model.BaseResponse; 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 cn.wise.sc.cement.business.service.IDataStatisticsService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
...@@ -46,31 +47,57 @@ public class DataStatisticsController { ...@@ -46,31 +47,57 @@ public class DataStatisticsController {
@ApiOperation(value = "统计概览-检测项数量统计") @ApiOperation(value = "统计概览-检测项数量统计")
@ApiImplicitParams(value = { @ApiImplicitParams(value = {
@ApiImplicitParam(name = "type", value = "类型1:按时间 2:按地区", paramType = "query", dataType = "Integer"), @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 = "startDate", value = "开始日期", paramType = "query", dataType = "String"),
@ApiImplicitParam(name = "endDate", value = "结束日期", paramType = "query", dataType = "String") @ApiImplicitParam(name = "endDate", value = "结束日期", paramType = "query", dataType = "String")
}) })
@GetMapping("/countTeamByTime") @GetMapping("/countTeam")
public BaseResponse countTeamByTime(Integer type, String startDate, String endDate) { public BaseResponse countTeam(Integer type, Integer cycle, String startDate, String endDate) {
try { try {
if(type == 1){ if(type == 1){
return dataStatisticsService.countTeamByTime(cycle, startDate,endDate);
}else if(type == 2){ }else if(type == 2){
return dataStatisticsService.countTeamByOrigin(cycle, startDate,endDate);
}else{ }else{
return BaseResponse.errorMsg("参数错误");
}
} catch (Exception e) {
log.debug("统计概览-检测项数量统计{}", e);
}
return BaseResponse.errorMsg("失败!");
} }
@ApiOperation(value = "统计概览-项目进展统计")
return dataStatisticsService.countTeamByTime(startDate,endDate); @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) { } catch (Exception e) {
log.debug("统计概览-检测项数量统计{}", e); log.debug("统计概览-正在进行的检测项统计{}", e);
} }
return BaseResponse.errorMsg("失败!"); return BaseResponse.errorMsg("失败!");
} }
...@@ -84,5 +111,7 @@ public class DataStatisticsController { ...@@ -84,5 +111,7 @@ public class DataStatisticsController {
} }
package cn.wise.sc.cement.business.controller; package cn.wise.sc.cement.business.controller;
import cn.wise.sc.cement.business.entity.SysGroup; 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.entity.TeamGroup;
import cn.wise.sc.cement.business.model.BaseResponse; import cn.wise.sc.cement.business.model.BaseResponse;
import cn.wise.sc.cement.business.model.PageQuery; import cn.wise.sc.cement.business.model.PageQuery;
import cn.wise.sc.cement.business.model.query.TeamGroupQuery; import cn.wise.sc.cement.business.model.query.TeamGroupQuery;
import cn.wise.sc.cement.business.service.ITeamGroupService; 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.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiImplicitParams;
...@@ -34,6 +38,8 @@ public class TeamGroupController { ...@@ -34,6 +38,8 @@ public class TeamGroupController {
@Autowired @Autowired
private ITeamGroupService teamGroupService; private ITeamGroupService teamGroupService;
@Autowired
private ITeamService teamService;
@ApiOperation(value = "检测组分页列表") @ApiOperation(value = "检测组分页列表")
@ApiImplicitParams(value = { @ApiImplicitParams(value = {
...@@ -102,6 +108,19 @@ public class TeamGroupController { ...@@ -102,6 +108,19 @@ public class TeamGroupController {
@PostMapping("/delete/{id}") @PostMapping("/delete/{id}")
public BaseResponse delete(@PathVariable Integer id) { public BaseResponse delete(@PathVariable Integer id) {
try { 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); teamGroupService.removeById(id);
return BaseResponse.okData("删除成功"); return BaseResponse.okData("删除成功");
} catch (Exception e) { } catch (Exception e) {
......
...@@ -26,4 +26,11 @@ public interface DataStatisticsMapper { ...@@ -26,4 +26,11 @@ public interface DataStatisticsMapper {
List<DataStatisticsVo> countTeamByOrigin(@Param("params") Map<String, Object> params); 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> { ...@@ -71,4 +71,7 @@ public interface SampleMapper extends BaseMapper<Sample> {
} }
...@@ -6,6 +6,15 @@ ...@@ -6,6 +6,15 @@
SELECT DATE_FORMAT(sd.create_time,'%Y-%m') as name, count(sd.id) as value SELECT DATE_FORMAT(sd.create_time,'%Y-%m') as name, count(sd.id) as value
FROM sample_distribution sd FROM sample_distribution sd
where sd.finish_time is not null 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 != ''"> <if test="params.startDate != null and params.startDate != ''">
and DATE(sd.create_time) &gt;= #{params.startDate} and DATE(sd.create_time) &gt;= #{params.startDate}
</if> </if>
...@@ -20,8 +29,17 @@ ...@@ -20,8 +29,17 @@
FROM sample_distribution sd FROM sample_distribution sd
left join sample s on s.id = sd.sample_id left join sample s on s.id = sd.sample_id
where sd.finish_time is not null where sd.finish_time is not null
<if test="params.startDate != null and params.startDate != ''"> <if test="params.cycle == 1 ">
and DATE(sd.create_time) &gt;= #{params.startDate} 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>
<if test="params.endDate != null and params.endDate != ''"> <if test="params.endDate != null and params.endDate != ''">
and DATE(sd.create_time) &lt;= #{params.endDate} and DATE(sd.create_time) &lt;= #{params.endDate}
...@@ -30,6 +48,52 @@ ...@@ -30,6 +48,52 @@
</select> </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> </mapper>
...@@ -26,9 +26,14 @@ public interface IDataStatisticsService { ...@@ -26,9 +26,14 @@ public interface IDataStatisticsService {
BaseResponse<Map<String, String>> countOverview(); 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 ...@@ -77,6 +77,9 @@ public class ClientServiceImpl extends ServiceImpl<ClientMapper, Client> impleme
if (count > 0) { if (count > 0) {
return BaseResponse.errorMsg("单位名称已存在!"); return BaseResponse.errorMsg("单位名称已存在!");
} }
if(query.getPrincipal().length() > 20 ){
return BaseResponse.errorMsg("联系人姓名过长!");
}
if(query.getPrincipalPhone().length() > 15 ){ if(query.getPrincipalPhone().length() > 15 ){
return BaseResponse.errorMsg("联系人电话过长!"); return BaseResponse.errorMsg("联系人电话过长!");
} }
...@@ -100,6 +103,12 @@ public class ClientServiceImpl extends ServiceImpl<ClientMapper, Client> impleme ...@@ -100,6 +103,12 @@ public class ClientServiceImpl extends ServiceImpl<ClientMapper, Client> impleme
if (count > 0) { if (count > 0) {
return BaseResponse.errorMsg("单位名称已存在!"); return BaseResponse.errorMsg("单位名称已存在!");
} }
if(query.getPrincipal().length() > 20 ){
return BaseResponse.errorMsg("联系人姓名过长!");
}
if(query.getPrincipalPhone().length() > 15 ){
return BaseResponse.errorMsg("联系人电话过长!");
}
Client update = new Client(); Client update = new Client();
BeanUtils.copyProperties(query, update); BeanUtils.copyProperties(query, update);
update.setId(query.getId()); update.setId(query.getId());
......
...@@ -19,6 +19,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage; ...@@ -19,6 +19,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.swagger.models.auth.In;
import lombok.Data; import lombok.Data;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
...@@ -62,6 +63,10 @@ public class DataStatisticsServiceImpl implements IDataStatisticsService { ...@@ -62,6 +63,10 @@ public class DataStatisticsServiceImpl implements IDataStatisticsService {
private IEntrustService entrustService; private IEntrustService entrustService;
@Autowired @Autowired
private CommonServiceImpl commonService; private CommonServiceImpl commonService;
@Autowired
private ISampleHandleService sampleHandleService;
@Autowired
private ISampleDistributionService sampleDistributionService;
/** /**
...@@ -98,12 +103,13 @@ public class DataStatisticsServiceImpl implements IDataStatisticsService { ...@@ -98,12 +103,13 @@ public class DataStatisticsServiceImpl implements IDataStatisticsService {
/** /**
* 检测项数量统计-按时间 * 检测项数量统计-按时间
* @param cycle
* @param startDate * @param startDate
* @param endDate * @param endDate
* @return * @return
*/ */
@Override @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<>(); Map<String, String> dateMap = new HashMap<>();
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM"); SimpleDateFormat format = new SimpleDateFormat("yyyy-MM");
...@@ -130,6 +136,7 @@ public class DataStatisticsServiceImpl implements IDataStatisticsService { ...@@ -130,6 +136,7 @@ public class DataStatisticsServiceImpl implements IDataStatisticsService {
} }
Map<String, Object> params = new HashMap<>(); Map<String, Object> params = new HashMap<>();
params.put("cycle", cycle);
params.put("startDate", startDate); params.put("startDate", startDate);
params.put("endDate", endDate); params.put("endDate", endDate);
List<DataStatisticsVo> list = dataStatisticsMapper.countTeamByTime(params); List<DataStatisticsVo> list = dataStatisticsMapper.countTeamByTime(params);
...@@ -155,14 +162,81 @@ public class DataStatisticsServiceImpl implements IDataStatisticsService { ...@@ -155,14 +162,81 @@ public class DataStatisticsServiceImpl implements IDataStatisticsService {
* @param endDate * @param endDate
* @return * @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<>(); Map<String, Object> params = new HashMap<>();
params.put("cycle", cycle);
params.put("startDate", startDate); params.put("startDate", startDate);
params.put("endDate", endDate); params.put("endDate", endDate);
List<DataStatisticsVo> list = dataStatisticsMapper.countTeamByOrigin(params); List<DataStatisticsVo> list = dataStatisticsMapper.countTeamByOrigin(params);
return BaseResponse.okData(list); 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 ...@@ -722,13 +722,27 @@ public class EntrustServiceImpl extends ServiceImpl<EntrustMapper, Entrust> impl
return BaseResponse.errorMsg("参数错误"); return BaseResponse.errorMsg("参数错误");
} }
EntrustVo entrustVo = entrustMapper.getDetail(id); 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<>(); List<SampleTmpVo> sampleVoList = new ArrayList<>();
if (sampleList != null && sampleList.size() > 0) { if (sampleList != null && sampleList.size() > 0) {
for (Sample sample : sampleList) { for (SampleTmp sample : sampleList) {
SampleTmpVo sampleVo = new SampleTmpVo(); SampleTmpVo sampleVo = new SampleTmpVo();
BeanUtils.copyProperties(sample, sampleVo); 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 teamIds = sample.getTeamIds();
String teamName = ""; String teamName = "";
if (teamIds != null) { if (teamIds != null) {
......
...@@ -12,6 +12,7 @@ import cn.wise.sc.cement.business.util.ExcelUtil; ...@@ -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.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; 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.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
...@@ -64,6 +65,9 @@ public class MethodServiceImpl extends ServiceImpl<MethodMapper, Method> impleme ...@@ -64,6 +65,9 @@ public class MethodServiceImpl extends ServiceImpl<MethodMapper, Method> impleme
@Override @Override
public BaseResponse<Method> create(MethodQuery query) { public BaseResponse<Method> create(MethodQuery query) {
if(StringUtils.isBlank(query.getName())){
return BaseResponse.errorMsg("检测依据名称不能为空!");
}
if(query.getName().contains("、") || query.getNumber().contains("、") ){ if(query.getName().contains("、") || query.getNumber().contains("、") ){
return BaseResponse.errorMsg("检测依据名称和编号不能出现特殊符号"); return BaseResponse.errorMsg("检测依据名称和编号不能出现特殊符号");
} }
...@@ -73,6 +77,21 @@ public class MethodServiceImpl extends ServiceImpl<MethodMapper, Method> impleme ...@@ -73,6 +77,21 @@ public class MethodServiceImpl extends ServiceImpl<MethodMapper, Method> impleme
if (count > 0) { if (count > 0) {
return BaseResponse.errorMsg("检测依据名称已存在!"); 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(); Method crate = new Method();
BeanUtils.copyProperties(query, crate); BeanUtils.copyProperties(query, crate);
crate.setCreateTime(LocalDateTime.now()) crate.setCreateTime(LocalDateTime.now())
...@@ -83,9 +102,39 @@ public class MethodServiceImpl extends ServiceImpl<MethodMapper, Method> impleme ...@@ -83,9 +102,39 @@ public class MethodServiceImpl extends ServiceImpl<MethodMapper, Method> impleme
@Override @Override
public BaseResponse<Method> update(MethodQuery query) { public BaseResponse<Method> update(MethodQuery query) {
if(StringUtils.isBlank(query.getName())){
return BaseResponse.errorMsg("检测依据名称不能为空!");
}
if(query.getName().contains("、") || query.getNumber().contains("、") ){ if(query.getName().contains("、") || query.getNumber().contains("、") ){
return BaseResponse.errorMsg("检测依据名称和编号不能出现特殊符号"); 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); Method update = Method.crate(query);
update.setId(query.getId()); update.setId(query.getId());
this.updateById(update); this.updateById(update);
......
...@@ -17,6 +17,7 @@ import cn.wise.sc.cement.business.wrapper.page.Query; ...@@ -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.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; 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.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.slf4j.Logger; import org.slf4j.Logger;
...@@ -75,6 +76,9 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl ...@@ -75,6 +76,9 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
@Override @Override
@Transactional @Transactional
public BaseResponse<Project> create(ProjectQuery query) { public BaseResponse<Project> create(ProjectQuery query) {
if(StringUtils.isBlank(query.getName())){
return BaseResponse.errorMsg("项目名称不可为空!");
}
QueryWrapper<Project> qw = new QueryWrapper<>(); QueryWrapper<Project> qw = new QueryWrapper<>();
qw.eq("name", query.getName()); qw.eq("name", query.getName());
int count = projectMapper.selectCount(qw); int count = projectMapper.selectCount(qw);
...@@ -93,6 +97,9 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl ...@@ -93,6 +97,9 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
@Override @Override
@Transactional @Transactional
public BaseResponse<Project> update(ProjectQuery query) { public BaseResponse<Project> update(ProjectQuery query) {
if(StringUtils.isBlank(query.getName())){
return BaseResponse.errorMsg("项目名称不可为空!");
}
//判断名字是否重复 //判断名字是否重复
QueryWrapper<Project> qw = new QueryWrapper<>(); QueryWrapper<Project> qw = new QueryWrapper<>();
qw.eq("name", query.getName()); qw.eq("name", query.getName());
......
...@@ -18,6 +18,7 @@ import cn.wise.sc.cement.business.util.ExcelUtil; ...@@ -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.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; 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.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.swagger.models.auth.In; import io.swagger.models.auth.In;
...@@ -84,6 +85,9 @@ public class TeamServiceImpl extends ServiceImpl<TeamMapper, Team> implements IT ...@@ -84,6 +85,9 @@ public class TeamServiceImpl extends ServiceImpl<TeamMapper, Team> implements IT
@Transactional @Transactional
public BaseResponse<Team> create(TeamQuery query) { public BaseResponse<Team> create(TeamQuery query) {
Team create = new Team(); Team create = new Team();
if (StringUtils.isBlank(query.getName())) {
return BaseResponse.errorMsg("检测项名称不能为空");
}
if (query.getGroupId() == null) { if (query.getGroupId() == null) {
return BaseResponse.errorMsg("请选择检测组"); return BaseResponse.errorMsg("请选择检测组");
} }
...@@ -152,6 +156,9 @@ public class TeamServiceImpl extends ServiceImpl<TeamMapper, Team> implements IT ...@@ -152,6 +156,9 @@ public class TeamServiceImpl extends ServiceImpl<TeamMapper, Team> implements IT
@Override @Override
@Transactional @Transactional
public BaseResponse<Team> update(TeamQuery query) { public BaseResponse<Team> update(TeamQuery query) {
if (StringUtils.isBlank(query.getName())) {
return BaseResponse.errorMsg("检测项名称不能为空");
}
Team update = teamMapper.selectById(query.getId()); Team update = teamMapper.selectById(query.getId());
if (update == null) { if (update == null) {
return BaseResponse.errorMsg("信息错误"); return BaseResponse.errorMsg("信息错误");
......
...@@ -5,16 +5,10 @@ import cn.wise.sc.cement.business.model.vo.SampleVo; ...@@ -5,16 +5,10 @@ import cn.wise.sc.cement.business.model.vo.SampleVo;
import freemarker.template.Configuration; import freemarker.template.Configuration;
import freemarker.template.Template; import freemarker.template.Template;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.poi.xwpf.usermodel.XWPFRun;
import javax.servlet.ServletOutputStream; import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.File; import java.io.*;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.nio.charset.StandardCharsets; import java.nio.charset.StandardCharsets;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -95,6 +89,10 @@ public class WordUtil { ...@@ -95,6 +89,10 @@ public class WordUtil {
template.process(beanParams, out); template.process(beanParams, out);
FileInputStream in = new FileInputStream(file); 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()]; byte[] buffer = new byte[in.available()];
int i = in.read(buffer); 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