Ver código fonte

张丁 作业票统计不能导入重复数据

zhangding 3 anos atrás
pai
commit
d0775ff5af

+ 15 - 3
master/src/main/java/com/ruoyi/project/ehs/controller/TJobticketController.java

@@ -155,11 +155,15 @@ public class TJobticketController extends BaseController
     {
         ISysUserService sysUserService = (ISysUserService) SpringContextUtils.getBean("sysUserService");
         StringBuilder contentUserUnit=new StringBuilder();
+        int sameCount=0;
+        int nosanmeCount=0;
         List<SysDictData> book_user_unit = iSysDictTypeService.selectDictDataByType("book_user_unit");
+        //批量插入时 需要查询数据库是否有重复数据 若果有 就不新增
         for (int i = 0; i < dto.size(); i++) {
             TJobticket tJobticket=new TJobticket();
             TInvoiceWorkcontent tInvoiceWorkcontent=dto.get(i);
-            tJobticket.setDeptId(tInvoiceWorkcontent.getDeptId());
+            //部门应该是导入票数据来源的承包商的所属部门
+            tJobticket.setDeptId(tInvoiceWorkcontent.getBookingworkticket().getDeptId());
             tJobticket.setContent(tInvoiceWorkcontent.getBookingworkticket().getWorkArea()+tInvoiceWorkcontent.getWorkDescription());
             //byc 联系人 用户主管+用户单位
             if(tInvoiceWorkcontent.getBookingworkticket().getUserUnit()!=null){
@@ -190,10 +194,18 @@ public class TJobticketController extends BaseController
             tJobticket.setUserMg(tInvoiceWorkcontent.getBookingworkticket().getUserMg());
             tJobticket.setUserUnit(tInvoiceWorkcontent.getBookingworkticket().getUserUnit());
             tJobticket.setZypzt("10");
-            tJobticketService.insertTJobticket(tJobticket);
+            //先查询是否重复
+            int same=  tJobticketService.selectTJobticketSameData(tJobticket);
+            if(same>0){
+                sameCount++;
+            }else {
+                nosanmeCount++;
+                tJobticketService.insertTJobticket(tJobticket);
+            }
+
             contentUserUnit.delete(0, contentUserUnit.length());
         }
-        return AjaxResult.success();
+        return AjaxResult.success("成功导入"+nosanmeCount+"条数据,"+"未导入重复"+sameCount+"条数据!");
     }
 
     /**

+ 8 - 0
master/src/main/java/com/ruoyi/project/ehs/mapper/TJobticketMapper.java

@@ -65,4 +65,12 @@ public interface TJobticketMapper
     public int deleteTJobticketByIds(Long[] ids);
 
     List<DataEntity> selectFireData(Map param);
+
+    /**
+     * 查询是否重复记录数
+     *
+     * @param tJobticket
+     * @return 结果
+     */
+    int selectTJobticketSameData(TJobticket tJobticket);
 }

+ 8 - 0
master/src/main/java/com/ruoyi/project/ehs/service/ITJobticketService.java

@@ -58,4 +58,12 @@ public interface ITJobticketService
      * @return 结果
      */
     public int deleteTJobticketById(Long id);
+
+    /**
+     * 查询是否重复记录数
+     *
+     * @param tJobticket
+     * @return 结果
+     */
+     public int selectTJobticketSameData(TJobticket tJobticket);
 }

+ 11 - 0
master/src/main/java/com/ruoyi/project/ehs/service/impl/TJobticketServiceImpl.java

@@ -98,6 +98,17 @@ public class TJobticketServiceImpl implements ITJobticketService
         return tJobticketMapper.deleteTJobticketById(id);
     }
 
+    /**
+     * 查询是否重复记录数
+     *
+     * @param tJobticket
+     * @return 结果
+     */
+    @Override
+    public int selectTJobticketSameData(TJobticket tJobticket) {
+        return tJobticketMapper.selectTJobticketSameData(tJobticket);
+    }
+
     public void dealJobticket(XWPFDocument doc, XWPFParagraph paragraph, XWPFRun run) {
         run.setText("", 0);
         XmlCursor cursor = paragraph.getCTP().newCursor();

+ 13 - 0
master/src/main/resources/mybatis/ehs/TJobticketMapper.xml

@@ -80,6 +80,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         where id = #{id}
     </select>
 
+    <!-- 查询相同数据 sql-->
+    <select id="selectTJobticketSameData" parameterType="TJobticket" resultType ="java.lang.Integer">
+        select count(*) from t_jobticket  d <where>
+        <if test="xzkjxkzh != null  and xzkjxkzh != ''"> and xzkjxkzh = #{xzkjxkzh}</if>
+        <if test="mbzyxkzh != null  and mbzyxkzh != ''"> and mbzyxkzh = #{mbzyxkzh}</if>
+        <if test="gczyxkzh != null  and gczyxkzh != ''"> and gczyxkzh = #{gczyxkzh}</if>
+        <if test="whgzxkzh != null  and whgzxkzh != ''"> and whgzxkzh = #{whgzxkzh}</if>
+        <if test="dhzyxkzh != null  and dhzyxkzh != ''"> and dhzyxkzh = #{dhzyxkzh}</if>
+        and d.del_flag = 0
+        and  d.xpxp = '10'
+    </where>
+    </select>
+
     <insert id="insertTJobticket" parameterType="TJobticket">
         <selectKey keyProperty="id" resultType="long" order="BEFORE">
             SELECT seq_t_jobticket.NEXTVAL as id FROM DUAL

+ 1 - 1
ui/src/views/invoice/bookingworkticket/index.vue

@@ -675,7 +675,7 @@ export default {
         let putData=this.$refs.multipleTable.selection
 
         batchAddJobticket(putData).then(response => {
-       this.msgSuccess(this.$t('带入数据到工作票统计页面成功'));
+       this.msgSuccess(this.$t(response.msg));
       });
     },
     //根据用户单位 查询对应选择的用户主管  根据用户单位 字段 查找对应的多个主管 返回 Sysuser的集合(id,name)