|
|
@@ -85,886 +85,886 @@ import java.util.Set;
|
|
|
@Service
|
|
|
public class PurcInquiryServiceImpl implements PurcInquiryService {
|
|
|
|
|
|
- private final static UsageBufferedLogger logger = BufferedLoggerManager.getLogger(UsageBufferedLogger.class);
|
|
|
+ private final static UsageBufferedLogger logger = BufferedLoggerManager.getLogger(UsageBufferedLogger.class);
|
|
|
|
|
|
- /**
|
|
|
- * 应用来源
|
|
|
- */
|
|
|
- private final String SOURCERAPP = "B2B";
|
|
|
+ /**
|
|
|
+ * 应用来源
|
|
|
+ */
|
|
|
+ private final String SOURCERAPP = "B2B";
|
|
|
|
|
|
- /**
|
|
|
- * 币别
|
|
|
- */
|
|
|
- private final String RMB = "RMB";
|
|
|
+ /**
|
|
|
+ * 币别
|
|
|
+ */
|
|
|
+ private final String RMB = "RMB";
|
|
|
|
|
|
- /**
|
|
|
- * 询价种类
|
|
|
- */
|
|
|
- private final String INQUIRYKIND = "publicInquiry";
|
|
|
+ /**
|
|
|
+ * 询价种类
|
|
|
+ */
|
|
|
+ private final String INQUIRYKIND = "publicInquiry";
|
|
|
|
|
|
- @Autowired
|
|
|
- private EnterpriseDao enterpriseDao;
|
|
|
+ @Autowired
|
|
|
+ private EnterpriseDao enterpriseDao;
|
|
|
|
|
|
- @Autowired
|
|
|
- private PurcInquiryItemDao purcInquiryItemDao;
|
|
|
+ @Autowired
|
|
|
+ private PurcInquiryItemDao purcInquiryItemDao;
|
|
|
|
|
|
- @Autowired
|
|
|
- private PurcInquiryDao inquiryDao;
|
|
|
+ @Autowired
|
|
|
+ private PurcInquiryDao inquiryDao;
|
|
|
|
|
|
- @Autowired
|
|
|
- private ProductDao productDao;
|
|
|
+ @Autowired
|
|
|
+ private ProductDao productDao;
|
|
|
|
|
|
- @Autowired
|
|
|
- private PurchaseInquiryItemDao purchaseInquiryItemDao;
|
|
|
+ @Autowired
|
|
|
+ private PurchaseInquiryItemDao purchaseInquiryItemDao;
|
|
|
|
|
|
- @Autowired
|
|
|
- private PurchaseInquiryDao purchaseInquiryDao;
|
|
|
+ @Autowired
|
|
|
+ private PurchaseInquiryDao purchaseInquiryDao;
|
|
|
|
|
|
- @Autowired
|
|
|
- private PurcInquiryItemInfoDao purcInquiryItemInfoDao;
|
|
|
+ @Autowired
|
|
|
+ private PurcInquiryItemInfoDao purcInquiryItemInfoDao;
|
|
|
|
|
|
- @Autowired
|
|
|
- private PurchaseInquiryInfoDao purchaseInquiryInfoDao;
|
|
|
+ @Autowired
|
|
|
+ private PurchaseInquiryInfoDao purchaseInquiryInfoDao;
|
|
|
|
|
|
- @Autowired
|
|
|
- private CommonDao commonDao;
|
|
|
+ @Autowired
|
|
|
+ private CommonDao commonDao;
|
|
|
|
|
|
- @Autowired
|
|
|
- private JdbcTemplate jdbcTemplate;
|
|
|
+ @Autowired
|
|
|
+ private JdbcTemplate jdbcTemplate;
|
|
|
|
|
|
- @Autowired
|
|
|
- private PurchaseInquiryReplyDao purchaseInquiryReplyDao;
|
|
|
+ @Autowired
|
|
|
+ private PurchaseInquiryReplyDao purchaseInquiryReplyDao;
|
|
|
|
|
|
- @Autowired
|
|
|
- private AttachService attachService;
|
|
|
+ @Autowired
|
|
|
+ private AttachService attachService;
|
|
|
|
|
|
- @Autowired
|
|
|
- private RoleDao roleDao;
|
|
|
+ @Autowired
|
|
|
+ private RoleDao roleDao;
|
|
|
|
|
|
- @Autowired
|
|
|
- private UserDao userDao;
|
|
|
+ @Autowired
|
|
|
+ private UserDao userDao;
|
|
|
|
|
|
- @Autowired
|
|
|
- private VendorDao vendorDao;
|
|
|
+ @Autowired
|
|
|
+ private VendorDao vendorDao;
|
|
|
|
|
|
- @Autowired
|
|
|
- private DistributeDao distributeDao;
|
|
|
+ @Autowired
|
|
|
+ private DistributeDao distributeDao;
|
|
|
|
|
|
- @Autowired
|
|
|
- private UserOrderDao userOrderDao;
|
|
|
+ @Autowired
|
|
|
+ private UserOrderDao userOrderDao;
|
|
|
|
|
|
- @Autowired
|
|
|
+ @Autowired
|
|
|
private RoleService roleService;
|
|
|
|
|
|
- @Autowired
|
|
|
- private PublicInquiryItemDao publicInquiryItemDao;
|
|
|
+ @Autowired
|
|
|
+ private PublicInquiryItemDao publicInquiryItemDao;
|
|
|
|
|
|
- @Autowired
|
|
|
+ @Autowired
|
|
|
private PublicInquiryDao publicInquiryDao;
|
|
|
|
|
|
- @Override
|
|
|
- public ModelMap save(PurcInquiryInfo inquiryInfo, List<VendorAndContact> contacts, FileUpload uploadItem) throws Exception {
|
|
|
- ModelMap map = new ModelMap();
|
|
|
- PurcInquiry old = inquiryDao.findByCode(inquiryInfo.getCode());
|
|
|
- if (old == null) { // 判断是否存在,防止重复
|
|
|
- Long enuu = SystemSession.getUser().getEnterprise().getUu();
|
|
|
- Long useruu = SystemSession.getUser().getUserUU();
|
|
|
- PurcInquiry inquiry = new PurcInquiry();
|
|
|
- Set<Attach> attachs = new HashSet<Attach>();
|
|
|
- if (uploadItem.getFile() != null) {// 附件存在
|
|
|
- Attach attach = attachService.upload(uploadItem, "productAttach", "平台客户上传物料照片或附件");
|
|
|
- if (attach == null) {
|
|
|
- map.put("error", "文件太大");
|
|
|
- } else {
|
|
|
- attachs.add(attach);
|
|
|
- inquiry.setAttachs(attachs);
|
|
|
- }
|
|
|
- }
|
|
|
- // 先判断供应商是否存在
|
|
|
- if (!CollectionUtils.isEmpty(contacts)) {
|
|
|
- if (inquiry.getId() == null) {// 新增
|
|
|
- inquiry.setDate(new Date());
|
|
|
- inquiry.setCode(inquiryInfo.getCode());
|
|
|
- inquiry.setEnUU(enuu);
|
|
|
- inquiry.setCode(inquiryInfo.getCode());
|
|
|
- inquiry.setEndDate(inquiryInfo.getEndDate());
|
|
|
- inquiry.setRemark(inquiryInfo.getRemark());
|
|
|
- inquiry.setEnvironment(inquiryInfo.getEnvironment());
|
|
|
- inquiry.setEnterprise(enterpriseDao.findEnterpriseInfoByUu(enuu));
|
|
|
- inquiry.setRecorder(SystemSession.getUser().getUserName());
|
|
|
- inquiry.setRecorderUU(SystemSession.getUser().getUserUU());
|
|
|
- inquiry.setEnteryStatus(Status.UNAPPLY.value());
|
|
|
- inquiry.setPriceType(inquiryInfo.getPriceType());
|
|
|
- inquiry.setIsOpen((short) inquiryInfo.getIsOpen());
|
|
|
- inquiry.setInvoice(inquiryInfo.getInvoice());
|
|
|
- inquiry.setShip(inquiryInfo.getShip());
|
|
|
- inquiry.setCurrency(inquiryInfo.getCurrency());
|
|
|
- inquiry.setIfTax(inquiryInfo.getIfTax());
|
|
|
- inquiry.setInquirytype(inquiryInfo.getInquirytype());
|
|
|
- Set<PurcInquiryItem> items = new HashSet<PurcInquiryItem>();
|
|
|
- Short i = 1;
|
|
|
- for (VendorAndContact contact : contacts) {
|
|
|
- if (!CollectionUtils.isEmpty(inquiryInfo.getInquiryItems())) {
|
|
|
- for (PurcInquiryItem purcitem : inquiryInfo.getInquiryItems()) {
|
|
|
- PurcInquiryItem item = new PurcInquiryItem();
|
|
|
- Product product = new Product();
|
|
|
- Enterprise vendorEn = enterpriseDao.findEnterpriseByUu(contact.getEnuu());
|
|
|
- if (purcitem.getProductId() != null) {// 点击选择出来的,一般带有id
|
|
|
- product = productDao.findOne(purcitem.getProductId());
|
|
|
- item.setProduct(product);
|
|
|
- item.setProductId(product.getId());
|
|
|
- } else {// 导入或手动输入的一般不带有id
|
|
|
- List<Product> products = productDao.findByEnUUAndCode(
|
|
|
- SystemSession.getUser().getEnterprise().getUu(), purcitem.getProdCode());
|
|
|
- if (products.size() > 0) {
|
|
|
- product = products.get(0);
|
|
|
- }
|
|
|
- if (product.getId() != null) {// 存在直接选择
|
|
|
- item.setProduct(product);
|
|
|
- item.setProductId(product.getId());
|
|
|
- } else { // 不存在,插入物料
|
|
|
- product = new Product();
|
|
|
- product.setBrand(purcitem.getInbrand());
|
|
|
- product.setCmpCode(purcitem.getCmpCode());
|
|
|
- product.setSourceApp(SOURCERAPP);
|
|
|
- product.setCode(purcitem.getProdCode());
|
|
|
- product.setEnUU(SystemSession.getUser().getEnterprise().getUu());
|
|
|
- product.setTitle(purcitem.getProdTitle());
|
|
|
- product.setCmpUuId(purcitem.getProdCode());
|
|
|
- product.setUnit(purcitem.getUnit());
|
|
|
- product.setUserUU(SystemSession.getUser().getUserUU());
|
|
|
+ @Override
|
|
|
+ public ModelMap save(PurcInquiryInfo inquiryInfo, List<VendorAndContact> contacts, FileUpload uploadItem) throws Exception {
|
|
|
+ ModelMap map = new ModelMap();
|
|
|
+ PurcInquiry old = inquiryDao.findByCode(inquiryInfo.getCode());
|
|
|
+ if (old == null) { // 判断是否存在,防止重复
|
|
|
+ Long enuu = SystemSession.getUser().getEnterprise().getUu();
|
|
|
+ Long useruu = SystemSession.getUser().getUserUU();
|
|
|
+ PurcInquiry inquiry = new PurcInquiry();
|
|
|
+ Set<Attach> attachs = new HashSet<Attach>();
|
|
|
+ if (uploadItem.getFile() != null) {// 附件存在
|
|
|
+ Attach attach = attachService.upload(uploadItem, "productAttach", "平台客户上传物料照片或附件");
|
|
|
+ if (attach == null) {
|
|
|
+ map.put("error", "文件太大");
|
|
|
+ } else {
|
|
|
+ attachs.add(attach);
|
|
|
+ inquiry.setAttachs(attachs);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 先判断供应商是否存在
|
|
|
+ if (!CollectionUtils.isEmpty(contacts)) {
|
|
|
+ if (inquiry.getId() == null) {// 新增
|
|
|
+ inquiry.setDate(new Date());
|
|
|
+ inquiry.setCode(inquiryInfo.getCode());
|
|
|
+ inquiry.setEnUU(enuu);
|
|
|
+ inquiry.setCode(inquiryInfo.getCode());
|
|
|
+ inquiry.setEndDate(inquiryInfo.getEndDate());
|
|
|
+ inquiry.setRemark(inquiryInfo.getRemark());
|
|
|
+ inquiry.setEnvironment(inquiryInfo.getEnvironment());
|
|
|
+ inquiry.setEnterprise(enterpriseDao.findEnterpriseInfoByUu(enuu));
|
|
|
+ inquiry.setRecorder(SystemSession.getUser().getUserName());
|
|
|
+ inquiry.setRecorderUU(SystemSession.getUser().getUserUU());
|
|
|
+ inquiry.setEnteryStatus(Status.UNAPPLY.value());
|
|
|
+ inquiry.setPriceType(inquiryInfo.getPriceType());
|
|
|
+ inquiry.setIsOpen(Constant.NO);
|
|
|
+ inquiry.setInvoice(inquiryInfo.getInvoice());
|
|
|
+ inquiry.setShip(inquiryInfo.getShip());
|
|
|
+ inquiry.setCurrency(inquiryInfo.getCurrency());
|
|
|
+ inquiry.setIfTax(inquiryInfo.getIfTax());
|
|
|
+ inquiry.setInquirytype(inquiryInfo.getInquirytype());
|
|
|
+ Set<PurcInquiryItem> items = new HashSet<PurcInquiryItem>();
|
|
|
+ Short i = 1;
|
|
|
+ for (VendorAndContact contact : contacts) {
|
|
|
+ if (!CollectionUtils.isEmpty(inquiryInfo.getInquiryItems())) {
|
|
|
+ for (PurcInquiryItem purcitem : inquiryInfo.getInquiryItems()) {
|
|
|
+ PurcInquiryItem item = new PurcInquiryItem();
|
|
|
+ Product product = new Product();
|
|
|
+ Enterprise vendorEn = enterpriseDao.findEnterpriseByUu(contact.getEnuu());
|
|
|
+ if (purcitem.getProductId() != null) {// 点击选择出来的,一般带有id
|
|
|
+ product = productDao.findOne(purcitem.getProductId());
|
|
|
+ item.setProduct(product);
|
|
|
+ item.setProductId(product.getId());
|
|
|
+ } else {// 导入或手动输入的一般不带有id
|
|
|
+ List<Product> products = productDao.findByEnUUAndCode(
|
|
|
+ SystemSession.getUser().getEnterprise().getUu(), purcitem.getProdCode());
|
|
|
+ if (products.size() > 0) {
|
|
|
+ product = products.get(0);
|
|
|
+ }
|
|
|
+ if (product.getId() != null) {// 存在直接选择
|
|
|
+ item.setProduct(product);
|
|
|
+ item.setProductId(product.getId());
|
|
|
+ } else { // 不存在,插入物料
|
|
|
+ product = new Product();
|
|
|
+ product.setBrand(purcitem.getInbrand());
|
|
|
+ product.setCmpCode(purcitem.getCmpCode());
|
|
|
+ product.setSourceApp(SOURCERAPP);
|
|
|
+ product.setCode(purcitem.getProdCode());
|
|
|
+ product.setEnUU(SystemSession.getUser().getEnterprise().getUu());
|
|
|
+ product.setTitle(purcitem.getProdTitle());
|
|
|
+ product.setCmpUuId(purcitem.getProdCode());
|
|
|
+ product.setUnit(purcitem.getUnit());
|
|
|
+ product.setUserUU(SystemSession.getUser().getUserUU());
|
|
|
// product.setShipAddr(SystemSession.getUser().getEnterprise().getEnAddress());
|
|
|
- // 导入的物料这里没有填写规格
|
|
|
- product.setSpec(purcitem.getProdTitle());
|
|
|
- Long proId = ProductUtils.updateOne(product);
|
|
|
- item.setProduct(product);
|
|
|
- item.setProductId(proId);
|
|
|
- }
|
|
|
- }
|
|
|
- item.setInquiry(inquiry);
|
|
|
- item.setNumber(i);
|
|
|
- item.setCurrency(contact.getCurrency());
|
|
|
- item.setFromDate(new Date());
|
|
|
- item.setToDate(purcitem.getToDate());
|
|
|
- // 币别为RMB税率17,其他税率为0
|
|
|
- if (contact.getRate() != null) {
|
|
|
- item.setTaxrate(contact.getRate());
|
|
|
- } else {
|
|
|
- if (item.getCurrency().equals(RMB)) {
|
|
|
- item.setTaxrate((float) 17);
|
|
|
- } else {
|
|
|
- item.setTaxrate((float) 0);
|
|
|
- }
|
|
|
- }
|
|
|
- item.setRemark(purcitem.getRemark());
|
|
|
- item.setVendUU(contact.getEnuu());
|
|
|
- item.setStatus((short) Status.NOT_REPLY.value());
|
|
|
- item.setVendUserUU(vendorEn.getEnAdminuu());
|
|
|
- item.setIsOpen(inquiryInfo.getIsOpen());
|
|
|
- item.setNeedquantity(purcitem.getNeedquantity());
|
|
|
- items.add(item);
|
|
|
- i++;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- List<PurcInquiryItem> purcitems = purcInquiryItemDao.save(items);
|
|
|
- if (purcitems.get(0).getId() != null) {
|
|
|
- map.put("success", "询价单保存成功");
|
|
|
- map.put("id", purcitems.get(0).getInquiry().getId());
|
|
|
- logger.log("询价单", "平台新增询价单", useruu, SystemSession.getUser().getIp());
|
|
|
- } else {
|
|
|
- map.put("error", "询价单保存失败");
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- return map;
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public ModelMap saveAndSubmit(PurcInquiryInfo inquiryInfo, List<VendorAndContact> contacts, FileUpload uploadItem) throws Exception {
|
|
|
- // 先进行保存
|
|
|
- Object inquiryId = save(inquiryInfo, contacts, uploadItem).get("id");// 取出id进行更新状态
|
|
|
- // 再进行提交
|
|
|
- ModelMap map = sumbit(Long.valueOf(inquiryId.toString()));
|
|
|
- return map;
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public ModelMap sumbit(Long id) {
|
|
|
- ModelMap map = new ModelMap();
|
|
|
- Long enuu = SystemSession.getUser().getEnterprise().getUu();
|
|
|
- Long useruu = SystemSession.getUser().getUserUU();
|
|
|
- PurcInquiry inquiry = inquiryDao.findOne(id);
|
|
|
- PurchaseInquiry saleInquiry = new PurchaseInquiry();
|
|
|
- saleInquiry.setDate(new Date());
|
|
|
- saleInquiry.setCode(inquiry.getCode());
|
|
|
- saleInquiry.setEnUU(enuu);
|
|
|
- saleInquiry.setEnterprise(enterpriseDao.findEnterpriseInfoByUu(enuu));
|
|
|
- saleInquiry.setRecorder(SystemSession.getUser().getUserName());
|
|
|
- saleInquiry.setRecorderUU(useruu);
|
|
|
- saleInquiry.setAuditor(SystemSession.getUser().getUserName());
|
|
|
- saleInquiry.setSourceApp(SOURCERAPP);
|
|
|
- saleInquiry.setSourceId(id);
|
|
|
- saleInquiry.setInvoice(inquiry.getInvoice());
|
|
|
- saleInquiry.setShip(inquiry.getShip());
|
|
|
- saleInquiry.setEndDate(inquiry.getEndDate());
|
|
|
- saleInquiry.setInquirytype(inquiry.getInquirytype());
|
|
|
- Set<Attach> attachs = new HashSet<Attach>();
|
|
|
- if (!CollectionUtils.isEmpty(inquiry.getAttachs())) {
|
|
|
- for (Attach attach : inquiry.getAttachs()) {
|
|
|
- Attach newAttach = new Attach();
|
|
|
- newAttach.setDate(new Date());
|
|
|
- newAttach.setDescription(attach.getDescription());
|
|
|
- newAttach.setName(attach.getName());
|
|
|
- newAttach.setPath(attach.getPath());
|
|
|
- attachs.add(newAttach);
|
|
|
- }
|
|
|
- }
|
|
|
- saleInquiry.setAttachs(attachs);
|
|
|
- saleInquiry.setAuditor(inquiry.getAuditor());
|
|
|
- saleInquiry.setRemark(inquiry.getRemark());
|
|
|
- Set<PurchaseInquiryItem> items = new HashSet<PurchaseInquiryItem>();
|
|
|
- if (!CollectionUtils.isEmpty(inquiry.getInquiryItems())) {
|
|
|
- for (PurcInquiryItem item : inquiry.getInquiryItems()) {
|
|
|
- PurchaseInquiryItem saleItem = new PurchaseInquiryItem();
|
|
|
- saleItem.setFromDate(item.getFromDate());
|
|
|
- Product product = productDao.findOne(item.getProductId());
|
|
|
- saleItem.setInquiry(saleInquiry);
|
|
|
- saleItem.setNumber(item.getNumber());
|
|
|
- saleItem.setVendUU(item.getVendUU());
|
|
|
- saleItem.setVendUserUU(item.getVendUserUU());
|
|
|
- saleItem.setProductId(item.getProductId());
|
|
|
- saleItem.setProduct(product);
|
|
|
- saleItem.setRemark(item.getRemark());
|
|
|
- saleItem.setFromDate(item.getFromDate());
|
|
|
- saleItem.setTaxrate(item.getTaxrate());
|
|
|
- saleItem.setToDate(item.getToDate());
|
|
|
- saleItem.setStatus((short) Status.NOT_REPLY.value());
|
|
|
- saleItem.setSendStatus((short) Status.NOT_UPLOAD.value());
|
|
|
- saleItem.setSourceApp(SOURCERAPP);
|
|
|
- saleItem.setSourceId(item.getId());
|
|
|
- saleItem.setCurrency(item.getCurrency());
|
|
|
- saleItem.setNeedquantity(item.getNeedquantity());
|
|
|
- Set<PurchaseInquiryReply> replies = new HashSet<PurchaseInquiryReply>();
|
|
|
- PurchaseInquiryReply reply = new PurchaseInquiryReply();
|
|
|
- reply.setLapQty((double) 0);
|
|
|
- replies.add(reply);
|
|
|
- saleItem.setReplies(replies);
|
|
|
- items.add(saleItem);
|
|
|
- }
|
|
|
- }
|
|
|
- List<PurchaseInquiryItem> purcitems = purchaseInquiryItemDao.save(items);
|
|
|
- // 触发事件,产生消息
|
|
|
- ContextUtils.publishEvent(new PurchaseInquiryItemSaveReleaseEvent(purcitems));
|
|
|
- if (purcitems.get(0).getId() != null) {
|
|
|
- inquiry = inquiryDao.findOne(id);
|
|
|
- inquiry.setEnteryStatus(Status.ENABLED.value());
|
|
|
- inquiryDao.save(inquiry);
|
|
|
- saveUserOrders(purcitems);
|
|
|
- logger.log("询价单", "平台提交询价单", useruu, SystemSession.getUser().getIp());
|
|
|
- map.put("success", "询价单提交成功");
|
|
|
- } else {
|
|
|
- map.put("error", "询价单提交失败");
|
|
|
- }
|
|
|
- return map;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 保存
|
|
|
- *
|
|
|
- * @param purcitems 采购询价单
|
|
|
- * @return
|
|
|
- */
|
|
|
- private void saveUserOrders(final List<PurchaseInquiryItem> purcitems){
|
|
|
- ThreadTask.getInstance().execute(new Runnable() {
|
|
|
- @Override
|
|
|
- public void run() {
|
|
|
- /* 添加供应商的阅读记录*/
|
|
|
- for(PurchaseInquiryItem item : purcitems) {
|
|
|
- Set<Long> userUUs = new HashSet<>();
|
|
|
- // 添加管理员
|
|
|
- List<Role> roles = roleDao.findByEnUUAndIssys(item.getVendUU(), Constant.YES);
|
|
|
- if (!CollectionUtils.isEmpty(roles)) {
|
|
|
- List<User> admins = userDao.findByRole(roles.get(0).getId());
|
|
|
- for (User admin : admins) {
|
|
|
- if (!userUUs.contains(admin.getUserUU())) {
|
|
|
- userUUs.add(admin.getUserUU());
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- List<Vendor> vendors = vendorDao.findByMyEnUUAndVendUU(item.getInquiry().getEnUU(), item.getVendUU());
|
|
|
- // 查找有权限的用户
|
|
|
- if (!CollectionUtils.isEmpty(vendors)) {
|
|
|
- Long vendorId = vendors.get(0).getId();
|
|
|
- List<Distribute> distributes = distributeDao.findByVendorId(vendorId);
|
|
|
- if (!CollectionUtils.isEmpty(distributes)) {
|
|
|
- for (Distribute distribute : distributes) {
|
|
|
- if (!userUUs.contains(distribute.getUserUU())) {
|
|
|
- userUUs.add(distribute.getUserUU());
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- UserOrders userOrders;
|
|
|
- List<UserOrders> list = new ArrayList<>();
|
|
|
- for (Long userUU : userUUs) {
|
|
|
- if (userUU == null) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- userOrders = new UserOrders(userUU, item.getVendUU(), item.getId(), "sale", "v$purc$inquiryitems");
|
|
|
- list.add(userOrders);
|
|
|
- }
|
|
|
+ // 导入的物料这里没有填写规格
|
|
|
+ product.setSpec(purcitem.getProdTitle());
|
|
|
+ Long proId = ProductUtils.updateOne(product);
|
|
|
+ item.setProduct(product);
|
|
|
+ item.setProductId(proId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ item.setInquiry(inquiry);
|
|
|
+ item.setNumber(i);
|
|
|
+ item.setCurrency(contact.getCurrency());
|
|
|
+ item.setFromDate(new Date());
|
|
|
+ item.setToDate(purcitem.getToDate());
|
|
|
+ // 币别为RMB税率17,其他税率为0
|
|
|
+ if (contact.getRate() != null) {
|
|
|
+ item.setTaxrate(contact.getRate());
|
|
|
+ } else {
|
|
|
+ if (item.getCurrency().equals(RMB)) {
|
|
|
+ item.setTaxrate((float) 17);
|
|
|
+ } else {
|
|
|
+ item.setTaxrate((float) 0);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ item.setRemark(purcitem.getRemark());
|
|
|
+ item.setVendUU(contact.getEnuu());
|
|
|
+ item.setStatus((short) Status.NOT_REPLY.value());
|
|
|
+ item.setVendUserUU(vendorEn.getEnAdminuu());
|
|
|
+ item.setIsOpen(inquiryInfo.getIsOpen());
|
|
|
+ item.setNeedquantity(purcitem.getNeedquantity());
|
|
|
+ items.add(item);
|
|
|
+ i++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<PurcInquiryItem> purcitems = purcInquiryItemDao.save(items);
|
|
|
+ if (purcitems.get(0).getId() != null) {
|
|
|
+ map.put("success", "询价单保存成功");
|
|
|
+ map.put("id", purcitems.get(0).getInquiry().getId());
|
|
|
+ logger.log("询价单", "平台新增询价单", useruu, SystemSession.getUser().getIp());
|
|
|
+ } else {
|
|
|
+ map.put("error", "询价单保存失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ModelMap saveAndSubmit(PurcInquiryInfo inquiryInfo, List<VendorAndContact> contacts, FileUpload uploadItem) throws Exception {
|
|
|
+ // 先进行保存
|
|
|
+ Object inquiryId = save(inquiryInfo, contacts, uploadItem).get("id");// 取出id进行更新状态
|
|
|
+ // 再进行提交
|
|
|
+ ModelMap map = sumbit(Long.valueOf(inquiryId.toString()));
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ModelMap sumbit(Long id) {
|
|
|
+ ModelMap map = new ModelMap();
|
|
|
+ Long enuu = SystemSession.getUser().getEnterprise().getUu();
|
|
|
+ Long useruu = SystemSession.getUser().getUserUU();
|
|
|
+ PurcInquiry inquiry = inquiryDao.findOne(id);
|
|
|
+ PurchaseInquiry saleInquiry = new PurchaseInquiry();
|
|
|
+ saleInquiry.setDate(new Date());
|
|
|
+ saleInquiry.setCode(inquiry.getCode());
|
|
|
+ saleInquiry.setEnUU(enuu);
|
|
|
+ saleInquiry.setEnterprise(enterpriseDao.findEnterpriseInfoByUu(enuu));
|
|
|
+ saleInquiry.setRecorder(SystemSession.getUser().getUserName());
|
|
|
+ saleInquiry.setRecorderUU(useruu);
|
|
|
+ saleInquiry.setAuditor(SystemSession.getUser().getUserName());
|
|
|
+ saleInquiry.setSourceApp(SOURCERAPP);
|
|
|
+ saleInquiry.setSourceId(id);
|
|
|
+ saleInquiry.setInvoice(inquiry.getInvoice());
|
|
|
+ saleInquiry.setShip(inquiry.getShip());
|
|
|
+ saleInquiry.setEndDate(inquiry.getEndDate());
|
|
|
+ saleInquiry.setInquirytype(inquiry.getInquirytype());
|
|
|
+ Set<Attach> attachs = new HashSet<Attach>();
|
|
|
+ if (!CollectionUtils.isEmpty(inquiry.getAttachs())) {
|
|
|
+ for (Attach attach : inquiry.getAttachs()) {
|
|
|
+ Attach newAttach = new Attach();
|
|
|
+ newAttach.setDate(new Date());
|
|
|
+ newAttach.setDescription(attach.getDescription());
|
|
|
+ newAttach.setName(attach.getName());
|
|
|
+ newAttach.setPath(attach.getPath());
|
|
|
+ attachs.add(newAttach);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ saleInquiry.setAttachs(attachs);
|
|
|
+ saleInquiry.setAuditor(inquiry.getAuditor());
|
|
|
+ saleInquiry.setRemark(inquiry.getRemark());
|
|
|
+ Set<PurchaseInquiryItem> items = new HashSet<PurchaseInquiryItem>();
|
|
|
+ if (!CollectionUtils.isEmpty(inquiry.getInquiryItems())) {
|
|
|
+ for (PurcInquiryItem item : inquiry.getInquiryItems()) {
|
|
|
+ PurchaseInquiryItem saleItem = new PurchaseInquiryItem();
|
|
|
+ saleItem.setFromDate(item.getFromDate());
|
|
|
+ Product product = productDao.findOne(item.getProductId());
|
|
|
+ saleItem.setInquiry(saleInquiry);
|
|
|
+ saleItem.setNumber(item.getNumber());
|
|
|
+ saleItem.setVendUU(item.getVendUU());
|
|
|
+ saleItem.setVendUserUU(item.getVendUserUU());
|
|
|
+ saleItem.setProductId(item.getProductId());
|
|
|
+ saleItem.setProduct(product);
|
|
|
+ saleItem.setRemark(item.getRemark());
|
|
|
+ saleItem.setFromDate(item.getFromDate());
|
|
|
+ saleItem.setTaxrate(item.getTaxrate());
|
|
|
+ saleItem.setToDate(item.getToDate());
|
|
|
+ saleItem.setStatus((short) Status.NOT_REPLY.value());
|
|
|
+ saleItem.setSendStatus((short) Status.NOT_UPLOAD.value());
|
|
|
+ saleItem.setSourceApp(SOURCERAPP);
|
|
|
+ saleItem.setSourceId(item.getId());
|
|
|
+ saleItem.setCurrency(item.getCurrency());
|
|
|
+ saleItem.setNeedquantity(item.getNeedquantity());
|
|
|
+ Set<PurchaseInquiryReply> replies = new HashSet<PurchaseInquiryReply>();
|
|
|
+ PurchaseInquiryReply reply = new PurchaseInquiryReply();
|
|
|
+ reply.setLapQty((double) 0);
|
|
|
+ replies.add(reply);
|
|
|
+ saleItem.setReplies(replies);
|
|
|
+ items.add(saleItem);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<PurchaseInquiryItem> purcitems = purchaseInquiryItemDao.save(items);
|
|
|
+ // 触发事件,产生消息
|
|
|
+ ContextUtils.publishEvent(new PurchaseInquiryItemSaveReleaseEvent(purcitems));
|
|
|
+ if (purcitems.get(0).getId() != null) {
|
|
|
+ inquiry = inquiryDao.findOne(id);
|
|
|
+ inquiry.setEnteryStatus(Status.ENABLED.value());
|
|
|
+ inquiryDao.save(inquiry);
|
|
|
+ saveUserOrders(purcitems);
|
|
|
+ logger.log("询价单", "平台提交询价单", useruu, SystemSession.getUser().getIp());
|
|
|
+ map.put("success", "询价单提交成功");
|
|
|
+ } else {
|
|
|
+ map.put("error", "询价单提交失败");
|
|
|
+ }
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 保存
|
|
|
+ *
|
|
|
+ * @param purcitems 采购询价单
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private void saveUserOrders(final List<PurchaseInquiryItem> purcitems) {
|
|
|
+ ThreadTask.getInstance().execute(new Runnable() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ /* 添加供应商的阅读记录*/
|
|
|
+ for (PurchaseInquiryItem item : purcitems) {
|
|
|
+ Set<Long> userUUs = new HashSet<>();
|
|
|
+ // 添加管理员
|
|
|
+ List<Role> roles = roleDao.findByEnUUAndIssys(item.getVendUU(), Constant.YES);
|
|
|
+ if (!CollectionUtils.isEmpty(roles)) {
|
|
|
+ List<User> admins = userDao.findByRole(roles.get(0).getId());
|
|
|
+ for (User admin : admins) {
|
|
|
+ if (!userUUs.contains(admin.getUserUU())) {
|
|
|
+ userUUs.add(admin.getUserUU());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ List<Vendor> vendors = vendorDao.findByMyEnUUAndVendUU(item.getInquiry().getEnUU(), item.getVendUU());
|
|
|
+ // 查找有权限的用户
|
|
|
+ if (!CollectionUtils.isEmpty(vendors)) {
|
|
|
+ Long vendorId = vendors.get(0).getId();
|
|
|
+ List<Distribute> distributes = distributeDao.findByVendorId(vendorId);
|
|
|
+ if (!CollectionUtils.isEmpty(distributes)) {
|
|
|
+ for (Distribute distribute : distributes) {
|
|
|
+ if (!userUUs.contains(distribute.getUserUU())) {
|
|
|
+ userUUs.add(distribute.getUserUU());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ UserOrders userOrders;
|
|
|
+ List<UserOrders> list = new ArrayList<>();
|
|
|
+ for (Long userUU : userUUs) {
|
|
|
+ if (userUU == null) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ userOrders = new UserOrders(userUU, item.getVendUU(), item.getId(), "sale", "v$purc$inquiryitems");
|
|
|
+ list.add(userOrders);
|
|
|
+ }
|
|
|
|
|
|
/* 添加采购员的阅读记录*/
|
|
|
- if (item.getInquiry().getRecorderUU() != null) {
|
|
|
+ if (item.getInquiry().getRecorderUU() != null) {
|
|
|
userOrders = new UserOrders(item.getInquiry().getRecorderUU(), item.getInquiry().getEnUU(), item.getId(), "purc", "v$purc$inquiryitems");
|
|
|
userOrders.setReadStatus((short) Status.READ.value());
|
|
|
list.add(userOrders);
|
|
|
}
|
|
|
- userOrderDao.save(list);
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public ModelMap clearOrder(Long id) {
|
|
|
- try {
|
|
|
- PurcInquiry inquiry = inquiryDao.findOne(id);
|
|
|
- if (inquiry != null) {
|
|
|
- if (!CollectionUtils.isEmpty(inquiry.getInquiryItems())) {
|
|
|
- for (PurcInquiryItem item : inquiry.getInquiryItems()) {
|
|
|
- purcInquiryItemDao.delete(item.getId());
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- return null;
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public ModelMap deleteById(Long id) {
|
|
|
- try {
|
|
|
- purcInquiryItemDao.delete(id);
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- return null;
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public Page<PurcInquiry> getUnapply(PageParams params) {
|
|
|
- final PageInfo pageInfo = new PageInfo(params);
|
|
|
- pageInfo.filter("enUU", SystemSession.getUser().getEnterprise().getUu());
|
|
|
- pageInfo.filter("enteryStatus", Status.UNAPPLY.value());
|
|
|
- return inquiryDao.findAll(new Specification<PurcInquiry>() {
|
|
|
- public Predicate toPredicate(Root<PurcInquiry> root, CriteriaQuery<?> query, CriteriaBuilder builder) {
|
|
|
- return query.where(pageInfo.getPredicates(root, query, builder)).getRestriction();
|
|
|
- }
|
|
|
- }, pageInfo);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public Page<PurcInquiry> getSubmit(PageParams params) {
|
|
|
- final PageInfo pageInfo = new PageInfo(params);
|
|
|
- pageInfo.filter("enUU", SystemSession.getUser().getEnterprise().getUu());
|
|
|
- pageInfo.filter("enteryStatus", Status.ENABLED.value());
|
|
|
- return inquiryDao.findAll(new Specification<PurcInquiry>() {
|
|
|
- public Predicate toPredicate(Root<PurcInquiry> root, CriteriaQuery<?> query, CriteriaBuilder builder) {
|
|
|
- return query.where(pageInfo.getPredicates(root, query, builder)).getRestriction();
|
|
|
- }
|
|
|
- }, pageInfo);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public ModelMap refuseInquiry(Long id) {
|
|
|
- ModelMap map = new ModelMap();
|
|
|
- PurchaseInquiryItem item = purchaseInquiryItemDao.findOne(id);
|
|
|
- item.setAgreed(Constant.NO);
|
|
|
- item.setStatus((short) Status.REPLIED.value());
|
|
|
- item = purchaseInquiryItemDao.save(item);
|
|
|
- if (item.getAgreed().equals(Constant.NO) && item.getStatus().equals((short) Status.REPLIED.value())) {
|
|
|
- map.put("success", "拒绝操作成功");
|
|
|
- } else {
|
|
|
- map.put("error", "操作失败");
|
|
|
- }
|
|
|
- List<PurchaseInquiryItem> items = new ArrayList<>();
|
|
|
- items.add(item);
|
|
|
- ContextUtils.publishEvent(new PurchaseInquiryItemDecideReleaseEvent(items));
|
|
|
- return map;
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public ModelMap acceptInquiry(Long id) {
|
|
|
- ModelMap map = new ModelMap();
|
|
|
- PurchaseInquiryItem item = purchaseInquiryItemDao.findOne(id);
|
|
|
- item.setAgreed(Constant.YES);
|
|
|
- item.setStatus((short) Status.REPLIED.value());
|
|
|
- item = purchaseInquiryItemDao.save(item);
|
|
|
- if (item.getAgreed().equals(Constant.YES) && item.getStatus().equals((short) Status.REPLIED.value())) {
|
|
|
- map.put("success", "采纳成功");
|
|
|
- } else {
|
|
|
- map.put("error", "采纳失败");
|
|
|
- }
|
|
|
- List<PurchaseInquiryItem> items = new ArrayList<>();
|
|
|
- items.add(item);
|
|
|
- ContextUtils.publishEvent(new PurchaseInquiryItemDecideReleaseEvent(items));
|
|
|
- return map;
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public ModelMap saveWithoutVendor(PurcInquiryInfo inquiryInfo, FileUpload uploadItem) throws Exception {
|
|
|
- PurcInquiry inquiry = new PurcInquiry();
|
|
|
- PurcInquiry old = inquiryDao.findByCode(inquiryInfo.getCode());
|
|
|
- ModelMap map = new ModelMap();
|
|
|
- if (old == null) {
|
|
|
- Set<Attach> attachs = new HashSet<Attach>();
|
|
|
- if (uploadItem.getFile() != null) {// 附件存在
|
|
|
- Attach attach = attachService.upload(uploadItem, "productAttach", "平台询价上传传物料照片或附件");
|
|
|
- if (attach == null) {
|
|
|
- map.put("error", "文件太大");
|
|
|
- } else {
|
|
|
- attachs.add(attach);
|
|
|
- inquiry.setAttachs(attachs);
|
|
|
- }
|
|
|
- }
|
|
|
- Long enuu = SystemSession.getUser().getEnterprise().getUu();
|
|
|
- Long useruu = SystemSession.getUser().getUserUU();
|
|
|
- if (inquiryInfo.getId() == null) {// 新增
|
|
|
- inquiry.setDate(new Date());
|
|
|
- inquiry.setCode(inquiryInfo.getCode());
|
|
|
- inquiry.setEnUU(enuu);
|
|
|
- inquiry.setCode(inquiryInfo.getCode());
|
|
|
- inquiry.setEndDate(inquiryInfo.getEndDate());
|
|
|
- inquiry.setRemark(inquiryInfo.getRemark());
|
|
|
- inquiry.setEnvironment(inquiryInfo.getEnvironment());
|
|
|
- inquiry.setEnterprise(enterpriseDao.findEnterpriseInfoByUu(enuu));
|
|
|
- inquiry.setRecorder(SystemSession.getUser().getUserName());
|
|
|
- inquiry.setRecorderUU(SystemSession.getUser().getUserUU());
|
|
|
- inquiry.setPriceType(inquiryInfo.getPriceType());
|
|
|
- inquiry.setIsOpen((short) inquiryInfo.getIsOpen());
|
|
|
- inquiry.setInvoice(inquiryInfo.getInvoice());
|
|
|
- inquiry.setShip(inquiryInfo.getShip());
|
|
|
- inquiry.setCurrency(inquiryInfo.getCurrency());
|
|
|
- inquiry.setIfTax(inquiryInfo.getIfTax());
|
|
|
- inquiry.setInquirytype(inquiryInfo.getInquirytype());
|
|
|
+ userOrderDao.save(list);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ModelMap clearOrder(Long id) {
|
|
|
+ try {
|
|
|
+ PurcInquiry inquiry = inquiryDao.findOne(id);
|
|
|
+ if (inquiry != null) {
|
|
|
+ if (!CollectionUtils.isEmpty(inquiry.getInquiryItems())) {
|
|
|
+ for (PurcInquiryItem item : inquiry.getInquiryItems()) {
|
|
|
+ purcInquiryItemDao.delete(item.getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ModelMap deleteById(Long id) {
|
|
|
+ try {
|
|
|
+ purcInquiryItemDao.delete(id);
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Page<PurcInquiry> getUnapply(PageParams params) {
|
|
|
+ final PageInfo pageInfo = new PageInfo(params);
|
|
|
+ pageInfo.filter("enUU", SystemSession.getUser().getEnterprise().getUu());
|
|
|
+ pageInfo.filter("enteryStatus", Status.UNAPPLY.value());
|
|
|
+ return inquiryDao.findAll(new Specification<PurcInquiry>() {
|
|
|
+ public Predicate toPredicate(Root<PurcInquiry> root, CriteriaQuery<?> query, CriteriaBuilder builder) {
|
|
|
+ return query.where(pageInfo.getPredicates(root, query, builder)).getRestriction();
|
|
|
+ }
|
|
|
+ }, pageInfo);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Page<PurcInquiry> getSubmit(PageParams params) {
|
|
|
+ final PageInfo pageInfo = new PageInfo(params);
|
|
|
+ pageInfo.filter("enUU", SystemSession.getUser().getEnterprise().getUu());
|
|
|
+ pageInfo.filter("enteryStatus", Status.ENABLED.value());
|
|
|
+ return inquiryDao.findAll(new Specification<PurcInquiry>() {
|
|
|
+ public Predicate toPredicate(Root<PurcInquiry> root, CriteriaQuery<?> query, CriteriaBuilder builder) {
|
|
|
+ return query.where(pageInfo.getPredicates(root, query, builder)).getRestriction();
|
|
|
+ }
|
|
|
+ }, pageInfo);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ModelMap refuseInquiry(Long id) {
|
|
|
+ ModelMap map = new ModelMap();
|
|
|
+ PurchaseInquiryItem item = purchaseInquiryItemDao.findOne(id);
|
|
|
+ item.setAgreed(Constant.NO);
|
|
|
+ item.setStatus((short) Status.REPLIED.value());
|
|
|
+ item = purchaseInquiryItemDao.save(item);
|
|
|
+ if (item.getAgreed().equals(Constant.NO) && item.getStatus().equals((short) Status.REPLIED.value())) {
|
|
|
+ map.put("success", "拒绝操作成功");
|
|
|
+ } else {
|
|
|
+ map.put("error", "操作失败");
|
|
|
+ }
|
|
|
+ List<PurchaseInquiryItem> items = new ArrayList<>();
|
|
|
+ items.add(item);
|
|
|
+ ContextUtils.publishEvent(new PurchaseInquiryItemDecideReleaseEvent(items));
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ModelMap acceptInquiry(Long id) {
|
|
|
+ ModelMap map = new ModelMap();
|
|
|
+ PurchaseInquiryItem item = purchaseInquiryItemDao.findOne(id);
|
|
|
+ item.setAgreed(Constant.YES);
|
|
|
+ item.setStatus((short) Status.REPLIED.value());
|
|
|
+ item = purchaseInquiryItemDao.save(item);
|
|
|
+ if (item.getAgreed().equals(Constant.YES) && item.getStatus().equals((short) Status.REPLIED.value())) {
|
|
|
+ map.put("success", "采纳成功");
|
|
|
+ } else {
|
|
|
+ map.put("error", "采纳失败");
|
|
|
+ }
|
|
|
+ List<PurchaseInquiryItem> items = new ArrayList<>();
|
|
|
+ items.add(item);
|
|
|
+ ContextUtils.publishEvent(new PurchaseInquiryItemDecideReleaseEvent(items));
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ModelMap saveWithoutVendor(PurcInquiryInfo inquiryInfo, FileUpload uploadItem) throws Exception {
|
|
|
+ PurcInquiry inquiry = new PurcInquiry();
|
|
|
+ PurcInquiry old = inquiryDao.findByCode(inquiryInfo.getCode());
|
|
|
+ ModelMap map = new ModelMap();
|
|
|
+ if (old == null) {
|
|
|
+ Set<Attach> attachs = new HashSet<Attach>();
|
|
|
+ if (uploadItem.getFile() != null) {// 附件存在
|
|
|
+ Attach attach = attachService.upload(uploadItem, "productAttach", "平台询价上传传物料照片或附件");
|
|
|
+ if (attach == null) {
|
|
|
+ map.put("error", "文件太大");
|
|
|
+ } else {
|
|
|
+ attachs.add(attach);
|
|
|
+ inquiry.setAttachs(attachs);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Long enuu = SystemSession.getUser().getEnterprise().getUu();
|
|
|
+ Long useruu = SystemSession.getUser().getUserUU();
|
|
|
+ if (inquiryInfo.getId() == null) {// 新增
|
|
|
+ inquiry.setDate(new Date());
|
|
|
+ inquiry.setCode(inquiryInfo.getCode());
|
|
|
+ inquiry.setEnUU(enuu);
|
|
|
+ inquiry.setCode(inquiryInfo.getCode());
|
|
|
+ inquiry.setEndDate(inquiryInfo.getEndDate());
|
|
|
+ inquiry.setRemark(inquiryInfo.getRemark());
|
|
|
+ inquiry.setEnvironment(inquiryInfo.getEnvironment());
|
|
|
+ inquiry.setEnterprise(enterpriseDao.findEnterpriseInfoByUu(enuu));
|
|
|
+ inquiry.setRecorder(SystemSession.getUser().getUserName());
|
|
|
+ inquiry.setRecorderUU(SystemSession.getUser().getUserUU());
|
|
|
+ inquiry.setPriceType(inquiryInfo.getPriceType());
|
|
|
+ inquiry.setIsOpen((short) inquiryInfo.getIsOpen());
|
|
|
+ inquiry.setInvoice(inquiryInfo.getInvoice());
|
|
|
+ inquiry.setShip(inquiryInfo.getShip());
|
|
|
+ inquiry.setCurrency(inquiryInfo.getCurrency());
|
|
|
+ inquiry.setIfTax(inquiryInfo.getIfTax());
|
|
|
+ inquiry.setInquirytype(inquiryInfo.getInquirytype());
|
|
|
inquiry.setEnteryStatus(Status.ENABLED.value());
|
|
|
inquiry.setSourceapp(SOURCERAPP);
|
|
|
- Set<PurcInquiryItem> items = new HashSet<PurcInquiryItem>();
|
|
|
- Short i = 1;
|
|
|
- if (!CollectionUtils.isEmpty(inquiryInfo.getInquiryItems())) {
|
|
|
- for (PurcInquiryItem purcitem : inquiryInfo.getInquiryItems()) {
|
|
|
- PurcInquiryItem item = new PurcInquiryItem();
|
|
|
- Product product = new Product();
|
|
|
- if (purcitem.getProductId() != null) {// 点击选择出来的,一般带有id
|
|
|
- product = productDao.findOne(purcitem.getProductId());
|
|
|
- item.setProduct(product);
|
|
|
- item.setProductId(product.getId());
|
|
|
- } else {// 导入或手动输入的一般不带有id
|
|
|
- product = productDao.findByEnUUAndCodeAndBrand(
|
|
|
- SystemSession.getUser().getEnterprise().getUu(), purcitem.getProdCode(),
|
|
|
- purcitem.getInbrand());
|
|
|
- if (product != null) {// 存在直接选择
|
|
|
- item.setProduct(product);
|
|
|
- item.setProductId(product.getId());
|
|
|
- } else { // 不存在,插入物料
|
|
|
- product = new Product();
|
|
|
- product.setBrand(purcitem.getInbrand());
|
|
|
- product.setCmpCode(purcitem.getCmpCode());
|
|
|
- product.setSourceApp(SOURCERAPP);
|
|
|
- product.setCode(purcitem.getProdCode());
|
|
|
- product.setEnUU(SystemSession.getUser().getEnterprise().getUu());
|
|
|
- product.setTitle(purcitem.getProdTitle());
|
|
|
- product.setCmpUuId(purcitem.getProdCode());
|
|
|
- product.setUnit(purcitem.getUnit());
|
|
|
- product.setUserUU(SystemSession.getUser().getUserUU());
|
|
|
- product.setSpec(purcitem.getProdTitle());
|
|
|
- Long proId = ProductUtils.updateOne(product);
|
|
|
- product = productDao.findOne(proId);
|
|
|
- item.setProdCode(purcitem.getProdCode());
|
|
|
- item.setProdTitle(purcitem.getProdTitle());
|
|
|
- item.setSpec(purcitem.getSpec());
|
|
|
- item.setCmpCode(purcitem.getCmpCode());
|
|
|
- if (null != product) {
|
|
|
- item.setProductId(proId);
|
|
|
- } else {
|
|
|
+ Set<PurcInquiryItem> items = new HashSet<PurcInquiryItem>();
|
|
|
+ Short i = 1;
|
|
|
+ if (!CollectionUtils.isEmpty(inquiryInfo.getInquiryItems())) {
|
|
|
+ for (PurcInquiryItem purcitem : inquiryInfo.getInquiryItems()) {
|
|
|
+ PurcInquiryItem item = new PurcInquiryItem();
|
|
|
+ Product product = new Product();
|
|
|
+ if (purcitem.getProductId() != null) {// 点击选择出来的,一般带有id
|
|
|
+ product = productDao.findOne(purcitem.getProductId());
|
|
|
+ item.setProduct(product);
|
|
|
+ item.setProductId(product.getId());
|
|
|
+ } else {// 导入或手动输入的一般不带有id
|
|
|
+ product = productDao.findByEnUUAndCodeAndBrand(
|
|
|
+ SystemSession.getUser().getEnterprise().getUu(), purcitem.getProdCode(),
|
|
|
+ purcitem.getInbrand());
|
|
|
+ if (product != null) {// 存在直接选择
|
|
|
+ item.setProduct(product);
|
|
|
+ item.setProductId(product.getId());
|
|
|
+ } else { // 不存在,插入物料
|
|
|
+ product = new Product();
|
|
|
+ product.setBrand(purcitem.getInbrand());
|
|
|
+ product.setCmpCode(purcitem.getCmpCode());
|
|
|
+ product.setSourceApp(SOURCERAPP);
|
|
|
+ product.setCode(purcitem.getProdCode());
|
|
|
+ product.setEnUU(SystemSession.getUser().getEnterprise().getUu());
|
|
|
+ product.setTitle(purcitem.getProdTitle());
|
|
|
+ product.setCmpUuId(purcitem.getProdCode());
|
|
|
+ product.setUnit(purcitem.getUnit());
|
|
|
+ product.setUserUU(SystemSession.getUser().getUserUU());
|
|
|
+ product.setSpec(purcitem.getProdTitle());
|
|
|
+ Long proId = ProductUtils.updateOne(product);
|
|
|
+ product = productDao.findOne(proId);
|
|
|
+ item.setProdCode(purcitem.getProdCode());
|
|
|
+ item.setProdTitle(purcitem.getProdTitle());
|
|
|
+ item.setSpec(purcitem.getSpec());
|
|
|
+ item.setCmpCode(purcitem.getCmpCode());
|
|
|
+ if (null != product) {
|
|
|
+ item.setProductId(proId);
|
|
|
+ } else {
|
|
|
throw new IllegalOperatorException("物料保存失败:" + product.getTitle());
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- item.setNumber(i);
|
|
|
- item.setCurrency(inquiry.getCurrency());
|
|
|
- item.setFromDate(new Date());
|
|
|
- item.setToDate(purcitem.getToDate());
|
|
|
- item.setDate(new Date());
|
|
|
- if (item.getCurrency().equals(RMB)) {
|
|
|
- item.setTaxrate((float) 17);
|
|
|
- } else {
|
|
|
- item.setTaxrate((float) 0);
|
|
|
- }
|
|
|
- item.setRemark(purcitem.getRemark());
|
|
|
- item.setStatus((short) Status.NOT_REPLY.value());
|
|
|
- item.setIsOpen(inquiryInfo.getIsOpen());
|
|
|
- item.setNeedquantity(purcitem.getNeedquantity());
|
|
|
- item.setUserUU(SystemSession.getUser().getUserUU());
|
|
|
- item.setUserName(SystemSession.getUser().getUserName());
|
|
|
- item.setUserTel(SystemSession.getUser().getUserTel());
|
|
|
- items.add(item);
|
|
|
- i++;
|
|
|
- }
|
|
|
- }
|
|
|
- inquiry.setInquiryItems(items);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ item.setNumber(i);
|
|
|
+ item.setCurrency(inquiry.getCurrency());
|
|
|
+ item.setFromDate(new Date());
|
|
|
+ item.setToDate(purcitem.getToDate());
|
|
|
+ item.setDate(new Date());
|
|
|
+ if (item.getCurrency().equals(RMB)) {
|
|
|
+ item.setTaxrate((float) 17);
|
|
|
+ } else {
|
|
|
+ item.setTaxrate((float) 0);
|
|
|
+ }
|
|
|
+ item.setRemark(purcitem.getRemark());
|
|
|
+ item.setStatus((short) Status.NOT_REPLY.value());
|
|
|
+ item.setIsOpen(inquiryInfo.getIsOpen());
|
|
|
+ item.setNeedquantity(purcitem.getNeedquantity());
|
|
|
+ item.setUserUU(SystemSession.getUser().getUserUU());
|
|
|
+ item.setUserName(SystemSession.getUser().getUserName());
|
|
|
+ item.setUserTel(SystemSession.getUser().getUserTel());
|
|
|
+ items.add(item);
|
|
|
+ i++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ inquiry.setInquiryItems(items);
|
|
|
inquiry = InquiryUtils.saveInquiry(inquiry);
|
|
|
- if (inquiry.getId() != null) {
|
|
|
- map.put("success", "询价单保存成功");
|
|
|
- map.put("id", inquiry.getId());
|
|
|
- logger.log("询价单", "平台新增询价单", useruu, SystemSession.getUser().getIp());
|
|
|
- } else {
|
|
|
- map.put("error", "询价单保存失败");
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- return map;
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public ModelMap saveAndSubmitWithoutVendor(PurcInquiryInfo inquiryInfo, FileUpload uploadItem) throws Exception {
|
|
|
- ModelMap map = new ModelMap();
|
|
|
- // 先进行保存
|
|
|
- Object inquiryId = saveWithoutVendor(inquiryInfo, uploadItem).get("id");// 取出id进行更新状态
|
|
|
- if (inquiryId != null) {
|
|
|
- map.put("success", "询价单发布成功");
|
|
|
- } else {
|
|
|
- map.put("error", "询价单发布失败");
|
|
|
- }
|
|
|
- return map;
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public ModelMap pubishInquiry(Long id) {
|
|
|
- ModelMap map = new ModelMap();
|
|
|
- PurcInquiry inquiry = inquiryDao.findOne(id);
|
|
|
- inquiry.setEnteryStatus(Status.ENABLED.value());
|
|
|
- inquiryDao.save(inquiry);
|
|
|
- logger.log("询价单", "发布公共询价单", SystemSession.getUser().getUserUU(), SystemSession.getUser().getIp());
|
|
|
- map.put("success", "发布询价单成功");
|
|
|
- return map;
|
|
|
- }
|
|
|
-
|
|
|
- @SuppressWarnings("deprecation")
|
|
|
- @Override
|
|
|
- public ModelMap transtoInquiry(Long id) {
|
|
|
- ModelMap map = new ModelMap();
|
|
|
+ if (inquiry.getId() != null) {
|
|
|
+ map.put("success", "询价单保存成功");
|
|
|
+ map.put("id", inquiry.getId());
|
|
|
+ logger.log("询价单", "平台新增询价单", useruu, SystemSession.getUser().getIp());
|
|
|
+ } else {
|
|
|
+ map.put("error", "询价单保存失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ModelMap saveAndSubmitWithoutVendor(PurcInquiryInfo inquiryInfo, FileUpload uploadItem) throws Exception {
|
|
|
+ ModelMap map = new ModelMap();
|
|
|
+ // 先进行保存
|
|
|
+ Object inquiryId = saveWithoutVendor(inquiryInfo, uploadItem).get("id");// 取出id进行更新状态
|
|
|
+ if (inquiryId != null) {
|
|
|
+ map.put("success", "询价单发布成功");
|
|
|
+ } else {
|
|
|
+ map.put("error", "询价单发布失败");
|
|
|
+ }
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ModelMap pubishInquiry(Long id) {
|
|
|
+ ModelMap map = new ModelMap();
|
|
|
+ PurcInquiry inquiry = inquiryDao.findOne(id);
|
|
|
+ inquiry.setEnteryStatus(Status.ENABLED.value());
|
|
|
+ inquiryDao.save(inquiry);
|
|
|
+ logger.log("询价单", "发布公共询价单", SystemSession.getUser().getUserUU(), SystemSession.getUser().getIp());
|
|
|
+ map.put("success", "发布询价单成功");
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+ @SuppressWarnings("deprecation")
|
|
|
+ @Override
|
|
|
+ public ModelMap transtoInquiry(Long id) {
|
|
|
+ ModelMap map = new ModelMap();
|
|
|
Long enuu = SystemSession.getUser().getEnterprise().getUu();
|
|
|
Long useruu = SystemSession.getUser().getUserUU();
|
|
|
// 这里先要判断是否有询价单的操作权限,涉及到后面单据查看的问题
|
|
|
Integer count = roleService.findRoleByEnUUAndUserUU(enuu, useruu);
|
|
|
- Double manCount = roleDao.findByEnuuAndUserUU(SystemSession.getUser().getEnterprise().getUu(),SystemSession.getUser().getUserUU());
|
|
|
- if(count == 0 && manCount == 0) {
|
|
|
+ Double manCount = roleDao.findByEnuuAndUserUU(SystemSession.getUser().getEnterprise().getUu(), SystemSession.getUser().getUserUU());
|
|
|
+ if (count == 0 && manCount == 0) {
|
|
|
map.put("info", "您没有询价单的操作权限,请通知管理员设置权限");
|
|
|
return map;
|
|
|
}
|
|
|
PurcInquiryItem purcInquiryItem = purcInquiryItemDao.findOne(id);
|
|
|
PurcInquiry purcInquiry = purcInquiryItem.getInquiry();
|
|
|
- // 先判断客户询价单是否存在这张单据
|
|
|
- PurchaseInquiry inquiry = purchaseInquiryDao.findBySourceIdAndSourceApp(purcInquiry.getId(), SOURCERAPP);
|
|
|
- if (null == inquiry) {// 新增
|
|
|
+ // 先判断客户询价单是否存在这张单据
|
|
|
+ PurchaseInquiry inquiry = purchaseInquiryDao.findBySourceIdAndSourceApp(purcInquiry.getId(), SOURCERAPP);
|
|
|
+ if (null == inquiry) {// 新增
|
|
|
// 这里设置自动添加为客户关系,并且如果当前用户非管理员要进行自动分配客户处理
|
|
|
- Long custuseruu = purcInquiry.getRecorderUU();
|
|
|
- if(null == custuseruu) {
|
|
|
- Enterprise enterprise = enterpriseDao.findOne(purcInquiry.getEnUU());
|
|
|
- custuseruu = enterprise.getEnAdminuu();
|
|
|
- }
|
|
|
- if(null != custuseruu) {
|
|
|
- vendorDao.initVendorAndDistribute(purcInquiry.getEnUU(), custuseruu, enuu, useruu);
|
|
|
- }
|
|
|
- PurchaseInquiry saleInquiry = new PurchaseInquiry();
|
|
|
- saleInquiry.setDate(new Date());
|
|
|
- saleInquiry.setCode(purcInquiry.getCode());
|
|
|
- saleInquiry.setEnUU(purcInquiry.getEnUU());
|
|
|
- saleInquiry.setEnterprise(purcInquiry.getEnterprise());
|
|
|
- saleInquiry.setRecorder(purcInquiry.getRecorder());
|
|
|
- saleInquiry.setRecorderUU(purcInquiry.getRecorderUU());
|
|
|
- saleInquiry.setAuditor(purcInquiry.getAuditor());
|
|
|
- saleInquiry.setSourceApp(SOURCERAPP);
|
|
|
- saleInquiry.setKind(INQUIRYKIND);
|
|
|
- saleInquiry.setSourceId(purcInquiry.getId());
|
|
|
- saleInquiry.setPriceType(purcInquiry.getPriceType());
|
|
|
- saleInquiry.setInvoice(purcInquiry.getInvoice());
|
|
|
- saleInquiry.setShip(purcInquiry.getShip());
|
|
|
- saleInquiry.setEndDate(purcInquiry.getEndDate());
|
|
|
- if (!CollectionUtils.isEmpty(purcInquiry.getAttachs())) {
|
|
|
- Set<Attach> attachs = new HashSet<Attach>();
|
|
|
- for (Attach attach : purcInquiry.getAttachs()) {
|
|
|
- Attach newAttach = new Attach();
|
|
|
- newAttach.setDate(new Date());
|
|
|
- newAttach.setDescription(attach.getDescription());
|
|
|
- newAttach.setName(attach.getName());
|
|
|
- newAttach.setPath(attach.getPath());
|
|
|
- newAttach.setRelativeKey(attach.getRelativeKey());
|
|
|
- newAttach.setSize(attach.getSize());
|
|
|
- newAttach.setSourceId(attach.getSourceId());
|
|
|
- attachs.add(newAttach);
|
|
|
- }
|
|
|
- saleInquiry.setAttachs(attachs);
|
|
|
-
|
|
|
- }
|
|
|
- saleInquiry.setEnvironment(purcInquiry.getEnvironment());
|
|
|
- saleInquiry.setRemark(purcInquiry.getRemark());
|
|
|
- saleInquiry.setInquirytype(purcInquiry.getInquirytype());
|
|
|
- Set<PurchaseInquiryItem> items = new HashSet<PurchaseInquiryItem>();
|
|
|
- Short i = 0;
|
|
|
- if (null != purcInquiryItem) {
|
|
|
- PurchaseInquiryItem item = new PurchaseInquiryItem();
|
|
|
- Product product = productDao.findOne(purcInquiryItem.getProductId());
|
|
|
- item.setProduct(product);
|
|
|
- item.setInquiry(saleInquiry);
|
|
|
- item.setNumber(i);
|
|
|
- item.setCurrency(purcInquiryItem.getCurrency());
|
|
|
- item.setFromDate(new Date());
|
|
|
- item.setToDate(purcInquiryItem.getToDate());
|
|
|
- item.setTaxrate(purcInquiryItem.getTaxrate());
|
|
|
- item.setRemark(purcInquiryItem.getRemark());
|
|
|
- item.setProductId(purcInquiryItem.getProductId());
|
|
|
- item.setStatus((short) Status.NOT_REPLY.value());
|
|
|
- item.setVendUU(enuu);
|
|
|
- item.setVendUserUU(useruu);
|
|
|
- item.setSourceApp(purcInquiryItem.getSource());
|
|
|
- item.setCustLap(Constant.NO);
|
|
|
- item.setSendStatus((short) Status.NOT_UPLOAD.value());
|
|
|
- item.setSourceId(id);
|
|
|
- Set<PurchaseInquiryReply> replies = new HashSet<PurchaseInquiryReply>();
|
|
|
- PurchaseInquiryReply reply = new PurchaseInquiryReply();
|
|
|
- reply.setLapQty((double) 0);
|
|
|
- replies.add(reply);
|
|
|
- item.setReplies(replies);
|
|
|
- item.setNeedquantity(purcInquiryItem.getNeedquantity());
|
|
|
- item.setKind(INQUIRYKIND);
|
|
|
- items.add(item);
|
|
|
- i++;
|
|
|
- }
|
|
|
- List<PurchaseInquiryItem> purcitems = purchaseInquiryItemDao.save(items);
|
|
|
- if (purcitems.get(0).getId() != null) {
|
|
|
- map.put("success", "转客户询价单成功");
|
|
|
- map.put("id", purcitems.get(0).getInquiry().getId());
|
|
|
- } else {
|
|
|
- map.put("success", "转客户询价单失败");
|
|
|
- }
|
|
|
- } else {// 插入
|
|
|
- PurchaseInquiryItem purcItem = purchaseInquiryItemDao
|
|
|
- .findByVendUUAndSourceId(SystemSession.getUser().getEnterprise().getUu(), id);
|
|
|
- if (purcItem != null) {
|
|
|
- map.put("info", "询价单已存在");
|
|
|
- } else {
|
|
|
- if (!CollectionUtils.isEmpty(purcInquiry.getInquiryItems())) {
|
|
|
- if (null != purcInquiryItem) {
|
|
|
- // 涉及到级联存储及ERP转入单据的操作,用主表id存储存在问题,这里先用sql语句直接插入
|
|
|
- PurchaseInquiryItem item = new PurchaseInquiryItem();
|
|
|
- Product product = productDao.findOne(purcInquiryItem.getProductId());
|
|
|
- item.setProduct(product);
|
|
|
- item.setNumber((short) (purcInquiry.getInquiryItems().size() + 1));
|
|
|
- item.setCurrency(purcInquiryItem.getCurrency());
|
|
|
- item.setFromDate(new Date());
|
|
|
- item.setToDate(purcInquiryItem.getToDate());
|
|
|
- item.setTaxrate(purcInquiryItem.getTaxrate());
|
|
|
- item.setRemark(purcInquiryItem.getRemark());
|
|
|
- item.setProductId(purcInquiryItem.getProductId());
|
|
|
- item.setVendUU(SystemSession.getUser().getEnterprise().getUu());
|
|
|
- item.setVendUserUU(SystemSession.getUser().getUserUU());
|
|
|
- item.setSourceApp(purcInquiryItem.getSource());
|
|
|
- item.setStatus((short) Status.NOT_REPLY.value());
|
|
|
- item.setCustLap(Constant.NO);
|
|
|
- item.setSendStatus((short) Status.NOT_UPLOAD.value());
|
|
|
- item.setSourceId(id);
|
|
|
- item.setKind(INQUIRYKIND);
|
|
|
- item.setNeedquantity(purcInquiryItem.getNeedquantity());
|
|
|
- Set<PurchaseInquiryReply> replies = new HashSet<PurchaseInquiryReply>();
|
|
|
- List<PurchaseInquiryReply> purcReplies = new ArrayList<PurchaseInquiryReply>();
|
|
|
- PurchaseInquiryReply reply = new PurchaseInquiryReply();
|
|
|
- reply.setLapQty((double) 0);
|
|
|
- purcReplies.add(reply);
|
|
|
- purcReplies = purchaseInquiryReplyDao.save(purcReplies);
|
|
|
- replies.addAll(purcReplies);
|
|
|
- item.setReplies(replies);
|
|
|
- Long idid = commonDao.queryForObject("select purc$inquiryitems_seq.nextval from dual", Long.class);
|
|
|
- try {
|
|
|
- jdbcTemplate.update(
|
|
|
- "insert into purc$inquiryitems(id_id,id_number,id_currency,id_fromdate,id_todate,id_taxrate,id_prid,id_venduu,"
|
|
|
- + "id_venduseruu,id_sourceapp,id_status,id_custlap,id_sendstatus,id_sourceid,id_inid,id_kind) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)",
|
|
|
- idid, item.getNumber(), item.getCurrency(), item.getFromDate(), item.getToDate(),
|
|
|
- item.getTaxrate(), item.getProductId(), item.getVendUU(), item.getVendUserUU(),
|
|
|
- item.getSourceApp(), item.getStatus(), item.getCustLap(), item.getSendStatus(),
|
|
|
- item.getSourceId(), inquiry.getId(), inquiry.getKind());
|
|
|
- } catch (DataAccessException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- item = purchaseInquiryItemDao.findOne(idid);
|
|
|
- //回复清单更新
|
|
|
- if(replies.size() > 0) {
|
|
|
- for (PurchaseInquiryReply reply1 : replies) {
|
|
|
- jdbcTemplate.update("update purc$inquiryreply set ir_idid = " + idid + "where ir_id = " + reply1.getId());
|
|
|
- }
|
|
|
- }
|
|
|
- if (item != null) {
|
|
|
- map.put("success", "转客户询价单成功");
|
|
|
- map.put("id", item.getInquiry().getId());
|
|
|
- } else {
|
|
|
- map.put("success", "转客户询价单失败");
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- return map;
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public ModelMap getInquiryItemDetail(Long id) {
|
|
|
- ModelMap map = new ModelMap();
|
|
|
- PurcInquiryItemInfo inquiryItem = purcInquiryItemInfoDao.findOne(id);
|
|
|
- map.put("inquiryItem", inquiryItem);
|
|
|
- PurcInquiryItem purcInquiryItem = purcInquiryItemDao.findOne(id);
|
|
|
- PurcInquiry purcInquiry = purcInquiryItem.getInquiry();
|
|
|
+ Long custuseruu = purcInquiry.getRecorderUU();
|
|
|
+ if (null == custuseruu) {
|
|
|
+ Enterprise enterprise = enterpriseDao.findOne(purcInquiry.getEnUU());
|
|
|
+ custuseruu = enterprise.getEnAdminuu();
|
|
|
+ }
|
|
|
+ if (null != custuseruu) {
|
|
|
+ vendorDao.initVendorAndDistribute(purcInquiry.getEnUU(), custuseruu, enuu, useruu);
|
|
|
+ }
|
|
|
+ PurchaseInquiry saleInquiry = new PurchaseInquiry();
|
|
|
+ saleInquiry.setDate(new Date());
|
|
|
+ saleInquiry.setCode(purcInquiry.getCode());
|
|
|
+ saleInquiry.setEnUU(purcInquiry.getEnUU());
|
|
|
+ saleInquiry.setEnterprise(purcInquiry.getEnterprise());
|
|
|
+ saleInquiry.setRecorder(purcInquiry.getRecorder());
|
|
|
+ saleInquiry.setRecorderUU(purcInquiry.getRecorderUU());
|
|
|
+ saleInquiry.setAuditor(purcInquiry.getAuditor());
|
|
|
+ saleInquiry.setSourceApp(SOURCERAPP);
|
|
|
+ saleInquiry.setKind(INQUIRYKIND);
|
|
|
+ saleInquiry.setSourceId(purcInquiry.getId());
|
|
|
+ saleInquiry.setPriceType(purcInquiry.getPriceType());
|
|
|
+ saleInquiry.setInvoice(purcInquiry.getInvoice());
|
|
|
+ saleInquiry.setShip(purcInquiry.getShip());
|
|
|
+ saleInquiry.setEndDate(purcInquiry.getEndDate());
|
|
|
+ if (!CollectionUtils.isEmpty(purcInquiry.getAttachs())) {
|
|
|
+ Set<Attach> attachs = new HashSet<Attach>();
|
|
|
+ for (Attach attach : purcInquiry.getAttachs()) {
|
|
|
+ Attach newAttach = new Attach();
|
|
|
+ newAttach.setDate(new Date());
|
|
|
+ newAttach.setDescription(attach.getDescription());
|
|
|
+ newAttach.setName(attach.getName());
|
|
|
+ newAttach.setPath(attach.getPath());
|
|
|
+ newAttach.setRelativeKey(attach.getRelativeKey());
|
|
|
+ newAttach.setSize(attach.getSize());
|
|
|
+ newAttach.setSourceId(attach.getSourceId());
|
|
|
+ attachs.add(newAttach);
|
|
|
+ }
|
|
|
+ saleInquiry.setAttachs(attachs);
|
|
|
+
|
|
|
+ }
|
|
|
+ saleInquiry.setEnvironment(purcInquiry.getEnvironment());
|
|
|
+ saleInquiry.setRemark(purcInquiry.getRemark());
|
|
|
+ saleInquiry.setInquirytype(purcInquiry.getInquirytype());
|
|
|
+ Set<PurchaseInquiryItem> items = new HashSet<PurchaseInquiryItem>();
|
|
|
+ Short i = 0;
|
|
|
+ if (null != purcInquiryItem) {
|
|
|
+ PurchaseInquiryItem item = new PurchaseInquiryItem();
|
|
|
+ Product product = productDao.findOne(purcInquiryItem.getProductId());
|
|
|
+ item.setProduct(product);
|
|
|
+ item.setInquiry(saleInquiry);
|
|
|
+ item.setNumber(i);
|
|
|
+ item.setCurrency(purcInquiryItem.getCurrency());
|
|
|
+ item.setFromDate(new Date());
|
|
|
+ item.setToDate(purcInquiryItem.getToDate());
|
|
|
+ item.setTaxrate(purcInquiryItem.getTaxrate());
|
|
|
+ item.setRemark(purcInquiryItem.getRemark());
|
|
|
+ item.setProductId(purcInquiryItem.getProductId());
|
|
|
+ item.setStatus((short) Status.NOT_REPLY.value());
|
|
|
+ item.setVendUU(enuu);
|
|
|
+ item.setVendUserUU(useruu);
|
|
|
+ item.setSourceApp(purcInquiryItem.getSource());
|
|
|
+ item.setCustLap(Constant.NO);
|
|
|
+ item.setSendStatus((short) Status.NOT_UPLOAD.value());
|
|
|
+ item.setSourceId(id);
|
|
|
+ Set<PurchaseInquiryReply> replies = new HashSet<PurchaseInquiryReply>();
|
|
|
+ PurchaseInquiryReply reply = new PurchaseInquiryReply();
|
|
|
+ reply.setLapQty((double) 0);
|
|
|
+ replies.add(reply);
|
|
|
+ item.setReplies(replies);
|
|
|
+ item.setNeedquantity(purcInquiryItem.getNeedquantity());
|
|
|
+ item.setKind(INQUIRYKIND);
|
|
|
+ items.add(item);
|
|
|
+ i++;
|
|
|
+ }
|
|
|
+ List<PurchaseInquiryItem> purcitems = purchaseInquiryItemDao.save(items);
|
|
|
+ if (purcitems.get(0).getId() != null) {
|
|
|
+ map.put("success", "转客户询价单成功");
|
|
|
+ map.put("id", purcitems.get(0).getInquiry().getId());
|
|
|
+ } else {
|
|
|
+ map.put("success", "转客户询价单失败");
|
|
|
+ }
|
|
|
+ } else {// 插入
|
|
|
+ PurchaseInquiryItem purcItem = purchaseInquiryItemDao
|
|
|
+ .findByVendUUAndSourceId(SystemSession.getUser().getEnterprise().getUu(), id);
|
|
|
+ if (purcItem != null) {
|
|
|
+ map.put("info", "询价单已存在");
|
|
|
+ } else {
|
|
|
+ if (!CollectionUtils.isEmpty(purcInquiry.getInquiryItems())) {
|
|
|
+ if (null != purcInquiryItem) {
|
|
|
+ // 涉及到级联存储及ERP转入单据的操作,用主表id存储存在问题,这里先用sql语句直接插入
|
|
|
+ PurchaseInquiryItem item = new PurchaseInquiryItem();
|
|
|
+ Product product = productDao.findOne(purcInquiryItem.getProductId());
|
|
|
+ item.setProduct(product);
|
|
|
+ item.setNumber((short) (purcInquiry.getInquiryItems().size() + 1));
|
|
|
+ item.setCurrency(purcInquiryItem.getCurrency());
|
|
|
+ item.setFromDate(new Date());
|
|
|
+ item.setToDate(purcInquiryItem.getToDate());
|
|
|
+ item.setTaxrate(purcInquiryItem.getTaxrate());
|
|
|
+ item.setRemark(purcInquiryItem.getRemark());
|
|
|
+ item.setProductId(purcInquiryItem.getProductId());
|
|
|
+ item.setVendUU(SystemSession.getUser().getEnterprise().getUu());
|
|
|
+ item.setVendUserUU(SystemSession.getUser().getUserUU());
|
|
|
+ item.setSourceApp(purcInquiryItem.getSource());
|
|
|
+ item.setStatus((short) Status.NOT_REPLY.value());
|
|
|
+ item.setCustLap(Constant.NO);
|
|
|
+ item.setSendStatus((short) Status.NOT_UPLOAD.value());
|
|
|
+ item.setSourceId(id);
|
|
|
+ item.setKind(INQUIRYKIND);
|
|
|
+ item.setNeedquantity(purcInquiryItem.getNeedquantity());
|
|
|
+ Set<PurchaseInquiryReply> replies = new HashSet<PurchaseInquiryReply>();
|
|
|
+ List<PurchaseInquiryReply> purcReplies = new ArrayList<PurchaseInquiryReply>();
|
|
|
+ PurchaseInquiryReply reply = new PurchaseInquiryReply();
|
|
|
+ reply.setLapQty((double) 0);
|
|
|
+ purcReplies.add(reply);
|
|
|
+ purcReplies = purchaseInquiryReplyDao.save(purcReplies);
|
|
|
+ replies.addAll(purcReplies);
|
|
|
+ item.setReplies(replies);
|
|
|
+ Long idid = commonDao.queryForObject("select purc$inquiryitems_seq.nextval from dual", Long.class);
|
|
|
+ try {
|
|
|
+ jdbcTemplate.update(
|
|
|
+ "insert into purc$inquiryitems(id_id,id_number,id_currency,id_fromdate,id_todate,id_taxrate,id_prid,id_venduu,"
|
|
|
+ + "id_venduseruu,id_sourceapp,id_status,id_custlap,id_sendstatus,id_sourceid,id_inid,id_kind) values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)",
|
|
|
+ idid, item.getNumber(), item.getCurrency(), item.getFromDate(), item.getToDate(),
|
|
|
+ item.getTaxrate(), item.getProductId(), item.getVendUU(), item.getVendUserUU(),
|
|
|
+ item.getSourceApp(), item.getStatus(), item.getCustLap(), item.getSendStatus(),
|
|
|
+ item.getSourceId(), inquiry.getId(), inquiry.getKind());
|
|
|
+ } catch (DataAccessException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ item = purchaseInquiryItemDao.findOne(idid);
|
|
|
+ //回复清单更新
|
|
|
+ if (replies.size() > 0) {
|
|
|
+ for (PurchaseInquiryReply reply1 : replies) {
|
|
|
+ jdbcTemplate.update("update purc$inquiryreply set ir_idid = " + idid + "where ir_id = " + reply1.getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (item != null) {
|
|
|
+ map.put("success", "转客户询价单成功");
|
|
|
+ map.put("id", item.getInquiry().getId());
|
|
|
+ } else {
|
|
|
+ map.put("success", "转客户询价单失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ModelMap getInquiryItemDetail(Long id) {
|
|
|
+ ModelMap map = new ModelMap();
|
|
|
+ PurcInquiryItemInfo inquiryItem = purcInquiryItemInfoDao.findOne(id);
|
|
|
+ map.put("inquiryItem", inquiryItem);
|
|
|
+ PurcInquiryItem purcInquiryItem = purcInquiryItemDao.findOne(id);
|
|
|
+ PurcInquiry purcInquiry = purcInquiryItem.getInquiry();
|
|
|
// PurchaseInquiry inquiry = purchaseInquiryDao.findBySourceIdAndSourceApp(purcInquiry.getId(), SOURCERAPP);
|
|
|
- PublicInquiry inquiry = publicInquiryDao.findBySourceIdAndSourceApp(purcInquiry.getId(), SOURCERAPP);
|
|
|
- if (null != inquiry) {
|
|
|
+ PublicInquiry inquiry = publicInquiryDao.findBySourceIdAndSourceApp(purcInquiry.getId(), SOURCERAPP);
|
|
|
+ if (null != inquiry) {
|
|
|
// PurchaseInquiryItem purcItem = purchaseInquiryItemDao
|
|
|
// .findByVendUUAndSourceId(SystemSession.getUser().getEnterprise().getUu(), id);
|
|
|
- PublicInquiryItem item = publicInquiryItemDao.findByVendUUAndSourceId(SystemSession.getUser().getEnterprise().getUu(), id);
|
|
|
- if (item != null) {
|
|
|
- map.put("id", inquiry.getId());
|
|
|
- }
|
|
|
- }
|
|
|
- return map;
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public InquiryDetailInfo getInquiryDetail(Long id) {
|
|
|
- PurchaseInquiryInfo inquiry = purchaseInquiryInfoDao.findOne(id);
|
|
|
- InquiryDetailInfo inquiryInfo = new InquiryDetailInfo();
|
|
|
- if (inquiry != null) {
|
|
|
- inquiryInfo.setAttachs(inquiry.getAttachs());
|
|
|
- inquiryInfo.setAuditor(inquiry.getAuditor());
|
|
|
- inquiryInfo.setCheck(inquiry.getCheck());
|
|
|
- inquiryInfo.setCode(inquiry.getCode());
|
|
|
- inquiryInfo.setDate(inquiry.getDate());
|
|
|
- inquiryInfo.setEndDate(inquiry.getEndDate());
|
|
|
- inquiryInfo.setEnterprise(inquiry.getEnterprise());
|
|
|
- inquiryInfo.setEnUU(inquiry.getEnUU());
|
|
|
- inquiryInfo.setEnvironment(inquiry.getEnvironment());
|
|
|
- inquiryInfo.setId(inquiry.getId());
|
|
|
- inquiryInfo.setIsOpen(inquiry.getIsOpen());
|
|
|
- inquiryInfo.setOverdue(inquiry.getOverdue());
|
|
|
- inquiryInfo.setPriceType(inquiry.getPriceType());
|
|
|
- inquiryInfo.setRecorder(inquiry.getRecorder());
|
|
|
- inquiryInfo.setRecorderUU(inquiry.getRecorderUU());
|
|
|
- inquiryInfo.setRemark(inquiry.getRemark());
|
|
|
- inquiryInfo.setSourceApp(inquiry.getSourceApp());
|
|
|
- inquiryInfo.setSourceId(inquiry.getSourceId());
|
|
|
- inquiryInfo.setShip(inquiry.getShip());
|
|
|
- inquiryInfo.setInvoice(inquiry.getInvoice());
|
|
|
- inquiryInfo.setInquirytype(inquiry.getInquirytype());
|
|
|
- Set<Long> ids = new HashSet<Long>();
|
|
|
- List<Long> idStrings = new ArrayList<>();
|
|
|
- Set<InquiryProductInfo> products = new HashSet<InquiryProductInfo>();
|
|
|
- if (!CollectionUtils.isEmpty(inquiry.getInquiryItems())) {
|
|
|
- for (PurchaseInquiryItemInfo item : inquiry.getInquiryItems()) {
|
|
|
- idStrings.add(item.getProductId());
|
|
|
- ids.addAll(idStrings);
|
|
|
- }
|
|
|
- }
|
|
|
- if (!CollectionUtils.isEmpty(ids)) {
|
|
|
- for (Long idInfo : ids) {
|
|
|
- InquiryProductInfo productInfo = new InquiryProductInfo();
|
|
|
- Set<PurchaseInquiryItemInfo> items = new HashSet<PurchaseInquiryItemInfo>();
|
|
|
- Product product = productDao.findOne(idInfo);
|
|
|
- productInfo.setBrand(product.getBrand());
|
|
|
- productInfo.setId(product.getId());
|
|
|
- productInfo.setSpec(product.getSpec());
|
|
|
- productInfo.setCode(product.getCode());
|
|
|
- productInfo.setTitle(product.getTitle());
|
|
|
- productInfo.setUnit(product.getUnit());
|
|
|
- for (PurchaseInquiryItemInfo item : inquiry.getInquiryItems()) {
|
|
|
- if (item.getProductId().equals(idInfo)) {
|
|
|
- items.add(item);
|
|
|
- }
|
|
|
- }
|
|
|
- productInfo.setInquiryItems(items);
|
|
|
- products.add(productInfo);
|
|
|
- inquiryInfo.setProducts(products);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- return inquiryInfo;
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public ModelMap releaseByWorkbook(Workbook workbook) {
|
|
|
- ModelMap modelMap = new ModelMap();
|
|
|
- List<String> alters = new ArrayList<String>();
|
|
|
- List<PurcInquiryProductInfo> infos = new ArrayList<PurcInquiryProductInfo>();
|
|
|
- Sheet sheet = workbook.getSheetAt(0);
|
|
|
- int rowNum = sheet.getLastRowNum();
|
|
|
- Row headerRow = sheet.getRow(0);
|
|
|
- int total = 0;
|
|
|
- if (headerRow != null) {
|
|
|
- for (int r = 3; r <= rowNum; r++) {
|
|
|
- Row row = sheet.getRow(r);
|
|
|
- if (row != null && row.getCell(0) != null && row.getCell(1).getCellType() != Cell.CELL_TYPE_BLANK) {
|
|
|
- total++;
|
|
|
- PurcInquiryProductInfo info = new PurcInquiryProductInfo();
|
|
|
- // 物料编号
|
|
|
- if (row.getCell(0) != null) {
|
|
|
- row.getCell(0).setCellType(Cell.CELL_TYPE_STRING);
|
|
|
- info.setProdCode(row.getCell(0).getStringCellValue().trim());
|
|
|
- }
|
|
|
-
|
|
|
- // 型号
|
|
|
- if (row.getCell(1) != null) {
|
|
|
- row.getCell(1).setCellType(Cell.CELL_TYPE_STRING);
|
|
|
- info.setCmpCode(row.getCell(1).getStringCellValue().trim());
|
|
|
- }
|
|
|
-
|
|
|
- // 产品名称
|
|
|
- if (row.getCell(2) != null) {
|
|
|
- row.getCell(2).setCellType(Cell.CELL_TYPE_STRING);
|
|
|
- info.setProdTitle(row.getCell(2).getStringCellValue().trim());
|
|
|
- }
|
|
|
-
|
|
|
- // 品牌
|
|
|
- if (row.getCell(3) != null) {
|
|
|
- row.getCell(3).setCellType(Cell.CELL_TYPE_STRING);
|
|
|
- info.setInbrand(row.getCell(3).getStringCellValue());
|
|
|
- }
|
|
|
-
|
|
|
- // 单位
|
|
|
- if (row.getCell(4) != null) {
|
|
|
- row.getCell(4).setCellType(Cell.CELL_TYPE_STRING);
|
|
|
- info.setUnit(row.getCell(4).getStringCellValue());
|
|
|
- }
|
|
|
-
|
|
|
- // 价格有效期
|
|
|
- if (row.getCell(5) != null && row.getCell(5).getDateCellValue() != null) {
|
|
|
- Date date = row.getCell(5).getDateCellValue();
|
|
|
- info.setToDate(date);
|
|
|
- }
|
|
|
- if (alters.size() > 0) {
|
|
|
- modelMap.put("alters", alters);
|
|
|
- }
|
|
|
- if (info.getProdCode() != null) {
|
|
|
- modelMap.put("total", total);
|
|
|
- modelMap.put("success", total - alters.size());
|
|
|
- infos.add(info);
|
|
|
- modelMap.put("items", infos);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- return modelMap;
|
|
|
- }
|
|
|
+ PublicInquiryItem item = publicInquiryItemDao.findByVendUUAndSourceId(SystemSession.getUser().getEnterprise().getUu(), id);
|
|
|
+ if (item != null) {
|
|
|
+ map.put("id", inquiry.getId());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return map;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public InquiryDetailInfo getInquiryDetail(Long id) {
|
|
|
+ PurchaseInquiryInfo inquiry = purchaseInquiryInfoDao.findOne(id);
|
|
|
+ InquiryDetailInfo inquiryInfo = new InquiryDetailInfo();
|
|
|
+ if (inquiry != null) {
|
|
|
+ inquiryInfo.setAttachs(inquiry.getAttachs());
|
|
|
+ inquiryInfo.setAuditor(inquiry.getAuditor());
|
|
|
+ inquiryInfo.setCheck(inquiry.getCheck());
|
|
|
+ inquiryInfo.setCode(inquiry.getCode());
|
|
|
+ inquiryInfo.setDate(inquiry.getDate());
|
|
|
+ inquiryInfo.setEndDate(inquiry.getEndDate());
|
|
|
+ inquiryInfo.setEnterprise(inquiry.getEnterprise());
|
|
|
+ inquiryInfo.setEnUU(inquiry.getEnUU());
|
|
|
+ inquiryInfo.setEnvironment(inquiry.getEnvironment());
|
|
|
+ inquiryInfo.setId(inquiry.getId());
|
|
|
+ inquiryInfo.setIsOpen(inquiry.getIsOpen());
|
|
|
+ inquiryInfo.setOverdue(inquiry.getOverdue());
|
|
|
+ inquiryInfo.setPriceType(inquiry.getPriceType());
|
|
|
+ inquiryInfo.setRecorder(inquiry.getRecorder());
|
|
|
+ inquiryInfo.setRecorderUU(inquiry.getRecorderUU());
|
|
|
+ inquiryInfo.setRemark(inquiry.getRemark());
|
|
|
+ inquiryInfo.setSourceApp(inquiry.getSourceApp());
|
|
|
+ inquiryInfo.setSourceId(inquiry.getSourceId());
|
|
|
+ inquiryInfo.setShip(inquiry.getShip());
|
|
|
+ inquiryInfo.setInvoice(inquiry.getInvoice());
|
|
|
+ inquiryInfo.setInquirytype(inquiry.getInquirytype());
|
|
|
+ Set<Long> ids = new HashSet<Long>();
|
|
|
+ List<Long> idStrings = new ArrayList<>();
|
|
|
+ Set<InquiryProductInfo> products = new HashSet<InquiryProductInfo>();
|
|
|
+ if (!CollectionUtils.isEmpty(inquiry.getInquiryItems())) {
|
|
|
+ for (PurchaseInquiryItemInfo item : inquiry.getInquiryItems()) {
|
|
|
+ idStrings.add(item.getProductId());
|
|
|
+ ids.addAll(idStrings);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!CollectionUtils.isEmpty(ids)) {
|
|
|
+ for (Long idInfo : ids) {
|
|
|
+ InquiryProductInfo productInfo = new InquiryProductInfo();
|
|
|
+ Set<PurchaseInquiryItemInfo> items = new HashSet<PurchaseInquiryItemInfo>();
|
|
|
+ Product product = productDao.findOne(idInfo);
|
|
|
+ productInfo.setBrand(product.getBrand());
|
|
|
+ productInfo.setId(product.getId());
|
|
|
+ productInfo.setSpec(product.getSpec());
|
|
|
+ productInfo.setCode(product.getCode());
|
|
|
+ productInfo.setTitle(product.getTitle());
|
|
|
+ productInfo.setUnit(product.getUnit());
|
|
|
+ for (PurchaseInquiryItemInfo item : inquiry.getInquiryItems()) {
|
|
|
+ if (item.getProductId().equals(idInfo)) {
|
|
|
+ items.add(item);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ productInfo.setInquiryItems(items);
|
|
|
+ products.add(productInfo);
|
|
|
+ inquiryInfo.setProducts(products);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return inquiryInfo;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ModelMap releaseByWorkbook(Workbook workbook) {
|
|
|
+ ModelMap modelMap = new ModelMap();
|
|
|
+ List<String> alters = new ArrayList<String>();
|
|
|
+ List<PurcInquiryProductInfo> infos = new ArrayList<PurcInquiryProductInfo>();
|
|
|
+ Sheet sheet = workbook.getSheetAt(0);
|
|
|
+ int rowNum = sheet.getLastRowNum();
|
|
|
+ Row headerRow = sheet.getRow(0);
|
|
|
+ int total = 0;
|
|
|
+ if (headerRow != null) {
|
|
|
+ for (int r = 3; r <= rowNum; r++) {
|
|
|
+ Row row = sheet.getRow(r);
|
|
|
+ if (row != null && row.getCell(0) != null && row.getCell(1).getCellType() != Cell.CELL_TYPE_BLANK) {
|
|
|
+ total++;
|
|
|
+ PurcInquiryProductInfo info = new PurcInquiryProductInfo();
|
|
|
+ // 物料编号
|
|
|
+ if (row.getCell(0) != null) {
|
|
|
+ row.getCell(0).setCellType(Cell.CELL_TYPE_STRING);
|
|
|
+ info.setProdCode(row.getCell(0).getStringCellValue().trim());
|
|
|
+ }
|
|
|
+
|
|
|
+ // 型号
|
|
|
+ if (row.getCell(1) != null) {
|
|
|
+ row.getCell(1).setCellType(Cell.CELL_TYPE_STRING);
|
|
|
+ info.setCmpCode(row.getCell(1).getStringCellValue().trim());
|
|
|
+ }
|
|
|
+
|
|
|
+ // 产品名称
|
|
|
+ if (row.getCell(2) != null) {
|
|
|
+ row.getCell(2).setCellType(Cell.CELL_TYPE_STRING);
|
|
|
+ info.setProdTitle(row.getCell(2).getStringCellValue().trim());
|
|
|
+ }
|
|
|
+
|
|
|
+ // 品牌
|
|
|
+ if (row.getCell(3) != null) {
|
|
|
+ row.getCell(3).setCellType(Cell.CELL_TYPE_STRING);
|
|
|
+ info.setInbrand(row.getCell(3).getStringCellValue());
|
|
|
+ }
|
|
|
+
|
|
|
+ // 单位
|
|
|
+ if (row.getCell(4) != null) {
|
|
|
+ row.getCell(4).setCellType(Cell.CELL_TYPE_STRING);
|
|
|
+ info.setUnit(row.getCell(4).getStringCellValue());
|
|
|
+ }
|
|
|
+
|
|
|
+ // 价格有效期
|
|
|
+ if (row.getCell(5) != null && row.getCell(5).getDateCellValue() != null) {
|
|
|
+ Date date = row.getCell(5).getDateCellValue();
|
|
|
+ info.setToDate(date);
|
|
|
+ }
|
|
|
+ if (alters.size() > 0) {
|
|
|
+ modelMap.put("alters", alters);
|
|
|
+ }
|
|
|
+ if (info.getProdCode() != null) {
|
|
|
+ modelMap.put("total", total);
|
|
|
+ modelMap.put("success", total - alters.size());
|
|
|
+ infos.add(info);
|
|
|
+ modelMap.put("items", infos);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return modelMap;
|
|
|
+ }
|
|
|
|
|
|
}
|