| | |
| | | @Component(CheckStandardManager.BEAN_ID) |
| | | public class CheckStandardManager { |
| | | |
| | | public static final String BEAN_ID = "check.checkStandardManager"; |
| | | public static final String BEAN_ID = "check.checkStandardManager"; |
| | | |
| | | @Autowired |
| | | private CoreCheckStandardService checkStandardService; |
| | | @Autowired |
| | | private CoreCheckStandardService checkStandardService; |
| | | |
| | | /** |
| | | * 根据参数获取化验项列表 |
| | | * |
| | | * @param checkId |
| | | * @param companyId |
| | | * @param foodVariety |
| | | * @return |
| | | */ |
| | | public List<CheckItemData> listCheckItem(String companyId, String checkId, |
| | | String foodVariety) { |
| | | if (StringUtils.isEmpty(companyId)) { |
| | | companyId = ContextUtil.getCompanyId(); |
| | | } |
| | | /** |
| | | * 根据参数获取化验项列表 |
| | | * |
| | | * @param checkId |
| | | * @param companyId |
| | | * @param foodVariety |
| | | * @return |
| | | */ |
| | | public List<CheckItemData> listCheckItem(String companyId, String checkId, |
| | | String foodVariety) { |
| | | if (StringUtils.isEmpty(companyId)) { |
| | | companyId = ContextUtil.getCompanyId(); |
| | | } |
| | | |
| | | List<CheckItemData> list = null; |
| | | if (null != checkId) |
| | | list = checkStandardService.getCheckItemById(checkId, companyId); |
| | | List<CheckItemData> list = null; |
| | | if (null != checkId) |
| | | list = checkStandardService.getCheckItemById(checkId, companyId); |
| | | |
| | | if (list == null || list.isEmpty()) { |
| | | list = checkStandardService.getCheckItemByStandard(companyId,checkId, foodVariety); |
| | | } |
| | | |
| | | return list; |
| | | } |
| | | if (list == null || list.isEmpty()) { |
| | | list = checkStandardService.getCheckItemByStandard(companyId, checkId, foodVariety); |
| | | } |
| | | |
| | | public CheckUpdateResult updateCheckItems(String checkId, String companyId, |
| | | List<CheckItemData> checkItems) { |
| | | return list; |
| | | } |
| | | |
| | | CheckUpdateResult result = new CheckUpdateResult(); |
| | | if (null == checkItems || checkItems.isEmpty()) { |
| | | return result; |
| | | } |
| | | if (StringUtils.isEmpty(companyId)) { |
| | | companyId = ContextUtil.getCompanyId(); |
| | | } |
| | | public CheckUpdateResult updateCheckItems(String checkId, String companyId, List<CheckItemData> checkItems) { |
| | | |
| | | for (CheckItemData item : checkItems) { |
| | | if (null == item.getCheckId()) { |
| | | item.setCheckId(checkId); |
| | | } |
| | | item.setCompanyId(companyId); |
| | | if (item.getUpperLimit() == null) { |
| | | item.setUpperLimit(0.0); |
| | | } |
| | | CheckUpdateResult result = new CheckUpdateResult(); |
| | | if (null == checkItems || checkItems.isEmpty()) { |
| | | return result; |
| | | } |
| | | if (StringUtils.isEmpty(companyId)) { |
| | | companyId = ContextUtil.getCompanyId(); |
| | | } |
| | | |
| | | if (null != item.getDeNum() && item.getDeNum() > 0) { |
| | | result.setDeSum(result.getDeSum() + item.getDeNum()); |
| | | } |
| | | if (null != item.getAddNum() && item.getAddNum() > 0) { |
| | | result.setAddSum(result.getAddSum() + item.getAddNum()); |
| | | } |
| | | if (null != item.getAddPrice() && item.getAddPrice() > 0) { |
| | | result.setAddPriceSum(result.getAddPriceSum() |
| | | + item.getAddPrice()); |
| | | } |
| | | if (null != item.getDePrice() && item.getDePrice() > 0) { |
| | | result.setDePriceSum(result.getDePriceSum() + item.getDePrice()); |
| | | } |
| | | for (CheckItemData item : checkItems) { |
| | | if (null == item.getCheckId()) { |
| | | item.setCheckId(checkId); |
| | | } |
| | | item.setCompanyId(companyId); |
| | | if (item.getUpperLimit() == null) { |
| | | item.setUpperLimit(0.0); |
| | | } |
| | | |
| | | // 先更新,更新失败则新增 |
| | | int i = checkStandardService.updateCheckItem(item); |
| | | if (i < 1) { |
| | | checkStandardService.insertCheckItem(item); |
| | | } |
| | | } |
| | | return result; |
| | | } |
| | | if (null != item.getDeNum() && item.getDeNum() > 0) { |
| | | result.setDeSum(result.getDeSum() + item.getDeNum()); |
| | | } |
| | | if (null != item.getAddNum() && item.getAddNum() > 0) { |
| | | result.setAddSum(result.getAddSum() + item.getAddNum()); |
| | | } |
| | | if (null != item.getAddPrice() && item.getAddPrice() > 0) { |
| | | result.setAddPriceSum(result.getAddPriceSum() |
| | | + item.getAddPrice()); |
| | | } |
| | | if (null != item.getDePrice() && item.getDePrice() > 0) { |
| | | result.setDePriceSum(result.getDePriceSum() + item.getDePrice()); |
| | | } |
| | | |
| | | //如果没有外键不执行持久化操作 |
| | | if (null == checkId) return result; |
| | | |
| | | // 先更新,更新失败则新增 |
| | | int i = checkStandardService.updateCheckItem(item); |
| | | if (i < 1) { |
| | | checkStandardService.insertCheckItem(item); |
| | | } |
| | | } |
| | | return result; |
| | | } |
| | | } |