|
|
@@ -10,89 +10,113 @@ import me.zhengjie.base.AppResultData;
|
|
|
import me.zhengjie.base.util.BeanCopyUtils;
|
|
|
import me.zhengjie.base.ResultCode;
|
|
|
import me.zhengjie.dao.mybatis.entity.NotarizationNoEntity;
|
|
|
+import me.zhengjie.dao.mybatis.entity.NotaryOfficeEntity;
|
|
|
import me.zhengjie.application.admin.controller.vo.NotarizationNoReq;
|
|
|
import me.zhengjie.dao.mybatis.mapper.NotarizationNoMapper;
|
|
|
+import me.zhengjie.dao.mybatis.mapper.NotaryOfficeMapper;
|
|
|
import me.zhengjie.application.admin.service.NotarizationNoService;
|
|
|
+import me.zhengjie.application.admin.service.NotaryOfficeService;
|
|
|
+
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
+import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
* 公证处 服务实现类
|
|
|
*/
|
|
|
@Service
|
|
|
@Slf4j
|
|
|
-public class NotarizationNoServiceImpl extends ServiceImpl<NotarizationNoMapper, NotarizationNoEntity> implements NotarizationNoService {
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private NotarizationNoMapper notarizationNoMapper;
|
|
|
+public class NotarizationNoServiceImpl extends ServiceImpl<NotarizationNoMapper, NotarizationNoEntity>
|
|
|
+ implements NotarizationNoService {
|
|
|
|
|
|
- @Override
|
|
|
- public AppBaseResponse<List<NotarizationNoReq>> query(NotarizationNoReq req){
|
|
|
- AppBaseResponse<List<NotarizationNoReq>> response = new AppBaseResponse<>();
|
|
|
- List<NotarizationNoReq> result = new ArrayList<>();
|
|
|
+ @Autowired
|
|
|
+ private NotarizationNoMapper notarizationNoMapper;
|
|
|
+ @Autowired
|
|
|
+ private NotaryOfficeService notaryOfficeService;
|
|
|
|
|
|
- IPage<NotarizationNoEntity> page = new Page<>(req.getIndex(),req.getSize());
|
|
|
- QueryWrapper<NotarizationNoEntity> qw = new QueryWrapper<>();
|
|
|
- if (!StringUtils.isEmpty(req.getNotaryOfficeId())){
|
|
|
- qw.eq("notary_office_id", req.getNotaryOfficeId());
|
|
|
- }
|
|
|
- qw.eq("no_status",1);
|
|
|
- page = notarizationNoMapper.selectPage(page,qw);
|
|
|
- List<NotarizationNoEntity> list = page.getRecords();
|
|
|
- List<NotarizationNoReq> res = BeanCopyUtils.convertList2List(list, NotarizationNoReq.class);
|
|
|
- for(NotarizationNoReq temp:res){
|
|
|
- int currentNum = temp.getCurrentNum() == null ? temp.getBeginNum() - 1:temp.getCurrentNum();
|
|
|
- int totalNum = temp.getEndNum() - temp.getBeginNum() + 1 ;
|
|
|
- int usedNum = currentNum - temp.getBeginNum() + 1;
|
|
|
- int leftNum = totalNum - usedNum;
|
|
|
- temp.setTotalNum(totalNum);
|
|
|
- temp.setUsedNum(usedNum);
|
|
|
- temp.setLeftNum(leftNum);
|
|
|
- }
|
|
|
- response.setData(new AppResultData<List<NotarizationNoReq>>(res,new me.zhengjie.base.Page(req.getIndex(),req.getSize(),(int)page.getTotal())));
|
|
|
- return response;
|
|
|
- }
|
|
|
+ @Override
|
|
|
+ public AppBaseResponse<List<NotarizationNoReq>> query(NotarizationNoReq req) {
|
|
|
+ AppBaseResponse<List<NotarizationNoReq>> response = new AppBaseResponse<>();
|
|
|
+ IPage<NotarizationNoEntity> page = new Page<>(req.getIndex(), req.getSize());
|
|
|
+ QueryWrapper<NotarizationNoEntity> qw = new QueryWrapper<>();
|
|
|
+ if (!StringUtils.isEmpty(req.getNotaryOfficeId())) {
|
|
|
+ qw.eq("notary_office_id", req.getNotaryOfficeId());
|
|
|
+ }
|
|
|
+ qw.eq("no_status", 1);
|
|
|
+
|
|
|
+ if (!StringUtils.isEmpty(req.getStartDate())) {
|
|
|
+ qw.ge("create_time", req.getStartDate());
|
|
|
+ }
|
|
|
+ if (!StringUtils.isEmpty(req.getEndDate())) {
|
|
|
+ qw.le("create_time", req.getEndDate());
|
|
|
+ }
|
|
|
+
|
|
|
+ page = notarizationNoMapper.selectPage(page, qw);
|
|
|
+ List<NotarizationNoEntity> list = page.getRecords();
|
|
|
+ List<NotarizationNoReq> res = BeanCopyUtils.convertList2List(list, NotarizationNoReq.class);
|
|
|
+ // 增加公证处名称
|
|
|
+ List<NotaryOfficeEntity> notaryOffice = notaryOfficeService.list();
|
|
|
+ Map<Integer, String> map = new HashMap<>();
|
|
|
+ for (NotaryOfficeEntity entity : notaryOffice) {
|
|
|
+ map.put(entity.getId(), entity.getName());
|
|
|
+ }
|
|
|
+ for (NotarizationNoReq temp : res) {
|
|
|
+ int currentNum = temp.getCurrentNum() == null ? temp.getBeginNum() - 1 : temp.getCurrentNum();
|
|
|
+ int totalNum = temp.getEndNum() - temp.getBeginNum() + 1;
|
|
|
+ int usedNum = currentNum - temp.getBeginNum() + 1;
|
|
|
+ int leftNum = totalNum - usedNum;
|
|
|
+ temp.setTotalNum(totalNum);
|
|
|
+ temp.setUsedNum(usedNum);
|
|
|
+ temp.setLeftNum(leftNum);
|
|
|
+ temp.setNotaryName(map.get(temp.getNotaryOfficeId()));
|
|
|
+ }
|
|
|
+ response.setData(new AppResultData<List<NotarizationNoReq>>(res,
|
|
|
+ new me.zhengjie.base.Page(req.getIndex(), req.getSize(), (int) page.getTotal())));
|
|
|
+ return response;
|
|
|
+ }
|
|
|
|
|
|
- @Override
|
|
|
- public AppBaseResponse create(NotarizationNoReq req) {
|
|
|
- AppBaseResponse response = new AppBaseResponse();
|
|
|
- NotarizationNoEntity notarizationNoEntity = NotarizationNoEntity.builder().notaryOfficeId(req.getNotaryOfficeId()).currentNum(0)
|
|
|
- .beginNum(req.getBeginNum()).endNum(req.getEndNum()).noStatus(1).createTime(new Date()).usedYear(req.getUsedYear()).build();
|
|
|
- int insertNum = notarizationNoMapper.insert(notarizationNoEntity);
|
|
|
- if (insertNum == 0){
|
|
|
- response.fail(ResultCode.DATA_INSERT_ERROR);
|
|
|
- }
|
|
|
- return response;
|
|
|
- }
|
|
|
+ @Override
|
|
|
+ public AppBaseResponse create(NotarizationNoReq req) {
|
|
|
+ AppBaseResponse response = new AppBaseResponse();
|
|
|
+ NotarizationNoEntity notarizationNoEntity = NotarizationNoEntity.builder()
|
|
|
+ .notaryOfficeId(req.getNotaryOfficeId()).currentNum(0).beginNum(req.getBeginNum())
|
|
|
+ .endNum(req.getEndNum()).noStatus(1).createTime(new Date()).usedYear(req.getUsedYear()).build();
|
|
|
+ int insertNum = notarizationNoMapper.insert(notarizationNoEntity);
|
|
|
+ if (insertNum == 0) {
|
|
|
+ response.fail(ResultCode.DATA_INSERT_ERROR);
|
|
|
+ }
|
|
|
+ return response;
|
|
|
+ }
|
|
|
|
|
|
- @Override
|
|
|
- public AppBaseResponse update(NotarizationNoReq req) {
|
|
|
- AppBaseResponse response = new AppBaseResponse();
|
|
|
- NotarizationNoEntity entity = NotarizationNoEntity.builder().notaryOfficeId(req.getNotaryOfficeId())
|
|
|
- .id(req.getId()).beginNum(req.getBeginNum())
|
|
|
- .endNum(req.getEndNum()).noStatus(req.getNoStaus()).usedYear(req.getUsedYear()).build();
|
|
|
- int update = notarizationNoMapper.updateById(entity);
|
|
|
- if (update==0){
|
|
|
- response.fail(ResultCode.DATA_UPDATE_ERROR);
|
|
|
- }
|
|
|
- return response;
|
|
|
- }
|
|
|
+ @Override
|
|
|
+ public AppBaseResponse update(NotarizationNoReq req) {
|
|
|
+ AppBaseResponse response = new AppBaseResponse();
|
|
|
+ NotarizationNoEntity entity = NotarizationNoEntity.builder().notaryOfficeId(req.getNotaryOfficeId())
|
|
|
+ .id(req.getId()).beginNum(req.getBeginNum()).endNum(req.getEndNum()).noStatus(req.getNoStaus())
|
|
|
+ .usedYear(req.getUsedYear()).build();
|
|
|
+ int update = notarizationNoMapper.updateById(entity);
|
|
|
+ if (update == 0) {
|
|
|
+ response.fail(ResultCode.DATA_UPDATE_ERROR);
|
|
|
+ }
|
|
|
+ return response;
|
|
|
+ }
|
|
|
|
|
|
- @Override
|
|
|
- public AppBaseResponse unUsed(NotarizationNoReq req) {
|
|
|
- AppBaseResponse response = new AppBaseResponse();
|
|
|
- NotarizationNoEntity notarizationNoEntity = new NotarizationNoEntity();
|
|
|
- notarizationNoEntity.setId(req.getId());
|
|
|
- notarizationNoEntity.setNoStatus(0);
|
|
|
- int update = notarizationNoMapper.updateById(notarizationNoEntity);
|
|
|
- if (update==0){
|
|
|
- response.fail(ResultCode.DATA_UPDATE_ERROR);
|
|
|
- }
|
|
|
- return response;
|
|
|
- }
|
|
|
+ @Override
|
|
|
+ public AppBaseResponse unUsed(NotarizationNoReq req) {
|
|
|
+ AppBaseResponse response = new AppBaseResponse();
|
|
|
+ NotarizationNoEntity notarizationNoEntity = new NotarizationNoEntity();
|
|
|
+ notarizationNoEntity.setId(req.getId());
|
|
|
+ notarizationNoEntity.setNoStatus(0);
|
|
|
+ int update = notarizationNoMapper.updateById(notarizationNoEntity);
|
|
|
+ if (update == 0) {
|
|
|
+ response.fail(ResultCode.DATA_UPDATE_ERROR);
|
|
|
+ }
|
|
|
+ return response;
|
|
|
+ }
|
|
|
}
|