|
|
@@ -601,7 +601,7 @@ public class ProductServiceImpl implements ProductService {
|
|
|
if (CollectionUtils.isEmpty(ids)) {
|
|
|
return new ResultMap(CodeType.NO_INFO, "没有传入有效信息");
|
|
|
}
|
|
|
- if (null != isPerson && isPerson.intValue() == IntegerConstant.YES_SHORT.intValue()) {
|
|
|
+ if (IntegerConstant.YES_SHORT.equals(isPerson)) {
|
|
|
String sql = "delete from product$users where pu_prid in (:ids) and pu_useruu = " + SystemSession.getUser().getUserUU();
|
|
|
Map<String, List<Long>> map = new HashedMap();
|
|
|
map.put("ids", ids);
|
|
|
@@ -679,27 +679,19 @@ public class ProductServiceImpl implements ProductService {
|
|
|
*/
|
|
|
@Override
|
|
|
public ResultMap deleteBatch(String type, Integer isPerson) {
|
|
|
- Integer standard;
|
|
|
+ //如果是删除个人物料
|
|
|
+ if (IntegerConstant.YES_SHORT.equals(isPerson)) {
|
|
|
+ ResultMap resultMap = deletePersonalProductByBatch(type);
|
|
|
+ return resultMap;
|
|
|
+ }
|
|
|
+ Integer standard = ProductConstant.STANDARD.equals(type) ? IntegerConstant.YES_SHORT : IntegerConstant.NO_SHORT;
|
|
|
List<ProductPerson> personList;
|
|
|
Integer fail = 0;
|
|
|
Integer success = 0;
|
|
|
Integer isHave = 0;
|
|
|
Long uu = SystemSession.getUser().getEnterprise().getUu();
|
|
|
- if (ProductConstant.STANDARD.equals(type)) {
|
|
|
- standard = IntegerConstant.YES_SHORT;
|
|
|
- } else {
|
|
|
- standard = IntegerConstant.NO_SHORT;
|
|
|
- }
|
|
|
List<Product> products = productDao.findProductByEnuuAndStandardAndEnabled(uu, standard, IntegerConstant.YES_SHORT);
|
|
|
for (Product product : products) {
|
|
|
- if (null != isPerson && isPerson.intValue() == IntegerConstant.YES_SHORT.intValue()) {
|
|
|
- List<ProductPerson> productPersonList = productPersonDao.findByProductIdAndUserUU(product.getId(),SystemSession.getUser().getUserUU());
|
|
|
- if (!CollectionUtils.isEmpty(productPersonList)) {
|
|
|
- Long ppid = productPersonList.get(0).getId();
|
|
|
- productPersonDao.delete(ppid);
|
|
|
- }
|
|
|
- continue;
|
|
|
- }
|
|
|
try {
|
|
|
personList = productPersonDao.findByProductId(product.getId());
|
|
|
if (CollectionUtils.isNotEmpty(personList)) {
|
|
|
@@ -773,6 +765,42 @@ public class ProductServiceImpl implements ProductService {
|
|
|
return new ResultMap(status, message);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 批量删除个人物料
|
|
|
+ *
|
|
|
+ * @param type
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public ResultMap deletePersonalProductByBatch(String type) {
|
|
|
+ Integer standard;
|
|
|
+ Integer success = 0;
|
|
|
+ Long uu = SystemSession.getUser().getEnterprise().getUu();
|
|
|
+ if (ProductConstant.STANDARD.equals(type)) {
|
|
|
+ standard = IntegerConstant.YES_SHORT;
|
|
|
+ } else {
|
|
|
+ standard = IntegerConstant.NO_SHORT;
|
|
|
+ }
|
|
|
+ List<Long> prids = productDao.findPridsByEnuuAndStardand(uu, standard);
|
|
|
+ List<Long> personPrIds = null;
|
|
|
+ if (CollectionUtils.isNotEmpty(prids)) {
|
|
|
+ personPrIds = productPersonDao.findIdsInProductPerson(prids, SystemSession.getUser().getUserUU());
|
|
|
+ if (CollectionUtils.isNotEmpty(personPrIds)) {
|
|
|
+ success = personPrIds.size();
|
|
|
+ String ids = StringUtilB2C.joinListUseContact(personPrIds, SplitChar.COMMA);
|
|
|
+ jdbcTemplate.update("delete from product$users where pu_id in (" + ids +")");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ String message = "";
|
|
|
+ if (IntegerConstant.NO_SHORT.equals(success)) {
|
|
|
+ message = "没有需要删除的信息";
|
|
|
+ } else {
|
|
|
+ message = "成功删除" + success + "条";
|
|
|
+ }
|
|
|
+ return new ResultMap(CodeType.OK, message);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
@Override
|
|
|
public Product match(Long id) {
|
|
|
Product product = productDao.findOne(id);
|