Browse Source

feat: 党员评优评先导入

zhangying 2 weeks ago
parent
commit
ede51eec68

+ 27 - 0
src/main/java/com/ghsc/partybuild/controller/PartyTwoController.java

@@ -120,6 +120,33 @@ public class PartyTwoController {
         return result;
     }
 
+    @ResponseBody
+    @RequestMapping("/importDnpxxx")
+    public RequsetData<List<Map<String, Object>>> importUserInfo(@RequestBody Map<String, Object> reqMap) {
+        System.out.println(reqMap.get("dnpxxxList"));
+
+        RequsetData<List<Map<String, Object>>> res = new RequsetData<>();
+        List<Map<String, Object>> errorInfo = new ArrayList<>();
+        String message = "";
+        try {
+            List<Map<String, Object>> dataList = JsonMapper.jsonToObject(reqMap.get("dnpxxxList").toString(), new TypeReference<List<Map<String, Object>>>() {
+            });
+            partyTwoService.importDnpxxx(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;
+    }
+
     @RequestMapping(value = "/exportDnpxxx", method = RequestMethod.GET)
     public void exportDnpxxx(HttpServletResponse response,
                              @RequestParam(required = false) String dzzmc,

+ 1 - 1
src/main/java/com/ghsc/partybuild/mapper/PartyUserCQuery.java

@@ -279,7 +279,7 @@ public interface PartyUserCQuery {
 
     int deleteUser(@Param("userCode") String userCode);
 
-    HashMap<String, Object> selectPartyUserSingleExt(@Param("rybm") String rybm);
+    HashMap<String, Object> selectPartyUserSingleExt(@Param("rybm") String rybm, @Param("xm") String xm);
 
     Integer batchInsertUserPartyOfMonth(@Param("yearMonth") Integer yearMonth);
 

+ 3 - 0
src/main/java/com/ghsc/partybuild/service/PartyTwoService.java

@@ -114,4 +114,7 @@ public interface PartyTwoService {
     int deleteMzpyById(String id);
 
     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;
 }

+ 6 - 0
src/main/java/com/ghsc/partybuild/service/PartyUserService.java

@@ -90,6 +90,12 @@ public interface PartyUserService {
      */
     HashMap<String, Object> getPartyUserExt(String rybm);
 
+    /**
+     * 党员信息(包含入党申请人)
+     * @param xm 人员姓名
+     */
+    HashMap<String, Object> getPartyUserExtByName(String xm);
+
     /**
      * 查询人员党组织代码
      * @param rybm

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

@@ -84,6 +84,9 @@ public class PartyTwoServiceImpl implements PartyTwoService {
     @Autowired
     private PartyService partyService;
 
+    @Autowired
+    private com.ghsc.partybuild.util.StringUtils stringUtils;
+
     @Override
     public DjDnpxxx getDnpxxx(String id) {
         return dnpxxxMapper.selectByPrimaryKey(id);
@@ -909,4 +912,88 @@ public class PartyTwoServiceImpl implements PartyTwoService {
         PageInfo<HashMap<String, Object>> result = new PageInfo(list);
         return result;
     }
+
+    @Override
+    public List<Map<String, Object>> importDnpxxx(List<Map<String, Object>> dataList) throws Exception {
+        if (dataList.size() <= 0) {
+            throw new Exception("请添加导入数据");
+        }
+        List<Map<String, Object>> resultList = new ArrayList<>();
+        List<Map<String, Object>> errorList = new ArrayList<>();
+        List<CfDictionary> positionLevelList = dictionaryService.getDictionaryListByDicTypeKey("positionLevel");
+        List<CfDictionary> honourTypeList = dictionaryService.getDictionaryListByDicTypeKey("honourType");
+
+        for (int i = 0; i < dataList.size(); i++) {
+            String errorInfo = "";
+            Integer honourlevel = null;
+            Integer honourtype = null;
+            HashMap<String, Object> partyUserInfo = new HashMap<>();
+
+            int finalI = i;
+            if (stringUtils.IsNullOrEmpty((String) dataList.get(i).get("userName"))) {
+                errorInfo += "请填写党员姓名!";
+            } else {
+                partyUserInfo = partyUserService.getPartyUserExtByName((String) dataList.get(i).get("userName")); // 按名字查询出党员信息
+                if (partyUserInfo == null || partyUserInfo.isEmpty()) {
+                    errorInfo += "该党员不存在!";
+                }
+            }
+            if (stringUtils.IsNullOrEmpty((String) dataList.get(i).get("honourname"))) {
+                errorInfo += "请填写荣誉名称!";
+            }
+            if (stringUtils.IsNullOrEmpty((String) dataList.get(i).get("honourlevel"))) {
+                errorInfo += "请填写荣誉等级!";
+            } else {
+                honourlevel = positionLevelList.stream().filter(it -> it.getDicvalue().equals(dataList.get(finalI).get("honourlevel"))).findFirst().orElse(new CfDictionary()).getDickey();
+                if (honourlevel == null) {
+                    errorInfo += "荣誉等级不存在!";
+                }
+            }
+            if (stringUtils.IsNullOrEmpty((String) dataList.get(i).get("honourtime"))) {
+                errorInfo += "请填写获得荣誉时间!";
+            }
+            if (stringUtils.IsNullOrEmpty((String) dataList.get(i).get("honourtype"))) {
+                errorInfo += "请填写荣誉类型!";
+            } else {
+                honourtype = honourTypeList.stream().filter(it -> it.getDicvalue().equals(dataList.get(finalI).get("honourtype"))).findFirst().orElse(new CfDictionary()).getDickey();
+                if (honourtype == null) {
+                    errorInfo += "荣誉等级不存在!";
+                }
+            }
+
+            if (stringUtils.IsNullOrEmpty(errorInfo)) {
+                // 处理数据
+                // 创建实体类
+                DjDnpxxx model = new DjDnpxxx();
+                model.setId(UUID.randomUUID().toString());
+                model.setDzzdm((String) partyUserInfo.get("DZZDM"));
+                model.setDzzmc((String) partyUserInfo.get("DZZMC"));
+                model.setHonourlevel(honourlevel);
+                model.setHonourtype(honourtype);
+                model.setHonourname((String) dataList.get(i).get("honourname"));
+                model.setHonourtime(dateUtils.strToDateExt((String) dataList.get(i).get("honourtime")));
+                model.setPxlx("1");
+
+                UserItemVo userItem = new UserItemVo();
+                userItem.setRybm((String) partyUserInfo.get("RYBM"));
+                userItem.setXm((String) partyUserInfo.get("XM"));
+                UserItemVo[] vos = new UserItemVo[]{userItem};
+
+                Map<String, Object> result = new HashMap<>();
+                result.put("model", model);
+                result.put("userItemVo", vos);
+                resultList.add(result);
+            } else {
+                dataList.get(i).put("errorInfo", errorInfo);
+                errorList.add(dataList.get(i));
+            }
+        }
+
+        if (errorList.isEmpty()) {
+            resultList.forEach(item -> {
+                RequsetData<String> stringRequsetData = saveDnpxxx((DjDnpxxx) item.get("model"), (UserItemVo[]) item.get("userItemVo"));
+            });
+        }
+        return errorList;
+    }
 }

+ 15 - 1
src/main/java/com/ghsc/partybuild/service/impl/PartyUserServiceImpl.java

@@ -194,7 +194,21 @@ public class PartyUserServiceImpl implements PartyUserService {
     public HashMap<String, Object> getPartyUserExt(String rybm) {
         HashMap<String, Object> result = new HashMap<>();
         if (!stringUtils.IsNullOrEmpty(rybm)) {
-            result = partyUserCquery.selectPartyUserSingleExt(rybm);
+            result = partyUserCquery.selectPartyUserSingleExt(rybm, null);
+        }
+        return result;
+    }
+
+    /**
+     * 党员信息(包含入党申请人)
+     *
+     * @param xm 人员姓名
+     */
+    @Override
+    public HashMap<String, Object> getPartyUserExtByName(String xm) {
+        HashMap<String, Object> result = new HashMap<>();
+        if (!stringUtils.IsNullOrEmpty(xm)) {
+            result = partyUserCquery.selectPartyUserSingleExt(null, xm);
         }
         return result;
     }

+ 7 - 4
src/main/resources/application.yml

@@ -3,10 +3,10 @@ server:
   tomcat:
     max-connections: 100000
 spring:
-  profiles:
-    include: user
-    #resources:
-    #static-locations: file:F:/IDEA/demo/schoolparty_mysql/src/main/resources/static/
+#  profiles:
+#    include: user
+  resources:
+    static-locations: file:D:\Code\Project\WSZYDangJian\GHSCPartyBuild\src\main\resources\static\
   datasource:
     name: party_build_db
     type: com.alibaba.druid.pool.DruidDataSource
@@ -67,6 +67,9 @@ spring:
   mvc:
     async:
       request-timeout: 300000
+    view:
+      prefix: /app/main/
+      suffix: .html
 
 logging:
   config: classpath:logback-spring.xml

+ 8 - 2
src/main/resources/mapping/PartyUserCQuery.xml

@@ -425,7 +425,7 @@
         select us.USERTYPE,us.RYJBXXBS,us.RYBM,us.XM,us.SZDZBDM,us.RYZT,us.SQRDRQ,
         uszw.dnzw as ZWMC,
         us.DNZWMC,us.XJSZWMC,us.XB,us.JG,us.MZ,us.CSRQ,us.XL,us.SFZH,
-        p.DZZMC,
+        p.DZZMC, p.DZZDM,
         ryzt.HZMC as RYZTMC,
         xb.HZMC as XBMC,mz.HZMC as MZMC,xl.HZMC as XLMC,jszw.HZMC as JSZWMC,
         userinfo.USERNAME as MOBILE,us.DNZWMC as POST,
@@ -450,7 +450,13 @@
         left join vw_partyduty uszw on us.RYBM=uszw.RYBM -- 党内职务名称
         left join ZZ_ZZQKXX dw on SUBSTR(p.DZZDM,1,12)=dw.DZZDM
         left join VM_PARTYGROUP partyGroup on dw.DZZDM = partyGroup.DZZDM
-        where 1=1 and us.RYBM = #{rybm}
+        where 1=1
+            <if test="rybm != null and rybm != ''">
+                and us.RYBM = #{rybm}
+            </if>
+            <if test="xm != null and xm != ''">
+                and us.XM = #{xm}
+            </if>
     </select>
 
     <!--党小组成员信息(已取消)-->

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

@@ -140,6 +140,9 @@
                             <button class="btn btn-default1" role-permission-code="dnpxxx.btn.btnAdd"
                                     ng-click="add()">新增
                             </button>
+                            <button class="btn btn-default1" ng-if="selectparams.pxlx==1"
+                                    ng-click="import()">导入
+                            </button>
                         </div>
                     </div>
                 </div>

+ 55 - 1
src/main/resources/static/app/main/partyTwoExt/dnpxxx/list.js

@@ -1,5 +1,5 @@
 (function ($app) {
-    $app.module('gtPartyApp').controller('dnpxxxCtrl', function ($scope, $http, $modal, $ocLazyLoad, $timeout, $alert, $loading, $state, AuthUser, $stateParams, $bsRouterState) {
+    $app.module('gtPartyApp').controller('dnpxxxCtrl', function ($scope, $http, $modal, $ocLazyLoad, $timeout, $alert, $loading, $state, AuthUser, $stateParams, $bsRouterState, $excel) {
         $state.params = $bsRouterState.$params($scope);
         $scope.isShow = false;
         $scope.moreTxt = "更多";
@@ -173,6 +173,60 @@
             }
         };
 
+        // 导入参数设置
+        $scope.excelDnpxxxConfig = {
+            filetype: 1,
+            columns: {
+                '姓名': 'userName',
+                '荣誉名称': 'honourname',
+                '等级': 'honourlevel',
+                '获得荣誉时间': 'honourtime',
+                '是否及时性表彰': 'iscommend',
+                '荣誉类型': 'honourtype',
+            },
+            errorcolumns: {
+                'userName': '姓名',
+                'honourname': '荣誉名称',
+                'honourlevel': '等级',
+                'honourtime': '获得荣誉时间',
+                'iscommend': '是否及时性表彰',
+                'honourtype': '荣誉类型',
+                '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/importDnpxxx",
+                    data: {
+                        dnpxxxList: 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