|
@@ -13,6 +13,7 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
|
|
|
@Service
|
|
@@ -40,7 +41,8 @@ public class ItemGroupServiceImpl implements ItemGroupService {
|
|
|
}
|
|
|
return Result.ok("添加item组成功");
|
|
|
} else {
|
|
|
- ItemGroup itemGroup1 = itemGroupDao.getItemGroupById(itemGroup.getId());
|
|
|
+ Integer id = itemGroup.getId();
|
|
|
+ ItemGroup itemGroup1 = itemGroupDao.getItemGroupById(id);
|
|
|
if (itemGroup1.getRunState() == ConstantStr.START_UP) {
|
|
|
return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), "此item组现在处于运行中,不允许修改");
|
|
|
}
|
|
@@ -51,7 +53,36 @@ public class ItemGroupServiceImpl implements ItemGroupService {
|
|
|
if (itemGroupDao.updateItemGroup(itemGroup) <= 0) {
|
|
|
return Result.no(ResultEnum.SERVER_ERROR.getRespCode(), "修改item组失败");
|
|
|
}
|
|
|
-// List<Item> itemList = itemGroup.getItemList();
|
|
|
+ List<Item> itemList = itemGroup.getItemList();
|
|
|
+ if (Blank.isEmpty(itemList)) {
|
|
|
+ itemGroupDao.delItemByGroupId(id);
|
|
|
+ return Result.ok("修改item组成功");
|
|
|
+ }
|
|
|
+ List<Item> oldItemList = itemGroupDao.getItemList(id);
|
|
|
+ if (Blank.isEmpty(oldItemList)) {
|
|
|
+ itemGroupDao.addItem(id, itemList);
|
|
|
+ return Result.ok("修改item组成功");
|
|
|
+ }
|
|
|
+ List<Item> publicItemList = itemGroupDao.getPublicItemList(id, itemList);
|
|
|
+ if (Blank.isEmpty(publicItemList)) {
|
|
|
+ itemGroupDao.delItemByGroupId(id);
|
|
|
+ itemGroupDao.addItem(id, itemList);
|
|
|
+ return Result.ok("修改item组成功");
|
|
|
+ }
|
|
|
+ itemGroupDao.delItemNoPub(id, publicItemList);
|
|
|
+ List<Item> addItemList = new ArrayList<>();
|
|
|
+ for (int i = 0; i < itemList.size(); i++) {
|
|
|
+ Boolean flage = true;
|
|
|
+ for (int j = 0; j < publicItemList.size(); j++) {
|
|
|
+ if (itemList.get(i).getItemGroupId().equals(publicItemList.get(j).getItemName())) {
|
|
|
+ flage = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (flage) {
|
|
|
+ addItemList.add(itemList.get(i));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ itemGroupDao.addItem(id, addItemList);
|
|
|
return Result.ok("修改item组成功");
|
|
|
}
|
|
|
}
|