Explorar o código

feat: 增加对账业务给erp操作的接口

suntg %!s(int64=7) %!d(string=hai) anos
pai
achega
540671fe6a

+ 597 - 0
src/main/java/com/uas/platform/b2b/erp/controller/operation/SaleApCheckController.java

@@ -0,0 +1,597 @@
+package com.uas.platform.b2b.erp.controller.operation;
+
+import com.alibaba.fastjson.JSONObject;
+import com.uas.platform.b2b.model.*;
+import com.uas.platform.b2b.search.SearchService;
+import com.uas.platform.b2b.service.*;
+import com.uas.platform.b2b.support.JxlsExcelView;
+import com.uas.platform.b2b.support.SPageUtils;
+import com.uas.platform.b2b.support.SystemSession;
+import com.uas.platform.b2b.support.UsageBufferedLogger;
+import com.uas.platform.core.logging.BufferedLoggerManager;
+import com.uas.platform.core.model.Constant;
+import com.uas.platform.core.model.PageInfo;
+import com.uas.platform.core.model.PageParams;
+import com.uas.platform.core.persistence.criteria.CriterionExpression;
+import com.uas.platform.core.persistence.criteria.LogicalExpression;
+import com.uas.platform.core.persistence.criteria.SimpleExpression;
+import com.uas.platform.core.util.serializer.FlexJsonUtils;
+import com.uas.platform.core.web.bind.RequestState;
+import com.uas.search.b2b.model.MultiValue;
+import com.uas.search.b2b.model.SPage;
+import com.uas.search.b2b.model.Sort;
+import com.uas.search.b2b.model.Sort.Type;
+import com.uas.search.b2b.util.SearchConstants;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.http.HttpStatus;
+import org.springframework.http.ResponseEntity;
+import org.springframework.ui.ModelMap;
+import org.springframework.util.CollectionUtils;
+import org.springframework.util.StringUtils;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.servlet.ModelAndView;
+
+import java.text.SimpleDateFormat;
+import java.util.*;
+
+/**
+ * 应收对账单
+ * <br/>给erp saas 直接调用进行操作的接口,不用于数据传输
+ *
+ * @author suntg
+ * @date 2019-1-25 09:34:16
+ */
+@SuppressWarnings("deprecation")
+@RestController("erp.SaleApCheckController")
+@RequestMapping("/erp/operation/sale/apCheck")
+public class SaleApCheckController {
+
+	@Autowired
+	private ErpProdIODetailService erpProdIODetailService;
+
+	@Autowired
+    private PurchaseApCheckService purchaseApCheckService;
+
+	@Autowired
+	private VendorService vendorService;
+
+	@Autowired
+	private UserService userService;
+
+	@Autowired
+	private SearchService searchService;
+
+	@Autowired
+    private OrderRedDotService redDotService;
+
+	private final static UsageBufferedLogger LOGGER = BufferedLoggerManager.getLogger(UsageBufferedLogger.class);
+
+	/**
+	 * 打印权限判断
+	 *
+	 * @return ModelMap
+	 */
+	@RequestMapping(value = "/printCount/permission", method = RequestMethod.POST)
+	public ModelMap printPermission() {
+		return new ModelMap("success", true);
+	}
+
+	/**
+	 * 打印对账单,增加打印次数
+	 * 
+	 * @param id 对账单id
+	 * @return ResponseEntity
+	 */
+	@RequestMapping(value = "/printCount/{id}", method = RequestMethod.POST)
+	public ResponseEntity<String> printCount(@PathVariable("id") Long id) {
+		purchaseApCheckService.print(id);
+		LOGGER.log("应收对账单", "打印应付对账单", id.toString());
+		return new ResponseEntity<>(HttpStatus.OK);
+	}
+
+	/**
+	 * 作废应收对账单
+     *
+	 * @param id 对账单id
+     * @return ModelMap
+	 */
+	@RequestMapping("/operation/cancel")
+	public ModelMap cancelApCheck(Long id) {
+		boolean result = purchaseApCheckService.cancelApCheck(id);
+		LOGGER.log("应收对账单", "作废应收对账单", result ? "成功" : "失败", "", id);
+		return new ModelMap("result", result);
+	}
+
+	/**
+	 * 得到所有的客户信息便于筛选
+	 * 
+	 * @return Set<Object> Object 客户信息
+	 */
+	@RequestMapping(value = "/getAllCustomers", method = RequestMethod.GET)
+	public Set<Object> getAllApChecksCustomers() {
+		Set<Object> set = new HashSet<>();
+		// 判断当前用户是否被客户分配
+		SearchFilter filter = userService.distribute();
+		// 不是管理员也没被分配客户是直接返回空
+		if (filter != null && filter.getDistribute() == null) {
+			return null;
+		}
+		Set<Role> roles = SystemSession.getUser().getRoles();
+		boolean isSys = false;
+		for (Role role : roles) {
+			if (role.getIssys() == 1) {
+				isSys = true;
+			}
+		}
+		// 不是管理员,被分配客户时
+		if (!SystemSession.getUser().isSys() && !isSys) {
+			List<Vendor> vendors = userService.findChooseVendor(SystemSession.getUser().getUserUU());
+			if (!CollectionUtils.isEmpty(vendors)) {
+				for (Vendor v : vendors) {
+					if (v.getApcheck() != null) {
+						// 只有开通了B2B对账的才筛选
+						if (v.getApcheck().equals(Constant.YES)) {
+							// 这里添加客户名称
+							set.add(v.getMyEnterprise().getEnName());
+						}
+					}
+				}
+			} else {
+				return null;
+			}
+		} else {
+			List<Vendor> vendors = vendorService.findMyCustomers();
+			for (Vendor vendor : vendors) {
+				if (vendor.getApcheck() != null) {
+					// 只有开通了B2B对账的才筛选
+					if (vendor.getApcheck().equals(Constant.YES)) {
+						set.add(vendor.getMyEnterprise().getEnName());
+					}
+				}
+			}
+		}
+        LOGGER.log("应收对账单", "获取客户信息", "获取所有符合条件的客户");
+        return set;
+	}
+
+	/**
+	 * 通过日期筛选,筛选出超出默认日期的单据
+	 * 
+	 * @param fromDate 开始时间
+	 * @param endDate 截止时间
+	 * @return List<ErpProdIo>
+	 */
+	@RequestMapping(value = "/getAllByKeywords", method = RequestMethod.GET)
+	public ErpProdIo getAllApchecksByDate(Long fromDate, Long endDate, ApcheckKeyWord searchKeyWord, String checkDate) throws InterruptedException {
+		List<Long> distributes = null;
+		// 判断当前用户是否被客户分配
+		if (!SystemSession.getUser().isSys()) {
+			List<Vendor> vendors = userService.findChooseVendor(SystemSession.getUser().getUserUU());
+			distributes = new ArrayList<>();
+			if (!CollectionUtils.isEmpty(vendors)) {
+				for (Vendor v : vendors) {
+					distributes.add(v.getMyEnUU());
+				} 
+			} else {
+				return new ErpProdIo();
+			}
+		}
+		return erpProdIODetailService.findXlsApChecks(distributes, searchKeyWord, fromDate, endDate, checkDate);
+	}
+
+    /**
+     * 获取客户
+     * @param keyword 关键字
+     * @param params 分页参数
+     * @param checkDate 筛选月份
+     * @return 符合条件的客户信息
+     */
+    @RequestMapping(value = "/customer", method = RequestMethod.GET)
+    public SPage<Vendor> getCustomers(PageParams params, String keyword, String checkDate, String searchFilter) throws InterruptedException {
+        LOGGER.log("应收对账单", "获取客户信息", "获取所有符合条件的客户");
+        SearchFilter filter = JSONObject.parseObject(searchFilter, SearchFilter.class);
+        return purchaseApCheckService.getCustomerInfo(params, keyword, checkDate, filter.getFromDate(), filter.getEndDate());
+    }
+
+	/**
+	 * 保存生成的应收对账单主记录
+     *
+     * @param json 前台对账json
+     * @return ModelMap 封装成功信息以及异常信息
+	 */
+	@RequestMapping(value = "/operation/save", method = RequestMethod.POST)
+	public ModelMap saveApCheck(@RequestBody String json) {
+		PurchaseApCheck apCheck = FlexJsonUtils.fromJson(json, PurchaseApCheck.class);
+		return purchaseApCheckService.checkCount(apCheck);
+	}
+
+    /**
+	 * 生成应收对账单的同时更新明细行来源表中,物料已转数
+     *
+	 * @param json 对账数据
+	 */
+	@RequestMapping(value = "/update", method = RequestMethod.POST)
+	public void updateYCheckQty(@RequestBody String json) {
+		List<HashMap<String, Object>> list = FlexJsonUtils.fromJsonArray(json, HashMap.class);
+		purchaseApCheckService.updateYCheckQty(list);
+        LOGGER.log("应收对账单", "生成应收对账单的同时更新明细行来源表中,物料已转数");
+    }
+
+	/**
+	 * 获得应收对账单,对应id
+	 * 
+	 * @param id 对账单id
+	 * @return  PurchaseApCheck
+     * <pre>
+     *     @see PurchaseApCheck
+     * </pre>
+	 */
+	@RequestMapping(value = "/{id}/info", method = RequestMethod.GET)
+	public PurchaseApCheck getCreatedPurchaseApCheckById(@PathVariable("id") Long id) {
+		LOGGER.log("应收对账单", "查看单个应收对账单", null, null, id);
+		return purchaseApCheckService.findById(id);
+	}
+
+	/**
+	 * 删除最新生成未提交的应收对账单
+     * @param id 对账单ID
+	 */
+	@RequestMapping(value = "/operation/deleteApCheck", method = RequestMethod.POST)
+	public void deleteApCheck(Long id) {
+		purchaseApCheckService.deleteApCheck(id);
+        LOGGER.log("应收对账单", "删除最新生成未提交的应收对账单", null, null, id);
+    }
+
+	/**
+	 * 提交生成的应收对账单
+     * @param id 对账单id
+     * @return ModelMap result true
+	 */
+	@RequestMapping(value = "/operation/updateStatus", method = RequestMethod.POST)
+	public ModelMap updateApCheckStatus(Long id) {
+		ModelMap map = new ModelMap();
+		map.put("result", purchaseApCheckService.updateApCheckStatus(id));
+        LOGGER.log("应收对账单", "提交生成的应收对账单", null, null, id);
+        return map;
+	}
+
+	/**
+	 * 作为卖家,获取应收对账单(全部)
+	 * 
+	 * @param params 分页参数
+	 * @param searchFilter 搜索过滤条件
+	 * @return SPage<PurchaseApCheck>
+	 */
+	@RequestMapping(value = "/info/search", method = RequestMethod.GET)
+	public SPage<PurchaseApCheck> getPurchaseApChecks(PageParams params, String searchFilter) {
+		LOGGER.log("应收对账单", "作为买家,获取全部应收对账单");
+		SearchFilter filter = JSONObject.parseObject(searchFilter, SearchFilter.class);
+		if (StringUtils.isEmpty(filter.getKeyword())) {
+            PageInfo pageInfo = new PageInfo(params);
+            pageInfo.filter("enUu", SystemSession.getUser().getEnterprise().getUu());
+            SearchFilter distribute = userService.distribute();
+            if (distribute != null && distribute.getDistribute() == null) {
+                return null;
+            }
+            if (distribute != null && !CollectionUtils.isEmpty(distribute.getDistribute())) {
+                filter.setDistribute(distribute.getDistribute());
+            }
+            return SPageUtils.covertSPage(purchaseApCheckService.findAllByPageInfo(pageInfo, null, filter));
+        }
+		com.uas.search.b2b.model.PageParams pageParams = distribute(params, searchFilter);
+		return searchService.searchPurchaseApCheckIds(filter.getKeyword(), pageParams);
+	}
+
+	/**
+	 * 作为卖家,获取应收对账单(未对账)
+     *
+     * @param params 分页参数
+     * @param searchFilter 搜索过滤条件
+     * @return SPage<PurchaseApCheck>
+	 */
+	@RequestMapping(value = "/info/search", params = RequestState.TODO, method = RequestMethod.GET)
+	public SPage<PurchaseApCheck> getTodoApChecks(PageParams params, String searchFilter) {
+		LOGGER.log("应收对账单", "获取未对账应收对账单");
+        SearchFilter filter = JSONObject.parseObject(searchFilter, SearchFilter.class);
+        if (StringUtils.isEmpty(filter.getKeyword())) {
+            PageInfo pageInfo = new PageInfo(params);
+            pageInfo.filter("enUu", SystemSession.getUser().getEnterprise().getUu());
+            pageInfo.filter("checkStatus", "未对账");
+            SearchFilter distribute = userService.distribute();
+            if (distribute != null && distribute.getDistribute() == null) {
+                return null;
+            }
+            if (distribute != null && !CollectionUtils.isEmpty(distribute.getDistribute())) {
+                filter.setDistribute(distribute.getDistribute());
+            }
+            return SPageUtils.covertSPage(purchaseApCheckService.findAllByPageInfo(pageInfo, null, filter));
+        }
+		com.uas.search.b2b.model.PageParams pageParams = distribute(params, searchFilter);
+        pageParams.getFilters().put("pa_checkstatus", "未对账");
+		return searchService.searchPurchaseApCheckIds(filter.getKeyword(), pageParams);
+	}
+
+    /**
+	 * 作为卖家,获取应收对账单(已确认)
+     *
+     * @param params 分页参数
+     * @param searchFilter 搜索过滤条件
+     * @return SPage<PurchaseApCheck>
+	 */
+	@RequestMapping(value = "/info/search", params = RequestState.DONE, method = RequestMethod.GET)
+	public SPage<PurchaseApCheck> getDoneApChecks(PageParams params, String searchFilter) {
+		LOGGER.log("应收对账单", "获取已对账应收对账单");
+        SearchFilter filter = JSONObject.parseObject(searchFilter, SearchFilter.class);
+        if (StringUtils.isEmpty(filter.getKeyword())) {
+            PageInfo pageInfo = new PageInfo(params);
+            pageInfo.filter("enUu", SystemSession.getUser().getEnterprise().getUu());
+            SearchFilter distribute = userService.distribute();
+            if (distribute != null && distribute.getDistribute() == null) {
+                return null;
+            }
+            if (distribute != null && !CollectionUtils.isEmpty(distribute.getDistribute())) {
+                filter.setDistribute(distribute.getDistribute());
+            }
+            SimpleExpression agreed = new SimpleExpression("checkStatus", "已确认", CriterionExpression.Operator.EQ, true);
+            SimpleExpression haveDone = new SimpleExpression("checkStatus", "未对账", CriterionExpression.Operator.EQ, true);
+            SimpleExpression[] expressions = new SimpleExpression[]{agreed, haveDone};
+            LogicalExpression logical = new LogicalExpression(expressions, CriterionExpression.Operator.OR);
+            pageInfo.orExpression(logical);
+            return SPageUtils.covertSPage(purchaseApCheckService.findAllByPageInfo(pageInfo, null, filter));
+        }
+		com.uas.search.b2b.model.PageParams pageParams = distribute(params, searchFilter);
+        List<Object> objectList = new ArrayList<>();
+        objectList.add("已确认");
+        objectList.add("未对账");
+		pageParams.getFilters().put("pa_checkstatus", new MultiValue(objectList, true));
+		return searchService.searchPurchaseApCheckIds(filter.getKeyword(), pageParams);
+	}
+
+	/**
+	 * 作为卖家,获取应收对账单(不同意)
+     *
+     * @param params 分页参数
+     * @param searchFilter 搜索过滤条件
+     * @return SPage<PurchaseApCheck>
+	 */
+	@RequestMapping(value = "/info/search", params = RequestState.END, method = RequestMethod.GET)
+	public SPage<PurchaseApCheck> getEndApChecks(PageParams params, String searchFilter) {
+		LOGGER.log("应收对账单", "获取不同意,已作废应收对账单");
+        SearchFilter filter = JSONObject.parseObject(searchFilter, SearchFilter.class);
+        if (StringUtils.isEmpty(filter.getKeyword())) {
+            PageInfo pageInfo = new PageInfo(params);
+            pageInfo.filter("enUu", SystemSession.getUser().getEnterprise().getUu());
+            SearchFilter distribute = userService.distribute();
+            if (distribute != null && distribute.getDistribute() == null) {
+                return null;
+            }
+            if (distribute != null && !CollectionUtils.isEmpty(distribute.getDistribute())) {
+                filter.setDistribute(distribute.getDistribute());
+            }
+            SimpleExpression disAgreed = new SimpleExpression("checkStatus", "不同意", CriterionExpression.Operator.EQ, true);
+            SimpleExpression invalid = new SimpleExpression("checkStatus", "已作废", CriterionExpression.Operator.EQ, true);
+            SimpleExpression[] expressions = new SimpleExpression[]{disAgreed, invalid};
+            LogicalExpression logical = new LogicalExpression(expressions, CriterionExpression.Operator.OR);
+            pageInfo.orExpression(logical);
+            return SPageUtils.covertSPage(purchaseApCheckService.findAllByPageInfo(pageInfo, null, filter));
+        }
+		com.uas.search.b2b.model.PageParams pageParams = distribute(params, searchFilter);
+		List<Object> list = new ArrayList<>();
+		list.add("不同意");
+		list.add("已作废");
+		pageParams.getFilters().put("pa_checkstatus", new MultiValue(list, true));
+		return searchService.searchPurchaseApCheckIds(filter.getKeyword(), pageParams);
+	}
+
+    /**
+     * 设置客户分配条件等
+     *
+     * @param params 分页参数
+     * @param filter 过滤条件
+     * @return pageParams
+     * <pre>
+     *     @see com.uas.search.b2b.model.PageParams
+     * </pre>
+     */
+    private com.uas.search.b2b.model.PageParams distribute(PageParams params, String filter) {
+        com.uas.search.b2b.model.PageParams pageParams = searchService.convertPageParams(params, filter);
+        // 当前登录企业作为买家
+        pageParams.getFilters().put("pa_enuu", SystemSession.getUser().getEnterprise().getUu());
+        SearchFilter distribute = userService.distribute();
+        if (distribute != null && distribute.getDistribute() == null) {
+            return null;
+        }
+        if (distribute != null && !CollectionUtils.isEmpty(distribute.getDistribute())) {
+            List<Object> list = new ArrayList<>();
+            for (Object object : distribute.getDistribute()) {
+                list.add(object);
+            }
+            pageParams.getFilters().put("pa_custuu", new MultiValue(list, true));
+        }
+        // 排序条件
+        List<Sort> sortList = new ArrayList<>();
+        // 如果日期为空,设置的默认时间2000/1/1 1:1:1
+        sortList.add(new Sort("pa_recorddate", false, Type.INT, 946659661L));
+        sortList.add(new Sort("pa_id", false, Type.INT, 1L));
+        pageParams.getFilters().put(SearchConstants.SORT_KEY, sortList);
+        return pageParams;
+    }
+
+	/**
+	 * 导出 - 全部
+	 * 
+	 * @param searchFilter 过滤条件
+	 * @return ModelAndView
+	 */
+	@RequestMapping(value = "/xls/list", method = RequestMethod.GET)
+	public ModelAndView exportApCheck(String searchFilter) {
+		PageInfo pageInfo = new PageInfo(1, JxlsExcelView.MAX_SIZE, 0);
+		PageParams params = new PageParams(pageInfo);
+		SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy年MM月dd日");
+		ModelAndView modelAndView = new ModelAndView();
+		modelAndView.addObject("dateFormat", dateFormat);
+		modelAndView.addObject("state", "全部");
+		modelAndView.addObject("data", getPurchaseApChecks(params, searchFilter).getContent());
+		modelAndView.setView(new JxlsExcelView("classpath:jxls-tpl/fa/saleApCheck", "应收对账单列表_全部"));
+		LOGGER.log("应收对账单", "导出Excel列表", "导出全部Excel列表");
+		return modelAndView;
+	}
+
+	/**
+	 * 导出 - 已确认
+	 * 
+	 * @param searchFilter 过滤条件
+	 * @return ModelAndView
+	 */
+	@RequestMapping(value = "/xls/list", params = RequestState.DONE, method = RequestMethod.GET)
+	public ModelAndView exportApCheckDone(String searchFilter) {
+		PageInfo pageInfo = new PageInfo(1, JxlsExcelView.MAX_SIZE, 0);
+        PageParams params = new PageParams(pageInfo);
+		SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy年MM月dd日");
+		ModelAndView modelAndView = new ModelAndView();
+		modelAndView.addObject("dateFormat", dateFormat);
+		modelAndView.addObject("state", "已对账");
+		modelAndView.addObject("data", getDoneApChecks(params, searchFilter).getContent());
+		modelAndView.setView(new JxlsExcelView("classpath:jxls-tpl/fa/saleApCheck", "应收对账单列表_已对账"));
+		LOGGER.log("应收对账单", "导出Excel列表", "导出已对账Excel列表");
+		return modelAndView;
+	}
+
+	/**
+	 * 导出 - 未对账
+	 * 
+	 * @param searchFilter 过滤条件
+	 * @return ModelAndView
+	 */
+	@RequestMapping(value = "/xls/list", params = RequestState.TODO, method = RequestMethod.GET)
+	public ModelAndView exportApCheckTodo(String searchFilter) {
+		PageInfo pageInfo = new PageInfo(1, JxlsExcelView.MAX_SIZE, 0);
+        PageParams params = new PageParams(pageInfo);
+		SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy年MM月dd日");
+		ModelAndView modelAndView = new ModelAndView();
+		modelAndView.addObject("dateFormat", dateFormat);
+		modelAndView.addObject("state", "未对账");
+		modelAndView.addObject("data", getDoneApChecks(params, searchFilter).getContent());
+		modelAndView.setView(new JxlsExcelView("classpath:jxls-tpl/fa/saleApCheck", "应收对账单列表_未对账"));
+		LOGGER.log("应收对账单", "导出Excel列表", "导出未对账Excel列表");
+		return modelAndView;
+	}
+
+	/**
+	 * 导出 - 已做废
+	 * 
+	 * @param searchFilter 过滤条件
+	 * @return ModelAndView
+	 */
+	@RequestMapping(value = "/xls/list", params = RequestState.END, method = RequestMethod.GET)
+	public ModelAndView exportApChecks(String searchFilter) {
+		PageInfo pageInfo = new PageInfo(1, JxlsExcelView.MAX_SIZE, 0);
+        PageParams params = new PageParams(pageInfo);
+		SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy年MM月dd日");
+		ModelAndView modelAndView = new ModelAndView();
+		modelAndView.addObject("dateFormat", dateFormat);
+		modelAndView.addObject("state", "已作废");
+		modelAndView.addObject("data", getEndApChecks(params, searchFilter).getContent());
+		modelAndView.setView(new JxlsExcelView("classpath:jxls-tpl/fa/saleApCheck", "应收对账单列表_已作废"));
+		LOGGER.log("应收对账单", "导出Excel列表", "导出已做废Excel列表");
+		return modelAndView;
+	}
+
+	/**
+	 * 导出权限判断
+	 *
+	 * @return ModelMap success true : 有导出权限; 没有导出权限会被拦截
+	 */
+	@RequestMapping(value = "/xls/permission", method = RequestMethod.GET)
+	public ModelMap exportPermission() {
+		return new ModelMap("success", true);
+	}
+
+	/**
+	 * 全部导出
+	 * 
+	 * @param keyword 关键字
+     *                @see    ApcheckKeyWord
+	 * @param fromDate 开始日期
+	 * @param endDate 截止日期
+     * @param checkDate 对账月份
+	 * @return ModelAndView
+	 */
+	@RequestMapping(value = "/xls", method = RequestMethod.GET)
+	public ModelAndView export(ApcheckKeyWord keyword, Long fromDate, Long endDate, String checkDate) throws InterruptedException {
+		List<ErpProdIODetail> details = getAllApchecksByDate(fromDate, endDate, keyword, checkDate).getDetails();
+		ModelAndView modelAndView = new ModelAndView();
+		SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy年MM月dd日");
+		modelAndView.addObject("dateFormat", dateFormat);
+		modelAndView.addObject("data", details);
+        modelAndView.addObject("title", "客户应收对账单");
+		modelAndView.setView(new JxlsExcelView("classpath:jxls-tpl/fa/faApCheck", "客户应收对账单"));
+		LOGGER.log("客户应收对账单", "导出Excel列表", "导出全部Excel列表");
+		return modelAndView;
+	}
+
+	/**
+	 * 设置单据已读
+     *
+	 * @author wangmh
+	 */
+	@RequestMapping(value = "/setRead", method = RequestMethod.POST)
+	public void setReadByOrder(@RequestBody Long... sourceId) {
+        LOGGER.log("消息红点", "设置单据已读", "设置对账单已读: " + sourceId);
+        redDotService.setReadByIds(OrderType.apcheck.name(), sourceId);
+	}
+
+	/**
+	 * 获得未阅读单据id
+     *
+	 * @author wangmh
+     * @return ModelMap
+	 */
+	@RequestMapping(value = "/getUnreadIds", method = RequestMethod.GET)
+	public ModelMap getUnreadIds() {
+		List<Long> list = redDotService.getUnreadIds(OrderType.apcheck.name(), Role.SELLER);
+		return new ModelMap("content", list);
+	}
+
+	/**
+	 * 统计未阅读单据各个状态数量
+	 *
+	 * @return ModelMap
+	 * @author wangmh
+	 */
+	@RequestMapping(value = "/unread", method = RequestMethod.GET, headers = "Accept=application/json")
+	@ResponseStatus(value = HttpStatus.OK)
+	public ModelMap getOrderUnreadCount() {
+		final ModelMap modelMap = new ModelMap();
+		List<Object[]> idList = redDotService.getApCheckCount(Role.SELLER);
+		int all = 0;
+		for (Object[] objects : idList) {
+            String key = objects[1].toString();
+			int value = Integer.valueOf(objects[0].toString());
+			if ("已作废".equals(key)) {
+				key = "cancelled";
+				all = all + value;
+			} else if ("已确认".equals(key)) {
+				key = "replied";
+				all = all + value;
+			} else if ("未对账".equals(key)) {
+				key = "notReply";
+			}
+			modelMap.put(key, value);
+		}
+		modelMap.put("all", all);
+		return modelMap;
+	}
+
+    /**
+     * 通过id获取已开票数
+     *
+     * @param id id
+     * @return Double
+     */
+	@RequestMapping(value = "/getBilled", method = RequestMethod.GET)
+	public Double getBilled(Long id) {
+        LOGGER.log("应付发票", "通过id获取已开票数", "", "", id);
+        return purchaseApCheckService.getBilledByItemId(id);
+	}
+}