Commit 4d55aed8 by wangchunyang

日常管理框架代码

parent fba418bc
package com.scpyun.platform.jilinsscgsdp.service.impl;
import com.scpyun.base.core.annotation.Api;
import com.scpyun.base.core.annotation.ApiOperation;
import com.scpyun.base.core.exception.CustomException;
import com.scpyun.base.db.service.CommonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Api("办公用品领用管理")
@Service("keyDmBorrow")
public class KeyDmBorrowServiceImpl {
@Autowired
private CommonService commonService;
private static final String SUCCESS = "success";
private final String namespace = "com.scpyun.platform.standard.jilinsscgsdp.keyDmBorrow.";
@ApiOperation(value = "领用申请列表", desc = "分页查询")
public Map<String, Object> selectList(Map<String, Object> map) {
if (map == null) map = new HashMap<>();
return commonService.findPage(namespace + "selectList", map);
}
@ApiOperation(value = "待审核列表", desc = "分页查询待审核")
public Map<String, Object> selectPendingList(Map<String, Object> map) {
if (map == null) map = new HashMap<>();
return commonService.findPage(namespace + "selectPendingList", map);
}
@ApiOperation(value = "保存申请(含明细)", desc = "新增或修改申请")
public String save(Map<String, Object> map) {
if (map == null) throw new CustomException("参数不能为空");
Object id = map.get("id");
List<Map<String, Object>> details = (List<Map<String, Object>>) map.get("details");
if (id == null || String.valueOf(id).trim().isEmpty()) {
// insert application
if (commonService.insert(namespace + "insert", map) != 1) throw new CustomException("保存失败");
// insert details if any
if (details != null) {
for (Map<String, Object> d : details) {
d.put("application_id", map.get("id"));
commonService.insert(namespace + "insertDetail", d);
}
}
} else {
int aff = commonService.update(namespace + "update", map);
if (aff < 0) throw new CustomException("保存失败");
// for simplicity, delete old details and insert new
commonService.delete(namespace + "deleteDetailsByApplicationId", map);
if (details != null) {
for (Map<String, Object> d : details) {
d.put("application_id", map.get("id"));
commonService.insert(namespace + "insertDetail", d);
}
}
}
return SUCCESS;
}
@ApiOperation(value = "提交申请", desc = "提交进入审批")
public String submit(Map<String, Object> map) {
if (map == null || map.get("id") == null) throw new CustomException("参数缺失");
int aff = commonService.update(namespace + "submit", map);
if (aff < 0) throw new CustomException("提交失败");
return SUCCESS;
}
@ApiOperation(value = "撤回申请", desc = "撤回审核中申请")
public String revoke(Map<String, Object> map) {
if (map == null || map.get("id") == null) throw new CustomException("参数缺失");
int aff = commonService.update(namespace + "revoke", map);
if (aff < 0) throw new CustomException("撤回失败");
return SUCCESS;
}
@ApiOperation(value = "审批通过", desc = "审批通过并生成出库,更新库存与日志")
public String approve(Map<String, Object> map) {
if (map == null || map.get("id") == null) throw new CustomException("参数缺失");
// 设置申请为通过
int aff = commonService.update(namespace + "approve", map);
if (aff < 0) throw new CustomException("审批失败");
// 生成出库记录(mapper 实现)
commonService.insert(namespace + "insertOutboundByApplication", map);
// 更新库存(mapper 内部处理)
commonService.update(namespace + "updateInventoryByApplication", map);
// 写操作日志(mapper 内部处理)
commonService.insert(namespace + "insertMaterialLogByApplication", map);
return SUCCESS;
}
@ApiOperation(value = "审批驳回", desc = "审批驳回,需保存意见")
public String reject(Map<String, Object> map) {
if (map == null || map.get("id") == null) throw new CustomException("参数缺失");
int aff = commonService.update(namespace + "reject", map);
if (aff < 0) throw new CustomException("驳回失败");
return SUCCESS;
}
@ApiOperation(value = "根据ID查询申请及明细/日志", desc = "详情")
public Map<String, Object> getById(Map<String, Object> map) {
if (map == null || map.get("id") == null) throw new CustomException("参数缺失");
Map<String, Object> ret = new HashMap<>();
Map<String, Object> app = commonService.getObject(namespace + "getById", map);
ret.putAll(app == null ? new HashMap<>() : app);
List<Map<String, Object>> details = commonService.findList(namespace + "selectDetailsByApplicationId", map);
ret.put("details", details == null ? new java.util.ArrayList<>() : details);
// logs from material log by application relation
List<Map<String, Object>> logs = commonService.findList(namespace + "selectLogsByApplicationId", map);
ret.put("logs", logs == null ? new java.util.ArrayList<>() : logs);
return ret;
}
}
package com.scpyun.platform.jilinsscgsdp.service.impl;
import com.scpyun.base.core.annotation.Api;
import com.scpyun.base.core.annotation.ApiOperation;
import com.scpyun.base.core.exception.CustomException;
import com.scpyun.base.db.service.CommonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Api("办公用品入库管理")
@Service("keyDmInbound")
public class KeyDmInboundServiceImpl {
@Autowired
private CommonService commonService;
private static final String SUCCESS = "success";
private final String namespace = "com.scpyun.platform.standard.jilinsscgsdp.keyDmInbound.";
@ApiOperation(value = "入库记录列表", desc = "分页查询")
public Map<String, Object> selectList(Map<String, Object> map) {
if (map == null) map = new HashMap<>();
return commonService.findPage(namespace + "selectList", map);
}
@ApiOperation(value = "保存入库记录", desc = "新增或修改入库单及明细")
public String save(Map<String, Object> map) {
if (map == null) throw new CustomException("参数不能为空");
Object id = map.get("id");
List<Map<String, Object>> details = (List<Map<String, Object>>) map.get("details");
if (id == null || String.valueOf(id).trim().isEmpty()) {
if (commonService.insert(namespace + "insert", map) != 1) throw new CustomException("保存失败");
if (details != null) {
for (Map<String, Object> d : details) {
d.put("inbound_id", map.get("id"));
commonService.insert(namespace + "insertDetail", d);
}
}
} else {
int aff = commonService.update(namespace + "update", map);
if (aff < 0) throw new CustomException("保存失败");
commonService.delete(namespace + "deleteDetailsByInboundId", map);
if (details != null) {
for (Map<String, Object> d : details) {
d.put("inbound_id", map.get("id"));
commonService.insert(namespace + "insertDetail", d);
}
}
}
return SUCCESS;
}
@ApiOperation(value = "删除入库单", desc = "逻辑删除")
public String delete(Map<String, Object> map) {
if (map == null || map.get("id") == null) throw new CustomException("参数缺失");
int aff = commonService.update(namespace + "delete", map);
if (aff < 0) throw new CustomException("删除失败");
return SUCCESS;
}
@ApiOperation(value = "执行入库", desc = "将入库单置为已入库,更新库存并写日志")
public String doInbound(Map<String, Object> map) {
if (map == null || map.get("id") == null) throw new CustomException("参数缺失");
// 设置入库状态
int aff = commonService.update(namespace + "doInbound", map);
if (aff < 0) throw new CustomException("入库失败");
// 更新库存明细:调用 mapper 更新库存和日志(mapper 内实现或逐条处理)
commonService.update(namespace + "updateInventoryByInbound", map);
commonService.insert(namespace + "insertMaterialLogByInbound", map);
return SUCCESS;
}
@ApiOperation(value = "待归还列表(来自申领)", desc = "查询待归还记录")
public Map<String, Object> selectPendingReturnList(Map<String, Object> map) {
if (map == null) map = new HashMap<>();
return commonService.findPage(namespace + "selectPendingReturnList", map);
}
@ApiOperation(value = "处理归还", desc = "基于申领生成入库单并更新库存")
public String processReturn(Map<String, Object> map) {
if (map == null || map.get("id") == null) throw new CustomException("参数缺失");
// 生成入库单
commonService.insert(namespace + "insertInboundByReturn", map);
// 更新库存
commonService.update(namespace + "updateInventoryByReturn", map);
// 写日志
commonService.insert(namespace + "insertMaterialLogByReturn", map);
return SUCCESS;
}
@ApiOperation(value = "库存查询", desc = "实时库存")
public Map<String, Object> selectInventoryList(Map<String, Object> map) {
if (map == null) map = new HashMap<>();
return commonService.findPage(namespace + "selectInventoryList", map);
}
@ApiOperation(value = "详情", desc = "查询入库/归还详情及日志")
public Map<String, Object> getById(Map<String, Object> map) {
if (map == null || map.get("id") == null) throw new CustomException("参数缺失");
Map<String, Object> ret = new HashMap<>();
Map<String, Object> rec = commonService.getObject(namespace + "getById", map);
ret.putAll(rec == null ? new HashMap<>() : rec);
List<Map<String, Object>> details = commonService.findList(namespace + "selectDetailsByInboundId", map);
ret.put("details", details == null ? new java.util.ArrayList<>() : details);
List<Map<String, Object>> logs = commonService.findList(namespace + "selectLogsByInboundId", map);
ret.put("logs", logs == null ? new java.util.ArrayList<>() : logs);
return ret;
}
}
package com.scpyun.platform.jilinsscgsdp.service.impl;
import com.scpyun.base.core.annotation.Api;
import com.scpyun.base.core.annotation.ApiOperation;
import com.scpyun.base.core.exception.CustomException;
import com.scpyun.base.db.service.CommonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Api("日常请假管理")
@Service("keyDmLeave")
public class KeyDmLeaveServiceImpl {
@Autowired
private CommonService commonService;
private static final String SUCCESS = "success";
private final String namespace = "com.scpyun.platform.standard.jilinsscgsdp.keyDmLeave.";
@ApiOperation(value = "分页查询请假申请列表", desc = "分页查询")
public Map<String, Object> selectList(Map<String, Object> map) {
if (map == null) map = new HashMap<>();
return commonService.findPage(namespace + "selectList", map);
}
@ApiOperation(value = "待审核列表", desc = "查询待审核数据")
public Map<String, Object> selectPendingList(Map<String, Object> map) {
if (map == null) map = new HashMap<>();
return commonService.findPage(namespace + "selectPendingList", map);
}
@ApiOperation(value = "保存请假申请", desc = "新增或修改,请假单保存")
public String save(Map<String, Object> map) {
if (map == null) throw new CustomException("参数不能为空");
Object id = map.get("id");
if (id == null || String.valueOf(id).trim().isEmpty()) {
if (commonService.insert(namespace + "insert", map) != 1) throw new CustomException("保存失败");
} else {
int aff = commonService.update(namespace + "update", map);
if (aff < 0) throw new CustomException("保存失败");
}
return SUCCESS;
}
@ApiOperation(value = "提交请假申请", desc = "提交进入审批流程")
public String submit(Map<String, Object> map) {
if (map == null || map.get("id") == null) throw new CustomException("参数缺失");
int aff = commonService.update(namespace + "submit", map);
if (aff < 0) throw new CustomException("提交失败");
return SUCCESS;
}
@ApiOperation(value = "撤回请假申请", desc = "撤回未完成审批的申请")
public String revoke(Map<String, Object> map) {
if (map == null || map.get("id") == null) throw new CustomException("参数缺失");
int aff = commonService.update(namespace + "revoke", map);
if (aff < 0) throw new CustomException("撤回失败");
return SUCCESS;
}
@ApiOperation(value = "审批通过", desc = "审批操作-通过")
public String approve(Map<String, Object> map) {
if (map == null || map.get("id") == null) throw new CustomException("参数缺失");
int aff = commonService.update(namespace + "approve", map);
if (aff < 0) throw new CustomException("审批失败");
return SUCCESS;
}
@ApiOperation(value = "审批驳回", desc = "审批操作-驳回")
public String reject(Map<String, Object> map) {
if (map == null || map.get("id") == null) throw new CustomException("参数缺失");
int aff = commonService.update(namespace + "reject", map);
if (aff < 0) throw new CustomException("驳回失败");
return SUCCESS;
}
@ApiOperation(value = "获取请假详情(含审批记录)", desc = "获取详情")
public Map<String, Object> getById(Map<String, Object> map) {
if (map == null || map.get("id") == null) throw new CustomException("参数缺失");
Map<String, Object> ret = new HashMap<>();
Map<String, Object> app = commonService.getObject(namespace + "getById", map);
ret.putAll(app == null ? new HashMap<>() : app);
List<Map<String, Object>> approvals = commonService.findList(namespace + "selectApprovalRecords", map);
ret.put("approvals", approvals == null ? new java.util.ArrayList<>() : approvals);
return ret;
}
@ApiOperation(value = "审批历史查询", desc = "查询审批历史")
public Map<String, Object> selectApprovalHistory(Map<String, Object> map) {
if (map == null) map = new HashMap<>();
return commonService.findPage(namespace + "selectApprovalHistory", map);
}
@ApiOperation(value = "请假统计", desc = "按人员统计已通过请假天数")
public List<Map<String, Object>> selectStats(Map<String, Object> map) {
if (map == null) map = new HashMap<>();
return commonService.findList(namespace + "selectStats", map);
}
}
package com.scpyun.platform.jilinsscgsdp.service.impl;
import com.scpyun.base.core.annotation.Api;
import com.scpyun.base.core.annotation.ApiOperation;
import com.scpyun.base.core.exception.CustomException;
import com.scpyun.base.db.service.CommonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.Map;
@Api("请假类型管理")
@Service("keyDmLeaveType")
public class KeyDmLeaveTypeServiceImpl {
@Autowired
private CommonService commonService;
private static final String SUCCESS = "success";
private final String namespace = "com.scpyun.platform.standard.jilinsscgsdp.keyDmLeaveType.";
@ApiOperation(value = "查询请假类型列表", desc = "分页查询请假类型")
public Map<String, Object> selectList(Map<String, Object> map) {
if (map == null) {
map = new HashMap<>();
}
return commonService.findPage(namespace + "selectList", map);
}
@ApiOperation(value = "保存请假类型", desc = "新增或修改请假类型")
public String save(Map<String, Object> map) {
if (map == null) {
throw new CustomException("参数不能为空");
}
Object id = map.get("id");
if (id == null || String.valueOf(id).trim().isEmpty()) {
// 新增
if (commonService.insert(namespace + "insert", map) != 1) {
throw new CustomException("保存失败");
}
} else {
// 修改
int affected = commonService.update(namespace + "update", map);
if (affected < 0) {
throw new CustomException("保存失败");
}
}
return SUCCESS;
}
@ApiOperation(value = "删除请假类型", desc = "逻辑删除请假类型")
public String delete(Map<String, Object> map) {
if (map == null || map.get("id") == null) {
throw new CustomException("参数不能为空");
}
int affected = commonService.update(namespace + "delete", map);
if (affected < 0) {
throw new CustomException("删除失败");
}
return SUCCESS;
}
}
package com.scpyun.platform.jilinsscgsdp.service.impl;
import com.scpyun.base.core.annotation.Api;
import com.scpyun.base.core.annotation.ApiOperation;
import com.scpyun.base.core.exception.CustomException;
import com.scpyun.base.db.service.CommonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.Map;
@Api("办公用品分类管理")
@Service("keyDmMaterialCategory")
public class KeyDmMaterialCategoryServiceImpl {
@Autowired
private CommonService commonService;
private static final String SUCCESS = "success";
private final String namespace = "com.scpyun.platform.standard.jilinsscgsdp.keyDmMaterialCategory.";
@ApiOperation(value = "查询办公用品分类列表", desc = "分页查询办公用品分类")
public Map<String, Object> selectList(Map<String, Object> map) {
if (map == null) {
map = new HashMap<>();
}
return commonService.findPage(namespace + "selectList", map);
}
@ApiOperation(value = "保存办公用品分类", desc = "新增或修改办公用品分类")
public String save(Map<String, Object> map) {
if (map == null) {
throw new CustomException("参数不能为空");
}
Object id = map.get("id");
if (id == null || String.valueOf(id).trim().isEmpty()) {
// 新增
if (commonService.insert(namespace + "insert", map) != 1) {
throw new CustomException("保存失败");
}
} else {
// 修改
int affected = commonService.update(namespace + "update", map);
if (affected < 0) {
throw new CustomException("保存失败");
}
}
return SUCCESS;
}
@ApiOperation(value = "删除办公用品分类", desc = "逻辑删除办公用品分类")
public String delete(Map<String, Object> map) {
if (map == null || map.get("id") == null) {
throw new CustomException("参数不能为空");
}
int affected = commonService.update(namespace + "delete", map);
if (affected < 0) {
throw new CustomException("删除失败");
}
return SUCCESS;
}
}
package com.scpyun.platform.jilinsscgsdp.service.impl;
import com.scpyun.base.core.annotation.Api;
import com.scpyun.base.core.annotation.ApiOperation;
import com.scpyun.base.core.exception.CustomException;
import com.scpyun.base.db.service.CommonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.Map;
@Api("办公用品管理")
@Service("keyDmMaterial")
public class KeyDmMaterialServiceImpl {
@Autowired
private CommonService commonService;
private static final String SUCCESS = "success";
private final String namespace = "com.scpyun.platform.standard.jilinsscgsdp.keyDmMaterial.";
@ApiOperation(value = "查询办公用品列表", desc = "分页查询办公用品")
public Map<String, Object> selectList(Map<String, Object> map) {
if (map == null) {
map = new HashMap<>();
}
return commonService.findPage(namespace + "selectList", map);
}
@ApiOperation(value = "保存办公用品", desc = "新增或修改办公用品")
public String save(Map<String, Object> map) {
if (map == null) {
throw new CustomException("参数不能为空");
}
Object id = map.get("id");
if (id == null || String.valueOf(id).trim().isEmpty()) {
// 新增
if (commonService.insert(namespace + "insert", map) != 1) {
throw new CustomException("保存失败");
}
} else {
// 修改
int affected = commonService.update(namespace + "update", map);
if (affected < 0) {
throw new CustomException("保存失败");
}
}
return SUCCESS;
}
@ApiOperation(value = "删除办公用品", desc = "逻辑删除办公用品")
public String delete(Map<String, Object> map) {
if (map == null || map.get("id") == null) {
throw new CustomException("参数不能为空");
}
int affected = commonService.update(namespace + "delete", map);
if (affected < 0) {
throw new CustomException("删除失败");
}
return SUCCESS;
}
}
package com.scpyun.platform.jilinsscgsdp.service.impl;
import com.scpyun.base.core.annotation.Api;
import com.scpyun.base.core.annotation.ApiOperation;
import com.scpyun.base.core.exception.CustomException;
import com.scpyun.base.db.service.CommonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Api("统计服务")
@Service("keyDmStats")
public class KeyDmStatsServiceImpl {
@Autowired
private CommonService commonService;
private final String namespace = "com.scpyun.platform.standard.jilinsscgsdp.keyDmStats.";
@ApiOperation(value = "使用统计", desc = "统计各部门领用量")
public List<Map<String, Object>> selectUsageStats(Map<String, Object> map) {
if (map == null) map = new HashMap<>();
return commonService.findList(namespace + "selectUsageStats", map);
}
@ApiOperation(value = "使用明细", desc = "查询使用明细")
public List<Map<String, Object>> selectUsageDetails(Map<String, Object> map) {
if (map == null) map = new HashMap<>();
return commonService.findList(namespace + "selectUsageDetails", map);
}
@ApiOperation(value = "工作量统计", desc = "统计人员工作量")
public List<Map<String, Object>> selectWorkloadStats(Map<String, Object> map) {
if (map == null) map = new HashMap<>();
return commonService.findList(namespace + "selectWorkloadStats", map);
}
@ApiOperation(value = "工作量明细", desc = "工作量明细")
public List<Map<String, Object>> selectWorkloadDetails(Map<String, Object> map) {
if (map == null) map = new HashMap<>();
return commonService.findList(namespace + "selectWorkloadDetails", map);
}
}
package com.scpyun.platform.jilinsscgsdp.service.impl;
import com.scpyun.base.core.annotation.Api;
import com.scpyun.base.core.annotation.ApiOperation;
import com.scpyun.base.core.exception.CustomException;
import com.scpyun.base.db.service.CommonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Api("人员分类权限管理")
@Service("keyDmUserCategoryPermission")
public class KeyDmUserCategoryPermissionServiceImpl {
@Autowired
private CommonService commonService;
private static final String SUCCESS = "success";
private final String namespace = "com.scpyun.platform.standard.jilinsscgsdp.keyDmUserCategoryPermission.";
@ApiOperation(value = "查询人员分类权限列表", desc = "根据分类ID查询权限列表")
public List<Map<String, Object>> selectList(Map<String, Object> map) {
if (map == null) {
map = new HashMap<>();
}
return commonService.findList(namespace + "selectList", map);
}
@ApiOperation(value = "保存人员分类权限", desc = "保存分类的权限配置,先删除旧权限再插入新权限")
public String save(Map<String, Object> map) {
if (map == null) {
throw new CustomException("参数不能为空");
}
Object categoryId = map.get("category_id");
if (categoryId == null || String.valueOf(categoryId).trim().isEmpty()) {
throw new CustomException("分类ID不能为空");
}
// 先删除该分类的所有权限
commonService.delete(namespace + "deleteByCategoryId", map);
// 插入新权限
Object permissions = map.get("permissions");
if (permissions != null && permissions instanceof List) {
List<Map<String, Object>> permissionList = (List<Map<String, Object>>) permissions;
for (Map<String, Object> permission : permissionList) {
permission.put("category_id", categoryId);
if (commonService.insert(namespace + "insert", permission) != 1) {
throw new CustomException("保存权限失败");
}
}
}
return SUCCESS;
}
}
package com.scpyun.platform.jilinsscgsdp.service.impl;
import com.scpyun.base.core.annotation.Api;
import com.scpyun.base.core.annotation.ApiOperation;
import com.scpyun.base.core.exception.CustomException;
import com.scpyun.base.db.service.CommonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Api("人员分类管理")
@Service("keyDmUserCategory")
public class KeyDmUserCategoryServiceImpl {
@Autowired
private CommonService commonService;
private static final String SUCCESS = "success";
private final String namespace = "com.scpyun.platform.standard.jilinsscgsdp.keyDmUserCategory.";
@ApiOperation(value = "查询人员分类列表", desc = "分页查询人员分类")
public Map<String, Object> selectList(Map<String, Object> map) {
if (map == null) {
map = new HashMap<>();
}
return commonService.findPage(namespace + "selectList", map);
}
@ApiOperation(value = "保存人员分类", desc = "新增或修改人员分类")
public String save(Map<String, Object> map) {
if (map == null) {
throw new CustomException("参数不能为空");
}
Object id = map.get("id");
if (id == null || String.valueOf(id).trim().isEmpty()) {
// 新增
if (commonService.insert(namespace + "insert", map) != 1) {
throw new CustomException("保存失败");
}
} else {
// 修改
int affected = commonService.update(namespace + "update", map);
if (affected < 0) {
throw new CustomException("保存失败");
}
}
return SUCCESS;
}
@ApiOperation(value = "删除人员分类", desc = "逻辑删除人员分类")
public String delete(Map<String, Object> map) {
if (map == null || map.get("id") == null) {
throw new CustomException("参数不能为空");
}
int affected = commonService.update(namespace + "delete", map);
if (affected < 0) {
throw new CustomException("删除失败");
}
return SUCCESS;
}
}
package com.scpyun.platform.jilinsscgsdp.service.impl;
import com.scpyun.base.core.annotation.Api;
import com.scpyun.base.core.annotation.ApiOperation;
import com.scpyun.base.core.exception.CustomException;
import com.scpyun.base.db.service.CommonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Api("日常人员管理")
@Service("keyDmUser")
public class KeyDmUserServiceImpl {
@Autowired
private CommonService commonService;
private static final String SUCCESS = "success";
private final String namespace = "com.scpyun.platform.standard.jilinsscgsdp.keyDmUser.";
@ApiOperation(value = "分页查询日常人员列表", desc = "分页")
public Map<String, Object> selectList(Map<String, Object> map) {
if (map == null) map = new HashMap<>();
return commonService.findPage(namespace + "selectList", map);
}
@ApiOperation(value = "保存日常人员(编辑)", desc = "保存单条记录")
public String save(Map<String, Object> map) {
if (map == null || map.get("id") == null) {
throw new CustomException("参数缺失");
}
// 如果已存在则更新,否则插入(插入时 id 使用 sys_user.id)
Map<String, Object> exists = commonService.getObject(namespace + "getById", map);
if (exists == null) {
if (commonService.insert(namespace + "insert", map) != 1) {
throw new CustomException("保存失败");
}
} else {
int aff = commonService.update(namespace + "updateSelective", map);
if (aff < 0) throw new CustomException("保存失败");
}
return SUCCESS;
}
@ApiOperation(value = "根据机构编码同步用户", desc = "同步本级及下属机构用户")
public String syncByOffice(Map<String, Object> map) {
if (map == null || map.get("office_code") == null) {
throw new CustomException("缺少机构编码");
}
// 查询 sys_user 列表(通过 office_code 匹配本级及下属机构)
List<Map<String, Object>> sysUsers = commonService.findList(namespace + "selectSysUserByOfficeCode", map);
if (sysUsers == null) return SUCCESS;
for (Map<String, Object> u : sysUsers) {
if (u == null) continue;
Map<String, Object> byIdParam = new HashMap<>();
byIdParam.put("id", u.get("id"));
Map<String, Object> exists = commonService.getObject(namespace + "getById", byIdParam);
if (exists == null) {
// prepare insert map: only copy available fields
Map<String, Object> ins = new HashMap<>();
ins.put("id", u.get("id"));
ins.put("is_ext", 1);
ins.put("office_id", u.get("office_id"));
ins.put("name", u.get("name"));
ins.put("gh", u.get("no"));
ins.put("email", u.get("email"));
ins.put("phone", u.get("phone"));
ins.put("mobile", u.get("mobile"));
ins.put("is_used", 1);
commonService.insert(namespace + "insert", ins);
} else {
// update: only update non-null fields from sys_user (null 不覆盖)
Map<String, Object> upd = new HashMap<>();
upd.put("id", u.get("id"));
if (u.get("office_id") != null) upd.put("office_id", u.get("office_id"));
if (u.get("email") != null) upd.put("email", u.get("email"));
if (u.get("phone") != null) upd.put("phone", u.get("phone"));
if (u.get("mobile") != null) upd.put("mobile", u.get("mobile"));
// 保留原有 is_ext 标识(若希望覆盖可修改)
commonService.update(namespace + "updateSelective", upd);
}
}
return SUCCESS;
}
}
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//oos.juyouhx.com//DTD Mapper 3.0//EN" "http://oss.juyouhx.com/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.scpyun.platform.standard.jilinsscgsdp.keyDmBorrow" name="领用申请">
<select id="selectList" parameterType="page" resultType="map">
SELECT * FROM jl_key_dm_borrow_application
<where>
AND is_used = 1
<if test="params.applicant_name != null and params.applicant_name != ''">
AND (applicant_name LIKE CONCAT('%', #{params.applicant_name}, '%') OR application_no LIKE CONCAT('%', #{params.applicant_name}, '%'))
</if>
</where>
ORDER BY create_time DESC
</select>
<select id="selectPendingList" parameterType="page" resultType="map">
SELECT * FROM jl_key_dm_borrow_application
<where>
AND is_used = 1
AND approval_status = 1
</where>
ORDER BY submit_time DESC
</select>
<select id="getById" parameterType="map" resultType="map">
SELECT * FROM jl_key_dm_borrow_application WHERE id = #{id} LIMIT 1
</select>
<insert id="insert" parameterType="map">
INSERT INTO jl_key_dm_borrow_application(
id,application_no,applicant_id,applicant_name,department_id,department_name,borrow_purpose,expected_return_date,
approval_status,issue_status,is_used,create_by,create_time,order_no
) VALUES (
#{id},#{application_no},#{applicant_id},#{applicant_name},#{department_id},#{department_name},#{borrow_purpose},#{expected_return_date},
#{approval_status},#{issue_status},1,#{_user.id},NOW(),#{order_no}
)
</insert>
<update id="update" parameterType="map">
UPDATE jl_key_dm_borrow_application
SET borrow_purpose = #{borrow_purpose}, expected_return_date = #{expected_return_date}, update_by = #{_user.id}, update_time = NOW()
WHERE id = #{id}
</update>
<update id="submit" parameterType="map">
UPDATE jl_key_dm_borrow_application SET approval_status = 1, submit_time = NOW(), update_by = #{_user.id}, update_time = NOW() WHERE id = #{id}
</update>
<update id="revoke" parameterType="map">
UPDATE jl_key_dm_borrow_application SET approval_status = 0, update_by = #{_user.id}, update_time = NOW() WHERE id = #{id} AND approval_status = 1
</update>
<update id="approve" parameterType="map">
UPDATE jl_key_dm_borrow_application SET approval_status = 9, approval_time = NOW(), issue_status = 1, update_by = #{_user.id}, update_time = NOW() WHERE id = #{id}
</update>
<update id="reject" parameterType="map">
UPDATE jl_key_dm_borrow_application SET approval_status = -1, approval_time = NOW(), approval_opinion = #{comment}, update_by = #{_user.id}, update_time = NOW() WHERE id = #{id}
</update>
<!-- 删除所有明细 -->
<delete id="deleteDetailsByApplicationId" parameterType="map">
DELETE FROM jl_key_dm_borrow_application_detail WHERE application_id = #{id}
</delete>
<!-- 生成出库记录与明细(批量由 mapper 内部实现) -->
<insert id="insertOutboundByApplication" parameterType="map">
<!-- mapper implementation should insert outbound record and details based on application id -->
INSERT INTO jl_key_dm_outbound_record(id,outbound_no,outbound_type,outbound_date,receiver_id,receiver_name,receiver_department_id,receiver_department_name,outbound_status,remark,is_used,create_by,create_time)
SELECT UUID(), CONCAT('OUT', REPLACE(UUID(),'-','')) , 2, NOW(), applicant_id, applicant_name, department_id, department_name, 1, borrow_purpose, 1, #{_user.id}, NOW()
FROM jl_key_dm_borrow_application WHERE id = #{id}
</insert>
<!-- 更新库存:根据申请明细扣减可用库存(mapper 内部实现以事务执行) -->
<update id="updateInventoryByApplication" parameterType="map">
<!-- 简化:调用存储过程或在 mapper 中实现逐条更新 -->
<!-- 实际实现依赖于业务,留给 mapper/服务调用具体 SQL -->
</update>
<!-- 插入日志 -->
<insert id="insertMaterialLogByApplication" parameterType="map">
<!-- 简化:实现者可在业务层调用单条插入,此处为占位 -->
</insert>
</mapper>
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//oos.juyouhx.com//DTD Mapper 3.0//EN" "http://oss.juyouhx.com/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.scpyun.platform.standard.jilinsscgsdp.keyDmBorrowDetail" name="领用申请明细">
<insert id="insertDetail" parameterType="map">
INSERT INTO jl_key_dm_borrow_application_detail(
id,application_id,material_id,material_code,material_name,apply_quantity,unit,issue_remark,returned_quantity,damaged_quantity,is_used,create_by,create_time
) VALUES (
#{id},#{application_id},#{material_id},#{material_code},#{material_name},#{apply_quantity},#{unit},#{issue_remark},COALESCE(#{returned_quantity},0),COALESCE(#{damaged_quantity},0),1,#{_user.id},NOW()
)
</insert>
<select id="selectDetailsByApplicationId" parameterType="map" resultType="map">
SELECT * FROM jl_key_dm_borrow_application_detail WHERE application_id = #{id} AND is_used = 1 ORDER BY create_time ASC
</select>
</mapper>
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//oos.juyouhx.com//DTD Mapper 3.0//EN" "http://oss.juyouhx.com/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.scpyun.platform.standard.jilinsscgsdp.keyDmInboundDetail" name="入库明细">
<insert id="insertDetail" parameterType="map">
INSERT INTO jl_key_dm_inbound_detail(
id,inbound_id,material_id,inbound_type,inbound_quantity,unit_price,total_amount,production_date,expiry_date,is_used,create_by,create_time
) VALUES (
#{id},#{inbound_id},#{material_id},#{inbound_type},#{inbound_quantity},#{unit_price},#{total_amount},#{production_date},#{expiry_date},1,#{_user.id},NOW()
)
</insert>
<select id="selectDetailsByInboundId" parameterType="map" resultType="map">
SELECT * FROM jl_key_dm_inbound_detail WHERE inbound_id = #{id} AND is_used = 1 ORDER BY create_time ASC
</select>
<delete id="deleteDetailsByInboundId" parameterType="map">
DELETE FROM jl_key_dm_inbound_detail WHERE inbound_id = #{id}
</delete>
</mapper>
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//oos.juyouhx.com//DTD Mapper 3.0//EN" "http://oss.juyouhx.com/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.scpyun.platform.standard.jilinsscgsdp.keyDmInbound" name="入库记录">
<select id="selectList" parameterType="page" resultType="map">
SELECT * FROM jl_key_dm_inbound_record
<where>
AND is_used = 1
<if test="params.inbound_no != null and params.inbound_no != ''">
AND (inbound_no LIKE CONCAT('%', #{params.inbound_no}, '%') OR batch_no LIKE CONCAT('%', #{params.inbound_no}, '%'))
</if>
</where>
ORDER BY inbound_date DESC
</select>
<select id="getById" parameterType="map" resultType="map">
SELECT * FROM jl_key_dm_inbound_record WHERE id = #{id} LIMIT 1
</select>
<insert id="insert" parameterType="map">
INSERT INTO jl_key_dm_inbound_record(
id,inbound_no,batch_no,inbound_date,inbound_type,storage_location,inbound_status,remark,is_used,create_by,create_time,order_no
) VALUES (
#{id},#{inbound_no},#{batch_no},#{inbound_date},#{inbound_type},#{storage_location},#{inbound_status},#{remark},1,#{_user.id},NOW(),#{order_no}
)
</insert>
<update id="update" parameterType="map">
UPDATE jl_key_dm_inbound_record
SET inbound_no=#{inbound_no},batch_no=#{batch_no},inbound_date=#{inbound_date},storage_location=#{storage_location},remark=#{remark},update_by=#{_user.id},update_time=NOW()
WHERE id = #{id}
</update>
<update id="delete" parameterType="map">
UPDATE jl_key_dm_inbound_record SET is_used = 0, update_by = #{_user.id}, update_time = NOW() WHERE id = #{id}
</update>
<update id="doInbound" parameterType="map">
UPDATE jl_key_dm_inbound_record SET inbound_status = 1, inbound_date = NOW(), update_by = #{_user.id}, update_time = NOW() WHERE id = #{id} AND inbound_status = 0
</update>
<!-- select inventory list for page -->
<select id="selectInventoryList" parameterType="page" resultType="map">
SELECT * FROM jl_key_dm_inventory
<where>
AND is_used = 1
<if test="params.material_name != null and params.material_name != ''">
AND (material_name LIKE CONCAT('%', #{params.material_name}, '%') OR material_code LIKE CONCAT('%', #{params.material_name}, '%'))
</if>
</where>
ORDER BY material_name ASC
</select>
<!-- insert inbound by return (simplified) -->
<insert id="insertInboundByReturn" parameterType="map">
INSERT INTO jl_key_dm_inbound_record(id,inbound_no,batch_no,inbound_date,inbound_type,storage_location,inbound_status,remark,is_used,create_by,create_time)
SELECT UUID(), CONCAT('INR', REPLACE(UUID(),'-','')), '', NOW(), 2, '', 1, '归还入库', 1, #{_user.id}, NOW()
FROM jl_key_dm_borrow_application WHERE id = #{id}
</insert>
<!-- update inventory by inbound (placeholder) -->
<update id="updateInventoryByInbound" parameterType="map">
<!-- mapper should iterate details and call KeyDmInventory.increaseAvailable -->
</update>
<select id="selectLogsByInboundId" parameterType="map" resultType="map">
SELECT * FROM jl_key_dm_material_log WHERE relation_id = #{id} AND is_used = 1 ORDER BY create_time ASC
</select>
</mapper>
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//oos.juyouhx.com//DTD Mapper 3.0//EN" "http://oss.juyouhx.com/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.scpyun.platform.standard.jilinsscgsdp.keyDmInventory" name="库存">
<select id="getByMaterialId" parameterType="map" resultType="map">
SELECT * FROM jl_key_dm_inventory WHERE material_id = #{material_id} AND is_used = 1 LIMIT 1
</select>
<update id="decreaseAvailable" parameterType="map">
UPDATE jl_key_dm_inventory
SET available_quantity = available_quantity - #{quantity}, borrowed_quantity = borrowed_quantity + #{quantity}, update_by = #{_user.id}, update_time = NOW()
WHERE material_id = #{material_id} AND available_quantity >= #{quantity}
</update>
<update id="increaseAvailable" parameterType="map">
UPDATE jl_key_dm_inventory
SET available_quantity = available_quantity + #{quantity}, borrowed_quantity = borrowed_quantity - #{quantity}, update_by = #{_user.id}, update_time = NOW()
WHERE material_id = #{material_id}
</update>
</mapper>
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//oos.juyouhx.com//DTD Mapper 3.0//EN" "http://oss.juyouhx.com/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.scpyun.platform.standard.jilinsscgsdp.keyDmLeave" name="请假申请">
<select id="selectList" parameterType="page" resultType="map">
SELECT
id,user_id,user_name,department_id,department_name,leave_type_id,leave_type_name,
start_time,end_time,duration_unit,duration,reason,emergency_contact,emergency_phone,
status,back_reason,submit_time,approval_complete_time,op_result,is_used,create_by,create_time,update_by,update_time,order_no
FROM jl_key_dm_leave_application
<where>
AND is_used = 1
<if test="params.user_name != null and params.user_name != ''">
AND user_name LIKE CONCAT('%', #{params.user_name}, '%')
</if>
</where>
ORDER BY submit_time DESC
</select>
<select id="selectPendingList" parameterType="page" resultType="map">
SELECT * FROM jl_key_dm_leave_application
<where>
AND is_used = 1
AND status = 1
</where>
ORDER BY submit_time DESC
</select>
<select id="getById" parameterType="map" resultType="map">
SELECT * FROM jl_key_dm_leave_application WHERE id = #{id} LIMIT 1
</select>
<insert id="insert" parameterType="map">
INSERT INTO jl_key_dm_leave_application(
id,user_id,user_name,department_id,department_name,leave_type_id,leave_type_name,
start_time,end_time,duration_unit,duration,reason,emergency_contact,emergency_phone,
status,submit_time,is_used,create_by,create_time,order_no
) VALUES (
#{id},#{user_id},#{user_name},#{department_id},#{department_name},#{leave_type_id},#{leave_type_name},
#{start_time},#{end_time},#{duration_unit},#{duration},#{reason},#{emergency_contact},#{emergency_phone},
#{status},#{submit_time},1,#{_user.id},NOW(),#{order_no}
)
</insert>
<update id="update" parameterType="map">
UPDATE jl_key_dm_leave_application
SET
leave_type_id = #{leave_type_id},
leave_type_name = #{leave_type_name},
start_time = #{start_time},
end_time = #{end_time},
duration_unit = #{duration_unit},
duration = #{duration},
reason = #{reason},
emergency_contact = #{emergency_contact},
emergency_phone = #{emergency_phone},
update_by = #{_user.id},
update_time = NOW()
WHERE id = #{id}
</update>
<!-- 提交:设置 status=1 (审核中),submit_time=NOW() -->
<update id="submit" parameterType="map">
UPDATE jl_key_dm_leave_application
SET status = 1, submit_time = NOW(), op_result = 0, update_by = #{_user.id}, update_time = NOW()
WHERE id = #{id}
</update>
<!-- 撤回:仅限审核中状态撤回,设置 status=0 -->
<update id="revoke" parameterType="map">
UPDATE jl_key_dm_leave_application
SET status = 0, op_result = 0, update_by = #{_user.id}, update_time = NOW()
WHERE id = #{id} AND status = 1
</update>
<!-- 审批通过:设置 status=9, op_result=1, approval_complete_time -->
<update id="approve" parameterType="map">
UPDATE jl_key_dm_leave_application
SET status = 9, op_result = 1, approval_complete_time = NOW(), update_by = #{_user.id}, update_time = NOW()
WHERE id = #{id}
</update>
<!-- 驳回:设置 status=-1, op_result=-1, back_reason -->
<update id="reject" parameterType="map">
UPDATE jl_key_dm_leave_application
SET status = -1, op_result = -1, back_reason = #{comment}, approval_complete_time = NOW(), update_by = #{_user.id}, update_time = NOW()
WHERE id = #{id}
</update>
<!-- 统计:按人员统计已通过请假时长(按天数汇总),params.start, params.end, params.department -->
<select id="selectStats" parameterType="map" resultType="map">
SELECT user_id, user_name, department_id, department_name, SUM(duration) AS passed_days
FROM jl_key_dm_leave_application
<where>
AND is_used = 1
AND status = 9
<if test="start != null and end != null">
AND submit_time BETWEEN #{start} AND #{end}
</if>
<if test="department != null and department != ''">
AND (department_id = #{department} OR department_name LIKE CONCAT('%', #{department}, '%'))
</if>
</where>
GROUP BY user_id, user_name, department_id, department_name
ORDER BY passed_days DESC
</select>
</mapper>
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//oos.juyouhx.com//DTD Mapper 3.0//EN" "http://oss.juyouhx.com/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.scpyun.platform.standard.jilinsscgsdp.keyDmLeaveApprovalRecord" name="请假审批记录">
<select id="selectApprovalRecords" parameterType="map" resultType="map">
SELECT id,leave_id,node_index,node_type,approver_id,approver_name,approver_result,approver_time,status,comment,transfer_to_id,transfer_to_name,transfer_reason
FROM jl_key_dm_leave_approval_record
WHERE leave_id = #{id}
ORDER BY approver_time ASC
</select>
<insert id="insert" parameterType="map">
INSERT INTO jl_key_dm_leave_approval_record(
id,leave_id,node_index,node_type,approver_id,approver_name,approver_result,approver_time,status,comment,transfer_to_id,transfer_to_name,transfer_reason,is_used,create_by,create_time,order_no
) VALUES (
#{id},#{leave_id},#{node_index},#{node_type},#{approver_id},#{approver_name},#{approver_result},#{approver_time},#{status},#{comment},#{transfer_to_id},#{transfer_to_name},#{transfer_reason},1,#{_user.id},NOW(),#{order_no}
)
</insert>
<select id="selectApprovalHistory" parameterType="page" resultType="map">
SELECT a.*, l.user_name, l.leave_type_name, l.start_time, l.end_time
FROM jl_key_dm_leave_approval_record a
LEFT JOIN jl_key_dm_leave_application l ON l.id = a.leave_id
<where>
AND a.is_used = 1
<if test="params.approver_name != null and params.approver_name != ''">
AND a.approver_name LIKE CONCAT('%', #{params.approver_name}, '%')
</if>
</where>
ORDER BY a.approver_time DESC
</select>
</mapper>
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//oos.juyouhx.com//DTD Mapper 3.0//EN" "http://oss.juyouhx.com/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.scpyun.platform.standard.jilinsscgsdp.keyDmLeaveType" name="请假类型管理">
<!-- 查询列表 -->
<select id="selectList" parameterType="page" resultType="map">
SELECT
id,
type_code,
type_name,
remark,
base_days,
max_days_per_year,
allow_half_day,
allow_hourly,
require_attachment,
attachment_types,
attachment_desc,
need_approval,
approval_flow_id,
status,
is_used,
create_by,
create_time,
update_by,
update_time,
order_no
FROM jl_key_dm_leave_type
<where>
AND is_used = 1
<if test="params.type_name != null and params.type_name != ''">
AND type_name LIKE CONCAT('%', #{params.type_name}, '%')
</if>
<if test="params.type_code != null and params.type_code != ''">
AND type_code LIKE CONCAT('%', #{params.type_code}, '%')
</if>
</where>
ORDER BY order_no ASC, create_time DESC
</select>
<!-- 新增 -->
<insert id="insert" parameterType="map">
INSERT INTO jl_key_dm_leave_type(
id,
type_code,
type_name,
remark,
base_days,
max_days_per_year,
allow_half_day,
allow_hourly,
require_attachment,
attachment_types,
attachment_desc,
need_approval,
approval_flow_id,
status,
is_used,
create_by,
create_time,
order_no
) VALUES (
UUID(),
#{type_code},
#{type_name},
#{remark},
#{base_days},
#{max_days_per_year},
COALESCE(#{allow_half_day}, 1),
COALESCE(#{allow_hourly}, 1),
COALESCE(#{require_attachment}, 0),
#{attachment_types},
#{attachment_desc},
COALESCE(#{need_approval}, 1),
#{approval_flow_id},
COALESCE(#{status}, 1),
1,
#{_user.id},
NOW(),
#{order_no}
)
</insert>
<!-- 修改 -->
<update id="update" parameterType="map">
UPDATE jl_key_dm_leave_type
SET
type_code = #{type_code},
type_name = #{type_name},
remark = #{remark},
base_days = #{base_days},
max_days_per_year = #{max_days_per_year},
allow_half_day = #{allow_half_day},
allow_hourly = #{allow_hourly},
require_attachment = #{require_attachment},
attachment_types = #{attachment_types},
attachment_desc = #{attachment_desc},
need_approval = #{need_approval},
approval_flow_id = #{approval_flow_id},
status = #{status},
order_no = #{order_no},
update_by = #{_user.id},
update_time = NOW()
WHERE id = #{id}
</update>
<!-- 删除(逻辑删除) -->
<update id="delete" parameterType="map">
UPDATE jl_key_dm_leave_type
SET
is_used = 0,
update_by = #{_user.id},
update_time = NOW()
WHERE id = #{id}
</update>
</mapper>
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//oos.juyouhx.com//DTD Mapper 3.0//EN" "http://oss.juyouhx.com/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.scpyun.platform.standard.jilinsscgsdp.keyDmMaterialCategory" name="办公用品分类管理">
<!-- 查询列表 -->
<select id="selectList" parameterType="page" resultType="map">
SELECT
Id,
category_Code,
category_Name,
parent_Id,
level,
full_Path,
remark,
status,
is_used,
create_by,
create_time,
update_by,
update_time,
order_no
FROM jl_key_dm_material_category
<where>
AND is_used = 1
<if test="params.category_Name != null and params.category_Name != ''">
AND category_Name LIKE CONCAT('%', #{params.category_Name}, '%')
</if>
<if test="params.category_Code != null and params.category_Code != ''">
AND category_Code LIKE CONCAT('%', #{params.category_Code}, '%')
</if>
</where>
ORDER BY order_no ASC, create_time DESC
</select>
<!-- 新增 -->
<insert id="insert" parameterType="map">
INSERT INTO jl_key_dm_material_category(
category_Code,
category_Name,
parent_Id,
level,
full_Path,
remark,
status,
is_used,
create_by,
create_time,
order_no
) VALUES (
#{category_Code},
#{category_Name},
COALESCE(#{parent_Id}, 0),
COALESCE(#{level}, 1),
#{full_Path},
#{remark},
COALESCE(#{status}, 1),
1,
#{_user.id},
NOW(),
#{order_no}
)
</insert>
<!-- 修改 -->
<update id="update" parameterType="map">
UPDATE jl_key_dm_material_category
SET
category_Code = #{category_Code},
category_Name = #{category_Name},
parent_Id = #{parent_Id},
level = #{level},
full_Path = #{full_Path},
remark = #{remark},
status = #{status},
order_no = #{order_no},
update_by = #{_user.id},
update_time = NOW()
WHERE Id = #{id}
</update>
<!-- 删除(逻辑删除) -->
<update id="delete" parameterType="map">
UPDATE jl_key_dm_material_category
SET
is_used = 0,
update_by = #{_user.id},
update_time = NOW()
WHERE Id = #{id}
</update>
</mapper>
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//oos.juyouhx.com//DTD Mapper 3.0//EN" "http://oss.juyouhx.com/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.scpyun.platform.standard.jilinsscgsdp.keyDmMaterial" name="办公用品管理">
<!-- 查询列表 -->
<select id="selectList" parameterType="page" resultType="map">
SELECT
m.id,
m.category_id,
m.material_code,
m.material_name,
m.material_spec,
m.unit,
m.unit_price,
m.storage_location,
m.min_stock,
m.max_stock,
m.status,
m.can_borrow,
m.material_desc,
m.is_used,
m.create_by,
m.create_time,
m.update_by,
m.update_time,
m.order_no,
c.category_Name AS category_name
FROM jl_key_dm_material m
LEFT JOIN jl_key_dm_material_category c ON c.Id = m.category_id
<where>
AND m.is_used = 1
<if test="params.material_name != null and params.material_name != ''">
AND m.material_name LIKE CONCAT('%', #{params.material_name}, '%')
</if>
<if test="params.material_code != null and params.material_code != ''">
AND m.material_code LIKE CONCAT('%', #{params.material_code}, '%')
</if>
<if test="params.category_id != null and params.category_id != ''">
AND m.category_id = #{params.category_id}
</if>
</where>
ORDER BY m.order_no ASC, m.create_time DESC
</select>
<!-- 新增 -->
<insert id="insert" parameterType="map">
INSERT INTO jl_key_dm_material(
id,
category_id,
material_code,
material_name,
material_spec,
unit,
unit_price,
storage_location,
min_stock,
max_stock,
status,
can_borrow,
material_desc,
is_used,
create_by,
create_time,
order_no
) VALUES (
UUID(),
#{category_id},
#{material_code},
#{material_name},
#{material_spec},
#{unit},
#{unit_price},
#{storage_location},
#{min_stock},
#{max_stock},
COALESCE(#{status}, 1),
COALESCE(#{can_borrow}, 1),
#{material_desc},
1,
#{_user.id},
NOW(),
#{order_no}
)
</insert>
<!-- 修改 -->
<update id="update" parameterType="map">
UPDATE jl_key_dm_material
SET
category_id = #{category_id},
material_code = #{material_code},
material_name = #{material_name},
material_spec = #{material_spec},
unit = #{unit},
unit_price = #{unit_price},
storage_location = #{storage_location},
min_stock = #{min_stock},
max_stock = #{max_stock},
status = #{status},
can_borrow = #{can_borrow},
material_desc = #{material_desc},
order_no = #{order_no},
update_by = #{_user.id},
update_time = NOW()
WHERE id = #{id}
</update>
<!-- 删除(逻辑删除) -->
<update id="delete" parameterType="map">
UPDATE jl_key_dm_material
SET
is_used = 0,
update_by = #{_user.id},
update_time = NOW()
WHERE id = #{id}
</update>
</mapper>
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//oos.juyouhx.com//DTD Mapper 3.0//EN" "http://oss.juyouhx.com/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.scpyun.platform.standard.jilinsscgsdp.keyDmMaterialLog" name="物料操作日志">
<insert id="insertLog" parameterType="map">
INSERT INTO jl_key_dm_material_log(
id,category_id,material_id,op_type,relation_id,relation_item_id,quantity,unit_price,total_amount,is_used,create_by,create_time
) VALUES (
#{id},#{category_id},#{material_id},#{op_type},#{relation_id},#{relation_item_id},#{quantity},#{unit_price},#{total_amount},1,#{_user.id},NOW()
)
</insert>
<select id="selectLogsByApplicationId" parameterType="map" resultType="map">
SELECT * FROM jl_key_dm_material_log WHERE relation_id = #{id} AND is_used = 1 ORDER BY create_time ASC
</select>
</mapper>
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//oos.juyouhx.com//DTD Mapper 3.0//EN" "http://oss.juyouhx.com/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.scpyun.platform.standard.jilinsscgsdp.keyDmOutbound" name="出库记录">
<insert id="insertOutboundRecord" parameterType="map">
INSERT INTO jl_key_dm_outbound_record(
id,outbound_no,outbound_type,outbound_date,receiver_id,receiver_name,receiver_department_id,receiver_department_name,outbound_status,remark,is_used,create_by,create_time
) VALUES (
#{id},#{outbound_no},#{outbound_type},#{outbound_date},#{receiver_id},#{receiver_name},#{receiver_department_id},#{receiver_department_name},#{outbound_status},#{remark},1,#{_user.id},NOW()
)
</insert>
<insert id="insertOutboundDetail" parameterType="map">
INSERT INTO jl_key_dm_outbound_detail(
id,outbound_id,material_id,outbound_type,outbound_quantity,unit_price,total_amount,borrow_application_detail_id,is_used,create_by,create_time
) VALUES (
#{id},#{outbound_id},#{material_id},#{outbound_type},#{outbound_quantity},#{unit_price},#{total_amount},#{borrow_application_detail_id},1,#{_user.id},NOW()
)
</insert>
</mapper>
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//oos.juyouhx.com//DTD Mapper 3.0//EN" "http://oss.juyouhx.com/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.scpyun.platform.standard.jilinsscgsdp.keyDmStats" name="统计">
<!-- 使用统计:按部门、物料统计领用数量 -->
<select id="selectUsageStats" parameterType="map" resultType="map">
SELECT
b.department_id,
b.department_name,
d.material_id,
d.material_name,
SUM(d.apply_quantity) AS total_quantity
FROM jl_key_dm_borrow_application_detail d
LEFT JOIN jl_key_dm_borrow_application b ON b.id = d.application_id
<where>
AND b.is_used = 1
<if test="params.start != null and params.start != '' and params.end != null and params.end != ''">
AND b.create_time BETWEEN #{params.start} AND #{params.end}
</if>
<if test="params.material != null and params.material != ''">
AND (d.material_name LIKE CONCAT('%', #{params.material}, '%') OR d.material_code LIKE CONCAT('%', #{params.material}, '%'))
</if>
</where>
GROUP BY b.department_id, b.department_name, d.material_id, d.material_name
ORDER BY total_quantity DESC
</select>
<!-- 使用明细 -->
<select id="selectUsageDetails" parameterType="map" resultType="map">
SELECT b.application_no, b.applicant_id, b.applicant_name, b.department_id, b.department_name,
d.material_id, d.material_code, d.material_name, d.apply_quantity, d.unit, b.create_time
FROM jl_key_dm_borrow_application_detail d
LEFT JOIN jl_key_dm_borrow_application b ON b.id = d.application_id
<where>
AND b.is_used = 1
<if test="params.start != null and params.start != '' and params.end != null and params.end != ''">
AND b.create_time BETWEEN #{params.start} AND #{params.end}
</if>
<if test="params.material != null and params.material != ''">
AND (d.material_name LIKE CONCAT('%', #{params.material}, '%') OR d.material_code LIKE CONCAT('%', #{params.material}, '%'))
</if>
<if test="params.department != null and params.department != ''">
AND b.department_id = #{params.department}
</if>
</where>
ORDER BY b.create_time DESC
</select>
<!-- 工作量统计:合并多表数据后按人员统计 -->
<select id="selectWorkloadStats" parameterType="map" resultType="map">
SELECT uid AS user_id, uname AS user_name,
SUM(leave_app) AS leave_applications,
SUM(leave_approve) AS leave_approvals,
SUM(borrow_app) AS borrow_applications,
SUM(inbound_cnt) AS inbound_count,
SUM(leave_duration) AS leave_duration
FROM (
SELECT l.user_id AS uid, l.user_name AS uname, 1 AS leave_app, 0 AS leave_approve, 0 AS borrow_app, 0 AS inbound_cnt, COALESCE(l.duration,0) AS leave_duration
FROM jl_key_dm_leave_application l
WHERE l.create_time BETWEEN #{params.start} AND #{params.end}
UNION ALL
SELECT r.approver_id AS uid, r.approver_name AS uname, 0, CASE WHEN r.approver_result = 1 THEN 1 ELSE 0 END, 0, 0, 0
FROM jl_key_dm_leave_approval_record r
WHERE r.approver_time BETWEEN #{params.start} AND #{params.end}
UNION ALL
SELECT b.applicant_id AS uid, b.applicant_name AS uname, 0, 0, 1, 0, 0
FROM jl_key_dm_borrow_application b
WHERE b.create_time BETWEEN #{params.start} AND #{params.end}
UNION ALL
SELECT o.receiver_id AS uid, o.receiver_name AS uname, 0, 0, 0, 1, 0
FROM jl_key_dm_outbound_record o
WHERE o.create_time BETWEEN #{params.start} AND #{params.end}
) t
GROUP BY uid, uname
ORDER BY leave_applications DESC, borrow_applications DESC
</select>
<!-- 工作量明细:按类型返回对应明细 -->
<select id="selectWorkloadDetails" parameterType="map" resultType="map">
<choose>
<when test="params.type == 'leave'">
SELECT id, user_id, user_name, start_time, end_time, duration, reason FROM jl_key_dm_leave_application
WHERE user_id = #{params.user_id} AND create_time BETWEEN #{params.start} AND #{params.end}
ORDER BY create_time DESC
</when>
<when test="params.type == 'inventory'">
SELECT b.application_no, b.applicant_id, b.applicant_name, d.material_name, d.apply_quantity
FROM jl_key_dm_borrow_application_detail d
LEFT JOIN jl_key_dm_borrow_application b ON b.id = d.application_id
WHERE b.applicant_id = #{params.user_id} AND b.create_time BETWEEN #{params.start} AND #{params.end}
ORDER BY b.create_time DESC
</when>
<otherwise>
SELECT 1 AS dummy
</otherwise>
</choose>
</select>
</mapper>
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//oos.juyouhx.com//DTD Mapper 3.0//EN" "http://oss.juyouhx.com/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.scpyun.platform.standard.jilinsscgsdp.keyDmUserCategory" name="人员分类管理">
<!-- 查询列表 -->
<select id="selectList" parameterType="page" resultType="map">
SELECT
id,
catgory_name,
remark,
is_used,
create_by,
create_time,
update_by,
update_time,
order_no
FROM jl_key_dm_user_catgory
<where>
AND is_used = 1
<if test="params.catgory_name != null and params.catgory_name != ''">
AND catgory_name LIKE CONCAT('%', #{params.catgory_name}, '%')
</if>
</where>
ORDER BY order_no ASC, create_time DESC
</select>
<!-- 新增 -->
<insert id="insert" parameterType="map">
INSERT INTO jl_key_dm_user_catgory(
id,
catgory_name,
remark,
is_used,
create_by,
create_time,
order_no
) VALUES (
UUID(),
#{catgory_name},
#{remark},
1,
#{_user.id},
NOW(),
#{order_no}
)
</insert>
<!-- 修改 -->
<update id="update" parameterType="map">
UPDATE jl_key_dm_user_catgory
SET
catgory_name = #{catgory_name},
remark = #{remark},
order_no = #{order_no},
update_by = #{_user.id},
update_time = NOW()
WHERE id = #{id}
</update>
<!-- 删除(逻辑删除) -->
<update id="delete" parameterType="map">
UPDATE jl_key_dm_user_catgory
SET
is_used = 0,
update_by = #{_user.id},
update_time = NOW()
WHERE id = #{id}
</update>
</mapper>
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//oos.juyouhx.com//DTD Mapper 3.0//EN" "http://oss.juyouhx.com/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.scpyun.platform.standard.jilinsscgsdp.keyDmUserCategoryPermission" name="人员分类权限管理">
<!-- 查询列表 -->
<select id="selectList" parameterType="map" resultType="map">
SELECT
id,
catgory_id,
permission_mark,
permission_name,
remark,
is_used,
create_by,
create_time,
update_by,
update_time,
order_no
FROM jl_key_dm_user_qx
<where>
AND is_used = 1
<if test="category_id != null and category_id != ''">
AND catgory_id = #{category_id}
</if>
</where>
ORDER BY order_no ASC, create_time DESC
</select>
<!-- 新增 -->
<insert id="insert" parameterType="map">
INSERT INTO jl_key_dm_user_qx(
id,
catgory_id,
permission_mark,
permission_name,
remark,
is_used,
create_by,
create_time,
order_no
) VALUES (
UUID(),
#{category_id},
#{permission_mark},
#{permission_name},
#{remark},
1,
#{_user.id},
NOW(),
#{order_no}
)
</insert>
<!-- 根据分类ID删除 -->
<delete id="deleteByCategoryId" parameterType="map">
DELETE FROM jl_key_dm_user_qx
WHERE catgory_id = #{category_id}
</delete>
</mapper>
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//oos.juyouhx.com//DTD Mapper 3.0//EN" "http://oss.juyouhx.com/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="com.scpyun.platform.standard.jilinsscgsdp.keyDmUser" name="日常人员管理">
<!-- 分页查询日常人员(可按姓名过滤) -->
<select id="selectList" parameterType="page" resultType="map">
SELECT
u.Id,
u.is_ext,
u.is_leave,
u.rc_role_id,
u.office_id,
o.name AS office_name,
u.name,
u.gh,
u.email,
u.phone,
u.mobile,
u.birthday,
u.in_work_time,
u.leader,
u.leader_name,
u.is_used,
u.create_by,
u.create_time,
u.update_by,
u.update_time,
u.order_no
FROM jl_key_dm_user u
LEFT JOIN sys_office o ON o.id = u.office_id
<where>
AND u.is_used = 1
<if test="params.name != null and params.name != ''">
AND u.name LIKE CONCAT('%', #{params.name}, '%')
</if>
</where>
ORDER BY u.order_no ASC, u.create_time DESC
</select>
<!-- 从 sys_user 查询指定机构(及下属机构)的用户,office_code 为机构 code 字段 -->
<select id="selectSysUserByOfficeCode" parameterType="map" resultType="map">
SELECT su.*
FROM sys_user su
WHERE su.office_id IN (
SELECT so.id FROM sys_office so
WHERE so.parent_ids LIKE CONCAT('%', #{office_code}, '%') OR so.code = #{office_code}
)
AND (su.del_flag IS NULL OR su.del_flag = '0')
</select>
<!-- 根据 id 获取日常人员 -->
<select id="getById" parameterType="map" resultType="map">
SELECT * FROM jl_key_dm_user WHERE Id = #{id} LIMIT 1
</select>
<!-- 插入 -->
<insert id="insert" parameterType="map">
INSERT INTO jl_key_dm_user(
Id, is_ext, is_leave, rc_role_id, office_id, name, gh, email, phone, mobile,
birthday, in_work_time, leader, leader_name, is_used, create_by, create_time, order_no
) VALUES (
#{id},
#{is_ext},
#{is_leave},
#{rc_role_id},
#{office_id},
#{name},
#{gh},
#{email},
#{phone},
#{mobile},
#{birthday},
#{in_work_time},
#{leader},
#{leader_name},
COALESCE(#{is_used},1),
#{_user.id},
NOW(),
#{order_no}
)
</insert>
<!-- 有选择性地更新字段(null 不覆盖) -->
<update id="updateSelective" parameterType="map">
UPDATE jl_key_dm_user
<set>
<if test="office_id != null">office_id = #{office_id},</if>
<if test="email != null">email = #{email},</if>
<if test="phone != null">phone = #{phone},</if>
<if test="mobile != null">mobile = #{mobile},</if>
<if test="is_leave != null">is_leave = #{is_leave},</if>
<if test="rc_role_id != null">rc_role_id = #{rc_role_id},</if>
<if test="birthday != null">birthday = #{birthday},</if>
<if test="in_work_time != null">in_work_time = #{in_work_time},</if>
<if test="leader != null">leader = #{leader},</if>
<if test="leader_name != null">leader_name = #{leader_name},</if>
update_by = #{_user.id},
update_time = NOW()
</set>
WHERE Id = #{id}
</update>
</mapper>
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论