LiGuang 3 gadi atpakaļ
vecāks
revīzija
b5be4557b9

+ 193 - 0
jeecg-boot-module-demo/src/main/java/org/jeecg/modules/geke/usercontract/controller/UserContractController.java

@@ -0,0 +1,193 @@
+package org.jeecg.modules.geke.usercontract.controller;
+
+import java.util.*;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.net.URLDecoder;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.shiro.SecurityUtils;
+import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.system.query.QueryGenerator;
+import org.jeecg.common.aspect.annotation.AutoLog;
+import org.jeecg.common.system.vo.LoginUser;
+import org.jeecg.common.util.oConvertUtils;
+import org.jeecg.modules.geke.userPrize.entity.UserPrize;
+import org.jeecg.modules.geke.userchange.entity.UserChage;
+import org.jeecg.modules.geke.usercontract.entity.UserContract;
+import org.jeecg.modules.geke.usercontract.service.IUserContractService;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.system.base.controller.JeecgController;
+import org.jeecgframework.poi.excel.ExcelImportUtil;
+import org.jeecgframework.poi.excel.def.NormalExcelConstants;
+import org.jeecgframework.poi.excel.entity.ExportParams;
+import org.jeecgframework.poi.excel.entity.ImportParams;
+import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+import org.springframework.web.multipart.MultipartHttpServletRequest;
+import org.springframework.web.servlet.ModelAndView;
+import com.alibaba.fastjson.JSON;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+
+ /**
+ * @Description: 员工合同
+ * @Author: jeecg-boot
+ * @Date:   2022-03-04
+ * @Version: V1.0
+ */
+@Slf4j
+@Api(tags="员工合同")
+@RestController
+@RequestMapping("/usercontract/userContract")
+public class UserContractController extends JeecgController<UserContract, IUserContractService> {
+	@Autowired
+	private IUserContractService userContractService;
+	 @Value("${jeecg.path.upload}")
+	 private String upLoadPath;
+	/**
+	 * 分页列表查询
+	 *
+	 * @param userContract
+	 * @param pageNo
+	 * @param pageSize
+	 * @param req
+	 * @return
+	 */
+	@AutoLog(value = "员工合同-分页列表查询")
+	@ApiOperation(value="员工合同-分页列表查询", notes="员工合同-分页列表查询")
+	@GetMapping(value = "/list")
+	public Result<?> queryPageList(UserContract userContract,
+								   @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
+								   @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
+								   HttpServletRequest req) {
+		QueryWrapper<UserContract> queryWrapper = QueryGenerator.initQueryWrapper(userContract, req.getParameterMap());
+		Page<UserContract> page = new Page<UserContract>(pageNo, pageSize);
+		//IPage<UserContract> pageList = userContractService.page(page, queryWrapper);
+		Page<UserContract> lists = userContractService.lists(page, userContract);
+		return Result.OK(lists);
+	}
+	
+	/**
+	 * 添加
+	 *
+	 * @param userContract
+	 * @return
+	 */
+	@AutoLog(value = "员工合同-添加")
+	@ApiOperation(value="员工合同-添加", notes="员工合同-添加")
+	@PostMapping(value = "/add")
+	public Result<?> add(@RequestBody UserContract userContract) {
+		userContractService.save(userContract);
+		return Result.OK("添加成功!");
+	}
+	
+	/**
+	 * 编辑
+	 *
+	 * @param userContract
+	 * @return
+	 */
+	@AutoLog(value = "员工合同-编辑")
+	@ApiOperation(value="员工合同-编辑", notes="员工合同-编辑")
+	@PutMapping(value = "/edit")
+	public Result<?> edit(@RequestBody UserContract userContract) {
+		userContractService.updateById(userContract);
+		return Result.OK("编辑成功!");
+	}
+	
+	/**
+	 * 通过id删除
+	 *
+	 * @param id
+	 * @return
+	 */
+	@AutoLog(value = "员工合同-通过id删除")
+	@ApiOperation(value="员工合同-通过id删除", notes="员工合同-通过id删除")
+	@DeleteMapping(value = "/delete")
+	public Result<?> delete(@RequestParam(name="id",required=true) String id) {
+		userContractService.removeById(id);
+		return Result.OK("删除成功!");
+	}
+	
+	/**
+	 * 批量删除
+	 *
+	 * @param ids
+	 * @return
+	 */
+	@AutoLog(value = "员工合同-批量删除")
+	@ApiOperation(value="员工合同-批量删除", notes="员工合同-批量删除")
+	@DeleteMapping(value = "/deleteBatch")
+	public Result<?> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
+		this.userContractService.removeByIds(Arrays.asList(ids.split(",")));
+		return Result.OK("批量删除成功!");
+	}
+	
+	/**
+	 * 通过id查询
+	 *
+	 * @param id
+	 * @return
+	 */
+	@AutoLog(value = "员工合同-通过id查询")
+	@ApiOperation(value="员工合同-通过id查询", notes="员工合同-通过id查询")
+	@GetMapping(value = "/queryById")
+	public Result<?> queryById(@RequestParam(name="id",required=true) String id) {
+		UserContract userContract = userContractService.getById(id);
+		return Result.OK(userContract);
+	}
+
+  /**
+   * 导出excel
+   *
+   * @param request
+   * @param userContract
+   */
+  @RequestMapping(value = "/exportXls")
+  public ModelAndView exportXls(HttpServletRequest request, UserContract userContract) {
+	  Page<UserContract> page = new Page<UserContract>(1, 10000);
+	  Page<UserContract> lists = userContractService.lists(page, userContract);
+	  LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+	  ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
+	  mv.addObject(NormalExcelConstants.FILE_NAME, "员工合同信息列表"); //此处设置的filename无效 ,前端会重更新设置一下
+	  mv.addObject(NormalExcelConstants.CLASS, UserContract.class);
+	  //update-begin--Author:liusq  Date:20210126 for:图片导出报错,ImageBasePath未设置--------------------
+	  ExportParams  exportParams=new ExportParams("员工合同信息列表", "导出人:" + sysUser.getRealname(), "员工合同信息列表");
+	  exportParams.setImageBasePath(upLoadPath);
+	  //update-end--Author:liusq  Date:20210126 for:图片导出报错,ImageBasePath未设置----------------------
+	  mv.addObject(NormalExcelConstants.PARAMS,exportParams);
+	  mv.addObject(NormalExcelConstants.DATA_LIST, lists.getRecords());
+      return mv;
+  }
+
+  /**
+   * 通过excel导入数据
+   *
+   * @param request
+   * @param response
+   * @return
+   */
+  @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
+  public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
+      return super.importExcel(request, response, UserContract.class);
+  }
+
+	 @AutoLog(value = "员工合同-分页列表查询")
+	 @ApiOperation(value="员工合同-分页列表查询", notes="员工合同-分页列表查询")
+	 @GetMapping(value = "/lists")
+	 public Result<?> queryPageLists(UserContract userContract) {
+		 Page<UserContract> page = new Page<UserContract>(1, 100);
+		 Map<String,Object>map=new HashMap<>();
+		 List<UserContract> list =userContractService.list(userContract.getUserId());
+		 return Result.OK(page.setRecords(list));
+	 }
+}

+ 83 - 0
jeecg-boot-module-demo/src/main/java/org/jeecg/modules/geke/usercontract/entity/UserContract.java

@@ -0,0 +1,83 @@
+package org.jeecg.modules.geke.usercontract.entity;
+
+import java.io.Serializable;
+import java.util.Date;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.baomidou.mybatisplus.annotation.TableField;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import org.jeecg.common.aspect.annotation.Dict;
+import org.springframework.format.annotation.DateTimeFormat;
+import org.jeecgframework.poi.excel.annotation.Excel;
+
+/**
+ * @Description: 员工合同
+ * @Author: jeecg-boot
+ * @Date:   2022-03-04
+ * @Version: V1.0
+ */
+@Data
+@TableName("geke_user_contract")
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value="geke_user_contract对象", description="员工合同")
+public class UserContract {
+    
+	/**id*/
+	@TableId(type = IdType.ASSIGN_ID)
+    @ApiModelProperty(value = "id")
+	private java.lang.String id;
+	@Excel(name = "员工姓名", width = 15)
+	private  transient String realname;
+	@Excel(name = "一级部门", width = 15)
+	private  transient String deptName;
+	@Excel(name = "二级部门", width = 15)
+	private  transient String deptName1;
+	@Excel(name = "三级部门", width = 15)
+	private  transient String deptName2;
+	@Excel(name = "末级部门", width = 15)
+	private  transient String deptNames;
+	/**用户id*/
+
+    @ApiModelProperty(value = "用户id")
+	private java.lang.String userId;
+
+
+	@ApiModelProperty(value = "部门id")
+	private java.lang.String deptId;
+
+	/**合同类型*/
+	@Excel(name = "合同类型", width = 15,dicCode="contract_type")
+    @ApiModelProperty(value = "合同类型")
+	@Dict(dicCode = "contract_type")
+	private java.lang.String contractType;
+	/**开始时间*/
+	@Excel(name = "开始时间", width = 20, format = "yyyy-MM-dd")
+	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "开始时间")
+	private java.util.Date startDate;
+	/**结束时间*/
+	@Excel(name = "结束时间", width = 20, format = "yyyy-MM-dd")
+	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "结束时间")
+	private java.util.Date endDate;
+	/**创建人*/
+    @ApiModelProperty(value = "创建人")
+	@Dict(dicCode = "id",dictTable = "sys_user",dicText = "realname")
+	private java.lang.String createBy;
+	/**创建时间*/
+	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "创建时间")
+	private java.util.Date createTime;
+
+
+}

+ 23 - 0
jeecg-boot-module-demo/src/main/java/org/jeecg/modules/geke/usercontract/mapper/UserContractMapper.java

@@ -0,0 +1,23 @@
+package org.jeecg.modules.geke.usercontract.mapper;
+
+import java.util.List;
+
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import org.apache.catalina.User;
+import org.apache.ibatis.annotations.Param;
+import org.jeecg.modules.geke.userPrize.entity.UserPrize;
+import org.jeecg.modules.geke.usercontract.entity.UserContract;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * @Description: 员工合同
+ * @Author: jeecg-boot
+ * @Date:   2022-03-04
+ * @Version: V1.0
+ */
+public interface UserContractMapper extends BaseMapper<UserContract> {
+
+    List<UserContract>lists(Page<UserContract> page,@Param("userContract")UserContract userContract,@Param("deptids")List<String>deptids);
+
+    List<UserContract>list(@Param("userid")String userid);
+}

+ 27 - 0
jeecg-boot-module-demo/src/main/java/org/jeecg/modules/geke/usercontract/mapper/xml/UserContractMapper.xml

@@ -0,0 +1,27 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="org.jeecg.modules.geke.usercontract.mapper.UserContractMapper">
+
+    <select id="lists" resultType="org.jeecg.modules.geke.usercontract.entity.UserContract">
+        select a.*,b.realname as 'realname' from geke_user_contract a left join sys_user b on a.user_id=b.id
+        where b.del_flag='0'
+        <if test="userContract.realname!=null and ''!=userContract.realname">
+            and b.realname like concat(concat('%',#{userContract.realname}),'%')
+        </if>
+        <if test="userContract.contractType!=null and ''!=userContract.contractType">
+            and a.contract_type=#{userContract.contractType}
+        </if>
+        <if test="deptids!=null and deptids.size()>0">
+            and a.dept_id in
+            <foreach collection="deptids" index="index" item="id" open="(" separator="," close=")">
+                #{id}
+            </foreach>
+        </if>
+    </select>
+    <select id="list" resultType="org.jeecg.modules.geke.usercontract.entity.UserContract">
+        select *from geke_user_contract where 1=1
+        <if test="userid!=null and ''!=userid">
+            and user_id=#{userid}
+        </if>
+    </select>
+</mapper>

+ 20 - 0
jeecg-boot-module-demo/src/main/java/org/jeecg/modules/geke/usercontract/service/IUserContractService.java

@@ -0,0 +1,20 @@
+package org.jeecg.modules.geke.usercontract.service;
+
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import org.apache.ibatis.annotations.Param;
+import org.jeecg.modules.geke.userPrize.entity.UserPrize;
+import org.jeecg.modules.geke.usercontract.entity.UserContract;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+import java.util.List;
+
+/**
+ * @Description: 员工合同
+ * @Author: jeecg-boot
+ * @Date:   2022-03-04
+ * @Version: V1.0
+ */
+public interface IUserContractService extends IService<UserContract> {
+    Page<UserContract> lists(Page<UserContract> page,UserContract userContract);
+    List<UserContract>list(String userid);
+}

+ 72 - 0
jeecg-boot-module-demo/src/main/java/org/jeecg/modules/geke/usercontract/service/impl/UserContractServiceImpl.java

@@ -0,0 +1,72 @@
+package org.jeecg.modules.geke.usercontract.service.impl;
+
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import org.jeecg.modules.geke.makeUpCard.mapper.MakeUpCardMapper;
+import org.jeecg.modules.geke.makeUpCard.service.IMakeUpCardService;
+import org.jeecg.modules.geke.userPrize.entity.UserPrize;
+import org.jeecg.modules.geke.userPrize.mapper.UserPrizeMapper;
+import org.jeecg.modules.geke.usercontract.entity.UserContract;
+import org.jeecg.modules.geke.usercontract.mapper.UserContractMapper;
+import org.jeecg.modules.geke.usercontract.service.IUserContractService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @Description: 员工合同
+ * @Author: jeecg-boot
+ * @Date:   2022-03-04
+ * @Version: V1.0
+ */
+@Service
+public class UserContractServiceImpl extends ServiceImpl<UserContractMapper, UserContract> implements IUserContractService {
+    @Autowired
+    private  UserContractMapper userContractMapper;
+    @Autowired
+    private MakeUpCardMapper makeUpCardMapper;
+    @Autowired
+    private UserPrizeMapper userPrizeMapper;
+    @Override
+    public Page<UserContract> lists(Page<UserContract> page, UserContract userContract) {
+        List<String> subDepIdsByDepId=null;
+        if (userContract.getDeptId()!=null){
+            subDepIdsByDepId= makeUpCardMapper.getSubDepIdsByDepId(userContract.getDeptId());
+        }
+        List<UserContract> lists = userContractMapper.lists(page, userContract, subDepIdsByDepId);
+        lists.forEach(str->{
+            List<Map<String, Object>> userid = userPrizeMapper.queryDept(str.getUserId());
+            if (userid!=null){
+                String code=userid.get(0).get("code").toString();
+                str.setDeptNames(userid.get(0).get("name").toString());
+                str.setDeptId(userid.get(0).get("id").toString());
+                List<String> codes = new ArrayList<>();
+                for (int i = 0; i < code.length(); i = i + 2) {
+                    codes.add(code.substring(0, i + 2));
+                }
+                List<Map<String,Object>> sysDeparts = makeUpCardMapper.listDeptTop(codes);
+                if (sysDeparts!=null&&sysDeparts.size()>0){
+                    sysDeparts.forEach(st->{
+                        if (st.get("org_type").equals("1")||st.get("org_type").equals(1)){
+                            str.setDeptName(st.get("depart_name").toString());
+                        }else if (st.get("org_type").equals("2")||st.get("org_type").equals(2)){
+                            str.setDeptName1(st.get("depart_name").toString());
+                        }else if (st.get("org_type").equals("3")||st.get("org_type").equals(3)){
+                            str.setDeptName2(st.get("depart_name").toString());
+                        }
+                    });
+                }
+            }
+        });
+        return page.setRecords(lists);
+    }
+
+    @Override
+    public List<UserContract> list(String userid) {
+        return userContractMapper.list(userid);
+    }
+}