dev
ic_excellent 2023-07-24 16:55:24 +08:00
parent dedfee53c1
commit 25c729783d
11 changed files with 402 additions and 14 deletions

View File

@ -47,19 +47,20 @@ public class ReportService {
String whereSql = " and (frhsz = 0 or frhsz is null) ";
if(!"".equals(beginDate) && !"".equals(endDate)){
whereSql += " and (dlsk1 between #{param.beginDate} and #{param.endDate} )";
}else {
param.put("today", TimeUtil.getCurrentDateString());
whereSql += " and dlsk1 >= #{param.today} ";
}
if(!"".equals(registrationPeople)){
whereSql += " and dyjbr = #{param.registrationPeople} ";
}
if(!"".equals(flightAndTrain)){
whereSql += " and hbcc = #{param.flightAndTrain} ";
whereSql += " and hbcc like '%"+flightAndTrain+"%' ";
}
if(!"".equals(project)){
//whereSql += " and exits (select 1 from uf_zwfwdjjmb_dt1 where mainid = main.id and ysdx = #{param.project}) ";
whereSql += " and exits (select 1 from uf_zwfwdjjmb_dt1 where mainid = main.id and wb like '%$t{param.project}%') ";
whereSql += " and exits (select 1 from uf_zwfwdjjmb_dt1 where mainid = main.id and wb like '%"+project+"%') ";
}
if(("".equals(beginDate) || "".equals(endDate)) && "".equals(registrationPeople) && "".equals(flightAndTrain)){
param.put("today", TimeUtil.getCurrentDateString());
whereSql += " and dlsk1 >= #{param.today} ";
}
whereSql = whereSql.replaceFirst(" and "," where ");
return whereSql;

View File

@ -20,7 +20,7 @@ public interface GenerateMapper {
* @return
*/
@Update("update uf_contract_num_log set workflow_info = #{workflowInfo},file_info = #{fileInfo},detail_id = #{detailId}," +
"row_id = #{rowId},contract_name = #{contractName},contract_num = #{contractNum},flow_num = #{flowNum},contract_month = #{contractMonth} where id = #{dataId}")
"row_id = #{rowId},contract_name = #{contractName},contract_num = #{contractNum},flow_num = #{flowNum},contract_month = #{contractMonth},contract_year = #{contractYear} where id = #{dataId}")
boolean updateContractLog(Map<String,Object> param);
/**
@ -34,8 +34,8 @@ public interface GenerateMapper {
* <h2></h2>
* @return
*/
@Select("select max(flow_num) from uf_contract_num_log where contract_month = #{month}")
int getMaxFlowByMonth(@ParamMapper("month")int month);
@Select("select max(flow_num) from uf_contract_num_log where contract_month = #{month} and contract_year = {year}")
int getMaxFlowByMonth(@ParamMapper("month")int month,@ParamMapper("year")int year);
/**
* <h2></h2>

View File

@ -32,8 +32,9 @@ public class GenerateContractNoService {
public String generateCode(Map<String,Object> param){
Calendar calendar = Calendar.getInstance();
int month = calendar.get(Calendar.MONTH);
int year = calendar.get(Calendar.YEAR);
//int maxFlow = generateMapper.getMaxFlow();
int maxFlow = generateMapper.getMaxFlowByMonth(month);
int maxFlow = generateMapper.getMaxFlowByMonth(month,year);
maxFlow = Math.max(maxFlow,0);
maxFlow++;
String contractNo = "";
@ -52,6 +53,7 @@ public class GenerateContractNoService {
param.put("contractNum",contractNo);
param.put("flowNum",maxFlow);
param.put("contractMonth",month);
param.put("contractYear",year);
boolean updateFlag = generateMapper.updateContractLog(param);
Util.rebuildModeDataShareByAsync(1,TABLE_NAME,dataId);
if(updateFlag){

View File

@ -0,0 +1,52 @@
package weaver.bokang.xiao.zxyh.depart_sync.entity;
import lombok.Data;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
/**
* Depart
*
* @Author
* @Date 2023/7/21 11:11
* @Description
**/
@Data
@XmlRootElement(name = "dept")
@XmlAccessorType(XmlAccessType.FIELD)
public class Depart {
private int id;
/**
*
*/
private String deptName;
/**
* ID
*/
private int deptId;
/**
*
*/
private String systemType;
/**
*
*/
private String systemCode;
/**
*
*/
private String businessName;
/**
* ID
*/
private String businessId;
}

View File

@ -0,0 +1,72 @@
package weaver.bokang.xiao.zxyh.depart_sync.entity;
import lombok.Data;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlRootElement;
import java.util.List;
/**
* DepartVO
*
* @Author
* @Date 2023/7/21 11:10
* @Description
**/
@Data
@XmlRootElement(name = "root")
@XmlAccessorType(XmlAccessType.FIELD)
public class DepartVO {
/**
*
*/
private String sender;
/**
*
*/
private String receiver;
/**
*
*/
private String trans;
/**
*
*/
private String serials;
/**
*
*/
private String retCode;
/**
*
*/
private String retmsg;
/**
*
*/
private boolean success;
/**
*
*/
private String message;
/**
*
*/
private int code;
/**
*
*/
@XmlElementWrapper(name = "deptList")
private List<Depart> dept;
}

View File

@ -0,0 +1,56 @@
package weaver.bokang.xiao.zxyh.depart_sync.entity;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlRootElement;
/**
* SendDTO
*
* @Author
* @Date 2023/7/21 11:10
* @Description
**/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@XmlRootElement(name = "root")
@XmlAccessorType(XmlAccessType.FIELD)
public class SendDTO {
/**
*
*/
private String sender;
/**
*
*/
private String receiver;
/**
*
*/
private String trans;
/**
*
*/
private String serials;
/**
*
*/
private String systemCode;
/**
*
*/
private String sendType;
}

View File

@ -0,0 +1,25 @@
package weaver.bokang.xiao.zxyh.depart_sync.mapper;
import aiyh.utils.annotation.recordset.*;
import weaver.bokang.xiao.zxyh.depart_sync.entity.Depart;
import java.util.List;
/**
* @ClassName SyncMapper
* @Author
* @Date 2023/7/21 11:09
* @Description <h1></h1>
**/
@SqlMapper
public interface SyncMapper {
@Select("select * from uf_depart_info")
List<Depart> queryDepartList();
@BatchUpdate("update uf_depart_info set dept_name = #{item.deptName}, dept_id = #{item.deptId}, system_type = #{item.systemType}, system_code = #{item.systemCode}, " +
" business_name= #{item.businessName}, business_id = #{item.businessId} " +
"where id = #{item.id}")
boolean updateDepart(@BatchSqlArgs List<Depart> departList);
}

View File

@ -0,0 +1,110 @@
package weaver.bokang.xiao.zxyh.depart_sync.schedule;
import aiyh.utils.Util;
import aiyh.utils.action.CusBaseCronJob;
import aiyh.utils.annotation.ActionDesc;
import aiyh.utils.annotation.PrintParamMark;
import aiyh.utils.annotation.RequiredMark;
import com.alibaba.fastjson.JSON;
import lombok.Setter;
import weaver.bokang.xiao.zxyh.depart_sync.entity.Depart;
import weaver.bokang.xiao.zxyh.depart_sync.entity.DepartVO;
import weaver.bokang.xiao.zxyh.depart_sync.entity.SendDTO;
import weaver.bokang.xiao.zxyh.depart_sync.mapper.SyncMapper;
import weaver.general.TimeUtil;
import weaver.xiao.commons.utils.RequestUtil;
import weaver.xiao.commons.utils.VerifyUtil;
import java.io.IOException;
import java.util.*;
import java.util.stream.Collectors;
/**
* @ClassName DepartSyncSchedule
* @Author
* @Date 2023/7/21 11:07
* @Description <h1></h1>
**/
@Setter
@ActionDesc(value = "同步总行部门信息", author = "bokang.xiao")
public class DepartSyncSchedule extends CusBaseCronJob {
@RequiredMark("发送请求地址")
@PrintParamMark
private String sendUrl;
@RequiredMark("部门模块ID")
@PrintParamMark
private String departModeId;
@RequiredMark("发送者名称")
@PrintParamMark
private String sender;
@RequiredMark("接收者名称")
@PrintParamMark
private String receiver;
@RequiredMark("传输数据")
@PrintParamMark
private String trans;
@RequiredMark("系统编码")
@PrintParamMark
private String systemCode;
@RequiredMark("发送类型")
@PrintParamMark
private String sendType;
private final SyncMapper syncMapper = Util.getMapper(SyncMapper.class);
@Override
public void runCode() throws IOException {
try {
List<Depart> sourceDepartList = syncMapper.queryDepartList();
Map<Integer, Integer> departMap = new HashMap<>();
if(Objects.nonNull(sourceDepartList) && !sourceDepartList.isEmpty()) {
departMap = sourceDepartList.stream().collect(Collectors.toMap(Depart::getDeptId, Depart::getId));
}
log.info("sync depart departMap ==>"+JSON.toJSONString(departMap));
SendDTO sendDTO = SendDTO.builder()
.sendType(this.sendType)
.sender(this.sender)
.receiver(this.receiver)
.trans(this.trans)
.systemCode(this.systemCode)
.serials(this.sender + TimeUtil.getFormartString(new Date(),"yyyyMMddHHmmSSsss")).build();
log.info("sendDTO =>"+sendDTO);
String sendXml = VerifyUtil.beanToXml(sendDTO);
log.info("depart req param ==>"+sendXml);
String resultXml = RequestUtil.sendToTPCG2(sendXml, sendUrl);
if (!"".equals(resultXml)) {
DepartVO departVO = VerifyUtil.xmlStrToObject(DepartVO.class, resultXml);
log.info("depart List ==>"+ JSON.toJSONString(departVO));
if(!departVO.isSuccess()){
log.error("请求不成功");
return;
}
List<Depart> departList = departVO.getDept();
if(Objects.nonNull(departList) && !departList.isEmpty()){
List<Integer> dataIdList = new ArrayList<>();
for (Depart depart : departList) {
if(departMap.containsKey(depart.getDeptId())){
depart.setId(departMap.get(depart.getDeptId()));
}else {
int dataId = Util.getModeDataId("uf_depart_info", Util.getIntValue(departModeId), 1);
depart.setId(dataId);
dataIdList.add(dataId);
}
}
syncMapper.updateDepart(departList);
Util.rebuildModeDataShareByAsyncList(1,Util.getIntValue(departModeId),dataIdList);
}
}
}catch (Exception e){
log.error("同步发生异常 ==>"+ Util.getErrString(e));
}
}
}

View File

@ -2,6 +2,7 @@ package weaver.xiao.commons.utils;
import com.alibaba.fastjson.JSON;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.commons.io.IOUtils;
import org.apache.http.HttpEntity;
import org.apache.http.client.methods.*;
import org.apache.http.entity.ContentType;
@ -13,12 +14,13 @@ import org.apache.http.util.EntityUtils;
import weaver.wechat.request.HttpManager;
import weaver.xiao.commons.exception.RequestException;
import weaver.zwl.common.ToolUtil;
import weaver.zwl.common.logging.Logger;
import weaver.zwl.common.logging.LoggerFactory;
import javax.ws.rs.core.MediaType;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.io.*;
import java.net.URL;
import java.net.URLConnection;
import java.nio.charset.StandardCharsets;
import java.util.Map;
@ -30,6 +32,8 @@ import java.util.Map;
public class RequestUtil {
private static final Logger logger = LoggerFactory.getLogger();
public static <T> T apiRequest(RequestBaseInfo requestInfo, Class<T> tClass){
Map<String,String> headers = requestInfo.getHeaders();
@ -135,6 +139,50 @@ public class RequestUtil {
return res;
}
public static String sendToTPCG2(String xml, String URL) {
byte[] data = xml.getBytes();
InputStream instr = null;
String res = "";
try {
logger.info("--- 开始调用外联平台接口 url => " + URL + " ---");
java.net.URL url = new URL(URL);
URLConnection urlCon = url.openConnection();
int time = 180000;
urlCon.setConnectTimeout(time);
urlCon.setReadTimeout(time);
urlCon.setDoOutput(true);
urlCon.setDoInput(true);
urlCon.setUseCaches(false);
urlCon.setRequestProperty("content-Type", "application/xml");
urlCon.setRequestProperty("charset", "utf-8");
DataOutputStream printout = new DataOutputStream(
urlCon.getOutputStream());
printout.write(data);
printout.flush();
printout.close();
instr = urlCon.getInputStream();
byte[] bis = IOUtils.toByteArray(instr);
res = new String(bis, StandardCharsets.UTF_8);
if ("".equals(res.trim())) {
throw new RuntimeException("调用 " +URL + " 接口响应为空!");
}
logger.info("外联平台返回信息 => " + res);
return res;
} catch (IOException e) {
logger.info("异常[" + e.getMessage() + "]");
throw new RuntimeException(e.getMessage());
} finally {
try {
if (instr != null) {
instr.close();
}
} catch (IOException e) {
throw new RuntimeException(e.getMessage());
}
}
}
public static String serializableUrl(String url,Map<String,Object> params){
if(params == null || params.isEmpty()){
return url;

View File

@ -130,6 +130,27 @@ public class VerifyUtil {
return xmlStr;
}
public static <T> String beanToXml(T t){
String xmlStr = "";
try {
//1、创建上下文
JAXBContext context = JAXBContext.newInstance(t.getClass());
StringWriter writer = new StringWriter();
//2、创建Marshaller 这个是用于转换成xml的
Marshaller marshaller = context.createMarshaller();
//3、设置marshaller的属性
//JAXB_FORMATTED_OUTPUT格式化
//JAXB_ENCODING:编码格式
// marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
//4、将实体类读取到writer中
marshaller.marshal(t, writer);
xmlStr = writer.toString();
}catch (Exception e){
logger.info("java bean 转换 xml异常 ==>"+LogUtil.getExceptionStr(e));
}
return xmlStr;
}
public static String mapToXml(Map<String, Object> map) {
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append("<?xml version=\"1.0\" encoding=\"UTF-8\" ?>").append("\n").append("<root>").append("\n");

View File

@ -56,6 +56,7 @@ import weaver.bokang.xiao.zscq.action.StatusChangeAction;
import weaver.bokang.xiao.zscq.config.service.ModeChangeService;
import weaver.bokang.xiao.zscq.store.TableNameStore;
import weaver.bokang.xiao.zxyh.RepeatSubmitAction;
import weaver.bokang.xiao.zxyh.depart_sync.schedule.DepartSyncSchedule;
import weaver.conn.RecordSet;
import weaver.general.StaticObj;
import weaver.hrm.User;
@ -85,7 +86,7 @@ public class NormalTest extends BaseTest {
@Test
public void testWord(){
GenerateFileUtil.createCronJobDocument(SyncTeachDataSchedule.class);
GenerateFileUtil.createCronJobDocument(DepartSyncSchedule.class);
//GenerateFileUtil.createActionDocument(DataPushAction.class);
//GenerateFileUtil.createActionDocument(DateFieldUpdateAction.class);
}