|
|
@@ -7,6 +7,7 @@ import com.uas.platform.b2b.dao.ProductUsersDao;
|
|
|
import com.uas.platform.b2b.model.Product;
|
|
|
import com.uas.platform.b2b.model.ProductUsers;
|
|
|
import com.uas.platform.b2b.model.Role;
|
|
|
+import com.uas.platform.b2b.ps.ProductUtils;
|
|
|
import com.uas.platform.b2b.service.ProductUsersService;
|
|
|
import com.uas.platform.b2b.service.RoleService;
|
|
|
import com.uas.platform.b2b.support.SystemSession;
|
|
|
@@ -75,7 +76,7 @@ public class ProductUsersServiceImpl implements ProductUsersService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public ModelMap addNewProduct(Product prodInfo) {
|
|
|
+ public ModelMap addNewProduct(Product prodInfo) throws Exception {
|
|
|
ModelMap map = new ModelMap();
|
|
|
// 先查找以前的个人物料是否存在
|
|
|
Long enuu = SystemSession.getUser().getEnterprise().getUu();
|
|
|
@@ -92,6 +93,8 @@ public class ProductUsersServiceImpl implements ProductUsersService {
|
|
|
prod.setEnuu(enuu);
|
|
|
prod.setPrid(productList.get(0).getId());
|
|
|
prod.setUseruu(useruu);
|
|
|
+ // TODO 因为这里要求数据即存即用,从公共库同步过来可能会有延迟,暂时两边都存;之后要修改为只调用公共服务方法
|
|
|
+ ProductUtils.updateProductUsersOne(prod);
|
|
|
productUsersDao.save(prod);
|
|
|
logger.log("个人产品库增加产品", "关联:" + productList.get(0).getId());
|
|
|
map.put("success", "新增成功");
|
|
|
@@ -125,12 +128,16 @@ public class ProductUsersServiceImpl implements ProductUsersService {
|
|
|
prodInfo.setIsShow(Constant.NO);
|
|
|
prodInfo.setStandard(Constant.NO);
|
|
|
prodInfo.setErpDate(new Date());
|
|
|
+ // TODO 因为这里要求数据即存即用,从公共库同步过来可能会有延迟,暂时两边都存;之后要修改为只调用公共服务方法
|
|
|
+ ProductUtils.updateOne(prodInfo);
|
|
|
prodInfo = productDao.save(prodInfo);
|
|
|
ProductUsers prod = new ProductUsers();
|
|
|
prod.setDate(new Date());
|
|
|
prod.setEnuu(enuu);
|
|
|
prod.setPrid(prodInfo.getId());
|
|
|
prod.setUseruu(useruu);
|
|
|
+ // TODO 因为这里要求数据即存即用,从公共库同步过来可能会有延迟,暂时两边都存;之后要修改为只调用公共服务方法
|
|
|
+ ProductUtils.updateProductUsersOne(prod);
|
|
|
productUsersDao.save(prod);
|
|
|
logger.log("个人产品库增加产品", "关联:" + prodInfo.getId());
|
|
|
map.put("success", "新增成功");
|
|
|
@@ -142,12 +149,14 @@ public class ProductUsersServiceImpl implements ProductUsersService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void deleteById(Long id) {
|
|
|
+ public void deleteById(Long id) throws Exception {
|
|
|
+ // TODO 因为这里要求数据即存即用,从公共库同步过来可能会有延迟,暂时两边都存;之后要修改为只调用公共服务方法
|
|
|
+ ProductUtils.deleteProductUser(id);
|
|
|
productUsersDao.delete(id);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public ModelMap releaseByWorkbook(Workbook workbook) {
|
|
|
+ public ModelMap releaseByWorkbook(Workbook workbook) throws Exception {
|
|
|
ModelMap modelMap = new ModelMap();
|
|
|
List<ProductUsers> productUsers = new ArrayList<ProductUsers>();
|
|
|
List<String> alters = new ArrayList<String>();
|
|
|
@@ -269,6 +278,8 @@ public class ProductUsersServiceImpl implements ProductUsersService {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ // TODO 因为这里要求数据即存即用,从公共库同步过来可能会有延迟,暂时两边都存;之后要修改为只调用公共服务方法
|
|
|
+ ProductUtils.updateOne(product);
|
|
|
product = productDao.save(product);
|
|
|
prod.setDate(new Date());
|
|
|
prod.setEnuu(enuu);
|
|
|
@@ -290,6 +301,8 @@ public class ProductUsersServiceImpl implements ProductUsersService {
|
|
|
modelMap.put("total", total);
|
|
|
if (!CollectionUtils.isEmpty(productUsers)) {
|
|
|
try {
|
|
|
+ // TODO 因为这里要求数据即存即用,从公共库同步过来可能会有延迟,暂时两边都存;之后要修改为只调用公共服务方法
|
|
|
+ ProductUtils.updateProductUsersByBatch(productUsers);
|
|
|
productUsers = productUsersDao.save(productUsers);
|
|
|
modelMap.put("success", productUsers.size());
|
|
|
if(alters.size() > 0)
|
|
|
@@ -307,20 +320,22 @@ public class ProductUsersServiceImpl implements ProductUsersService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public ModelMap coverToUserProd(String ids) {
|
|
|
- ids.replace("["," ");
|
|
|
- ids.replace("]"," ");
|
|
|
- Integer count = productUsersDao.coverToUserProd(ids, SystemSession.getUser().getUserUU(), SystemSession.getUser().getEnterprise().getUu());
|
|
|
+ public ModelMap coverToUserProd(String ids) throws Exception {
|
|
|
+// ids.replace("["," ");
|
|
|
+// ids.replace("]"," ");
|
|
|
+// Integer count = productUsersDao.coverToUserProd(ids, SystemSession.getUser().getUserUU(), SystemSession.getUser().getEnterprise().getUu());
|
|
|
+ // 这里更换成调用公共服务接口
|
|
|
+ Integer count = ProductUtils.coverToUserProd(ids, SystemSession.getUser().getEnterprise().getUu(), SystemSession.getUser().getUserUU());
|
|
|
logger.log("我的产品库", "新增了我产品信息", "size:" + count);
|
|
|
return new ModelMap("count", count);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void coverToUserProd(Long id) {
|
|
|
+ public void coverToUserProd(Long id) throws Exception {
|
|
|
Long useruu = SystemSession.getUser().getUserUU();
|
|
|
Long enuu = SystemSession.getUser().getEnterprise().getUu();
|
|
|
- List<ProductUsers> prods = productUsersDao.findByEnuuAndUseruuAndAndPrid(enuu, useruu, id);
|
|
|
- if(CollectionUtils.isEmpty(prods)) {
|
|
|
+ ProductUsers productUsers = productUsersDao.findByEnuuAndUseruuAndPrid(enuu, useruu, id);
|
|
|
+ if(null == productUsers) {
|
|
|
Product product = productDao.findOne(id);
|
|
|
List<Role> roles = roleService.findByEnUUAndUserUU(enuu, useruu);
|
|
|
// 根据当前用户角色更新物料销售采购属性
|
|
|
@@ -329,11 +344,15 @@ public class ProductUsersServiceImpl implements ProductUsersService {
|
|
|
if(role.getDesc().equals("业务员") || role.getDesc().equals("销售经理")) {
|
|
|
if(product.getIsSale() == null || product.getIsSale().equals(Constant.NO)) {
|
|
|
product.setIsSale(Constant.YES);
|
|
|
+ // TODO 因为这里要求数据即存即用,从公共库同步过来可能会有延迟,暂时两边都存;之后要修改为只调用公共服务方法
|
|
|
+ ProductUtils.updateOne(product);
|
|
|
productDao.save(product);
|
|
|
}
|
|
|
} else if(role.getDesc().equals("采购员")) {
|
|
|
if(product.getIsPurchase() == null || product.getIsPurchase().equals(Constant.NO)) {
|
|
|
product.setIsPurchase(Constant.YES);
|
|
|
+ // TODO 因为这里要求数据即存即用,从公共库同步过来可能会有延迟,暂时两边都存;之后要修改为只调用公共服务方法
|
|
|
+ ProductUtils.updateOne(product);
|
|
|
productDao.save(product);
|
|
|
}
|
|
|
}
|
|
|
@@ -344,13 +363,17 @@ public class ProductUsersServiceImpl implements ProductUsersService {
|
|
|
prod.setEnuu(enuu);
|
|
|
prod.setPrid(id);
|
|
|
prod.setDate(new Date());
|
|
|
+ // TODO 因为这里要求数据即存即用,从公共库同步过来可能会有延迟,暂时两边都存;之后要修改为只调用公共服务方法
|
|
|
+ ProductUtils.updateProductUsersOne(prod);
|
|
|
prod = productUsersDao.save(prod);
|
|
|
logger.log("我的产品库", "新增了我产品信息", "id:" + prod.getId());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void deleteByBatch(List<Long> idList) {
|
|
|
+ public void deleteByBatch(List<Long> idList) throws Exception {
|
|
|
+ // TODO 因为这里要求数据即存即用,从公共库同步过来可能会有延迟,暂时两边都存;之后要修改为只调用公共服务方法
|
|
|
+ ProductUtils.deleteProductUserByBatch(idList);
|
|
|
List<ProductUsers> prods = productUsersDao.findAll(idList);
|
|
|
productUsersDao.delete(prods);
|
|
|
}
|
|
|
@@ -366,7 +389,15 @@ public class ProductUsersServiceImpl implements ProductUsersService {
|
|
|
|
|
|
@Override
|
|
|
public void run() {
|
|
|
- productUsersDao.coverToUserByPrid(productId, enuu, useruu);
|
|
|
+// productUsersDao.coverToUserByPrid(productId, enuu, useruu);
|
|
|
+ ProductUsers productUsers = productUsersDao.findByEnuuAndUseruuAndPrid(enuu, useruu, productId);
|
|
|
+ if (null == productUsers) {
|
|
|
+ try {
|
|
|
+ ProductUtils.coverToUserProd(String.valueOf(productId), enuu, useruu);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}).run();
|
|
|
}
|