新增第三方生产企业
parent
3f06c5a1dd
commit
1ed3360997
@ -1,13 +1,20 @@
|
||||
package com.glxp.api.controller.basic;
|
||||
|
||||
import com.glxp.api.controller.BaseController;
|
||||
import com.glxp.api.service.basic.BasicManufacturerService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 生产企业字典
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
public class BasicManufacturerController extends BaseController {
|
||||
|
||||
|
||||
@Resource
|
||||
BasicManufacturerService manufacturerService;
|
||||
}
|
||||
|
@ -0,0 +1,132 @@
|
||||
package com.glxp.api.controller.thrsys;
|
||||
|
||||
import cn.hutool.core.thread.ThreadUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
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.thrsys.ThrManufacturerEntity;
|
||||
import com.glxp.api.entity.thrsys.ThrSystemDetailEntity;
|
||||
import com.glxp.api.http.ErpBasicClient;
|
||||
import com.glxp.api.req.system.DeleteRequest;
|
||||
import com.glxp.api.req.thrsys.FilterThrCorpRequest;
|
||||
import com.glxp.api.req.thrsys.ThrManuFilterRequest;
|
||||
import com.glxp.api.req.thrsys.ThrUnitMaintainFilterRequest;
|
||||
import com.glxp.api.res.PageSimpleResponse;
|
||||
import com.glxp.api.res.thrsys.ThrCorpsResponse;
|
||||
import com.glxp.api.res.thrsys.ThrUnitMaintainResponse;
|
||||
import com.glxp.api.service.thrsys.ThrManufacturerService;
|
||||
import com.glxp.api.service.thrsys.ThrSystemDetailService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.validation.BindingResult;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
public class ThrManusController {
|
||||
|
||||
|
||||
@Resource
|
||||
ThrManufacturerService thrManufacturerService;
|
||||
@Resource
|
||||
private ThrSystemDetailService thrSystemDetailService;
|
||||
@Resource
|
||||
private ErpBasicClient erpBasicClient;
|
||||
|
||||
|
||||
@GetMapping("/udiwms/thrsys/getManus")
|
||||
public BaseResponse getManus(FilterThrCorpRequest filterThrCorpRequest,
|
||||
BindingResult bindingResult) {
|
||||
|
||||
if (bindingResult.hasErrors()) {
|
||||
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
|
||||
}
|
||||
List<ThrManufacturerEntity> thrManufacturerEntities
|
||||
= thrManufacturerService.filterThrManu(filterThrCorpRequest);
|
||||
PageInfo<ThrManufacturerEntity> pageInfo;
|
||||
pageInfo = new PageInfo<>(thrManufacturerEntities);
|
||||
PageSimpleResponse<ThrManufacturerEntity> pageSimpleResponse = new PageSimpleResponse<>();
|
||||
pageSimpleResponse.setTotal(pageInfo.getTotal());
|
||||
pageSimpleResponse.setList(thrManufacturerEntities);
|
||||
return ResultVOUtils.success(pageSimpleResponse);
|
||||
}
|
||||
|
||||
|
||||
@AuthRuleAnnotation("")
|
||||
@PostMapping("/udiwms/thrsys/delManus")
|
||||
public BaseResponse delCorps(@RequestBody DeleteRequest deleteRequest, BindingResult bindingResult) {
|
||||
|
||||
if (bindingResult.hasErrors()) {
|
||||
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
|
||||
}
|
||||
String id = deleteRequest.getId();
|
||||
thrManufacturerService.removeById(id);
|
||||
return ResultVOUtils.success("删除成功");
|
||||
}
|
||||
|
||||
|
||||
//选中或者下载全部
|
||||
@AuthRuleAnnotation("")
|
||||
@PostMapping("/udiwms/thrsys/manu/corpsDlAll")
|
||||
public BaseResponse corpsDlAll(@RequestBody ThrManuFilterRequest thrManuFilterRequest) {
|
||||
if (null == thrManuFilterRequest) {
|
||||
return ResultVOUtils.error(500, "参数不能为空");
|
||||
}
|
||||
ThreadUtil.execAsync(() -> {
|
||||
try {
|
||||
thrManufacturerService.downloadByRequest(thrManuFilterRequest);
|
||||
} catch (Exception e) {
|
||||
log.error("下载异常", e);
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
});
|
||||
return ResultVOUtils.success("后台正在下载,请稍后刷新查看!");
|
||||
}
|
||||
|
||||
|
||||
//查询ERP往来单位
|
||||
@AuthRuleAnnotation("")
|
||||
@GetMapping("/udiwms/manu/filterErp")
|
||||
public BaseResponse filterErp(ThrManuFilterRequest thrManuFilterRequest,
|
||||
BindingResult bindingResult) {
|
||||
|
||||
if (bindingResult.hasErrors()) {
|
||||
return ResultVOUtils.error(ResultEnum.PARAM_VERIFY_FALL, bindingResult.getFieldError().getDefaultMessage());
|
||||
}
|
||||
ThrSystemDetailEntity thrSystemDetailEntity = thrSystemDetailService.selectByKey("manuUrl", thrManuFilterRequest.getThirdSys());
|
||||
if (thrSystemDetailEntity == null || thrSystemDetailEntity.getValue() == null)
|
||||
return ResultVOUtils.error(500, "生产企业接口地址未定义");
|
||||
if (thrSystemDetailEntity.getEnabled()) {
|
||||
BaseResponse<PageSimpleResponse<ThrManufacturerEntity>> udiDlDeviceResponse = erpBasicClient.getThrManu(thrManuFilterRequest);
|
||||
if (udiDlDeviceResponse.getCode() == 20000) {
|
||||
for (ThrManufacturerEntity item : udiDlDeviceResponse.getData().getList()) {
|
||||
ThrManufacturerEntity thrManufacturerEntity = thrManufacturerService.getOne(new QueryWrapper<ThrManufacturerEntity>().eq("unitId", item.getUnitId()).eq("thirdSysFk", thrManuFilterRequest.getThirdSys()).last("limit 1"));
|
||||
if (thrManufacturerEntity != null) {
|
||||
item.setChecked(true);
|
||||
} else {
|
||||
item.setChecked(false);
|
||||
}
|
||||
}
|
||||
return udiDlDeviceResponse;
|
||||
} else {
|
||||
return udiDlDeviceResponse;
|
||||
}
|
||||
|
||||
} else {
|
||||
return ResultVOUtils.error(500, "第三方系统往来单位服务接口未启用");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package com.glxp.api.dao.thrsys;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.glxp.api.dao.BaseMapperPlus;
|
||||
import com.glxp.api.entity.thrsys.ThrCorpEntity;
|
||||
import com.glxp.api.entity.thrsys.ThrManufacturerEntity;
|
||||
import com.glxp.api.req.thrsys.FilterThrCorpRequest;
|
||||
import com.glxp.api.res.thrsys.ThrCorpsResponse;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface ThrManufacturerMapper extends BaseMapperPlus<ThrManufacturerMapper, ThrManufacturerEntity, ThrManufacturerEntity> {
|
||||
|
||||
List<ThrManufacturerEntity> filterThrManu(FilterThrCorpRequest filterThrCorpRequest);
|
||||
|
||||
ThrManufacturerEntity selectByUnitIdAndThirdId(@Param("unitId") String unitId, @Param("thirdId") String thirdId);
|
||||
|
||||
}
|
@ -0,0 +1,79 @@
|
||||
package com.glxp.api.entity.thrsys;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 第三方往来单位类型
|
||||
*/
|
||||
@Data
|
||||
@TableName(value = "thr_manufacturer")
|
||||
public class ThrManufacturerEntity implements Serializable {
|
||||
@TableId(value = "id", type = IdType.INPUT)
|
||||
private Long id;
|
||||
|
||||
@TableField("unitId")
|
||||
private String unitId;
|
||||
|
||||
@TableField("spell")
|
||||
private String spell;
|
||||
|
||||
@TableField("addr")
|
||||
private String addr;
|
||||
|
||||
@TableField("creditNo")
|
||||
private String creditNo;
|
||||
|
||||
@TableField("contact")
|
||||
private String contact;
|
||||
|
||||
@TableField("mobile")
|
||||
private String mobile;
|
||||
|
||||
@TableField("thirdSysFk")
|
||||
private String thirdSysFk;
|
||||
|
||||
@TableField("name")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
@TableField("createUser")
|
||||
private String createUser;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField("createTime")
|
||||
private Date createTime;
|
||||
|
||||
/**
|
||||
* 更新人
|
||||
*/
|
||||
@TableField("updateUser")
|
||||
private String updateUser;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@TableField("updateTime")
|
||||
private Date updateTime;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
@TableField("remark")
|
||||
private String remark;
|
||||
@TableField(exist = false)
|
||||
private Boolean checked;
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
package com.glxp.api.req.thrsys;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.glxp.api.res.thrsys.ThrCorpsResponse;
|
||||
import com.glxp.api.util.page.ListPageRequest;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
public class ThrManuFilterRequest extends ListPageRequest {
|
||||
|
||||
private Integer id;
|
||||
private String key;
|
||||
private String unitId;
|
||||
private String name;
|
||||
private String thirdSys;
|
||||
private String thirdSysFk;
|
||||
|
||||
private String thirdId;
|
||||
private String thirdId1;
|
||||
private String thirdId2;
|
||||
private String thirdId3;
|
||||
private String thirdId4;
|
||||
private String erpId;
|
||||
private Integer corpType;
|
||||
private Integer outType;
|
||||
private Boolean isDownThrSys;
|
||||
private String lastUpdateTime;
|
||||
List<ThrCorpsResponse> thrCorpEntities;
|
||||
|
||||
|
||||
public String getThirdSys() {
|
||||
if (StrUtil.isEmpty(thirdSys))
|
||||
return thirdSysFk;
|
||||
return thirdSys;
|
||||
}
|
||||
|
||||
public String getThirdSysFk() {
|
||||
|
||||
if (StrUtil.isEmpty(thirdSysFk))
|
||||
return thirdSys;
|
||||
return thirdSysFk;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,153 @@
|
||||
package com.glxp.api.service.thrsys;
|
||||
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import com.github.pagehelper.PageHelper;
|
||||
import com.glxp.api.common.res.BaseResponse;
|
||||
import com.glxp.api.common.util.ResultVOUtils;
|
||||
import com.glxp.api.config.WebSocketServer;
|
||||
import com.glxp.api.constant.BasicProcessStatus;
|
||||
import com.glxp.api.constant.Constant;
|
||||
import com.glxp.api.dao.thrsys.ThrCorpDao;
|
||||
import com.glxp.api.entity.thrsys.*;
|
||||
import com.glxp.api.http.ErpBasicClient;
|
||||
import com.glxp.api.req.thrsys.FilterThrCorpImportLogRequest;
|
||||
import com.glxp.api.req.thrsys.FilterThrCorpRequest;
|
||||
import com.glxp.api.req.thrsys.ThrManuFilterRequest;
|
||||
import com.glxp.api.req.thrsys.ThrUnitMaintainFilterRequest;
|
||||
import com.glxp.api.res.PageSimpleResponse;
|
||||
import com.glxp.api.res.thrsys.ThrCorpsResponse;
|
||||
import com.glxp.api.util.CustomUtil;
|
||||
import com.glxp.api.util.RedisUtil;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.glxp.api.dao.thrsys.ThrManufacturerMapper;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
public class ThrManufacturerService extends ServiceImpl<ThrManufacturerMapper, ThrManufacturerEntity> {
|
||||
|
||||
@Resource
|
||||
private ThrManufacturerMapper thrManufacturerMapper;
|
||||
@Resource
|
||||
private ErpBasicClient erpBasicClient;
|
||||
|
||||
|
||||
public List<ThrManufacturerEntity> filterThrManu(FilterThrCorpRequest filterThrCorpRequest) {
|
||||
if (filterThrCorpRequest == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
if (filterThrCorpRequest.getPage() != null) {
|
||||
int offset = (filterThrCorpRequest.getPage() - 1) * filterThrCorpRequest.getLimit();
|
||||
PageHelper.offsetPage(offset, filterThrCorpRequest.getLimit());
|
||||
}
|
||||
List<ThrManufacturerEntity> data = thrManufacturerMapper.filterThrManu(filterThrCorpRequest);
|
||||
return data;
|
||||
}
|
||||
|
||||
public BaseResponse downloadThrManu(ThrSystemDetailEntity thrSystemDetailEntity) {
|
||||
int page = 1;
|
||||
int limit = 100;
|
||||
|
||||
while (true) {
|
||||
ThrManuFilterRequest request = new ThrManuFilterRequest();
|
||||
request.setPage(page);
|
||||
request.setLimit(limit);
|
||||
request.setThirdSysFk(thrSystemDetailEntity.getThirdSysFk());
|
||||
BaseResponse<PageSimpleResponse<ThrManufacturerEntity>> baseResponse = erpBasicClient.getThrManu(request);
|
||||
|
||||
if (baseResponse.getCode() == 20000) {
|
||||
List<ThrManufacturerEntity> list = baseResponse.getData().getList();
|
||||
list.forEach(thrCorpsResponse -> {
|
||||
ThrManufacturerEntity thrCorpEntity = thrManufacturerMapper.selectByUnitIdAndThirdId(thrCorpsResponse.getUnitId(), thrSystemDetailEntity.getThirdSysFk());
|
||||
if (null == thrCorpEntity) {
|
||||
thrCorpEntity = new ThrManufacturerEntity();
|
||||
BeanUtils.copyProperties(thrCorpsResponse, thrCorpEntity);
|
||||
thrCorpEntity.setCreateTime(new Date());
|
||||
thrCorpEntity.setUpdateTime(new Date());
|
||||
thrCorpEntity.setId(IdUtil.getSnowflakeNextId());
|
||||
thrCorpEntity.setThirdSysFk(thrSystemDetailEntity.getThirdSysFk());
|
||||
thrManufacturerMapper.insert(thrCorpEntity);
|
||||
} else {
|
||||
boolean isChange = verifyDataChange(thrCorpEntity, thrCorpsResponse);
|
||||
if (isChange) {
|
||||
thrCorpEntity.setUpdateTime(new Date());
|
||||
thrManufacturerMapper.updateById(thrCorpEntity);
|
||||
}
|
||||
}
|
||||
});
|
||||
if (list.size() >= limit) {
|
||||
page++;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
return baseResponse;
|
||||
}
|
||||
}
|
||||
|
||||
return ResultVOUtils.success("下载完成");
|
||||
}
|
||||
|
||||
public BaseResponse downloadByRequest(ThrManuFilterRequest request) {
|
||||
int page = 1;
|
||||
int limit = 100;
|
||||
while (true) {
|
||||
request.setPage(page);
|
||||
request.setLimit(limit);
|
||||
request.setThirdSysFk(request.getThirdSys());
|
||||
BaseResponse<PageSimpleResponse<ThrManufacturerEntity>> baseResponse = erpBasicClient.getThrManu(request);
|
||||
if (baseResponse.getCode() == 20000) {
|
||||
List<ThrManufacturerEntity> list = baseResponse.getData().getList();
|
||||
list.forEach(thrCorpsResponse -> {
|
||||
ThrManufacturerEntity thrCorpEntity = thrManufacturerMapper.selectByUnitIdAndThirdId(thrCorpsResponse.getUnitId(), request.getThirdSys());
|
||||
if (null == thrCorpEntity) {
|
||||
thrCorpEntity = new ThrManufacturerEntity();
|
||||
BeanUtils.copyProperties(thrCorpsResponse, thrCorpEntity);
|
||||
thrCorpEntity.setCreateTime(new Date());
|
||||
thrCorpEntity.setUpdateTime(new Date());
|
||||
thrCorpEntity.setThirdSysFk(request.getThirdSys());
|
||||
thrCorpEntity.setId(IdUtil.getSnowflakeNextId());
|
||||
thrManufacturerMapper.insert(thrCorpEntity);
|
||||
} else {
|
||||
boolean isChange = verifyDataChange(thrCorpEntity, thrCorpsResponse);
|
||||
if (isChange) {
|
||||
thrCorpEntity.setUpdateTime(new Date());
|
||||
thrManufacturerMapper.updateById(thrCorpEntity);
|
||||
}
|
||||
}
|
||||
});
|
||||
if (list.size() >= limit) {
|
||||
page++;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
return baseResponse;
|
||||
}
|
||||
}
|
||||
|
||||
return ResultVOUtils.success("下载完成");
|
||||
}
|
||||
|
||||
private boolean verifyDataChange(ThrManufacturerEntity thrCorpEntity, ThrManufacturerEntity thrCorpsResponse) {
|
||||
ThrManufacturerEntity oldData = new ThrManufacturerEntity();
|
||||
BeanUtils.copyProperties(thrCorpEntity, oldData);
|
||||
thrCorpEntity.setSpell(thrCorpsResponse.getSpell());
|
||||
thrCorpEntity.setAddr(thrCorpsResponse.getAddr());
|
||||
thrCorpEntity.setContact(thrCorpsResponse.getCreditNo());
|
||||
thrCorpEntity.setContact(thrCorpsResponse.getContact());
|
||||
thrCorpEntity.setMobile(thrCorpsResponse.getMobile());
|
||||
thrCorpEntity.setName(thrCorpsResponse.getName());
|
||||
thrCorpEntity.setRemark(thrCorpsResponse.getRemark());
|
||||
return !thrCorpEntity.equals(oldData);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
<?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.thrsys.ThrManufacturerMapper">
|
||||
<select id="filterThrManu" parameterType="com.glxp.api.req.thrsys.FilterThrCorpRequest"
|
||||
resultType="com.glxp.api.entity.thrsys.ThrManufacturerEntity">
|
||||
SELECT *
|
||||
FROM thr_manufacturer
|
||||
<where>
|
||||
<if test="unitId != '' and unitId != null">
|
||||
AND unitId like concat('%', #{unitId}, '%')
|
||||
</if>
|
||||
<if test="name != '' and name != null">
|
||||
AND (name LIKE concat('%', #{name}, '%') or spell LIKE concat('%', #{name}, '%'))
|
||||
</if>
|
||||
<if test="thirdSysFk != '' and thirdSysFk != null">
|
||||
AND thirdSysFk = #{thirdSysFk}
|
||||
</if>
|
||||
<if test="lastUpdateTime != null and lastUpdateTime != ''">
|
||||
<![CDATA[
|
||||
and DATE_FORMAT(updateTime, '%Y-%m-%d %H:%i:%S') >= DATE_FORMAT(#{lastUpdateTime}, '%Y-%m-%d %H:%i:%S')
|
||||
]]>
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY updateTime DESC
|
||||
</select>
|
||||
|
||||
|
||||
<select id="selectByUnitIdAndThirdId" resultType="com.glxp.api.entity.thrsys.ThrManufacturerEntity">
|
||||
select id,
|
||||
spell,
|
||||
addr,
|
||||
creditNo,
|
||||
contact,
|
||||
mobile,
|
||||
name,
|
||||
remark
|
||||
from thr_manufacturer
|
||||
<where>
|
||||
<if test="unitId != null and unitId != ''">
|
||||
AND unitId = #{unitId}
|
||||
</if>
|
||||
<if test="thirdId != null and thirdId != ''">
|
||||
AND thirdSysFk = #{thirdId}
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
</mapper>
|
Loading…
Reference in New Issue