feat():岗位信息;

master
jiyufei 3 months ago
parent 40def8bdcf
commit c8ca6dbce1

@ -21,7 +21,7 @@ spring:
port: 3309
username: root
password: linus,.123
db-name: jnpf_zhihui
db-name: jnpf_yys_dev
db-schema: #金仓达梦选填
prepare-url: #自定义url

@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>jnpf-example</artifactId>
<groupId>com.jnpf</groupId>
<version>3.5.0-RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>jnpf-example-biz</artifactId>
<dependencies>
<dependency>
<groupId>com.jnpf</groupId>
<artifactId>jnpf-example-entity</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.jnpf</groupId>
<artifactId>jnpf-generater-base</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</project>

@ -0,0 +1,16 @@
package jnpf.mapper;
import jnpf.entity.YysPostEntity;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
/**
* yysPost
* V3.5
* https://www.jnpfsoft.com
* JNPF
* 2024-08-05
*/
public interface YysPostMapper extends BaseMapper<YysPostEntity> {
}

@ -0,0 +1,35 @@
package jnpf.service;
import jnpf.model.yyspost.*;
import jnpf.entity.*;
import java.util.*;
import com.baomidou.mybatisplus.extension.service.IService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
/**
* yysPost
* V3.5
* https://www.jnpfsoft.com
* JNPF
* 2024-08-05
*/
public interface YysPostService extends IService<YysPostEntity> {
List<YysPostEntity> getList(YysPostPagination yysPostPagination);
List<YysPostEntity> getTypeList(YysPostPagination yysPostPagination,String dataType);
YysPostEntity getInfo(String id);
void delete(YysPostEntity entity);
void create(YysPostEntity entity);
boolean update(String id, YysPostEntity entity);
//子表方法
//副表数据方法
String checkForm(YysPostForm form,int i);
void saveOrUpdate(YysPostForm yysPostForm,String id, boolean isSave) throws Exception;
}

@ -0,0 +1,317 @@
package jnpf.service.impl;
import jnpf.entity.*;
import jnpf.mapper.YysPostMapper;
import jnpf.service.*;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import jnpf.model.yyspost.*;
import java.math.BigDecimal;
import cn.hutool.core.util.ObjectUtil;
import jnpf.permission.model.authorize.AuthorizeConditionModel;
import jnpf.util.GeneraterSwapUtil;
import jnpf.database.model.superQuery.SuperQueryJsonModel;
import jnpf.database.model.superQuery.ConditionJsonModel;
import jnpf.database.model.superQuery.SuperQueryConditionModel;
import java.lang.reflect.Field;
import com.baomidou.mybatisplus.annotation.TableField;
import java.util.regex.Pattern;
import jnpf.model.QueryModel;
import java.util.stream.Collectors;
import jnpf.base.model.ColumnDataModel;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.metadata.IPage;
import jnpf.database.model.superQuery.SuperJsonModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import java.text.SimpleDateFormat;
import jnpf.util.*;
import java.util.*;
import jnpf.base.UserInfo;
import jnpf.permission.entity.UserEntity;
/**
*
* yysPost
* V3.5
* https://www.jnpfsoft.com
* JNPF
* 2024-08-05
*/
@Service
public class YysPostServiceImpl extends ServiceImpl<YysPostMapper, YysPostEntity> implements YysPostService{
@Autowired
private GeneraterSwapUtil generaterSwapUtil;
@Autowired
private UserProvider userProvider;
@Override
public List<YysPostEntity> getList(YysPostPagination yysPostPagination){
return getTypeList(yysPostPagination,yysPostPagination.getDataType());
}
/** 列表查询 */
@Override
public List<YysPostEntity> getTypeList(YysPostPagination yysPostPagination,String dataType){
String userId=userProvider.get().getUserId();
List<String> AllIdList =new ArrayList();
List<List<String>> intersectionList =new ArrayList<>();
boolean isPc = ServletUtil.getHeader("jnpf-origin").equals("pc");
String columnData = !isPc ? YysPostConstant.getAppColumnData() : YysPostConstant.getColumnData();
ColumnDataModel columnDataModel = JsonUtil.getJsonToBean(columnData, ColumnDataModel.class);
String ruleJson = !isPc ? JsonUtil.getObjectToString(columnDataModel.getRuleListApp()) : JsonUtil.getObjectToString(columnDataModel.getRuleList());
int total=0;
int yysPostNum =0;
QueryWrapper<YysPostEntity> yysPostQueryWrapper=new QueryWrapper<>();
List<String> allSuperIDlist = new ArrayList<>();
String superOp ="";
if (ObjectUtil.isNotEmpty(yysPostPagination.getSuperQueryJson())){
List<String> allSuperList = new ArrayList<>();
List<List<String>> intersectionSuperList = new ArrayList<>();
String queryJson = yysPostPagination.getSuperQueryJson();
SuperJsonModel superJsonModel = JsonUtil.getJsonToBean(queryJson, SuperJsonModel.class);
int superNum = 0;
QueryWrapper<YysPostEntity> yysPostSuperWrapper = new QueryWrapper<>();
yysPostSuperWrapper = generaterSwapUtil.getCondition(new QueryModel(yysPostSuperWrapper,YysPostEntity.class,queryJson,"0"));
int yysPostNum1 = yysPostSuperWrapper.getExpression().getNormal().size();
if (yysPostNum1>0){
List<String> yysPostList =this.list(yysPostSuperWrapper).stream().map(YysPostEntity::getId).collect(Collectors.toList());
allSuperList.addAll(yysPostList);
intersectionSuperList.add(yysPostList);
superNum++;
}
superOp = superNum > 0 ? superJsonModel.getMatchLogic() : "";
//and or
if(superOp.equalsIgnoreCase("and")){
allSuperIDlist = generaterSwapUtil.getIntersection(intersectionSuperList);
}else{
allSuperIDlist = allSuperList;
}
}
List<String> allRuleIDlist = new ArrayList<>();
String ruleOp ="";
if (ObjectUtil.isNotEmpty(ruleJson)){
List<String> allRuleList = new ArrayList<>();
List<List<String>> intersectionRuleList = new ArrayList<>();
SuperJsonModel ruleJsonModel = JsonUtil.getJsonToBean(ruleJson, SuperJsonModel.class);
int ruleNum = 0;
QueryWrapper<YysPostEntity> yysPostSuperWrapper = new QueryWrapper<>();
yysPostSuperWrapper = generaterSwapUtil.getCondition(new QueryModel(yysPostSuperWrapper,YysPostEntity.class,ruleJson,"0"));
int yysPostNum1 = yysPostSuperWrapper.getExpression().getNormal().size();
if (yysPostNum1>0){
List<String> yysPostList =this.list(yysPostSuperWrapper).stream().map(YysPostEntity::getId).collect(Collectors.toList());
allRuleList.addAll(yysPostList);
intersectionRuleList.add(yysPostList);
ruleNum++;
}
ruleOp = ruleNum > 0 ? ruleJsonModel.getMatchLogic() : "";
//and or
if(ruleOp.equalsIgnoreCase("and")){
allRuleIDlist = generaterSwapUtil.getIntersection(intersectionRuleList);
}else{
allRuleIDlist = allRuleList;
}
}
boolean pcPermission = false;
boolean appPermission = false;
if(isPc && pcPermission){
if (!userProvider.get().getIsAdministrator()){
Object yysPostObj=generaterSwapUtil.getAuthorizeCondition(new QueryModel(yysPostQueryWrapper,YysPostEntity.class,yysPostPagination.getMenuId(),"0"));
if (ObjectUtil.isEmpty(yysPostObj)){
return new ArrayList<>();
} else {
yysPostQueryWrapper = (QueryWrapper<YysPostEntity>)yysPostObj;
if( yysPostQueryWrapper.getExpression().getNormal().size()>0){
yysPostNum++;
}
}
}
}
if(!isPc && appPermission){
if (!userProvider.get().getIsAdministrator()){
Object yysPostObj=generaterSwapUtil.getAuthorizeCondition(new QueryModel(yysPostQueryWrapper,YysPostEntity.class,yysPostPagination.getMenuId(),"0"));
if (ObjectUtil.isEmpty(yysPostObj)){
return new ArrayList<>();
} else {
yysPostQueryWrapper = (QueryWrapper<YysPostEntity>)yysPostObj;
if( yysPostQueryWrapper.getExpression().getNormal().size()>0){
yysPostNum++;
}
}
}
}
if(isPc){
if(ObjectUtil.isNotEmpty(yysPostPagination.getPostName())){
yysPostNum++;
String value = yysPostPagination.getPostName() instanceof List ?
JsonUtil.getObjectToString(yysPostPagination.getPostName()) :
String.valueOf(yysPostPagination.getPostName());
yysPostQueryWrapper.lambda().like(YysPostEntity::getPostName,value);
}
if(ObjectUtil.isNotEmpty(yysPostPagination.getPostCode())){
yysPostNum++;
String value = yysPostPagination.getPostCode() instanceof List ?
JsonUtil.getObjectToString(yysPostPagination.getPostCode()) :
String.valueOf(yysPostPagination.getPostCode());
yysPostQueryWrapper.lambda().like(YysPostEntity::getPostCode,value);
}
if(ObjectUtil.isNotEmpty(yysPostPagination.getPostStatus())){
yysPostNum++;
List<String> idList = new ArrayList<>();
try {
String[][] postStatus = JsonUtil.getJsonToBean(yysPostPagination.getPostStatus(),String[][].class);
for(int i=0;i<postStatus.length;i++){
if(postStatus[i].length>0){
idList.add(JsonUtil.getObjectToString(Arrays.asList(postStatus[i])));
}
}
}catch (Exception e1){
try {
List<String> postStatus = JsonUtil.getJsonToList(yysPostPagination.getPostStatus(),String.class);
if(postStatus.size()>0){
idList.addAll(postStatus);
}
}catch (Exception e2){
idList.add(String.valueOf(yysPostPagination.getPostStatus()));
}
}
yysPostQueryWrapper.lambda().and(t->{
idList.forEach(tt->{
t.like(YysPostEntity::getPostStatus, tt).or();
});
});
}
}
List<String> intersection = generaterSwapUtil.getIntersection(intersectionList);
if (total>0){
if (intersection.size()==0){
intersection.add("jnpfNullList");
}
yysPostQueryWrapper.lambda().in(YysPostEntity::getId, intersection);
}
//是否有高级查询
if (StringUtil.isNotEmpty(superOp)){
if (allSuperIDlist.size()==0){
allSuperIDlist.add("jnpfNullList");
}
List<String> finalAllSuperIDlist = allSuperIDlist;
yysPostQueryWrapper.lambda().and(t->t.in(YysPostEntity::getId, finalAllSuperIDlist));
}
//是否有数据过滤查询
if (StringUtil.isNotEmpty(ruleOp)){
if (allRuleIDlist.size()==0){
allRuleIDlist.add("jnpfNullList");
}
List<String> finalAllRuleIDlist = allRuleIDlist;
yysPostQueryWrapper.lambda().and(t->t.in(YysPostEntity::getId, finalAllRuleIDlist));
}
//排序
if(StringUtil.isEmpty(yysPostPagination.getSidx())){
yysPostQueryWrapper.lambda().orderByDesc(YysPostEntity::getId);
}else{
try {
String sidx = yysPostPagination.getSidx();
String[] strs= sidx.split("_name");
YysPostEntity yysPostEntity = new YysPostEntity();
Field declaredField = yysPostEntity.getClass().getDeclaredField(strs[0]);
declaredField.setAccessible(true);
String value = declaredField.getAnnotation(TableField.class).value();
yysPostQueryWrapper="asc".equals(yysPostPagination.getSort().toLowerCase())?yysPostQueryWrapper.orderByAsc(value):yysPostQueryWrapper.orderByDesc(value);
} catch (NoSuchFieldException e) {
e.printStackTrace();
}
}
if("0".equals(dataType)){
if((total>0 && AllIdList.size()>0) || total==0){
Page<YysPostEntity> page=new Page<>(yysPostPagination.getCurrentPage(), yysPostPagination.getPageSize());
IPage<YysPostEntity> userIPage=this.page(page, yysPostQueryWrapper);
return yysPostPagination.setData(userIPage.getRecords(),userIPage.getTotal());
}else{
List<YysPostEntity> list = new ArrayList();
return yysPostPagination.setData(list, list.size());
}
}else{
return this.list(yysPostQueryWrapper);
}
}
@Override
public YysPostEntity getInfo(String id){
QueryWrapper<YysPostEntity> queryWrapper=new QueryWrapper<>();
queryWrapper.lambda().eq(YysPostEntity::getId,id);
return this.getOne(queryWrapper);
}
@Override
public void create(YysPostEntity entity){
this.save(entity);
}
@Override
public boolean update(String id, YysPostEntity entity){
return this.updateById(entity);
}
@Override
public void delete(YysPostEntity entity){
if(entity!=null){
this.removeById(entity.getId());
}
}
/** 验证表单唯一字段,正则,非空 i-0新增-1修改*/
@Override
public String checkForm(YysPostForm form,int i) {
boolean isUp =StringUtil.isNotEmpty(form.getId()) && !form.getId().equals("0");
String id="";
String countRecover = "";
if (isUp){
id = form.getId();
}
//主表字段验证
if(StringUtil.isEmpty(form.getPostName())){
return "岗位名称不能为空";
}
if(StringUtil.isEmpty(form.getPostCode())){
return "岗位编码不能为空";
}
if(StringUtil.isNotEmpty(form.getPostSort())){
if(!Pattern.compile("^\\d+$").matcher(String.valueOf(form.getPostSort())).matches()){
return "请输入正确的数字";
}
}
return countRecover;
}
/**
* ()
* @param id
* @param yysPostForm
* @return
*/
@Override
@Transactional
public void saveOrUpdate(YysPostForm yysPostForm,String id, boolean isSave) throws Exception{
UserInfo userInfo=userProvider.get();
UserEntity userEntity = generaterSwapUtil.getUser(userInfo.getUserId());
yysPostForm = JsonUtil.getJsonToBean(
generaterSwapUtil.swapDatetime(YysPostConstant.getFormData(),yysPostForm),YysPostForm.class);
YysPostEntity entity = JsonUtil.getJsonToBean(yysPostForm, YysPostEntity.class);
if(isSave){
String mainId = RandomUtil.uuId() ;
entity.setId(mainId);
}else{
}
this.saveOrUpdate(entity);
}
}

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>jnpf-example</artifactId>
<groupId>com.jnpf</groupId>
<version>3.5.0-RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>jnpf-example-controller</artifactId>
<dependencies>
<dependency>
<groupId>com.jnpf</groupId>
<artifactId>jnpf-example-biz</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</project>

@ -0,0 +1,330 @@
package jnpf.controller;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jnpf.base.ActionResult;
import jnpf.base.UserInfo;
import jnpf.exception.DataException;
import jnpf.permission.entity.UserEntity;
import jnpf.service.*;
import jnpf.entity.*;
import jnpf.util.*;
import jnpf.model.yyspost.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.util.*;
import jnpf.annotation.JnpfField;
import jnpf.base.vo.PageListVO;
import jnpf.base.vo.PaginationVO;
import jnpf.base.vo.DownloadVO;
import jnpf.config.ConfigValueUtil;
import jnpf.base.entity.ProvinceEntity;
import java.io.IOException;
import java.util.stream.Collectors;
import jnpf.engine.entity.FlowTaskEntity;
import jnpf.exception.WorkFlowException;
import org.springframework.web.multipart.MultipartFile;
import cn.afterturn.easypoi.excel.ExcelExportUtil;
import cn.afterturn.easypoi.excel.ExcelImportUtil;
import cn.afterturn.easypoi.excel.entity.ExportParams;
import cn.afterturn.easypoi.excel.entity.ImportParams;
import cn.afterturn.easypoi.excel.entity.params.ExcelExportEntity;
import cn.afterturn.easypoi.excel.entity.enmus.ExcelType;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Workbook;
import java.io.File;
import jnpf.onlinedev.model.ExcelImFieldModel;
import jnpf.onlinedev.model.OnlineImport.ImportDataModel;
import jnpf.onlinedev.model.OnlineImport.ImportFormCheckUniqueModel;
import jnpf.onlinedev.model.OnlineImport.ExcelImportModel;
import jnpf.onlinedev.model.OnlineImport.VisualImportModel;
import cn.xuyanwu.spring.file.storage.FileInfo;
import lombok.Cleanup;
import jnpf.model.visualJson.config.HeaderModel;
import jnpf.base.model.ColumnDataModel;
import jnpf.base.util.VisualUtils;
import org.springframework.transaction.annotation.Transactional;
/**
* yysPost
* @ V3.5
* @ https://www.jnpfsoft.com
* @ JNPF
* @ 2024-08-05
*/
@Slf4j
@RestController
@Tag(name = "yysPost" , description = "example")
@RequestMapping("/api/example/YysPost")
public class YysPostController {
@Autowired
private GeneraterSwapUtil generaterSwapUtil;
@Autowired
private UserProvider userProvider;
@Autowired
private YysPostService yysPostService;
@Autowired
private ConfigValueUtil configValueUtil;
/**
*
*
* @param yysPostPagination
* @return
*/
@Operation(summary = "获取列表")
@PostMapping("/getList")
public ActionResult list(@RequestBody YysPostPagination yysPostPagination)throws IOException{
List<YysPostEntity> list= yysPostService.getList(yysPostPagination);
List<Map<String, Object>> realList=new ArrayList<>();
for (YysPostEntity entity : list) {
Map<String, Object> yysPostMap=JsonUtil.entityToMap(entity);
yysPostMap.put("id", yysPostMap.get("id"));
//副表数据
//子表数据
realList.add(yysPostMap);
}
//数据转换
realList = generaterSwapUtil.swapDataList(realList, YysPostConstant.getFormData(), YysPostConstant.getColumnData(), yysPostPagination.getModuleId(),false);
//返回对象
PageListVO vo = new PageListVO();
vo.setList(realList);
PaginationVO page = JsonUtil.getJsonToBean(yysPostPagination, PaginationVO.class);
vo.setPagination(page);
return ActionResult.success(vo);
}
/**
*
*
* @param yysPostForm
* @return
*/
@PostMapping()
@Operation(summary = "创建")
public ActionResult create(@RequestBody @Valid YysPostForm yysPostForm) {
String b = yysPostService.checkForm(yysPostForm,0);
if (StringUtil.isNotEmpty(b)){
return ActionResult.fail(b );
}
try{
yysPostService.saveOrUpdate(yysPostForm, null ,true);
}catch(Exception e){
return ActionResult.fail("新增数据失败");
}
return ActionResult.success("创建成功");
}
/**
* Excel
*
* @return
*/
@Operation(summary = "导出Excel")
@PostMapping("/Actions/Export")
public ActionResult Export(@RequestBody YysPostPagination yysPostPagination) throws IOException {
if (StringUtil.isEmpty(yysPostPagination.getSelectKey())){
return ActionResult.fail("请选择导出字段");
}
List<YysPostEntity> list= yysPostService.getList(yysPostPagination);
List<Map<String, Object>> realList=new ArrayList<>();
for (YysPostEntity entity : list) {
Map<String, Object> yysPostMap=JsonUtil.entityToMap(entity);
yysPostMap.put("id", yysPostMap.get("id"));
//副表数据
//子表数据
realList.add(yysPostMap);
}
//数据转换
realList = generaterSwapUtil.swapDataList(realList, YysPostConstant.getFormData(), YysPostConstant.getColumnData(), yysPostPagination.getModuleId(),false);
String[]keys=!StringUtil.isEmpty(yysPostPagination.getSelectKey())?yysPostPagination.getSelectKey():new String[0];
UserInfo userInfo=userProvider.get();
DownloadVO vo=this.creatModelExcel(configValueUtil.getTemporaryFilePath(),realList,keys,userInfo);
return ActionResult.success(vo);
}
/**
*
*/
public DownloadVO creatModelExcel(String path,List<Map<String, Object>>list,String[]keys,UserInfo userInfo){
DownloadVO vo=DownloadVO.builder().build();
List<ExcelExportEntity> entitys=new ArrayList<>();
if(keys.length>0){
for(String key:keys){
switch(key){
case "postName" :
entitys.add(new ExcelExportEntity("岗位名称" ,"postName"));
break;
case "postCode" :
entitys.add(new ExcelExportEntity("岗位编码" ,"postCode"));
break;
case "postSort" :
entitys.add(new ExcelExportEntity("岗位顺序" ,"postSort"));
break;
case "postStatus" :
entitys.add(new ExcelExportEntity("岗位状态" ,"postStatus"));
break;
case "reamrk" :
entitys.add(new ExcelExportEntity("岗位备注" ,"reamrk"));
break;
default:
break;
}
}
}
ExportParams exportParams = new ExportParams(null, "表单信息");
exportParams.setType(ExcelType.XSSF);
try{
@Cleanup Workbook workbook = new HSSFWorkbook();
if (entitys.size()>0){
if (list.size()==0){
list.add(new HashMap<>());
}
//去除空数据
List<Map<String, Object>> dataList = new ArrayList<>();
for (Map<String, Object> map : list) {
int i = 0;
for (String key : keys) {
//子表
if (key.toLowerCase().startsWith("tablefield")) {
String tableField = key.substring(0, key.indexOf("-" ));
String field = key.substring(key.indexOf("-" ) + 1);
Object o = map.get(tableField);
if (o != null) {
List<Map<String, Object>> childList = (List<Map<String, Object>>) o;
for (Map<String, Object> childMap : childList) {
if (childMap.get(field) != null) {
i++;
}
}
}
} else {
Object o = map.get(key);
if (o != null) {
i++;
}
}
}
if (i > 0) {
dataList.add(map);
}
}
//复杂表头-表头和数据处理
ColumnDataModel columnDataModel = JsonUtil.getJsonToBean(YysPostConstant.getColumnData(), ColumnDataModel.class);
List<HeaderModel> complexHeaderList = columnDataModel.getComplexHeaderList();
if (!Objects.equals(columnDataModel.getType(), 3) && !Objects.equals(columnDataModel.getType(), 5)) {
entitys = VisualUtils.complexHeaderHandel(entitys, complexHeaderList);
dataList = VisualUtils.complexHeaderDataHandel(dataList, complexHeaderList);
}
workbook = ExcelExportUtil.exportExcel(exportParams, entitys, dataList);
}
String fileName = "表单信息" + DateUtil.dateNow("yyyyMMdd") + "_" + RandomUtil.uuId() + ".xlsx";
MultipartFile multipartFile = ExcelUtil.workbookToCommonsMultipartFile(workbook, fileName);
String temporaryFilePath = configValueUtil.getTemporaryFilePath();
FileInfo fileInfo = FileUploadUtils.uploadFile(multipartFile, temporaryFilePath, fileName);
vo.setName(fileInfo.getFilename());
vo.setUrl(UploaderUtil.uploaderFile(fileInfo.getFilename() + "#" + "Temporary") + "&name=" + fileName);
} catch (Exception e) {
log.error("信息导出Excel错误:{}", e.getMessage());
e.printStackTrace();
}
return vo;
}
/**
*
* @param id
* @param yysPostForm
* @return
*/
@PutMapping("/{id}")
@Operation(summary = "更新")
public ActionResult update(@PathVariable("id") String id,@RequestBody @Valid YysPostForm yysPostForm,
@RequestParam(value = "isImport", required = false) boolean isImport){
yysPostForm.setId(id);
if (!isImport) {
String b = yysPostService.checkForm(yysPostForm,1);
if (StringUtil.isNotEmpty(b)){
return ActionResult.fail(b );
}
}
YysPostEntity entity= yysPostService.getInfo(id);
if(entity!=null){
try{
yysPostService.saveOrUpdate(yysPostForm,id,false);
}catch(Exception e){
return ActionResult.fail("修改数据失败");
}
return ActionResult.success("更新成功");
}else{
return ActionResult.fail("更新失败,数据不存在");
}
}
/**
*
* @param id
* @return
*/
@Operation(summary = "删除")
@DeleteMapping("/{id}")
@Transactional
public ActionResult delete(@PathVariable("id") String id){
YysPostEntity entity= yysPostService.getInfo(id);
if(entity!=null){
//主表数据删除
yysPostService.delete(entity);
}
return ActionResult.success("删除成功");
}
/**
* ()
* 使-
* @param id
* @return
*/
@Operation(summary = "表单信息(详情页)")
@GetMapping("/detail/{id}")
public ActionResult detailInfo(@PathVariable("id") String id){
YysPostEntity entity= yysPostService.getInfo(id);
if(entity==null){
return ActionResult.fail("表单数据不存在!");
}
Map<String, Object> yysPostMap=JsonUtil.entityToMap(entity);
yysPostMap.put("id", yysPostMap.get("id"));
//副表数据
//子表数据
yysPostMap = generaterSwapUtil.swapDataDetail(yysPostMap,YysPostConstant.getFormData(),"590144090977338949",false);
return ActionResult.success(yysPostMap);
}
/**
* ()
* 使-
* @param id
* @return
*/
@Operation(summary = "信息")
@GetMapping("/{id}")
public ActionResult info(@PathVariable("id") String id){
YysPostEntity entity= yysPostService.getInfo(id);
if(entity==null){
return ActionResult.fail("表单数据不存在!");
}
Map<String, Object> yysPostMap=JsonUtil.entityToMap(entity);
yysPostMap.put("id", yysPostMap.get("id"));
//副表数据
//子表数据
yysPostMap = generaterSwapUtil.swapDataForm(yysPostMap,YysPostConstant.getFormData(),YysPostConstant.TABLEFIELDKEY,YysPostConstant.TABLERENAMES);
return ActionResult.success(yysPostMap);
}
}

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>jnpf-example</artifactId>
<groupId>com.jnpf</groupId>
<version>3.5.0-RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>jnpf-example-entity</artifactId>
<dependencies>
<dependency>
<groupId>com.jnpf</groupId>
<artifactId>jnpf-common-all</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</project>

@ -0,0 +1,53 @@
package jnpf.entity;
import com.baomidou.mybatisplus.annotation.*;
import lombok.Data;
import java.util.Date;
/**
* @ V3.5
* @ https://www.jnpfsoft.com
* @ JNPF
* @ 2024-08-05
*/
@Data
@TableName("yys_post")
public class YysPostEntity {
@TableId(value = "ID")
private String id;
@TableField(value = "POST_NAME", updateStrategy = FieldStrategy.IGNORED)
private String postName;
@TableField(value = "POST_CODE", updateStrategy = FieldStrategy.IGNORED)
private String postCode;
@TableField(value = "POST_STATUS", updateStrategy = FieldStrategy.IGNORED)
private String postStatus;
@TableField(value = "POST_SORT", updateStrategy = FieldStrategy.IGNORED)
private String postSort;
@TableField(value = "REAMRK", updateStrategy = FieldStrategy.IGNORED)
private String reamrk;
@TableField("F_CREATOR_TIME")
private Date creatorTime;
@TableField("F_CREATOR_USER_ID")
private String creatorUserId;
@TableField("F_LAST_MODIFY_TIME")
private Date lastModifyTime;
@TableField("F_LAST_MODIFY_USER_ID")
private String lastModifyUserId;
@TableField("F_DELETE_TIME")
private Date deleteTime;
@TableField("F_DELETE_USER_ID")
private String deleteUserId;
@TableField("F_DELETE_MARK")
private Integer deleteMark;
@TableField("F_TENANT_ID")
private String tenantId;
@TableField("COMPANY_ID")
private String companyId;
@TableField("DEPARTMENT_ID")
private String departmentId;
@TableField("ORGANIZE_JSON_ID")
private String organizeJsonId;
@TableField("F_FLOW_ID")
private String flowId;
}

@ -0,0 +1,35 @@
package jnpf.model.yyspost;
import lombok.Data;
import java.util.List;
import java.math.BigDecimal;
import com.fasterxml.jackson.annotation.JsonProperty;
/**
* yysPost
* @ V3.5
* @ https://www.jnpfsoft.com
* @ JNPF
* @ 2024-08-05
*/
@Data
public class YysPostForm {
/** 主键 */
private String id;
/** 岗位名称 **/
@JsonProperty("postName")
private String postName;
/** 岗位编码 **/
@JsonProperty("postCode")
private String postCode;
/** 岗位顺序 **/
@JsonProperty("postSort")
private String postSort;
/** 岗位状态 **/
@JsonProperty("postStatus")
private Object postStatus;
/** 岗位备注 **/
@JsonProperty("reamrk")
private String reamrk;
}

@ -0,0 +1,39 @@
package jnpf.model.yyspost;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import jnpf.base.Pagination;
import java.util.List;
/**
*
* yysPost
* @ V3.5
* @ https://www.jnpfsoft.com
* @ JNPF
* @ 2024-08-05
*/
@Data
public class YysPostPagination extends Pagination {
/** 查询key */
private String[] selectKey;
/** json */
private String json;
/** 数据类型 0-当前页1-全部数据 */
private String dataType;
/** 高级查询 */
private String superQueryJson;
/** 功能id */
private String moduleId;
/** 菜单id */
private String menuId;
/** 岗位名称 */
@JsonProperty("postName")
private Object postName;
/** 岗位编码 */
@JsonProperty("postCode")
private Object postCode;
/** 岗位状态 */
@JsonProperty("postStatus")
private Object postStatus;
}

@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>jnpf-scheduletask</artifactId>
<groupId>com.jnpf</groupId>
<version>3.5.0-RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>jnpf-scheduletask-biz</artifactId>
<dependencies>
<dependency>
<groupId>com.jnpf</groupId>
<artifactId>jnpf-common-all</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.jnpf</groupId>
<artifactId>jnpf-common-scheduletask</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.jnpf</groupId>
<artifactId>jnpf-system-biz</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</project>

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>jnpf-scheduletask</artifactId>
<groupId>com.jnpf</groupId>
<version>3.5.0-RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>jnpf-scheduletask-controller</artifactId>
<dependencies>
<dependency>
<groupId>com.jnpf</groupId>
<artifactId>jnpf-scheduletask-biz</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
</project>

@ -0,0 +1,186 @@
package jnpf.scheduletask.controller;
import com.alibaba.fastjson.JSONObject;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import jnpf.base.ActionResult;
import jnpf.base.UserInfo;
import jnpf.base.Pagination;
import jnpf.constant.MsgCode;
import jnpf.scheduletask.entity.HandlerNameEntity;
import jnpf.scheduletask.entity.TimeTaskEntity;
import jnpf.exception.DataException;
import jnpf.scheduletask.model.*;
import jnpf.scheduletask.rest.RestScheduleTaskUtil;
import jnpf.util.JsonUtil;
import jnpf.util.JsonUtilEx;
import jnpf.util.UserProvider;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.validation.Valid;
import java.util.ArrayList;
import java.util.List;
/**
*
*
* @author JNPF
* @version V3.1.0
* @copyright
* @date 2019927 9:18
*/
@Tag(name = "任务调度", description = "TimeTask")
@RestController
@RequestMapping("/api/scheduletask")
public class TimeTaskController {
@Autowired
private UserProvider userProvider;
/**
*
*
* @param pagination
* @return
*/
@Operation(summary = "获取任务调度列表")
@GetMapping
public JSONObject list(Pagination pagination) {
UserInfo userInfo = userProvider.get();
return RestScheduleTaskUtil.getList(pagination, userInfo);
}
/**
*
*
* @return
*/
@Operation(summary = "获取任务调度列表")
@GetMapping("/TaskMethods")
public ActionResult<List<TaskMethodsVO>> taskMethods() {
List<TaskMethodsVO> list = new ArrayList<>(16);
// 获取所有handlerName
List<HandlerNameEntity> handlerNameEntities = RestScheduleTaskUtil.getHandlerList();
for (HandlerNameEntity entity : handlerNameEntities) {
TaskMethodsVO taskMethodsVO = new TaskMethodsVO();
taskMethodsVO.setId(entity.getId());
taskMethodsVO.setFullName(entity.getHandlerName());
list.add(taskMethodsVO);
}
return ActionResult.success(list);
}
/**
*
*
* @param pagination
* @param taskId Id
* @return
*/
@Operation(summary = "获取任务调度日志列表")
@GetMapping("/{id}/TaskLog")
public JSONObject list(@PathVariable("id") String taskId, TaskPage pagination) {
return RestScheduleTaskUtil.getLogList(taskId, userProvider.get(), pagination);
}
/**
*
*
* @param id
* @return
*/
@Operation(summary = "获取任务调度信息")
@GetMapping("/Info/{id}")
public ActionResult<TaskInfoVO> info(@PathVariable("id") String id) throws DataException {
TimeTaskEntity entity = RestScheduleTaskUtil.getInfo(id, userProvider.get());
TaskInfoVO vo = JsonUtilEx.getJsonToBeanEx(entity, TaskInfoVO.class);
return ActionResult.success(vo);
}
/**
*
*
* @param taskCrForm
* @return
*/
@Operation(summary = "新建任务调度")
@PostMapping
public ActionResult create(@RequestBody @Valid TaskCrForm taskCrForm) {
taskCrForm.setUserInfo(userProvider.get());
JSONObject jsonObject = RestScheduleTaskUtil.create(taskCrForm);
return JsonUtil.getJsonToBean(jsonObject, ActionResult.class);
}
/**
*
*
* @param id
* @param taskUpForm
* @return
*/
@Operation(summary = "修改任务调度")
@PutMapping("/{id}")
public ActionResult update(@PathVariable("id") String id, @RequestBody @Valid TaskUpForm taskUpForm) {
taskUpForm.setUserInfo(userProvider.get());
JSONObject jsonObject = RestScheduleTaskUtil.update(id, taskUpForm);
return JsonUtil.getJsonToBean(jsonObject, ActionResult.class);
}
/**
*
*
* @param id
* @return
*/
@Operation(summary = "删除任务")
@DeleteMapping("/{id}")
public ActionResult delete(@PathVariable("id") String id) {
JSONObject jsonObject = RestScheduleTaskUtil.delete(id, userProvider.get());
return JsonUtil.getJsonToBean(jsonObject, ActionResult.class);
}
/**
*
*
* @param id
* @return
*/
@Operation(summary = "停止任务调度")
@PutMapping("/{id}/Actions/Stop")
public ActionResult stop(@PathVariable("id") String id) {
UpdateTaskModel updateTaskModel = new UpdateTaskModel();
TimeTaskEntity entity = RestScheduleTaskUtil.getInfo(id, userProvider.get());
if (entity != null) {
entity.setEnabledMark(0);
entity.setRunCount(entity.getRunCount());
updateTaskModel.setEntity(entity);
updateTaskModel.setUserInfo(userProvider.get());
RestScheduleTaskUtil.updateTask(updateTaskModel);
return ActionResult.success(MsgCode.SU005.get());
}
return ActionResult.fail("操作失败,任务不存在");
}
/**
*
*
* @param id
* @return
*/
@Operation(summary = "启动任务调度")
@PutMapping("/{id}/Actions/Enable")
public ActionResult enable(@PathVariable("id") String id) {
UpdateTaskModel updateTaskModel = new UpdateTaskModel();
TimeTaskEntity entity = RestScheduleTaskUtil.getInfo(id, userProvider.get());
if (entity != null) {
entity.setEnabledMark(1);
updateTaskModel.setEntity(entity);
updateTaskModel.setUserInfo(userProvider.get());
RestScheduleTaskUtil.updateTask(updateTaskModel);
return ActionResult.success(MsgCode.SU005.get());
}
return ActionResult.fail("操作失败,任务不存在");
}
}

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>jnpf-java-boot</artifactId>
<groupId>com.jnpf</groupId>
<version>3.5.0-RELEASE</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>jnpf-scheduletask</artifactId>
<packaging>pom</packaging>
<modules>
<module>jnpf-scheduletask-controller</module>
<module>jnpf-scheduletask-biz</module>
</modules>
</project>

File diff suppressed because it is too large Load Diff

@ -61,10 +61,10 @@
<!-- <template slot-scope="scope">
{{ scope.row.postStatus }}
</template> -->
            <template slot-scope="scope">
              <el-tag v-if="scope.row.postStatus == '启用'"></el-tag>
              <el-tag type="success" v-else-if="scope.row.postStatus == ''">不启用</el-tag>
            </template>
<template slot-scope="scope">
<el-tag v-if="scope.row.postStatus == '启用'"></el-tag>
<el-tag type="success" v-else-if="scope.row.postStatus == ''">不启用</el-tag>
</template>
</el-table-column>
<el-table-column label="操作" fixed="right" width="150">
<template slot-scope="scope">

@ -0,0 +1,2 @@
const superQueryJson = [{"clearable":true,"maxlength":null,"suffixIcon":"","fullName":"岗位名称","addonAfter":"","__config__":{"formId":101,"visibility":["pc","app"],"jnpfKey":"input","noShow":false,"tipLabel":"","dragDisabled":false,"className":[],"label":"岗位名称","trigger":"blur","showLabel":true,"required":true,"tableName":"yys_post","renderKey":1722837183559,"layout":"colFormItem","tagIcon":"icon-ym icon-ym-generator-input","unique":false,"tag":"JnpfInput","regList":[],"span":8},"readonly":false,"showWordLimit":false,"__vModel__":"postName","showPassword":false,"style":{"width":"100%"},"disabled":false,"id":"postName","placeholder":"请输入","prefixIcon":"","addonBefore":"","on":{"change":"({ data, formData, setFormData, setShowOrHide, setRequired, setDisabled, onlineUtils }) => {\n // 在此编写代码\n \n}","blur":"({ data, formData, setFormData, setShowOrHide, setRequired, setDisabled, onlineUtils }) => {\n // 在此编写代码\n \n}"}},{"clearable":true,"maxlength":null,"suffixIcon":"","fullName":"岗位编码","addonAfter":"","__config__":{"formId":102,"visibility":["pc","app"],"jnpfKey":"input","noShow":false,"tipLabel":"","dragDisabled":false,"className":[],"label":"岗位编码","trigger":"blur","showLabel":true,"required":true,"tableName":"yys_post","renderKey":1722837353100,"layout":"colFormItem","tagIcon":"icon-ym icon-ym-generator-input","unique":false,"tag":"JnpfInput","regList":[],"span":8},"readonly":false,"showWordLimit":false,"__vModel__":"postCode","showPassword":false,"style":{"width":"100%"},"disabled":false,"id":"postCode","placeholder":"请输入","prefixIcon":"","addonBefore":"","on":{"change":"({ data, formData, setFormData, setShowOrHide, setRequired, setDisabled, onlineUtils }) => {\n // 在此编写代码\n \n}","blur":"({ data, formData, setFormData, setShowOrHide, setRequired, setDisabled, onlineUtils }) => {\n // 在此编写代码\n \n}"}},{"clearable":true,"maxlength":null,"suffixIcon":"","fullName":"岗位顺序","addonAfter":"","__config__":{"formId":104,"visibility":["pc","app"],"jnpfKey":"input","noShow":false,"tipLabel":"","dragDisabled":false,"className":[],"label":"岗位顺序","trigger":"blur","showLabel":true,"required":false,"tableName":"yys_post","renderKey":1722837451727,"layout":"colFormItem","tagIcon":"icon-ym icon-ym-generator-input","unique":false,"tag":"JnpfInput","regList":[{"pattern":"/^\\d+$/","message":"请输入正确的数字"}],"span":8},"readonly":false,"showWordLimit":false,"__vModel__":"postSort","showPassword":false,"style":{"width":"100%"},"disabled":false,"id":"postSort","placeholder":"请输入","prefixIcon":"","addonBefore":"","on":{"change":"({ data, formData, setFormData, setShowOrHide, setRequired, setDisabled, onlineUtils }) => {\n // 在此编写代码\n \n}","blur":"({ data, formData, setFormData, setShowOrHide, setRequired, setDisabled, onlineUtils }) => {\n // 在此编写代码\n \n}"}},{"filterable":false,"clearable":true,"multiple":false,"fullName":"岗位状态","props":{"label":"fullName","value":"id"},"__config__":{"formId":103,"visibility":["pc","app"],"jnpfKey":"select","defaultValue":"","noShow":false,"dataType":"static","dictionaryType":"","tipLabel":"","dragDisabled":false,"className":[],"label":"岗位状态","trigger":"change","propsUrl":"","templateJson":[],"showLabel":true,"required":true,"tableName":"yys_post","renderKey":1722837372783,"layout":"colFormItem","tagIcon":"icon-ym icon-ym-generator-select","propsName":"","tag":"JnpfSelect","regList":[],"span":8},"options":[{"fullName":"启用","id":"1"},{"fullName":"不启用","id":"2"}],"__vModel__":"postStatus","style":{"width":"100%"},"disabled":false,"interfaceHasPage":false,"id":"postStatus","placeholder":"请选择","on":{"change":"({ data, formData, setFormData, setShowOrHide, setRequired, setDisabled, onlineUtils }) => {\n // 在此编写代码\n \n}"}},{"maxlength":null,"fullName":"岗位备注","type":"textarea","autoSize":{"minRows":4,"maxRows":4},"__config__":{"formId":105,"visibility":["pc","app"],"jnpfKey":"textarea","noShow":false,"tipLabel":"","dragDisabled":false,"className":[],"label":"岗位备注","trigger":"blur","showLabel":true,"required":false,"tableName":"yys_post","renderKey":1722837540972,"layout":"colFormItem","tagIcon":"icon-ym icon-ym-generator-textarea","tag":"JnpfTextarea","regList":[],"span":24},"readonly":false,"showWordLimit":true,"__vModel__":"reamrk","style":{"width":"100%"},"disabled":false,"id":"reamrk","placeholder":"请输入","on":{"change":"({ data, formData, setFormData, setShowOrHide, setRequired, setDisabled, onlineUtils }) => {\n // 在此编写代码\n \n}","blur":"({ data, formData, setFormData, setShowOrHide, setRequired, setDisabled, onlineUtils }) => {\n // 在此编写代码\n \n}"}}]
export default superQueryJson
Loading…
Cancel
Save