|
@@ -0,0 +1,213 @@
|
|
|
|
|
+package com.xjrsoft.module.personnel.controller;
|
|
|
|
|
+
|
|
|
|
|
+import cn.dev33.satoken.annotation.SaCheckPermission;
|
|
|
|
|
+import cn.hutool.core.bean.BeanUtil;
|
|
|
|
|
+import com.alibaba.excel.EasyExcel;
|
|
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
|
|
+import com.xjrsoft.common.model.result.RT;
|
|
|
|
|
+import com.xjrsoft.common.utils.VoToColumnUtil;
|
|
|
|
|
+import com.xjrsoft.module.personnel.dto.AddBasePersonnelLabourCapitalDto;
|
|
|
|
|
+import com.xjrsoft.module.personnel.dto.BasePersonnelLabourCapitalListDto;
|
|
|
|
|
+import com.xjrsoft.module.personnel.dto.UpdateBasePersonnelLabourCapitalDto;
|
|
|
|
|
+import com.xjrsoft.module.personnel.entity.BasePersonnelLabourCapital;
|
|
|
|
|
+import com.xjrsoft.module.personnel.entity.BasePersonnelLabourCapitalData;
|
|
|
|
|
+import com.xjrsoft.module.personnel.entity.BasePersonnelLabourCapitalTitle;
|
|
|
|
|
+import com.xjrsoft.module.personnel.service.IBasePersonnelLabourCapitalService;
|
|
|
|
|
+import com.xjrsoft.module.personnel.vo.BasePersonnelLabourCapitalListVo;
|
|
|
|
|
+import com.xjrsoft.module.personnel.vo.BasePersonnelLabourCapitalVo;
|
|
|
|
|
+import com.yomahub.liteflow.util.JsonUtil;
|
|
|
|
|
+import io.swagger.annotations.Api;
|
|
|
|
|
+import io.swagger.annotations.ApiOperation;
|
|
|
|
|
+import lombok.AllArgsConstructor;
|
|
|
|
|
+import org.springframework.web.bind.annotation.DeleteMapping;
|
|
|
|
|
+import org.springframework.web.bind.annotation.GetMapping;
|
|
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
|
|
+import org.springframework.web.bind.annotation.PutMapping;
|
|
|
|
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
|
|
+import org.springframework.web.bind.annotation.RequestParam;
|
|
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
+
|
|
|
|
|
+import javax.validation.Valid;
|
|
|
|
|
+import java.io.IOException;
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
|
|
+import java.util.List;
|
|
|
|
|
+import java.util.Map;
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+* @title: 工资发放
|
|
|
|
|
+* @Author dzx
|
|
|
|
|
+* @Date: 2023-11-08
|
|
|
|
|
+* @Version 1.0
|
|
|
|
|
+*/
|
|
|
|
|
+@RestController
|
|
|
|
|
+@RequestMapping("/personnel" + "/basepersonnellabourcapital")
|
|
|
|
|
+@Api(value = "/personnel" + "/basepersonnellabourcapital",tags = "工资发放代码")
|
|
|
|
|
+@AllArgsConstructor
|
|
|
|
|
+public class BasePersonnelLabourCapitalController {
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ private final IBasePersonnelLabourCapitalService basePersonnelLabourCapitalService;
|
|
|
|
|
+
|
|
|
|
|
+ @GetMapping(value = "/list")
|
|
|
|
|
+ @ApiOperation(value="工资发放列表(不分页)")
|
|
|
|
|
+ @SaCheckPermission("basepersonnellabourcapital:detail")
|
|
|
|
|
+ public RT<List<BasePersonnelLabourCapitalListVo>> list(@Valid BasePersonnelLabourCapitalListDto dto){
|
|
|
|
|
+
|
|
|
|
|
+ LambdaQueryWrapper<BasePersonnelLabourCapital> queryWrapper = new LambdaQueryWrapper<>();
|
|
|
|
|
+ queryWrapper
|
|
|
|
|
+ .orderByDesc(BasePersonnelLabourCapital::getId)
|
|
|
|
|
+ .select(BasePersonnelLabourCapital.class,x -> VoToColumnUtil.fieldsToColumns(BasePersonnelLabourCapitalListVo.class).contains(x.getProperty()));
|
|
|
|
|
+
|
|
|
|
|
+ List<BasePersonnelLabourCapital> list = basePersonnelLabourCapitalService.list(queryWrapper);
|
|
|
|
|
+ List<BasePersonnelLabourCapitalListVo> listVos = BeanUtil.copyToList(list, BasePersonnelLabourCapitalListVo.class);
|
|
|
|
|
+ return RT.ok(listVos);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @GetMapping(value = "/info")
|
|
|
|
|
+ @ApiOperation(value="根据id查询工资发放信息")
|
|
|
|
|
+ @SaCheckPermission("basepersonnellabourcapital:detail")
|
|
|
|
|
+ public RT<BasePersonnelLabourCapitalVo> info(@RequestParam Long id){
|
|
|
|
|
+ BasePersonnelLabourCapital basePersonnelLabourCapital = basePersonnelLabourCapitalService.getByIdDeep(id);
|
|
|
|
|
+ if (basePersonnelLabourCapital == null) {
|
|
|
|
|
+ return RT.error("找不到此数据!");
|
|
|
|
|
+ }
|
|
|
|
|
+ return RT.ok(BeanUtil.toBean(basePersonnelLabourCapital, BasePersonnelLabourCapitalVo.class));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ @PostMapping
|
|
|
|
|
+ @ApiOperation(value = "新增工资发放")
|
|
|
|
|
+ @SaCheckPermission("basepersonnellabourcapital:add")
|
|
|
|
|
+ public RT<Boolean> add(@Valid @RequestBody AddBasePersonnelLabourCapitalDto dto){
|
|
|
|
|
+ BasePersonnelLabourCapital basePersonnelLabourCapital = BeanUtil.toBean(dto, BasePersonnelLabourCapital.class);
|
|
|
|
|
+ boolean isSuccess = basePersonnelLabourCapitalService.add(basePersonnelLabourCapital);
|
|
|
|
|
+ return RT.ok(isSuccess);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @PutMapping
|
|
|
|
|
+ @ApiOperation(value = "修改工资发放")
|
|
|
|
|
+ @SaCheckPermission("basepersonnellabourcapital:edit")
|
|
|
|
|
+ public RT<Boolean> update(@Valid @RequestBody UpdateBasePersonnelLabourCapitalDto dto){
|
|
|
|
|
+
|
|
|
|
|
+ BasePersonnelLabourCapital basePersonnelLabourCapital = BeanUtil.toBean(dto, BasePersonnelLabourCapital.class);
|
|
|
|
|
+ return RT.ok(basePersonnelLabourCapitalService.update(basePersonnelLabourCapital));
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @DeleteMapping
|
|
|
|
|
+ @ApiOperation(value = "删除工资发放")
|
|
|
|
|
+ @SaCheckPermission("basepersonnellabourcapital:delete")
|
|
|
|
|
+ public RT<Boolean> delete(@Valid @RequestBody List<Long> ids){
|
|
|
|
|
+ return RT.ok(basePersonnelLabourCapitalService.delete(ids));
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ @PostMapping("/import")
|
|
|
|
|
+ @ApiOperation(value = "导入")
|
|
|
|
|
+ public RT<Boolean> importData(@Valid @RequestBody AddBasePersonnelLabourCapitalDto dto, @RequestParam MultipartFile file) throws IOException {
|
|
|
|
|
+ List<Map<Integer, Object>> excelDataList = EasyExcel.read(file.getInputStream()).sheet().headRowNumber(dto.getDataRow() - 1).doReadSync();
|
|
|
|
|
+ //验证数据
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ //处理表头数据,目前只支持2行表头
|
|
|
|
|
+ List<BasePersonnelLabourCapitalTitle> titleList = initTitleList(excelDataList.get(0), excelDataList.get(1));
|
|
|
|
|
+ //读取表内容数据
|
|
|
|
|
+ List<BasePersonnelLabourCapitalData> dataList = initDataList(dto, excelDataList);
|
|
|
|
|
+
|
|
|
|
|
+ //构造数据
|
|
|
|
|
+ BasePersonnelLabourCapital basePersonnelLabourCapital = BeanUtil.toBean(dto, BasePersonnelLabourCapital.class);
|
|
|
|
|
+ //添加表头数据
|
|
|
|
|
+ basePersonnelLabourCapital.setBasePersonnelLabourCapitalTitleList(titleList);
|
|
|
|
|
+ basePersonnelLabourCapital.setBasePersonnelLabourCapitalDataList(dataList);
|
|
|
|
|
+
|
|
|
|
|
+ Boolean result = basePersonnelLabourCapitalService.add(basePersonnelLabourCapital);
|
|
|
|
|
+ return RT.ok(result);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 处理教师工资数据
|
|
|
|
|
+ * @param excelDataList 表格数据
|
|
|
|
|
+ * @return 返回集合
|
|
|
|
|
+ */
|
|
|
|
|
+ List<BasePersonnelLabourCapitalData> initDataList(AddBasePersonnelLabourCapitalDto dto, List<Map<Integer, Object>> excelDataList){
|
|
|
|
|
+ List<BasePersonnelLabourCapitalData> resultList = new ArrayList<>();
|
|
|
|
|
+ for (int i = 0; i < excelDataList.size(); i ++){
|
|
|
|
|
+ //跳过表头
|
|
|
|
|
+ if(i < 2){
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ Map<Integer, Object> datatMap = excelDataList.get(i);
|
|
|
|
|
+ BasePersonnelLabourCapitalData data = new BasePersonnelLabourCapitalData();
|
|
|
|
|
+ data.setName(datatMap.get(dto.getPersonnelNameColumn()) == null?null:datatMap.get(dto.getPersonnelNameColumn()).toString());
|
|
|
|
|
+ data.setIdNumber(datatMap.get(dto.getIdNumberColumn()) == null?null:datatMap.get(dto.getIdNumberColumn()).toString());
|
|
|
|
|
+ data.setIdType(datatMap.get(dto.getIdTypeColumn()) == null?null:datatMap.get(dto.getIdTypeColumn()).toString());
|
|
|
|
|
+ data.setAmountTo(datatMap.get(dto.getAmountToColumn()) == null?null:datatMap.get(dto.getAmountToColumn()).toString());
|
|
|
|
|
+ data.setJobNumber(datatMap.get(dto.getJobNumberColumn()) == null?null:datatMap.get(dto.getJobNumberColumn()).toString());
|
|
|
|
|
+ data.setExtendJson(JsonUtil.toJsonString(datatMap));
|
|
|
|
|
+ resultList.add(data);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return resultList;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 处理表头数据
|
|
|
|
|
+ * @param titleRow1 第一行数据
|
|
|
|
|
+ * @param titleRow2 第二行数据
|
|
|
|
|
+ * @return 返回集合
|
|
|
|
|
+ */
|
|
|
|
|
+ List<BasePersonnelLabourCapitalTitle> initTitleList(Map<Integer, Object> titleRow1, Map<Integer, Object> titleRow2){
|
|
|
|
|
+ List<BasePersonnelLabourCapitalTitle> resultList = new ArrayList<>();
|
|
|
|
|
+ //识别第一行
|
|
|
|
|
+ int mergeColumns = 0, mergeRows = 0;
|
|
|
|
|
+ for (Integer column : titleRow1.keySet()) {
|
|
|
|
|
+ BasePersonnelLabourCapitalTitle title = new BasePersonnelLabourCapitalTitle();
|
|
|
|
|
+ Object value = titleRow1.get(column);
|
|
|
|
|
+ if(value == null){
|
|
|
|
|
+ mergeColumns = 0;
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ for (int i = column + 1; i < titleRow1.size(); i ++){
|
|
|
|
|
+ Object mergeValue = titleRow1.get(i);
|
|
|
|
|
+ if(mergeValue != null){
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ mergeColumns ++;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ Object value2 = titleRow2.get(column);
|
|
|
|
|
+ if(value2 == null){
|
|
|
|
|
+ mergeRows = 2;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ title.setName(value.toString());
|
|
|
|
|
+ title.setColumnNumber(column);
|
|
|
|
|
+ title.setRowNumber(4);
|
|
|
|
|
+ title.setMergeColumns(mergeColumns);
|
|
|
|
|
+ title.setMergeRows(mergeRows);
|
|
|
|
|
+ resultList.add(title);
|
|
|
|
|
+
|
|
|
|
|
+ mergeColumns = 0;
|
|
|
|
|
+ mergeRows = 0;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ //识别第二行
|
|
|
|
|
+ for (Integer column : titleRow2.keySet()) {
|
|
|
|
|
+ BasePersonnelLabourCapitalTitle title = new BasePersonnelLabourCapitalTitle();
|
|
|
|
|
+ Object value = titleRow2.get(column);
|
|
|
|
|
+ if(value == null){
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ title.setName(value.toString());
|
|
|
|
|
+ title.setColumnNumber(column);
|
|
|
|
|
+ title.setRowNumber(4);
|
|
|
|
|
+ title.setMergeColumns(mergeColumns);
|
|
|
|
|
+ title.setMergeRows(mergeRows);
|
|
|
|
|
+ resultList.add(title);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return resultList;
|
|
|
|
|
+ }
|
|
|
|
|
+}
|