POC项目,Action开发
parent
3597676b36
commit
2cd96be4e7
@ -0,0 +1,12 @@
|
||||
package com.api.jclpoc.web;
|
||||
|
||||
import javax.ws.rs.Path;
|
||||
|
||||
/**
|
||||
* @author:dxfeng
|
||||
* @createTime: 2024/04/17
|
||||
* @version: 1.0
|
||||
*/
|
||||
@Path("/jcl/poc/entry")
|
||||
public class PocEntryController extends com.engine.jclpoc.web.PocEntryController{
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
package com.engine.jclpoc.web;
|
||||
|
||||
import cn.hutool.core.convert.Convert;
|
||||
import com.engine.common.util.ParamUtil;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.general.Util;
|
||||
import weaver.hrm.HrmUserVarify;
|
||||
import weaver.hrm.User;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.Context;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author:dxfeng
|
||||
* @createTime: 2024/04/17
|
||||
* @version: 1.0
|
||||
*/
|
||||
public class PocEntryController {
|
||||
@GET
|
||||
@Path("/getStaffInfo")
|
||||
@Produces(MediaType.APPLICATION_JSON)
|
||||
public Map<String, Object> getStaffInfo(@Context HttpServletRequest request, @Context HttpServletResponse response) {
|
||||
Map<String, Object> map = ParamUtil.request2Map(request);
|
||||
Map<String, Object> returnMap = new HashMap<>();
|
||||
returnMap.put("api_status",false);
|
||||
String bm = Util.null2String(map.get("bm"));
|
||||
RecordSet rs = new RecordSet();
|
||||
int staff_num = 0;
|
||||
int permanent_num = 0;
|
||||
int freeze_num = 0;
|
||||
rs.executeQuery("select staff_num,permanent_num,freeze_num from jcl_org_staff a inner join jcl_org_staffplan b on a.plan_id = b.id and b.forbidden_tag = 0 and b.delete_type = 0 where ec_department = ? and a.job_id is null and a.delete_type = 0", bm);
|
||||
if (rs.next()) {
|
||||
staff_num = Convert.toInt(rs.getString("staff_num"), 0);
|
||||
permanent_num = Convert.toInt(rs.getString("permanent_num"), 0);
|
||||
freeze_num = Convert.toInt(rs.getString("freeze_num"), 0);
|
||||
returnMap.put("staff_num", staff_num);
|
||||
returnMap.put("permanent_num", permanent_num);
|
||||
returnMap.put("freeze_num", freeze_num);
|
||||
returnMap.put("num", staff_num - permanent_num - freeze_num);
|
||||
returnMap.put("api_status",true);
|
||||
}
|
||||
|
||||
return returnMap;
|
||||
}
|
||||
}
|
@ -1,119 +0,0 @@
|
||||
package weaver.interfaces.akx.cronjob;
|
||||
|
||||
import weaver.common.DateUtil;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.interfaces.schedule.BaseCronJob;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 安科讯宿舍水电费计算计划任务
|
||||
*
|
||||
* @author:dxfeng
|
||||
* @createTime: 2024/04/10
|
||||
* @version: 1.0
|
||||
*/
|
||||
public class CalculateCostsJob extends BaseCronJob {
|
||||
@Override
|
||||
public void execute() {
|
||||
String currentDate = DateUtil.getCurrentDate();
|
||||
String currentMonth = currentDate.substring(0, 7);
|
||||
RecordSet rs = new RecordSet();
|
||||
try {
|
||||
rs.writeLog("当前日期:" + currentDate + ",水电费计算计划任务开始------");
|
||||
// 查询入住日期<=当前日期,且转出日期>=当前日期,或未转出的数据
|
||||
String sql = "select * from uf_rygl where rzsj <=? and (zcsj >=? or zcsj is null)";
|
||||
rs.executeQuery(sql, currentDate, currentDate);
|
||||
List<PersonnelManagement> personnelManagementList = new ArrayList<>();
|
||||
while (rs.next()) {
|
||||
PersonnelManagement personnelManagement = new PersonnelManagement();
|
||||
personnelManagement.setLd(rs.getString("ld"));
|
||||
personnelManagement.setYg(rs.getString("yg"));
|
||||
personnelManagement.setRzsj(rs.getString("rzsj"));
|
||||
personnelManagement.setZcsj(rs.getString("zcsj"));
|
||||
personnelManagementList.add(personnelManagement);
|
||||
}
|
||||
// 查询当月所有楼栋的水电费标准
|
||||
Map<String, Integer> costMap = new HashMap<>();
|
||||
sql = "select * from uf_sdfbz where yf = ?";
|
||||
rs.executeQuery(sql, currentMonth);
|
||||
while (rs.next()) {
|
||||
costMap.put(rs.getString("yf"), rs.getInt("sdfbz"));
|
||||
}
|
||||
|
||||
// 计算当月的入住天数和费用
|
||||
Map<String, Map<String, List<PersonnelManagement>>> managementMap = personnelManagementList.stream().collect(Collectors.groupingBy(PersonnelManagement::getYg, Collectors.groupingBy(PersonnelManagement::getLd)));
|
||||
|
||||
for (Map.Entry<String, Map<String, List<PersonnelManagement>>> entry : managementMap.entrySet()) {
|
||||
String yg = entry.getKey();
|
||||
Map<String, List<PersonnelManagement>> ldMap = entry.getValue();
|
||||
for (Map.Entry<String, List<PersonnelManagement>> item : ldMap.entrySet()) {
|
||||
String ld = item.getKey();
|
||||
List<PersonnelManagement> ldList = item.getValue();
|
||||
// 计算入住的所有的天数
|
||||
for (PersonnelManagement management : ldList) {
|
||||
|
||||
}
|
||||
// 计算当前人员、当前楼栋的水电费
|
||||
}
|
||||
}
|
||||
|
||||
rs.writeLog("当前日期:" + currentDate + ",水电费计算计划任务结束------");
|
||||
} catch (Exception e) {
|
||||
rs.writeLog("当前日期:" + currentDate + ",水电费计算计划任务异常");
|
||||
rs.writeLog(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 人员管理对象
|
||||
*/
|
||||
private static class PersonnelManagement {
|
||||
// 楼栋
|
||||
private String ld;
|
||||
// 员工
|
||||
private String yg;
|
||||
// 入住日期
|
||||
private String rzsj;
|
||||
// 转出日期
|
||||
private String zcsj;
|
||||
|
||||
public String getLd() {
|
||||
return ld;
|
||||
}
|
||||
|
||||
public void setLd(String ld) {
|
||||
this.ld = ld;
|
||||
}
|
||||
|
||||
public String getYg() {
|
||||
return yg;
|
||||
}
|
||||
|
||||
public void setYg(String yg) {
|
||||
this.yg = yg;
|
||||
}
|
||||
|
||||
public String getRzsj() {
|
||||
return rzsj;
|
||||
}
|
||||
|
||||
public void setRzsj(String rzsj) {
|
||||
this.rzsj = rzsj;
|
||||
}
|
||||
|
||||
public String getZcsj() {
|
||||
return zcsj;
|
||||
}
|
||||
|
||||
public void setZcsj(String zcsj) {
|
||||
this.zcsj = zcsj;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,88 @@
|
||||
package weaver.interfaces.jcl.poc.action;
|
||||
|
||||
import com.engine.common.util.ServiceUtil;
|
||||
import com.engine.hrm.service.impl.OrganizationServiceImpl;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.general.BaseBean;
|
||||
import weaver.general.Util;
|
||||
import weaver.hrm.User;
|
||||
import weaver.interfaces.workflow.action.Action;
|
||||
import weaver.soa.workflow.request.MainTableInfo;
|
||||
import weaver.soa.workflow.request.Property;
|
||||
import weaver.soa.workflow.request.RequestInfo;
|
||||
import weaver.workflow.request.RequestManager;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 组织调整流程,归档Action
|
||||
*
|
||||
* @author:dxfeng
|
||||
* @createTime: 2024/04/17
|
||||
* @version: 1.0
|
||||
*/
|
||||
public class AdjustDepartmentNameAction implements Action {
|
||||
@Override
|
||||
public String execute(RequestInfo requestInfo) {
|
||||
try {
|
||||
RequestManager requestManager = requestInfo.getRequestManager();
|
||||
User user = requestManager.getUser();
|
||||
MainTableInfo mainTableInfo = requestInfo.getMainTableInfo();
|
||||
Property[] propertyArray = mainTableInfo.getProperty();
|
||||
Map<String, String> mainMap = new HashMap<>(16);
|
||||
|
||||
for (Property property : propertyArray) {
|
||||
mainMap.put(property.getName(), property.getValue());
|
||||
}
|
||||
|
||||
String departmentId = mainMap.get("yzz");
|
||||
String newDepartmentName = mainMap.get("gm");
|
||||
RecordSet rs = new RecordSet();
|
||||
// 更新部门全称、简称
|
||||
rs.executeUpdate("update hrmdepartment set departmentmark = ?,departmentname = ? where id = ?", newDepartmentName, newDepartmentName, departmentId);
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
// 构建原来的部门数据集合
|
||||
buildEcDepartmentData(map, departmentId);
|
||||
map.put("departmentmark", newDepartmentName);
|
||||
map.put("departmentname", newDepartmentName);
|
||||
Map<String, Object> resultMap = ServiceUtil.getService(OrganizationServiceImpl.class, user).editDepartment(map, user);
|
||||
if ("-1".equals(Util.null2String(resultMap.get("status")))) {
|
||||
requestInfo.getRequestManager().setMessagecontent(Util.null2String(resultMap.get("message")));
|
||||
return FAILURE_AND_CONTINUE;
|
||||
}
|
||||
return SUCCESS;
|
||||
} catch (Exception e) {
|
||||
new BaseBean().writeLog(e);
|
||||
requestInfo.getRequestManager().setMessagecontent("操作失败,请联系系统管理处理");
|
||||
return FAILURE_AND_CONTINUE;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 构建原部门信息集合
|
||||
*
|
||||
* @param map
|
||||
* @param ecDepartment
|
||||
*/
|
||||
private void buildEcDepartmentData(Map<String, Object> map, String ecDepartment) {
|
||||
map.put("id", ecDepartment);
|
||||
RecordSet rs = new RecordSet();
|
||||
// 先查拓展表
|
||||
rs.execute("select * from hrmdepartmentdefined where deptid = '" + ecDepartment + "'");
|
||||
int colcount = rs.getColCounts();
|
||||
if (rs.next()) {
|
||||
for (int i = 1; i <= colcount; i++) {
|
||||
map.put(rs.getColumnName(i).toLowerCase(), Util.null2String(rs.getString(i)));
|
||||
}
|
||||
}
|
||||
// 再查主表
|
||||
rs.execute("select * from hrmdepartment where id = '" + ecDepartment + "'");
|
||||
colcount = rs.getColCounts();
|
||||
if (rs.next()) {
|
||||
for (int i = 1; i <= colcount; i++) {
|
||||
map.put(rs.getColumnName(i).toLowerCase(), Util.null2String(rs.getString(i)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,78 @@
|
||||
package weaver.interfaces.jcl.poc.action;
|
||||
|
||||
import com.engine.common.util.ServiceUtil;
|
||||
import com.engine.organization.entity.staff.param.StaffOutParam;
|
||||
import com.engine.organization.enums.StaffChangeEnum;
|
||||
import com.engine.organization.exception.OrganizationRunTimeException;
|
||||
import com.engine.organization.service.impl.StaffOutServiceImpl;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.poi.util.StringUtil;
|
||||
import weaver.conn.RecordSet;
|
||||
import weaver.general.BaseBean;
|
||||
import weaver.hrm.User;
|
||||
import weaver.interfaces.workflow.action.Action;
|
||||
import weaver.soa.workflow.request.MainTableInfo;
|
||||
import weaver.soa.workflow.request.Property;
|
||||
import weaver.soa.workflow.request.RequestInfo;
|
||||
import weaver.workflow.request.RequestManager;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author:dxfeng
|
||||
* @createTime: 2024/04/17
|
||||
* @version: 1.0
|
||||
*/
|
||||
public class AdjustDepartmentStaffAction implements Action {
|
||||
@Override
|
||||
public String execute(RequestInfo requestInfo) {
|
||||
try {
|
||||
RequestManager requestManager = requestInfo.getRequestManager();
|
||||
User user = requestManager.getUser();
|
||||
MainTableInfo mainTableInfo = requestInfo.getMainTableInfo();
|
||||
Property[] propertyArray = mainTableInfo.getProperty();
|
||||
Map<String, String> mainMap = new HashMap<>(16);
|
||||
|
||||
for (Property property : propertyArray) {
|
||||
mainMap.put(property.getName(), property.getValue());
|
||||
}
|
||||
|
||||
String departmentId = mainMap.get("bm");
|
||||
String dz = mainMap.get("dz");
|
||||
|
||||
// 查询对应的该部门对应的编制方案
|
||||
String planId = "";
|
||||
String companyId = "";
|
||||
RecordSet rs = new RecordSet();
|
||||
rs.executeQuery("select a.plan_id , a.ec_company from jcl_org_staff a inner join jcl_org_staffplan b on a.plan_id = b.id and b.forbidden_tag = 0 and b.delete_type = 0 where a.ec_department = ? and a.job_id is null and a.delete_type = 0", departmentId);
|
||||
if (rs.next()) {
|
||||
planId = rs.getString("plan_id");
|
||||
companyId = rs.getString("ec_company");
|
||||
}
|
||||
if (StringUtils.isBlank(planId)) {
|
||||
requestInfo.getRequestManager().setMessagecontent("未获取到编制信息,请先在编制信息列表维护该部门编制");
|
||||
return FAILURE_AND_CONTINUE;
|
||||
}
|
||||
int dzNum = Integer.parseInt(dz);
|
||||
StaffOutServiceImpl staffOutService = ServiceUtil.getService(StaffOutServiceImpl.class, user);
|
||||
StaffOutParam staffOutParam = new StaffOutParam();
|
||||
staffOutParam.setType(dzNum > 0 ? StaffChangeEnum.ADD : StaffChangeEnum.REDUCE);
|
||||
staffOutParam.setPlanId(Integer.parseInt(planId));
|
||||
staffOutParam.setCompany(Integer.parseInt(companyId));
|
||||
staffOutParam.setDepartment(Integer.parseInt(departmentId));
|
||||
staffOutParam.setChangeMode(1);
|
||||
staffOutParam.setNum(Math.abs(dzNum));
|
||||
Integer integer = staffOutService.changeStaff(staffOutParam);
|
||||
return SUCCESS;
|
||||
|
||||
} catch (OrganizationRunTimeException e) {
|
||||
requestInfo.getRequestManager().setMessagecontent(e.getMessage());
|
||||
return FAILURE_AND_CONTINUE;
|
||||
} catch (Exception e) {
|
||||
new BaseBean().writeLog(e);
|
||||
requestInfo.getRequestManager().setMessagecontent("操作失败,请联系系统管理处理");
|
||||
return FAILURE_AND_CONTINUE;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue