Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
db37e17d50
|
@ -0,0 +1,136 @@
|
|||
package shkd.cosmic.cxkg.task;
|
||||
|
||||
import cn.hutool.http.HttpRequest;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import kd.bos.context.RequestContext;
|
||||
import kd.bos.dataentity.OperateOption;
|
||||
import kd.bos.dataentity.entity.DynamicObject;
|
||||
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
||||
import kd.bos.entity.operate.result.OperationResult;
|
||||
import kd.bos.exception.KDException;
|
||||
import kd.bos.orm.query.QCP;
|
||||
import kd.bos.orm.query.QFilter;
|
||||
import kd.bos.schedule.executor.AbstractTask;
|
||||
import kd.bos.servicehelper.BusinessDataServiceHelper;
|
||||
import kd.bos.servicehelper.operation.OperationServiceHelper;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import shkd.cosmic.cxkg.task.DTO.Query;
|
||||
import shkd.cosmic.cxkg.task.DTO.QueryDTO;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.*;
|
||||
|
||||
public class CostCenterTaskImpl extends AbstractTask {
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(HrmDepartmentTaskImpl.class);
|
||||
private static final int PAGESIZE = 20;
|
||||
private int CURPAGE = 1;
|
||||
|
||||
private String base_custom_data = "field0,field1";
|
||||
|
||||
@Override
|
||||
public void execute(RequestContext requestContext, Map<String, Object> map) throws KDException {
|
||||
//构造请求体
|
||||
QueryDTO queryDTO = new QueryDTO();
|
||||
queryDTO.setPagesize(PAGESIZE);
|
||||
queryDTO.setCurpage(CURPAGE);
|
||||
queryDTO.setBase_custom_data(base_custom_data);
|
||||
|
||||
Query query = new Query();
|
||||
query.setQueryDTO(queryDTO);
|
||||
|
||||
Object isFull = map.get("isfull");//判断是否全量。
|
||||
if ("0".equals(isFull)) {//判断是否全量,不是则设置时间戳参数
|
||||
Calendar calendar = Calendar.getInstance();// 获取当前日期
|
||||
calendar.set(Calendar.HOUR_OF_DAY, 0);
|
||||
calendar.set(Calendar.MINUTE, 0);
|
||||
calendar.set(Calendar.SECOND, 0);
|
||||
Long time = calendar.getTimeInMillis();
|
||||
queryDTO.setCreated(time.toString());
|
||||
}
|
||||
|
||||
//创建人员对应成本中心集合
|
||||
HashMap<String, String> orgMap = new HashMap<>();
|
||||
|
||||
JSONObject data = this.getOAUserData(query);
|
||||
this.importOrgMap(orgMap,data);//填充人员数据(人员编码,成本中心编码)
|
||||
BigDecimal totalSize = data.getBigDecimal("totalSize");//获取查询到人员总数;
|
||||
BigDecimal size = new BigDecimal(PAGESIZE);//设置页大小为20
|
||||
BigDecimal pageNumber = totalSize.divide(size, 0, RoundingMode.UP);//计算需要分页数量
|
||||
|
||||
//判断分页数量是否大于1,是则进行遍历后续数据
|
||||
if (pageNumber.compareTo(new BigDecimal(1)) > 0) {//当页数为1时,不需要再次查询接口直接去同步数据
|
||||
for (int i = 1; i < pageNumber.intValue(); i++){//查询成功取第一轮数据同步
|
||||
//修改CURPAGE当前页数
|
||||
CURPAGE = i + 1;
|
||||
queryDTO.setCurpage(CURPAGE);
|
||||
JSONObject dataNext = this.getOAUserData(query);//获取查询的数据
|
||||
this.importOrgMap(orgMap,dataNext);//填充人员数据(人员编码,成本中心编码)
|
||||
}
|
||||
}
|
||||
OperateOption option = OperateOption.create();
|
||||
if (!orgMap.isEmpty()){
|
||||
Set<String> keys = orgMap.keySet();
|
||||
for (String key : keys) {
|
||||
QFilter userQF = new QFilter("number", QCP.equals, key);
|
||||
DynamicObject bos_user = BusinessDataServiceHelper.loadSingle("bos_user", userQF.toArray());//查找星瀚对应人员
|
||||
if (bos_user != null){//当人员数据不为空时
|
||||
String costNumber = orgMap.get(key);//对应的成本中心编码
|
||||
QFilter costQFr = new QFilter("number", QCP.equals, costNumber);
|
||||
DynamicObject bos_costCenter = BusinessDataServiceHelper.loadSingle("bos_costcenter", costQFr.toArray());
|
||||
if (bos_costCenter != null){//当成本中心不为空时
|
||||
//获取用户的成本中心信息分录
|
||||
DynamicObjectCollection costEntity = bos_user.getDynamicObjectCollection("shkd_costentity");
|
||||
//首先遍历移除已存在的来源为泛微的数据
|
||||
for (int i = 0;i < costEntity.size();i++){
|
||||
DynamicObject dynamicObject = costEntity.get(i);
|
||||
String shkd_e_source = dynamicObject.getString("shkd_e_source");
|
||||
if ("B".equals(shkd_e_source)){
|
||||
int index = costEntity.indexOf(dynamicObject);
|
||||
costEntity.remove(index);
|
||||
}
|
||||
}
|
||||
DynamicObject newObject = costEntity.addNew();
|
||||
newObject.set("shkd_e_cost",bos_costCenter);
|
||||
newObject.set("shkd_e_source","B");
|
||||
OperationResult operationResult = OperationServiceHelper.executeOperate("save", "bos_user", new DynamicObject[]{bos_user}, option);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private JSONObject getOAUserData(Query query) {
|
||||
String requestBody = JSON.toJSONString(query);
|
||||
//返回参数
|
||||
String json = HttpRequest.post("http://" + "10.157.226.9:8088" + "/api/hrm/resful/getHrmUserInfoWithPage").body(requestBody).execute().body();
|
||||
JSONObject resultJson = JSONObject.parseObject(json);;//查询oa接口返回人员数据
|
||||
String code = resultJson.getString("code");//第一次执行查询,判断接口调用是否成功,否则不执行后续逻辑
|
||||
if (!Objects.equals("1",code)){//当code不为1时,调用失败
|
||||
logger.info("调用接口失败"+resultJson.getString("msg"));
|
||||
return null;
|
||||
}
|
||||
JSONObject data = resultJson.getJSONObject("data");
|
||||
return data ;
|
||||
}
|
||||
|
||||
private void importOrgMap(HashMap<String, String> orgMap,JSONObject data){
|
||||
JSONArray dataList = data.getJSONArray("dataList");//oa人员数据集合
|
||||
for (int i = 0; i < dataList.size(); i++) {
|
||||
JSONObject userData = dataList.getJSONObject(i);
|
||||
JSONObject base_custom_data = userData.getJSONObject("base_custom_data");
|
||||
if (base_custom_data != null){
|
||||
String field0 = base_custom_data.getString("field0");
|
||||
if (!"".equals(field0)){
|
||||
orgMap.put(userData.getString("workcode"),field0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -40,6 +40,8 @@ public class UserTaskImpl extends AbstractTask {
|
|||
private static Logger logger = LoggerFactory.getLogger(HrmDepartmentTaskImpl.class);
|
||||
private static final int PAGESIZE = 20;
|
||||
private int CURPAGE = 1;
|
||||
|
||||
private String base_custom_data = "field0,field1";
|
||||
private DynamicObjectCollection queryOrges;
|
||||
|
||||
static boolean flag = false; //判断当前用户集合是否存在需要设置的用户还没存入系统的情况
|
||||
|
@ -53,6 +55,7 @@ public class UserTaskImpl extends AbstractTask {
|
|||
QueryDTO queryDTO = new QueryDTO();
|
||||
queryDTO.setPagesize(PAGESIZE);
|
||||
queryDTO.setCurpage(CURPAGE);
|
||||
queryDTO.setBase_custom_data(base_custom_data);
|
||||
Query query = new Query();
|
||||
query.setQueryDTO(queryDTO);
|
||||
|
||||
|
@ -70,10 +73,17 @@ public class UserTaskImpl extends AbstractTask {
|
|||
if(data != null) {
|
||||
//查询当前星瀚人员id集合
|
||||
DynamicObjectCollection queryUsers = QueryServiceHelper.query("bos_user",
|
||||
"id,number,shkd_oaid", null);//查询星瀚系统部门集合
|
||||
"id,number,shkd_oaid", null);//查询星瀚系统人员集合
|
||||
Map<Object, Long> userIds = new HashMap<Object, Long>();//存放系统中已经存在的用户id集合
|
||||
for (DynamicObject queryUser : queryUsers) {
|
||||
userIds.put(queryUser.getString("number"), queryUser.getLong("id"));//存放已经存在的人员的id以及number
|
||||
userIds.put(queryUser.getString("shkd_oaid"), queryUser.getLong("id"));//存放已经存在的人员的id以及number
|
||||
}
|
||||
|
||||
DynamicObjectCollection queryOrges = QueryServiceHelper.query("bos_adminorg",
|
||||
"id,number", null);//查询星瀚部门集合
|
||||
Map<Object, Long> orgIds = new HashMap<Object, Long>();//存放系统中已经存在的行政组织id集合
|
||||
for (DynamicObject queryOrge : queryOrges) {
|
||||
orgIds.put(queryOrge.getString("number"), queryOrge.getLong("id"));//存放已经存在的部门的id以及number
|
||||
}
|
||||
|
||||
List<UserParam> paramList = new ArrayList<>();//创建存放人员类的集合
|
||||
|
@ -83,7 +93,7 @@ public class UserTaskImpl extends AbstractTask {
|
|||
BigDecimal size = new BigDecimal(PAGESIZE);//设置页大小为20
|
||||
BigDecimal pageNumber = totalSize.divide(size, 0, RoundingMode.UP);//计算需要分页数量
|
||||
//查询成功取第一轮数据添加入参数集合
|
||||
this.buildUserParam(paramList, dataList, userIds);
|
||||
this.buildUserParam(paramList, dataList, userIds,orgIds);
|
||||
|
||||
//判断分页数量是否大于1,是则进行遍历后续数据
|
||||
if (pageNumber.compareTo(new BigDecimal(1)) > 0) {//当页数为1时,不需要再次查询接口直接去同步数据
|
||||
|
@ -92,7 +102,7 @@ public class UserTaskImpl extends AbstractTask {
|
|||
CURPAGE = i + 1;
|
||||
queryDTO.setCurpage(CURPAGE);
|
||||
JSONObject dataNext = this.getOAUserData(query);//获取查询的数据
|
||||
this.buildUserParam(paramList,dataNext.getJSONArray("dataList"),userIds);
|
||||
this.buildUserParam(paramList,dataNext.getJSONArray("dataList"),userIds,orgIds);
|
||||
}
|
||||
}
|
||||
UserServiceHelper.addOrUpdate(paramList);
|
||||
|
@ -112,7 +122,7 @@ public class UserTaskImpl extends AbstractTask {
|
|||
paramList.clear();
|
||||
userIds.clear();
|
||||
queryUsers = QueryServiceHelper.query("bos_user",
|
||||
"id,number,shkd_oaid", null);//查询星瀚系统部门集合
|
||||
"id,number,shkd_oaid", null);//查询星瀚系统人员集合
|
||||
userIds = new HashMap<Object, Long>();//存放系统中已经存在的用户id集合
|
||||
for (DynamicObject queryUser : queryUsers) {
|
||||
userIds.put(queryUser.getString("shkd_oaid"), queryUser.getLong("id"));//存放已经存在的人员的id以及number
|
||||
|
@ -121,7 +131,7 @@ public class UserTaskImpl extends AbstractTask {
|
|||
CURPAGE = i ;
|
||||
queryDTO.setCurpage(CURPAGE);
|
||||
JSONObject dataNext = this.getOAUserData(query);//获取查询的数据
|
||||
this.buildUserParam(paramList,dataNext.getJSONArray("dataList"),userIds);
|
||||
this.buildUserParam(paramList,dataNext.getJSONArray("dataList"),userIds,orgIds);
|
||||
}
|
||||
UserServiceHelper.addOrUpdate(paramList);//新增或更新全量数据
|
||||
for (UserParam userParam : paramList) {
|
||||
|
@ -151,11 +161,11 @@ public class UserTaskImpl extends AbstractTask {
|
|||
return data ;
|
||||
}
|
||||
|
||||
private void buildUserParam(List<UserParam> paramList,JSONArray dataList,Map<Object,Long> userIds) {
|
||||
private void buildUserParam(List<UserParam> paramList,JSONArray dataList,Map<Object,Long> userIds,Map<Object, Long> orgIds) {
|
||||
for (int i = 0; i < dataList.size(); i++) {
|
||||
UserParam user = new UserParam();
|
||||
JSONObject userData = dataList.getJSONObject(i);
|
||||
Long workid = userIds.get(userData.getString("workcode"));
|
||||
Long workid = userIds.get(userData.getString("id"));
|
||||
if (workid != null){
|
||||
user.setId(workid);
|
||||
user.setCustomUserId(workid);
|
||||
|
@ -170,6 +180,12 @@ public class UserTaskImpl extends AbstractTask {
|
|||
dataMap.put("birthday", userData.getDate("birthday"));//生日
|
||||
dataMap.put("gender", "男" .equals(userData.getString("sex")) ? "1" : "2"); //性别
|
||||
dataMap.put("shkd_oaid",userData.getString("id"));
|
||||
JSONObject base_custom_data = userData.getJSONObject("base_custom_data");
|
||||
String field1= base_custom_data.getString("field1");
|
||||
if (!"".equals(field1)){
|
||||
dataMap.put("shkd_labororg",orgIds.get(field1));
|
||||
}
|
||||
|
||||
|
||||
// 职位分
|
||||
if(workid == null){//若人不存在则更新部门
|
||||
|
@ -184,7 +200,7 @@ public class UserTaskImpl extends AbstractTask {
|
|||
entryentity.put("position", userData.getString("jobactivityname")); // 职位
|
||||
entryentity.put("isincharge", false); //负责人
|
||||
entryentity.put("ispartjob", false); //兼职
|
||||
String managerId_oa = userData.getString("managerid");//获取上级人员id(oa)
|
||||
String managerId_oa = userData.getString("managerid");//获取上级人员id(oa)
|
||||
Long managerId = userIds.get(managerId_oa);//直接上级id
|
||||
if (managerId != null){
|
||||
entryentity.put("superior", managerId); // 赋值直接上级
|
||||
|
|
|
@ -41,7 +41,7 @@ import java.util.stream.Collectors;
|
|||
*/
|
||||
public class ContractBillPopFormPlugin extends AbstractFormPlugin implements Plugin {
|
||||
private static final Log log = LogFactory.getLog(ContractBillPopFormPlugin.class);
|
||||
public static final String ATTACH_KEY = "shkd_attachmentpanelap"; // 动态表单的附件面板标识 - 根据情况修改
|
||||
public static final String ATTACH_KEY = "shkd_attachmentpanelap6"; // 动态表单的附件面板标识 - 根据情况修改
|
||||
|
||||
|
||||
@Override
|
||||
|
@ -87,7 +87,7 @@ public class ContractBillPopFormPlugin extends AbstractFormPlugin implements Plu
|
|||
|
||||
private void doUpload() {
|
||||
String entityNumber = "er_contractbill";//当前单据实体编码
|
||||
String attKey = "zc88_attachmentpanelap"; // 单据面板标识 attachmentpanel
|
||||
String attKey = "shkd_attachmentpanelap"; // 单据面板标识 attachmentpanel
|
||||
AttachmentPanel attachmentPanel = getControl(ATTACH_KEY);
|
||||
List<Map<String, Object>> attachmentData = attachmentPanel.getAttachmentData();
|
||||
if (attachmentData.size() == 0) {
|
||||
|
|
|
@ -3,6 +3,8 @@ package shkd.fi.er.plugin.formplugin;
|
|||
import kd.bos.bill.AbstractBillPlugIn;
|
||||
import kd.bos.dataentity.entity.DynamicObject;
|
||||
import kd.bos.dataentity.entity.DynamicObjectCollection;
|
||||
import kd.bos.entity.datamodel.events.ChangeData;
|
||||
import kd.bos.entity.datamodel.events.PropertyChangedArgs;
|
||||
import kd.bos.form.field.BasedataEdit;
|
||||
import kd.bos.form.field.events.BeforeF7SelectEvent;
|
||||
import kd.bos.form.field.events.BeforeF7SelectListener;
|
||||
|
@ -95,6 +97,22 @@ public class CommonCostCenterBillFormPlugin extends AbstractBillPlugIn implement
|
|||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void propertyChanged(PropertyChangedArgs e) {
|
||||
super.propertyChanged(e);
|
||||
if(payList.contains(entityId)){
|
||||
String name = e.getProperty().getName();//获取变更字段
|
||||
if("costcompany".equals(name)){
|
||||
DynamicObject applier = (DynamicObject) this.getModel().getValue("applier");
|
||||
if (applier != null){
|
||||
DynamicObject bos_user = BusinessDataServiceHelper.loadSingle(applier.getPkValue(), "bos_user");
|
||||
DynamicObject shkd_labororg = bos_user.getDynamicObject("shkd_labororg");
|
||||
this.getModel().setValue("paycompany",shkd_labororg);//设置支付公司为申请人员上的劳动主体
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 费用明细分录的成本中心只能选择申请人员上存在的成本中心
|
||||
* @param beforeF7SelectEvent
|
||||
|
|
Loading…
Reference in New Issue