客户管理功能代码提交

pro^2^2
郑明梁 2 years ago
parent 5e3901e040
commit c5b7ba7db5

@ -522,5 +522,12 @@ public class BasicCorpController {
return ResultVOUtils.success(getCorpList);
}
@AuthRuleAnnotation("")
@GetMapping("/udiwms/basic/unit/maintain/getCorpLists")
public BaseResponse getCorpLists() {
List<BasicCorpEntity> getCorpList = basicUnitMaintainService.getCorpLists();
return ResultVOUtils.success(getCorpList);
}
}

@ -0,0 +1,232 @@
package com.glxp.api.controller.inout;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.github.pagehelper.PageInfo;
import com.glxp.api.annotation.AuthRuleAnnotation;
import com.glxp.api.common.enums.ResultEnum;
import com.glxp.api.common.res.BaseResponse;
import com.glxp.api.common.util.ResultVOUtils;
import com.glxp.api.entity.inout.UnitMaintainPlatformEntity;
import com.glxp.api.entity.system.PlatformEntity;
import com.glxp.api.req.inout.PlatformLinkRequest;
import com.glxp.api.req.system.DeleteRequest;
import com.glxp.api.req.system.PlatformUserInfoRequest;
import com.glxp.api.res.PageSimpleResponse;
import com.glxp.api.res.inout.PlatformLinkResponse;
import com.glxp.api.service.auth.CustomerService;
import com.glxp.api.service.inout.PlatformService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate;
import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@RestController
@Slf4j
public class PlatformController {
@Resource
private PlatformService platformService;
@Resource
private CustomerService customerService;
@AuthRuleAnnotation("")
@PostMapping("/udiwms/platform/remove")
public BaseResponse remove(@RequestBody PlatformEntity platformEntity) {
if (platformService.remove(platformEntity.getId()) > 0) {
ResultVOUtils.success("删除成功");
}
return ResultVOUtils.error(500, "删除失败");
}
@AuthRuleAnnotation("")
@PostMapping("/udiwms/platform/update")
public BaseResponse update(@RequestBody PlatformEntity platformEntity) {
if (StrUtil.isBlank(platformEntity.getName()) || StrUtil.isBlank(platformEntity.getHost())) {
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, "参数不能为空");
}
return platformService.update(platformEntity);
}
@AuthRuleAnnotation("")
@GetMapping("/udiwms/platform/list")
public BaseResponse list(@RequestParam Map<String, Object> params) {
List<PlatformEntity> list = platformService.list(params);
PageInfo<PlatformEntity> pageInfo = new PageInfo<>(list);
PageSimpleResponse<PlatformEntity> pageSimpleResponse = new PageSimpleResponse<>();
pageSimpleResponse.setTotal(pageInfo.getTotal());
pageSimpleResponse.setList(pageInfo.getList());
return ResultVOUtils.success(pageSimpleResponse);
}
/**
*
*
* @return
*/
@AuthRuleAnnotation("")
@PostMapping("/udiwms/platform/testUserInfo")
public BaseResponse testUserInfo(@RequestBody PlatformUserInfoRequest platformUserInfoRequest, BindingResult bindingResult) {
if (bindingResult.hasErrors()) {
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
}
PlatformEntity platformEntity = platformService.getPlatformById(platformUserInfoRequest.getPlatformId());
if (null == platformEntity || StrUtil.isBlank(platformEntity.getHost())) {
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL);
}
String url = platformEntity.getHost() + "/verify";
Map<String, Object> map = new HashMap<>();
map.put("username", platformUserInfoRequest.getUsername());
map.put("password", platformUserInfoRequest.getPassword());
HttpHeaders headers = new HttpHeaders();
headers.setContentType(MediaType.APPLICATION_JSON_UTF8);
HttpEntity<String> request = new HttpEntity<>(JSON.toJSONString(map), headers);
RestTemplate restTemplate = new RestTemplate();
log.error(url);
String result = restTemplate.postForObject(url, request, String.class, map);
log.error(result);
Map<String, Object> object = JSON.parseObject(result, Map.class);
if (!String.valueOf(object.get("code")).equals("20000")) {
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, String.valueOf(object.get("message")));
}
Map<String, Object> data = JSON.parseObject(JSON.toJSONString(object.get("data")), Map.class);
ObjectMapper mapper = new ObjectMapper();
UnitMaintainPlatformEntity unitMaintainPlatformEntity = mapper.convertValue(data, UnitMaintainPlatformEntity.class);
return ResultVOUtils.success(unitMaintainPlatformEntity);
}
@AuthRuleAnnotation("")
@PostMapping("/udiwms/platform/link")
public BaseResponse update(@RequestBody PlatformLinkRequest platformLinkRequest) {
//判断此数据是否重复
String verifyResult = platformService.verifyUnitMaintainPlatform(platformLinkRequest);
if (!verifyResult.equals("success")) {
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, verifyResult);
}
UnitMaintainPlatformEntity unitMaintainPlatform = new UnitMaintainPlatformEntity();
BeanUtil.copyProperties(platformLinkRequest, unitMaintainPlatform);
unitMaintainPlatform.setCustomerId(Long.valueOf(unitMaintainPlatform.getUnitId()));
platformService.saveUnitPlatform(unitMaintainPlatform);
return ResultVOUtils.success("关联成功");
}
/**
*
*/
@AuthRuleAnnotation("")
@GetMapping("/udiwms/platform/getLinkPlatformList")
public BaseResponse getLinkPlatformList(PlatformLinkRequest platformLinkRequest, BindingResult bindingResult) {
if (bindingResult.hasErrors()) {
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL);
}
platformLinkRequest.setCustomerId(String.valueOf(customerService.getUserBean().getCustomerId()));
List<PlatformLinkResponse> list = platformService.getLinkPlatformList(platformLinkRequest);
PageInfo<PlatformLinkResponse> pageInfo = new PageInfo<>(list);
PageSimpleResponse<PlatformLinkResponse> pageSimpleResponse = new PageSimpleResponse<>();
pageSimpleResponse.setTotal(pageInfo.getTotal());
pageSimpleResponse.setList(pageInfo.getList());
return ResultVOUtils.success(pageSimpleResponse);
}
/**
*
*
* @param deleteRequest
* @return
*/
@AuthRuleAnnotation("")
@PostMapping("/udiwms/platform/unbind")
public BaseResponse unbindPlatform(DeleteRequest deleteRequest) {
if (StrUtil.isBlank(deleteRequest.getId())) {
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL);
}
platformService.unbindPlatform(deleteRequest.getId());
return ResultVOUtils.success();
}
/**
*
*
* @return
*/
@AuthRuleAnnotation("")
@GetMapping("/udiwms/platform/getTargetActions")
public BaseResponse getTargetActions(String platformId, String invSubCode, String apiKey, String apiSecret) {
if (StrUtil.isBlank(platformId)) {
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL);
}
return platformService.getTargetActions(platformId, invSubCode, apiKey, apiSecret);
}
@AuthRuleAnnotation("")
@GetMapping("/udiwms/platform/getTargetInv")
public BaseResponse getTargetInv(String platformId, String apiKey, String apiSecret) {
if (StrUtil.isBlank(platformId)) {
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL);
}
return platformService.getTargetInv(platformId, apiKey, apiSecret);
}
@AuthRuleAnnotation("")
@GetMapping("/udiwms/platform/getTargetSubInv")
public BaseResponse getTargetSubInv(String platformId, String invCode, String apiKey, String apiSecret) {
if (StrUtil.isBlank(platformId)) {
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL);
}
return platformService.getTargetSubInv(platformId, invCode, apiKey, apiSecret);
}
/**
*
*
* @param host
* @return
*/
@AuthRuleAnnotation("")
@GetMapping("udiwms/platform/testPlatformConnection")
public BaseResponse testPlatformConnection(String host) {
if (StrUtil.isBlank(host)) {
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL);
}
return platformService.testPlatformConnection(host);
}
/**
*
*
* @param platformLinkRequest
* @return
*/
@AuthRuleAnnotation("")
@PostMapping("/udiwms/platform/getPlatFormDelect")
public BaseResponse getPlatFormDelect(@RequestBody PlatformLinkRequest platformLinkRequest) {
List<PlatformLinkResponse> platformLinkResponses = platformService.selectDelectList(platformLinkRequest);
PageInfo<PlatformLinkResponse> pageInfo = new PageInfo<>(platformLinkResponses);
PageSimpleResponse<PlatformLinkResponse> pageSimpleResponse = new PageSimpleResponse<>();
pageSimpleResponse.setTotal(pageInfo.getTotal());
pageSimpleResponse.setList(pageInfo.getList());
return ResultVOUtils.success(pageSimpleResponse);
}
}

@ -63,4 +63,7 @@ public interface BasicCorpDao extends BaseMapperPlus<BasicCorpDao, BasicCorpEnti
String selectNameByErpId(@Param("supId") String supId);
List<BasicCorpEntity> getCorpList();
List<BasicCorpEntity> getCorpLists();
}

@ -0,0 +1,40 @@
package com.glxp.api.dao.inout;
import com.glxp.api.entity.system.PlatformEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
@Mapper
public interface PlatformDao {
int batchSave(List<PlatformEntity> list);
List<PlatformEntity> list( Map<String, Object> map);
int count(Map<String, Object> map);
PlatformEntity get(String id);
/**
* 访
*
* @param name
* @param host
* @return
*/
List<PlatformEntity> selectByNameAndHost(@Param("name") String name, @Param("host") String host);
PlatformEntity selectById(@Param("platformId") String platformId);
int insert(PlatformEntity platformEntity);
List<PlatformEntity> selectList(@Param("id") String id, @Param("name") String name, @Param("host") String host);
int deleteById(@Param("id") String id);
void updateById(PlatformEntity platformEntity);
}

@ -0,0 +1,46 @@
package com.glxp.api.dao.inout;
import com.glxp.api.entity.inout.UnitMaintainPlatformEntity;
import com.glxp.api.req.inout.PlatformLinkRequest;
import com.glxp.api.res.inout.PlatformLinkResponse;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@Mapper
public interface UnitMaintainPlatformDao {
/**
*
*
* @param page
* @param customerId
* @param key
* @return
*/
List<PlatformLinkResponse> getLinkPlatformList(@Param("customerId") String customerId, @Param("key") String key);
/**
* ID
*
* @param customerId
* @return
*/
List<UnitMaintainPlatformEntity> selectByCustomerId(@Param("customerId") Long customerId);
void updateById(UnitMaintainPlatformEntity maintainPlatform);
void insert(UnitMaintainPlatformEntity unitMaintainPlatformEntity);
List<UnitMaintainPlatformEntity> selectList(PlatformLinkRequest platformLinkRequest);
UnitMaintainPlatformEntity findLinkData(@Param("customerId") long customerId, @Param("action") String action, @Param("unitId") String unitId);
void deleteById(String id);
Long selectCount(@Param("unitId") String unitId, @Param("action") String action);
List<PlatformLinkResponse> selectDelectList(@Param("platformId") String platformId);
}

@ -0,0 +1,71 @@
package com.glxp.api.entity.inout;
import lombok.Data;
/**
*
*/
@Data
public class UnitMaintainPlatformEntity {
private Integer id;
/**
* ID
*/
private String unitId;
/**
* ID
*/
private Long customerId;
/**
* ID
*/
private String platformId;
/**
*
*/
private String sourceAction;
/**
*
*/
private String targetAction;
/**
*
*/
private String invCode;
/**
*
*/
private String invSubCode;
/**
*
*/
private String appid;
/**
*
*/
private String secretKey;
/**
* ID
*/
private String apiKey;
//目标单据类型
private String targetName;
private String invName;
private String invSubName;
}

@ -0,0 +1,46 @@
package com.glxp.api.req.inout;
import com.glxp.api.util.page.ListPageRequest;
import lombok.Data;
/**
*
*/
@Data
public class PlatformLinkRequest extends ListPageRequest {
private Integer id;
private String unitId;
private String corpName;
private String platformId;
private String platformUsername;
private String platformPassword;
private String appid;
private String apiKey;
private String secretKey;
private String sourceAction;
private String targetAction;
private String invCode;
private String invSubCode;
private String key;
private String customerId;
private String invName;
private String invSubName;
private String targetName;
}

@ -0,0 +1,42 @@
package com.glxp.api.res.inout;
import lombok.Data;
/**
*
*/
@Data
public class PlatformLinkResponse {
//往来单位ID
private Long id;
//往来单位编码
private String unitId;
//往来单位名称
private String corpName;
//往来单位类型
private Integer corpType;
//拼音码
private String pinyinCode;
//自助平台名称
private String platformName;
//自助平台ID
private String platformId;
private String socurceName;
//本地单据类型
private String sourceAction;
private String sourceName;
//目标单据类型
private String targetAction;
private String targetName;
private String invCode;
private String invName;
private String invSubCode;
private String invSubName;
private String name;
private String host;
}

@ -55,4 +55,6 @@ public interface BasicCorpService {
List<BasicCorpEntity> selectCorpList(BasicUnitMaintainFilterRequest basicUnitMaintainFilterRequest);
List<BasicCorpEntity> getCorpLists();
}

@ -167,4 +167,9 @@ public class BasicCorpServiceImpl implements BasicCorpService {
}
return false;
}
@Override
public List<BasicCorpEntity> getCorpLists() {
return basicCorpDao.getCorpLists();
}
}

@ -0,0 +1,109 @@
package com.glxp.api.service.inout;
import com.glxp.api.common.res.BaseResponse;
import com.glxp.api.entity.inout.UnitMaintainPlatformEntity;
import com.glxp.api.entity.system.PlatformEntity;
import com.glxp.api.req.inout.PlatformLinkRequest;
import com.glxp.api.res.inout.PlatformLinkResponse;
import java.util.List;
import java.util.Map;
public interface PlatformService {
public int save(PlatformEntity platformEntity);
public int remove(String id);
public BaseResponse update(PlatformEntity platformEntity);
List<PlatformEntity> list(Map<String, Object> map);
int count(Map<String, Object> map);
PlatformEntity get(String id);
/**
*
*
* @param platformLinkRequest
* @return
*/
List<PlatformLinkResponse> getLinkPlatformList(PlatformLinkRequest platformLinkRequest);
/**
*
*
* @param id
*/
void unbindPlatform(String id);
/**
*
*
* @param platformId
* @return
*/
BaseResponse getTargetActions(String platformId, String invSubCode,String apiKey,String apiSecret);
//获取自助平台一级仓库
BaseResponse getTargetInv(String platformId,String apiKey,String apiSecret);
//获取自助平台一级仓库所属分库
BaseResponse getTargetSubInv(String platformId, String invCode,String apiKey,String apiSecret);
/**
*
*
* @param host
* @return
*/
BaseResponse testPlatformConnection(String host);
/**
* ID
*
* @param platformId
* @return
*/
PlatformEntity getPlatformById(String platformId);
/**
*
*
* @param unitMaintainPlatform
*/
void saveUnitPlatform(UnitMaintainPlatformEntity unitMaintainPlatform);
/**
*
*
* @param platformLinkRequest
* @return
*/
public String verifyUnitMaintainPlatform(PlatformLinkRequest platformLinkRequest);
/**
*
*
* @param customerId
* @param action
* @param unitId
* @return
*/
UnitMaintainPlatformEntity findLinkData(long customerId, String action, String unitId);
/**
*
* @param platformId
* @return
*/
List<PlatformLinkResponse> selectDelectList(PlatformLinkRequest platformLinkRequest);
}

@ -0,0 +1,291 @@
package com.glxp.api.service.inout.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSON;
import com.github.pagehelper.PageHelper;
import com.glxp.api.common.enums.ResultEnum;
import com.glxp.api.common.res.BaseResponse;
import com.glxp.api.common.util.ResultVOUtils;
import com.glxp.api.dao.inout.PlatformDao;
import com.glxp.api.dao.inout.UnitMaintainPlatformDao;
import com.glxp.api.entity.inout.UnitMaintainPlatformEntity;
import com.glxp.api.entity.system.PlatformEntity;
import com.glxp.api.req.inout.PlatformLinkRequest;
import com.glxp.api.res.inout.PlatformLinkResponse;
import com.glxp.api.service.inout.PlatformService;
import com.glxp.api.util.HttpClient;
import com.glxp.api.util.OkHttpCli;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Slf4j
@Service
@Transactional(rollbackFor = Exception.class)
public class PlatformServiceImpl implements PlatformService {
@Resource
private PlatformDao platformDao;
@Resource
private UnitMaintainPlatformDao unitMaintainPlatformDao;
@Resource
private OkHttpCli okHttpCli;
public int save(PlatformEntity platformEntity) {
if (StringUtils.isEmpty(platformEntity.getId())) {
platformEntity.setId(String.valueOf(IdUtil.getSnowflake().nextId()));
}
return platformDao.insert(platformEntity);
}
public int remove(String id) {
return platformDao.deleteById(id);
}
public BaseResponse update(PlatformEntity platformEntity) {
if (StrUtil.isBlank(platformEntity.getId())) {
if (!verifyPlatformExist(platformEntity)) {
save(platformEntity);
return ResultVOUtils.success("添加成功");
} else {
return ResultVOUtils.error(500, "已存在相同数据");
}
}
platformDao.updateById(platformEntity);
return ResultVOUtils.success("更新成功");
}
private boolean verifyPlatformExist(PlatformEntity platformEntity) {
//校验名称和地址是否重复
List<PlatformEntity> list = platformDao.selectByNameAndHost(platformEntity.getName(), platformEntity.getHost());
if (CollUtil.isEmpty(list)) {
return false;
}
return true;
}
public List<PlatformEntity> list(Map<String, Object> map) {
if (map.get("page") != null && map.get("limit") != null) {
Integer page = Integer.valueOf(String.valueOf(map.get("page")));
Integer limit = Integer.valueOf(String.valueOf(map.get("limit")));
PageHelper.offsetPage((page - 1) * limit, limit);
}
List<PlatformEntity> list = platformDao.selectList(String.valueOf(map.get("id")), String.valueOf(map.get("name")), String.valueOf(map.get("host")));
return list;
}
public int count(Map<String, Object> map) {
return platformDao.count(map);
}
public PlatformEntity get(String id) {
return platformDao.get(id);
}
/**
*
*
* @param platformLinkRequest
* @return
*/
public List<PlatformLinkResponse> getLinkPlatformList(PlatformLinkRequest platformLinkRequest) {
if (null == platformLinkRequest) {
return Collections.emptyList();
}
if (null != platformLinkRequest.getPage() && null != platformLinkRequest.getLimit()) {
PageHelper.offsetPage((platformLinkRequest.getPage() - 1) * platformLinkRequest.getLimit(), platformLinkRequest.getLimit());
}
return unitMaintainPlatformDao.getLinkPlatformList(platformLinkRequest.getCustomerId(), platformLinkRequest.getKey());
}
/**
*
*
* @param id
*/
public void unbindPlatform(String id) {
unitMaintainPlatformDao.deleteById(id);
}
/**
*
*
* @param platformId
* @return
*/
public BaseResponse getTargetActions(String platformId, String invSubCode,String apiKey,String apiSecret) {
PlatformEntity platformEntity = platformDao.get(platformId);
if (null == platformEntity) {
return ResultVOUtils.success();
}
String host = platformEntity.getHost();
Map<String, String> paramMap = new HashMap<>();
paramMap.put("invSubCode", invSubCode);
String resp = okHttpCli.doGet(host + "/udiwms/bussinessType/udimsFilter",paramMap,buildHeader(apiKey,apiSecret));
if (StrUtil.isNotBlank(resp) && resp.contains("20000")) {
return JSON.parseObject(resp, BaseResponse.class);
} else {
log.error("获取自助平台单据类型异常");
return ResultVOUtils.error(500, "获取自助平台接口异常");
}
}
//获取自助平台一级仓库
public BaseResponse getTargetInv(String platformId,String apiKey,String apiSecret) {
PlatformEntity platformEntity = platformDao.get(platformId);
if (null == platformEntity) {
return ResultVOUtils.success();
}
String host = platformEntity.getHost();
String url = host + "/spms/inv/warehouse/filterInv/forUdims";
log.info("拉取自助平台仓库数据:" + url);
String resp = okHttpCli.doGet(url,buildHeader(apiKey,apiSecret));
log.info("拉取结果:" + resp);
if (StrUtil.isNotBlank(resp) && resp.contains("20000")) {
try {
return JSON.parseObject(resp, BaseResponse.class);
} catch (Exception e) {
log.error("格式化自助平台仓库信息异常", e);
return ResultVOUtils.error(500, "调用自助平台接口异常");
}
} else {
log.error("获取自助平台仓库失败");
return ResultVOUtils.error(500, "调用自助平台接口异常");
}
}
//获取自助平台一级仓库所属分库
public BaseResponse getTargetSubInv(String platformId, String invCode,String apiKey,String apiSecret) {
PlatformEntity platformEntity = platformDao.get(platformId);
if (null == platformEntity) {
return ResultVOUtils.success();
}
String host = platformEntity.getHost();
Map<String, String> paramMap = new HashMap<>();
paramMap.put("invCode", invCode);
String resp = okHttpCli.doGet(host + "/spms/sub/inv/warehouse/getSubInvForUdims",paramMap,buildHeader(apiKey,apiSecret));
if (StrUtil.isNotBlank(resp) && resp.contains("20000")) {
return JSON.parseObject(resp, BaseResponse.class);
} else {
log.error("获取自助平台分库失败");
return ResultVOUtils.error(500, "获取自助平台接口异常");
}
}
/**
*
*
* @param host
* @return
*/
public BaseResponse testPlatformConnection(String host) {
String testUrl = host + "/udiwms/auth/device/connect";
String response = HttpUtil.get(testUrl);
if (StrUtil.isNotBlank(response)) {
try {
BaseResponse result = JSONUtil.toBean(response, BaseResponse.class);
if (result.getCode() == 20000) {
return ResultVOUtils.success();
}
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL);
} catch (Exception e) {
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL);
}
} else {
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL);
}
}
/**
* ID
*
* @param platformId
* @return
*/
public PlatformEntity getPlatformById(String platformId) {
return platformDao.selectById(platformId);
}
/**
*
*
* @param unitMaintainPlatformEntity
*/
public void saveUnitPlatform(UnitMaintainPlatformEntity unitMaintainPlatformEntity) {
if (null != unitMaintainPlatformEntity.getId()) {
unitMaintainPlatformDao.updateById(unitMaintainPlatformEntity);
} else {
unitMaintainPlatformDao.insert(unitMaintainPlatformEntity);
}
//更新当前客户关联数据的所有key
List<UnitMaintainPlatformEntity> list = unitMaintainPlatformDao.selectByCustomerId(unitMaintainPlatformEntity.getCustomerId());
if (CollUtil.isNotEmpty(list)) {
for (UnitMaintainPlatformEntity maintainPlatform : list) {
maintainPlatform.setAppid(unitMaintainPlatformEntity.getAppid());
maintainPlatform.setApiKey(unitMaintainPlatformEntity.getApiKey());
maintainPlatform.setSecretKey(unitMaintainPlatformEntity.getSecretKey());
unitMaintainPlatformDao.updateById(maintainPlatform);
}
}
}
@Override
public String verifyUnitMaintainPlatform(PlatformLinkRequest platformLinkRequest) {
List<UnitMaintainPlatformEntity> list = unitMaintainPlatformDao.selectList(platformLinkRequest);
if (CollUtil.isEmpty(list)) {
return "success";
} else {
for (UnitMaintainPlatformEntity maintainPlatform : list) {
if (maintainPlatform.getId().equals(platformLinkRequest.getId())) {
return "success";
} else {
return "重复添加";
}
}
}
return "重复添加";
}
/**
*
*
* @param customerId
* @param action
* @param unitId
* @return
*/
public UnitMaintainPlatformEntity findLinkData(long customerId, String action, String unitId) {
return unitMaintainPlatformDao.findLinkData(customerId, action, unitId);
}
@Override
public List<PlatformLinkResponse> selectDelectList(PlatformLinkRequest platformLinkRequest) {
if (null == platformLinkRequest) {
return Collections.emptyList();
}
if (null != platformLinkRequest.getPage() && null != platformLinkRequest.getLimit()) {
PageHelper.offsetPage((platformLinkRequest.getPage() - 1) * platformLinkRequest.getLimit(), platformLinkRequest.getLimit());
}
return unitMaintainPlatformDao.selectDelectList(platformLinkRequest.getPlatformId());
}
public String[] buildHeader(String apiKey,String apiSecret) {
String[] headers = {"api_key", apiKey, "secret_key", apiSecret};
return headers;
}
}

@ -21,8 +21,8 @@ import javax.annotation.Resource;
import java.util.Arrays;
@Component
@EnableScheduling
//@Component
//@EnableScheduling
public class SyncHeartTask implements SchedulingConfigurer {
final Logger logger = LoggerFactory.getLogger(SyncHeartTask.class);

@ -34,7 +34,7 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ExecutorService;
@Component
@EnableScheduling
//@EnableScheduling
@Slf4j
public class SyncThirdSysTask implements SchedulingConfigurer {

@ -343,4 +343,11 @@
WHERE erpId NOT IN (SELECT customerId FROM sup_company)
AND corpType = 2;
</select>
<select id="getCorpLists" resultType="com.glxp.api.entity.basic.BasicCorpEntity">
SELECT *
FROM basic_corp
WHERE corpType = 1
AND outType = 2;
</select>
</mapper>

@ -0,0 +1,106 @@
<?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="com.glxp.api.dao.inout.PlatformDao">
<insert id="batchSave" parameterType="java.util.List">
replace into auth_platform
(id, name, host)
values
<foreach item="item" index="index" collection="list"
separator=",">
(#{item.id}, #{item.name,jdbcType=VARCHAR}, #{item.host,jdbcType=VARCHAR})
</foreach>
</insert>
<select id="get" resultType="com.glxp.api.entity.system.PlatformEntity">
select *
from auth_platform
where id = #{value}
</select>
<select id="list" resultType="com.glxp.api.entity.system.PlatformEntity">
select *
from auth_platform
<where>
<if test="id != null and id != ''">
and id = #{id}
</if>
<if test="name != null and name != ''">
and instr(name, #{name})
</if>
<if test="host != null and host != ''">
and instr(host, #{host})
</if>
</where>
order by id desc
</select>
<select id="count" resultType="int">
select count(*)
from auth_platform
<where>
<if test="id != null and id != ''">
and id = #{id}
</if>
<if test="name != null and name != ''">
and instr(name, #{name})
</if>
<if test="host != null and host != ''">
and instr(host, #{host})
</if>
</where>
</select>
<select id="selectByNameAndHost" resultType="com.glxp.api.entity.system.PlatformEntity">
select *
from auth_platform
where name = #{name}
and host = #{host}
</select>
<select id="selectById" resultType="com.glxp.api.entity.system.PlatformEntity">
select *
from auth_platform
where id = #{platformId}
</select>
<insert id="insert">
insert into auth_platform(id, name, host)
VALUES (#{id}, #{name}, #{host})
</insert>
<select id="selectList" resultType="com.glxp.api.entity.system.PlatformEntity">
select *
from auth_platform
<where>
<if test="id != null and id != '' and id != 'null'">
AND id = #{id}
</if>
<if test="name != null and name != '' and name != 'null'">
AND name like concat('%', #{name}, '%')
</if>
<if test="host != null and host != '' and host != 'null'">
AND host like concat('%', #{host}, '%')
</if>
</where>
</select>
<delete id="deleteById">
delete
from auth_platform
where id = #{id}
</delete>
<update id="updateById">
update auth_platform
<trim prefix="set" suffixOverrides=",">
<if test="name != null and name != ''">
name = #{name},
</if>
<if test="host != null and host != ''">
host = #{host},
</if>
</trim>
where id = #{id}
</update>
</mapper>

@ -0,0 +1,168 @@
<?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="com.glxp.api.dao.inout.UnitMaintainPlatformDao">
<select id="getLinkPlatformList" resultType="com.glxp.api.res.inout.PlatformLinkResponse">
SELECT a1.id as platformId,
a1.`name`,
a1.`host`,
iu.id,
iu.unitId,
iu.customerId,
iu.invCode,
iu.targetAction,
iu.sourceAction,
iu.invSubCode,
b1.`name` as corpName
FROM auth_platform a1
LEFT JOIN io_unit_maintain_platform iu ON a1.id = iu.platformId
LEFT JOIN basic_corp b1 ON b1.erpId = iu.unitId
<where>
<if test="key != null and key != ''">
AND a1.`name` = #{key}
</if>
</where>
GROUP BY a1.id
</select>
<select id="selectByCustomerId" resultType="com.glxp.api.entity.inout.UnitMaintainPlatformEntity">
select *
from io_unit_maintain_platform
where customerId = #{customerId}
</select>
<update id="updateById" parameterType="com.glxp.api.entity.inout.UnitMaintainPlatformEntity">
update io_unit_maintain_platform
<trim prefix="set" suffixOverrides=",">
<if test="unitId != null and unitId != ''">
unitId = #{unitId},
</if>
<if test="customerId != null">
customerId = #{customerId},
</if>
<if test="platformId != null and platformId != ''">
platformId = #{platformId},
</if>
<if test="sourceAction != null and sourceAction != ''">
sourceAction = #{sourceAction},
</if>
<if test="targetAction != null and targetAction != ''">
targetAction = #{targetAction},
</if>
<if test="invCode != null and invCode != ''">
invCode = #{invCode},
</if>
<if test="invSubCode != null and invSubCode != ''">
invSubCode = #{invSubCode},
</if>
<if test="appid != null and appid != ''">
appid = #{appid},
</if>
<if test="apiKey != null and apiKey != ''">
apiKey = #{apiKey},
</if>
<if test="secretKey != null and secretKey != ''">
secretKey = #{secretKey},
</if>
<if test="invName != null and invName != ''">
invName = #{invName},
</if>
<if test="invSubName != null and invSubName != ''">
invSubName = #{invSubName},
</if>
<if test="targetName != null and targetName != ''">
targetName = #{targetName}
</if>
</trim>
where id = #{id}
</update>
<insert id="insert" useGeneratedKeys="true" keyColumn="id" keyProperty="id"
parameterType="com.glxp.api.entity.inout.UnitMaintainPlatformEntity">
insert into io_unit_maintain_platform (unitId, customerId, platformId, sourceAction, targetAction, invCode,
invSubCode, appid, apiKey, secretKey, invName, invSubName, targetName)
VALUES (#{unitId}, #{customerId}, #{platformId}, #{sourceAction}, #{targetAction}, #{invCode}, #{invSubCode},
#{appid}, #{apiKey}, #{secretKey}, #{invName}, #{invSubName}, #{targetName})
</insert>
<select id="selectList" resultType="com.glxp.api.entity.inout.UnitMaintainPlatformEntity">
select *
from io_unit_maintain_platform
<where>
<if test="unitId != null and unitId != ''">
AND unitId = #{unitId}
</if>
<if test="customerId != null and customerId != ''">
AND customerId = #{customerId}
</if>
<if test="platformId != null and platformId != ''">
AND platformId = #{platformId}
</if>
<if test="sourceAction != null and sourceAction != ''">
AND sourceAction = #{sourceAction}
</if>
<if test="targetAction != null and targetAction != ''">
AND targetAction = #{targetAction}
</if>
<if test="invSubCode != null and invSubCode != ''">
AND invCode = #{invCode}
</if>
<if test="invSubCode != null and invSubCode != ''">
AND invSubCode = #{invSubCode}
</if>
<if test="appid != null and appid != ''">
AND appid = #{appid}
</if>
<if test="apiKey != null and apiKey != ''">
AND apiKey = #{apiKey}
</if>
<if test="secretKey != null and secretKey != ''">
AND secretKey = #{secretKey}
</if>
</where>
</select>
<select id="findLinkData" resultType="com.glxp.api.entity.inout.UnitMaintainPlatformEntity">
select *
from io_unit_maintain_platform
<where>
<if test="unitId != null and unitId != ''">
AND unitId = #{unitId}
</if>
<if test="customerId != null">
AND customerId = #{customerId}
</if>
<if test="action != null and action != ''">
AND sourceAction = #{action}
</if>
</where>
</select>
<delete id="deleteById">
delete
from io_unit_maintain_platform
where id = #{id}
</delete>
<select id="selectCount" resultType="java.lang.Long">
select count(*)
from io_unit_maintain_platform
where sourceAction = #{action}
and unitId = #{unitId}
</select>
<select id="selectDelectList" resultType="com.glxp.api.res.inout.PlatformLinkResponse">
SELECT io.id,
io.platformId,
io.invCode,
io.invName,
io.invSubCode,
io.invSubName,
io.targetAction,
io.targetName,
io.sourceAction,
b1.`name` as sourceName
FROM io_unit_maintain_platform io
LEFT JOIN basic_bussiness_type b1 ON b1.action = io.sourceAction
where io.platformId = #{platformId}
</select>
</mapper>
Loading…
Cancel
Save