Browse Source

feat: 民主评议导入

zhangying 2 weeks ago
parent
commit
42ba428fc2

+ 26 - 3
src/main/java/com/ghsc/partybuild/controller/PartyTwoController.java

@@ -122,9 +122,7 @@ public class PartyTwoController {
 
     @ResponseBody
     @RequestMapping("/importDnpxxx")
-    public RequsetData<List<Map<String, Object>>> importUserInfo(@RequestBody Map<String, Object> reqMap) {
-        System.out.println(reqMap.get("dnpxxxList"));
-
+    public RequsetData<List<Map<String, Object>>> importDnpxxx(@RequestBody Map<String, Object> reqMap) {
         RequsetData<List<Map<String, Object>>> res = new RequsetData<>();
         List<Map<String, Object>> errorInfo = new ArrayList<>();
         String message = "";
@@ -1316,6 +1314,31 @@ public class PartyTwoController {
         return result;
     }
 
+    @ResponseBody
+    @RequestMapping("/importMzpy")
+    public RequsetData<List<Map<String, Object>>> importMzpy(@RequestBody Map<String, Object> reqMap) {
+        RequsetData<List<Map<String, Object>>> res = new RequsetData<>();
+        List<Map<String, Object>> errorInfo = new ArrayList<>();
+        String message = "";
+        try {
+            List<ZzMzpyxxVo> dataList = JsonMapper.jsonToObject(reqMap.get("mzpyList").toString(), new TypeReference<List<ZzMzpyxxVo>>() {
+            });
+            partyTwoService.importMzpy(dataList);
+        } catch (Exception e) {
+            e.printStackTrace();
+            message = e.toString();
+        }
+        if (errorInfo.size() <= 0 && stringUtils.IsNullOrEmpty(message)) {
+            res.setSuccess(true);
+            res.setMsg("操作成功!");
+        } else {
+            res.setSuccess(false);
+            res.setMsg("操作失败!" + message);
+            res.setItem(errorInfo);
+        }
+        return res;
+    }
+
     @ResponseBody
     @GetMapping("/getleaderUserList")
     public RequsetData<PageInfo<HashMap<String, Object>> > getleaderUserList(@RequestParam("pageindex") int pageIndex, @RequestParam("pagesize") int pageSize,@RequestParam(required = false) String username,@RequestParam(required = false) Integer usertype) {

+ 4 - 1
src/main/java/com/ghsc/partybuild/service/PartyTwoService.java

@@ -4,6 +4,7 @@ import com.github.pagehelper.PageInfo;
 import com.ghsc.partybuild.controller.jsonmodel.RequsetData;
 import com.ghsc.partybuild.model.*;
 import com.ghsc.partybuild.vo.*;
+import org.springframework.web.bind.annotation.RequestBody;
 
 import java.util.HashMap;
 import java.util.List;
@@ -114,9 +115,11 @@ public interface PartyTwoService {
     ZzMzpyxxVo getMzpyById(String id);
     int saveMzpy(ZzMzpyxxVo data);
     int deleteMzpyById(String id);
+    // 导入民主评议
+    List<ZzMzpyxxVo> importMzpy(List<ZzMzpyxxVo> dataList) throws Exception;
 
     PageInfo<HashMap<String, Object>> getleaderUserList(int page, int rows, String username, Integer usertype);
 
-    // 导入
+    // 导入党员评先
     List<Map<String, Object>> importDnpxxx(List<Map<String, Object>> dataList) throws Exception;
 }

+ 70 - 0
src/main/java/com/ghsc/partybuild/service/impl/PartyTwoServiceImpl.java

@@ -962,6 +962,76 @@ public class PartyTwoServiceImpl implements PartyTwoService {
         return zzMzpyxxMapper.deleteByExample(exp);
     }
 
+    @Override
+    public List<ZzMzpyxxVo> importMzpy(List<ZzMzpyxxVo> dataList) throws Exception {
+        if (dataList.size() <= 0) {
+            throw new Exception("请添加导入数据");
+        }
+        List<ZzMzpyxxVo> errorList = new ArrayList<>();
+        List<HashMap<String, Object>> mzpyjgList = getMzpyjgList(); // 民主评议结果字典
+        List<HashMap<String, Object>> mzpybhgclqkList = getMzpybhgclqkList(); // 民主评议不合格处理情况字典
+
+        for (int i = 0; i < dataList.size(); i++) {
+            String errorInfo = "";
+            HashMap<String, Object> pyjg = null;
+            HashMap<String, Object> pyjcqk = null;
+            HashMap<String, Object> partyUserInfo = new HashMap<>();
+
+            int finalI = i;
+            if (stringUtils.IsNullOrEmpty(dataList.get(i).getUserName())) {
+                errorInfo += "请填写党员姓名!";
+            } else {
+                partyUserInfo = partyUserService.getPartyUserExtByName(dataList.get(i).getUserName()); // 按名字查询出党员信息
+                if (partyUserInfo == null || partyUserInfo.isEmpty()) {
+                    errorInfo += "该党员不存在!";
+                }
+            }
+            if (stringUtils.IsNullOrEmpty(dataList.get(i).getKzpyrq())) {
+                errorInfo += "请填写评议开始日期!";
+            }
+            if (stringUtils.IsNullOrEmpty(dataList.get(i).getJspyrq())) {
+                errorInfo += "请填写评议结束日期!";
+            }
+            if (stringUtils.IsNullOrEmpty(dataList.get(i).getPyjg())) {
+                errorInfo += "请填写评议结果!";
+            } else {
+                pyjg = mzpyjgList.stream().filter(it -> it.get("HZMC").equals(dataList.get(finalI).getPyjg())).findFirst().orElse(null);
+                if (pyjg == null) {
+                    errorInfo += "评议结果不存在!";
+                } else {
+                    dataList.get(i).setPyjg((String) pyjg.get("BM"));
+                }
+            }
+            if (!stringUtils.IsNullOrEmpty(dataList.get(i).getPyjcqk())) {
+                pyjcqk = mzpybhgclqkList.stream().filter(it -> it.get("HZMC").equals(dataList.get(finalI).getPyjcqk())).findFirst().orElse(null);
+                if (pyjcqk == null) {
+                    errorInfo += "不合格处理情况不存在!";
+                } else {
+                    dataList.get(i).setPyjcqk((String) pyjcqk.get("BM"));
+                }
+            }
+
+            if (stringUtils.IsNullOrEmpty(errorInfo)) {
+                // 初始化数据
+                dataList.get(i).setRybm((String) partyUserInfo.get("RYBM"));
+                dataList.get(i).setSzdzbdm((String) partyUserInfo.get("SZDZBDM"));
+                dataList.get(i).setKzpyrq(dateUtils.strFormat_short(dataList.get(i).getKzpyrq()));
+                dataList.get(i).setJspyrq(dateUtils.strFormat_short(dataList.get(i).getJspyrq()));
+                dataList.get(i).setMzpyxxbs(UUID.randomUUID().toString());
+            } else {
+                dataList.get(i).setErrorInfo(errorInfo);
+                errorList.add(dataList.get(i));
+            }
+        }
+
+        if (errorList.isEmpty()) {
+            for (ZzMzpyxxVo zzMzpyxxVo : dataList) {
+                saveMzpy(zzMzpyxxVo);
+            }
+        }
+        return errorList;
+    }
+
     @Override
     public PageInfo<HashMap<String, Object>> getleaderUserList(int page, int rows, String username, Integer usertype) {
         PageHelper.startPage(page, rows);

+ 1 - 0
src/main/java/com/ghsc/partybuild/vo/ZzMzpyxxVo.java

@@ -7,4 +7,5 @@ import lombok.Data;
 public class ZzMzpyxxVo extends ZzMzpyxx {
     private String userName;
     private String partyName;
+    private String errorInfo;
 }

+ 3 - 0
src/main/resources/static/app/main/partyTwoExt/mzpyxx/list.html

@@ -126,6 +126,9 @@
                             <button class="btn  btn-default1"
                                     ng-click="edit()">新增
                             </button>
+                            <button class="btn btn-default1"
+                                    ng-click="import()">导入
+                            </button>
                             <button class="btn  btn-default1"
                                     ng-click="export()">导出
                             </button>

+ 53 - 1
src/main/resources/static/app/main/partyTwoExt/mzpyxx/list.js

@@ -1,5 +1,5 @@
 (function ($app) {
-    $app.module('gtPartyApp').controller('mzpyxxCtrl', function ($scope, $http, $modal, $ocLazyLoad, $timeout, $alert, $loading, $state, AuthUser, $stateParams, $bsRouterState) {
+    $app.module('gtPartyApp').controller('mzpyxxCtrl', function ($scope, $http, $modal, $ocLazyLoad, $timeout, $alert, $loading, $state, AuthUser, $stateParams, $bsRouterState, $excel) {
         $state.params = $bsRouterState.$params($scope);
         $scope.isShow = false;
         $scope.moreTxt = "更多";
@@ -162,6 +162,58 @@
             }
         };
 
+        // 导入参数设置
+        $scope.excelDnpxxxConfig = {
+            filetype: 1,
+            columns: {
+                '姓名': 'userName',
+                '评议开始日期': 'kzpyrq',
+                '评议结束日期': 'jspyrq',
+                '评议结果': 'pyjg',
+                '不合格处理情况': 'pyjcqk',
+            },
+            errorcolumns: {
+                'userName': '姓名',
+                'kzpyrq': '评议开始日期',
+                'jspyrq': '评议结束日期',
+                'pyjg': '评议结果',
+                'pyjcqk': '不合格处理情况',
+                'errorInfo': '错误信息'
+            },
+            readonly: false,
+            templateUrl: '/doc/template/党员民主评议导入模板.xlsx'
+        };
+
+        $scope.import = function () {
+            $excel.addFile($scope.excelDnpxxxConfig).then(function (items) {
+                $loading.show();
+                $http({
+                    method: "post",
+                    url: "../../api/partyTowExt/importMzpy",
+                    data: {
+                        mzpyList: JSON.stringify(items)
+                    }
+                }).then(function (result) {
+                    $loading.hide();
+                    if (result.data.success) {
+                        $scope.loadData();
+                        $scope.showMsg('成功', result.data.msg, 3);
+                    } else {
+                        if (result.data.item.length > 0) {
+                            $scope.showMsg('错误', '导入失败,存在错误数据,请修改后重新导入!', 20);
+                            $excel.showErrorInfo(result.data.item);
+                        } else {
+                            $scope.showMsg(result.data.msg);
+                        }
+                    }
+
+                }, function (resp) {
+                    $loading.hide();
+                    $scope.showMsg('错误', '服务器错误');
+                })
+            });
+        };
+
         $scope.export = function () {
             if ($scope.selectparams.dzzdm != "") {
                 var params = "?1=1";

BIN
src/main/resources/static/doc/template/党员民主评议导入模板.xlsx