Commit 82d46423 authored by renchao's avatar renchao

送验单模块代码编写

parent 67dcf564
package cn.wise.sc.acquisition.business.controller;
import cn.wise.sc.acquisition.business.entity.TSampleList;
import cn.wise.sc.acquisition.business.model.query.TSampleListQuery;
import cn.wise.sc.acquisition.business.service.impl.TSampleListServiceImpl;
import cn.wise.sc.acquisition.business.wrapper.WrapMapper;
import cn.wise.sc.acquisition.business.wrapper.Wrapper;
import cn.wise.sc.acquisition.business.wrapper.page.Query;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.api.R;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
......@@ -37,9 +32,24 @@ public class TSampleListController {
* @param tSampleListQuery
* @return
*/
@RequestMapping(value = "/listAllByQuery", method = RequestMethod.GET)
public R listAllByQuery(TSampleListQuery tSampleListQuery, Query query) {
return R.ok(tSampleListService.listAllByQuery(tSampleListQuery,query));
@RequestMapping(value = "/getPage", method = RequestMethod.GET)
public R getPage(TSampleListQuery tSampleListQuery, Query query) {
return R.ok(tSampleListService.getPage(tSampleListQuery,query));
}
@RequestMapping(value = "/updateByHolesID", method = RequestMethod.POST)
public R updateByHolesID(TSampleListQuery tSampleListQuery) {
return R.ok(tSampleListService.updateByHolesID(tSampleListQuery));
}
@RequestMapping(value = "/insertSampleList", method = RequestMethod.POST)
public R insertSampleList(TSampleListQuery tSampleListQuery) {
return R.ok(tSampleListService.insertSampleList(tSampleListQuery));
}
@RequestMapping(value = "/deleteByHolesID", method = RequestMethod.POST)
public R deleteByHolesID(TSampleListQuery tSampleListQuery) {
return R.ok(tSampleListService.deleteByHolesID(tSampleListQuery));
}
}
......
......@@ -92,5 +92,15 @@ public class TSampleList implements Serializable {
@TableField("Bz")
private String Bz;
/**
* 记录对象
*/
@TableField("RecordName")
private String RecordName;
/**
* 记录形式
*/
@TableField("RecordCode")
private byte[] RecordCode;
}
......@@ -97,4 +97,15 @@ public class TSampleListQuery implements Serializable {
private String Bz;
/**
* 记录对象
*/
@ApiModelProperty("记录对象")
private String RecordName;
/**
* 记录形式
*/
@ApiModelProperty("记录形式")
private byte[] RecordCode;
}
......@@ -9,12 +9,19 @@ import com.baomidou.mybatisplus.extension.service.IService;
/**
* <p>
* 服务类
* 服务类
* </p>
*
* @author ztw
* @since 2021-04-22
*/
public interface ITSampleListService extends IService<TSampleList> {
R listAllByQuery(TSampleListQuery tSampleListQuery, Query query);
R getPage(TSampleListQuery tSampleListQuery, Query query);
R updateByHolesID(TSampleListQuery tSampleListQuery);
R deleteByHolesID(TSampleListQuery tSampleListQuery);
R insertSampleList(TSampleListQuery tSampleListQuery);
}
......@@ -6,14 +6,20 @@ import cn.wise.sc.acquisition.business.mapper.TSampleListMapper;
import cn.wise.sc.acquisition.business.model.query.TSampleListQuery;
import cn.wise.sc.acquisition.business.service.ITSampleListService;
import cn.wise.sc.acquisition.business.wrapper.page.Query;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.api.R;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Optional;
/**
* <p>
......@@ -24,10 +30,12 @@ import java.util.List;
* @since 2021-04-22
*/
@Service
@Slf4j
public class TSampleListServiceImpl extends ServiceImpl<TSampleListMapper, TSampleList> implements ITSampleListService {
@Override
public R listAllByQuery(TSampleListQuery tSampleListQuery, Query query) {
public R getPage(TSampleListQuery tSampleListQuery, Query query) {
log.info(JSON.toJSONString(tSampleListQuery));
//参数校验
//分页
Page<TSampleList> page = new Page<>(query.getPageNum(), query.getPageSize());
......@@ -41,4 +49,79 @@ public class TSampleListServiceImpl extends ServiceImpl<TSampleListMapper, TSamp
return R.ok(tSampleListPage);
}
@Override
@Transactional
public R updateByHolesID(TSampleListQuery tSampleListQuery) {
log.info(JSON.toJSONString(tSampleListQuery));
//参数校验
Rcode.NOT_PARAM.assertNotNull(tSampleListQuery.getHolesID());
//条件封装
TSampleList tSampleList = new TSampleList();
BeanUtils.copyProperties(tSampleListQuery, tSampleList);
QueryWrapper<TSampleList> queryWrapper = new QueryWrapper<>();
queryWrapper.eq("HolesID", tSampleListQuery.getHolesID());
//修改
int update = baseMapper.update(tSampleList, queryWrapper);
if (update > 0) {
return R.ok("修改成功");
} else {
log.info(JSON.toJSONString(tSampleList));
return R.ok("修改失败");
}
}
@Override
@Transactional
public R insertSampleList(TSampleListQuery tSampleListQuery) {
log.info(JSON.toJSONString(tSampleListQuery));
//参数校验
Rcode.NOT_PARAM.assertNotNull(tSampleListQuery.getHolesID());
Rcode.NOT_PARAM.assertNotNull(tSampleListQuery.getYh());
Rcode.NOT_PARAM.assertNotNull(tSampleListQuery.getStart());
Rcode.NOT_PARAM.assertNotNull(tSampleListQuery.getEndTo());
Rcode.NOT_PARAM.assertNotNull(tSampleListQuery.getRecordName());
Rcode.NOT_PARAM.assertNotNull(tSampleListQuery.getRecordCode());
Rcode.NOT_PARAM.assertNotNull(tSampleListQuery.getBz());
Rcode.NOT_PARAM.assertNotNull(tSampleListQuery.getSyr());
Rcode.NOT_PARAM.assertNotNull(tSampleListQuery.getQRCode());
//条件封装
TSampleList tSampleList = new TSampleList();
BeanUtils.copyProperties(tSampleListQuery, tSampleList);
//若时间送样为空,创建当前时间
Optional<LocalDateTime> ofNullable = Optional.ofNullable(tSampleList.getSyrq());
if (!ofNullable.isPresent()) {
tSampleList.setSyrq(LocalDateTime.now());
}
//修改
log.info(JSON.toJSONString(tSampleList));
int insert = baseMapper.insert(tSampleList);
if (insert > 0) {
return R.ok("增加成功");
} else {
log.info(JSON.toJSONString(tSampleList));
return R.ok("增加失败");
}
}
@Override
@Transactional
public R deleteByHolesID(TSampleListQuery tSampleListQuery) {
log.info(JSON.toJSONString(tSampleListQuery));
//参数校验
Rcode.NOT_PARAM.assertNotNull(tSampleListQuery.getHolesID());
//删除
int delete = baseMapper.delete(new QueryWrapper<TSampleList>().eq("HolesID", tSampleListQuery.getHolesID()));
if (delete > 0) {
return R.ok("删除成功");
} else {
return R.ok("删除失败");
}
}
}
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.wise.sc.acquisition.business.mapper.TEquipmentAccountMapper">
</mapper>
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
cn.wise.im.common.exception.handler.UnifiedExceptionHandler,\
cn.wise.im.common.currency.i18n.UnifiedMessageSource
spring:
mvc:
throw-exception-if-no-handler-found: true
resources:
add-mappings: false
\ No newline at end of file
......@@ -57,7 +57,7 @@ public class GeneratorApplication {
GlobalConfig gc = new GlobalConfig();
String projectPath = System.getProperty("user.dir");
gc.setOutputDir(projectPath + "\\acquisition-business\\src\\main\\java");
gc.setAuthor("ztw");
gc.setAuthor("renchao");
gc.setOpen(false);
// gc.setSwagger2(true); 实体属性 Swagger2 注解
mpg.setGlobalConfig(gc);
......
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