LiGuang 3 年之前
父节点
当前提交
a36b8fa071

+ 8 - 3
jeecg-boot-module-demo/src/main/java/org/jeecg/modules/geke/shift/controller/ShiftController.java

@@ -132,7 +132,7 @@ public class ShiftController extends JeecgController<Shift, IShiftService> {
 	@ApiOperation(value="班次档案-通过id删除", notes="班次档案-通过id删除")
 	@DeleteMapping(value = "/delete")
 	public Result<?> delete(@RequestParam(name="id",required=true) String id) {
-		List<UserShift> userShifts = userShiftService.listByShiftId(id);
+		List<UserShift> userShifts = userShiftService.listByShiftId(Arrays.asList(id.split(",")));
 		if (userShifts!=null&&userShifts.size()>0){
 			return Result.error("删除失败,该班次已使用!");
 		}else {
@@ -151,8 +151,13 @@ public class ShiftController extends JeecgController<Shift, IShiftService> {
 	@ApiOperation(value="班次档案-批量删除", notes="班次档案-批量删除")
 	@DeleteMapping(value = "/deleteBatch")
 	public Result<?> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
-		this.shiftService.removeByIds(Arrays.asList(ids.split(",")));
-		return Result.OK("批量删除成功!");
+		List<UserShift> userShifts = userShiftService.listByShiftId(Arrays.asList(ids.split(",")));
+		if (userShifts!=null&&userShifts.size()>0){
+			return Result.error("删除失败,勾选数据中存在已使用的班次!");
+		}else {
+			this.shiftService.removeByIds(Arrays.asList(ids.split(",")));
+			return Result.OK("批量删除成功!");
+		}
 	}
 	
 	/**

+ 1 - 1
jeecg-boot-module-demo/src/main/java/org/jeecg/modules/geke/userShift/mapper/UserShiftMapper.java

@@ -53,7 +53,7 @@ public interface UserShiftMapper extends BaseMapper<UserShift> {
 
     List<String>uids(@Param("depts") List<String> depts);
 
-    List<UserShift>listByShiftId(@Param("shiftid")String shiftid);
+    List<UserShift>listByShiftId(@Param("shiftid")List<String> shiftid);
 
     //统计每月班次有多少次人员排班
    Map<String,Object>ShiftCount(@Param("id")String id,@Param("date")String date,@Param("deptids")List<String>deptids,@Param("realname")String realname,@Param("deptid")String deptid);

+ 5 - 2
jeecg-boot-module-demo/src/main/java/org/jeecg/modules/geke/userShift/mapper/xml/UserShiftMapper.xml

@@ -194,8 +194,11 @@ order by a.shift_date desc
         select a.*from geke_user_shift a
         left join sys_user b  on a.user_id=b.id
         where b.del_flag='0' and b.employment_status='10'
-        <if test="shiftid!=null and ''!=shiftid">
-            and a.shift_id=#{shiftid}
+        <if test="shiftid!=null and shiftid.size()>0">
+            and a.shift_id in
+            <foreach collection="shiftid" index="index" item="id" open="(" separator="," close=")">
+                #{id}
+            </foreach>
         </if>
     </select>
 </mapper>

+ 1 - 1
jeecg-boot-module-demo/src/main/java/org/jeecg/modules/geke/userShift/service/IUserShiftService.java

@@ -34,7 +34,7 @@ public interface IUserShiftService extends IService<UserShift> {
 
     public boolean addUserShifts(UserShift userShift);
 
-    List<UserShift>listByShiftId(String shiftid);
+    List<UserShift>listByShiftId(List<String> shiftid);
 
     List<Map<String,Object>> getMothUserShifts(String userid, String date);
 

+ 1 - 1
jeecg-boot-module-demo/src/main/java/org/jeecg/modules/geke/userShift/service/impl/UserShiftServiceImpl.java

@@ -119,7 +119,7 @@ public class UserShiftServiceImpl extends ServiceImpl<UserShiftMapper, UserShift
     }
 
     @Override
-    public List<UserShift> listByShiftId(String shiftid) {
+    public List<UserShift> listByShiftId(List<String> shiftid) {
         return userShiftMapper.listByShiftId(shiftid);
     }