瀏覽代碼

更新教职工工资

Administrator 1 年之前
父節點
當前提交
541aee6b07

+ 3 - 0
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/domain/pay/XiaoyuanPay.java

@@ -57,6 +57,9 @@ public class XiaoyuanPay extends TenantEntity {
      */
     private String payTime;
 
+    private String year;
+    private String month;
+
     /**
      * 备注
      */

+ 2 - 0
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/domain/pay/bo/XiaoyuanPayBo.java

@@ -59,6 +59,8 @@ public class XiaoyuanPayBo extends BaseEntity {
      * 发放时间
      */
     private String payTime;
+    private String year;
+    private String month;
 
 
     /**

+ 3 - 0
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/domain/pay/vo/XiaoyuanPayVo.java

@@ -70,6 +70,9 @@ public class XiaoyuanPayVo implements Serializable {
      */
     private String payTime;
 
+    private String year;
+    private String month;
+
     /**
      * 备注
      */

+ 5 - 0
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/listener/XiaoYuanPayUtil.java

@@ -54,6 +54,11 @@ public class XiaoYuanPayUtil {
                 throw new RuntimeException("表头不能缺少工号");
             }
             if (!excelHeadIdxNameMap.containsValue("发放时间")){
+                String faTime = excelHeadIdxNameMap.get("发放时间");
+                String[] split = faTime.split("-");
+                if (split.length < 1){
+                    throw new RuntimeException("发放时间格式需要是yyyy-MM");
+                }
                 throw new RuntimeException("表头不能缺少发放时间");
             }
             //封装数据体

+ 21 - 13
ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/service/impl/pay/XiaoyuanPayServiceImpl.java

@@ -44,7 +44,7 @@ public class XiaoyuanPayServiceImpl implements IXiaoyuanPayService {
      * 查询教职工工资条
      */
     @Override
-    public XiaoyuanPayVo queryById(Long payId){
+    public XiaoyuanPayVo queryById(Long payId) {
         return baseMapper.selectVoById(payId);
     }
 
@@ -61,10 +61,11 @@ public class XiaoyuanPayServiceImpl implements IXiaoyuanPayService {
         XiaoyuanPayVo vo = new XiaoyuanPayVo();
         List<XiaoyuanPayVo> records = result.getRecords();
         List<JSONObject> detailList = new ArrayList<>();
-        if (records!= null && records.size()> 0){
+        if (records != null && records.size() > 0) {
             for (XiaoyuanPayVo record : records) {
                 String tableDetail = record.getTableDetail();
-                Map<String, String> stringMap = mapStringToMap(tableDetail);
+                Map<String, Object> stringMap = mapStringToMap(tableDetail);
+                stringMap.put("payId", record.getPayId());
                 detailList.add(new JSONObject(stringMap));
             }
             //vo.setTableLabelJA(JSONUtil.parseArray(records.get(0).getTableHead()));
@@ -81,10 +82,10 @@ public class XiaoyuanPayServiceImpl implements IXiaoyuanPayService {
      * @param str Map字符串
      * @return Map
      */
-    public static Map<String,String> mapStringToMap(String str){
-        str = str.substring(1, str.length()-1);
+    public static Map<String, Object> mapStringToMap(String str) {
+        str = str.substring(1, str.length() - 1);
         String[] strs = str.split(",");
-        Map<String,String> map = new HashMap<String, String>();
+        Map<String, Object> map = new HashMap<String, Object>();
         for (String string : strs) {
             String key = string.split("=")[0];
             String value = string.split("=")[1];
@@ -143,7 +144,7 @@ public class XiaoyuanPayServiceImpl implements IXiaoyuanPayService {
     /**
      * 保存前的数据校验
      */
-    private void validEntityBeforeSave(XiaoyuanPay entity){
+    private void validEntityBeforeSave(XiaoyuanPay entity) {
         //TODO 做一些数据校验,如唯一约束
     }
 
@@ -152,7 +153,7 @@ public class XiaoyuanPayServiceImpl implements IXiaoyuanPayService {
      */
     @Override
     public Boolean deleteWithValidByIds(Collection<Long> ids, Boolean isValid) {
-        if(isValid){
+        if (isValid) {
             //TODO 做一些业务上的校验,判断是否需要校验
         }
         return baseMapper.deleteBatchIds(ids) > 0;
@@ -160,6 +161,7 @@ public class XiaoyuanPayServiceImpl implements IXiaoyuanPayService {
 
     /**
      * 教职工工资表导入数据
+     *
      * @param maps
      */
     @Override
@@ -169,9 +171,9 @@ public class XiaoyuanPayServiceImpl implements IXiaoyuanPayService {
         //工资条所需要的所有表头信息
         List<JSONObject> sysDictList = new ArrayList<>();
         for (SysDictDataVo sysDictDataVo : sysSubject) {
-            Map <String,Object> sysDictMap = new HashMap<>();
-            sysDictMap.put("label",sysDictDataVo.getDictLabel());
-            sysDictMap.put("prop",sysDictDataVo.getDictLabel());
+            Map<String, Object> sysDictMap = new HashMap<>();
+            sysDictMap.put("label", sysDictDataVo.getDictLabel());
+            sysDictMap.put("prop", sysDictDataVo.getDictLabel());
             sysDictList.add(new JSONObject(sysDictMap));
         }
         List<XiaoyuanPayBo> boList = new ArrayList<>();
@@ -180,13 +182,19 @@ public class XiaoyuanPayServiceImpl implements IXiaoyuanPayService {
             //组装数据
             bo.setTeacherName(map.get("姓名"));
             bo.setTeacherNum(map.get("工号"));
-            bo.setPayTime(map.get("发放时间"));
+            String faTime = map.get("发放时间");
+            String[] split = faTime.split("-");
+            if (split.length > 1) {
+                bo.setYear(split[0]);
+                bo.setMonth(split[1]);
+            }
+            bo.setPayTime(faTime);
             bo.setTableHead(sysDictList.toString());
             bo.setTableDetail(map.toString());
             bo.setCreateTime(DateUtils.getNowDate());
             boList.add(bo);
         }
-        baseMapper.insertBatch(MapstructUtils.convert(boList,XiaoyuanPay.class));
+        baseMapper.insertBatch(MapstructUtils.convert(boList, XiaoyuanPay.class));
     }
 
 }