|
@@ -0,0 +1,306 @@
|
|
|
|
|
+package com.minpay.huicai.personmanage.action;
|
|
|
|
|
+
|
|
|
|
|
+import java.util.HashMap;
|
|
|
|
|
+import java.util.List;
|
|
|
|
|
+import java.util.Map;
|
|
|
|
|
+
|
|
|
|
|
+import com.minpay.common.bean.User;
|
|
|
|
|
+import com.minpay.common.constant.Constant;
|
|
|
|
|
+import com.minpay.common.exception.BusinessCodeException;
|
|
|
|
|
+import com.minpay.common.format.IFormatService;
|
|
|
|
|
+import com.minpay.common.service.ILogService;
|
|
|
|
|
+import com.minpay.common.service.IPublicService;
|
|
|
|
|
+import com.minpay.common.util.RegexUtil;
|
|
|
|
|
+import com.minpay.db.table.mapper.ImBranchMapper;
|
|
|
|
|
+import com.minpay.db.table.mapper.ImUserMapper;
|
|
|
|
|
+import com.minpay.db.table.model.ImBranch;
|
|
|
|
|
+import com.minpay.db.table.model.ImBranchExample;
|
|
|
|
|
+import com.minpay.db.table.model.ImUser;
|
|
|
|
|
+import com.minpay.db.table.model.ImUserExample;
|
|
|
|
|
+import com.minpay.db.table.own.mapper.BranchManageMapper;
|
|
|
|
|
+import com.startup.minpay.frame.business.IMINAction;
|
|
|
|
|
+import com.startup.minpay.frame.business.MINHttpServletRequestContext;
|
|
|
|
|
+import com.startup.minpay.frame.business.res.MINActionResult;
|
|
|
|
|
+import com.startup.minpay.frame.constant.IMINBusinessConstant;
|
|
|
|
|
+import com.startup.minpay.frame.constant.IMINTransactionEnum;
|
|
|
|
|
+import com.startup.minpay.frame.data.format.MINCopyFormat;
|
|
|
|
|
+import com.startup.minpay.frame.exception.MINBusinessException;
|
|
|
|
|
+import com.startup.minpay.frame.jdbc.MINRowBounds;
|
|
|
|
|
+import com.startup.minpay.frame.service.base.IMINDataBaseService;
|
|
|
|
|
+import com.startup.minpay.frame.service.base.Service;
|
|
|
|
|
+import com.startup.minpay.frame.session.MINSession;
|
|
|
|
|
+import com.startup.minpay.frame.target.MINAction;
|
|
|
|
|
+import com.startup.minpay.frame.target.MINComponent;
|
|
|
|
|
+import com.startup.minpay.frame.target.MINParam;
|
|
|
|
|
+import com.startup.minpay.frame.target.MINValidator;
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * 部门管理
|
|
|
|
|
+ * @author Zhumq
|
|
|
|
|
+ *
|
|
|
|
|
+ */
|
|
|
|
|
+@MINComponent
|
|
|
|
|
+public class DepartmentManageAction implements IMINAction {
|
|
|
|
|
+
|
|
|
|
|
+ /**查询部门*/
|
|
|
|
|
+ public final static String BRANCH_QUERY_ALL = "branchQueryAll";
|
|
|
|
|
+
|
|
|
|
|
+ /**添加部门*/
|
|
|
|
|
+ public final static String ADD_BRANCH = "addBranch";
|
|
|
|
|
+
|
|
|
|
|
+ /**删除部门*/
|
|
|
|
|
+ public final static String DELETE_BRANCH = "deleteBranch";
|
|
|
|
|
+
|
|
|
|
|
+ /**编辑部门*/
|
|
|
|
|
+ public final static String MODIFY_BRANCH = "modifyBranch";
|
|
|
|
|
+
|
|
|
|
|
+ /**部门人员列表*/
|
|
|
|
|
+ public final static String STAFFLIST = "staffList";
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 查询当前操作员所属机构以及下属机构信息
|
|
|
|
|
+ * @param page
|
|
|
|
|
+ * @param limit
|
|
|
|
|
+ * @param branchLevel
|
|
|
|
|
+ * @param branchId
|
|
|
|
|
+ * @param branchName
|
|
|
|
|
+ * @param branchStatus
|
|
|
|
|
+ * @param session
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ @MINAction(value = BRANCH_QUERY_ALL, transaction = IMINTransactionEnum.CMT)
|
|
|
|
|
+ public MINActionResult branchQueryAll(
|
|
|
|
|
+ @MINParam(key = "page", defaultValue = "1") int page,
|
|
|
|
|
+ @MINParam(key = "limit", defaultValue = "3") int limit,
|
|
|
|
|
+ @MINParam(key = "branchLevel") String[] branchLevel,
|
|
|
|
|
+ @MINParam(key = "branchId") String branchId,
|
|
|
|
|
+ @MINParam(key = "type") String type,
|
|
|
|
|
+ @MINParam(key = "branchName") String branchName,
|
|
|
|
|
+ @MINParam(key = "branchStatus") String branchStatus,
|
|
|
|
|
+ @MINParam(key = "branchType") String branchType,
|
|
|
|
|
+ @MINParam(key = "bIds") String bIds,
|
|
|
|
|
+ MINSession session
|
|
|
|
|
+ ) throws MINBusinessException {
|
|
|
|
|
+
|
|
|
|
|
+ MINActionResult res = new MINActionResult();
|
|
|
|
|
+ MINRowBounds rows = new MINRowBounds(page, limit);
|
|
|
|
|
+ User user = session.getUser();
|
|
|
|
|
+ String bId = user.getBranchid();
|
|
|
|
|
+ if(bId==null || "".equals(bId)){
|
|
|
|
|
+ throw new MINBusinessException("获取客户开户机构号失败!");
|
|
|
|
|
+ }
|
|
|
|
|
+ if(!"".equals(bIds)){
|
|
|
|
|
+ bId = bIds;
|
|
|
|
|
+ }
|
|
|
|
|
+ Map<String,String> map = new HashMap<String,String>();
|
|
|
|
|
+ map.put("bId", bId);
|
|
|
|
|
+ map.put("branchId", branchId);
|
|
|
|
|
+ map.put("branchName", branchName);
|
|
|
|
|
+ map.put("branchStatus", branchStatus);
|
|
|
|
|
+ map.put("branchType", branchType);
|
|
|
|
|
+ List<Map<String, Object>> ls = null;
|
|
|
|
|
+ //如果操作员所属机构为系统机构则查询所有机构信息
|
|
|
|
|
+ if("88888888".equals(bId)){
|
|
|
|
|
+ ls = Service.lookup(IMINDataBaseService.class).getMybatisMapper(BranchManageMapper.class).queryAllBranch(map,rows);
|
|
|
|
|
+ }else{
|
|
|
|
|
+ ls = Service.lookup(IMINDataBaseService.class).getMybatisMapper(BranchManageMapper.class).queryBranchByLevel(map,rows);
|
|
|
|
|
+ }
|
|
|
|
|
+ for(Map<String,Object> m : ls){
|
|
|
|
|
+ if(bId.equals(m.get("branchId").toString())){
|
|
|
|
|
+ m.put("flag", "0");
|
|
|
|
|
+ }else{
|
|
|
|
|
+ m.put("flag", "1");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ ls = new MINCopyFormat("{stt:'sttdesc',level:'leveldesc',branchType:'branchTypedesc'}").format(ls);
|
|
|
|
|
+ ls = Service.lookup(IFormatService.class).formatEnum(ls, "{sttdesc:'IM_BRANCH_STATE',leveldesc:'IM_BRANCH_LEVEL',branchTypedesc:'BRANCH_TYPE'}");
|
|
|
|
|
+ res.set(IMINBusinessConstant.F_PAGING_LAY, ls);
|
|
|
|
|
+ res.set(IMINBusinessConstant.F_PAGING_COUNT, rows.getCount());
|
|
|
|
|
+
|
|
|
|
|
+ return res;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 添加部门(添加商户)
|
|
|
|
|
+ * @param fapResult
|
|
|
|
|
+ * @param pointName 机构名称
|
|
|
|
|
+ * @param shortName 简称
|
|
|
|
|
+ * @param remark 简介
|
|
|
|
|
+ * @param session
|
|
|
|
|
+ * @return
|
|
|
|
|
+ * @throws MINBusinessException
|
|
|
|
|
+ */
|
|
|
|
|
+ @MINAction(value = ADD_BRANCH, transaction = IMINTransactionEnum.CMT)
|
|
|
|
|
+ public MINActionResult addBranch(
|
|
|
|
|
+ MINHttpServletRequestContext fapResult,
|
|
|
|
|
+ @MINParam(key ="pointName") String pointName,
|
|
|
|
|
+ @MINParam(key ="shortName") String shortName,
|
|
|
|
|
+ @MINParam(key ="remark") String remark,
|
|
|
|
|
+ @MINParam(key ="person") String person,
|
|
|
|
|
+ @MINParam(key ="phone") String phone,
|
|
|
|
|
+ MINSession session
|
|
|
|
|
+ ) throws MINBusinessException {
|
|
|
|
|
+ MINActionResult res = new MINActionResult();
|
|
|
|
|
+ User user = session.getUser();
|
|
|
|
|
+ String branchId = user.getBranchid();
|
|
|
|
|
+ ImBranch imb = Service.lookup(IMINDataBaseService.class)
|
|
|
|
|
+ .getMybatisMapper(ImBranchMapper.class)
|
|
|
|
|
+ .selectByPrimaryKey(branchId);
|
|
|
|
|
+ if(imb==null){
|
|
|
|
|
+ throw new MINBusinessException("获取机构信息异常!");
|
|
|
|
|
+ }
|
|
|
|
|
+ //检查机构名称
|
|
|
|
|
+ ImBranchExample ibe = new ImBranchExample();
|
|
|
|
|
+ ibe.createCriteria().andNameEqualTo(pointName);
|
|
|
|
|
+ List<ImBranch> branchList = Service.lookup(IMINDataBaseService.class).selectByExample(ImBranchMapper.class, ibe);
|
|
|
|
|
+ if(branchList.size()>0){
|
|
|
|
|
+ throw new BusinessCodeException("JINM0108");
|
|
|
|
|
+ }
|
|
|
|
|
+ String pointNo = Service.lookup(IPublicService.class).getSequence("IM_BRANCH_NO");
|
|
|
|
|
+ Integer level = imb.getLevel();
|
|
|
|
|
+ ImBranch ib = new ImBranch();
|
|
|
|
|
+ ib.setId(pointNo);
|
|
|
|
|
+ ib.setName(pointName);
|
|
|
|
|
+ ib.setLevel(level+1);
|
|
|
|
|
+ ib.setParentid(branchId);
|
|
|
|
|
+ ib.setStt("0");
|
|
|
|
|
+ ib.setDesc(remark);
|
|
|
|
|
+ ib.setPerson(person);
|
|
|
|
|
+ ib.setPhone(phone);
|
|
|
|
|
+ ib.setShortname(shortName);
|
|
|
|
|
+ int i = Service.lookup(IMINDataBaseService.class).insertSelective(ImBranchMapper.class, ib);
|
|
|
|
|
+ if(0==i){
|
|
|
|
|
+ throw new MINBusinessException("新增机构异常");
|
|
|
|
|
+ }
|
|
|
|
|
+ // 记录日志
|
|
|
|
|
+ String logInfo = "新增机构 :"+pointName+",机构编号:"+pointNo;
|
|
|
|
|
+ Service.lookup(ILogService.class).logging(session, logInfo);
|
|
|
|
|
+ return res;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @MINValidator(value = ADD_BRANCH)
|
|
|
|
|
+ public MINActionResult uaddBranchValidator(
|
|
|
|
|
+ @MINParam(key ="pointName", regex = RegexUtil.NOT_NULL,min = 0, max = 100, error = "商户名称不能超过100个字符") String pointName,
|
|
|
|
|
+ @MINParam(key ="shortName") String shortName,
|
|
|
|
|
+ @MINParam(key ="remark", max = 300, error = "描述不能超过300个字符") String remark,
|
|
|
|
|
+ @MINParam(key ="person",regex = RegexUtil.NOT_NULL,min = 0, max = 100, error = "联系人不能超过30个字符") String person,
|
|
|
|
|
+ @MINParam(key ="phone", regex = RegexUtil.NOT_NULL,min = 0, max = 20, error = "联系方式不能超过20个字符") String phone,
|
|
|
|
|
+ MINSession session) throws MINBusinessException {
|
|
|
|
|
+ MINActionResult res = new MINActionResult();
|
|
|
|
|
+ return res;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 修改部门
|
|
|
|
|
+ * @param fapResult
|
|
|
|
|
+ * @param pointNo
|
|
|
|
|
+ * @param pointName
|
|
|
|
|
+ * @param pointPerson
|
|
|
|
|
+ * @param personTlephone
|
|
|
|
|
+ * @param remark
|
|
|
|
|
+ * @param address
|
|
|
|
|
+ * @param shortName
|
|
|
|
|
+ * @param content
|
|
|
|
|
+ * @param session
|
|
|
|
|
+ * @return
|
|
|
|
|
+ * @throws MINBusinessException
|
|
|
|
|
+ */
|
|
|
|
|
+ @MINAction(value = MODIFY_BRANCH)
|
|
|
|
|
+ public MINActionResult modifyBranch(
|
|
|
|
|
+ MINHttpServletRequestContext fapResult,
|
|
|
|
|
+ @MINParam(key ="branchId") String pointNo,
|
|
|
|
|
+ @MINParam(key ="pointName") String pointName,
|
|
|
|
|
+ @MINParam(key ="pointPerson") String pointPerson,
|
|
|
|
|
+ @MINParam(key ="personTlephone") String personTlephone,
|
|
|
|
|
+ @MINParam(key ="remark") String remark,
|
|
|
|
|
+ @MINParam(key ="address") String address,
|
|
|
|
|
+ @MINParam(key ="shortName") String shortName,
|
|
|
|
|
+ @MINParam(key ="content") String content,
|
|
|
|
|
+ MINSession session
|
|
|
|
|
+ ) throws MINBusinessException {
|
|
|
|
|
+ MINActionResult res = new MINActionResult();
|
|
|
|
|
+ //检查部门名称
|
|
|
|
|
+ ImBranchExample ibe = new ImBranchExample();
|
|
|
|
|
+ ibe.createCriteria().andNameEqualTo(pointName).andIdNotEqualTo(pointNo);
|
|
|
|
|
+ List<ImBranch> branchList = Service.lookup(IMINDataBaseService.class).selectByExample(ImBranchMapper.class, ibe);
|
|
|
|
|
+ if(branchList.size()>0){
|
|
|
|
|
+ throw new BusinessCodeException("JINM0108");
|
|
|
|
|
+ }
|
|
|
|
|
+ ImBranch ib = new ImBranch();
|
|
|
|
|
+
|
|
|
|
|
+ ib.setId(pointNo);
|
|
|
|
|
+ ib.setName(pointName);
|
|
|
|
|
+ ib.setPhone(personTlephone);
|
|
|
|
|
+ ib.setPerson(pointPerson);
|
|
|
|
|
+ ib.setDesc(remark);
|
|
|
|
|
+ ib.setShortname(shortName);
|
|
|
|
|
+ ib.setAddress(address);
|
|
|
|
|
+ int i = Service.lookup(IMINDataBaseService.class).updateByPrimaryKeySelective(ImBranchMapper.class, ib);
|
|
|
|
|
+ if(0==i){
|
|
|
|
|
+ throw new MINBusinessException("插入数据时出现异常");
|
|
|
|
|
+ }
|
|
|
|
|
+ // 记录日志
|
|
|
|
|
+ String logInfo = "修改部门 :"+pointName+",部门编号:"+pointNo;
|
|
|
|
|
+ Service.lookup(ILogService.class).logging(session, logInfo);
|
|
|
|
|
+ return res;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 删除部门
|
|
|
|
|
+ * @param branchId
|
|
|
|
|
+ * @param session
|
|
|
|
|
+ * @return
|
|
|
|
|
+ * @throws MINBusinessException
|
|
|
|
|
+ */
|
|
|
|
|
+ @MINAction(value = DELETE_BRANCH)
|
|
|
|
|
+ public MINActionResult deleteBranch(
|
|
|
|
|
+ @MINParam(key ="branchId") String branchId,
|
|
|
|
|
+ MINSession session
|
|
|
|
|
+ ) throws MINBusinessException {
|
|
|
|
|
+ MINActionResult res = new MINActionResult();
|
|
|
|
|
+ //查询改部门下 有无操作员
|
|
|
|
|
+ ImUserExample example = new ImUserExample();
|
|
|
|
|
+ example.createCriteria().andBranchidEqualTo(branchId);
|
|
|
|
|
+ List<ImUser> userCount = Service.lookup(IMINDataBaseService.class).getMybatisMapper(ImUserMapper.class).selectByExample(example);
|
|
|
|
|
+ // 大于0 则表示有操作员不允许删除 否则可删除
|
|
|
|
|
+ if(userCount.size()>0) {
|
|
|
|
|
+ throw new MINBusinessException("该部门存在操作员,禁止删除!");
|
|
|
|
|
+ }else {
|
|
|
|
|
+ ImBranch ib = new ImBranch();
|
|
|
|
|
+ ib.setId(branchId);
|
|
|
|
|
+ ib.setStt(Constant.DEPT_STT_DEL);
|
|
|
|
|
+ int ret = Service.lookup(IMINDataBaseService.class).updateByPrimaryKeySelective(ImBranchMapper.class, ib);
|
|
|
|
|
+ if(0 == ret){
|
|
|
|
|
+ throw new MINBusinessException("更新数据时出现异常");
|
|
|
|
|
+ }
|
|
|
|
|
+ String logInfo = "删除部门 ,部门编号:"+branchId;
|
|
|
|
|
+ Service.lookup(ILogService.class).logging(session, logInfo);
|
|
|
|
|
+ }
|
|
|
|
|
+ return res;
|
|
|
|
|
+ }
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 查看该部门人员
|
|
|
|
|
+ * @param branchId
|
|
|
|
|
+ * @param session
|
|
|
|
|
+ * @return
|
|
|
|
|
+ * @throws MINBusinessException
|
|
|
|
|
+ */
|
|
|
|
|
+ @MINAction(value = STAFFLIST)
|
|
|
|
|
+ public MINActionResult staffList(
|
|
|
|
|
+ @MINParam(key ="branchId") String branchId,
|
|
|
|
|
+ MINSession session
|
|
|
|
|
+ ) throws MINBusinessException {
|
|
|
|
|
+ MINActionResult res = new MINActionResult();
|
|
|
|
|
+ //查看该部门人员
|
|
|
|
|
+ ImUserExample example = new ImUserExample();
|
|
|
|
|
+ example.createCriteria().andBranchidEqualTo(branchId);
|
|
|
|
|
+ List<ImUser> userList = Service.lookup(IMINDataBaseService.class).getMybatisMapper(ImUserMapper.class).selectByExample(example);
|
|
|
|
|
+ res.set(IMINBusinessConstant.F_PAGING_LAY, userList);
|
|
|
|
|
+ return res;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+}
|