From 50b32fe3b60b9bba03436e0895ed53e0a0c177d8 Mon Sep 17 00:00:00 2001
From: 赵士淞 <zhaoss@yhzhg.cn>
Date: Tue, 21 Mar 2023 06:52:31 +0000
Subject: [PATCH] 目标管理

---
 eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/mapstruct/SysGoalSettingMapper.java  |   32 ++
 eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/domain/SysGoalSetting.java                   |   69 ++++
 eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/SysGoalSettingDto.java           |   48 +++
 eladmin-web-master/src/components/Crud/crud.js                                                                      |   13 
 eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/repository/SysGoalSettingRepository.java     |   28 ++
 eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/SysGoalSettingService.java           |   83 +++++
 eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/temp/Temp.java                                      |   48 +++
 eladmin-web-master/src/api/system/goalSetting.js                                                                    |   35 ++
 eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/SysGoalSettingController.java           |   95 ++++++
 eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/SysGoalSettingQueryCriteria.java |   38 ++
 eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/SysGoalSettingServiceImpl.java  |  144 ++++++++++
 eladmin-web-master/src/views/system/goalSetting/index.vue                                                           |  156 +++++++++++
 12 files changed, 789 insertions(+), 0 deletions(-)

diff --git a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/domain/SysGoalSetting.java b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/domain/SysGoalSetting.java
new file mode 100644
index 0000000..3f69a98
--- /dev/null
+++ b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/domain/SysGoalSetting.java
@@ -0,0 +1,69 @@
+/*
+*  Copyright 2019-2020 Zheng Jie
+*
+*  Licensed under the Apache License, Version 2.0 (the "License");
+*  you may not use this file except in compliance with the License.
+*  You may obtain a copy of the License at
+*
+*  http://www.apache.org/licenses/LICENSE-2.0
+*
+*  Unless required by applicable law or agreed to in writing, software
+*  distributed under the License is distributed on an "AS IS" BASIS,
+*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*  See the License for the specific language governing permissions and
+*  limitations under the License.
+*/
+package me.zhengjie.modules.system.domain;
+
+import lombok.Data;
+import cn.hutool.core.bean.BeanUtil;
+import io.swagger.annotations.ApiModelProperty;
+import cn.hutool.core.bean.copier.CopyOptions;
+import me.zhengjie.base.BaseEntity;
+
+import javax.persistence.*;
+import javax.validation.constraints.*;
+import java.sql.Timestamp;
+import java.math.BigDecimal;
+import java.io.Serializable;
+
+/**
+* @website https://eladmin.vip
+* @description /
+* @author 赵士淞
+* @date 2023-03-21
+**/
+@Entity
+@Data
+@Table(name="sys_goal_setting")
+public class SysGoalSetting extends BaseEntity implements Serializable {
+
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    @Column(name = "`id`")
+    @ApiModelProperty(value = "ID")
+    private Long id;
+
+    @Column(name = "`target_year`",nullable = false)
+    @NotNull
+    @ApiModelProperty(value = "目标年度")
+    private Timestamp targetYear;
+
+    @Column(name = "`project_distinguish`",nullable = false)
+    @NotBlank
+    @ApiModelProperty(value = "项目区分")
+    private String projectDistinguish;
+
+    @Column(name = "`target_amount`",nullable = false)
+    @NotNull
+    @ApiModelProperty(value = "目标金额")
+    private BigDecimal targetAmount;
+
+    @Column(name = "`remarks`")
+    @ApiModelProperty(value = "备注")
+    private String remarks;
+
+    public void copy(SysGoalSetting source){
+        BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
+    }
+}
diff --git a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/repository/SysGoalSettingRepository.java b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/repository/SysGoalSettingRepository.java
new file mode 100644
index 0000000..871450d
--- /dev/null
+++ b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/repository/SysGoalSettingRepository.java
@@ -0,0 +1,28 @@
+/*
+*  Copyright 2019-2020 Zheng Jie
+*
+*  Licensed under the Apache License, Version 2.0 (the "License");
+*  you may not use this file except in compliance with the License.
+*  You may obtain a copy of the License at
+*
+*  http://www.apache.org/licenses/LICENSE-2.0
+*
+*  Unless required by applicable law or agreed to in writing, software
+*  distributed under the License is distributed on an "AS IS" BASIS,
+*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*  See the License for the specific language governing permissions and
+*  limitations under the License.
+*/
+package me.zhengjie.modules.system.repository;
+
+import me.zhengjie.modules.system.domain.SysGoalSetting;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
+
+/**
+* @website https://eladmin.vip
+* @author 赵士淞
+* @date 2023-03-21
+**/
+public interface SysGoalSettingRepository extends JpaRepository<SysGoalSetting, Long>, JpaSpecificationExecutor<SysGoalSetting> {
+}
\ No newline at end of file
diff --git a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/SysGoalSettingController.java b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/SysGoalSettingController.java
new file mode 100644
index 0000000..61a2b83
--- /dev/null
+++ b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/rest/SysGoalSettingController.java
@@ -0,0 +1,95 @@
+/*
+*  Copyright 2019-2020 Zheng Jie
+*
+*  Licensed under the Apache License, Version 2.0 (the "License");
+*  you may not use this file except in compliance with the License.
+*  You may obtain a copy of the License at
+*
+*  http://www.apache.org/licenses/LICENSE-2.0
+*
+*  Unless required by applicable law or agreed to in writing, software
+*  distributed under the License is distributed on an "AS IS" BASIS,
+*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*  See the License for the specific language governing permissions and
+*  limitations under the License.
+*/
+package me.zhengjie.modules.system.rest;
+
+import me.zhengjie.annotation.Log;
+import me.zhengjie.modules.system.domain.SysGoalSetting;
+import me.zhengjie.modules.system.service.SysGoalSettingService;
+import me.zhengjie.modules.system.service.dto.SysGoalSettingQueryCriteria;
+import org.springframework.data.domain.Pageable;
+import lombok.RequiredArgsConstructor;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+import io.swagger.annotations.*;
+import java.io.IOException;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+* @website https://eladmin.vip
+* @author 赵士淞
+* @date 2023-03-21
+**/
+@RestController
+@RequiredArgsConstructor
+@Api(tags = "目标设定管理")
+@RequestMapping("/api/sysGoalSetting")
+public class SysGoalSettingController {
+
+    private final SysGoalSettingService sysGoalSettingService;
+
+    @Log("导出数据")
+    @ApiOperation("导出数据")
+    @GetMapping(value = "/download")
+    @PreAuthorize("@el.check('sysGoalSetting:download')")
+    public void exportSysGoalSetting(HttpServletResponse response, SysGoalSettingQueryCriteria criteria) throws IOException {
+        sysGoalSettingService.download(sysGoalSettingService.queryAll(criteria), response);
+    }
+
+    @GetMapping
+    @Log("查询目标设定")
+    @ApiOperation("查询目标设定")
+    @PreAuthorize("@el.check('sysGoalSetting:list')")
+    public ResponseEntity<Object> querySysGoalSetting(SysGoalSettingQueryCriteria criteria, Pageable pageable){
+        return new ResponseEntity<>(sysGoalSettingService.queryAll(criteria,pageable),HttpStatus.OK);
+    }
+
+    @GetMapping(value = "/all")
+    @Log("查询目标设定")
+    @ApiOperation("查询目标设定")
+    @PreAuthorize("@el.check('sysGoalSetting:list')")
+    public ResponseEntity<Object> querySysGoalSetting(SysGoalSettingQueryCriteria criteria){
+        return new ResponseEntity<>(sysGoalSettingService.queryAll(criteria),HttpStatus.OK);
+    }
+
+    @PostMapping
+    @Log("新增目标设定")
+    @ApiOperation("新增目标设定")
+    @PreAuthorize("@el.check('sysGoalSetting:add')")
+    public ResponseEntity<Object> createSysGoalSetting(@Validated @RequestBody SysGoalSetting resources) throws Exception{
+        return new ResponseEntity<>(sysGoalSettingService.create(resources),HttpStatus.CREATED);
+    }
+
+    @PutMapping
+    @Log("修改目标设定")
+    @ApiOperation("修改目标设定")
+    @PreAuthorize("@el.check('sysGoalSetting:edit')")
+    public ResponseEntity<Object> updateSysGoalSetting(@Validated @RequestBody SysGoalSetting resources) throws Exception{
+        sysGoalSettingService.update(resources);
+        return new ResponseEntity<>(HttpStatus.NO_CONTENT);
+    }
+
+    @DeleteMapping
+    @Log("删除目标设定")
+    @ApiOperation("删除目标设定")
+    @PreAuthorize("@el.check('sysGoalSetting:del')")
+    public ResponseEntity<Object> deleteSysGoalSetting(@RequestBody Long[] ids) {
+        sysGoalSettingService.deleteAll(ids);
+        return new ResponseEntity<>(HttpStatus.OK);
+    }
+}
\ No newline at end of file
diff --git a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/SysGoalSettingService.java b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/SysGoalSettingService.java
new file mode 100644
index 0000000..e0d5589
--- /dev/null
+++ b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/SysGoalSettingService.java
@@ -0,0 +1,83 @@
+/*
+*  Copyright 2019-2020 Zheng Jie
+*
+*  Licensed under the Apache License, Version 2.0 (the "License");
+*  you may not use this file except in compliance with the License.
+*  You may obtain a copy of the License at
+*
+*  http://www.apache.org/licenses/LICENSE-2.0
+*
+*  Unless required by applicable law or agreed to in writing, software
+*  distributed under the License is distributed on an "AS IS" BASIS,
+*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*  See the License for the specific language governing permissions and
+*  limitations under the License.
+*/
+package me.zhengjie.modules.system.service;
+
+import me.zhengjie.modules.system.domain.SysGoalSetting;
+import me.zhengjie.modules.system.service.dto.SysGoalSettingDto;
+import me.zhengjie.modules.system.service.dto.SysGoalSettingQueryCriteria;
+import org.springframework.data.domain.Pageable;
+import java.util.Map;
+import java.util.List;
+import java.io.IOException;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+* @website https://eladmin.vip
+* @description 服务接口
+* @author 赵士淞
+* @date 2023-03-21
+**/
+public interface SysGoalSettingService {
+
+    /**
+    * 查询数据分页
+    * @param criteria 条件
+    * @param pageable 分页参数
+    * @return Map<String,Object>
+    */
+    Map<String,Object> queryAll(SysGoalSettingQueryCriteria criteria, Pageable pageable);
+
+    /**
+    * 查询所有数据不分页
+    * @param criteria 条件参数
+    * @return List<SysGoalSettingDto>
+    */
+    List<SysGoalSettingDto> queryAll(SysGoalSettingQueryCriteria criteria);
+
+    /**
+     * 根据ID查询
+     * @param id ID
+     * @return SysGoalSettingDto
+     */
+    SysGoalSettingDto findById(Long id);
+
+    /**
+    * 创建
+    * @param resources /
+    * @return SysGoalSettingDto
+    */
+    SysGoalSettingDto create(SysGoalSetting resources) throws Exception;
+
+    /**
+    * 编辑
+    * @param resources /
+    */
+    void update(SysGoalSetting resources) throws Exception;
+
+    /**
+    * 多选删除
+    * @param ids /
+    */
+    void deleteAll(Long[] ids);
+
+    /**
+    * 导出数据
+    * @param all 待导出的数据
+    * @param response /
+    * @throws IOException /
+    */
+    void download(List<SysGoalSettingDto> all, HttpServletResponse response) throws IOException;
+}
\ No newline at end of file
diff --git a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/SysGoalSettingDto.java b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/SysGoalSettingDto.java
new file mode 100644
index 0000000..1da9ae1
--- /dev/null
+++ b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/SysGoalSettingDto.java
@@ -0,0 +1,48 @@
+/*
+*  Copyright 2019-2020 Zheng Jie
+*
+*  Licensed under the Apache License, Version 2.0 (the "License");
+*  you may not use this file except in compliance with the License.
+*  You may obtain a copy of the License at
+*
+*  http://www.apache.org/licenses/LICENSE-2.0
+*
+*  Unless required by applicable law or agreed to in writing, software
+*  distributed under the License is distributed on an "AS IS" BASIS,
+*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*  See the License for the specific language governing permissions and
+*  limitations under the License.
+*/
+package me.zhengjie.modules.system.service.dto;
+
+import lombok.Data;
+import me.zhengjie.base.BaseDTO;
+
+import java.sql.Timestamp;
+import java.math.BigDecimal;
+import java.io.Serializable;
+
+/**
+* @website https://eladmin.vip
+* @description /
+* @author 赵士淞
+* @date 2023-03-21
+**/
+@Data
+public class SysGoalSettingDto extends BaseDTO implements Serializable {
+
+    /** ID */
+    private Long id;
+
+    /** 目标年度 */
+    private Timestamp targetYear;
+
+    /** 项目区分 */
+    private String projectDistinguish;
+
+    /** 目标金额 */
+    private BigDecimal targetAmount;
+
+    /** 备注 */
+    private String remarks;
+}
\ No newline at end of file
diff --git a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/SysGoalSettingQueryCriteria.java b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/SysGoalSettingQueryCriteria.java
new file mode 100644
index 0000000..121ad98
--- /dev/null
+++ b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/dto/SysGoalSettingQueryCriteria.java
@@ -0,0 +1,38 @@
+/*
+*  Copyright 2019-2020 Zheng Jie
+*
+*  Licensed under the Apache License, Version 2.0 (the "License");
+*  you may not use this file except in compliance with the License.
+*  You may obtain a copy of the License at
+*
+*  http://www.apache.org/licenses/LICENSE-2.0
+*
+*  Unless required by applicable law or agreed to in writing, software
+*  distributed under the License is distributed on an "AS IS" BASIS,
+*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*  See the License for the specific language governing permissions and
+*  limitations under the License.
+*/
+package me.zhengjie.modules.system.service.dto;
+
+import lombok.Data;
+import java.sql.Timestamp;
+import java.util.List;
+import me.zhengjie.annotation.Query;
+
+/**
+* @website https://eladmin.vip
+* @author 赵士淞
+* @date 2023-03-21
+**/
+@Data
+public class SysGoalSettingQueryCriteria{
+
+    /** 精确 */
+    @Query(type = Query.Type.INNER_LIKE)
+    private String targetYear;
+
+    /** 精确 */
+    @Query
+    private String projectDistinguish;
+}
\ No newline at end of file
diff --git a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/SysGoalSettingServiceImpl.java b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/SysGoalSettingServiceImpl.java
new file mode 100644
index 0000000..aee6944
--- /dev/null
+++ b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/SysGoalSettingServiceImpl.java
@@ -0,0 +1,144 @@
+/*
+*  Copyright 2019-2020 Zheng Jie
+*
+*  Licensed under the Apache License, Version 2.0 (the "License");
+*  you may not use this file except in compliance with the License.
+*  You may obtain a copy of the License at
+*
+*  http://www.apache.org/licenses/LICENSE-2.0
+*
+*  Unless required by applicable law or agreed to in writing, software
+*  distributed under the License is distributed on an "AS IS" BASIS,
+*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*  See the License for the specific language governing permissions and
+*  limitations under the License.
+*/
+package me.zhengjie.modules.system.service.impl;
+
+import me.zhengjie.exception.BadRequestException;
+import me.zhengjie.modules.constant.Constant;
+import me.zhengjie.modules.system.domain.SysGoalSetting;
+import me.zhengjie.modules.system.repository.DictDetailRepository;
+import me.zhengjie.utils.*;
+import lombok.RequiredArgsConstructor;
+import me.zhengjie.modules.system.repository.SysGoalSettingRepository;
+import me.zhengjie.modules.system.service.SysGoalSettingService;
+import me.zhengjie.modules.system.service.dto.SysGoalSettingDto;
+import me.zhengjie.modules.system.service.dto.SysGoalSettingQueryCriteria;
+import me.zhengjie.modules.system.service.mapstruct.SysGoalSettingMapper;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
+
+import java.text.SimpleDateFormat;
+import java.util.List;
+import java.util.Map;
+import java.io.IOException;
+import javax.servlet.http.HttpServletResponse;
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+
+/**
+* @website https://eladmin.vip
+* @description 服务实现
+* @author 赵士淞
+* @date 2023-03-21
+**/
+@Service
+@RequiredArgsConstructor
+public class SysGoalSettingServiceImpl implements SysGoalSettingService {
+
+    private final SysGoalSettingRepository sysGoalSettingRepository;
+    private final SysGoalSettingMapper sysGoalSettingMapper;
+    private final DictDetailRepository dictDetailRepository;
+
+    @Override
+    public Map<String,Object> queryAll(SysGoalSettingQueryCriteria criteria, Pageable pageable){
+        // 判断目标查询类目标年度是否为空
+        if (criteria.getTargetYear() != null && !"".equals(criteria.getTargetYear())) {
+            // 目标年度:国际时间转中国时间
+            criteria.setTargetYear(DateUtil.internationalTimeToChinaTime(criteria.getTargetYear()));
+        }
+        Page<SysGoalSetting> page = sysGoalSettingRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
+        return PageUtil.toPage(page.map(sysGoalSettingMapper::toDto));
+    }
+
+    @Override
+    public List<SysGoalSettingDto> queryAll(SysGoalSettingQueryCriteria criteria){
+        return sysGoalSettingMapper.toDto(sysGoalSettingRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
+    }
+
+    @Override
+    @Transactional
+    public SysGoalSettingDto findById(Long id) {
+        SysGoalSetting sysGoalSetting = sysGoalSettingRepository.findById(id).orElseGet(SysGoalSetting::new);
+        ValidationUtil.isNull(sysGoalSetting.getId(),"SysGoalSetting","id",id);
+        return sysGoalSettingMapper.toDto(sysGoalSetting);
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public SysGoalSettingDto create(SysGoalSetting resources) throws Exception {
+        createOrUpdateCheck(resources);
+        return sysGoalSettingMapper.toDto(sysGoalSettingRepository.save(resources));
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void update(SysGoalSetting resources) throws Exception {
+        SysGoalSetting sysGoalSetting = sysGoalSettingRepository.findById(resources.getId()).orElseGet(SysGoalSetting::new);
+        ValidationUtil.isNull( sysGoalSetting.getId(),"SysGoalSetting","id",resources.getId());
+        sysGoalSetting.copy(resources);
+        createOrUpdateCheck(sysGoalSetting);
+        sysGoalSettingRepository.save(sysGoalSetting);
+    }
+
+    @Override
+    public void deleteAll(Long[] ids) {
+        for (Long id : ids) {
+            sysGoalSettingRepository.deleteById(id);
+        }
+    }
+
+    @Override
+    public void download(List<SysGoalSettingDto> all, HttpServletResponse response) throws IOException {
+        List<Map<String, Object>> list = new ArrayList<>();
+        for (SysGoalSettingDto sysGoalSetting : all) {
+            SimpleDateFormat sdf = new SimpleDateFormat("yyyy");
+            String targetYear = sdf.format(sysGoalSetting.getTargetYear());
+            String projectDistinguish = sysGoalSetting.getProjectDistinguish() != null ? dictDetailRepository.findByDictNameAndValue(Constant.PROJECT_DISTINGUISH, sysGoalSetting.getProjectDistinguish()).getLabel() : "";
+            Map<String,Object> map = new LinkedHashMap<>();
+            map.put("目标年度", targetYear);
+            map.put("项目区分", projectDistinguish);
+            map.put("目标金额", sysGoalSetting.getTargetAmount());
+            map.put("备注", sysGoalSetting.getRemarks());
+            map.put("创建者", sysGoalSetting.getCreateBy());
+            map.put("创建时间", sysGoalSetting.getCreateTime());
+            map.put("更新者", sysGoalSetting.getUpdateBy());
+            map.put("更新时间", sysGoalSetting.getUpdateTime());
+            list.add(map);
+        }
+        FileUtil.downloadExcel(list, response);
+    }
+
+    private void createOrUpdateCheck(SysGoalSetting resources) throws Exception {
+        // 日期格式化
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        String targetYear = sdf.format(resources.getTargetYear());
+        // 目标检索类
+        SysGoalSettingQueryCriteria criteria = new SysGoalSettingQueryCriteria();
+        criteria.setTargetYear(DateUtil.internationalTimeToChinaTime(targetYear));
+        criteria.setProjectDistinguish(resources.getProjectDistinguish());
+        // 查询目标数据
+        List<SysGoalSettingDto> sysGoalSettingDtoList = queryAll(criteria);
+        // 判断目标数据
+        if (sysGoalSettingDtoList.size() > 1) {
+            throw new BadRequestException("目标年度已有此项目区分数据!");
+        } else if (sysGoalSettingDtoList.size() == 1) {
+            if (sysGoalSettingDtoList.get(0).getId() != resources.getId()) {
+                throw new BadRequestException("目标年度已有此项目区分数据!");
+            }
+        }
+    }
+}
\ No newline at end of file
diff --git a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/mapstruct/SysGoalSettingMapper.java b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/mapstruct/SysGoalSettingMapper.java
new file mode 100644
index 0000000..fbe5348
--- /dev/null
+++ b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/mapstruct/SysGoalSettingMapper.java
@@ -0,0 +1,32 @@
+/*
+*  Copyright 2019-2020 Zheng Jie
+*
+*  Licensed under the Apache License, Version 2.0 (the "License");
+*  you may not use this file except in compliance with the License.
+*  You may obtain a copy of the License at
+*
+*  http://www.apache.org/licenses/LICENSE-2.0
+*
+*  Unless required by applicable law or agreed to in writing, software
+*  distributed under the License is distributed on an "AS IS" BASIS,
+*  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+*  See the License for the specific language governing permissions and
+*  limitations under the License.
+*/
+package me.zhengjie.modules.system.service.mapstruct;
+
+import me.zhengjie.base.BaseMapper;
+import me.zhengjie.modules.system.domain.SysGoalSetting;
+import me.zhengjie.modules.system.service.dto.SysGoalSettingDto;
+import org.mapstruct.Mapper;
+import org.mapstruct.ReportingPolicy;
+
+/**
+* @website https://eladmin.vip
+* @author 赵士淞
+* @date 2023-03-21
+**/
+@Mapper(componentModel = "spring", unmappedTargetPolicy = ReportingPolicy.IGNORE)
+public interface SysGoalSettingMapper extends BaseMapper<SysGoalSettingDto, SysGoalSetting> {
+
+}
\ No newline at end of file
diff --git a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/temp/Temp.java b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/temp/Temp.java
new file mode 100644
index 0000000..11efb70
--- /dev/null
+++ b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/temp/Temp.java
@@ -0,0 +1,48 @@
+package me.zhengjie.modules.temp;
+
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.RequiredArgsConstructor;
+import me.zhengjie.annotation.Log;
+import me.zhengjie.annotation.rest.AnonymousPutMapping;
+import me.zhengjie.modules.project.domain.Project;
+import me.zhengjie.modules.project.repository.ProjectRepository;
+import me.zhengjie.modules.project.repository.ProjectTypeRepository;
+import me.zhengjie.modules.project.service.ProjectService;
+import me.zhengjie.modules.project.service.dto.ProjectDto;
+import me.zhengjie.modules.project.service.dto.ProjectQueryCriteria;
+import me.zhengjie.modules.project.service.mapstruct.ProjectMapper;
+import me.zhengjie.utils.QueryHelp;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+
+@RestController
+@RequiredArgsConstructor
+@Api(tags = "临时接口")
+@RequestMapping("/api/temp")
+public class Temp {
+
+    private final ProjectRepository projectRepository;
+
+    @AnonymousPutMapping(value = "/updateProjectLiableUserId")
+    @Log("修改项目责任人ID")
+    @ApiOperation("修改项目责任人ID")
+    public ResponseEntity<Object> updateProjectLiableUserId(){
+        ProjectQueryCriteria criteria = new ProjectQueryCriteria();
+        List<Project> projectList = projectRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder));
+
+        for (int i = 0; i < projectList.size(); i ++) {
+            Project project = projectList.get(i);
+            if (project.getLiableUserId() != null && !"".equals(project.getLiableUserId())) {
+                project.setLiableUserId("-" + project.getLiableUserId() + "-");
+                projectRepository.save(project);
+            }
+        }
+
+        return new ResponseEntity<>("", HttpStatus.OK);
+    }
+}
diff --git a/eladmin-web-master/src/api/system/goalSetting.js b/eladmin-web-master/src/api/system/goalSetting.js
new file mode 100644
index 0000000..4d4969d
--- /dev/null
+++ b/eladmin-web-master/src/api/system/goalSetting.js
@@ -0,0 +1,35 @@
+import request from '@/utils/request'
+
+export function getAll(params) {
+  return request({
+    url: 'api/sysGoalSetting/all',
+    method: 'get',
+    params
+  })
+}
+
+export function add(data) {
+  return request({
+    url: 'api/sysGoalSetting',
+    method: 'post',
+    data
+  })
+}
+
+export function del(ids) {
+  return request({
+    url: 'api/sysGoalSetting/',
+    method: 'delete',
+    data: ids
+  })
+}
+
+export function edit(data) {
+  return request({
+    url: 'api/sysGoalSetting',
+    method: 'put',
+    data
+  })
+}
+
+export default { getAll, add, edit, del }
diff --git a/eladmin-web-master/src/components/Crud/crud.js b/eladmin-web-master/src/components/Crud/crud.js
index bfe0be2..82c179f 100644
--- a/eladmin-web-master/src/components/Crud/crud.js
+++ b/eladmin-web-master/src/components/Crud/crud.js
@@ -531,6 +531,19 @@
       })
     },
     /**
+     * 年份格式化
+     * @param {Object} timestamp 时间戳
+     */
+    toYear(timestamp) {
+      if (timestamp == null) {
+        return
+      } else {
+        const system = new Date(timestamp)
+        const year = system.getFullYear()
+        return year
+      }
+    },
+    /**
      * 年月格式化
      * @param {Object} timestamp 时间戳
      */
diff --git a/eladmin-web-master/src/views/system/goalSetting/index.vue b/eladmin-web-master/src/views/system/goalSetting/index.vue
new file mode 100644
index 0000000..778c9ce
--- /dev/null
+++ b/eladmin-web-master/src/views/system/goalSetting/index.vue
@@ -0,0 +1,156 @@
+<template>
+  <div class="app-container">
+    <!--工具栏-->
+    <div class="head-container">
+      <div v-if="crud.props.searchToggle">
+        <!-- 搜索 -->
+        <el-date-picker v-model="query.targetYear" type="year" clearable placeholder="目标年度" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery" />
+        <el-select v-model="query.projectDistinguish" filterable clearable placeholder="项目区分" style="width: 185px;" class="filter-item" @keyup.enter.native="crud.toQuery">
+          <el-option
+            v-for="item in dict[projectDistinguish]"
+            :key="item.id"
+            :label="item.label"
+            :value="item.value"
+          />
+        </el-select>
+        <rrOperation :crud="crud" />
+      </div>
+      <!--如果想在工具栏加入更多按钮,可以使用插槽方式, slot = 'left' or 'right'-->
+      <crudOperation :permission="permission" />
+      <!--表单组件-->
+      <el-dialog :close-on-click-modal="false" :before-close="crud.cancelCU" :visible.sync="crud.status.cu > 0" :title="crud.status.title" width="500px">
+        <el-form ref="form" :model="form" :rules="rules" size="small" label-width="80px">
+          <el-form-item label="目标年度" prop="targetYear">
+            <el-date-picker v-model="form.targetYear" type="year" style="width: 370px;" />
+          </el-form-item>
+          <el-form-item label="项目区分" prop="projectDistinguish">
+            <el-select v-model="form.projectDistinguish" filterable placeholder="请选择" style="width: 370px;">
+              <el-option
+                v-for="item in dict[projectDistinguish]"
+                :key="item.id"
+                :label="item.label"
+                :value="item.value"
+              />
+            </el-select>
+          </el-form-item>
+          <el-form-item label="目标金额" prop="targetAmount">
+            <money-input :key="random" v-model="form.targetAmount" :width="370" />
+          </el-form-item>
+          <el-form-item label="备注">
+            <el-input v-model="form.remarks" :rows="3" type="textarea" style="width: 370px;" />
+          </el-form-item>
+        </el-form>
+        <div slot="footer" class="dialog-footer">
+          <el-button type="text" @click="crud.cancelCU">取消</el-button>
+          <el-button :loading="crud.status.cu === 2" type="primary" @click="crud.submitCU">确认</el-button>
+        </div>
+      </el-dialog>
+      <!--表格渲染-->
+      <el-table ref="table" v-loading="crud.loading" :data="crud.data" size="small" style="width: 100%;" @selection-change="crud.selectionChangeHandler">
+        <el-table-column type="selection" width="55" />
+        <el-table-column :show-overflow-tooltip="true" prop="targetYear" label="目标年度">
+          <template slot-scope="scope">
+            {{ crud.toYear(scope.row.targetYear) }}
+          </template>
+        </el-table-column>
+        <el-table-column :show-overflow-tooltip="true" prop="projectDistinguish" label="项目区分">
+          <template slot-scope="scope">
+            {{ dict.label[projectDistinguish][scope.row.projectDistinguish] }}
+          </template>
+        </el-table-column>
+        <el-table-column :show-overflow-tooltip="true" prop="targetAmount" label="目标金额">
+          <template slot-scope="scope">
+            {{ crud.toMoney(scope.row.targetAmount) }}
+          </template>
+        </el-table-column>
+        <el-table-column :show-overflow-tooltip="true" prop="remarks" label="备注" />
+        <el-table-column :show-overflow-tooltip="true" prop="createTime" label="创建时间" />
+        <el-table-column v-if="checkPer(['admin','sysGoalSetting:edit','sysGoalSetting:del'])" label="操作" width="150px" align="center">
+          <template slot-scope="scope">
+            <udOperation
+              :data="scope.row"
+              :permission="permission"
+            />
+          </template>
+        </el-table-column>
+      </el-table>
+      <!--分页组件-->
+      <pagination />
+    </div>
+  </div>
+</template>
+
+<script>
+import crudSysGoalSetting from '@/api/system/goalSetting'
+import CRUD, { presenter, header, form, crud } from '@crud/crud'
+import rrOperation from '@crud/RR.operation'
+import crudOperation from '@crud/CRUD.operation'
+import udOperation from '@crud/UD.operation'
+import pagination from '@crud/Pagination'
+import constant from '../../../utils/constant'
+import moneyInput from '../../assembly/moneyInput/index.vue'
+
+const defaultForm = { id: null, targetYear: null, projectDistinguish: null, targetAmount: null, remarks: null, createBy: null, createTime: null, updateBy: null, updateTime: null }
+export default {
+  name: 'SysGoalSetting',
+  components: { pagination, crudOperation, rrOperation, udOperation, moneyInput },
+  mixins: [presenter(), header(), form(defaultForm), crud()],
+  dicts: [constant.PROJECT_DISTINGUISH],
+  cruds() {
+    return CRUD({ title: '目标管理', url: 'api/sysGoalSetting', idField: 'id', sort: 'id,desc', crudMethod: { ...crudSysGoalSetting }})
+  },
+  data() {
+    // 金额(十亿内)验证
+    var amountValidate = (rule, value, callback) => {
+      if (value != null && value !== '' && (isNaN(value) || Number(value) < 0 || Number(value) > 1000000000)) {
+        callback(new Error('请输入 十亿 以内的正整数或两位小数'))
+      } else {
+        callback()
+      }
+    }
+    return {
+      permission: {
+        add: ['admin', 'sysGoalSetting:add'],
+        edit: ['admin', 'sysGoalSetting:edit'],
+        del: ['admin', 'sysGoalSetting:del'],
+        download: ['admin', 'sysGoalSetting:download']
+      },
+      rules: {
+        targetYear: [
+          { required: true, message: '目标年度不能为空', trigger: 'change' }
+        ],
+        projectDistinguish: [
+          { required: true, message: '项目区分不能为空', trigger: 'change' }
+        ],
+        targetAmount: [
+          { required: true, message: '目标金额不能为空', trigger: 'blur' },
+          { validator: amountValidate, trigger: 'blur' }
+        ]
+      },
+      queryTypeOptions: [
+        { key: 'targetYear', display_name: '目标年度' },
+        { key: 'projectDistinguish', display_name: '项目区分' }
+      ],
+      // 字典:项目区分
+      projectDistinguish: constant.PROJECT_DISTINGUISH,
+      // 随机数
+      random: 0
+    }
+  },
+  methods: {
+    // 钩子:在获取表格数据之前执行,false 则代表不获取数据
+    [CRUD.HOOK.beforeRefresh]() {
+      return true
+    },
+    // 钩子: 开始 "新建/编辑" - 之前
+    [CRUD.HOOK.beforeToCU]() {
+      // 随机数
+      this.random = Math.random()
+    }
+  }
+}
+</script>
+
+<style scoped>
+
+</style>

--
Gitblit v1.9.3