Commit 44b35895 authored by zuoyh's avatar zuoyh

股東表插入、查詢

parent 3465cb2a
......@@ -55,6 +55,9 @@ public class AppShareholderDetailDTO {
@ApiModelProperty("公司集合")
private Map<Integer, String> companyMap;
@ApiModelProperty("公司数组")
private String[] companyList;
@ApiModelProperty("股东身份ID")
private Integer positionId;
......
......@@ -13,6 +13,7 @@ import com.github.wxiaoqi.security.common.exception.BaseException;
import com.github.wxiaoqi.security.common.msg.ObjectRestResponse;
import com.github.wxiaoqi.security.common.util.process.ResultCode;
import com.github.wxiaoqi.security.common.vo.PageDataVO;
import com.xxfc.platform.vehicle.common.RestResponse;
import com.xxfc.platform.vehicle.entity.BranchCompany;
import com.xxfc.platform.vehicle.feign.VehicleFeign;
import lombok.extern.slf4j.Slf4j;
......@@ -26,13 +27,12 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import tk.mybatis.mapper.entity.Example;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.concurrent.CountDownLatch;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@Slf4j
@Transactional
......@@ -54,6 +54,7 @@ public class AppShareholderDetailBiz extends BaseBiz<AppShareholderDetailMapper,
@Autowired
private ThreadPoolTaskExecutor threadPoolTaskExecutor;
public static int HEADQUARTERS_SHAREHOLDER = 1;
public static int BRANCH_HEADQUARTERS_SHAREHOLDER = 2;
......@@ -76,21 +77,24 @@ public class AppShareholderDetailBiz extends BaseBiz<AppShareholderDetailMapper,
public ObjectRestResponse add(AppShareholderDetailDTO appShareholderDetailDTO, Integer updUserId) {
if (appShareholderDetailDTO == null || StringUtils.isBlank(appShareholderDetailDTO.getName()) || StringUtils.isBlank(appShareholderDetailDTO.getPhone()) ||
appShareholderDetailDTO.getCompanyMap().size() == 0) {
appShareholderDetailDTO.getCompanyList() == null) {
return ObjectRestResponse.createFailedResult(ResultCode.NOTEXIST_CODE, "参数不能为空");
}
AppShareholderDetail appShareholderDetail = new AppShareholderDetail();
Map<Integer, String> companyMap = appShareholderDetailDTO.getCompanyMap();
String[] companyArray = appShareholderDetailDTO.getCompanyList();
for (Integer companyId : companyMap.keySet()) {
String companyName = companyMap.get(companyId);
if (!(companyId != null && companyId > 0 && StringUtils.isNotBlank(companyName)))
for (String company : companyArray) {
Integer companyId = Integer.valueOf(company);
if (!(companyId != null && companyId > 0))
return ObjectRestResponse.createFailedResult(ResultCode.NOTEXIST_CODE, "分公司不存在");
BranchCompany branchCompany = vehicleFeign.companyId(companyName);
if (branchCompany == null) {
RestResponse<BranchCompany> branchCompany = vehicleFeign.get(companyId);
if (branchCompany.getData() == null) {
return ObjectRestResponse.createFailedResult(ResultCode.NOTEXIST_CODE, "分公司不存在");
}
Integer positionId = branchCompany.getId().equals(1) ? HEADQUARTERS_SHAREHOLDER : BRANCH_HEADQUARTERS_SHAREHOLDER;
appShareholderDetailDTO.setCompanyId(companyId);
appShareholderDetailDTO.setCompanyName(branchCompany.getData().getName());
Integer positionId = branchCompany.getData().getId().equals(1) ? HEADQUARTERS_SHAREHOLDER : BRANCH_HEADQUARTERS_SHAREHOLDER;
//用户表更改其身份
Integer userId = 0;
//登陆表查询用户手机号
......@@ -109,13 +113,7 @@ public class AppShareholderDetailBiz extends BaseBiz<AppShareholderDetailMapper,
BeanUtils.copyProperties(appShareholderDetailDTO, appShareholderDetail);
appShareholderDetail.setPositionId(positionId);
appShareholderDetailDTO.setUserId(userId);
//插入
if (id == null || id == 0) {
insertSelective(appShareholderDetail);
//編輯
} else {
updateSelectiveById(appShareholderDetail);
}
insertSelective(appShareholderDetail);
}
return ObjectRestResponse.succ();
}
......@@ -129,19 +127,21 @@ public class AppShareholderDetailBiz extends BaseBiz<AppShareholderDetailMapper,
PageDataVO<AppShareholderDetailVo> dataVO = new PageDataVO<>();
Example example = new Example(AppShareholderDetail.class);
Example.Criteria criteria = example.createCriteria();
if (StringUtils.isNotEmpty(appShareholderDetailFindDTO.getName())) {
example.createCriteria().andEqualTo("name", String.format("%%%s%%", appShareholderDetailFindDTO.getName().trim()));
criteria.andLike("name", String.format("%%%s%%", appShareholderDetailFindDTO.getName().trim()));
}
if (StringUtils.isNotEmpty(appShareholderDetailFindDTO.getPhone())) {
example.createCriteria().andEqualTo("phone", appShareholderDetailFindDTO.getPhone());
criteria.andEqualTo("phone", appShareholderDetailFindDTO.getPhone());
}
if (Objects.nonNull(appShareholderDetailFindDTO.getCompanyId())) {
example.createCriteria().andEqualTo("companyId", appShareholderDetailFindDTO.getCompanyId());
criteria.andEqualTo("companyId", appShareholderDetailFindDTO.getCompanyId());
}
if (Objects.nonNull(appShareholderDetailFindDTO.getPositionId())) {
example.createCriteria().andEqualTo("positionId", appShareholderDetailFindDTO.getPositionId());
criteria.andEqualTo("positionId", appShareholderDetailFindDTO.getPositionId());
}
example.setOrderByClause("crt_time desc");
List<AppShareholderDetail> list = mapper.selectByExample(example);
example.setOrderByClause("upd_time desc");
PageDataVO<AppShareholderDetail> pageDataVO = PageDataVO.pageInfo(appShareholderDetailFindDTO.getPage(), appShareholderDetailFindDTO.getLimit(), () -> mapper.selectByExample(example));
List<AppShareholderDetail> data = pageDataVO.getData();
if (CollectionUtils.isEmpty(data)) {
......
package com.github.wxiaoqi.security.admin.rest.admin;
import com.github.wxiaoqi.security.admin.biz.AppShareholderDetailBiz;
import com.github.wxiaoqi.security.admin.dto.AppShareholderDetailDTO;
import com.github.wxiaoqi.security.admin.dto.AppShareholderDetailFindDTO;
import com.github.wxiaoqi.security.admin.vo.AppShareholderDetailVo;
import com.github.wxiaoqi.security.auth.client.config.UserAuthConfig;
......@@ -56,16 +57,32 @@ public class AppShareholderDetailController {
}
/**
* 查询
*
* @param appShareholderDetailFindDTO
* @return
*/
@PostMapping("/page")
@GetMapping("/page")
public ObjectRestResponse<PageDataVO<AppShareholderDetailVo>> findWithPage(@RequestBody AppShareholderDetailFindDTO appShareholderDetailFindDTO) {
PageDataVO<AppShareholderDetailVo> dataVO = appShareholderDetailBiz.findWithPage(appShareholderDetailFindDTO);
return ObjectRestResponse.succ(dataVO);
}
/**
* 新增或编辑身份信息
*
* @return
*/
@PostMapping("/addUserPostion")
public ObjectRestResponse<Void> addUserPostion(@RequestBody AppShareholderDetailDTO appShareholderDetailDTO, HttpServletRequest request) {
try {
IJWTInfo infoFromToken = userAuthUtil.getInfoFromToken(userAuthConfig.getToken(request));
Integer updUserId = Integer.valueOf(infoFromToken.getId());
return appShareholderDetailBiz.add(appShareholderDetailDTO, updUserId);
} catch (Exception e) {
log.error("新增失败【{}】", e);
throw new BaseException("新增失败");
}
}
}
......@@ -212,4 +212,7 @@ public interface VehicleFeign {
@GetMapping("/branchCompany/company_info")
Map<Integer, String> findCompanyMap();
@RequestMapping(value ="/branchCompany/{id}",method = RequestMethod.GET)
RestResponse<BranchCompany> get(@PathVariable Integer id);
}
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