• Java项目:54 springboot工资信息管理系统453


    作者主页:舒克日记

    简介:Java领域优质创作者、Java项目、学习资料、技术互助

    文中获取源码

    项目介绍

    本系统的使用角色可以被分为用户和管理员,

    用户具有注册、查看信息、留言信息等功能,

    管理员具有修改用户信息,发布津贴等功能

    环境要求

    1.运行环境:最好是java jdk1.8,我们在这个平台上运行的。其他版本理论上也可以。

    2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA;

    3.tomcat环境:Tomcat7.x,8.X,9.x版本均可

    4.硬件环境:windows7/8/10 4G内存以上;或者Mac OS;

    5.是否Maven项目:是;查看源码目录中是否包含pom.xml;若包含,则为maven项目,否则为非maven.项目

    6.数据库:MySql5.7/8.0等版本均可;

    技术栈

    运行环境:jdk8 + tomcat9 + mysql5.7 + windows10

    服务端技术:Spring Boot+ Mybatis +VUE

    使用说明

    1.使用Navicati或者其它工具,在mysql中创建对应sq文件名称的数据库,并导入项目的sql文件;

    2.使用IDEA/Eclipse/MyEclipse导入项目,修改配置,运行项目;

    3.将项目中config-propertiesi配置文件中的数据库配置改为自己的配置,然后运行;

    运行指导

    idea导入源码空间站顶目教程说明(Vindows版)-ssm篇:

    http://mtw.so/5MHvZq

    源码地址:http://codegym.top

    运行截图

    文档截图

    image-20240315234234444

    项目截图

    微信截图_20240315233843

    微信截图_20240315233854

    微信截图_20240315233901

    微信截图_20240315233916

    微信截图_20240315233921

    微信截图_20240315233928

    微信截图_20240315233934

    微信截图_20240315234003

    微信截图_20240315234009

    微信截图_20240315234013

    微信截图_20240315234020

    微信截图_20240315233800

    微信截图_20240315233836

    代码

    
    package com.controller;
    
    import java.io.File;
    import java.math.BigDecimal;
    import java.net.URL;
    import java.text.SimpleDateFormat;
    import com.alibaba.fastjson.JSONObject;
    import java.util.*;
    import org.springframework.beans.BeanUtils;
    import javax.servlet.http.HttpServletRequest;
    import org.springframework.web.context.ContextLoader;
    import javax.servlet.ServletContext;
    import com.service.TokenService;
    import com.utils.*;
    import java.lang.reflect.InvocationTargetException;
    
    import com.service.DictionaryService;
    import org.apache.commons.lang3.StringUtils;
    import com.annotation.IgnoreAuth;
    import org.slf4j.Logger;
    import org.slf4j.LoggerFactory;
    import org.springframework.beans.factory.annotation.Autowired;
    import org.springframework.stereotype.Controller;
    import org.springframework.web.bind.annotation.*;
    import com.baomidou.mybatisplus.mapper.EntityWrapper;
    import com.baomidou.mybatisplus.mapper.Wrapper;
    import com.entity.*;
    import com.entity.view.*;
    import com.service.*;
    import com.utils.PageUtils;
    import com.utils.R;
    import com.alibaba.fastjson.*;
    
    /**
     * 津贴
     * 后端接口
     * @author
     * @email
    */
    @RestController
    @Controller
    @RequestMapping("/jintie")
    public class JintieController {
        private static final Logger logger = LoggerFactory.getLogger(JintieController.class);
    
        private static final String TABLE_NAME = "jintie";
    
        @Autowired
        private JintieService jintieService;
    
    
        @Autowired
        private TokenService tokenService;
    
        @Autowired
        private DictionaryService dictionaryService;//字典表
        @Autowired
        private GonggaoService gonggaoService;//公告
        @Autowired
        private JixiaoService jixiaoService;//绩效
        @Autowired
        private XinziService xinziService;//套账
        @Autowired
        private YuangongService yuangongService;//用户
        @Autowired
        private YuangongKaoqinService yuangongKaoqinService;//员工考勤
        @Autowired
        private YuangongKaoqinListService yuangongKaoqinListService;//员工考勤详情
        @Autowired
        private UsersService usersService;//管理员
    
    
        /**
        * 后端列表
        */
        @RequestMapping("/page")
        public R page(@RequestParam Map params, HttpServletRequest request){
            logger.debug("page方法:,,Controller:{},,params:{}",this.getClass().getName(),JSONObject.toJSONString(params));
            String role = String.valueOf(request.getSession().getAttribute("role"));
            if(false)
                return R.error(511,"永不会进入");
            else if("用户".equals(role))
                params.put("yuangongId",request.getSession().getAttribute("userId"));
            CommonUtil.checkMap(params);
            PageUtils page = jintieService.queryPage(params);
    
            //字典表数据转换
            List list =(List)page.getList();
            for(JintieView c:list){
                //修改对应字典表字段
                dictionaryService.dictionaryConvert(c, request);
            }
            return R.ok().put("data", page);
        }
    
        /**
        * 后端详情
        */
        @RequestMapping("/info/{id}")
        public R info(@PathVariable("id") Long id, HttpServletRequest request){
            logger.debug("info方法:,,Controller:{},,id:{}",this.getClass().getName(),id);
            JintieEntity jintie = jintieService.selectById(id);
            if(jintie !=null){
                //entity转view
                JintieView view = new JintieView();
                BeanUtils.copyProperties( jintie , view );//把实体数据重构到view中
                //级联表 用户
                //级联表
                YuangongEntity yuangong = yuangongService.selectById(jintie.getYuangongId());
                if(yuangong != null){
                BeanUtils.copyProperties( yuangong , view ,new String[]{ "id", "createTime", "insertTime", "updateTime", "username", "password", "newMoney", "yuangongId"});//把级联的数据添加到view中,并排除id和创建时间字段,当前表的级联注册表
                view.setYuangongId(yuangong.getId());
                }
                //修改对应字典表字段
                dictionaryService.dictionaryConvert(view, request);
                return R.ok().put("data", view);
            }else {
                return R.error(511,"查不到数据");
            }
    
        }
    
        /**
        * 后端保存
        */
        @RequestMapping("/save")
        public R save(@RequestBody JintieEntity jintie, HttpServletRequest request){
            logger.debug("save方法:,,Controller:{},,jintie:{}",this.getClass().getName(),jintie.toString());
    
            String role = String.valueOf(request.getSession().getAttribute("role"));
            if(false)
                return R.error(511,"永远不会进入");
            else if("用户".equals(role))
                jintie.setYuangongId(Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId"))));
    
            Wrapper queryWrapper = new EntityWrapper()
                .eq("yuangong_id", jintie.getYuangongId())
                .eq("jintie_name", jintie.getJintieName())
                .eq("jintie_types", jintie.getJintieTypes())
                ;
    
            logger.info("sql语句:"+queryWrapper.getSqlSegment());
            JintieEntity jintieEntity = jintieService.selectOne(queryWrapper);
            if(jintieEntity==null){
                jintie.setInsertTime(new Date());
                jintie.setCreateTime(new Date());
                jintieService.insert(jintie);
                return R.ok();
            }else {
                return R.error(511,"表中有相同数据");
            }
        }
    
        /**
        * 后端修改
        */
        @RequestMapping("/update")
        public R update(@RequestBody JintieEntity jintie, HttpServletRequest request) throws NoSuchFieldException, ClassNotFoundException, IllegalAccessException, InstantiationException {
            logger.debug("update方法:,,Controller:{},,jintie:{}",this.getClass().getName(),jintie.toString());
            JintieEntity oldJintieEntity = jintieService.selectById(jintie.getId());//查询原先数据
    
            String role = String.valueOf(request.getSession().getAttribute("role"));
    //        if(false)
    //            return R.error(511,"永远不会进入");
    //        else if("用户".equals(role))
    //            jintie.setYuangongId(Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId"))));
            if("".equals(jintie.getJintieFile()) || "null".equals(jintie.getJintieFile())){
                    jintie.setJintieFile(null);
            }
            if("".equals(jintie.getJintieContent()) || "null".equals(jintie.getJintieContent())){
                    jintie.setJintieContent(null);
            }
    
                jintieService.updateById(jintie);//根据id更新
                return R.ok();
        }
    
    
    
        /**
        * 删除
        */
        @RequestMapping("/delete")
        public R delete(@RequestBody Integer[] ids, HttpServletRequest request){
            logger.debug("delete:,,Controller:{},,ids:{}",this.getClass().getName(),ids.toString());
            List oldJintieList =jintieService.selectBatchIds(Arrays.asList(ids));//要删除的数据
            jintieService.deleteBatchIds(Arrays.asList(ids));
    
            return R.ok();
        }
    
    
        /**
         * 批量上传
         */
        @RequestMapping("/batchInsert")
        public R save( String fileName, HttpServletRequest request){
            logger.debug("batchInsert方法:,,Controller:{},,fileName:{}",this.getClass().getName(),fileName);
            Integer yuangongId = Integer.valueOf(String.valueOf(request.getSession().getAttribute("userId")));
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
            //.eq("time", new SimpleDateFormat("yyyy-MM-dd").format(new Date()))
            try {
                List jintieList = new ArrayList<>();//上传的东西
                Map> seachFields= new HashMap<>();//要查询的字段
                Date date = new Date();
                int lastIndexOf = fileName.lastIndexOf(".");
                if(lastIndexOf == -1){
                    return R.error(511,"该文件没有后缀");
                }else{
                    String suffix = fileName.substring(lastIndexOf);
                    if(!".xls".equals(suffix)){
                        return R.error(511,"只支持后缀为xls的excel文件");
                    }else{
                        URL resource = this.getClass().getClassLoader().getResource("static/upload/" + fileName);//获取文件路径
                        File file = new File(resource.getFile());
                        if(!file.exists()){
                            return R.error(511,"找不到上传文件,请联系管理员");
                        }else{
                            List> dataList = PoiUtil.poiImport(file.getPath());//读取xls文件
                            dataList.remove(0);//删除第一行,因为第一行是提示
                            for(List data:dataList){
                                //循环
                                JintieEntity jintieEntity = new JintieEntity();
    //                            jintieEntity.setYuangongId(Integer.valueOf(data.get(0)));   //员工 要改的
    //                            jintieEntity.setJintieUuidNumber(data.get(0));                    //津贴编号 要改的
    //                            jintieEntity.setJintieName(data.get(0));                    //津贴标题 要改的
    //                            jintieEntity.setJintieFile(data.get(0));                    //附件 要改的
    //                            jintieEntity.setJintieTypes(Integer.valueOf(data.get(0)));   //津贴类型 要改的
    //                            jintieEntity.setJintieJine(data.get(0));                    //津贴金额 要改的
    //                            jintieEntity.setJintieContent("");//详情和图片
    //                            jintieEntity.setInsertTime(date);//时间
    //                            jintieEntity.setCreateTime(date);//时间
                                jintieList.add(jintieEntity);
    
    
                                //把要查询是否重复的字段放入map中
                                    //津贴编号
                                    if(seachFields.containsKey("jintieUuidNumber")){
                                        List jintieUuidNumber = seachFields.get("jintieUuidNumber");
                                        jintieUuidNumber.add(data.get(0));//要改的
                                    }else{
                                        List jintieUuidNumber = new ArrayList<>();
                                        jintieUuidNumber.add(data.get(0));//要改的
                                        seachFields.put("jintieUuidNumber",jintieUuidNumber);
                                    }
                            }
    
                            //查询是否重复
                             //津贴编号
                            List jintieEntities_jintieUuidNumber = jintieService.selectList(new EntityWrapper().in("jintie_uuid_number", seachFields.get("jintieUuidNumber")));
                            if(jintieEntities_jintieUuidNumber.size() >0 ){
                                ArrayList repeatFields = new ArrayList<>();
                                for(JintieEntity s:jintieEntities_jintieUuidNumber){
                                    repeatFields.add(s.getJintieUuidNumber());
                                }
                                return R.error(511,"数据库的该表中的 [津贴编号] 字段已经存在 存在数据为:"+repeatFields.toString());
                            }
                            jintieService.insertBatch(jintieList);
                            return R.ok();
                        }
                    }
                }
            }catch (Exception e){
                e.printStackTrace();
                return R.error(511,"批量插入数据异常,请联系管理员");
            }
        }
    
    
    
    
    }
    
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
    • 67
    • 68
    • 69
    • 70
    • 71
    • 72
    • 73
    • 74
    • 75
    • 76
    • 77
    • 78
    • 79
    • 80
    • 81
    • 82
    • 83
    • 84
    • 85
    • 86
    • 87
    • 88
    • 89
    • 90
    • 91
    • 92
    • 93
    • 94
    • 95
    • 96
    • 97
    • 98
    • 99
    • 100
    • 101
    • 102
    • 103
    • 104
    • 105
    • 106
    • 107
    • 108
    • 109
    • 110
    • 111
    • 112
    • 113
    • 114
    • 115
    • 116
    • 117
    • 118
    • 119
    • 120
    • 121
    • 122
    • 123
    • 124
    • 125
    • 126
    • 127
    • 128
    • 129
    • 130
    • 131
    • 132
    • 133
    • 134
    • 135
    • 136
    • 137
    • 138
    • 139
    • 140
    • 141
    • 142
    • 143
    • 144
    • 145
    • 146
    • 147
    • 148
    • 149
    • 150
    • 151
    • 152
    • 153
    • 154
    • 155
    • 156
    • 157
    • 158
    • 159
    • 160
    • 161
    • 162
    • 163
    • 164
    • 165
    • 166
    • 167
    • 168
    • 169
    • 170
    • 171
    • 172
    • 173
    • 174
    • 175
    • 176
    • 177
    • 178
    • 179
    • 180
    • 181
    • 182
    • 183
    • 184
    • 185
    • 186
    • 187
    • 188
    • 189
    • 190
    • 191
    • 192
    • 193
    • 194
    • 195
    • 196
    • 197
    • 198
    • 199
    • 200
    • 201
    • 202
    • 203
    • 204
    • 205
    • 206
    • 207
    • 208
    • 209
    • 210
    • 211
    • 212
    • 213
    • 214
    • 215
    • 216
    • 217
    • 218
    • 219
    • 220
    • 221
    • 222
    • 223
    • 224
    • 225
    • 226
    • 227
    • 228
    • 229
    • 230
    • 231
    • 232
    • 233
    • 234
    • 235
    • 236
    • 237
    • 238
    • 239
    • 240
    • 241
    • 242
    • 243
    • 244
    • 245
    • 246
    • 247
    • 248
    • 249
    • 250
    • 251
    • 252
    • 253
    • 254
    • 255
    • 256
    • 257
    • 258
    • 259
    • 260
    • 261
    • 262
    • 263
    • 264
    • 265
    • 266
    • 267
    • 268
    • 269
    • 270
    • 271
    • 272
    • 273
    • 274
    • 275
  • 相关阅读:
    E047-论坛漏洞分析及利用-针对Wordpress论坛进行信息收集与漏洞扫描的探索
    04.toRef 默认值
    包含日志文件
    Nature、science、cell旗下刊物
    源码解析FlinkKafkaConsumer支持punctuated水位线发送
    LQ0035 时间显示【时间计算】
    青龙面板【常见问题报错】以及【升级方法】
    iview label-in-value 和 @on-change 的使用
    typescript变量
    蓝桥杯刷题(九)
  • 原文地址:https://blog.csdn.net/cativen/article/details/136752630