添加企业同步定时任务

main
吴顺杰 6 months ago
parent 1a978f7a8a
commit 014ea0ba3b

@ -1,11 +1,11 @@
package com.mudu.entity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.mudu.entity.dto.response.EnterpriseResponse;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import lombok.Data;
import java.io.Serializable;
import java.text.NumberFormat;
@ -18,8 +18,7 @@ import java.util.Date;
* @author wu
* @since 2024-02-26 10:43:24
*/
@Getter
@Setter
@Data
@ApiModel("实体类")
@TableName(value = "a_safe_qyjcxx")
public class ASafeQyjcxx implements Serializable {
@ -562,8 +561,12 @@ public class ASafeQyjcxx implements Serializable {
@ApiModelProperty(value = "科达企业编号,用来对照")
private String kdqybh;
public ASafeQyjcxx() {
}
/**
*
*/
@TableField(exist = false)
private ASafeWgcy aSafeWgcy;
public ASafeQyjcxx(EnterpriseResponse res) {

@ -0,0 +1,111 @@
package com.mudu.entity;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* (ASafeWgcy)
*
* @author wu
* @since 2024-08-24 18:14:06
*/
@Data
@ApiModel("实体类")
@TableName(value = "a_safe_wgcy")
public class ASafeWgcy implements Serializable {
private static final long serialVersionUID = -54375539799721806L;
private String xxbh;
/**
*
*/
@ApiModelProperty(value = "人员编号")
private String rybh;
/**
*
*/
@ApiModelProperty(value = "人员姓名")
private String ryxm;
/**
*
*/
@ApiModelProperty(value = "固定电话")
private String gddh;
/**
*
*/
@ApiModelProperty(value = "人员职务")
private String ryzw;
/**
*
*/
@ApiModelProperty(value = "电子邮箱")
private String dzyx;
/**
*
*/
@ApiModelProperty(value = "移动电话")
private String yddh;
/**
*
*/
@ApiModelProperty(value = "父级编号")
private String pid;
/**
* 1,2
*/
@ApiModelProperty(value = "1,网格成员2企业专职安全员")
private Integer rylx;
/**
*
*/
@ApiModelProperty(value = "记录状态")
private Integer jlzt;
/**
*
*/
@ApiModelProperty(value = "显示顺序")
private Integer xssx;
/**
*
*/
@ApiModelProperty(value = "入库人员")
private String rkry;
/**
*
*/
@ApiModelProperty(value = "更新时间")
private String gxry;
/**
*
*/
@ApiModelProperty(value = "入库时间")
private Date rksj;
/**
*
*/
@ApiModelProperty(value = "更新时间")
private Date gxsj;
}

@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.mudu.entity.ASafeQyjcxx;
import org.apache.ibatis.annotations.Param;
import java.util.List;
/**
* (ASafeQyjcxx)访
*
@ -20,5 +22,12 @@ public interface ASafeQyjcxxMapper extends BaseMapper<ASafeQyjcxx> {
* @return
*/
ASafeQyjcxx findOneByqymcOrXybm(@Param("qymc") String qymc, @Param("xybm") String xybm);
/**
*
*
* @param list
*/
void updateByTyshxybm(List<String> list);
}

@ -0,0 +1,15 @@
package com.mudu.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.mudu.entity.ASafeWgcy;
/**
* (ASafeWgcy)访
*
* @author wu
* @since 2024-08-24 18:14:06
*/
public interface ASafeWgcyMapper extends BaseMapper<ASafeWgcy> {
}

@ -12,23 +12,17 @@ import com.mudu.entity.ASafeQyjcxx;
import com.mudu.entity.ASafeQyzypgl;
import com.mudu.entity.dto.request.ASafeBqbhpxRequest;
import com.mudu.entity.dto.request.ASafeQyzypglRequest;
import com.mudu.entity.dto.response.EnterpriseResponse;
import com.mudu.entity.dto.response.XcTpResponse;
import com.mudu.service.ASafeBqbhpxService;
import com.mudu.service.ASafeQyjcxxService;
import com.mudu.service.ASafeQyzypglService;
import com.mudu.service.EnterpriseService;
import com.mudu.service.impl.LoginService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.util.ArrayList;

@ -0,0 +1,97 @@
package com.mudu.quartz;
import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpRequest;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.mudu.entity.ASafeQyjcxx;
import com.mudu.entity.ASafeWgcy;
import com.mudu.service.ASafeQyjcxxService;
import com.mudu.service.ASafeWgcyService;
import com.mudu.service.impl.LoginService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.Resource;
import java.util.List;
import java.util.stream.Collectors;
/**
*
*
* @author wu
* @since 2024/8/24 18:11
*/
@Transactional(rollbackFor = Exception.class)
@Configuration
@EnableScheduling
public class EntQuartz {
@Resource
private ASafeQyjcxxService qyjcxxService;
@Resource
private ASafeWgcyService wgcyService;
@Resource
private LoginService loginService;
@Value("${addEntUrl}")
private String addEntUrl;
@Value("${findEntDelUrl}")
private String findEntDelUrl;
private String getToken() {
return "Bearer " + loginService.getToken();
}
/**
*
*/
@Scheduled(cron = "0 30 12 * * ? ")
public void addqyjcxxAndWgcy() {
// 获取token
String token = getToken();
// 获取所有信息
String res = HttpRequest.get(addEntUrl)
.contentType("application/x-www-form-urlencoded;charset=UTF-8")
.header("Authorization", token)
.execute().body();
JSONObject resObj = JSON.parseObject(res);
String dataList = resObj.getString("data");
if (StrUtil.isEmpty(dataList)) {
return;
}
List<ASafeQyjcxx> qyjcxxList = JSON.parseArray(dataList, ASafeQyjcxx.class);
qyjcxxService.saveBatch(qyjcxxList);
List<ASafeWgcy> wgcyList = qyjcxxList.stream().map(ASafeQyjcxx::getASafeWgcy).collect(Collectors.toList());
wgcyService.saveBatch(wgcyList);
}
/**
*
*/
@Scheduled(cron = "0 30 12 * * ? ")
public void findEntDel() {
// 获取token
String token = getToken();
// 获取所有信息
String res = HttpRequest.get(findEntDelUrl)
.contentType("application/x-www-form-urlencoded;charset=UTF-8")
.header("Authorization", token)
.execute().body();
JSONObject resObj = JSON.parseObject(res);
String dataList = resObj.getString("data");
if (StrUtil.isEmpty(dataList)) {
return;
}
List<String> tyshxybmList = JSON.parseArray(dataList, String.class);
qyjcxxService.updateByTyshxybm(tyshxybmList);
}
}

@ -3,6 +3,8 @@ package com.mudu.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.mudu.entity.ASafeQyjcxx;
import java.util.List;
/**
* (ASafeQyjcxx)
*
@ -24,5 +26,12 @@ public interface ASafeQyjcxxService extends IService<ASafeQyjcxx> {
* @return
*/
ASafeQyjcxx findOneByqymcOrXybm(String qymc, String xybm);
/**
*
*
* @param tyshxybmList
*/
void updateByTyshxybm(List<String> tyshxybmList);
}

@ -0,0 +1,15 @@
package com.mudu.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.mudu.entity.ASafeWgcy;
/**
* (ASafeWgcy)
*
* @author wu
* @since 2024-08-24 18:14:06
*/
public interface ASafeWgcyService extends IService<ASafeWgcy> {
}

@ -15,7 +15,6 @@ import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
/**
* (ASafeQyjcxx)
@ -86,5 +85,15 @@ public class ASafeQyjcxxServiceImpl extends ServiceImpl<ASafeQyjcxxMapper, ASafe
public ASafeQyjcxx findOneByqymcOrXybm(String qymc, String xybm) {
return baseMapper.findOneByqymcOrXybm(qymc, xybm);
}
/**
*
*
* @param tyshxybmList
*/
@Override
public void updateByTyshxybm(List<String> tyshxybmList) {
baseMapper.updateByTyshxybm(tyshxybmList);
}
}

@ -0,0 +1,19 @@
package com.mudu.service.impl;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mudu.entity.ASafeWgcy;
import com.mudu.mapper.ASafeWgcyMapper;
import com.mudu.service.ASafeWgcyService;
import org.springframework.stereotype.Service;
/**
* (ASafeWgcy)
*
* @author wu
* @since 2024-08-24 18:14:07
*/
@Service("aSafeWgcyService")
public class ASafeWgcyServiceImpl extends ServiceImpl<ASafeWgcyMapper, ASafeWgcy> implements ASafeWgcyService {
}

@ -59,3 +59,9 @@ xczqUrl: https://www.jichuanglanhai.com:88/csapi/mudu/aSafeXcrwRead/getByxxbh
#停复工url
tfgUrl: https://www.jichuanglanhai.com:88/csapi/mudu/aSafeTfg
# 获取新增企业信息
addEntUrl: https://www.jichuanglanhai.com:88/csapi/mudu/enterprise/findAddEnt
# 获取删除企业信息
findEntDelUrl: https://www.jichuanglanhai.com:88/csapi/mudu/enterprise/findEntDel

@ -63,4 +63,10 @@ xczqUrl: https://www.jichuanglanhai.com:88/csapi/mudu/aSafeXcrwRead/getByxxbh
#停复工url
tfgUrl: https://www.jichuanglanhai.com:88/csapi/mudu/aSafeTfg
# 获取新增企业信息
addEntUrl: https://www.jichuanglanhai.com:88/csapi/mudu/enterprise/findAddEnt
# 获取删除企业信息
findEntDelUrl: https://www.jichuanglanhai.com:88/csapi/mudu/enterprise/findEntDel

@ -3,6 +3,14 @@
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.mudu.mapper.ASafeQyjcxxMapper">
<update id="updateByTyshxybm">
update a_safe_qyjcxx set jlzt = 0 where
tyshxybm in
<foreach item="item" index="index" collection="list"
open="(" separator="," close=")">
#{item}
</foreach>
</update>
<select id="findOneByqymcOrXybm" resultType="com.mudu.entity.ASafeQyjcxx">

Loading…
Cancel
Save