路维光编制需求
This commit is contained in:
parent
18e9101c31
commit
53757c880b
|
|
@ -1,10 +1,13 @@
|
|||
package com.api.newwaymask.web;
|
||||
|
||||
import javax.ws.rs.Path;
|
||||
|
||||
/**
|
||||
* @Author liang.cheng
|
||||
* @Date 2025/4/22 18:07
|
||||
* @Description:
|
||||
* @Version 1.0
|
||||
*/
|
||||
public class StaffDutyAction {
|
||||
@Path("/newwaymask/staff")
|
||||
public class StaffDutyAction extends com.engine.newwaymask.web.StaffDutyAction {
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,38 @@
|
|||
package com.engine.newwaymask.entity;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @Author liang.cheng
|
||||
* @Date 2025/4/23 10:04
|
||||
* @Description: 复合键
|
||||
* @Version 1.0
|
||||
*/
|
||||
public class Key {
|
||||
|
||||
private final Integer jobId;
|
||||
private final Integer staffBelong;
|
||||
private final Integer jobType;
|
||||
|
||||
public Key(Integer jobId, Integer staffBelong, Integer jobType) {
|
||||
this.jobId = jobId;
|
||||
this.staffBelong = staffBelong;
|
||||
this.jobType = jobType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o){ return true;}
|
||||
if (o == null || getClass() != o.getClass()) {return false;}
|
||||
Key key = (Key) o;
|
||||
return Objects.equals(jobId, key.jobId) &&
|
||||
Objects.equals(staffBelong, key.staffBelong) &&
|
||||
Objects.equals(jobType, key.jobType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(jobId, staffBelong, jobType);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -5,6 +5,7 @@ import com.engine.newwaymask.entity.StaffDutyResult;
|
|||
import com.engine.newwaymask.entity.StaffPlan;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Author liang.cheng
|
||||
|
|
@ -66,4 +67,12 @@ public interface StaffDutyService {
|
|||
StaffDutyResult transferWorkflow(String requestId,String operateType);
|
||||
|
||||
|
||||
/**
|
||||
* @Description: 全部计算功能
|
||||
* @Author: liang.cheng
|
||||
* @Date: 2025/4/23 09:33
|
||||
* @param: []
|
||||
* @return: java.util.Map<java.lang.String,java.lang.Object>
|
||||
*/
|
||||
Map<String,Object> calculateAll();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package com.engine.newwaymask.service.impl;
|
|||
|
||||
import com.engine.core.impl.Service;
|
||||
import com.engine.newwaymask.entity.JobRecord;
|
||||
import com.engine.newwaymask.entity.Key;
|
||||
import com.engine.newwaymask.entity.StaffDutyResult;
|
||||
import com.engine.newwaymask.entity.StaffPlan;
|
||||
import com.engine.newwaymask.service.StaffDutyService;
|
||||
|
|
@ -35,11 +36,10 @@ public class StaffDutyServiceImpl extends Service implements StaffDutyService {
|
|||
"left join uf_zt c on a.gwzt = c.id \n" +
|
||||
"where c.on_job = 0 and a.ksrq <= ? and a.jsrq >= ?";
|
||||
if (!StringUtil.isEmpty(requestId)) {
|
||||
sql += " and a.lcid = "+requestId;
|
||||
sql += " and a.lcqqid = "+requestId;
|
||||
}
|
||||
|
||||
String currentDate = TimeUtil.getCurrentDateString();
|
||||
|
||||
rs.executeQuery(sql,currentDate,currentDate);
|
||||
|
||||
|
||||
|
|
@ -89,10 +89,12 @@ public class StaffDutyServiceImpl extends Service implements StaffDutyService {
|
|||
staffPlans.add(StaffPlan.builder()
|
||||
.id(Util.getIntValue(rs.getString("id")))
|
||||
.jobId(Util.getIntValue(rs.getString("gw")))
|
||||
.jobType(Util.getIntValue(rs.getString("rzlx")))
|
||||
.staffBelong(Util.getIntValue(rs.getString("bzgz")))
|
||||
.staffPlanNums(Util.getIntValue(rs.getString("zbzjhs"),0))
|
||||
.frozenNums(Util.getIntValue(rs.getString("djbzs"),0))
|
||||
.onJobNums(Util.getIntValue(rs.getString("zbrs"),0))
|
||||
.restNums(Util.getIntValue(rs.getString("syrs"),0))
|
||||
.restNums(Util.getIntValue(rs.getString("syrs")))
|
||||
.build());
|
||||
}
|
||||
}else {
|
||||
|
|
@ -105,7 +107,7 @@ public class StaffDutyServiceImpl extends Service implements StaffDutyService {
|
|||
.staffPlanNums(Util.getIntValue(rs.getString("zbzjhs"),0))
|
||||
.frozenNums(Util.getIntValue(rs.getString("djbzs"),0))
|
||||
.onJobNums(Util.getIntValue(rs.getString("zbrs"),0))
|
||||
.restNums(Util.getIntValue(rs.getString("syrs"),0))
|
||||
.restNums(Util.getIntValue(rs.getString("syrs")))
|
||||
.build());
|
||||
}
|
||||
}
|
||||
|
|
@ -269,6 +271,35 @@ public class StaffDutyServiceImpl extends Service implements StaffDutyService {
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> calculateAll() {
|
||||
|
||||
List<JobRecord> jobRecords = selectJobRecords("");
|
||||
List<StaffPlan> staffPlans = selectStaffPlans(null, true);
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
|
||||
Map<Key, Integer> countMap = new HashMap<>();
|
||||
for (JobRecord record : jobRecords) {
|
||||
Key key = new Key(record.getJobId(), record.getStaffBelong(), record.getJobType());
|
||||
countMap.put(key, countMap.getOrDefault(key, 0) + 1);
|
||||
}
|
||||
|
||||
for (StaffPlan plan : staffPlans) {
|
||||
Key key = new Key(plan.getJobId(), plan.getStaffBelong(), plan.getJobType());
|
||||
Integer onJob = countMap.getOrDefault(key, 0);
|
||||
LinkedList<Integer> numbers = new LinkedList<>(Arrays.asList(plan.getStaffPlanNums(), plan.getFrozenNums(), onJob));
|
||||
int rest = numbers.stream()
|
||||
.findFirst()
|
||||
.map(first -> first - numbers.stream().skip(1).mapToInt(Integer::intValue).sum())
|
||||
.orElse(0);
|
||||
updateStaffPlan(onJob, rest, plan.getId());
|
||||
}
|
||||
|
||||
map.put("size",staffPlans.size());
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
|
||||
private StaffDutyResult buildStaffPlan(String requestId) {
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,50 @@
|
|||
package com.engine.newwaymask.web;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.fastjson.serializer.SerializerFeature;
|
||||
import com.engine.common.util.ServiceUtil;
|
||||
import com.engine.newwaymask.service.StaffDutyService;
|
||||
import com.engine.newwaymask.service.impl.StaffDutyServiceImpl;
|
||||
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 liang.cheng
|
||||
* @Date 2025/4/22 18:50
|
||||
* @Description:
|
||||
* @Version 1.0
|
||||
*/
|
||||
public class StaffDutyAction {
|
||||
|
||||
private StaffDutyService getService(User user) {
|
||||
return ServiceUtil.getService(StaffDutyServiceImpl.class, user);
|
||||
}
|
||||
|
||||
|
||||
@GET
|
||||
@Path("/calculateAll")
|
||||
@Produces(MediaType.TEXT_PLAIN)
|
||||
public String calculateAll(@Context HttpServletRequest request, @Context HttpServletResponse response){
|
||||
Map<String, Object> data = new HashMap<>(8);
|
||||
try {
|
||||
User user = HrmUserVarify.getUser(request, response);
|
||||
data.putAll(getService(user).calculateAll());
|
||||
data.put("code", 200);
|
||||
} catch (Exception e) {
|
||||
data.put("code", 500);
|
||||
data.put("msg", "catch exception : " + e.getMessage());
|
||||
}
|
||||
return JSONObject.toJSONString(data, SerializerFeature.DisableCircularReferenceDetect);
|
||||
}
|
||||
}
|
||||
|
|
@ -43,13 +43,15 @@ public class StaffByEndWorkflowAction implements Action {
|
|||
break;
|
||||
}
|
||||
|
||||
|
||||
if (result.getStatus()) {
|
||||
requestInfo.getRequestManager().setMessagecontent(result.getMessage());
|
||||
return Action.SUCCESS;
|
||||
}else {
|
||||
requestInfo.getRequestManager().setMessagecontent(result.getMessage());
|
||||
return Action.FAILURE_AND_CONTINUE;
|
||||
}
|
||||
|
||||
// if (result.getStatus()) {
|
||||
// requestInfo.getRequestManager().setMessagecontent(result.getMessage());
|
||||
// return Action.SUCCESS;
|
||||
// }else {
|
||||
// requestInfo.getRequestManager().setMessagecontent(result.getMessage());
|
||||
// return Action.FAILURE_AND_CONTINUE;
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue