diff --git a/src/com/engine/organization/entity/staff/bo/StaffBO.java b/src/com/engine/organization/entity/staff/bo/StaffBO.java index aa8a3b56..23b0914d 100644 --- a/src/com/engine/organization/entity/staff/bo/StaffBO.java +++ b/src/com/engine/organization/entity/staff/bo/StaffBO.java @@ -2,6 +2,7 @@ package com.engine.organization.entity.staff.bo; import com.engine.organization.entity.staff.param.StaffSearchParam; import com.engine.organization.entity.staff.po.StaffPO; +import com.engine.organization.transmethod.StaffTransMethod; import java.util.Date; @@ -35,4 +36,44 @@ public class StaffBO { .creator(employeeId) .build(); } + + public static void buildStaffDesc(StaffPO staffPO) { + staffPO.setLackStatus(parseLackStatus(null == staffPO.getStaffNum() ? 0 : staffPO.getStaffNum(), null == staffPO.getPermanentNum() ? 0 : staffPO.getPermanentNum())); + StringBuilder sb = new StringBuilder(); + sb.append("编制数:").append(parseNull(staffPO.getStaffNum())) + .append(",在编数:").append(parseNull(staffPO.getPermanentNum())) + .append(",冻结数:").append(parseNull(staffPO.getFreezeNum())) + .append(",缺编状态:").append(StaffTransMethod.getLackSpan(staffPO.getLackStatus()+"")); + staffPO.setStaffDesc(sb.toString()); + + } + + + /** + * null 转换为 0 + * + * @param number + * @return + */ + private static Integer parseNull(Integer number) { + return null == number ? 0 : number; + + } + + /** + * 转换缺编状态 + * + * @param staffNum + * @param permanentNum + * @return + */ + private static int parseLackStatus(int staffNum, int permanentNum) { + if (staffNum == permanentNum) { + return 1; + } + if (staffNum > permanentNum) { + return 2; + } + return 3; + } } diff --git a/src/com/engine/organization/entity/staff/param/StaffSearchParam.java b/src/com/engine/organization/entity/staff/param/StaffSearchParam.java index 1ff52b55..1e004e5d 100644 --- a/src/com/engine/organization/entity/staff/param/StaffSearchParam.java +++ b/src/com/engine/organization/entity/staff/param/StaffSearchParam.java @@ -70,4 +70,9 @@ public class StaffSearchParam { * 方案名称 */ private String staffName; + + /** + * 调整数量 + */ + private Integer changeNum; } diff --git a/src/com/engine/organization/entity/staff/po/StaffsPO.java b/src/com/engine/organization/entity/staff/po/StaffsPO.java new file mode 100644 index 00000000..9654950c --- /dev/null +++ b/src/com/engine/organization/entity/staff/po/StaffsPO.java @@ -0,0 +1,50 @@ +package com.engine.organization.entity.staff.po; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +import java.util.Date; + +/** + * @description: TODO + * @author:dxfeng + * @createTime: 2022/06/07 + * @version: 1.0 + */ +@Data +@Builder +@AllArgsConstructor +@NoArgsConstructor +public class StaffsPO { + /** + * 主键 + */ + private Long id; + /** + * 编制ID + */ + private Long staffId; + /** + * 业务类型 + */ + private Integer businessType; + /** + * 编制变动数 + */ + private Integer changeNum; + /** + * 业务来源 + */ + private Integer businessSource; + /** + * 关联流程 + */ + private Integer requestId; + + private Long creator; + private int deleteType; + private Date createTime; + private Date updateTime; +} diff --git a/src/com/engine/organization/entity/staff/vo/StaffTableVO.java b/src/com/engine/organization/entity/staff/vo/StaffTableVO.java index c8fab370..1c38d833 100644 --- a/src/com/engine/organization/entity/staff/vo/StaffTableVO.java +++ b/src/com/engine/organization/entity/staff/vo/StaffTableVO.java @@ -80,8 +80,8 @@ public class StaffTableVO { /** * 缺编状态 */ - @OrganizationTableColumn(text = "缺编状态", width = "10%", column = "lack_status") - private Integer lackStatus; + @OrganizationTableColumn(text = "缺编状态", width = "10%", column = "lack_status", transmethod = "com.engine.organization.transmethod.StaffTransMethod.getLackSpan") + private String lackStatus; /** * 编制描述 */ diff --git a/src/com/engine/organization/mapper/staff/StaffMapper.java b/src/com/engine/organization/mapper/staff/StaffMapper.java index 0d39e82c..53835363 100644 --- a/src/com/engine/organization/mapper/staff/StaffMapper.java +++ b/src/com/engine/organization/mapper/staff/StaffMapper.java @@ -23,6 +23,16 @@ public interface StaffMapper { */ StaffPO getStaffByID(@Param("id") long id); + /** + * 根据分部、部门、岗位查询编制 + * + * @param companyId + * @param departmentId + * @param jobId + * @return + */ + StaffPO getStaffByFilter(@Param("companyId") Long companyId, @Param("departmentId") Long departmentId, @Param("jobId") Long jobId); + /** * 插入编制方案 * diff --git a/src/com/engine/organization/mapper/staff/StaffMapper.xml b/src/com/engine/organization/mapper/staff/StaffMapper.xml index 137f2b2e..9426e52b 100644 --- a/src/com/engine/organization/mapper/staff/StaffMapper.xml +++ b/src/com/engine/organization/mapper/staff/StaffMapper.xml @@ -48,6 +48,20 @@ from jcl_org_staffs where delete_type = 0 + update jcl_org_staff diff --git a/src/com/engine/organization/mapper/staff/StaffsMapper.java b/src/com/engine/organization/mapper/staff/StaffsMapper.java new file mode 100644 index 00000000..e8ed90ef --- /dev/null +++ b/src/com/engine/organization/mapper/staff/StaffsMapper.java @@ -0,0 +1,19 @@ +package com.engine.organization.mapper.staff; + +import com.engine.organization.entity.staff.po.StaffsPO; + +/** + * @description: TODO + * @author:dxfeng + * @createTime: 2022/06/07 + * @version: 1.0 + */ +public interface StaffsMapper { + /** + * 插入编制方案 + * + * @param staffsPO + * @return + */ + int insertIgnoreNull(StaffsPO staffsPO); +} diff --git a/src/com/engine/organization/mapper/staff/StaffsMapper.xml b/src/com/engine/organization/mapper/staff/StaffsMapper.xml new file mode 100644 index 00000000..11695407 --- /dev/null +++ b/src/com/engine/organization/mapper/staff/StaffsMapper.xml @@ -0,0 +1,95 @@ + + + + + + + + + + + + + + + + + + + t + . + id + , t.staff_id + , t.business_type + , t.change_num + , t.business_source + , t.staff_num + , t.requestid + + + + + INSERT INTO jcl_org_staffs + + + creator, + + + delete_type, + + + create_time, + + + update_time, + + + staff_id, + + + business_type, + + + change_num, + + + business_source, + + + requestid, + + + + + #{creator}, + + + #{deleteType}, + + + #{createTime}, + + + #{updateTime}, + + + + #{staffId}, + + + #{businessType}, + + + #{changeNum}, + + + #{businessSource}, + + + #{requestId}, + + + + + \ No newline at end of file diff --git a/src/com/engine/organization/service/impl/StaffServiceImpl.java b/src/com/engine/organization/service/impl/StaffServiceImpl.java index 47b4c6db..ebbe9aa2 100644 --- a/src/com/engine/organization/service/impl/StaffServiceImpl.java +++ b/src/com/engine/organization/service/impl/StaffServiceImpl.java @@ -11,12 +11,14 @@ import com.engine.organization.entity.DeleteParam; import com.engine.organization.entity.staff.bo.StaffBO; import com.engine.organization.entity.staff.param.StaffSearchParam; import com.engine.organization.entity.staff.po.StaffPO; +import com.engine.organization.entity.staff.po.StaffsPO; import com.engine.organization.entity.staff.vo.StaffTableVO; import com.engine.organization.mapper.comp.CompMapper; import com.engine.organization.mapper.department.DepartmentMapper; import com.engine.organization.mapper.job.JobMapper; import com.engine.organization.mapper.staff.StaffMapper; import com.engine.organization.mapper.staff.StaffPlanMapper; +import com.engine.organization.mapper.staff.StaffsMapper; import com.engine.organization.service.StaffService; import com.engine.organization.util.*; import com.engine.organization.util.db.DBType; @@ -89,8 +91,25 @@ public class StaffServiceImpl extends Service implements StaffService { @Override public int updateStaff(StaffSearchParam param) { HasRightUtil.hasRight(user, RIGHT_NAME, false); - StaffPO staffPlanPO = StaffBO.convertParamToPO(param, (long) user.getUID()); - return getStaffMapper().updateStaff(staffPlanPO); + StaffPO staffByID = getStaffMapper().getStaffByID(param.getId()); + StaffPO staffPO = StaffBO.convertParamToPO(param, (long) user.getUID()); + + Integer changeNum = param.getChangeNum(); + if (null == changeNum) { + // 插入明细表数据 + StaffsPO staffsPO = StaffsPO.builder().staffId(staffPO.getId()).businessType(1).changeNum(staffPO.getStaffNum() - staffByID.getStaffNum()).businessSource(1).build(); + MapperProxyFactory.getProxy(StaffsMapper.class).insertIgnoreNull(staffsPO); + + } else { + // 插入明细表数据 + StaffsPO staffsPO = StaffsPO.builder().staffId(staffPO.getId()).businessType(2).changeNum(changeNum).businessSource(1).build(); + MapperProxyFactory.getProxy(StaffsMapper.class).insertIgnoreNull(staffsPO); + // 更新编制表 + staffPO.setStaffNum(staffPO.getStaffNum() + changeNum); + } + StaffBO.buildStaffDesc(staffPO); + // 更新主表 + return getStaffMapper().updateStaff(staffPO); } @@ -183,6 +202,9 @@ public class StaffServiceImpl extends Service implements StaffService { SearchConditionItem controlPolicyItem = OrganizationFormItemUtil.selectItem(user, selectOptions, 2, 16, 6, false, "控制策略", "controlPolicy"); controlPolicyItem.setViewAttr(3); controlPolicyItem.setRules("required|string"); + SearchConditionItem descriptionItem = OrganizationFormItemUtil.textareaItem(user, 2, 16, true, 2, 60, "描述说明", "description"); + + // 编辑状态下赋值操作 String id = Util.null2String(params.get("id")); @@ -196,22 +218,23 @@ public class StaffServiceImpl extends Service implements StaffService { planIdItem.setBrowserConditionParam(planIdItemBean); BrowserBean compIdItemBean = compIdItem.getBrowserConditionParam(); - List> compIdMaps = getCompMapper().listCompsByIds(DeleteParam.builder().ids(staffPO.getPlanId().toString()).build().getIds()); + List> compIdMaps = getCompMapper().listCompsByIds(DeleteParam.builder().ids(staffPO.getCompId().toString()).build().getIds()); compIdItemBean.setReplaceDatas(compIdMaps); compIdItem.setBrowserConditionParam(compIdItemBean); BrowserBean deptIdItemBean = deptIdItem.getBrowserConditionParam(); - List> deptIdMaps = getDepartmentMapper().listDeptsByIds(DeleteParam.builder().ids(staffPO.getPlanId().toString()).build().getIds()); + List> deptIdMaps = getDepartmentMapper().listDeptsByIds(DeleteParam.builder().ids(staffPO.getDeptId().toString()).build().getIds()); deptIdItemBean.setReplaceDatas(deptIdMaps); deptIdItem.setBrowserConditionParam(deptIdItemBean); BrowserBean jobIdItemBean = jobIdItem.getBrowserConditionParam(); - List> jobIdMaps = getJobMapper().listJobsByIds(DeleteParam.builder().ids(staffPO.getPlanId().toString()).build().getIds()); + List> jobIdMaps = getJobMapper().listJobsByIds(DeleteParam.builder().ids(staffPO.getJobId().toString()).build().getIds()); jobIdItemBean.setReplaceDatas(jobIdMaps); jobIdItem.setBrowserConditionParam(jobIdItemBean); staffNumItem.setValue(staffPO.getStaffNum()); - controlPolicyItem.setValue(staffPO.getControlPolicy()); + controlPolicyItem.setValue(staffPO.getControlPolicy()+""); + descriptionItem.setValue(staffPO.getDescription()); } selectItems.add(planIdItem); selectItems.add(compIdItem); @@ -219,6 +242,14 @@ public class StaffServiceImpl extends Service implements StaffService { selectItems.add(jobIdItem); selectItems.add(staffNumItem); selectItems.add(controlPolicyItem); + selectItems.add(descriptionItem); + String operateType = (String)params.get("operateType"); + if ("2".equals(operateType)) { + selectItems.forEach(item->item.setViewAttr(1)); + SearchConditionItem changeNumItem = OrganizationFormItemUtil.inputNumberItem(user, 2, 16, 3, "调整数量", "changeNum"); + staffNumItem.setRules("required"); + selectItems.add(changeNumItem); + } addGroups.add(new SearchConditionGroup("基本信息", true, selectItems)); apiDatas.put("condition", addGroups); diff --git a/src/com/engine/organization/transmethod/StaffTransMethod.java b/src/com/engine/organization/transmethod/StaffTransMethod.java new file mode 100644 index 00000000..0215a7ad --- /dev/null +++ b/src/com/engine/organization/transmethod/StaffTransMethod.java @@ -0,0 +1,28 @@ +package com.engine.organization.transmethod; + +/** + * @description: TODO + * @author:dxfeng + * @createTime: 2022/06/07 + * @version: 1.0 + */ +public class StaffTransMethod { + public static String getLackSpan(String lackStatus) { + String lackSpan = ""; + switch (lackStatus) { + case "1": + lackSpan = "缺编"; + break; + case "2": + lackSpan = "满员"; + break; + case "3": + lackSpan = "超编"; + break; + default: + break; + + } + return lackSpan; + } +} diff --git a/src/weaver/interfaces/organization/action/StaffChangeAction.java b/src/weaver/interfaces/organization/action/StaffChangeAction.java new file mode 100644 index 00000000..e21c26ca --- /dev/null +++ b/src/weaver/interfaces/organization/action/StaffChangeAction.java @@ -0,0 +1,81 @@ +package weaver.interfaces.organization.action; + +import com.engine.organization.entity.staff.bo.StaffBO; +import com.engine.organization.entity.staff.po.StaffPO; +import com.engine.organization.entity.staff.po.StaffsPO; +import com.engine.organization.mapper.staff.StaffMapper; +import com.engine.organization.mapper.staff.StaffsMapper; +import com.engine.organization.util.db.MapperProxyFactory; +import org.apache.commons.lang3.StringUtils; +import weaver.general.Util; +import weaver.interfaces.workflow.action.Action; +import weaver.soa.workflow.request.MainTableInfo; +import weaver.soa.workflow.request.Property; +import weaver.soa.workflow.request.RequestInfo; + +/** + * @description: TODO + * @author:dxfeng + * @createTime: 2022/06/07 + * @version: 1.0 + */ +public class StaffChangeAction implements Action { + @Override + public String execute(RequestInfo requestInfo) { + Integer requestid = Integer.parseInt(requestInfo.getRequestid()); + Long companyId = null; + Long departmentId = null; + Long jobId = null; + Integer changeNum = null; + Integer businessSource = null; + MainTableInfo mainTableInfo = requestInfo.getMainTableInfo(); + Property[] property = mainTableInfo.getProperty(); + // 取表单数据赋值 + for (int i = 0; i < property.length; i++) { + String name = property[i].getName(); + String value = Util.null2String(property[i].getValue()); + if (StringUtils.isNotBlank(name) && StringUtils.isNotBlank(value)) { + switch (name) { + case "fb": + companyId = Long.parseLong(value); + break; + case "bm": + departmentId = Long.parseLong(value); + break; + case "gw": + jobId = Long.parseLong(value); + + break; + case "bzbds": + changeNum = Integer.parseInt(value); + break; + case "ywly": + businessSource = Integer.parseInt(value); + break; + default: + break; + } + } + + } + + // 根据分部、部门、岗位 定位具体编制信息 + StaffPO staffPO = MapperProxyFactory.getProxy(StaffMapper.class).getStaffByFilter(companyId, departmentId, jobId); + if (null != staffPO) { + + // 插入明细表 + StaffsPO staffsPO = StaffsPO.builder().staffId(staffPO.getId()).businessType(2).changeNum(changeNum).businessSource(businessSource).requestId(requestid).build(); + MapperProxyFactory.getProxy(StaffsMapper.class).insertIgnoreNull(staffsPO); + + // 更新编制表 + staffPO.setStaffNum(staffPO.getStaffNum() + changeNum); + + StaffBO.buildStaffDesc(staffPO); + + MapperProxyFactory.getProxy(StaffMapper.class).updateStaff(staffPO); + } + + return null; + } + +}